From 050057d31561a4fdd1999c040e95e1583f7862b1 Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 26 Mar 2025 03:05:00 +1100 Subject: [PATCH] Update to Minecraft 1.21.5 --- nms-patches/net/minecraft/CrashReport.patch | 2 +- .../advancements/AdvancementTree.patch | 2 +- .../commands/CommandDispatcher.patch | 36 +- .../commands/CommandListenerWrapper.patch | 16 +- .../commands/arguments/ArgumentEntity.patch | 2 +- .../arguments/blocks/ArgumentBlock.patch | 15 +- .../selector/ArgumentParserSelector.patch | 9 - .../arguments/selector/EntitySelector.patch | 25 +- .../core/cauldron/CauldronInteraction.patch | 12 +- .../core/component/DataComponentPatch.patch | 24 +- .../core/dispenser/DispenseBehaviorBoat.patch | 4 +- .../dispenser/DispenseBehaviorShears.patch | 12 +- .../core/dispenser/IDispenseBehavior.patch | 249 ++++---- .../nbt/NBTCompressedStreamTools.patch | 2 +- .../minecraft/network/NetworkManager.patch | 24 +- .../network/PacketDataSerializer.patch | 57 +- .../network/chat/IChatBaseComponent.patch | 3 +- .../ServerboundCustomPayloadPacket.patch | 2 +- .../network/syncher/DataWatcher.patch | 8 +- .../server/AdvancementDataPlayer.patch | 4 +- .../server/AdvancementDataWorld.patch | 10 +- .../minecraft/server/CustomFunctionData.patch | 2 +- .../minecraft/server/DispenserRegistry.patch | 41 +- nms-patches/net/minecraft/server/Main.patch | 18 +- .../minecraft/server/MinecraftServer.patch | 129 ++--- .../minecraft/server/ScoreboardServer.patch | 55 +- .../server/bossevents/BossBattleCustom.patch | 14 +- .../server/commands/CommandDifficulty.patch | 2 +- .../server/commands/CommandEffect.patch | 14 +- .../server/commands/CommandGamerule.patch | 2 +- .../server/commands/CommandGive.patch | 10 +- .../server/commands/CommandLoot.patch | 11 +- .../server/commands/CommandReload.patch | 2 +- .../server/commands/CommandSchedule.patch | 2 +- .../server/commands/CommandSpawnpoint.patch | 10 +- .../commands/CommandSpreadPlayers.patch | 10 +- .../server/commands/CommandTeleport.patch | 4 +- .../server/commands/CommandTime.patch | 28 +- .../server/commands/PlaceCommand.patch | 2 +- .../server/dedicated/DedicatedServer.patch | 8 +- .../dedicated/DedicatedServerProperties.patch | 2 +- .../server/dedicated/PropertyManager.patch | 50 +- .../net/minecraft/server/gui/ServerGUI.patch | 9 - .../server/level/ChunkMapDistance.patch | 116 +--- .../server/level/ChunkProviderServer.patch | 38 +- .../minecraft/server/level/EntityPlayer.patch | 422 ++++++-------- .../server/level/EntityTrackerEntry.patch | 61 +- .../minecraft/server/level/PlayerChunk.patch | 19 +- .../server/level/PlayerChunkMap.patch | 40 +- .../server/level/PlayerInteractManager.patch | 44 +- .../net/minecraft/server/level/Ticket.patch | 18 + .../minecraft/server/level/TicketType.patch | 24 +- .../minecraft/server/level/WorldServer.patch | 144 ++--- .../server/network/HandshakeListener.patch | 10 +- .../server/network/LegacyPingHandler.patch | 22 +- .../server/network/PlayerConnection.patch | 535 +++++++++--------- .../server/network/ServerConnection.patch | 15 +- .../minecraft/server/players/JsonList.patch | 53 +- .../NameReferencingFileConverter.patch | 14 +- .../minecraft/server/players/PlayerList.patch | 192 +++---- .../server/players/SleepStatus.patch | 10 +- .../minecraft/server/players/UserCache.patch | 34 +- .../rcon/thread/RemoteControlSession.patch | 34 +- .../minecraft/stats/RecipeBookServer.patch | 10 +- .../stats/ServerStatisticManager.patch | 29 +- .../net/minecraft/util/SpawnUtil.patch | 2 +- .../util/datafix/DataConverterRegistry.patch | 83 +-- .../util/worldupdate/WorldUpgrader.patch | 17 +- .../net/minecraft/world/IInventory.patch | 18 +- .../world/InventorySubcontainer.patch | 6 +- .../world/effect/HealOrHarmMobEffect.patch | 10 +- .../world/effect/InfestedMobEffect.patch | 2 +- .../world/effect/OozingMobEffect.patch | 2 +- .../world/entity/ConversionType.patch | 22 +- .../net/minecraft/world/entity/Entity.patch | 261 +++++---- .../world/entity/EntityAgeable.patch | 18 +- .../world/entity/EntityAreaEffectCloud.patch | 46 +- .../world/entity/EntityCreature.patch | 2 +- .../world/entity/EntityExperienceOrb.patch | 55 +- .../world/entity/EntityInsentient.patch | 186 +++--- .../world/entity/EntityLightning.patch | 21 +- .../minecraft/world/entity/EntityLiving.patch | 406 ++++++++----- .../world/entity/EntityTameableAnimal.patch | 8 +- .../minecraft/world/entity/EntityTypes.patch | 51 +- .../world/entity/IEntityAngerable.patch | 33 +- .../world/entity/IEntitySelector.patch | 10 +- .../minecraft/world/entity/Interaction.patch | 28 +- .../minecraft/world/entity/Leashable.patch | 49 +- .../world/entity/SaddleStorage.patch | 10 +- .../entity/ai/behavior/BehaviorCareer.patch | 10 +- .../entity/ai/behavior/BehaviorFarm.patch | 30 +- .../entity/ai/behavior/BehaviorMakeLove.patch | 10 +- .../ai/behavior/BehaviorProfession.patch | 12 +- .../entity/ai/behavior/BehaviorUtil.patch | 20 - .../ai/behavior/PrepareRamNearestTarget.patch | 35 +- .../behavior/TryLaySpawnOnWaterNearLand.patch | 6 +- .../ai/goal/PathfinderGoalEatTile.patch | 8 +- .../entity/ai/goal/PathfinderGoalSit.patch | 11 - .../target/PathfinderGoalDefendVillage.patch | 11 +- .../target/PathfinderGoalHurtByTarget.patch | 4 +- .../ai/goal/target/PathfinderGoalTarget.patch | 2 +- .../world/entity/ai/gossip/Reputation.patch | 56 +- .../entity/ai/sensing/TemptingSensor.patch | 10 +- .../entity/ai/village/VillageSiege.patch | 4 +- .../world/entity/ambient/EntityBat.patch | 6 +- .../{EntityCow.patch => AbstractCow.patch} | 12 +- .../world/entity/animal/Bucketable.patch | 26 +- .../world/entity/animal/EntityAnimal.patch | 26 +- .../world/entity/animal/EntityBee.patch | 115 ++-- .../world/entity/animal/EntityCat.patch | 69 +-- .../world/entity/animal/EntityChicken.patch | 2 +- .../world/entity/animal/EntityDolphin.patch | 14 +- .../world/entity/animal/EntityFox.patch | 58 +- .../world/entity/animal/EntityIronGolem.patch | 2 +- .../entity/animal/EntityMushroomCow.patch | 26 +- .../world/entity/animal/EntityOcelot.patch | 4 +- .../world/entity/animal/EntityPanda.patch | 17 +- .../world/entity/animal/EntityParrot.patch | 19 +- .../world/entity/animal/EntityPig.patch | 8 +- .../entity/animal/EntityPufferFish.patch | 4 +- .../world/entity/animal/EntityRabbit.patch | 21 +- .../world/entity/animal/EntitySnowman.patch | 16 +- .../world/entity/animal/EntityTurtle.patch | 10 +- .../world/entity/animal/allay/Allay.patch | 33 +- .../entity/animal/armadillo/Armadillo.patch | 13 +- .../world/entity/animal/axolotl/Axolotl.patch | 31 +- .../world/entity/animal/camel/Camel.patch | 6 +- .../entity/animal/frog/ShootTongue.patch | 22 +- .../world/entity/animal/frog/Tadpole.patch | 4 +- .../world/entity/animal/goat/Goat.patch | 4 +- .../animal/horse/EntityHorseAbstract.patch | 110 +--- .../animal/horse/EntityHorseSkeleton.patch | 2 +- .../entity/animal/horse/EntityLlama.patch | 13 +- .../animal/horse/EntityLlamaTrader.patch | 6 +- .../horse/PathfinderGoalHorseTrap.patch | 2 +- .../animal/{ => sheep}/EntitySheep.patch | 15 +- .../world/entity/animal/sniffer/Sniffer.patch | 13 +- .../entity/animal/{ => wolf}/EntityWolf.patch | 57 +- .../boss/enderdragon/EntityEnderCrystal.patch | 15 +- .../boss/enderdragon/EntityEnderDragon.patch | 48 +- .../phases/DragonControllerLandedFlame.patch | 2 +- .../phases/DragonControllerManager.patch | 8 - .../entity/boss/wither/EntityWither.patch | 18 +- .../decoration/BlockAttachedEntity.patch | 11 +- .../entity/decoration/EntityArmorStand.patch | 59 +- .../entity/decoration/EntityItemFrame.patch | 6 +- .../world/entity/decoration/EntityLeash.patch | 14 +- .../entity/decoration/EntityPainting.patch | 4 +- .../entity/item/EntityFallingBlock.patch | 19 +- .../world/entity/item/EntityItem.patch | 31 +- .../world/entity/item/EntityTNTPrimed.patch | 34 +- .../world/entity/monster/Bogged.patch | 2 +- .../entity/monster/EntityCaveSpider.patch | 6 +- .../world/entity/monster/EntityCreeper.patch | 16 +- .../world/entity/monster/EntityEnderman.patch | 23 +- .../entity/monster/EntityEndermite.patch | 2 +- .../world/entity/monster/EntityEvoker.patch | 4 +- .../world/entity/monster/EntityGhast.patch | 2 +- .../entity/monster/EntityGuardianElder.patch | 2 +- .../monster/EntityIllagerIllusioner.patch | 4 +- .../entity/monster/EntityIllagerWizard.patch | 4 +- .../world/entity/monster/EntityPhantom.patch | 16 +- .../entity/monster/EntityPigZombie.patch | 6 +- .../world/entity/monster/EntityPillager.patch | 2 +- .../world/entity/monster/EntityRavager.patch | 4 +- .../world/entity/monster/EntityShulker.patch | 8 +- .../entity/monster/EntitySilverfish.patch | 4 +- .../world/entity/monster/EntitySkeleton.patch | 4 +- .../monster/EntitySkeletonAbstract.patch | 4 +- .../world/entity/monster/EntitySlime.patch | 8 +- .../world/entity/monster/EntityStrider.patch | 2 +- .../world/entity/monster/EntityVex.patch | 11 +- .../world/entity/monster/EntityWitch.patch | 4 +- .../world/entity/monster/EntityZombie.patch | 26 +- .../entity/monster/EntityZombieHusk.patch | 2 +- .../entity/monster/EntityZombieVillager.patch | 67 +-- .../world/entity/monster/breeze/Breeze.patch | 4 +- .../entity/monster/creaking/Creaking.patch | 11 +- .../entity/monster/hoglin/EntityHoglin.patch | 14 +- .../entity/monster/piglin/EntityPiglin.patch | 32 +- .../monster/piglin/EntityPiglinAbstract.patch | 4 +- .../entity/monster/piglin/PiglinAI.patch | 59 +- .../world/entity/monster/warden/Warden.patch | 27 +- .../world/entity/npc/EntityVillager.patch | 107 ++-- .../entity/npc/EntityVillagerAbstract.patch | 24 +- .../entity/npc/EntityVillagerTrader.patch | 44 +- .../world/entity/npc/MobSpawnerTrader.patch | 16 +- .../world/entity/player/EntityHuman.patch | 180 ++---- .../world/entity/player/PlayerInventory.patch | 40 +- .../world/entity/projectile/EntityArrow.patch | 55 +- .../projectile/EntityDragonFireball.patch | 4 +- .../world/entity/projectile/EntityEgg.patch | 36 +- .../entity/projectile/EntityEnderPearl.patch | 16 +- .../entity/projectile/EntityEnderSignal.patch | 18 +- .../entity/projectile/EntityEvokerFangs.patch | 15 +- .../projectile/EntityFireballFireball.patch | 16 - .../entity/projectile/EntityFireworks.patch | 14 +- .../entity/projectile/EntityFishingHook.patch | 92 +-- .../projectile/EntityLargeFireball.patch | 20 +- .../entity/projectile/EntityLlamaSpit.patch | 4 +- .../entity/projectile/EntityPotion.patch | 125 +--- .../EntityProjectileThrowable.patch | 2 +- .../projectile/EntityShulkerBullet.patch | 34 +- .../projectile/EntitySpectralArrow.patch | 2 +- .../projectile/EntityThrownExpBottle.patch | 2 +- .../projectile/EntityThrownTrident.patch | 13 +- .../entity/projectile/EntityTippedArrow.patch | 19 +- .../entity/projectile/EntityWitherSkull.patch | 14 +- .../world/entity/projectile/IProjectile.patch | 21 +- .../projectile/ThrownLingeringPotion.patch | 37 ++ .../projectile/ThrownSplashPotion.patch | 82 +++ .../world/entity/raid/EntityRaider.patch | 22 +- .../world/entity/raid/PersistentRaid.patch | 40 +- .../minecraft/world/entity/raid/Raid.patch | 88 +-- .../world/entity/vehicle/AbstractBoat.patch | 14 +- .../entity/vehicle/AbstractChestBoat.patch | 10 +- .../vehicle/EntityMinecartAbstract.patch | 31 +- .../vehicle/EntityMinecartContainer.patch | 12 +- .../entity/vehicle/EntityMinecartTNT.patch | 39 +- .../entity/vehicle/NewMinecartBehavior.patch | 24 +- .../entity/vehicle/OldMinecartBehavior.patch | 14 +- .../world/entity/vehicle/VehicleEntity.patch | 2 +- .../net/minecraft/world/food/FoodInfo.patch | 8 +- .../minecraft/world/food/FoodMetaData.patch | 11 +- .../minecraft/world/inventory/Container.patch | 117 ++-- .../world/inventory/ContainerAnvil.patch | 32 +- .../inventory/ContainerAnvilAbstract.patch | 11 +- .../world/inventory/ContainerBeacon.patch | 6 +- .../inventory/ContainerCartography.patch | 21 +- .../world/inventory/ContainerChest.patch | 2 +- .../inventory/ContainerEnchantTable.patch | 41 +- .../world/inventory/ContainerGrindstone.patch | 23 +- .../world/inventory/ContainerHorse.patch | 21 +- .../world/inventory/ContainerLectern.patch | 4 +- .../world/inventory/ContainerLoom.patch | 24 +- .../world/inventory/ContainerPlayer.patch | 9 - .../world/inventory/ContainerShulkerBox.patch | 4 +- .../world/inventory/ContainerSmithing.patch | 9 - .../inventory/ContainerStonecutter.patch | 19 +- .../world/inventory/ContainerWorkbench.patch | 2 +- .../world/inventory/Containers.patch | 14 + .../inventory/InventoryCraftResult.patch | 4 +- .../world/inventory/InventoryMerchant.patch | 6 +- .../TransientCraftingContainer.patch | 4 +- .../minecraft/world/item/ItemArmorStand.patch | 6 +- .../net/minecraft/world/item/ItemBlock.patch | 22 +- .../world/item/ItemBlockWallable.patch | 15 +- .../net/minecraft/world/item/ItemBoat.patch | 34 +- .../net/minecraft/world/item/ItemBucket.patch | 42 +- .../net/minecraft/world/item/ItemEgg.patch | 12 +- .../minecraft/world/item/ItemEndCrystal.patch | 2 +- .../minecraft/world/item/ItemEnderEye.patch | 4 +- .../minecraft/world/item/ItemEnderPearl.patch | 6 +- .../minecraft/world/item/ItemFireball.patch | 6 +- .../minecraft/world/item/ItemFishingRod.patch | 12 +- .../world/item/ItemFlintAndSteel.patch | 6 +- .../minecraft/world/item/ItemHanging.patch | 25 +- .../net/minecraft/world/item/ItemLeash.patch | 23 +- .../minecraft/world/item/ItemMinecart.patch | 4 +- .../minecraft/world/item/ItemMonsterEgg.patch | 16 +- .../minecraft/world/item/ItemSnowball.patch | 8 +- .../net/minecraft/world/item/ItemStack.patch | 105 +--- .../minecraft/world/item/ItemTrident.patch | 14 +- .../net/minecraft/world/item/MaceItem.patch | 12 +- .../minecraft/world/item/MobBucketItem.patch | 6 +- .../world/item/alchemy/PotionContents.patch | 13 +- .../item/component/DeathProtection.patch | 8 +- .../component/SuspiciousStewEffects.patch | 13 +- .../ApplyStatusEffectsConsumeEffect.patch | 9 +- .../item/consume_effects/ConsumeEffect.patch | 9 + .../RemoveStatusEffectsConsumeEffect.patch | 9 +- .../TeleportRandomlyConsumeEffect.patch | 6 +- .../world/item/crafting/CraftingManager.patch | 21 +- .../world/item/crafting/IRecipe.patch | 2 +- .../world/item/crafting/RecipeMap.patch | 19 +- .../crafting/SmithingTransformRecipe.patch | 9 +- .../item/crafting/SmithingTrimRecipe.patch | 13 +- .../world/item/crafting/TransmuteRecipe.patch | 11 +- .../enchantment/effects/ReplaceDisk.patch | 4 +- .../level/CommandBlockListenerAbstract.patch | 4 +- .../net/minecraft/world/level/GameRules.patch | 169 +++--- .../world/level/GeneratorAccess.patch | 4 +- .../minecraft/world/level/IBlockAccess.patch | 15 +- .../world/level/MobSpawnerAbstract.patch | 6 +- .../world/level/ServerExplosion.patch | 45 +- .../world/level/SpawnerCreature.patch | 57 +- .../minecraft/world/level/TicketStorage.patch | 58 ++ .../net/minecraft/world/level/World.patch | 56 +- .../world/level/block/BigDripleafBlock.patch | 17 +- .../minecraft/world/level/block/Block.patch | 24 +- .../world/level/block/BlockBamboo.patch | 6 +- .../level/block/BlockBambooSapling.patch | 2 +- .../world/level/block/BlockBed.patch | 10 +- .../world/level/block/BlockBeehive.patch | 20 +- .../world/level/block/BlockBell.patch | 4 +- .../level/block/BlockButtonAbstract.patch | 8 +- .../world/level/block/BlockCactus.patch | 22 +- .../world/level/block/BlockCake.patch | 2 +- .../world/level/block/BlockCampfire.patch | 6 +- .../world/level/block/BlockCauldron.patch | 17 +- .../world/level/block/BlockChest.patch | 28 +- .../world/level/block/BlockChorusFlower.patch | 12 +- .../world/level/block/BlockCocoa.patch | 8 +- .../world/level/block/BlockComposter.patch | 37 +- .../level/block/BlockConcretePowder.patch | 12 +- .../world/level/block/BlockCoralPlant.patch | 2 +- .../world/level/block/BlockCrops.patch | 16 +- .../level/block/BlockDaylightDetector.patch | 2 +- .../level/block/BlockDiodeAbstract.patch | 2 +- .../world/level/block/BlockDispenser.patch | 6 +- .../world/level/block/BlockDoor.patch | 6 +- .../world/level/block/BlockEndGateway.patch | 4 +- .../world/level/block/BlockEnderPortal.patch | 14 +- .../world/level/block/BlockFenceGate.patch | 2 +- .../world/level/block/BlockFire.patch | 128 ++--- .../world/level/block/BlockFireAbstract.patch | 11 +- .../world/level/block/BlockFlowerPot.patch | 6 +- .../world/level/block/BlockLeaves.patch | 6 +- .../world/level/block/BlockLectern.patch | 16 - .../world/level/block/BlockLever.patch | 6 +- .../level/block/BlockMinecartDetector.patch | 9 +- .../world/level/block/BlockMobSpawner.patch | 5 +- .../world/level/block/BlockMonsterEggs.patch | 6 +- .../world/level/block/BlockMushroom.patch | 8 +- .../world/level/block/BlockNetherWart.patch | 2 +- .../world/level/block/BlockPortal.patch | 8 +- .../block/BlockPressurePlateAbstract.patch | 4 +- .../level/block/BlockPumpkinCarved.patch | 10 +- .../level/block/BlockRedstoneComparator.patch | 12 +- .../level/block/BlockRedstoneTorch.patch | 6 +- .../world/level/block/BlockReed.patch | 6 +- .../level/block/BlockRespawnAnchor.patch | 24 +- .../world/level/block/BlockSapling.patch | 12 +- .../world/level/block/BlockScaffolding.patch | 2 +- .../world/level/block/BlockSign.patch | 6 +- .../world/level/block/BlockSnow.patch | 2 +- .../world/level/block/BlockSoil.patch | 14 +- .../world/level/block/BlockSponge.patch | 20 +- .../world/level/block/BlockStem.patch | 8 +- .../level/block/BlockSweetBerryBush.patch | 18 +- .../world/level/block/BlockTNT.patch | 46 +- .../world/level/block/BlockTallPlant.patch | 2 +- .../world/level/block/BlockTrapdoor.patch | 6 +- .../world/level/block/BlockTripwire.patch | 27 +- .../world/level/block/BlockTripwireHook.patch | 8 +- .../world/level/block/BlockTurtleEgg.patch | 18 +- .../world/level/block/BlockVine.patch | 16 +- .../world/level/block/BlockWaterLily.patch | 10 +- .../world/level/block/BlockWitherRose.patch | 2 +- .../world/level/block/BlockWitherSkull.patch | 16 +- .../world/level/block/CaveVines.patch | 9 +- .../level/block/ChangeOverTimeBlock.patch | 2 +- .../world/level/block/CrafterBlock.patch | 22 +- .../world/level/block/DecoratedPotBlock.patch | 4 +- .../world/level/block/EyeblossomBlock.patch | 2 +- .../level/block/LayeredCauldronBlock.patch | 10 +- .../world/level/block/MultifaceSpreader.patch | 22 +- .../level/block/PointedDripstoneBlock.patch | 32 +- .../world/level/block/PowderSnowBlock.patch | 24 +- .../world/level/block/SculkBlock.patch | 6 +- .../world/level/block/SculkSensorBlock.patch | 11 +- .../level/block/SculkShriekerBlock.patch | 2 +- .../world/level/block/SculkSpreader.patch | 31 +- .../world/level/block/SculkVeinBlock.patch | 8 +- ...BlockPlant.patch => VegetationBlock.patch} | 8 +- .../level/block/WallHangingSignBlock.patch | 2 +- .../block/entity/BrushableBlockEntity.patch | 48 +- .../entity/ChiseledBookShelfBlockEntity.patch | 11 +- .../entity/ContainerOpenersCounter.patch | 12 +- .../block/entity/CrafterBlockEntity.patch | 12 +- .../entity/DecoratedPotBlockEntity.patch | 2 +- .../entity/SculkCatalystBlockEntity.patch | 4 +- .../entity/TestInstanceBlockEntity.patch | 26 + .../world/level/block/entity/TileEntity.patch | 54 +- .../level/block/entity/TileEntityBanner.patch | 38 +- .../level/block/entity/TileEntityBarrel.patch | 2 +- .../level/block/entity/TileEntityBeacon.patch | 94 ++- .../block/entity/TileEntityBeehive.patch | 76 ++- .../level/block/entity/TileEntityBell.patch | 11 +- .../block/entity/TileEntityBrewingStand.patch | 20 +- .../block/entity/TileEntityCampfire.patch | 8 +- .../level/block/entity/TileEntityChest.patch | 6 +- .../block/entity/TileEntityCommand.patch | 6 +- .../block/entity/TileEntityConduit.patch | 25 +- .../block/entity/TileEntityContainer.patch | 2 +- .../block/entity/TileEntityDispenser.patch | 2 +- .../block/entity/TileEntityEndGateway.patch | 21 +- .../block/entity/TileEntityFurnace.patch | 40 +- .../level/block/entity/TileEntityHopper.patch | 12 +- .../block/entity/TileEntityJukeBox.patch | 6 +- .../block/entity/TileEntityLectern.patch | 26 +- .../block/entity/TileEntityShulkerBox.patch | 14 +- .../level/block/entity/TileEntitySign.patch | 45 +- .../level/block/entity/TileEntityTypes.patch | 18 +- .../entity/trialspawner/TrialSpawner.patch | 40 +- .../trialspawner/TrialSpawnerData.patch | 4 +- .../block/entity/vault/VaultBlockEntity.patch | 56 +- .../block/entity/vault/VaultServerData.patch | 11 - .../block/grower/WorldGenTreeProvider.patch | 12 +- .../level/block/piston/BlockPiston.patch | 12 +- .../world/level/block/state/BlockBase.patch | 16 +- .../world/level/border/WorldBorder.patch | 8 +- .../minecraft/world/level/chunk/Chunk.patch | 55 +- .../world/level/chunk/ChunkGenerator.patch | 21 +- .../world/level/chunk/ChunkSection.patch | 4 +- .../world/level/chunk/IChunkAccess.patch | 10 +- .../level/chunk/storage/IChunkLoader.patch | 16 +- .../level/chunk/storage/RegionFile.patch | 14 +- .../level/chunk/storage/RegionFileCache.patch | 12 +- .../chunk/storage/SerializableChunkData.patch | 115 ++-- .../dimension/end/EnderDragonBattle.patch | 12 +- .../dimension/end/EnumDragonRespawn.patch | 20 +- .../world/level/entity/EntityAccess.patch | 6 +- .../PersistentEntitySectionManager.patch | 34 +- .../level/gameevent/GameEventDispatcher.patch | 6 +- .../vibrations/VibrationSystem.patch | 43 +- .../level/levelgen/MobSpawnerPatrol.patch | 2 +- .../level/levelgen/MobSpawnerPhantom.patch | 14 +- .../levelgen/feature/EndPlatformFeature.patch | 14 +- .../structure/PersistentStructureLegacy.patch | 33 +- .../levelgen/structure/StructurePiece.patch | 44 +- .../levelgen/structure/StructureStart.patch | 14 +- .../structures/DesertPyramidStructure.patch | 2 +- .../structure/structures/EndCityPieces.patch | 2 +- .../structures/MineshaftPieces.patch | 41 +- .../structures/NetherFortressPieces.patch | 12 +- .../structures/OceanRuinPieces.patch | 4 +- .../structures/ShipwreckPieces.patch | 2 +- .../structures/StrongholdPieces.patch | 14 +- .../structure/structures/SwampHutPiece.patch | 8 +- .../templatesystem/DefinedStructure.patch | 45 +- .../level/material/FluidTypeFlowing.patch | 12 +- .../world/level/material/FluidTypeLava.patch | 44 +- .../level/portal/PortalTravelAgent.patch | 46 +- .../DefaultRedstoneWireEvaluator.patch | 4 +- .../ExperimentalRedstoneWireEvaluator.patch | 16 +- .../level/redstone/NeighborUpdater.patch | 7 +- .../world/level/saveddata/maps/WorldMap.patch | 173 +++--- .../world/level/storage/Convertable.patch | 15 +- .../world/level/storage/WorldDataServer.patch | 24 +- .../level/storage/loot/LootDataType.patch | 2 +- .../world/level/storage/loot/LootTable.patch | 12 +- pom.xml | 32 +- .../org/bukkit/craftbukkit/CraftChunk.java | 4 +- .../craftbukkit/CraftEquipmentSlot.java | 1 + .../craftbukkit/CraftOfflinePlayer.java | 39 +- .../org/bukkit/craftbukkit/CraftParticle.java | 1 + .../org/bukkit/craftbukkit/CraftRaid.java | 5 +- .../craftbukkit/CraftRegionAccessor.java | 15 +- .../org/bukkit/craftbukkit/CraftRegistry.java | 15 + .../org/bukkit/craftbukkit/CraftServer.java | 8 +- .../org/bukkit/craftbukkit/CraftWorld.java | 46 +- .../java/org/bukkit/craftbukkit/Main.java | 8 +- .../bukkit/craftbukkit/block/CraftBeacon.java | 9 +- .../bukkit/craftbukkit/block/CraftBlock.java | 4 +- .../craftbukkit/block/CraftBlockStates.java | 4 + .../craftbukkit/block/CraftContainer.java | 9 +- .../block/CraftCreatureSpawner.java | 22 +- .../craftbukkit/block/CraftTestBlock.java | 27 + .../craftbukkit/block/CraftTestInstance.java | 27 + .../block/CraftTrialSpawnerConfiguration.java | 58 +- .../block/data/CraftBlockData.java | 8 +- .../block/data/type/CraftCreakingHeart.java | 16 +- ...aftPinkPetals.java => CraftFlowerBed.java} | 4 +- .../block/data/type/CraftLeafLitter.java | 24 + .../block/data/type/CraftTestBlock.java | 19 + .../block/impl/CraftCreakingHeart.java | 16 +- ...aftPinkPetals.java => CraftFlowerBed.java} | 12 +- .../block/impl/CraftLeafLitter.java | 53 ++ .../craftbukkit/block/impl/CraftTest.java | 29 + ...es.java => CraftTintedParticleLeaves.java} | 12 +- .../impl/CraftUntintedParticleLeaves.java | 54 ++ .../entity/CraftAbstractArrow.java | 2 +- .../craftbukkit/entity/CraftAbstractCow.java | 11 + .../entity/CraftAbstractHorse.java | 7 +- .../craftbukkit/entity/CraftArmorStand.java | 6 +- .../craftbukkit/entity/CraftChicken.java | 48 ++ .../bukkit/craftbukkit/entity/CraftCow.java | 50 +- .../craftbukkit/entity/CraftEntity.java | 6 +- .../entity/CraftEntityFactory.java | 2 +- .../entity/CraftEntitySnapshot.java | 2 +- .../craftbukkit/entity/CraftEntityTypes.java | 21 +- .../entity/CraftExperienceOrb.java | 4 +- .../bukkit/craftbukkit/entity/CraftFox.java | 9 +- .../bukkit/craftbukkit/entity/CraftFrog.java | 2 +- .../bukkit/craftbukkit/entity/CraftHorse.java | 3 +- .../craftbukkit/entity/CraftHumanEntity.java | 4 +- .../entity/CraftLingeringPotion.java | 12 + .../craftbukkit/entity/CraftLivingEntity.java | 18 +- .../bukkit/craftbukkit/entity/CraftLlama.java | 3 +- .../craftbukkit/entity/CraftMinecart.java | 12 +- .../entity/CraftMinecartMobSpawner.java | 4 +- .../craftbukkit/entity/CraftMinecartTNT.java | 2 +- .../craftbukkit/entity/CraftMushroomCow.java | 2 +- .../bukkit/craftbukkit/entity/CraftPig.java | 52 +- .../craftbukkit/entity/CraftPlayer.java | 39 +- .../craftbukkit/entity/CraftRaider.java | 2 +- .../craftbukkit/entity/CraftSalmon.java | 2 +- .../bukkit/craftbukkit/entity/CraftSheep.java | 2 +- .../craftbukkit/entity/CraftSplashPotion.java | 12 + .../craftbukkit/entity/CraftStrider.java | 5 +- .../entity/CraftTameableAnimal.java | 11 +- .../craftbukkit/entity/CraftThrownPotion.java | 2 +- .../craftbukkit/entity/CraftVillager.java | 47 +- .../entity/CraftVillagerZombie.java | 10 +- .../bukkit/craftbukkit/entity/CraftWolf.java | 4 +- .../craftbukkit/event/CraftEventFactory.java | 24 +- .../craftbukkit/generator/CraftChunkData.java | 3 +- .../generator/CustomChunkGenerator.java | 10 - .../inventory/CraftEntityEquipment.java | 12 +- .../inventory/CraftInventoryPlayer.java | 20 +- .../inventory/CraftItemFactory.java | 5 + .../craftbukkit/inventory/CraftItemFlag.java | 62 ++ .../craftbukkit/inventory/CraftItemMetas.java | 2 +- .../craftbukkit/inventory/CraftItemStack.java | 7 +- .../inventory/CraftMerchantRecipe.java | 6 +- .../craftbukkit/inventory/CraftMetaArmor.java | 7 +- .../inventory/CraftMetaArmorStand.java | 4 +- .../inventory/CraftMetaAxolotlBucket.java | 21 +- .../inventory/CraftMetaBlockState.java | 22 +- .../inventory/CraftMetaEnchantedBook.java | 3 - .../inventory/CraftMetaEntityTag.java | 6 +- .../craftbukkit/inventory/CraftMetaItem.java | 304 +++++++--- .../inventory/CraftMetaLeatherArmor.java | 7 +- .../inventory/CraftMetaMusicInstrument.java | 12 +- .../inventory/CraftMetaPotion.java | 45 +- .../craftbukkit/inventory/CraftMetaSkull.java | 24 +- .../inventory/CraftMetaSpawnEgg.java | 6 +- .../CraftMetaTropicalFishBucket.java | 21 +- .../craftbukkit/inventory/CraftRecipe.java | 14 + .../CraftSmithingTransformRecipe.java | 2 +- .../inventory/CraftSmithingTrimRecipe.java | 10 +- .../inventory/CraftTransmuteRecipe.java | 9 +- .../CraftBlocksAttacksComponent.java | 429 ++++++++++++++ .../components/CraftEquippableComponent.java | 35 +- .../components/CraftJukeboxComponent.java | 20 +- .../components/CraftToolComponent.java | 24 +- .../components/CraftWeaponComponent.java | 96 ++++ .../inventory/util/CraftMenus.java | 2 +- .../craftbukkit/legacy/CraftLegacy.java | 7 +- .../craftbukkit/legacy/FieldRename.java | 2 +- .../CraftPersistentDataContainer.java | 2 +- .../CraftPersistentDataTypeRegistry.java | 26 +- .../bukkit/craftbukkit/util/ApiVersion.java | 4 +- .../bukkit/craftbukkit/util/Commodore.java | 8 +- .../craftbukkit/util/CraftChatMessage.java | 15 +- .../craftbukkit/util/CraftMagicNumbers.java | 2 +- .../util/CraftNBTTagConfigSerializer.java | 20 +- .../util/DelegatedGeneratorAccess.java | 375 ++++++------ .../util/DummyGeneratorAccess.java | 4 +- src/test/java/org/bukkit/ChatTest.java | 6 +- .../craftbukkit/entity/EntityTypesTest.java | 8 +- .../inventory/PlayerInventoryTest.java | 25 +- .../bukkit/craftbukkit/legacy/LegacyTest.java | 2 + .../java/org/bukkit/entity/VillagerTest.java | 2 + .../provider/RegistriesArgumentProvider.java | 17 +- 556 files changed, 7427 insertions(+), 6656 deletions(-) create mode 100644 nms-patches/net/minecraft/server/level/Ticket.patch delete mode 100644 nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.patch rename nms-patches/net/minecraft/world/entity/animal/{EntityCow.patch => AbstractCow.patch} (78%) rename nms-patches/net/minecraft/world/entity/animal/{ => sheep}/EntitySheep.patch (85%) rename nms-patches/net/minecraft/world/entity/animal/{ => wolf}/EntityWolf.patch (69%) delete mode 100644 nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch create mode 100644 nms-patches/net/minecraft/world/entity/projectile/ThrownLingeringPotion.patch create mode 100644 nms-patches/net/minecraft/world/entity/projectile/ThrownSplashPotion.patch create mode 100644 nms-patches/net/minecraft/world/level/TicketStorage.patch delete mode 100644 nms-patches/net/minecraft/world/level/block/BlockLectern.patch rename nms-patches/net/minecraft/world/level/block/{BlockPlant.patch => VegetationBlock.patch} (85%) create mode 100644 nms-patches/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.patch delete mode 100644 nms-patches/net/minecraft/world/level/block/entity/vault/VaultServerData.patch create mode 100644 src/main/java/org/bukkit/craftbukkit/block/CraftTestBlock.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/CraftTestInstance.java rename src/main/java/org/bukkit/craftbukkit/block/data/type/{CraftPinkPetals.java => CraftFlowerBed.java} (80%) create mode 100644 src/main/java/org/bukkit/craftbukkit/block/data/type/CraftLeafLitter.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTestBlock.java rename src/main/java/org/bukkit/craftbukkit/block/impl/{CraftPinkPetals.java => CraftFlowerBed.java} (70%) create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftLeafLitter.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftTest.java rename src/main/java/org/bukkit/craftbukkit/block/impl/{CraftParticleLeaves.java => CraftTintedParticleLeaves.java} (70%) create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftUntintedParticleLeaves.java create mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractCow.java create mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftLingeringPotion.java create mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftSplashPotion.java create mode 100644 src/main/java/org/bukkit/craftbukkit/inventory/components/CraftBlocksAttacksComponent.java create mode 100644 src/main/java/org/bukkit/craftbukkit/inventory/components/CraftWeaponComponent.java diff --git a/nms-patches/net/minecraft/CrashReport.patch b/nms-patches/net/minecraft/CrashReport.patch index 0c5cb0b08..a7f8497d6 100644 --- a/nms-patches/net/minecraft/CrashReport.patch +++ b/nms-patches/net/minecraft/CrashReport.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/CrashReport.java +++ b/net/minecraft/CrashReport.java -@@ -36,6 +36,7 @@ +@@ -35,6 +35,7 @@ public CrashReport(String s, Throwable throwable) { this.title = s; this.exception = throwable; diff --git a/nms-patches/net/minecraft/advancements/AdvancementTree.patch b/nms-patches/net/minecraft/advancements/AdvancementTree.patch index a09551dba..28b41d2bc 100644 --- a/nms-patches/net/minecraft/advancements/AdvancementTree.patch +++ b/nms-patches/net/minecraft/advancements/AdvancementTree.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/advancements/AdvancementTree.java +++ b/net/minecraft/advancements/AdvancementTree.java -@@ -77,7 +77,7 @@ +@@ -69,7 +69,7 @@ } } diff --git a/nms-patches/net/minecraft/commands/CommandDispatcher.patch b/nms-patches/net/minecraft/commands/CommandDispatcher.patch index 8f5612fb5..953a18d94 100644 --- a/nms-patches/net/minecraft/commands/CommandDispatcher.patch +++ b/nms-patches/net/minecraft/commands/CommandDispatcher.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/CommandDispatcher.java +++ b/net/minecraft/commands/CommandDispatcher.java -@@ -139,6 +139,14 @@ +@@ -138,6 +138,14 @@ import net.minecraft.world.level.GameRules; import org.slf4j.Logger; @@ -15,7 +15,7 @@ public class CommandDispatcher { private static final ThreadLocal> CURRENT_EXECUTION_CONTEXT = new ThreadLocal(); -@@ -151,6 +159,7 @@ +@@ -150,6 +158,7 @@ private final com.mojang.brigadier.CommandDispatcher dispatcher = new com.mojang.brigadier.CommandDispatcher(); public CommandDispatcher(CommandDispatcher.ServerType commanddispatcher_servertype, CommandBuildContext commandbuildcontext) { @@ -23,7 +23,7 @@ CommandAdvancement.register(this.dispatcher); CommandAttribute.register(this.dispatcher, commandbuildcontext); CommandExecute.register(this.dispatcher, commandbuildcontext); -@@ -252,6 +261,11 @@ +@@ -251,6 +260,11 @@ CommandPublish.register(this.dispatcher); } @@ -35,7 +35,7 @@ this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer()); } -@@ -262,18 +276,65 @@ +@@ -261,18 +275,65 @@ return new ParseResults(commandcontextbuilder1, parseresults.getReader(), parseresults.getExceptions()); } @@ -103,7 +103,7 @@ try { if (contextchain != null) { -@@ -307,7 +368,7 @@ +@@ -306,7 +367,7 @@ } @Nullable @@ -112,16 +112,16 @@ try { validateParseResults(parseresults); return (ContextChain) ContextChain.tryFlatten(parseresults.getContext().build(s)).orElseThrow(() -> { -@@ -318,7 +379,7 @@ +@@ -317,7 +378,7 @@ if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) { int i = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor()); IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.empty().withStyle(EnumChatFormat.GRAY).withStyle((chatmodifier) -> { -- return chatmodifier.withClickEvent(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, "/" + s)); -+ return chatmodifier.withClickEvent(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, label)); // CraftBukkit +- return chatmodifier.withClickEvent(new ChatClickable.SuggestCommand("/" + s)); ++ return chatmodifier.withClickEvent(new ChatClickable.SuggestCommand("/" + label)); // CraftBukkit }); if (i > 10) { -@@ -368,7 +429,7 @@ +@@ -367,7 +428,7 @@ executioncontext1.close(); } finally { @@ -130,7 +130,7 @@ } } else { consumer.accept(executioncontext); -@@ -377,11 +438,36 @@ +@@ -376,18 +437,43 @@ } public void sendCommands(EntityPlayer entityplayer) { @@ -168,16 +168,15 @@ entityplayer.connection.send(new PacketPlayOutCommands(rootcommandnode)); } -@@ -392,7 +478,7 @@ - CommandNode commandnode2 = (CommandNode) iterator.next(); - + private void fillUsableCommands(CommandNode commandnode, CommandNode commandnode1, CommandListenerWrapper commandlistenerwrapper, Map, CommandNode> map) { + for (CommandNode commandnode2 : commandnode.getChildren()) { if (commandnode2.canUse(commandlistenerwrapper)) { - ArgumentBuilder argumentbuilder = commandnode2.createBuilder(); + ArgumentBuilder argumentbuilder = commandnode2.createBuilder(); // CraftBukkit - decompile error argumentbuilder.requires((icompletionprovider) -> { return true; -@@ -415,7 +501,7 @@ +@@ -410,7 +496,7 @@ argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect())); } @@ -186,12 +185,3 @@ map.put(commandnode2, commandnode3); commandnode1.addChild(commandnode3); -@@ -481,7 +567,7 @@ - } - - private HolderLookup.b.a createLookup(final HolderLookup.b holderlookup_b) { -- return new HolderLookup.b.a(this) { -+ return new HolderLookup.b.a() { // CraftBukkit - decompile error - @Override - public HolderLookup.b parent() { - return holderlookup_b; diff --git a/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch b/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch index 940733b49..c42afc6f2 100644 --- a/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch +++ b/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/CommandListenerWrapper.java +++ b/net/minecraft/commands/CommandListenerWrapper.java -@@ -46,6 +46,8 @@ +@@ -44,6 +44,8 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; @@ -9,7 +9,7 @@ public class CommandListenerWrapper implements ExecutionCommandSource, ICompletionProvider { public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(IChatBaseComponent.translatable("permissions.requires.player")); -@@ -65,6 +67,7 @@ +@@ -63,6 +65,7 @@ private final Vec2F rotation; private final CommandSigningContext signingContext; private final TaskChainer chatMessageChainer; @@ -17,7 +17,7 @@ public CommandListenerWrapper(ICommandListener icommandlistener, Vec3D vec3d, Vec2F vec2f, WorldServer worldserver, int i, String s, IChatBaseComponent ichatbasecomponent, MinecraftServer minecraftserver, @Nullable Entity entity) { this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, CommandResultCallback.EMPTY, ArgumentAnchor.Anchor.FEET, CommandSigningContext.ANONYMOUS, TaskChainer.immediate(minecraftserver)); -@@ -171,9 +174,23 @@ +@@ -169,9 +172,23 @@ @Override public boolean hasPermission(int i) { @@ -41,16 +41,16 @@ public Vec3D getPosition() { return this.worldPosition; } -@@ -302,7 +319,7 @@ - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); +@@ -296,7 +313,7 @@ + if (this.server.getGameRules().getBoolean(GameRules.RULE_SENDCOMMANDFEEDBACK)) { + for (EntityPlayer entityplayer : this.server.getPlayerList().getPlayers()) { - if (entityplayer.commandSource() != this.source && this.server.getPlayerList().isOp(entityplayer.getGameProfile())) { + if (entityplayer.commandSource() != this.source && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit - entityplayer.sendSystemMessage(ichatmutablecomponent); + entityplayer.sendSystemMessage(ichatbasecomponent1); } } -@@ -400,4 +417,10 @@ +@@ -394,4 +411,10 @@ public boolean isSilent() { return this.silent; } diff --git a/nms-patches/net/minecraft/commands/arguments/ArgumentEntity.patch b/nms-patches/net/minecraft/commands/arguments/ArgumentEntity.patch index 9f83ef913..fa860e022 100644 --- a/nms-patches/net/minecraft/commands/arguments/ArgumentEntity.patch +++ b/nms-patches/net/minecraft/commands/arguments/ArgumentEntity.patch @@ -10,7 +10,7 @@ + + public EntitySelector parse(StringReader stringreader, boolean flag, boolean overridePermissions) throws CommandSyntaxException { + // CraftBukkit end - boolean flag1 = false; + int i = 0; ArgumentParserSelector argumentparserselector = new ArgumentParserSelector(stringreader, flag); - EntitySelector entityselector = argumentparserselector.parse(); + EntitySelector entityselector = argumentparserselector.parse(overridePermissions); // CraftBukkit diff --git a/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch b/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch index 09c530635..1e517c453 100644 --- a/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch +++ b/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/blocks/ArgumentBlock.java +++ b/net/minecraft/commands/arguments/blocks/ArgumentBlock.java -@@ -67,7 +67,7 @@ +@@ -65,7 +65,7 @@ private final StringReader reader; private final boolean forTesting; private final boolean allowNbt; @@ -9,16 +9,7 @@ private final Map vagueProperties = Maps.newHashMap(); private MinecraftKey id = MinecraftKey.withDefaultNamespace(""); @Nullable -@@ -275,7 +275,7 @@ - Iterator iterator = iblockstate.getPossibleValues().iterator(); - - while (iterator.hasNext()) { -- T t0 = (Comparable) iterator.next(); -+ T t0 = (T) iterator.next(); // CraftBukkit - decompile error - - if (t0 instanceof Integer integer) { - suggestionsbuilder.suggest(integer); -@@ -545,7 +545,7 @@ +@@ -516,7 +516,7 @@ Optional optional = iblockstate.getValue(s); if (optional.isPresent()) { @@ -27,7 +18,7 @@ this.properties.put(iblockstate, (Comparable) optional.get()); } else { this.reader.setCursor(i); -@@ -581,7 +581,7 @@ +@@ -551,7 +551,7 @@ private static > void appendProperty(StringBuilder stringbuilder, IBlockState iblockstate, Comparable comparable) { stringbuilder.append(iblockstate.getName()); stringbuilder.append('='); diff --git a/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch b/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch index 0a3f63320..b12c107e7 100644 --- a/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch +++ b/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch @@ -1,14 +1,5 @@ --- a/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java +++ b/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java -@@ -158,7 +158,7 @@ - axisalignedbb = this.createAabb(this.deltaX == null ? 0.0D : this.deltaX, this.deltaY == null ? 0.0D : this.deltaY, this.deltaZ == null ? 0.0D : this.deltaZ); - } - -- Function function; -+ Function function; // CraftBukkit - decompile error - - if (this.x == null && this.y == null && this.z == null) { - function = (vec3d) -> { @@ -215,8 +215,10 @@ }; } diff --git a/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch b/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch index 144825345..d6f8853e9 100644 --- a/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch +++ b/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/net/minecraft/commands/arguments/selector/EntitySelector.java -@@ -93,7 +93,7 @@ +@@ -92,7 +92,7 @@ } private void checkPermissions(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException { @@ -9,3 +9,26 @@ throw ArgumentEntity.ERROR_SELECTORS_NOT_ALLOWED.create(); } } +@@ -254,19 +254,19 @@ + + list1.addAll(this.contextFreePredicates); + if (flag) { +- list1.add((Predicate) (entity) -> { ++ list1.add((entity) -> { // CraftBukkit - decompile error + return entity.getType().isEnabled(featureflagset); + }); + } + + if (flag1) { +- list1.add((Predicate) (entity) -> { ++ list1.add((entity) -> { // CraftBukkit - decompile error + return axisalignedbb.intersects(entity.getBoundingBox()); + }); + } + + if (flag2) { +- list1.add((Predicate) (entity) -> { ++ list1.add((entity) -> { // CraftBukkit - decompile error + return this.range.matchesSqr(entity.distanceToSqr(vec3d)); + }); + } diff --git a/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch b/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch index d9fb2ed9e..8ddaebf99 100644 --- a/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch +++ b/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch @@ -42,12 +42,12 @@ entityhuman.awardStat(StatisticList.ITEM_USED.get(item)); - world.setBlockAndUpdate(blockposition, Blocks.WATER_CAULDRON.defaultBlockState()); + // world.setBlockAndUpdate(blockposition, Blocks.WATER_CAULDRON.defaultBlockState()); // CraftBukkit - world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.playSound((Entity) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition); } @@ -93,12 +104,17 @@ }); - map1.put(Items.GLASS_BOTTLE, (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { + map1.put(Items.GLASS_BOTTLE, (CauldronInteraction) (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { if (!world.isClientSide) { + // CraftBukkit start + if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL)) { @@ -61,7 +61,7 @@ entityhuman.awardStat(StatisticList.ITEM_USED.get(item)); - LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); + // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit - world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.playSound((Entity) null, blockposition, SoundEffects.BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F); world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition); } @@ -113,10 +129,15 @@ @@ -78,7 +78,7 @@ entityhuman.awardStat(StatisticList.ITEM_USED.get(itemstack.getItem())); - world.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.cycle(LayeredCauldronBlock.LEVEL)); + // world.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.cycle(LayeredCauldronBlock.LEVEL)); // CraftBukkit - world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.playSound((Entity) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition); } @@ -194,12 +215,17 @@ @@ -97,7 +97,7 @@ entityhuman.awardStat(StatisticList.ITEM_USED.get(item)); - world.setBlockAndUpdate(blockposition, Blocks.CAULDRON.defaultBlockState()); + // world.setBlockAndUpdate(blockposition, Blocks.CAULDRON.defaultBlockState()); // CraftBukkit - world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.playSound((Entity) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition); } @@ -210,12 +236,17 @@ @@ -116,7 +116,7 @@ entityhuman.awardStat(StatisticList.ITEM_USED.get(item)); - world.setBlockAndUpdate(blockposition, iblockdata); + // world.setBlockAndUpdate(blockposition, iblockdata); // CraftBukkit - world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.playSound((Entity) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition); } @@ -242,11 +273,16 @@ diff --git a/nms-patches/net/minecraft/core/component/DataComponentPatch.patch b/nms-patches/net/minecraft/core/component/DataComponentPatch.patch index 5e70217b4..f63cd38ed 100644 --- a/nms-patches/net/minecraft/core/component/DataComponentPatch.patch +++ b/nms-patches/net/minecraft/core/component/DataComponentPatch.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/core/component/DataComponentPatch.java +++ b/net/minecraft/core/component/DataComponentPatch.java -@@ -61,7 +61,7 @@ +@@ -60,7 +60,7 @@ } } - return reference2objectmap; + return (Reference2ObjectMap) reference2objectmap; // CraftBukkit - decompile error }); - public static final StreamCodec STREAM_CODEC = new StreamCodec() { - public DataComponentPatch decode(RegistryFriendlyByteBuf registryfriendlybytebuf) { -@@ -144,7 +144,7 @@ - } + public static final StreamCodec STREAM_CODEC = createStreamCodec(new DataComponentPatch.b() { + @Override +@@ -159,7 +159,7 @@ + } - private static void encodeComponent(RegistryFriendlyByteBuf registryfriendlybytebuf, DataComponentType datacomponenttype, Object object) { -- datacomponenttype.streamCodec().encode(registryfriendlybytebuf, object); -+ datacomponenttype.streamCodec().encode(registryfriendlybytebuf, (T) object); // CraftBukkit - decompile error - } - }; - private static final String REMOVED_PREFIX = "!"; -@@ -271,6 +271,42 @@ + private void encodeComponent(RegistryFriendlyByteBuf registryfriendlybytebuf, DataComponentType datacomponenttype, Object object) { +- datacomponentpatch_b.apply(datacomponenttype).encode(registryfriendlybytebuf, object); ++ datacomponentpatch_b.apply(datacomponenttype).encode(registryfriendlybytebuf, (T) object); // CraftBukkit - decompile error + } + }; + } +@@ -321,6 +321,42 @@ a() {} diff --git a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch index 9bef9068d..dac047952 100644 --- a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch +++ b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch @@ -43,12 +43,12 @@ + } + } + // CraftBukkit end - AbstractBoat abstractboat = (AbstractBoat) this.type.create(worldserver, EntitySpawnReason.DISPENSER); + AbstractBoat abstractboat = this.type.create(worldserver, EntitySpawnReason.DISPENSER); if (abstractboat != null) { - abstractboat.setInitialPos(d1, d2 + d4, d3); + abstractboat.setInitialPos(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); // CraftBukkit - EntityTypes.createDefaultStackConfig(worldserver, itemstack, (EntityHuman) null).accept(abstractboat); + EntityTypes.createDefaultStackConfig(worldserver, itemstack, (EntityLiving) null).accept(abstractboat); abstractboat.setYRot(enumdirection.toYRot()); - worldserver.addFreshEntity(abstractboat); - itemstack.shrink(1); diff --git a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch index 6e0926874..212310b52 100644 --- a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch +++ b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/DispenseBehaviorShears.java +++ b/net/minecraft/core/dispenser/DispenseBehaviorShears.java -@@ -23,6 +23,13 @@ +@@ -21,6 +21,13 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AxisAlignedBB; @@ -14,7 +14,7 @@ public class DispenseBehaviorShears extends DispenseBehaviorMaybe { public DispenseBehaviorShears() {} -@@ -30,11 +37,34 @@ +@@ -28,11 +35,34 @@ @Override protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) { WorldServer worldserver = sourceblock.level(); @@ -50,17 +50,13 @@ if (this.isSuccess()) { itemstack.hurtAndBreak(1, worldserver, (EntityPlayer) null, (item) -> { }); -@@ -64,7 +94,7 @@ +@@ -62,10 +92,15 @@ return false; } - private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { + private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, org.bukkit.block.Block bukkitBlock, CraftItemStack craftItem) { // CraftBukkit - add args - List list = worldserver.getEntitiesOfClass(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.NO_SPECTATORS); - Iterator iterator = list.iterator(); - -@@ -73,6 +103,11 @@ - + for (EntityLiving entityliving : worldserver.getEntitiesOfClass(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.NO_SPECTATORS)) { if (entityliving instanceof IShearable ishearable) { if (ishearable.readyForShearing()) { + // CraftBukkit start diff --git a/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch b/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch index 9ea817d60..74e93cb4a 100644 --- a/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch +++ b/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/IDispenseBehavior.java +++ b/net/minecraft/core/dispenser/IDispenseBehavior.java -@@ -63,6 +63,22 @@ +@@ -64,6 +64,22 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import org.slf4j.Logger; @@ -23,7 +23,7 @@ public interface IDispenseBehavior { Logger LOGGER = LogUtils.getLogger(); -@@ -90,14 +106,42 @@ +@@ -93,14 +109,42 @@ EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING); EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(sourceblock.level().registryAccess(), itemstack); @@ -55,7 +55,7 @@ + } + try { - entitytypes.spawn(sourceblock.level(), itemstack, (EntityHuman) null, sourceblock.pos().relative(enumdirection), EntitySpawnReason.DISPENSER, enumdirection != EnumDirection.UP, false); + entitytypes.spawn(sourceblock.level(), itemstack, (EntityLiving) null, sourceblock.pos().relative(enumdirection), EntitySpawnReason.DISPENSER, enumdirection != EnumDirection.UP, false); } catch (Exception exception) { - null.LOGGER.error("Error while dispensing spawn egg from dispenser at {}", sourceblock.pos(), exception); + LOGGER.error("Error while dispensing spawn egg from dispenser at {}", sourceblock.pos(), exception); // CraftBukkit - decompile error @@ -100,10 +100,10 @@ + } + // CraftBukkit end + - Consumer consumer = EntityTypes.appendDefaultStackConfig((entityarmorstand) -> { + Consumer consumer = EntityTypes.appendDefaultStackConfig((entityarmorstand) -> { entityarmorstand.setYRot(enumdirection.toYRot()); - }, worldserver, itemstack, (EntityHuman) null); - EntityArmorStand entityarmorstand = (EntityArmorStand) EntityTypes.ARMOR_STAND.spawn(worldserver, consumer, blockposition, EntitySpawnReason.DISPENSER, false, false); + }, worldserver, itemstack, (EntityLiving) null); + EntityArmorStand entityarmorstand = EntityTypes.ARMOR_STAND.spawn(worldserver, consumer, blockposition, EntitySpawnReason.DISPENSER, false, false); if (entityarmorstand != null) { - itemstack.shrink(1); @@ -111,29 +111,28 @@ } return itemstack; -@@ -141,7 +213,34 @@ - }); - - if (!list.isEmpty()) { -- ((ISaddleable) list.get(0)).equipSaddle(itemstack.split(1), SoundCategory.BLOCKS); -+ // CraftBukkit start +@@ -136,11 +208,35 @@ + for (EntityHorseChestedAbstract entityhorsechestedabstract : sourceblock.level().getEntitiesOfClass(EntityHorseChestedAbstract.class, new AxisAlignedBB(blockposition), (entityhorsechestedabstract1) -> { + return entityhorsechestedabstract1.isAlive() && !entityhorsechestedabstract1.hasChest(); + })) { +- if (entityhorsechestedabstract.isTamed() && entityhorsechestedabstract.getSlot(499).set(itemstack)) { +- itemstack.shrink(1); +- this.setSuccess(true); + ItemStack itemstack1 = itemstack.split(1); + WorldServer world = sourceblock.level(); + org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + -+ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) list.get(0).getBukkitEntity()); ++ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorsechestedabstract.getBukkitEntity()); + if (!BlockDispenser.eventFired) { + world.getCraftServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { -+ itemstack.grow(1); -+ return itemstack; -+ } + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.grow(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); @@ -142,53 +141,21 @@ + return itemstack; + } + } -+ ((ISaddleable) list.get(0)).equipSaddle(itemstack1, SoundCategory.BLOCKS); ++ entityhorsechestedabstract.getSlot(499).set(CraftItemStack.asNMSCopy(event.getItem())); + // CraftBukkit end - this.setSuccess(true); - return itemstack; - } else { -@@ -166,9 +265,35 @@ - } - - entityhorsechestedabstract = (EntityHorseChestedAbstract) iterator1.next(); -- } while (!entityhorsechestedabstract.isTamed() || !entityhorsechestedabstract.getSlot(499).set(itemstack)); -+ // CraftBukkit start -+ } while (!entityhorsechestedabstract.isTamed()); -+ ItemStack itemstack1 = itemstack.split(1); -+ WorldServer world = sourceblock.level(); -+ org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos()); -+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - -- itemstack.shrink(1); -+ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorsechestedabstract.getBukkitEntity()); -+ if (!BlockDispenser.eventFired) { -+ world.getCraftServer().getPluginManager().callEvent(event); -+ } + -+ if (event.isCancelled()) { ++ // itemstack.shrink(1); // CraftBukkit - handled above ++ this.setSuccess(true); + return itemstack; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ // Chain to handler for new item -+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != EquipmentDispenseItemBehavior.INSTANCE) { -+ idispensebehavior.dispense(sourceblock, eventStack); -+ return itemstack; -+ } -+ } -+ entityhorsechestedabstract.getSlot(499).set(CraftItemStack.asNMSCopy(event.getItem())); -+ // CraftBukkit end -+ -+ // itemstack.shrink(1); // CraftBukkit - handled above - this.setSuccess(true); - return itemstack; - } -@@ -202,6 +327,38 @@ - BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); - WorldServer worldserver = sourceblock.level(); + } + return super.execute(sourceblock, itemstack); +@@ -175,6 +271,40 @@ + BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); + World world = sourceblock.level(); + ++ WorldServer worldserver = sourceblock.level(); ++ + // CraftBukkit start + int x = blockposition.getX(); + int y = blockposition.getY(); @@ -221,29 +188,29 @@ + } + // CraftBukkit end + - if (dispensiblecontaineritem.emptyContents((EntityHuman) null, worldserver, blockposition, (MovingObjectPositionBlock) null)) { - dispensiblecontaineritem.checkExtraContent((EntityHuman) null, worldserver, itemstack, blockposition); + if (dispensiblecontaineritem.emptyContents((EntityLiving) null, world, blockposition, (MovingObjectPositionBlock) null)) { + dispensiblecontaineritem.checkExtraContent((EntityLiving) null, world, itemstack, blockposition); return this.consumeWithRemainder(sourceblock, itemstack, new ItemStack(Items.BUCKET)); -@@ -229,7 +386,7 @@ +@@ -202,7 +332,7 @@ Block block = iblockdata.getBlock(); if (block instanceof IFluidSource ifluidsource) { -- ItemStack itemstack1 = ifluidsource.pickupBlock((EntityHuman) null, worldserver, blockposition, iblockdata); -+ ItemStack itemstack1 = ifluidsource.pickupBlock((EntityHuman) null, DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit +- ItemStack itemstack1 = ifluidsource.pickupBlock((EntityLiving) null, generatoraccess, blockposition, iblockdata); ++ ItemStack itemstack1 = ifluidsource.pickupBlock((EntityLiving) null, DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit if (itemstack1.isEmpty()) { return super.execute(sourceblock, itemstack); -@@ -237,6 +394,32 @@ - worldserver.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition); +@@ -210,6 +340,32 @@ + generatoraccess.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition); Item item = itemstack1.getItem(); + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = CraftBlock.at(worldserver, sourceblock.pos()); ++ org.bukkit.block.Block bukkitBlock = CraftBlock.at(generatoraccess, sourceblock.pos()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + + BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); + if (!BlockDispenser.eventFired) { -+ worldserver.getCraftServer().getPluginManager().callEvent(event); ++ sourceblock.level().getCraftServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -260,13 +227,13 @@ + } + } + -+ itemstack1 = ifluidsource.pickupBlock((EntityHuman) null, worldserver, blockposition, iblockdata); // From above ++ itemstack1 = ifluidsource.pickupBlock((EntityLiving) null, generatoraccess, blockposition, iblockdata); // From above + // CraftBukkit end + return this.consumeWithRemainder(sourceblock, itemstack, new ItemStack(item)); } } else { -@@ -249,16 +432,44 @@ +@@ -222,16 +378,44 @@ protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) { WorldServer worldserver = sourceblock.level(); @@ -311,20 +278,20 @@ } else if (!BlockCampfire.canLight(iblockdata) && !CandleBlock.canLight(iblockdata) && !CandleCakeBlock.canLight(iblockdata)) { - if (iblockdata.getBlock() instanceof BlockTNT) { + if (iblockdata.getBlock() instanceof BlockTNT && org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(worldserver, blockposition, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.DISPENSER, null, sourceblock.pos())) { // CraftBukkit - TNTPrimeEvent - BlockTNT.explode(worldserver, blockposition); - worldserver.removeBlock(blockposition, false); - } else { -@@ -283,12 +494,62 @@ + if (BlockTNT.prime(worldserver, blockposition)) { + worldserver.removeBlock(blockposition, false); + } else { +@@ -259,12 +443,62 @@ this.setSuccess(true); - WorldServer worldserver = sourceblock.level(); + World world = sourceblock.level(); BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); + // CraftBukkit start -+ org.bukkit.block.Block block = CraftBlock.at(worldserver, sourceblock.pos()); ++ org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + + BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); + if (!BlockDispenser.eventFired) { -+ worldserver.getCraftServer().getPluginManager().callEvent(event); ++ world.getCraftServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -341,22 +308,22 @@ + } + } + -+ worldserver.captureTreeGeneration = true; ++ world.captureTreeGeneration = true; + // CraftBukkit end - if (!ItemBoneMeal.growCrop(itemstack, worldserver, blockposition) && !ItemBoneMeal.growWaterPlant(itemstack, worldserver, blockposition, (EnumDirection) null)) { + if (!ItemBoneMeal.growCrop(itemstack, world, blockposition) && !ItemBoneMeal.growWaterPlant(itemstack, world, blockposition, (EnumDirection) null)) { this.setSuccess(false); - } else if (!worldserver.isClientSide) { - worldserver.levelEvent(1505, blockposition, 15); + } else if (!world.isClientSide) { + world.levelEvent(1505, blockposition, 15); } + // CraftBukkit start -+ worldserver.captureTreeGeneration = false; -+ if (worldserver.capturedBlockStates.size() > 0) { ++ world.captureTreeGeneration = false; ++ if (world.capturedBlockStates.size() > 0) { + TreeType treeType = BlockSapling.treeType; + BlockSapling.treeType = null; -+ Location location = CraftLocation.toBukkit(blockposition, worldserver.getWorld()); -+ List blocks = new java.util.ArrayList<>(worldserver.capturedBlockStates.values()); -+ worldserver.capturedBlockStates.clear(); ++ Location location = CraftLocation.toBukkit(blockposition, world.getWorld()); ++ List blocks = new java.util.ArrayList<>(world.capturedBlockStates.values()); ++ world.capturedBlockStates.clear(); + StructureGrowEvent structureEvent = null; + if (treeType != null) { + structureEvent = new StructureGrowEvent(location, treeType, false, null, blocks); @@ -377,61 +344,61 @@ return itemstack; } -@@ -298,12 +559,41 @@ - protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) { - WorldServer worldserver = sourceblock.level(); - BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); -- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); -+ // CraftBukkit start -+ // EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); +@@ -279,12 +513,41 @@ + return itemstack; + } else { + BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); +- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); ++ // CraftBukkit start ++ // EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); + -+ ItemStack itemstack1 = itemstack.split(1); -+ org.bukkit.block.Block block = CraftBlock.at(worldserver, sourceblock.pos()); -+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); ++ ItemStack itemstack1 = itemstack.split(1); ++ org.bukkit.block.Block block = CraftBlock.at(worldserver, sourceblock.pos()); ++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + -+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D)); -+ if (!BlockDispenser.eventFired) { -+ worldserver.getCraftServer().getPluginManager().callEvent(event); -+ } ++ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D)); ++ if (!BlockDispenser.eventFired) { ++ worldserver.getCraftServer().getPluginManager().callEvent(event); ++ } + -+ if (event.isCancelled()) { -+ itemstack.grow(1); -+ return itemstack; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ itemstack.grow(1); -+ // Chain to handler for new item -+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { -+ idispensebehavior.dispense(sourceblock, eventStack); ++ if (event.isCancelled()) { ++ itemstack.grow(1); + return itemstack; + } -+ } + -+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), (EntityLiving) null); -+ // CraftBukkit end ++ if (!event.getItem().equals(craftItem)) { ++ itemstack.grow(1); ++ // Chain to handler for new item ++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(sourceblock, eventStack); ++ return itemstack; ++ } ++ } ++ ++ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), (EntityLiving) null); ++ // CraftBukkit end - worldserver.addFreshEntity(entitytntprimed); - worldserver.playSound((EntityHuman) null, entitytntprimed.getX(), entitytntprimed.getY(), entitytntprimed.getZ(), SoundEffects.TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); - worldserver.gameEvent((Entity) null, (Holder) GameEvent.ENTITY_PLACE, blockposition); -- itemstack.shrink(1); -+ // itemstack.shrink(1); // CraftBukkit - handled above - return itemstack; - } - }); -@@ -314,6 +604,30 @@ + worldserver.addFreshEntity(entitytntprimed); + worldserver.playSound((Entity) null, entitytntprimed.getX(), entitytntprimed.getY(), entitytntprimed.getZ(), SoundEffects.TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); + worldserver.gameEvent((Entity) null, (Holder) GameEvent.ENTITY_PLACE, blockposition); +- itemstack.shrink(1); ++ // itemstack.shrink(1); // CraftBukkit - handled above + this.setSuccess(true); + return itemstack; + } +@@ -297,6 +560,30 @@ EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING); BlockPosition blockposition = sourceblock.pos().relative(enumdirection); + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = CraftBlock.at(worldserver, sourceblock.pos()); ++ org.bukkit.block.Block bukkitBlock = CraftBlock.at(world, sourceblock.pos()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + + BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); + if (!BlockDispenser.eventFired) { -+ worldserver.getCraftServer().getPluginManager().callEvent(event); ++ world.getCraftServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -449,20 +416,20 @@ + } + // CraftBukkit end + - if (worldserver.isEmptyBlock(blockposition) && BlockWitherSkull.canSpawnMob(worldserver, blockposition, itemstack)) { - worldserver.setBlock(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.defaultBlockState().setValue(BlockSkull.ROTATION, RotationSegment.convertToSegment(enumdirection)), 3); - worldserver.gameEvent((Entity) null, (Holder) GameEvent.BLOCK_PLACE, blockposition); -@@ -339,6 +653,30 @@ + if (world.isEmptyBlock(blockposition) && BlockWitherSkull.canSpawnMob(world, blockposition, itemstack)) { + world.setBlock(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.defaultBlockState().setValue(BlockSkull.ROTATION, RotationSegment.convertToSegment(enumdirection)), 3); + world.gameEvent((Entity) null, (Holder) GameEvent.BLOCK_PLACE, blockposition); +@@ -322,6 +609,30 @@ BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN; + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = CraftBlock.at(worldserver, sourceblock.pos()); ++ org.bukkit.block.Block bukkitBlock = CraftBlock.at(world, sourceblock.pos()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + + BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); + if (!BlockDispenser.eventFired) { -+ worldserver.getCraftServer().getPluginManager().callEvent(event); ++ world.getCraftServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -480,10 +447,10 @@ + } + // CraftBukkit end + - if (worldserver.isEmptyBlock(blockposition) && blockpumpkincarved.canSpawnGolem(worldserver, blockposition)) { - if (!worldserver.isClientSide) { - worldserver.setBlock(blockposition, blockpumpkincarved.defaultBlockState(), 3); -@@ -377,6 +715,30 @@ + if (world.isEmptyBlock(blockposition) && blockpumpkincarved.canSpawnGolem(world, blockposition)) { + if (!world.isClientSide) { + world.setBlock(blockposition, blockpumpkincarved.defaultBlockState(), 3); +@@ -356,6 +667,30 @@ BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); IBlockData iblockdata = worldserver.getBlockState(blockposition); @@ -514,7 +481,7 @@ if (iblockdata.is(TagsBlock.BEEHIVES, (blockbase_blockdata) -> { return blockbase_blockdata.hasProperty(BlockBeehive.HONEY_LEVEL) && blockbase_blockdata.getBlock() instanceof BlockBeehive; }) && (Integer) iblockdata.getValue(BlockBeehive.HONEY_LEVEL) >= 5) { -@@ -426,6 +788,31 @@ +@@ -405,6 +740,31 @@ this.setSuccess(false); return itemstack; } else { @@ -543,6 +510,6 @@ + } + } + // CraftBukkit end - Iterator iterator1 = list.iterator(); - - Armadillo armadillo; + for (Armadillo armadillo : list) { + if (armadillo.brushOffScute()) { + itemstack.hurtAndBreak(16, worldserver, (EntityPlayer) null, (item) -> { diff --git a/nms-patches/net/minecraft/nbt/NBTCompressedStreamTools.patch b/nms-patches/net/minecraft/nbt/NBTCompressedStreamTools.patch index e7fb3c796..e2cccd016 100644 --- a/nms-patches/net/minecraft/nbt/NBTCompressedStreamTools.patch +++ b/nms-patches/net/minecraft/nbt/NBTCompressedStreamTools.patch @@ -4,4 +4,4 @@ +// mc-dev import package net.minecraft.nbt; - import java.io.BufferedOutputStream; + import com.google.common.annotations.VisibleForTesting; diff --git a/nms-patches/net/minecraft/network/NetworkManager.patch b/nms-patches/net/minecraft/network/NetworkManager.patch index c5e375772..d98175c9a 100644 --- a/nms-patches/net/minecraft/network/NetworkManager.patch +++ b/nms-patches/net/minecraft/network/NetworkManager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/NetworkManager.java +++ b/net/minecraft/network/NetworkManager.java -@@ -114,6 +114,7 @@ +@@ -113,6 +113,7 @@ private volatile DisconnectionDetails delayedDisconnect; @Nullable BandwidthDebugMonitor bandwidthDebugMonitor; @@ -8,7 +8,7 @@ public NetworkManager(EnumProtocolDirection enumprotocoldirection) { this.receiving = enumprotocoldirection; -@@ -205,7 +206,7 @@ +@@ -204,7 +205,7 @@ } private static void genericsFtw(Packet packet, PacketListener packetlistener) { @@ -17,7 +17,16 @@ } private void validateListener(ProtocolInfo protocolinfo, PacketListener packetlistener) { -@@ -469,7 +470,7 @@ +@@ -331,7 +332,7 @@ + this.flushQueue(); + this.sendPacket(packet, packetsendlistener, flag); + } else { +- this.pendingActions.add((Consumer) (networkmanager) -> { ++ this.pendingActions.add((networkmanager) -> { // CraftBukkit - decompile error + networkmanager.sendPacket(packet, packetsendlistener, flag); + }); + } +@@ -467,7 +468,7 @@ } if (this.isConnected()) { @@ -26,12 +35,3 @@ this.disconnectionDetails = disconnectiondetails; } -@@ -537,7 +538,7 @@ - } - - public void configurePacketHandler(ChannelPipeline channelpipeline) { -- channelpipeline.addLast("hackfix", new ChannelOutboundHandlerAdapter(this) { -+ channelpipeline.addLast("hackfix", new ChannelOutboundHandlerAdapter() { // CraftBukkit - decompile error - public void write(ChannelHandlerContext channelhandlercontext, Object object, ChannelPromise channelpromise) throws Exception { - super.write(channelhandlercontext, object, channelpromise); - } diff --git a/nms-patches/net/minecraft/network/PacketDataSerializer.patch b/nms-patches/net/minecraft/network/PacketDataSerializer.patch index 459f09786..8f7833177 100644 --- a/nms-patches/net/minecraft/network/PacketDataSerializer.patch +++ b/nms-patches/net/minecraft/network/PacketDataSerializer.patch @@ -1,24 +1,6 @@ --- a/net/minecraft/network/PacketDataSerializer.java +++ b/net/minecraft/network/PacketDataSerializer.java -@@ -139,7 +139,7 @@ - - public > C readCollection(IntFunction intfunction, StreamDecoder streamdecoder) { - int i = this.readVarInt(); -- C c0 = (Collection) intfunction.apply(i); -+ C c0 = intfunction.apply(i); // CraftBukkit - decompile error - - for (int j = 0; j < i; ++j) { - c0.add(streamdecoder.decode(this)); -@@ -150,7 +150,7 @@ - - public void writeCollection(Collection collection, StreamEncoder streamencoder) { - this.writeVarInt(collection.size()); -- Iterator iterator = collection.iterator(); -+ Iterator iterator = collection.iterator(); // CraftBukkit - decompile error - - while (iterator.hasNext()) { - T t0 = iterator.next(); -@@ -177,12 +177,12 @@ +@@ -173,7 +173,7 @@ public void writeIntIdList(IntList intlist) { this.writeVarInt(intlist.size()); @@ -27,43 +9,10 @@ } public > M readMap(IntFunction intfunction, StreamDecoder streamdecoder, StreamDecoder streamdecoder1) { - int i = this.readVarInt(); -- M m0 = (Map) intfunction.apply(i); -+ M m0 = intfunction.apply(i); // CraftBukkit - decompile error - - for (int j = 0; j < i; ++j) { - K k0 = streamdecoder.decode(this); -@@ -216,7 +216,7 @@ - } - - public > void writeEnumSet(EnumSet enumset, Class oclass) { -- E[] ae = (Enum[]) oclass.getEnumConstants(); -+ E[] ae = oclass.getEnumConstants(); // CraftBukkit - decompile error - BitSet bitset = new BitSet(ae.length); - - for (int i = 0; i < ae.length; ++i) { -@@ -227,7 +227,7 @@ - } - - public > EnumSet readEnumSet(Class oclass) { -- E[] ae = (Enum[]) oclass.getEnumConstants(); -+ E[] ae = oclass.getEnumConstants(); // CraftBukkit - decompile error - BitSet bitset = this.readFixedBitSet(ae.length); - EnumSet enumset = EnumSet.noneOf(oclass); - -@@ -498,7 +498,7 @@ - } - - public > T readEnum(Class oclass) { -- return ((Enum[]) oclass.getEnumConstants())[this.readVarInt()]; -+ return ((T[]) oclass.getEnumConstants())[this.readVarInt()]; // CraftBukkit - fix decompile error - } - - public PacketDataSerializer writeEnum(Enum oenum) { -@@ -565,7 +565,7 @@ +@@ -566,7 +566,7 @@ try { - NBTCompressedStreamTools.writeAnyTag((NBTBase) nbtbase, new ByteBufOutputStream(bytebuf)); + NBTCompressedStreamTools.writeAnyTag(nbtbase, new ByteBufOutputStream(bytebuf)); - } catch (IOException ioexception) { + } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception throw new EncoderException(ioexception); diff --git a/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch b/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch index 783abb4db..cc5f2cdf8 100644 --- a/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch +++ b/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch @@ -1,11 +1,12 @@ --- a/net/minecraft/network/chat/IChatBaseComponent.java +++ b/net/minecraft/network/chat/IChatBaseComponent.java -@@ -38,7 +38,22 @@ +@@ -37,7 +37,23 @@ import net.minecraft.util.FormattedString; import net.minecraft.world.level.ChunkCoordIntPair; -public interface IChatBaseComponent extends Message, IChatFormatted { +// CraftBukkit start ++import java.util.Iterator; +import java.util.stream.Stream; +// CraftBukkit end + diff --git a/nms-patches/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.patch b/nms-patches/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.patch index 7e2451598..c91404528 100644 --- a/nms-patches/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.patch +++ b/nms-patches/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.patch @@ -4,7 +4,7 @@ private static final int MAX_PAYLOAD_SIZE = 32767; public static final StreamCodec STREAM_CODEC = CustomPacketPayload.codec((minecraftkey) -> { return DiscardedPayload.codec(minecraftkey, 32767); -- }, (List) SystemUtils.make(Lists.newArrayList(new CustomPacketPayload.c[]{new CustomPacketPayload.c<>(BrandPayload.TYPE, BrandPayload.STREAM_CODEC)}), (arraylist) -> { +- }, (List) SystemUtils.make(Lists.newArrayList(new CustomPacketPayload.c[]{new CustomPacketPayload.c(BrandPayload.TYPE, BrandPayload.STREAM_CODEC)}), (arraylist) -> { - })).map(ServerboundCustomPayloadPacket::new, ServerboundCustomPayloadPacket::payload); + }, java.util.Collections.emptyList()).map(ServerboundCustomPayloadPacket::new, ServerboundCustomPayloadPacket::payload); // CraftBukkit - treat all packets the same diff --git a/nms-patches/net/minecraft/network/syncher/DataWatcher.patch b/nms-patches/net/minecraft/network/syncher/DataWatcher.patch index 309bde763..a6cbacf01 100644 --- a/nms-patches/net/minecraft/network/syncher/DataWatcher.patch +++ b/nms-patches/net/minecraft/network/syncher/DataWatcher.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/syncher/DataWatcher.java +++ b/net/minecraft/network/syncher/DataWatcher.java -@@ -14,6 +14,11 @@ +@@ -13,6 +13,11 @@ import org.apache.commons.lang3.ObjectUtils; import org.slf4j.Logger; @@ -12,7 +12,7 @@ public class DataWatcher { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -51,7 +56,7 @@ +@@ -50,7 +55,7 @@ } private DataWatcher.Item getItem(DataWatcherObject datawatcherobject) { @@ -21,7 +21,7 @@ } public T get(DataWatcherObject datawatcherobject) { -@@ -74,6 +79,13 @@ +@@ -73,6 +78,13 @@ } @@ -35,7 +35,7 @@ public boolean isDirty() { return this.isDirty; } -@@ -140,7 +152,7 @@ +@@ -128,7 +140,7 @@ if (!Objects.equals(datawatcher_c.serializer(), datawatcher_item.accessor.serializer())) { throw new IllegalStateException(String.format(Locale.ROOT, "Invalid entity data item type for field %d on entity %s: old=%s(%s), new=%s(%s)", datawatcher_item.accessor.id(), this.entity, datawatcher_item.value, datawatcher_item.value.getClass(), datawatcher_c.value, datawatcher_c.value.getClass())); } else { diff --git a/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch b/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch index ef25110a6..91f63276b 100644 --- a/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch +++ b/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/AdvancementDataPlayer.java +++ b/net/minecraft/server/AdvancementDataPlayer.java -@@ -196,6 +196,7 @@ +@@ -155,6 +155,7 @@ AdvancementHolder advancementholder = advancementdataworld.get(minecraftkey); if (advancementholder == null) { @@ -8,7 +8,7 @@ AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", minecraftkey, this.playerSavePath); } else { this.startProgress(advancementholder, advancementprogress); -@@ -227,6 +228,7 @@ +@@ -186,6 +187,7 @@ this.progressChanged.add(advancementholder); flag = true; if (!flag1 && advancementprogress.isDone()) { diff --git a/nms-patches/net/minecraft/server/AdvancementDataWorld.patch b/nms-patches/net/minecraft/server/AdvancementDataWorld.patch index 258a729f4..8419b1c34 100644 --- a/nms-patches/net/minecraft/server/AdvancementDataWorld.patch +++ b/nms-patches/net/minecraft/server/AdvancementDataWorld.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/AdvancementDataWorld.java +++ b/net/minecraft/server/AdvancementDataWorld.java -@@ -21,10 +21,14 @@ +@@ -19,10 +19,14 @@ import net.minecraft.util.profiling.GameProfilerFiller; import org.slf4j.Logger; @@ -16,12 +16,12 @@ private AdvancementTree tree = new AdvancementTree(); private final HolderLookup.a registries; -@@ -40,7 +44,7 @@ +@@ -38,7 +42,7 @@ this.validate(minecraftkey, advancement); - builder.put(minecraftkey, new AdvancementHolder(minecraftkey, advancement)); + immutablemap_builder.put(minecraftkey, new AdvancementHolder(minecraftkey, advancement)); }); -- this.advancements = builder.buildOrThrow(); -+ this.advancements = new HashMap<>(builder.buildOrThrow()); // CraftBukkit - SPIGOT-7734: mutable +- this.advancements = immutablemap_builder.buildOrThrow(); ++ this.advancements = new HashMap<>(immutablemap_builder.buildOrThrow()); // CraftBukkit - SPIGOT-7734: mutable AdvancementTree advancementtree = new AdvancementTree(); advancementtree.addAll(this.advancements.values()); diff --git a/nms-patches/net/minecraft/server/CustomFunctionData.patch b/nms-patches/net/minecraft/server/CustomFunctionData.patch index 419c9c3ea..21f7645c6 100644 --- a/nms-patches/net/minecraft/server/CustomFunctionData.patch +++ b/nms-patches/net/minecraft/server/CustomFunctionData.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/CustomFunctionData.java +++ b/net/minecraft/server/CustomFunctionData.java -@@ -37,7 +37,7 @@ +@@ -36,7 +36,7 @@ } public CommandDispatcher getDispatcher() { diff --git a/nms-patches/net/minecraft/server/DispenserRegistry.patch b/nms-patches/net/minecraft/server/DispenserRegistry.patch index 2c354a2c0..05c572124 100644 --- a/nms-patches/net/minecraft/server/DispenserRegistry.patch +++ b/nms-patches/net/minecraft/server/DispenserRegistry.patch @@ -1,11 +1,12 @@ --- a/net/minecraft/server/DispenserRegistry.java +++ b/net/minecraft/server/DispenserRegistry.java -@@ -30,7 +30,13 @@ +@@ -30,7 +30,14 @@ import net.minecraft.world.level.block.state.BlockBase; import org.slf4j.Logger; -@SuppressForbidden(a = "System.out setup") +// CraftBukkit start ++import java.util.Map; +import net.minecraft.util.datafix.fixes.DataConverterFlattenData; +import net.minecraft.util.datafix.fixes.DataConverterMaterialId; +import net.minecraft.util.datafix.fixes.DataConverterSpawnEgg; @@ -15,7 +16,7 @@ public class DispenserRegistry { public static final PrintStream STDOUT = System.out; -@@ -42,6 +48,23 @@ +@@ -42,6 +49,23 @@ public static void bootStrap() { if (!DispenserRegistry.isBootstrapped) { @@ -39,30 +40,30 @@ DispenserRegistry.isBootstrapped = true; Instant instant = Instant.now(); -@@ -61,6 +84,69 @@ +@@ -61,6 +85,69 @@ wrapStreams(); DispenserRegistry.bootstrapDuration.set(Duration.between(instant, Instant.now()).toMillis()); } + // CraftBukkit start - easier than fixing the decompile -+ DataConverterFlattenData.register(1008, "{Name:'minecraft:oak_sign',Properties:{rotation:'0'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'0'}}"); -+ DataConverterFlattenData.register(1009, "{Name:'minecraft:oak_sign',Properties:{rotation:'1'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'1'}}"); -+ DataConverterFlattenData.register(1010, "{Name:'minecraft:oak_sign',Properties:{rotation:'2'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'2'}}"); -+ DataConverterFlattenData.register(1011, "{Name:'minecraft:oak_sign',Properties:{rotation:'3'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'3'}}"); -+ DataConverterFlattenData.register(1012, "{Name:'minecraft:oak_sign',Properties:{rotation:'4'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'4'}}"); -+ DataConverterFlattenData.register(1013, "{Name:'minecraft:oak_sign',Properties:{rotation:'5'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'5'}}"); -+ DataConverterFlattenData.register(1014, "{Name:'minecraft:oak_sign',Properties:{rotation:'6'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'6'}}"); -+ DataConverterFlattenData.register(1015, "{Name:'minecraft:oak_sign',Properties:{rotation:'7'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'7'}}"); -+ DataConverterFlattenData.register(1016, "{Name:'minecraft:oak_sign',Properties:{rotation:'8'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'8'}}"); -+ DataConverterFlattenData.register(1017, "{Name:'minecraft:oak_sign',Properties:{rotation:'9'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'9'}}"); -+ DataConverterFlattenData.register(1018, "{Name:'minecraft:oak_sign',Properties:{rotation:'10'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'10'}}"); -+ DataConverterFlattenData.register(1019, "{Name:'minecraft:oak_sign',Properties:{rotation:'11'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'11'}}"); -+ DataConverterFlattenData.register(1020, "{Name:'minecraft:oak_sign',Properties:{rotation:'12'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'12'}}"); -+ DataConverterFlattenData.register(1021, "{Name:'minecraft:oak_sign',Properties:{rotation:'13'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'13'}}"); -+ DataConverterFlattenData.register(1022, "{Name:'minecraft:oak_sign',Properties:{rotation:'14'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'14'}}"); -+ DataConverterFlattenData.register(1023, "{Name:'minecraft:oak_sign',Properties:{rotation:'15'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'15'}}"); ++ DataConverterFlattenData.register(1008, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "0")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "0"))); ++ DataConverterFlattenData.register(1009, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "1")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "1"))); ++ DataConverterFlattenData.register(1010, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "2")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "2"))); ++ DataConverterFlattenData.register(1011, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "3")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "3"))); ++ DataConverterFlattenData.register(1012, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "4")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "4"))); ++ DataConverterFlattenData.register(1013, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "5")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "5"))); ++ DataConverterFlattenData.register(1014, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "6")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "6"))); ++ DataConverterFlattenData.register(1015, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "7")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "7"))); ++ DataConverterFlattenData.register(1016, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "8")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "8"))); ++ DataConverterFlattenData.register(1017, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "9")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "9"))); ++ DataConverterFlattenData.register(1018, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "10")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "10"))); ++ DataConverterFlattenData.register(1019, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "11")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "11"))); ++ DataConverterFlattenData.register(1020, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "12")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "12"))); ++ DataConverterFlattenData.register(1021, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "13")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "13"))); ++ DataConverterFlattenData.register(1022, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "14")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "14"))); ++ DataConverterFlattenData.register(1023, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "15")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "15"))); + DataConverterMaterialId.ITEM_NAMES.put(323, "minecraft:oak_sign"); + -+ DataConverterFlattenData.register(1440, "{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}", new String[]{"{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}"}); ++ DataConverterFlattenData.register(1440, DataConverterFlattenData.create("minecraft:portal", Map.of("axis", "x")), DataConverterFlattenData.create("minecraft:portal", Map.of("axis", "x"))); + + DataConverterMaterialId.ITEM_NAMES.put(409, "minecraft:prismarine_shard"); + DataConverterMaterialId.ITEM_NAMES.put(410, "minecraft:prismarine_crystals"); diff --git a/nms-patches/net/minecraft/server/Main.patch b/nms-patches/net/minecraft/server/Main.patch index 416ed85cd..7a575ca93 100644 --- a/nms-patches/net/minecraft/server/Main.patch +++ b/nms-patches/net/minecraft/server/Main.patch @@ -96,7 +96,7 @@ - Convertable.ConversionSession convertable_conversionsession = convertable.validateAndCreateAccess(s); + Convertable.ConversionSession convertable_conversionsession = convertable.validateAndCreateAccess(s, WorldDimension.OVERWORLD); + // CraftBukkit end - Dynamic dynamic; + Dynamic dynamic; if (convertable_conversionsession.hasWorldData()) { @@ -174,13 +204,31 @@ @@ -164,10 +164,10 @@ + /* IRegistryCustom.Dimension iregistrycustom_dimension = worldstem.registries().compositeAccess(); - boolean flag1 = optionset.has(optionspec6); - -@@ -237,20 +287,31 @@ SaveData savedata = worldstem.worldData(); + boolean flag1 = optionset.has(optionspec6); +@@ -236,20 +286,31 @@ + } convertable_conversionsession.saveDataTag(iregistrycustom_dimension, savedata); + */ @@ -200,7 +200,7 @@ Thread thread = new Thread("Server Shutdown Thread") { public void run() { dedicatedserver.halt(true); -@@ -259,6 +320,7 @@ +@@ -258,6 +319,7 @@ thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER)); Runtime.getRuntime().addShutdownHook(thread); @@ -208,12 +208,12 @@ } catch (Exception exception1) { Main.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", exception1); } -@@ -295,7 +357,7 @@ +@@ -294,7 +356,7 @@ } - public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, IRegistryCustom iregistrycustom, boolean flag1) { + public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, SaveData savedata, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, IRegistryCustom iregistrycustom, boolean flag1) { - Main.LOGGER.info("Forcing world upgrade!"); + Main.LOGGER.info("Forcing world upgrade! {}", convertable_conversionsession.getLevelId()); // CraftBukkit - WorldUpgrader worldupgrader = new WorldUpgrader(convertable_conversionsession, datafixer, iregistrycustom, flag, flag1); - try { + try (WorldUpgrader worldupgrader = new WorldUpgrader(convertable_conversionsession, datafixer, savedata, iregistrycustom, flag, flag1)) { + IChatBaseComponent ichatbasecomponent = null; diff --git a/nms-patches/net/minecraft/server/MinecraftServer.patch b/nms-patches/net/minecraft/server/MinecraftServer.patch index a5c4537e4..90223579f 100644 --- a/nms-patches/net/minecraft/server/MinecraftServer.patch +++ b/nms-patches/net/minecraft/server/MinecraftServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -180,13 +180,38 @@ +@@ -176,13 +176,38 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -40,7 +40,7 @@ private static final int OVERLOADED_TICKS_THRESHOLD = 20; private static final long OVERLOADED_WARNING_INTERVAL_NANOS = 10L * TimeRange.NANOSECONDS_PER_SECOND; private static final int OVERLOADED_TICKS_WARNING_INTERVAL = 100; -@@ -277,6 +302,19 @@ +@@ -273,6 +298,19 @@ private final SuppressedExceptionCollector suppressedExceptions; private final DiscontinuousFrame tickFrame; @@ -60,15 +60,7 @@ public static S spin(Function function) { AtomicReference atomicreference = new AtomicReference(); Thread thread = new Thread(() -> { -@@ -290,14 +328,14 @@ - thread.setPriority(8); - } - -- S s0 = (MinecraftServer) function.apply(thread); -+ S s0 = function.apply(thread); // CraftBukkit - decompile error - - atomicreference.set(s0); - thread.start(); +@@ -293,7 +331,7 @@ return s0; } @@ -77,7 +69,7 @@ super("Server"); this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; this.onMetricsRecordingStopped = (methodprofilerresults) -> { -@@ -321,7 +359,7 @@ +@@ -317,7 +355,7 @@ this.suppressedExceptions = new SuppressedExceptionCollector(); this.registries = worldstem.registries(); this.worldData = worldstem.worldData(); @@ -86,7 +78,7 @@ throw new IllegalStateException("Missing Overworld dimension data"); } else { this.proxy = proxy; -@@ -349,6 +387,33 @@ +@@ -345,6 +383,33 @@ this.fuelValues = FuelValues.vanillaBurnTimes(this.registries.compositeAccess(), this.worldData.enabledFeatures()); this.tickFrame = TracyClient.createDiscontinuousFrame("Server Tick"); } @@ -120,7 +112,7 @@ } private void readScoreboard(WorldPersistentData worldpersistentdata) { -@@ -357,7 +422,7 @@ +@@ -353,7 +418,7 @@ protected abstract boolean initServer() throws IOException; @@ -129,7 +121,7 @@ if (!JvmProfiler.INSTANCE.isRunning()) { ; } -@@ -365,12 +430,8 @@ +@@ -361,12 +426,8 @@ boolean flag = false; ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted(); @@ -143,7 +135,7 @@ if (profiledduration != null) { profiledduration.finish(true); } -@@ -387,23 +448,217 @@ +@@ -383,23 +444,217 @@ protected void forceDifficulty() {} @@ -305,7 +297,7 @@ + } + worlddata.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 (options.has("forceUpgrade")) { -+ net.minecraft.server.Main.forceUpgrade(worldSession, DataConverterRegistry.getDataFixer(), options.has("eraseCache"), () -> { ++ net.minecraft.server.Main.forceUpgrade(worldSession, worlddata, DataConverterRegistry.getDataFixer(), options.has("eraseCache"), () -> { + return true; + }, iregistrycustom_dimension, options.has("recreateRegionFiles")); + } @@ -375,7 +367,7 @@ if (!iworlddataserver.isInitialized()) { try { -@@ -427,30 +682,8 @@ +@@ -423,28 +678,8 @@ iworlddataserver.setInitialized(true); } @@ -385,16 +377,14 @@ - } - - RandomSequences randomsequences = worldserver.getRandomSequences(); -- Iterator iterator = iregistry.entrySet().iterator(); - -- while (iterator.hasNext()) { -- Entry, WorldDimension> entry = (Entry) iterator.next(); -- ResourceKey resourcekey = (ResourceKey) entry.getKey(); +- for (Map.Entry, WorldDimension> map_entry : iregistry.entrySet()) { +- ResourceKey resourcekey = (ResourceKey) map_entry.getKey(); - - if (resourcekey != WorldDimension.OVERWORLD) { - ResourceKey resourcekey1 = ResourceKey.create(Registries.DIMENSION, resourcekey.location()); - SecondaryWorldData secondaryworlddata = new SecondaryWorldData(this.worldData, iworlddataserver); -- WorldServer worldserver1 = new WorldServer(this, this.executor, this.storageSource, secondaryworlddata, resourcekey1, (WorldDimension) entry.getValue(), worldloadlistener, flag, j, ImmutableList.of(), false, randomsequences); +- WorldServer worldserver1 = new WorldServer(this, this.executor, this.storageSource, secondaryworlddata, resourcekey1, (WorldDimension) map_entry.getValue(), worldloadlistener, flag, j, ImmutableList.of(), false, randomsequences); - - worldborder.addListener(new IWorldBorderListener.a(worldserver1.getWorldBorder())); - this.levels.put(resourcekey1, worldserver1); @@ -407,7 +397,7 @@ private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) { if (flag1) { -@@ -458,6 +691,21 @@ +@@ -452,6 +687,21 @@ } else { ChunkProviderServer chunkproviderserver = worldserver.getChunkSource(); ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition()); @@ -429,7 +419,7 @@ int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver); if (i < worldserver.getMinY()) { -@@ -516,8 +764,11 @@ +@@ -510,8 +760,11 @@ iworlddataserver.setGameType(EnumGamemode.SPECTATOR); } @@ -443,7 +433,7 @@ MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location()); BlockPosition blockposition = worldserver.getSharedSpawnPos(); -@@ -527,20 +778,22 @@ +@@ -521,18 +774,21 @@ this.nextTickTimeNanos = SystemUtils.getNanos(); worldserver.setDefaultSpawnPos(blockposition, worldserver.getSharedSpawnAngle()); @@ -461,20 +451,17 @@ - this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS; - this.waitUntilNextTick(); -- Iterator iterator = this.levels.values().iterator(); + // this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS; + this.executeModerately(); -+ // Iterator iterator = this.levels.values().iterator(); -- while (iterator.hasNext()) { -- WorldServer worldserver1 = (WorldServer) iterator.next(); +- for (WorldServer worldserver1 : this.levels.values()) { + if (true) { + WorldServer worldserver1 = worldserver; + // CraftBukkit end - ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk.factory(), "chunks"); + TicketStorage ticketstorage = (TicketStorage) worldserver1.getDataStorage().get(TicketStorage.TYPE); - if (forcedchunk != null) { -@@ -555,10 +808,17 @@ + if (ticketstorage != null) { +@@ -540,10 +796,17 @@ } } @@ -495,8 +482,8 @@ } public EnumGamemode getDefaultGameType() { -@@ -588,12 +848,16 @@ - worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2); +@@ -572,12 +835,16 @@ + flag3 = true; } + // CraftBukkit start - moved to WorldServer.save @@ -510,9 +497,9 @@ + */ + // CraftBukkit end if (flag1) { - Iterator iterator1 = this.getAllLevels().iterator(); - -@@ -628,18 +892,40 @@ + for (WorldServer worldserver2 : this.getAllLevels()) { + MinecraftServer.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", worldserver2.getChunkSource().chunkMap.getStorageName()); +@@ -608,18 +875,40 @@ this.stopServer(); } @@ -553,7 +540,7 @@ } MinecraftServer.LOGGER.info("Saving worlds"); -@@ -727,7 +1013,7 @@ +@@ -699,7 +988,7 @@ } this.nextTickTimeNanos = SystemUtils.getNanos(); @@ -562,7 +549,7 @@ this.status = this.buildServerStatus(); while (this.running) { -@@ -744,6 +1030,7 @@ +@@ -716,6 +1005,7 @@ if (j > MinecraftServer.OVERLOADED_THRESHOLD_NANOS + 20L * i && this.nextTickTimeNanos - this.lastOverloadWarningNanos >= MinecraftServer.OVERLOADED_WARNING_INTERVAL_NANOS + 100L * i) { long k = j / i; @@ -570,7 +557,7 @@ MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", j / TimeRange.NANOSECONDS_PER_MILLISECOND, k); this.nextTickTimeNanos += k * i; this.lastOverloadWarningNanos = this.nextTickTimeNanos; -@@ -757,6 +1044,7 @@ +@@ -729,6 +1019,7 @@ this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount); } @@ -578,7 +565,7 @@ this.nextTickTimeNanos += i; try { -@@ -830,6 +1118,12 @@ +@@ -802,6 +1093,12 @@ this.services.profileCache().clearExecutor(); } @@ -591,7 +578,7 @@ this.onServerExit(); } -@@ -889,7 +1183,14 @@ +@@ -861,7 +1158,14 @@ } private boolean haveTime() { @@ -607,7 +594,7 @@ } public static boolean throwIfFatalException() { -@@ -903,7 +1204,7 @@ +@@ -875,7 +1179,7 @@ } public static void setFatalException(RuntimeException runtimeexception) { @@ -616,7 +603,7 @@ } @Override -@@ -977,7 +1278,7 @@ +@@ -945,7 +1249,7 @@ } } @@ -625,7 +612,7 @@ Profiler.get().incrementCounter("runTask"); super.doRunTask(ticktask); } -@@ -1041,6 +1342,7 @@ +@@ -1009,6 +1313,7 @@ this.autoSave(); } @@ -633,7 +620,7 @@ this.tickConnection(); return; } -@@ -1055,7 +1357,7 @@ +@@ -1023,7 +1328,7 @@ } --this.ticksUntilAutosave; @@ -642,7 +629,7 @@ this.autoSave(); } -@@ -1074,7 +1376,7 @@ +@@ -1042,7 +1347,7 @@ } private void autoSave() { @@ -651,7 +638,7 @@ MinecraftServer.LOGGER.debug("Autosave started"); GameProfilerFiller gameprofilerfiller = Profiler.get(); -@@ -1154,11 +1456,26 @@ +@@ -1122,21 +1427,38 @@ this.getPlayerList().getPlayers().forEach((entityplayer) -> { entityplayer.connection.suspendFlushing(); }); @@ -659,7 +646,6 @@ gameprofilerfiller.push("commandFunctions"); this.getFunctions().tick(); gameprofilerfiller.popPush("levels"); - Iterator iterator = this.getAllLevels().iterator(); + // CraftBukkit start + // Run tasks that are waiting on processing @@ -675,10 +661,9 @@ + } + } + - while (iterator.hasNext()) { - WorldServer worldserver = (WorldServer) iterator.next(); - -@@ -1167,11 +1484,13 @@ + for (WorldServer worldserver : this.getAllLevels()) { + gameprofilerfiller.push(() -> { + String s = String.valueOf(worldserver); return s + " " + String.valueOf(worldserver.dimension().location()); }); @@ -692,7 +677,7 @@ gameprofilerfiller.push("tick"); -@@ -1267,6 +1586,22 @@ +@@ -1226,6 +1548,22 @@ return (WorldServer) this.levels.get(resourcekey); } @@ -715,7 +700,7 @@ public Set> levelKeys() { return this.levels.keySet(); } -@@ -1296,7 +1631,7 @@ +@@ -1255,7 +1593,7 @@ @DontObfuscate public String getServerModName() { @@ -724,7 +709,7 @@ } public SystemReport fillSystemReport(SystemReport systemreport) { -@@ -1634,11 +1969,11 @@ +@@ -1589,11 +1927,11 @@ public CompletableFuture reloadResources(Collection collection) { CompletableFuture completablefuture = CompletableFuture.supplyAsync(() -> { @@ -736,9 +721,9 @@ - return (ImmutableList) stream.map(resourcepackrepository::getPack).filter(Objects::nonNull).map(ResourcePackLoader::open).collect(ImmutableList.toImmutableList()); + return stream.map(resourcepackrepository::getPack).filter(Objects::nonNull).map(ResourcePackLoader::open).collect(ImmutableList.toImmutableList()); // CraftBukkit - decompile error }, this).thenCompose((immutablelist) -> { - ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist); - List> list = TagDataPack.loadTagsForExistingRegistries(resourcemanager, this.registries.compositeAccess()); -@@ -1654,6 +1989,7 @@ + IReloadableResourceManager ireloadableresourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist); + List> list = TagDataPack.loadTagsForExistingRegistries(ireloadableresourcemanager, this.registries.compositeAccess()); +@@ -1609,6 +1947,7 @@ }).thenAcceptAsync((minecraftserver_reloadableresources) -> { this.resources.close(); this.resources = minecraftserver_reloadableresources; @@ -746,26 +731,8 @@ this.packRepository.setSelected(collection); WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(getSelectedPacks(this.packRepository, true), this.worldData.enabledFeatures()); -@@ -1952,7 +2288,7 @@ - final List list = Lists.newArrayList(); - final GameRules gamerules = this.getGameRules(); - -- gamerules.visitGameRuleTypes(new GameRules.GameRuleVisitor(this) { -+ gamerules.visitGameRuleTypes(new GameRules.GameRuleVisitor() { // CraftBukkit - decompile error - @Override - public > void visit(GameRules.GameRuleKey gamerules_gamerulekey, GameRules.GameRuleDefinition gamerules_gameruledefinition) { - list.add(String.format(Locale.ROOT, "%s=%s\n", gamerules_gamerulekey.getId(), gamerules.getRule(gamerules_gamerulekey))); -@@ -2058,7 +2394,7 @@ - try { - label51: - { -- ArrayList arraylist; -+ ArrayList arraylist; // CraftBukkit - decompile error - - try { - arraylist = Lists.newArrayList(NativeModuleLister.listModules()); -@@ -2108,6 +2444,22 @@ - +@@ -1938,6 +2277,22 @@ + } } + // CraftBukkit start @@ -787,7 +754,7 @@ private GameProfilerFiller createProfiler() { if (this.willStartRecordingMetrics) { this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> { -@@ -2235,6 +2587,11 @@ +@@ -2065,6 +2420,11 @@ } diff --git a/nms-patches/net/minecraft/server/ScoreboardServer.patch b/nms-patches/net/minecraft/server/ScoreboardServer.patch index a99db94a5..0f6cd2ce8 100644 --- a/nms-patches/net/minecraft/server/ScoreboardServer.patch +++ b/nms-patches/net/minecraft/server/ScoreboardServer.patch @@ -1,6 +1,15 @@ --- a/net/minecraft/server/ScoreboardServer.java +++ b/net/minecraft/server/ScoreboardServer.java -@@ -42,7 +42,7 @@ +@@ -32,7 +32,7 @@ + return persistentbase_a.levelOrThrow().getScoreboard().createData(); + }, (persistentbase_a) -> { + ScoreboardServer scoreboardserver = persistentbase_a.levelOrThrow().getScoreboard(); +- Codec codec = PersistentScoreboard.a.CODEC; ++ Codec codec = PersistentScoreboard.a.CODEC; // CraftBukkit - decompile error + + Objects.requireNonNull(scoreboardserver); + return codec.xmap(scoreboardserver::createData, PersistentScoreboard::pack); +@@ -49,7 +49,7 @@ protected void onScoreChanged(ScoreHolder scoreholder, ScoreboardObjective scoreboardobjective, ScoreboardScore scoreboardscore) { super.onScoreChanged(scoreholder, scoreboardobjective, scoreboardscore); if (this.trackedObjectives.contains(scoreboardobjective)) { @@ -9,7 +18,7 @@ } this.setDirty(); -@@ -57,7 +57,7 @@ +@@ -64,7 +64,7 @@ @Override public void onPlayerRemoved(ScoreHolder scoreholder) { super.onPlayerRemoved(scoreholder); @@ -18,7 +27,7 @@ this.setDirty(); } -@@ -65,7 +65,7 @@ +@@ -72,7 +72,7 @@ public void onPlayerScoreRemoved(ScoreHolder scoreholder, ScoreboardObjective scoreboardobjective) { super.onPlayerScoreRemoved(scoreholder, scoreboardobjective); if (this.trackedObjectives.contains(scoreboardobjective)) { @@ -27,7 +36,7 @@ } this.setDirty(); -@@ -78,7 +78,7 @@ +@@ -85,7 +85,7 @@ super.setDisplayObjective(displayslot, scoreboardobjective); if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) { if (this.getObjectiveDisplaySlotCount(scoreboardobjective1) > 0) { @@ -36,7 +45,7 @@ } else { this.stopTrackingObjective(scoreboardobjective1); } -@@ -86,7 +86,7 @@ +@@ -93,7 +93,7 @@ if (scoreboardobjective != null) { if (this.trackedObjectives.contains(scoreboardobjective)) { @@ -45,7 +54,7 @@ } else { this.startTrackingObjective(scoreboardobjective); } -@@ -98,7 +98,7 @@ +@@ -105,7 +105,7 @@ @Override public boolean addPlayerToTeam(String s, ScoreboardTeam scoreboardteam) { if (super.addPlayerToTeam(s, scoreboardteam)) { @@ -54,7 +63,7 @@ this.setDirty(); return true; } else { -@@ -109,7 +109,7 @@ +@@ -116,7 +116,7 @@ @Override public void removePlayerFromTeam(String s, ScoreboardTeam scoreboardteam) { super.removePlayerFromTeam(s, scoreboardteam); @@ -63,7 +72,7 @@ this.setDirty(); } -@@ -123,7 +123,7 @@ +@@ -130,7 +130,7 @@ public void onObjectiveChanged(ScoreboardObjective scoreboardobjective) { super.onObjectiveChanged(scoreboardobjective); if (this.trackedObjectives.contains(scoreboardobjective)) { @@ -72,7 +81,7 @@ } this.setDirty(); -@@ -142,21 +142,21 @@ +@@ -149,21 +149,21 @@ @Override public void onTeamAdded(ScoreboardTeam scoreboardteam) { super.onTeamAdded(scoreboardteam); @@ -97,24 +106,24 @@ this.setDirty(); } -@@ -207,6 +207,7 @@ +@@ -200,6 +200,7 @@ + List> list = this.getStartTrackingPackets(scoreboardobjective); - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); + for (EntityPlayer entityplayer : this.server.getPlayerList().getPlayers()) { + if (entityplayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board - Iterator iterator1 = list.iterator(); + for (Packet packet : list) { + entityplayer.connection.send(packet); + } +@@ -226,6 +227,7 @@ + List> list = this.getStopTrackingPackets(scoreboardobjective); - while (iterator1.hasNext()) { -@@ -243,6 +244,7 @@ - - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); + for (EntityPlayer entityplayer : this.server.getPlayerList().getPlayers()) { + if (entityplayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board - Iterator iterator1 = list.iterator(); - - while (iterator1.hasNext()) { -@@ -287,6 +289,16 @@ - return this.createData().load(nbttagcompound, holderlookup_a); + for (Packet packet : list) { + entityplayer.connection.send(packet); + } +@@ -261,6 +263,16 @@ + return persistentscoreboard; } + // CraftBukkit start - Send to players diff --git a/nms-patches/net/minecraft/server/bossevents/BossBattleCustom.patch b/nms-patches/net/minecraft/server/bossevents/BossBattleCustom.patch index 3dacf9566..58b6615db 100644 --- a/nms-patches/net/minecraft/server/bossevents/BossBattleCustom.patch +++ b/nms-patches/net/minecraft/server/bossevents/BossBattleCustom.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/bossevents/BossBattleCustom.java +++ b/net/minecraft/server/bossevents/BossBattleCustom.java -@@ -19,12 +19,27 @@ +@@ -19,6 +19,11 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.BossBattle; @@ -11,7 +11,8 @@ + public class BossBattleCustom extends BossBattleServer { - private final MinecraftKey id; + private static final int DEFAULT_MAX = 100; +@@ -26,6 +31,16 @@ private final Set players = Sets.newHashSet(); private int value; private int max = 100; @@ -28,3 +29,12 @@ public BossBattleCustom(MinecraftKey minecraftkey, IChatBaseComponent ichatbasecomponent) { super(ichatbasecomponent, BossBattle.BarColor.WHITE, BossBattle.BarStyle.PROGRESS); +@@ -168,7 +183,7 @@ + bossbattlecustom.setDarkenScreen(bossbattlecustom_a.darkenScreen); + bossbattlecustom.setPlayBossMusic(bossbattlecustom_a.playBossMusic); + bossbattlecustom.setCreateWorldFog(bossbattlecustom_a.createWorldFog); +- Set set = bossbattlecustom_a.players; ++ Set set = bossbattlecustom_a.players; // CraftBukkit - decompile error + + Objects.requireNonNull(bossbattlecustom); + set.forEach(bossbattlecustom::addOfflinePlayer); diff --git a/nms-patches/net/minecraft/server/commands/CommandDifficulty.patch b/nms-patches/net/minecraft/server/commands/CommandDifficulty.patch index 2a303cc1f..c30db44e5 100644 --- a/nms-patches/net/minecraft/server/commands/CommandDifficulty.patch +++ b/nms-patches/net/minecraft/server/commands/CommandDifficulty.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/CommandDifficulty.java +++ b/net/minecraft/server/commands/CommandDifficulty.java -@@ -44,11 +44,12 @@ +@@ -40,11 +40,12 @@ public static int setDifficulty(CommandListenerWrapper commandlistenerwrapper, EnumDifficulty enumdifficulty) throws CommandSyntaxException { MinecraftServer minecraftserver = commandlistenerwrapper.getServer(); diff --git a/nms-patches/net/minecraft/server/commands/CommandEffect.patch b/nms-patches/net/minecraft/server/commands/CommandEffect.patch index f1896566c..ef6aaa0e0 100644 --- a/nms-patches/net/minecraft/server/commands/CommandEffect.patch +++ b/nms-patches/net/minecraft/server/commands/CommandEffect.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/CommandEffect.java +++ b/net/minecraft/server/commands/CommandEffect.java -@@ -84,7 +84,7 @@ +@@ -79,7 +79,7 @@ if (entity instanceof EntityLiving) { MobEffect mobeffect = new MobEffect(holder, k, i, false, flag); @@ -9,19 +9,19 @@ ++j; } } -@@ -114,7 +114,7 @@ - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); +@@ -106,7 +106,7 @@ + int i = 0; + for (Entity entity : collection) { - if (entity instanceof EntityLiving && ((EntityLiving) entity).removeAllEffects()) { + if (entity instanceof EntityLiving && ((EntityLiving) entity).removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit ++i; } } -@@ -144,7 +144,7 @@ - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); +@@ -133,7 +133,7 @@ + int i = 0; + for (Entity entity : collection) { - if (entity instanceof EntityLiving && ((EntityLiving) entity).removeEffect(holder)) { + if (entity instanceof EntityLiving && ((EntityLiving) entity).removeEffect(holder, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit ++i; diff --git a/nms-patches/net/minecraft/server/commands/CommandGamerule.patch b/nms-patches/net/minecraft/server/commands/CommandGamerule.patch index f3107570d..3c41d68d8 100644 --- a/nms-patches/net/minecraft/server/commands/CommandGamerule.patch +++ b/nms-patches/net/minecraft/server/commands/CommandGamerule.patch @@ -7,7 +7,7 @@ - T t0 = commandlistenerwrapper.getServer().getGameRules().getRule(gamerules_gamerulekey); + T t0 = commandlistenerwrapper.getLevel().getGameRules().getRule(gamerules_gamerulekey); // CraftBukkit - t0.setFromArgument(commandcontext, "value"); + ((GameRules.GameRuleValue) t0).setFromArgument(commandcontext, "value"); commandlistenerwrapper.sendSuccess(() -> { @@ -44,7 +44,7 @@ } diff --git a/nms-patches/net/minecraft/server/commands/CommandGive.patch b/nms-patches/net/minecraft/server/commands/CommandGive.patch index bf774c373..729b500dd 100644 --- a/nms-patches/net/minecraft/server/commands/CommandGive.patch +++ b/nms-patches/net/minecraft/server/commands/CommandGive.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/commands/CommandGive.java +++ b/net/minecraft/server/commands/CommandGive.java -@@ -60,7 +60,7 @@ - EntityItem entityitem; +@@ -55,7 +55,7 @@ + boolean flag = entityplayer.getInventory().add(itemstack1); if (flag && itemstack1.isEmpty()) { -- entityitem = entityplayer.drop(itemstack, false); -+ entityitem = entityplayer.drop(itemstack, false, false, false); // CraftBukkit - SPIGOT-2942: Add boolean to call event +- EntityItem entityitem = entityplayer.drop(itemstack, false); ++ EntityItem entityitem = entityplayer.drop(itemstack, false, false, false); // CraftBukkit - SPIGOT-2942: Add boolean to call event + if (entityitem != null) { entityitem.makeFakeItem(); - } diff --git a/nms-patches/net/minecraft/server/commands/CommandLoot.patch b/nms-patches/net/minecraft/server/commands/CommandLoot.patch index d68afd407..37d8a3706 100644 --- a/nms-patches/net/minecraft/server/commands/CommandLoot.patch +++ b/nms-patches/net/minecraft/server/commands/CommandLoot.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/server/commands/CommandLoot.java +++ b/net/minecraft/server/commands/CommandLoot.java -@@ -95,7 +95,7 @@ - } - - private static > T addTargets(T t0, CommandLoot.c commandloot_c) { -- return t0.then(((LiteralArgumentBuilder) net.minecraft.commands.CommandDispatcher.literal("replace").then(net.minecraft.commands.CommandDispatcher.literal("entity").then(net.minecraft.commands.CommandDispatcher.argument("entities", ArgumentEntity.entities()).then(commandloot_c.construct(net.minecraft.commands.CommandDispatcher.argument("slot", ArgumentInventorySlot.slot()), (commandcontext, list, commandloot_a) -> { -+ return (T) t0.then(((LiteralArgumentBuilder) net.minecraft.commands.CommandDispatcher.literal("replace").then(net.minecraft.commands.CommandDispatcher.literal("entity").then(net.minecraft.commands.CommandDispatcher.argument("entities", ArgumentEntity.entities()).then(commandloot_c.construct(net.minecraft.commands.CommandDispatcher.argument("slot", ArgumentInventorySlot.slot()), (commandcontext, list, commandloot_a) -> { // CraftBukkit - decompile error - return entityReplace(ArgumentEntity.getEntities(commandcontext, "entities"), ArgumentInventorySlot.getSlot(commandcontext, "slot"), list.size(), list, commandloot_a); - }).then(commandloot_c.construct(net.minecraft.commands.CommandDispatcher.argument("count", IntegerArgumentType.integer(0)), (commandcontext, list, commandloot_a) -> { - return entityReplace(ArgumentEntity.getEntities(commandcontext, "entities"), ArgumentInventorySlot.getSlot(commandcontext, "slot"), IntegerArgumentType.getInteger(commandcontext, "count"), list, commandloot_a); -@@ -250,6 +250,7 @@ +@@ -237,6 +237,7 @@ private static int dropInWorld(CommandListenerWrapper commandlistenerwrapper, Vec3D vec3d, List list, CommandLoot.a commandloot_a) throws CommandSyntaxException { WorldServer worldserver = commandlistenerwrapper.getLevel(); diff --git a/nms-patches/net/minecraft/server/commands/CommandReload.patch b/nms-patches/net/minecraft/server/commands/CommandReload.patch index 46887c014..17544cae2 100644 --- a/nms-patches/net/minecraft/server/commands/CommandReload.patch +++ b/nms-patches/net/minecraft/server/commands/CommandReload.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/CommandReload.java +++ b/net/minecraft/server/commands/CommandReload.java -@@ -44,6 +44,16 @@ +@@ -40,6 +40,16 @@ return collection1; } diff --git a/nms-patches/net/minecraft/server/commands/CommandSchedule.patch b/nms-patches/net/minecraft/server/commands/CommandSchedule.patch index 96177b3a2..704118821 100644 --- a/nms-patches/net/minecraft/server/commands/CommandSchedule.patch +++ b/nms-patches/net/minecraft/server/commands/CommandSchedule.patch @@ -7,5 +7,5 @@ - CustomFunctionCallbackTimerQueue customfunctioncallbacktimerqueue = commandlistenerwrapper.getServer().getWorldData().overworldData().getScheduledEvents(); + CustomFunctionCallbackTimerQueue customfunctioncallbacktimerqueue = commandlistenerwrapper.getLevel().serverLevelData.overworldData().getScheduledEvents(); // CraftBukkit - SPIGOT-6667: Use world specific function timer Optional> optional = ((Either) pair.getSecond()).left(); - String s; + if (optional.isPresent()) { diff --git a/nms-patches/net/minecraft/server/commands/CommandSpawnpoint.patch b/nms-patches/net/minecraft/server/commands/CommandSpawnpoint.patch index 20b1a585e..ecb965a39 100644 --- a/nms-patches/net/minecraft/server/commands/CommandSpawnpoint.patch +++ b/nms-patches/net/minecraft/server/commands/CommandSpawnpoint.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/commands/CommandSpawnpoint.java +++ b/net/minecraft/server/commands/CommandSpawnpoint.java -@@ -41,7 +41,7 @@ - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); +@@ -37,7 +37,7 @@ + ResourceKey resourcekey = commandlistenerwrapper.getLevel().dimension(); -- entityplayer.setRespawnPosition(resourcekey, blockposition, f, true, false); -+ entityplayer.setRespawnPosition(resourcekey, blockposition, f, true, false, org.bukkit.event.player.PlayerSpawnChangeEvent.Cause.COMMAND); // CraftBukkit + for (EntityPlayer entityplayer : collection) { +- entityplayer.setRespawnPosition(new EntityPlayer.RespawnConfig(resourcekey, blockposition, f, true), false); ++ entityplayer.setRespawnPosition(new EntityPlayer.RespawnConfig(resourcekey, blockposition, f, true), false, org.bukkit.event.player.PlayerSpawnChangeEvent.Cause.COMMAND); // CraftBukkit } String s = resourcekey.location().toString(); diff --git a/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch b/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch index 67d39d332..7f6207e9c 100644 --- a/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch +++ b/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/CommandSpreadPlayers.java +++ b/net/minecraft/server/commands/CommandSpreadPlayers.java -@@ -93,7 +93,7 @@ +@@ -88,7 +88,7 @@ if (entity instanceof EntityHuman) { set.add(entity.getTeam()); } else { @@ -9,12 +9,12 @@ } } -@@ -203,7 +203,7 @@ +@@ -187,7 +187,7 @@ commandspreadplayers_a = acommandspreadplayers_a[j++]; } - entity.teleportTo(worldserver, (double) MathHelper.floor(commandspreadplayers_a.x) + 0.5D, (double) commandspreadplayers_a.getSpawnY(worldserver, i), (double) MathHelper.floor(commandspreadplayers_a.z) + 0.5D, Set.of(), entity.getYRot(), entity.getXRot(), true); + entity.teleportTo(worldserver, (double) MathHelper.floor(commandspreadplayers_a.x) + 0.5D, (double) commandspreadplayers_a.getSpawnY(worldserver, i), (double) MathHelper.floor(commandspreadplayers_a.z) + 0.5D, Set.of(), entity.getYRot(), entity.getXRot(), true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit - handle teleport reason - d1 = Double.MAX_VALUE; - CommandSpreadPlayers.a[] acommandspreadplayers_a1 = acommandspreadplayers_a; - int k = acommandspreadplayers_a.length; + double d1 = Double.MAX_VALUE; + + for (CommandSpreadPlayers.a commandspreadplayers_a1 : acommandspreadplayers_a) { diff --git a/nms-patches/net/minecraft/server/commands/CommandTeleport.patch b/nms-patches/net/minecraft/server/commands/CommandTeleport.patch index 01612c03d..ef13b0820 100644 --- a/nms-patches/net/minecraft/server/commands/CommandTeleport.patch +++ b/nms-patches/net/minecraft/server/commands/CommandTeleport.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/CommandTeleport.java +++ b/net/minecraft/server/commands/CommandTeleport.java -@@ -31,6 +31,14 @@ +@@ -30,6 +30,14 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; @@ -15,7 +15,7 @@ public class CommandTeleport { private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(IChatBaseComponent.translatable("commands.teleport.invalidPosition")); -@@ -167,7 +175,30 @@ +@@ -160,7 +168,30 @@ float f4 = MathHelper.wrapDegrees(f2); float f5 = MathHelper.wrapDegrees(f3); diff --git a/nms-patches/net/minecraft/server/commands/CommandTime.patch b/nms-patches/net/minecraft/server/commands/CommandTime.patch index 6fd4ab8ae..af95e238e 100644 --- a/nms-patches/net/minecraft/server/commands/CommandTime.patch +++ b/nms-patches/net/minecraft/server/commands/CommandTime.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/CommandTime.java +++ b/net/minecraft/server/commands/CommandTime.java -@@ -9,6 +9,11 @@ +@@ -8,6 +8,11 @@ import net.minecraft.network.chat.IChatBaseComponent; import net.minecraft.server.level.WorldServer; @@ -12,18 +12,15 @@ public class CommandTime { public CommandTime() {} -@@ -49,12 +54,18 @@ +@@ -48,8 +53,15 @@ } public static int setTime(CommandListenerWrapper commandlistenerwrapper, int i) { -- Iterator iterator = commandlistenerwrapper.getServer().getAllLevels().iterator(); -+ Iterator iterator = com.google.common.collect.Iterators.singletonIterator(commandlistenerwrapper.getLevel()); // CraftBukkit - SPIGOT-6496: Only set the time for the world the command originates in - - while (iterator.hasNext()) { - WorldServer worldserver = (WorldServer) iterator.next(); - +- for (WorldServer worldserver : commandlistenerwrapper.getServer().getAllLevels()) { - worldserver.setDayTime((long) i); -+ // CraftBukkit start ++ // CraftBukkit start - SPIGOT-6496: Only set the time for the world the command originates in ++ { ++ WorldServer worldserver = commandlistenerwrapper.getLevel(); + TimeSkipEvent event = new TimeSkipEvent(worldserver.getWorld(), TimeSkipEvent.SkipReason.COMMAND, i - worldserver.getDayTime()); + Bukkit.getPluginManager().callEvent(event); + if (!event.isCancelled()) { @@ -33,18 +30,15 @@ } commandlistenerwrapper.getServer().forceTimeSynchronization(); -@@ -65,12 +76,18 @@ +@@ -60,8 +72,15 @@ } public static int addTime(CommandListenerWrapper commandlistenerwrapper, int i) { -- Iterator iterator = commandlistenerwrapper.getServer().getAllLevels().iterator(); -+ Iterator iterator = com.google.common.collect.Iterators.singletonIterator(commandlistenerwrapper.getLevel()); // CraftBukkit - SPIGOT-6496: Only set the time for the world the command originates in - - while (iterator.hasNext()) { - WorldServer worldserver = (WorldServer) iterator.next(); - +- for (WorldServer worldserver : commandlistenerwrapper.getServer().getAllLevels()) { - worldserver.setDayTime(worldserver.getDayTime() + (long) i); -+ // CraftBukkit start ++ // CraftBukkit start - SPIGOT-6496: Only set the time for the world the command originates in ++ { ++ WorldServer worldserver = commandlistenerwrapper.getLevel(); + TimeSkipEvent event = new TimeSkipEvent(worldserver.getWorld(), TimeSkipEvent.SkipReason.COMMAND, i); + Bukkit.getPluginManager().callEvent(event); + if (!event.isCancelled()) { diff --git a/nms-patches/net/minecraft/server/commands/PlaceCommand.patch b/nms-patches/net/minecraft/server/commands/PlaceCommand.patch index 61c08f6c4..642c0f6b1 100644 --- a/nms-patches/net/minecraft/server/commands/PlaceCommand.patch +++ b/nms-patches/net/minecraft/server/commands/PlaceCommand.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/PlaceCommand.java +++ b/net/minecraft/server/commands/PlaceCommand.java -@@ -132,6 +132,7 @@ +@@ -134,6 +134,7 @@ if (!structurestart.isValid()) { throw PlaceCommand.ERROR_STRUCTURE_FAILED.create(); } else { diff --git a/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch b/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch index 2b0e23970..04a3edb88 100644 --- a/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch +++ b/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch @@ -169,7 +169,7 @@ } if (dedicatedserverproperties.enableQuery) { -@@ -293,6 +367,7 @@ +@@ -278,6 +352,7 @@ this.queryThreadGs4.stop(); } @@ -177,7 +177,7 @@ } @Override -@@ -314,7 +389,15 @@ +@@ -299,7 +374,15 @@ while (!this.consoleInput.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0); @@ -194,7 +194,7 @@ } } -@@ -541,16 +624,52 @@ +@@ -524,16 +607,52 @@ @Override public String getPluginNames() { @@ -251,7 +251,7 @@ } public void storeUsingWhiteList(boolean flag) { -@@ -660,4 +779,15 @@ +@@ -643,4 +762,15 @@ } } } diff --git a/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch b/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch index 89fcf8664..d15b7e332 100644 --- a/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch +++ b/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch @@ -72,7 +72,7 @@ @@ -269,7 +278,7 @@ if (holder.is(WorldPresets.FLAT)) { - RegistryOps registryops = holderlookup_a.createSerializationContext(JsonOps.INSTANCE); + RegistryOps registryops = holderlookup_a.createSerializationContext(JsonOps.INSTANCE); - DataResult dataresult = GeneratorSettingsFlat.CODEC.parse(new Dynamic(registryops, this.generatorSettings())); + DataResult dataresult = GeneratorSettingsFlat.CODEC.parse(new Dynamic(registryops, this.generatorSettings())); // CraftBukkit - decompile error Logger logger = DedicatedServerProperties.LOGGER; diff --git a/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch b/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch index 7ad50cc4b..182c81695 100644 --- a/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch +++ b/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch @@ -36,22 +36,22 @@ + return new Properties(); + } + // CraftBukkit end - Properties properties; - Properties properties1; - -@@ -97,6 +117,11 @@ + try (InputStream inputstream = Files.newInputStream(path)) { + CharsetDecoder charsetdecoder = StandardCharsets.UTF_8.newDecoder().onMalformedInput(CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPORT); + Properties properties = new Properties(); +@@ -57,6 +77,11 @@ + } public void store(Path path) { - try { -+ // CraftBukkit start - Don't attempt writing to file if it's read only -+ if (path.toFile().exists() && !path.toFile().canWrite()) { -+ return; -+ } -+ // CraftBukkit end - BufferedWriter bufferedwriter = Files.newBufferedWriter(path, StandardCharsets.UTF_8); - - try { -@@ -125,7 +150,7 @@ ++ // CraftBukkit start - Don't attempt writing to file if it's read only ++ if (path.toFile().exists() && !path.toFile().canWrite()) { ++ return; ++ } ++ // CraftBukkit end + try (Writer writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) { + this.properties.store(writer, "Minecraft server properties"); + } catch (IOException ioexception) { +@@ -68,7 +93,7 @@ private static Function wrapNumberDeserializer(Function function) { return (s) -> { try { @@ -60,7 +60,7 @@ } catch (NumberFormatException numberformatexception) { return null; } -@@ -144,7 +169,7 @@ +@@ -87,7 +112,7 @@ @Nullable private String getStringRaw(String s) { @@ -69,7 +69,7 @@ } @Nullable -@@ -160,6 +185,16 @@ +@@ -103,6 +128,16 @@ } protected V get(String s, Function function, Function function1, V v0) { @@ -84,18 +84,18 @@ + private V get0(String s, Function function, Function function1, V v0) { + // CraftBukkit end String s1 = this.getStringRaw(s); - V v1 = MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0); + V v1 = (V) MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0); -@@ -172,7 +207,7 @@ - V v1 = MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0); +@@ -115,7 +150,7 @@ + V v1 = (V) MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0); this.properties.put(s, function1.apply(v1)); -- return new PropertyManager.EditableProperty<>(s, v1, function1); +- return new PropertyManager.EditableProperty(s, v1, function1); + return new PropertyManager.EditableProperty(s, v1, function1); // CraftBukkit - decompile error } protected V get(String s, Function function, UnaryOperator unaryoperator, Function function1, V v0) { -@@ -236,7 +271,7 @@ +@@ -179,7 +214,7 @@ return properties; } @@ -104,7 +104,7 @@ public class EditableProperty implements Supplier { -@@ -244,7 +279,7 @@ +@@ -187,7 +222,7 @@ private final V value; private final Function serializer; @@ -113,12 +113,12 @@ this.key = s; this.value = object; this.serializer = function; -@@ -258,7 +293,7 @@ +@@ -201,7 +236,7 @@ Properties properties = PropertyManager.this.cloneProperties(); properties.put(this.key, this.serializer.apply(v0)); -- return PropertyManager.this.reload(iregistrycustom, properties); -+ return PropertyManager.this.reload(iregistrycustom, properties, PropertyManager.this.options); // CraftBukkit +- return (T) PropertyManager.this.reload(iregistrycustom, properties); ++ return (T) PropertyManager.this.reload(iregistrycustom, properties, PropertyManager.this.options); // CraftBukkit } } } diff --git a/nms-patches/net/minecraft/server/gui/ServerGUI.patch b/nms-patches/net/minecraft/server/gui/ServerGUI.patch index e99114a8d..5c6b09ab3 100644 --- a/nms-patches/net/minecraft/server/gui/ServerGUI.patch +++ b/nms-patches/net/minecraft/server/gui/ServerGUI.patch @@ -9,15 +9,6 @@ Objects.requireNonNull(guistatscomponent); collection.add(guistatscomponent::close); -@@ -132,7 +132,7 @@ - - jtextfield.setText(""); - }); -- jtextarea.addFocusListener(new FocusAdapter(this) { -+ jtextarea.addFocusListener(new FocusAdapter() { // CraftBukkit - decompile error - public void focusGained(FocusEvent focusevent) {} - }); - jpanel.add(jscrollpane, "Center"); @@ -166,6 +166,7 @@ this.finalizers.forEach(Runnable::run); } diff --git a/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch b/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch index 8a42bd4da..c78451d48 100644 --- a/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch +++ b/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch @@ -1,93 +1,18 @@ --- a/net/minecraft/server/level/ChunkMapDistance.java +++ b/net/minecraft/server/level/ChunkMapDistance.java -@@ -117,6 +117,15 @@ - - PlayerChunk playerchunk; +@@ -77,6 +77,11 @@ + } + if (!this.chunksToUpdateFutures.isEmpty()) { + // CraftBukkit start - SPIGOT-7780: Call chunk unload events before updateHighestAllowedStatus -+ while (iterator.hasNext()) { -+ playerchunk = (PlayerChunk) iterator.next(); ++ for (PlayerChunk playerchunk : this.chunksToUpdateFutures) { + playerchunk.callEventIfUnloading(playerchunkmap); + } -+ -+ iterator = this.chunksToUpdateFutures.iterator(); + // CraftBukkit end -+ - while (iterator.hasNext()) { - playerchunk = (PlayerChunk) iterator.next(); + for (PlayerChunk playerchunk : this.chunksToUpdateFutures) { playerchunk.updateHighestAllowedStatus(playerchunkmap); -@@ -165,7 +174,7 @@ - } - } - -- void addTicket(long i, Ticket ticket) { -+ boolean addTicket(long i, Ticket ticket) { // CraftBukkit - void -> boolean - ArraySetSorted> arraysetsorted = this.getTickets(i); - int j = getTicketLevelAt(arraysetsorted); - Ticket ticket1 = (Ticket) arraysetsorted.addOrGet(ticket); -@@ -175,13 +184,15 @@ - this.ticketTracker.update(i, ticket.getTicketLevel(), true); - } - -+ return ticket == ticket1; // CraftBukkit - } - -- void removeTicket(long i, Ticket ticket) { -+ boolean removeTicket(long i, Ticket ticket) { // CraftBukkit - void -> boolean - ArraySetSorted> arraysetsorted = this.getTickets(i); - -+ boolean removed = false; // CraftBukkit - if (arraysetsorted.remove(ticket)) { -- ; -+ removed = true; // CraftBukkit - } - - if (arraysetsorted.isEmpty()) { -@@ -189,6 +200,7 @@ - } - - this.ticketTracker.update(i, getTicketLevelAt(arraysetsorted), false); -+ return removed; // CraftBukkit - } - - public void addTicket(TicketType tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { -@@ -202,19 +214,33 @@ - } - - public void addRegionTicket(TicketType tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { -+ // CraftBukkit start -+ addRegionTicketAtDistance(tickettype, chunkcoordintpair, i, t0); -+ } -+ -+ public boolean addRegionTicketAtDistance(TicketType tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { -+ // CraftBukkit end - Ticket ticket = new Ticket<>(tickettype, ChunkLevel.byStatus(FullChunkStatus.FULL) - i, t0); - long j = chunkcoordintpair.toLong(); - -- this.addTicket(j, ticket); -+ boolean added = this.addTicket(j, ticket); // CraftBukkit - this.tickingTicketsTracker.addTicket(j, ticket); -+ return added; // CraftBukkit - } - - public void removeRegionTicket(TicketType tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { -+ // CraftBukkit start -+ removeRegionTicketAtDistance(tickettype, chunkcoordintpair, i, t0); -+ } -+ -+ public boolean removeRegionTicketAtDistance(TicketType tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { -+ // CraftBukkit end - Ticket ticket = new Ticket<>(tickettype, ChunkLevel.byStatus(FullChunkStatus.FULL) - i, t0); - long j = chunkcoordintpair.toLong(); - -- this.removeTicket(j, ticket); -+ boolean removed = this.removeTicket(j, ticket); // CraftBukkit - this.tickingTicketsTracker.removeTicket(j, ticket); -+ return removed; // CraftBukkit - } - - private ArraySetSorted> getTickets(long i) { -@@ -253,6 +279,7 @@ + } +@@ -137,6 +142,7 @@ ChunkCoordIntPair chunkcoordintpair = sectionposition.chunk(); long i = chunkcoordintpair.toLong(); ObjectSet objectset = (ObjectSet) this.playersPerChunk.get(i); @@ -95,30 +20,3 @@ objectset.remove(entityplayer); if (objectset.isEmpty()) { -@@ -391,6 +418,26 @@ - 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(); -+ ArraySetSorted> tickets = entry.getValue(); -+ if (tickets.remove(target)) { -+ // copied from removeTicket -+ this.ticketTracker.update(entry.getLongKey(), getTicketLevelAt(tickets), false); -+ -+ // can't use entry after it's removed -+ if (tickets.isEmpty()) { -+ iterator.remove(); -+ } -+ } -+ } -+ } -+ // CraftBukkit end -+ - private class a extends ChunkMap { - - private static final int MAX_LEVEL = ChunkLevel.MAX_LEVEL + 1; diff --git a/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch b/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch index 6d00dd684..1d5926132 100644 --- a/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch +++ b/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ChunkProviderServer.java +++ b/net/minecraft/server/level/ChunkProviderServer.java -@@ -96,6 +96,16 @@ +@@ -100,6 +100,16 @@ this.clearCache(); } @@ -17,7 +17,7 @@ @Override public LightEngineThreaded getLightEngine() { return this.lightEngine; -@@ -139,7 +149,7 @@ +@@ -143,7 +153,7 @@ if (k == this.lastChunkPos[l] && chunkstatus == this.lastChunkStatus[l]) { IChunkAccess ichunkaccess = this.lastChunk[l]; @@ -26,16 +26,16 @@ return ichunkaccess; } } -@@ -152,7 +162,7 @@ +@@ -156,7 +166,7 @@ Objects.requireNonNull(completablefuture); - chunkproviderserver_b.managedBlock(completablefuture::isDone); + chunkproviderserver_a.managedBlock(completablefuture::isDone); ChunkResult chunkresult = (ChunkResult) completablefuture.join(); -- IChunkAccess ichunkaccess1 = (IChunkAccess) chunkresult.orElse((Object) null); -+ IChunkAccess ichunkaccess1 = (IChunkAccess) chunkresult.orElse(null); // CraftBukkit - decompile error +- IChunkAccess ichunkaccess1 = chunkresult.orElse((Object) null); ++ IChunkAccess ichunkaccess1 = chunkresult.orElse(null); // CraftBukkit - decompile error if (ichunkaccess1 == null && flag) { throw (IllegalStateException) SystemUtils.pauseInIde(new IllegalStateException("Chunk not there when requested: " + chunkresult.getError())); -@@ -232,7 +242,15 @@ +@@ -236,7 +246,15 @@ int l = ChunkLevel.byStatus(chunkstatus); PlayerChunk playerchunk = this.getVisibleChunkIfPresent(k); @@ -49,10 +49,10 @@ + } + if (flag && !currentlyUnloading) { + // CraftBukkit end - this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair); + this.addTicket(new Ticket(TicketType.UNKNOWN, l), chunkcoordintpair); if (this.chunkAbsent(playerchunk, l)) { GameProfilerFiller gameprofilerfiller = Profiler.get(); -@@ -251,7 +269,7 @@ +@@ -255,7 +273,7 @@ } private boolean chunkAbsent(@Nullable PlayerChunk playerchunk, int i) { @@ -61,7 +61,7 @@ } @Override -@@ -310,12 +328,34 @@ +@@ -314,12 +332,34 @@ @Override public void close() throws IOException { @@ -85,7 +85,7 @@ + GameProfilerFiller gameprofilerfiller = Profiler.get(); + + gameprofilerfiller.push("purge"); -+ this.distanceManager.purgeStaleTickets(); ++ this.ticketStorage.purgeStaleTickets(); + this.runDistanceManagerUpdates(); + gameprofilerfiller.popPush("unload"); + this.chunkMap.tick(() -> true); @@ -97,25 +97,25 @@ @Override public void tick(BooleanSupplier booleansupplier, boolean flag) { GameProfilerFiller gameprofilerfiller = Profiler.get(); -@@ -402,14 +442,14 @@ +@@ -384,14 +424,14 @@ this.lastSpawnState = spawnercreature_d; gameprofilerfiller.popPush("spawnAndTick"); - boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING); + boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); - List list1; + List list; if (flag && (this.spawnEnemies || this.spawnFriendlies)) { - boolean flag1 = this.level.getLevelData().getGameTime() % 400L == 0L; + boolean flag1 = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getLevelData().getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit -- list1 = SpawnerCreature.getFilteredSpawningCategories(spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1); -+ list1 = SpawnerCreature.getFilteredSpawningCategories(spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1, this.level); // CraftBukkit +- list = SpawnerCreature.getFilteredSpawningCategories(spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1); ++ list = SpawnerCreature.getFilteredSpawningCategories(spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1, this.level); // CraftBukkit } else { - list1 = List.of(); + list = List.of(); } -@@ -542,8 +582,14 @@ +@@ -554,8 +594,14 @@ @Override public void setSpawnSettings(boolean flag) { @@ -131,7 +131,7 @@ } public String getChunkDebugData(ChunkCoordIntPair chunkcoordintpair) { -@@ -619,13 +665,19 @@ +@@ -631,13 +677,19 @@ } @Override @@ -151,4 +151,4 @@ + // CraftBukkit end } } - + } diff --git a/nms-patches/net/minecraft/server/level/EntityPlayer.patch b/nms-patches/net/minecraft/server/level/EntityPlayer.patch index e88bc39cd..598e12125 100644 --- a/nms-patches/net/minecraft/server/level/EntityPlayer.patch +++ b/nms-patches/net/minecraft/server/level/EntityPlayer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/EntityPlayer.java +++ b/net/minecraft/server/level/EntityPlayer.java -@@ -183,6 +183,41 @@ +@@ -189,6 +189,41 @@ import net.minecraft.world.scores.criteria.IScoreboardCriteria; import org.slf4j.Logger; @@ -42,7 +42,7 @@ public class EntityPlayer extends EntityHuman { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -225,7 +260,7 @@ +@@ -234,7 +269,7 @@ private int levitationStartTime; private boolean disconnected; private int requestedViewDistance; @@ -51,7 +51,7 @@ @Nullable private Vec3D startingToFallPosition; @Nullable -@@ -259,6 +294,22 @@ +@@ -265,6 +300,22 @@ private int containerCounter; public boolean wonGame; @@ -74,7 +74,16 @@ public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, ClientInformation clientinformation) { super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile); this.chatVisibility = EnumChatVisibility.FULL; -@@ -340,6 +391,13 @@ +@@ -329,7 +380,7 @@ + + @Override + public RemoteSlot createSlot() { +- LoadingCache loadingcache = this.cache; ++ LoadingCache,Integer> loadingcache = this.cache; // CraftBukkit - decompile error + + Objects.requireNonNull(this.cache); + return new RemoteSlot.a(loadingcache::getUnchecked); +@@ -371,6 +422,13 @@ public void sendSystemMessage(IChatBaseComponent ichatbasecomponent) { EntityPlayer.this.sendSystemMessage(ichatbasecomponent); } @@ -88,8 +97,8 @@ }; this.textFilter = minecraftserver.createTextFilterForPlayer(this); this.gameMode = minecraftserver.createGameModeForPlayer(this); -@@ -352,14 +410,67 @@ - this.moveTo(this.adjustSpawnLocation(worldserver, worldserver.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F); +@@ -383,14 +441,67 @@ + this.snapTo(this.adjustSpawnLocation(worldserver, worldserver.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F); this.updateOptions(clientinformation); this.object = null; + @@ -102,7 +111,7 @@ + // Use method to resend items in hands in case of client desync, because the item use got cancelled. + // For example, when cancelling the leash event + public void resendItemInHands() { -+ containerMenu.findSlot(getInventory(), getInventory().selected).ifPresent(s -> { ++ containerMenu.findSlot(getInventory(), getInventory().getSelectedSlot()).ifPresent(s -> { + containerSynchronizer.sendSlotChange(containerMenu, s, getMainHandItem()); + }); + containerSynchronizer.sendSlotChange(inventoryMenu, ContainerPlayer.SHIELD_SLOT, getOffhandItem()); @@ -157,7 +166,7 @@ int i = Math.max(0, this.server.getSpawnRadius(worldserver)); int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ())); -@@ -395,14 +506,20 @@ +@@ -426,14 +537,20 @@ Objects.requireNonNull(blockposition); crashreportsystemdetails.setDetail("Origin", blockposition::toString); @@ -174,76 +183,52 @@ + // CraftBukkit start - decompile error + int finalL1 = l1; crashreportsystemdetails.setDetail("Progress", () -> { -- return "" + l1 + " out of " + i1; -+ return "" + finalL1 + " out of " + i1; +- return l1 + " out of " + i1; ++ return finalL1 + " out of " + i1; + // CraftBukkit end }); throw new ReportedException(crashreport); } -@@ -440,7 +557,7 @@ - dataresult = WardenSpawnTracker.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("warden_spawn_tracker"))); - logger = EntityPlayer.LOGGER; - Objects.requireNonNull(logger); -- dataresult.resultOrPartial(logger::error).ifPresent((wardenspawntracker) -> { -+ ((DataResult) dataresult).resultOrPartial(logger::error).ifPresent((wardenspawntracker) -> { - this.wardenSpawnTracker = wardenspawntracker; - }); - } -@@ -457,17 +574,26 @@ - return this.server.getRecipeManager().byKey(resourcekey).isPresent(); - }); - } +@@ -465,18 +582,27 @@ + public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { + super.readAdditionalSaveData(nbttagcompound); + this.wardenSpawnTracker = (WardenSpawnTracker) nbttagcompound.read("warden_spawn_tracker", WardenSpawnTracker.CODEC).orElseGet(WardenSpawnTracker::new); +- this.enteredNetherPosition = (Vec3D) nbttagcompound.read("entered_nether_pos", Vec3D.CODEC).orElse((Object) null); ++ this.enteredNetherPosition = (Vec3D) nbttagcompound.read("entered_nether_pos", Vec3D.CODEC).orElse(null); // CraftBukkit - decompile error + this.seenCredits = nbttagcompound.getBooleanOr("seenCredits", false); + this.recipeBook.fromNbt(nbttagcompound.getCompoundOrEmpty("recipeBook"), (resourcekey) -> { + return this.server.getRecipeManager().byKey(resourcekey).isPresent(); + }); + this.getBukkitEntity().readExtraData(nbttagcompound); // CraftBukkit - if (this.isSleeping()) { this.stopSleeping(); } +- this.respawnConfig = (EntityPlayer.RespawnConfig) nbttagcompound.read("respawn", EntityPlayer.RespawnConfig.CODEC).orElse((Object) null); ++ this.respawnConfig = (EntityPlayer.RespawnConfig) nbttagcompound.read("respawn", EntityPlayer.RespawnConfig.CODEC).orElse(null); // CraftBukkit - decompile error + // CraftBukkit start -+ String spawnWorld = nbttagcompound.getString("SpawnWorld"); ++ String spawnWorld = nbttagcompound.getStringOr("SpawnWorld", ""); + CraftWorld oldWorld = (CraftWorld) Bukkit.getWorld(spawnWorld); + if (oldWorld != null) { -+ this.respawnDimension = oldWorld.getHandle().dimension(); ++ EntityPlayer.RespawnConfig respawnConfig = this.respawnConfig; ++ this.respawnConfig = new RespawnConfig(oldWorld.getHandle().dimension(), respawnConfig.pos(), respawnConfig.angle(), respawnConfig.forced()); + } + // CraftBukkit end -+ - if (nbttagcompound.contains("SpawnX", 99) && nbttagcompound.contains("SpawnY", 99) && nbttagcompound.contains("SpawnZ", 99)) { - this.respawnPosition = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ")); - this.respawnForced = nbttagcompound.getBoolean("SpawnForced"); - this.respawnAngle = nbttagcompound.getFloat("SpawnAngle"); - if (nbttagcompound.contains("SpawnDimension")) { -- DataResult dataresult1 = World.RESOURCE_KEY_CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("SpawnDimension")); -+ DataResult> dataresult1 = World.RESOURCE_KEY_CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("SpawnDimension")); // CraftBukkit - decompile error - Logger logger1 = EntityPlayer.LOGGER; + this.spawnExtraParticlesOnFall = nbttagcompound.getBooleanOr("spawn_extra_particles_on_fall", false); +- this.raidOmenPosition = (BlockPosition) nbttagcompound.read("raid_omen_position", BlockPosition.CODEC).orElse((Object) null); ++ this.raidOmenPosition = (BlockPosition) nbttagcompound.read("raid_omen_position", BlockPosition.CODEC).orElse(null); // CraftBukkit - decompile error + } - Objects.requireNonNull(logger1); -@@ -482,7 +608,7 @@ - dataresult = BlockPosition.CODEC.parse(DynamicOpsNBT.INSTANCE, nbtbase); - logger = EntityPlayer.LOGGER; - Objects.requireNonNull(logger); -- dataresult.resultOrPartial(logger::error).ifPresent((blockposition) -> { -+ ((DataResult) dataresult).resultOrPartial(logger::error).ifPresent((blockposition) -> { // CraftBukkit - decompile error - this.raidOmenPosition = blockposition; - }); - } -@@ -492,7 +618,7 @@ @Override - public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { - super.addAdditionalSaveData(nbttagcompound); -- DataResult dataresult = WardenSpawnTracker.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.wardenSpawnTracker); -+ DataResult dataresult = WardenSpawnTracker.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.wardenSpawnTracker); // CraftBukkit - decompile error - Logger logger = EntityPlayer.LOGGER; - - Objects.requireNonNull(logger); -@@ -526,6 +652,7 @@ - nbttagcompound.put("SpawnDimension", nbtbase); - }); - } +@@ -490,6 +616,7 @@ + nbttagcompound.put("recipeBook", this.recipeBook.toNbt()); + nbttagcompound.putString("Dimension", this.level().dimension().location().toString()); + nbttagcompound.storeNullable("respawn", EntityPlayer.RespawnConfig.CODEC, this.respawnConfig); + this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit - nbttagcompound.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall); - if (this.raidOmenPosition != null) { -@@ -544,7 +671,20 @@ + nbttagcompound.storeNullable("raid_omen_position", BlockPosition.CODEC, this.raidOmenPosition); + this.saveEnderPearls(nbttagcompound); +@@ -499,7 +626,20 @@ Entity entity = this.getRootVehicle(); Entity entity1 = this.getVehicle(); @@ -265,61 +250,41 @@ NBTTagCompound nbttagcompound1 = new NBTTagCompound(); NBTTagCompound nbttagcompound2 = new NBTTagCompound(); -@@ -598,12 +738,12 @@ +@@ -521,7 +661,7 @@ + }); + + if (entity != null) { +- UUID uuid = (UUID) ((NBTTagCompound) optional.get()).read("Attach", UUIDUtil.CODEC).orElse((Object) null); ++ UUID uuid = (UUID) ((NBTTagCompound) optional.get()).read("Attach", UUIDUtil.CODEC).orElse(null); // CraftBukkit - decompile error + + if (entity.getUUID().equals(uuid)) { + this.startRiding(entity, true); +@@ -536,10 +676,10 @@ if (!this.isPassenger()) { EntityPlayer.LOGGER.warn("Couldn't reattach entity to player"); - entity.discard(); + entity.discard(null); // CraftBukkit - add Bukkit remove cause - iterator = entity.getIndirectPassengers().iterator(); - while (iterator.hasNext()) { - entity1 = (Entity) iterator.next(); -- entity1.discard(); -+ entity1.discard(null); // CraftBukkit - add Bukkit remove cause + for (Entity entity2 : entity.getIndirectPassengers()) { +- entity2.discard(); ++ entity2.discard(null); // CraftBukkit - add Bukkit remove cause } } - } -@@ -625,7 +765,7 @@ - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - - entityenderpearl.save(nbttagcompound1); -- DataResult dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, entityenderpearl.level().dimension().location()); -+ DataResult dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, entityenderpearl.level().dimension().location()); // CraftBukkit - decompile error - Logger logger = EntityPlayer.LOGGER; - - Objects.requireNonNull(logger); -@@ -651,7 +791,7 @@ - nbttaglist.forEach((nbtbase1) -> { - if (nbtbase1 instanceof NBTTagCompound nbttagcompound) { - if (nbttagcompound.contains("ender_pearl_dimension")) { -- DataResult dataresult = World.RESOURCE_KEY_CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("ender_pearl_dimension")); -+ DataResult> dataresult = World.RESOURCE_KEY_CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("ender_pearl_dimension")); // CraftBukkit - decompile error - Logger logger = EntityPlayer.LOGGER; - - Objects.requireNonNull(logger); -@@ -686,6 +826,29 @@ +@@ -597,6 +737,20 @@ + } } + // CraftBukkit start - World fallback code, either respawn location or global spawn -+ public void spawnIn(World world) { ++ public void spawnIn(World world, boolean flag) { + this.setLevel(world); + if (world == null) { + this.unsetRemoved(); -+ Vec3D position = null; -+ if (this.respawnDimension != null) { -+ world = this.server.getLevel(this.respawnDimension); -+ if (world != null && this.getRespawnPosition() != null) { -+ position = EntityPlayer.findRespawnAndUseSpawnBlock((WorldServer) world, this.getRespawnPosition(), this.getRespawnAngle(), false, false).map(EntityPlayer.RespawnPosAngle::position).orElse(null); -+ } -+ } -+ if (world == null || position == null) { -+ world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle(); -+ position = Vec3D.atCenterOf(world.getSharedSpawnPos()); -+ } -+ this.setLevel(world); -+ this.setPos(position); ++ TeleportTransition teleporttransition = this.findRespawnPositionAndUseSpawnBlock(!flag, TeleportTransition.DO_NOTHING, null); ++ ++ this.setLevel(teleporttransition.newLevel()); ++ this.setPos(teleporttransition.position()); + } + this.gameMode.setLevel((WorldServer) world); + } @@ -328,7 +293,7 @@ public void setExperiencePoints(int i) { float f = (float) this.getXpNeededForNextLevel(); float f1 = (f - 1.0F) / f; -@@ -714,6 +877,7 @@ +@@ -625,6 +779,7 @@ public void initMenu(Container container) { container.addSlotListener(this.containerListener); container.setSynchronizer(this.containerSynchronizer); @@ -336,7 +301,7 @@ } public void initInventoryMenu() { -@@ -744,6 +908,11 @@ +@@ -655,6 +810,11 @@ @Override public void tick() { @@ -348,7 +313,7 @@ this.tickClientLoadTimeout(); this.gameMode.tick(); this.wardenSpawnTracker.tick(); -@@ -820,7 +989,7 @@ +@@ -731,7 +891,7 @@ } if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -357,7 +322,7 @@ this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -851,6 +1020,12 @@ +@@ -762,6 +922,12 @@ this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience)); } @@ -370,7 +335,7 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel)); -@@ -865,6 +1040,20 @@ +@@ -776,6 +942,20 @@ CriterionTriggers.LOCATION.trigger(this); } @@ -391,7 +356,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked"); -@@ -893,7 +1082,7 @@ +@@ -804,7 +984,7 @@ if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.serverLevel().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { if (this.tickCount % 20 == 0) { if (this.getHealth() < this.getMaxHealth()) { @@ -400,7 +365,7 @@ } float f = this.foodData.getSaturationLevel(); -@@ -946,7 +1135,8 @@ +@@ -857,7 +1037,8 @@ } private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) { @@ -410,7 +375,7 @@ scoreaccess.set(i); }); } -@@ -955,9 +1145,47 @@ +@@ -866,9 +1047,47 @@ public void die(DamageSource damagesource) { this.gameEvent(GameEvent.ENTITY_DIE); boolean flag = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); @@ -424,14 +389,14 @@ - if (flag) { - IChatBaseComponent ichatbasecomponent = this.getCombatTracker().getDeathMessage(); + if (!keepInventory) { -+ for (ItemStack item : this.getInventory().getContents()) { ++ for (ItemStack item : this.getInventory()) { + if (!item.isEmpty() && !EnchantmentManager.has(item, EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) { + loot.add(CraftItemStack.asCraftMirror(item).markForInventoryDrop()); + } + } + } + // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule) -+ this.dropFromLootTable(this.serverLevel(), damagesource, this.lastHurtByPlayerTime > 0); ++ this.dropFromLootTable(this.serverLevel(), damagesource, this.lastHurtByPlayerMemoryTime > 0); + this.dropCustomDeathLoot(this.serverLevel(), damagesource, flag); + + loot.addAll(this.drops); @@ -459,8 +424,8 @@ + } this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> { - boolean flag1 = true; -@@ -988,12 +1216,18 @@ + int i = 256; +@@ -899,12 +1118,18 @@ if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) { this.tellNeutralMobsThatIDied(); } @@ -483,7 +448,7 @@ EntityLiving entityliving = this.getKillCredit(); if (entityliving != null) { -@@ -1028,10 +1262,12 @@ +@@ -939,10 +1164,12 @@ public void awardKillScore(Entity entity, DamageSource damagesource) { if (entity != this) { super.awardKillScore(entity, damagesource); @@ -498,7 +463,7 @@ } else { this.awardStat(StatisticList.MOB_KILLS); } -@@ -1049,7 +1285,8 @@ +@@ -960,7 +1187,8 @@ int i = scoreboardteam.getColor().getId(); if (i >= 0 && i < aiscoreboardcriteria.length) { @@ -508,7 +473,7 @@ } } -@@ -1093,10 +1330,16 @@ +@@ -1004,10 +1232,16 @@ } private boolean isPvpAllowed() { @@ -524,10 +489,10 @@ + boolean isBedSpawn = false; + boolean isAnchorSpawn = false; + // CraftBukkit end - BlockPosition blockposition = this.getRespawnPosition(); - float f = this.getRespawnAngle(); - boolean flag1 = this.isRespawnForced(); -@@ -1108,13 +1351,32 @@ + EntityPlayer.RespawnConfig entityplayer_respawnconfig = this.getRespawnConfig(); + WorldServer worldserver = this.server.getLevel(EntityPlayer.RespawnConfig.getDimensionOrDefault(entityplayer_respawnconfig)); + +@@ -1017,13 +1251,32 @@ if (optional.isPresent()) { EntityPlayer.RespawnPosAngle entityplayer_respawnposangle = (EntityPlayer.RespawnPosAngle) optional.get(); @@ -562,8 +527,8 @@ + // CraftBukkit end } - public static Optional findRespawnAndUseSpawnBlock(WorldServer worldserver, BlockPosition blockposition, float f, boolean flag, boolean flag1) { -@@ -1129,11 +1391,11 @@ + public static Optional findRespawnAndUseSpawnBlock(WorldServer worldserver, EntityPlayer.RespawnConfig entityplayer_respawnconfig, boolean flag) { +@@ -1041,11 +1294,11 @@ } return optional.map((vec3d) -> { @@ -575,9 +540,9 @@ - return EntityPlayer.RespawnPosAngle.of(vec3d, blockposition); + return EntityPlayer.RespawnPosAngle.of(vec3d, blockposition, true, false); // CraftBukkit }); - } else if (!flag) { + } else if (!flag1) { return Optional.empty(); -@@ -1142,7 +1404,7 @@ +@@ -1054,7 +1307,7 @@ IBlockData iblockdata1 = worldserver.getBlockState(blockposition.above()); boolean flag3 = iblockdata1.getBlock().isPossibleToRespawnInThis(iblockdata1); @@ -586,7 +551,7 @@ } } -@@ -1160,6 +1422,7 @@ +@@ -1072,6 +1325,7 @@ @Nullable @Override public EntityPlayer teleport(TeleportTransition teleporttransition) { @@ -594,7 +559,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1169,18 +1432,38 @@ +@@ -1081,18 +1335,38 @@ WorldServer worldserver = teleporttransition.newLevel(); WorldServer worldserver1 = this.serverLevel(); @@ -618,7 +583,7 @@ + // CraftBukkit end if (!teleporttransition.asPassenger()) { - this.stopRiding(); + this.removeVehicle(); } - if (worldserver.dimension() == resourcekey) { @@ -636,7 +601,7 @@ this.isChangingDimension = true; WorldData worlddata = worldserver.getLevelData(); -@@ -1191,17 +1474,31 @@ +@@ -1103,17 +1377,31 @@ playerlist.sendPlayerPermissionLevel(this); worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); this.unsetRemoved(); @@ -670,7 +635,7 @@ this.connection.resetPosition(); worldserver.addDuringTeleport(this); gameprofilerfiller.pop(); -@@ -1215,11 +1512,29 @@ +@@ -1127,11 +1415,29 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -700,7 +665,7 @@ @Override public void forceSetRotation(float f, float f1) { this.connection.send(new ClientboundPlayerRotationPacket(f, f1)); -@@ -1228,13 +1543,21 @@ +@@ -1140,13 +1446,21 @@ public void triggerDimensionChangeTriggers(WorldServer worldserver) { ResourceKey resourcekey = worldserver.dimension(); ResourceKey resourcekey1 = this.level().dimension(); @@ -725,7 +690,7 @@ this.enteredNetherPosition = null; } -@@ -1251,19 +1574,17 @@ +@@ -1163,19 +1477,17 @@ this.containerMenu.broadcastChanges(); } @@ -744,12 +709,12 @@ } else if (this.bedBlocked(blockposition, enumdirection)) { return Either.left(EntityHuman.EnumBedResult.OBSTRUCTED); } else { -- this.setRespawnPosition(this.level().dimension(), blockposition, this.getYRot(), false, true); -+ this.setRespawnPosition(this.level().dimension(), blockposition, this.getYRot(), false, true, PlayerSpawnChangeEvent.Cause.BED); // CraftBukkit - if (this.level().isDay()) { +- this.setRespawnPosition(new EntityPlayer.RespawnConfig(this.level().dimension(), blockposition, this.getYRot(), false), true); ++ this.setRespawnPosition(new EntityPlayer.RespawnConfig(this.level().dimension(), blockposition, this.getYRot(), false), true, PlayerSpawnChangeEvent.Cause.BED); // CraftBukkit + if (this.level().isBrightOutside()) { return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_NOW); } else { -@@ -1280,7 +1601,36 @@ +@@ -1192,7 +1504,36 @@ } } @@ -787,7 +752,7 @@ this.awardStat(StatisticList.SLEEP_IN_BED); CriterionTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -1293,9 +1643,8 @@ +@@ -1205,9 +1546,8 @@ return either; } } @@ -798,7 +763,7 @@ } @Override -@@ -1322,13 +1671,31 @@ +@@ -1234,13 +1574,31 @@ @Override public void stopSleepInBed(boolean flag, boolean flag1) { @@ -831,7 +796,7 @@ } } -@@ -1387,8 +1754,9 @@ +@@ -1293,8 +1651,9 @@ this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos(), flag)); } @@ -842,7 +807,7 @@ } @Override -@@ -1396,13 +1764,35 @@ +@@ -1302,13 +1661,35 @@ if (itileinventory == null) { return OptionalInt.empty(); } else { @@ -878,7 +843,7 @@ if (container == null) { if (this.isSpectator()) { this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true); -@@ -1410,9 +1800,11 @@ +@@ -1316,9 +1697,11 @@ return OptionalInt.empty(); } else { @@ -892,7 +857,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1425,15 +1817,26 @@ +@@ -1331,15 +1714,26 @@ @Override public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { @@ -921,7 +886,7 @@ this.initMenu(this.containerMenu); } -@@ -1456,6 +1859,7 @@ +@@ -1362,6 +1756,7 @@ @Override public void closeContainer() { @@ -929,47 +894,49 @@ this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId)); this.doCloseContainer(); } -@@ -1485,19 +1889,19 @@ - i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); +@@ -1390,21 +1785,21 @@ + if (i > 0) { this.awardStat(StatisticList.SWIM_ONE_CM, i); - this.causeFoodExhaustion(0.01F * (float) i * 0.01F); + this.causeFoodExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.SWIM); // CraftBukkit - EntityExhaustionEvent } } else if (this.isEyeInFluid(TagsFluid.WATER)) { - i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); - if (i > 0) { - this.awardStat(StatisticList.WALK_UNDER_WATER_ONE_CM, i); -- this.causeFoodExhaustion(0.01F * (float) i * 0.01F); -+ this.causeFoodExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_UNDERWATER); // CraftBukkit - EntityExhaustionEvent + int j = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); + + if (j > 0) { + this.awardStat(StatisticList.WALK_UNDER_WATER_ONE_CM, j); +- this.causeFoodExhaustion(0.01F * (float) j * 0.01F); ++ this.causeFoodExhaustion(0.01F * (float) j * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_UNDERWATER); // CraftBukkit - EntityExhaustionEvent } } else if (this.isInWater()) { - i = Math.round((float) Math.sqrt(d0 * d0 + d2 * d2) * 100.0F); - if (i > 0) { - this.awardStat(StatisticList.WALK_ON_WATER_ONE_CM, i); -- this.causeFoodExhaustion(0.01F * (float) i * 0.01F); -+ this.causeFoodExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_ON_WATER); // CraftBukkit - EntityExhaustionEvent + int k = Math.round((float) Math.sqrt(d0 * d0 + d2 * d2) * 100.0F); + + if (k > 0) { + this.awardStat(StatisticList.WALK_ON_WATER_ONE_CM, k); +- this.causeFoodExhaustion(0.01F * (float) k * 0.01F); ++ this.causeFoodExhaustion(0.01F * (float) k * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_ON_WATER); // CraftBukkit - EntityExhaustionEvent } } else if (this.onClimbable()) { if (d1 > 0.0D) { -@@ -1508,13 +1912,13 @@ - if (i > 0) { +@@ -1416,13 +1811,13 @@ + if (l > 0) { if (this.isSprinting()) { - this.awardStat(StatisticList.SPRINT_ONE_CM, i); -- this.causeFoodExhaustion(0.1F * (float) i * 0.01F); -+ this.causeFoodExhaustion(0.1F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.SPRINT); // CraftBukkit - EntityExhaustionEvent + this.awardStat(StatisticList.SPRINT_ONE_CM, l); +- this.causeFoodExhaustion(0.1F * (float) l * 0.01F); ++ this.causeFoodExhaustion(0.1F * (float) l * 0.01F, EntityExhaustionEvent.ExhaustionReason.SPRINT); // CraftBukkit - EntityExhaustionEvent } else if (this.isCrouching()) { - this.awardStat(StatisticList.CROUCH_ONE_CM, i); -- this.causeFoodExhaustion(0.0F * (float) i * 0.01F); -+ this.causeFoodExhaustion(0.0F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.CROUCH); // CraftBukkit - EntityExhaustionEvent + this.awardStat(StatisticList.CROUCH_ONE_CM, l); +- this.causeFoodExhaustion(0.0F * (float) l * 0.01F); ++ this.causeFoodExhaustion(0.0F * (float) l * 0.01F, EntityExhaustionEvent.ExhaustionReason.CROUCH); // CraftBukkit - EntityExhaustionEvent } else { - this.awardStat(StatisticList.WALK_ONE_CM, i); -- this.causeFoodExhaustion(0.0F * (float) i * 0.01F); -+ this.causeFoodExhaustion(0.0F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK); // CraftBukkit - EntityExhaustionEvent + this.awardStat(StatisticList.WALK_ONE_CM, l); +- this.causeFoodExhaustion(0.0F * (float) l * 0.01F); ++ this.causeFoodExhaustion(0.0F * (float) l * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK); // CraftBukkit - EntityExhaustionEvent } } } else if (this.isFallFlying()) { -@@ -1557,7 +1961,7 @@ +@@ -1467,7 +1862,7 @@ @Override public void awardStat(Statistic statistic, int i) { this.stats.increment(this, statistic, i); @@ -978,7 +945,7 @@ scoreaccess.add(i); }); } -@@ -1565,7 +1969,7 @@ +@@ -1475,7 +1870,7 @@ @Override public void resetStat(Statistic statistic) { this.stats.setValue(this, statistic, 0); @@ -987,7 +954,7 @@ } @Override -@@ -1597,9 +2001,9 @@ +@@ -1507,9 +1902,9 @@ super.jumpFromGround(); this.awardStat(StatisticList.JUMP); if (this.isSprinting()) { @@ -999,7 +966,7 @@ } } -@@ -1625,6 +2029,7 @@ +@@ -1535,6 +1930,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -1007,7 +974,7 @@ } @Override -@@ -1661,7 +2066,7 @@ +@@ -1571,12 +1967,12 @@ this.onUpdateAbilities(); if (flag) { this.getAttributes().assignBaseValues(entityplayer.getAttributes()); @@ -1015,17 +982,14 @@ + // this.getAttributes().assignPermanentModifiers(entityplayer.getAttributes()); // CraftBukkit this.setHealth(entityplayer.getHealth()); this.foodData = entityplayer.foodData; - Iterator iterator = entityplayer.getActiveEffects().iterator(); -@@ -1669,7 +2074,7 @@ - while (iterator.hasNext()) { - MobEffect mobeffect = (MobEffect) iterator.next(); + for (MobEffect mobeffect : entityplayer.getActiveEffects()) { - this.addEffect(new MobEffect(mobeffect)); + // this.addEffect(new MobEffect(mobeffect)); // CraftBukkit } this.getInventory().replaceWith(entityplayer.getInventory()); -@@ -1680,7 +2085,7 @@ +@@ -1587,7 +1983,7 @@ this.portalProcess = entityplayer.portalProcess; } else { this.getAttributes().assignBaseValues(entityplayer.getAttributes()); @@ -1034,7 +998,7 @@ if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || entityplayer.isSpectator()) { this.getInventory().replaceWith(entityplayer.getInventory()); this.experienceLevel = entityplayer.experienceLevel; -@@ -1696,7 +2101,7 @@ +@@ -1603,7 +1999,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -1043,7 +1007,7 @@ this.seenCredits = entityplayer.seenCredits; this.enteredNetherPosition = entityplayer.enteredNetherPosition; this.chunkTrackingView = entityplayer.chunkTrackingView; -@@ -1752,7 +2157,7 @@ +@@ -1656,7 +2052,7 @@ } @Override @@ -1052,7 +1016,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, true); } -@@ -1761,7 +2166,7 @@ +@@ -1665,7 +2061,7 @@ this.setCamera(this); } @@ -1061,7 +1025,7 @@ if (flag1) { this.setYHeadRot(set.contains(Relative.Y_ROT) ? this.getYHeadRot() + f : f); -@@ -1878,6 +2283,16 @@ +@@ -1778,6 +2174,16 @@ } public void updateOptions(ClientInformation clientinformation) { @@ -1078,7 +1042,7 @@ this.language = clientinformation.language(); this.requestedViewDistance = clientinformation.viewDistance(); this.chatVisibility = clientinformation.chatVisibility(); -@@ -1962,7 +2377,13 @@ +@@ -1862,7 +2268,13 @@ if (world instanceof WorldServer) { WorldServer worldserver = (WorldServer) world; @@ -1093,7 +1057,7 @@ } if (entity != null) { -@@ -1999,11 +2420,11 @@ +@@ -1899,11 +2311,11 @@ @Nullable public IChatBaseComponent getTabListDisplayName() { @@ -1107,80 +1071,62 @@ } @Override -@@ -2046,6 +2467,32 @@ +@@ -1934,6 +2346,32 @@ } - public void setRespawnPosition(ResourceKey resourcekey, @Nullable BlockPosition blockposition, float f, boolean flag, boolean flag1) { + public void setRespawnPosition(@Nullable EntityPlayer.RespawnConfig entityplayer_respawnconfig, boolean flag) { + // CraftBukkit start -+ this.setRespawnPosition(resourcekey, blockposition, f, flag, flag1, PlayerSpawnChangeEvent.Cause.UNKNOWN); ++ this.setRespawnPosition(entityplayer_respawnconfig, flag, PlayerSpawnChangeEvent.Cause.UNKNOWN); + } + -+ public void setRespawnPosition(ResourceKey resourcekey, @Nullable BlockPosition blockposition, float f, boolean flag, boolean flag1, PlayerSpawnChangeEvent.Cause cause) { -+ WorldServer newWorld = this.server.getLevel(resourcekey); -+ Location newSpawn = (blockposition != null) ? CraftLocation.toBukkit(blockposition, newWorld.getWorld(), f, 0) : null; ++ public void setRespawnPosition(@Nullable EntityPlayer.RespawnConfig entityplayer_respawnconfig, boolean flag, PlayerSpawnChangeEvent.Cause cause) { ++ Location newSpawn = null; ++ boolean forced = false; ++ if (entityplayer_respawnconfig != null) { ++ WorldServer newWorld = this.server.getLevel(entityplayer_respawnconfig.dimension()); ++ newSpawn = CraftLocation.toBukkit(entityplayer_respawnconfig.pos(), newWorld.getWorld(), entityplayer_respawnconfig.angle(), 0); ++ forced = respawnConfig.forced(); ++ } + -+ PlayerSpawnChangeEvent event = new PlayerSpawnChangeEvent(this.getBukkitEntity(), newSpawn, flag, cause); ++ PlayerSpawnChangeEvent event = new PlayerSpawnChangeEvent(this.getBukkitEntity(), newSpawn, forced, cause); + Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } + newSpawn = event.getNewSpawn(); -+ flag = event.isForced(); + + if (newSpawn != null) { -+ resourcekey = ((CraftWorld) newSpawn.getWorld()).getHandle().dimension(); -+ blockposition = BlockPosition.containing(newSpawn.getX(), newSpawn.getY(), newSpawn.getZ()); -+ f = newSpawn.getYaw(); ++ entityplayer_respawnconfig = new EntityPlayer.RespawnConfig(((CraftWorld) newSpawn.getWorld()).getHandle().dimension(), BlockPosition.containing(newSpawn.getX(), newSpawn.getY(), newSpawn.getZ()), newSpawn.getYaw(), event.isForced()); + } else { -+ resourcekey = World.OVERWORLD; -+ blockposition = null; -+ f = 0.0F; ++ entityplayer_respawnconfig = null; + } + // CraftBukkit end - if (blockposition != null) { - boolean flag2 = blockposition.equals(this.respawnPosition) && resourcekey.equals(this.respawnDimension); - -@@ -2088,12 +2535,38 @@ + if (flag && entityplayer_respawnconfig != null && !entityplayer_respawnconfig.isSamePosition(this.respawnConfig)) { + this.sendSystemMessage(EntityPlayer.SPAWN_SET_MESSAGE); + } +@@ -1963,8 +2401,10 @@ } @Override - public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1) { -+ public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1, boolean callEvent) { // CraftBukkit - SPIGOT-2942: Add boolean to call event - EntityItem entityitem = this.createItemStackToDrop(itemstack, flag, flag1); +- EntityItem entityitem = super.drop(itemstack, flag, flag1); ++ // CraftBukkit start - SPIGOT-2942: Add boolean to call event ++ public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1, boolean callEvent) { ++ EntityItem entityitem = super.drop(itemstack, flag, flag1, callEvent); ++ // CraftBukkit end - if (entityitem == null) { - return null; - } else { -+ // CraftBukkit start - fire PlayerDropItemEvent -+ if (callEvent) { -+ Player player = (Player) this.getBukkitEntity(); -+ org.bukkit.entity.Item drop = (org.bukkit.entity.Item) entityitem.getBukkitEntity(); -+ -+ PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop); -+ this.level().getCraftServer().getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { -+ org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand(); -+ if (flag1 && (cur == null || cur.getAmount() == 0)) { -+ // The complete stack was dropped -+ player.getInventory().setItemInHand(drop.getItemStack()); -+ } else if (flag1 && 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(entityitem); - ItemStack itemstack1 = entityitem.getItem(); + if (flag1) { + ItemStack itemstack1 = entityitem != null ? entityitem.getItem() : ItemStack.EMPTY; +@@ -1989,7 +2429,7 @@ -@@ -2375,10 +2848,12 @@ + @Nullable + private static EnumGamemode readPlayerMode(@Nullable NBTTagCompound nbttagcompound, String s) { +- return nbttagcompound != null ? (EnumGamemode) nbttagcompound.read(s, EnumGamemode.LEGACY_ID_CODEC).orElse((Object) null) : null; ++ return nbttagcompound != null ? (EnumGamemode) nbttagcompound.read(s, EnumGamemode.LEGACY_ID_CODEC).orElse(null) : null; // CraftBukkit - decompile error + } + + private EnumGamemode calculateGameModeForNewPlayer(@Nullable EnumGamemode enumgamemode) { +@@ -2206,10 +2646,12 @@ return TicketType.ENDER_PEARL.timeout(); } @@ -1196,11 +1142,10 @@ } private static float calculateLookAtYaw(Vec3D vec3d, BlockPosition blockposition) { -@@ -2387,4 +2862,146 @@ - return (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); +@@ -2219,6 +2661,148 @@ } } -+ + + // CraftBukkit start - Add per-player time and weather. + public long timeOffset = 0; + public boolean relativeTime = true; @@ -1287,7 +1232,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(); + } + @@ -1342,4 +1287,7 @@ + return (CraftPlayer) super.getBukkitEntity(); + } + // CraftBukkit end - } ++ + public static record RespawnConfig(ResourceKey dimension, BlockPosition pos, float angle, boolean forced) { + + public static final Codec CODEC = RecordCodecBuilder.create((instance) -> { diff --git a/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch b/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch index 1e4584f0e..0ec9c4082 100644 --- a/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch +++ b/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/EntityTrackerEntry.java +++ b/net/minecraft/server/level/EntityTrackerEntry.java -@@ -50,6 +50,12 @@ +@@ -52,6 +52,12 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -13,30 +13,29 @@ public class EntityTrackerEntry { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -74,8 +80,12 @@ +@@ -77,8 +83,12 @@ private boolean wasOnGround; @Nullable private List> trackedDataValues; + // CraftBukkit start + private final Set trackedPlayers; -- public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer> consumer) { -+ public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer> consumer, Set trackedPlayers) { +- public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer> consumer, BiConsumer, List> biconsumer) { ++ public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer> consumer, BiConsumer, List> biconsumer, Set trackedPlayers) { + this.trackedPlayers = trackedPlayers; + // CraftBukkit end this.level = worldserver; this.broadcast = consumer; this.entity = entity; -@@ -94,7 +104,7 @@ - List list = this.entity.getPassengers(); - +@@ -100,22 +110,23 @@ if (!list.equals(this.lastPassengers)) { -- this.broadcast.accept(new PacketPlayOutMount(this.entity)); -+ this.broadcastAndSend(new PacketPlayOutMount(this.entity)); // CraftBukkit - removedPassengers(list, this.lastPassengers).forEach((entity) -> { - if (entity instanceof EntityPlayer entityplayer) { - entityplayer.connection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot()); -@@ -107,18 +117,18 @@ + List list1 = this.mountedOrDismounted(list).map(Entity::getUUID).toList(); + +- this.broadcastWithIgnore.accept(new PacketPlayOutMount(this.entity), list1); ++ this.broadcastWithIgnoreAndSend(new PacketPlayOutMount(this.entity), list1); // CraftBukkit + this.lastPassengers = list; + } + Entity entity = this.entity; if (entity instanceof EntityItemFrame entityitemframe) { @@ -50,16 +49,13 @@ WorldMap worldmap = ItemWorldMap.getSavedData(mapid, this.level); if (worldmap != null) { -- Iterator iterator = this.level.players().iterator(); -+ Iterator iterator = this.trackedPlayers.iterator(); // CraftBukkit - - while (iterator.hasNext()) { -- EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -+ EntityPlayer entityplayer = iterator.next().getPlayer(); // CraftBukkit - +- for (EntityPlayer entityplayer : this.level.players()) { ++ for (ServerPlayerConnection connection : this.trackedPlayers) { // CraftBukkit ++ EntityPlayer entityplayer = connection.getPlayer(); // CraftBukkit worldmap.tickCarriedBy(entityplayer, itemstack); Packet packet = worldmap.getUpdatePacket(mapid, entityplayer); -@@ -248,6 +258,27 @@ + +@@ -244,6 +255,27 @@ ++this.tickCount; if (this.entity.hurtMarked) { @@ -87,7 +83,7 @@ this.entity.hurtMarked = false; this.broadcastAndSend(new PacketPlayOutEntityVelocity(this.entity)); } -@@ -298,7 +329,10 @@ +@@ -296,7 +328,10 @@ public void sendPairingData(EntityPlayer entityplayer, Consumer> consumer) { if (this.entity.isRemoved()) { @@ -99,7 +95,7 @@ } Packet packet = this.entity.getAddEntityPacket(this); -@@ -313,6 +347,12 @@ +@@ -311,6 +346,12 @@ if (this.entity instanceof EntityLiving) { Collection collection = ((EntityLiving) this.entity).getAttributes().getSyncableAttributes(); @@ -112,7 +108,7 @@ if (!collection.isEmpty()) { consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection)); } -@@ -344,6 +384,7 @@ +@@ -340,6 +381,7 @@ if (!list.isEmpty()) { consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list)); } @@ -120,7 +116,7 @@ } if (!this.entity.getPassengers().isEmpty()) { -@@ -396,6 +437,11 @@ +@@ -392,6 +434,11 @@ Set set = ((EntityLiving) this.entity).getAttributes().getAttributesToSync(); if (!set.isEmpty()) { @@ -132,3 +128,18 @@ this.broadcastAndSend(new PacketPlayOutUpdateAttributes(this.entity.getId(), set)); } +@@ -407,4 +454,14 @@ + } + + } ++ ++ // CraftBukkit start ++ private void broadcastWithIgnoreAndSend(Packet packet, List list) { ++ this.broadcastWithIgnore.accept(packet, list); ++ if (this.entity instanceof EntityPlayer) { ++ ((EntityPlayer) this.entity).connection.send(packet); ++ } ++ ++ } ++ // CraftBukkit end + } diff --git a/nms-patches/net/minecraft/server/level/PlayerChunk.patch b/nms-patches/net/minecraft/server/level/PlayerChunk.patch index 8cdc55080..31bbc5170 100644 --- a/nms-patches/net/minecraft/server/level/PlayerChunk.patch +++ b/nms-patches/net/minecraft/server/level/PlayerChunk.patch @@ -60,20 +60,7 @@ if (this.changedBlocksPerSection[i] == null) { this.hasChangedSections = true; this.changedBlocksPerSection[i] = new ShortOpenHashSet(); -@@ -224,8 +241,11 @@ - PacketPlayOutMultiBlockChange packetplayoutmultiblockchange = new PacketPlayOutMultiBlockChange(sectionposition, shortset, chunksection); - - this.broadcast(list, packetplayoutmultiblockchange); -+ // CraftBukkit start -+ List finalList = list; - packetplayoutmultiblockchange.runUpdates((blockposition1, iblockdata1) -> { -- this.broadcastBlockEntityIfNeeded(list, world, blockposition1, iblockdata1); -+ this.broadcastBlockEntityIfNeeded(finalList, world, blockposition1, iblockdata1); -+ // CraftBukkit end - }); - } - } -@@ -291,7 +311,7 @@ +@@ -291,7 +308,7 @@ this.pendingFullStateConfirmation = completablefuture1; completablefuture.thenAccept((chunkresult) -> { chunkresult.ifSuccess((chunk) -> { @@ -82,7 +69,7 @@ }); }); } -@@ -301,6 +321,38 @@ +@@ -301,6 +318,38 @@ playerchunkmap.onFullChunkStatusChange(this.pos, fullchunkstatus); } @@ -121,7 +108,7 @@ protected void updateFutures(PlayerChunkMap playerchunkmap, Executor executor) { FullChunkStatus fullchunkstatus = ChunkLevel.fullStatus(this.oldTicketLevel); FullChunkStatus fullchunkstatus1 = ChunkLevel.fullStatus(this.ticketLevel); -@@ -357,6 +409,26 @@ +@@ -357,6 +406,26 @@ this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel); this.oldTicketLevel = this.ticketLevel; diff --git a/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch b/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch index 91440ae95..88392edf8 100644 --- a/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch +++ b/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/PlayerChunkMap.java +++ b/net/minecraft/server/level/PlayerChunkMap.java -@@ -104,6 +104,10 @@ +@@ -105,6 +105,10 @@ import org.apache.commons.lang3.mutable.MutableBoolean; import org.slf4j.Logger; @@ -11,7 +11,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.b, GeneratingChunkMap { private static final ChunkResult> UNLOADED_CHUNK_LIST_RESULT = ChunkResult.error("Unloaded chunks found in range"); -@@ -149,6 +153,27 @@ +@@ -151,6 +155,27 @@ public int serverViewDistance; private final WorldGenContext worldGenContext; @@ -36,10 +36,10 @@ + }; + // CraftBukkit end + - public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, StructureTemplateManager structuretemplatemanager, Executor executor, IAsyncTaskHandler iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier supplier, int i, boolean flag) { + public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, StructureTemplateManager structuretemplatemanager, Executor executor, IAsyncTaskHandler iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier supplier, TicketStorage ticketstorage, int i, boolean flag) { super(new RegionStorageInfo(convertable_conversionsession.getLevelId(), worldserver.dimension(), "chunk"), convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag); this.visibleChunkMap = this.updatingChunkMap.clone(); -@@ -170,7 +195,13 @@ +@@ -172,7 +197,13 @@ IRegistryCustom iregistrycustom = worldserver.registryAccess(); long j = worldserver.getSeed(); @@ -51,29 +51,29 @@ + } + if (randomGenerator instanceof ChunkGeneratorAbstract chunkgeneratorabstract) { + // CraftBukkit end - this.randomState = RandomState.create((GeneratorSettingBase) chunkgeneratorabstract.generatorSettings().value(), (HolderGetter) iregistrycustom.lookupOrThrow(Registries.NOISE), j); + this.randomState = RandomState.create((GeneratorSettingBase) chunkgeneratorabstract.generatorSettings().value(), iregistrycustom.lookupOrThrow(Registries.NOISE), j); } else { - this.randomState = RandomState.create(GeneratorSettingBase.dummy(), (HolderGetter) iregistrycustom.lookupOrThrow(Registries.NOISE), j); -@@ -325,7 +356,7 @@ + this.randomState = RandomState.create(GeneratorSettingBase.dummy(), iregistrycustom.lookupOrThrow(Registries.NOISE), j); +@@ -316,7 +347,7 @@ throw this.debugFuturesAndCreateReportedException(new IllegalStateException("At least one of the chunk futures were null"), "n/a"); } -- IChunkAccess ichunkaccess = (IChunkAccess) chunkresult.orElse((Object) null); -+ IChunkAccess ichunkaccess = (IChunkAccess) chunkresult.orElse(null); // CraftBukkit - decompile error +- IChunkAccess ichunkaccess = chunkresult.orElse((Object) null); ++ IChunkAccess ichunkaccess = chunkresult.orElse(null); // CraftBukkit - decompile error if (ichunkaccess == null) { return PlayerChunkMap.UNLOADED_CHUNK_LIST_RESULT; -@@ -977,7 +1008,8 @@ +@@ -961,7 +992,8 @@ return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty(); }); -- csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getPersistedStatus).orElse((Object) null), optional1.map(Chunk::getFullStatus).orElse((Object) null), printFuture(playerchunk.getFullChunkFuture()), printFuture(playerchunk.getTickingChunkFuture()), printFuture(playerchunk.getEntityTickingChunkFuture()), this.distanceManager.getTicketDebugString(i), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> { +- csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getPersistedStatus).orElse((Object) null), optional1.map(Chunk::getFullStatus).orElse((Object) null), printFuture(playerchunk.getFullChunkFuture()), printFuture(playerchunk.getTickingChunkFuture()), printFuture(playerchunk.getEntityTickingChunkFuture()), this.ticketStorage.getTicketDebugString(i, false), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> { + // CraftBukkit - decompile error -+ csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getPersistedStatus).orElse(null), optional1.map(Chunk::getFullStatus).orElse(null), printFuture(playerchunk.getFullChunkFuture()), printFuture(playerchunk.getTickingChunkFuture()), printFuture(playerchunk.getEntityTickingChunkFuture()), this.distanceManager.getTicketDebugString(i), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> { ++ csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getPersistedStatus).orElse(null), optional1.map(Chunk::getFullStatus).orElse(null), printFuture(playerchunk.getFullChunkFuture()), printFuture(playerchunk.getTickingChunkFuture()), printFuture(playerchunk.getEntityTickingChunkFuture()), this.ticketStorage.getTicketDebugString(i, false), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> { return chunk.getBlockEntities().size(); - }).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> { + }).orElse(0), this.ticketStorage.getTicketDebugString(i, true), this.distanceManager.getChunkLevel(i, true), optional1.map((chunk) -> { return chunk.getBlockTicks().count(); -@@ -990,7 +1022,7 @@ +@@ -974,7 +1006,7 @@ private static String printFuture(CompletableFuture> completablefuture) { try { @@ -82,7 +82,7 @@ return chunkresult != null ? (chunkresult.isSuccess() ? "done" : "unloaded") : "not completed"; } catch (CompletionException completionexception) { -@@ -1002,12 +1034,14 @@ +@@ -986,12 +1018,14 @@ private CompletableFuture> readChunk(ChunkCoordIntPair chunkcoordintpair) { return this.read(chunkcoordintpair).thenApplyAsync((optional) -> { @@ -99,17 +99,17 @@ + // CraftBukkit end } - void forEachSpawnCandidateChunk(Consumer consumer) { -@@ -1424,7 +1458,7 @@ + void collectSpawningChunks(List list) { +@@ -1413,7 +1447,7 @@ public final Set seenBy = Sets.newIdentityHashSet(); public EntityTracker(final Entity entity, final int i, final int j, final boolean flag) { -- this.serverEntity = new EntityTrackerEntry(PlayerChunkMap.this.level, entity, j, flag, this::broadcast); -+ this.serverEntity = new EntityTrackerEntry(PlayerChunkMap.this.level, entity, j, flag, this::broadcast, seenBy); // CraftBukkit +- this.serverEntity = new EntityTrackerEntry(PlayerChunkMap.this.level, entity, j, flag, this::broadcast, this::broadcastIgnorePlayers); ++ this.serverEntity = new EntityTrackerEntry(PlayerChunkMap.this.level, entity, j, flag, this::broadcast, this::broadcastIgnorePlayers, seenBy); // CraftBukkit this.entity = entity; this.range = i; this.lastSectionPos = SectionPosition.of((EntityAccess) entity); -@@ -1484,6 +1518,11 @@ +@@ -1474,6 +1508,11 @@ double d2 = d0 * d0; boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer) && PlayerChunkMap.this.isChunkTracked(entityplayer, this.entity.chunkPosition().x, this.entity.chunkPosition().z); diff --git a/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch b/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch index 5826f84b9..de7565839 100644 --- a/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch +++ b/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch @@ -52,15 +52,15 @@ public void tick() { - ++this.gameTicks; + this.gameTicks = MinecraftServer.currentTick; // CraftBukkit; - IBlockData iblockdata; - if (this.hasDelayedDestroy) { -@@ -146,11 +174,33 @@ + IBlockData iblockdata = this.level.getBlockState(this.delayedDestroyPos); +@@ -144,11 +172,33 @@ + } else { if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) { if (!this.level.mayInteract(this.player, blockposition)) { + // CraftBukkit start - fire PlayerInteractEvent -+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getSelected(), EnumHand.MAIN_HAND); ++ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getSelectedItem(), EnumHand.MAIN_HAND); this.player.connection.send(new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition))); this.debugLogging(blockposition, false, j, "may not interact"); + // Update any tile entity data for this block @@ -73,7 +73,7 @@ } + // CraftBukkit start -+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getSelected(), EnumHand.MAIN_HAND); ++ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getSelectedItem(), EnumHand.MAIN_HAND); + if (event.isCancelled()) { + // Let the client know the block still exists + this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition)); @@ -86,13 +86,13 @@ + } + // CraftBukkit end + - if (this.isCreative()) { + if (this.player.getAbilities().instabuild) { this.destroyAndAck(blockposition, j, "creative destroy"); return; -@@ -166,7 +216,19 @@ +@@ -164,7 +214,19 @@ float f = 1.0F; + IBlockData iblockdata = this.level.getBlockState(blockposition); - iblockdata = this.level.getBlockState(blockposition); - if (!iblockdata.isAir()) { + // CraftBukkit start - Swings at air do *NOT* exist. + if (event.useInteractedBlock() == Event.Result.DENY) { @@ -110,7 +110,7 @@ EnchantmentManager.onHitBlock(this.level, this.player.getMainHandItem(), this.player, this.player, EnumItemSlot.MAINHAND, Vec3D.atCenterOf(blockposition), iblockdata, (item) -> { this.player.onEquippedItemBroken(item, EnumItemSlot.MAINHAND); }); -@@ -174,6 +236,26 @@ +@@ -172,6 +234,26 @@ f = iblockdata.getDestroyProgress(this.player, this.player.level(), blockposition); } @@ -121,7 +121,7 @@ + } + return; + } -+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition, this.player.getInventory().getSelected(), f >= 1.0f); ++ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition, this.player.getInventory().getSelectedItem(), f >= 1.0f); + + if (blockEvent.isCancelled()) { + // Let the client know the block still exists @@ -137,7 +137,7 @@ if (!iblockdata.isAir() && f >= 1.0F) { this.destroyAndAck(blockposition, j, "insta mine"); } else { -@@ -218,13 +300,15 @@ +@@ -216,13 +298,15 @@ } else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) { this.isDestroyingBlock = false; if (!Objects.equals(this.destroyPos, blockposition)) { @@ -150,11 +150,11 @@ this.level.destroyBlockProgress(this.player.getId(), blockposition, -1); this.debugLogging(blockposition, true, j, "aborted destroying"); + -+ CraftEventFactory.callBlockDamageAbortEvent(this.player, blockposition, this.player.getInventory().getSelected()); // CraftBukkit ++ CraftEventFactory.callBlockDamageAbortEvent(this.player, blockposition, this.player.getInventory().getSelectedItem()); // CraftBukkit } } -@@ -242,10 +326,65 @@ +@@ -240,10 +324,65 @@ public boolean destroyBlock(BlockPosition blockposition) { IBlockData iblockdata = this.level.getBlockState(blockposition); @@ -162,10 +162,10 @@ + org.bukkit.block.Block bblock = CraftBlock.at(level, blockposition); + BlockBreakEvent event = null; -- if (!this.player.getMainHandItem().getItem().canAttackBlock(iblockdata, this.level, blockposition, this.player)) { +- if (!this.player.getMainHandItem().canDestroyBlock(iblockdata, this.level, blockposition, this.player)) { + if (this.player instanceof EntityPlayer) { + // Sword + Creative mode pre-cancel -+ boolean isSwordNoBreak = !this.player.getMainHandItem().getItem().canAttackBlock(iblockdata, this.level, blockposition, this.player); ++ boolean isSwordNoBreak = !this.player.getMainHandItem().canDestroyBlock(iblockdata, this.level, blockposition, this.player); + + // Tell client the block is gone immediately then process events + // Don't tell the client if its a creative sword break because its not broken! @@ -213,7 +213,7 @@ + } + // CraftBukkit end + -+ if (false && !this.player.getMainHandItem().getItem().canAttackBlock(iblockdata, this.level, blockposition, this.player)) { // CraftBukkit - false ++ if (false && !this.player.getMainHandItem().canDestroyBlock(iblockdata, this.level, blockposition, this.player)) { // CraftBukkit - false return false; } else { + iblockdata = this.level.getBlockState(blockposition); // CraftBukkit - update state from plugins @@ -221,7 +221,7 @@ TileEntity tileentity = this.level.getBlockEntity(blockposition); Block block = iblockdata.getBlock(); -@@ -255,6 +394,10 @@ +@@ -253,6 +392,10 @@ } else if (this.player.blockActionRestricted(this.level, blockposition, this.gameModeForPlayer)) { return false; } else { @@ -232,10 +232,10 @@ IBlockData iblockdata1 = block.playerWillDestroy(this.level, blockposition, iblockdata, this.player); boolean flag = this.level.removeBlock(blockposition, false); -@@ -263,19 +406,32 @@ +@@ -261,19 +404,32 @@ } - if (this.isCreative()) { + if (this.player.preventsBlockDrops()) { - return true; + // return true; // CraftBukkit } else { @@ -268,7 +268,7 @@ } } } -@@ -321,14 +477,53 @@ +@@ -319,14 +475,53 @@ } } @@ -322,12 +322,12 @@ if (itileinventory != null) { entityplayer.openMenu(itileinventory); -@@ -359,7 +554,7 @@ +@@ -357,7 +552,7 @@ } } - if (!itemstack.isEmpty() && !entityplayer.getCooldowns().isOnCooldown(itemstack)) { + if (!itemstack.isEmpty() && !interactResult) { // add !interactResult SPIGOT-764 ItemActionContext itemactioncontext = new ItemActionContext(entityplayer, enumhand, movingobjectpositionblock); + EnumInteractionResult enuminteractionresult2; - if (this.isCreative()) { diff --git a/nms-patches/net/minecraft/server/level/Ticket.patch b/nms-patches/net/minecraft/server/level/Ticket.patch new file mode 100644 index 000000000..a3e615946 --- /dev/null +++ b/nms-patches/net/minecraft/server/level/Ticket.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/server/level/Ticket.java ++++ b/net/minecraft/server/level/Ticket.java +@@ -17,6 +17,15 @@ + private final TicketType type; + private final int ticketLevel; + private long ticksLeft; ++ // CraftBukkit start ++ public Object key; ++ ++ public static Ticket of(TicketType tickettype, int i, Object key) { ++ Ticket ticket = new Ticket(tickettype, i); ++ ticket.key = key; ++ return ticket; ++ } ++ // CraftBukkit end + + public Ticket(TicketType tickettype, int i) { + this(tickettype, i, tickettype.timeout()); diff --git a/nms-patches/net/minecraft/server/level/TicketType.patch b/nms-patches/net/minecraft/server/level/TicketType.patch index 6f0d81969..26ea25dc8 100644 --- a/nms-patches/net/minecraft/server/level/TicketType.patch +++ b/nms-patches/net/minecraft/server/level/TicketType.patch @@ -1,11 +1,19 @@ --- a/net/minecraft/server/level/TicketType.java +++ b/net/minecraft/server/level/TicketType.java -@@ -22,6 +22,8 @@ - public static final TicketType PORTAL = create("portal", BaseBlockPosition::compareTo, 300); - public static final TicketType ENDER_PEARL = create("ender_pearl", Comparator.comparingLong(ChunkCoordIntPair::toLong), 40); - public static final TicketType UNKNOWN = create("unknown", Comparator.comparingLong(ChunkCoordIntPair::toLong), 1); -+ public static final TicketType PLUGIN = create("plugin", (a, b) -> 0); // CraftBukkit -+ public static final TicketType PLUGIN_TICKET = create("plugin_ticket", (plugin1, plugin2) -> plugin1.getClass().getName().compareTo(plugin2.getClass().getName())); // CraftBukkit +@@ -14,6 +14,16 @@ + public static final TicketType PORTAL = register("portal", 300L, true, TicketType.a.LOADING_AND_SIMULATION); + public static final TicketType ENDER_PEARL = register("ender_pearl", 40L, false, TicketType.a.LOADING_AND_SIMULATION); + public static final TicketType UNKNOWN = register("unknown", 1L, false, TicketType.a.LOADING); ++ // CraftBukkit start ++ public static long pluginTimeout = 0L; ++ public static final TicketType PLUGIN = register("plugin", 0L, false, TicketType.a.LOADING_AND_SIMULATION); ++ public static final TicketType PLUGIN_TICKET = register("plugin_ticket", 0L, false, TicketType.a.LOADING_AND_SIMULATION); ++ ++ @Override ++ public long timeout() { ++ return (this != TicketType.PLUGIN) ? this.timeout : TicketType.pluginTimeout; ++ } ++ // CraftBukkit end - public static TicketType create(String s, Comparator comparator) { - return new TicketType<>(s, comparator, 0L); + private static TicketType register(String s, long i, boolean flag, TicketType.a tickettype_a) { + return (TicketType) IRegistry.register(BuiltInRegistries.TICKET_TYPE, s, new TicketType(i, flag, tickettype_a)); diff --git a/nms-patches/net/minecraft/server/level/WorldServer.patch b/nms-patches/net/minecraft/server/level/WorldServer.patch index 3ed6f6b4a..694b356e6 100644 --- a/nms-patches/net/minecraft/server/level/WorldServer.patch +++ b/nms-patches/net/minecraft/server/level/WorldServer.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/server/level/WorldServer.java +++ b/net/minecraft/server/level/WorldServer.java -@@ -174,6 +174,23 @@ +@@ -169,6 +169,24 @@ import net.minecraft.world.ticks.TickListServer; import org.slf4j.Logger; +// CraftBukkit start ++import java.util.UUID; +import net.minecraft.world.level.biome.WorldChunkManager; +import net.minecraft.world.level.dimension.WorldDimension; +import net.minecraft.world.level.levelgen.ChunkGeneratorAbstract; @@ -24,7 +25,7 @@ public class WorldServer extends World implements ServerEntityGetter, GeneratorAccessSeed { public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0); -@@ -187,7 +204,7 @@ +@@ -182,7 +200,7 @@ final List players = Lists.newArrayList(); private final ChunkProviderServer chunkSource; private final MinecraftServer server; @@ -33,7 +34,7 @@ private int lastSpawnChunkRadius; final EntityTickList entityTickList = new EntityTickList(); public final PersistentEntitySectionManager entityManager; -@@ -214,13 +231,47 @@ +@@ -209,13 +227,47 @@ private final boolean tickTime; private final RandomSequences randomSequences; @@ -83,7 +84,7 @@ boolean flag2 = minecraftserver.forceSynchronousWrites(); DataFixer datafixer = minecraftserver.getFixerUpper(); EntityPersistentStorage entitypersistentstorage = new EntityStorage(new SimpleRegionStorage(new RegionStorageInfo(convertable_conversionsession.getLevelId(), resourcekey, "entities"), convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, DataFixTypes.ENTITY_CHUNK), this, minecraftserver); -@@ -248,9 +299,9 @@ +@@ -243,9 +295,9 @@ long l = minecraftserver.getWorldData().worldGenOptions().seed(); this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer); @@ -96,24 +97,25 @@ } else { this.dragonFight = null; } -@@ -260,6 +311,7 @@ +@@ -255,6 +307,7 @@ this.randomSequences = (RandomSequences) Objects.requireNonNullElseGet(randomsequences, () -> { - return (RandomSequences) this.getDataStorage().computeIfAbsent(RandomSequences.factory(l), "random_sequences"); + return (RandomSequences) this.getDataStorage().computeIfAbsent(RandomSequences.TYPE); }); + this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit } /** @deprecated */ -@@ -305,12 +357,20 @@ - long j; +@@ -299,13 +352,22 @@ + int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { -+ // CraftBukkit start -+ j = this.levelData.getDayTime() + 24000L; -+ TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (j - j % 24000L) - this.getDayTime()); ++ TimeSkipEvent event = null; // CraftBukkit if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { -- j = this.levelData.getDayTime() + 24000L; + long j = this.levelData.getDayTime() + 24000L; + - this.setDayTime(j - j % 24000L); ++ // CraftBukkit start ++ event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (j - j % 24000L) - this.getDayTime()); + getCraftServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { + this.setDayTime(this.getDayTime() + event.getSkipAmount()); @@ -121,23 +123,23 @@ } - this.wakeUpAllPlayers(); -+ if (!event.isCancelled()) { ++ if (event == null || !event.isCancelled()) { + this.wakeUpAllPlayers(); + } + // CraftBukkit end if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) { this.resetWeatherCycle(); } -@@ -345,7 +405,7 @@ +@@ -341,7 +403,7 @@ this.handlingTick = false; gameprofilerfiller.pop(); -- boolean flag1 = !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); -+ boolean flag1 = true || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players +- boolean flag1 = !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); ++ boolean flag1 = true || !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players if (flag1) { this.resetEmptyTime(); -@@ -429,7 +489,7 @@ +@@ -421,7 +483,7 @@ private void wakeUpAllPlayers() { this.sleepStatus.removeAllSleepers(); @@ -146,7 +148,7 @@ entityplayer.stopSleepInBed(false, false); }); } -@@ -456,7 +516,7 @@ +@@ -498,7 +560,7 @@ entityhorseskeleton.setTrap(true); entityhorseskeleton.setAge(0); entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); @@ -155,16 +157,16 @@ } } -@@ -465,7 +525,7 @@ +@@ -507,7 +569,7 @@ if (entitylightning != null) { - entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition)); + entitylightning.snapTo(Vec3D.atBottomCenterOf(blockposition)); entitylightning.setVisualOnly(flag1); - this.addFreshEntity(entitylightning); + this.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.WEATHER); // CraftBukkit } } } -@@ -521,7 +581,7 @@ +@@ -522,7 +584,7 @@ BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition1).value(); if (biomebase.shouldFreeze(this, blockposition2)) { @@ -173,7 +175,7 @@ } if (this.isRaining()) { -@@ -537,10 +597,10 @@ +@@ -538,10 +600,10 @@ IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, j + 1); Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition1); @@ -186,7 +188,7 @@ } } -@@ -701,6 +761,7 @@ +@@ -698,6 +760,7 @@ this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F); } @@ -194,7 +196,7 @@ if (this.oRainLevel != this.rainLevel) { this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension()); } -@@ -719,15 +780,48 @@ +@@ -716,15 +779,48 @@ this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } @@ -245,23 +247,23 @@ } public void resetEmptyTime() { -@@ -763,6 +857,7 @@ +@@ -760,6 +856,7 @@ }); gameprofilerfiller.incrementCounter("tickNonPassenger"); entity.tick(); + entity.postTick(); // CraftBukkit gameprofilerfiller.pop(); - Iterator iterator = entity.getPassengers().iterator(); -@@ -786,6 +881,7 @@ + for (Entity entity1 : entity.getPassengers()) { +@@ -780,6 +877,7 @@ }); gameprofilerfiller.incrementCounter("tickPassenger"); entity1.rideTick(); + entity1.postTick(); // CraftBukkit gameprofilerfiller.pop(); - Iterator iterator = entity1.getPassengers().iterator(); -@@ -810,6 +906,7 @@ + for (Entity entity2 : entity1.getPassengers()) { +@@ -811,6 +909,7 @@ ChunkProviderServer chunkproviderserver = this.getChunkSource(); if (!flag1) { @@ -269,7 +271,7 @@ if (iprogressupdate != null) { iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel")); } -@@ -827,11 +924,19 @@ +@@ -828,11 +927,19 @@ } } @@ -290,7 +292,7 @@ } WorldPersistentData worldpersistentdata = this.getChunkSource().getDataStorage(); -@@ -903,18 +1008,40 @@ +@@ -901,18 +1008,40 @@ @Override public boolean addFreshEntity(Entity entity) { @@ -334,7 +336,7 @@ } } -@@ -939,24 +1066,37 @@ +@@ -937,24 +1066,37 @@ this.entityManager.addNewEntity(entityplayer); } @@ -376,7 +378,7 @@ return true; } } -@@ -967,13 +1107,35 @@ +@@ -965,17 +1107,45 @@ } public void removePlayerImmediately(EntityPlayer entityplayer, Entity.RemovalReason entity_removalreason) { @@ -402,18 +404,15 @@ + @Override public void destroyBlockProgress(int i, BlockPosition blockposition, int j) { - Iterator iterator = this.server.getPlayerList().getPlayers().iterator(); - + // CraftBukkit start + EntityHuman entityhuman = null; + Entity entity = this.getEntity(i); + if (entity instanceof EntityHuman) entityhuman = (EntityHuman) entity; + // CraftBukkit end + - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); - -@@ -982,6 +1144,12 @@ + for (EntityPlayer entityplayer : this.server.getPlayerList().getPlayers()) { + if (entityplayer != null && entityplayer.level() == this && entityplayer.getId() != i) { + double d0 = (double) blockposition.getX() - entityplayer.getX(); double d1 = (double) blockposition.getY() - entityplayer.getY(); double d2 = (double) blockposition.getZ() - entityplayer.getZ(); @@ -426,15 +425,18 @@ if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); } -@@ -1060,7 +1228,18 @@ - Iterator iterator = this.navigatingMobs.iterator(); +@@ -1078,8 +1248,21 @@ - while (iterator.hasNext()) { -- EntityInsentient entityinsentient = (EntityInsentient) iterator.next(); -+ // CraftBukkit start - fix SPIGOT-6362 + if (VoxelShapes.joinIsNotEmpty(voxelshape, voxelshape1, OperatorBoolean.NOT_SAME)) { + List list = new ObjectArrayList(); ++ // CraftBukkit start - fix SPIGOT-6362 ++ java.util.Iterator iterator = this.navigatingMobs.iterator(); + +- for (EntityInsentient entityinsentient : this.navigatingMobs) { ++ while (iterator.hasNext()) { + EntityInsentient entityinsentient; + try { -+ entityinsentient = (EntityInsentient) iterator.next(); ++ entityinsentient = iterator.next(); + } catch (java.util.ConcurrentModificationException ex) { + // This can happen because the pathfinder update below may trigger a chunk load, which in turn may cause more navigators to register + // In this case we just run the update again across all the iterators as the chunk will then be loaded @@ -446,7 +448,7 @@ NavigationAbstract navigationabstract = entityinsentient.getNavigation(); if (navigationabstract.shouldRecomputePath(blockposition)) { -@@ -1126,6 +1305,12 @@ +@@ -1142,6 +1325,12 @@ @Override public void explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, World.a world_a, ParticleParam particleparam, ParticleParam particleparam1, Holder holder) { @@ -459,7 +461,7 @@ Explosion.Effect explosion_effect; switch (world_a) { -@@ -1144,6 +1329,11 @@ +@@ -1160,6 +1349,11 @@ case TRIGGER: explosion_effect = Explosion.Effect.TRIGGER_BLOCK; break; @@ -471,7 +473,7 @@ default: throw new MatchException((String) null, (Throwable) null); } -@@ -1153,6 +1343,11 @@ +@@ -1169,6 +1363,11 @@ ServerExplosion serverexplosion = new ServerExplosion(this, entity, damagesource, explosiondamagecalculator, vec3d, f, flag, explosion_effect1); serverexplosion.explode(); @@ -481,9 +483,9 @@ + } + // CraftBukkit end ParticleParam particleparam2 = serverexplosion.isSmall() ? particleparam : particleparam1; - Iterator iterator = this.players.iterator(); -@@ -1166,6 +1361,7 @@ + for (EntityPlayer entityplayer : this.players) { +@@ -1179,6 +1378,7 @@ } } @@ -491,7 +493,7 @@ } private Explosion.Effect getDestroyType(GameRules.GameRuleKey gamerules_gamerulekey) { -@@ -1226,15 +1422,22 @@ +@@ -1239,15 +1439,22 @@ } public int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { @@ -515,7 +517,7 @@ if (this.sendParticles(entityplayer, flag, d0, d1, d2, packetplayoutworldparticles)) { ++j; -@@ -1292,7 +1495,7 @@ +@@ -1300,7 +1507,7 @@ @Nullable public BlockPosition findNearestMapStructure(TagKey tagkey, BlockPosition blockposition, int i, boolean flag) { @@ -524,13 +526,13 @@ return null; } else { Optional> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(tagkey); -@@ -1334,11 +1537,22 @@ +@@ -1342,10 +1549,21 @@ @Nullable @Override public WorldMap getMapData(MapId mapid) { -- return (WorldMap) this.getServer().overworld().getDataStorage().get(WorldMap.factory(), mapid.key()); +- return (WorldMap) this.getServer().overworld().getDataStorage().get(WorldMap.type(mapid)); + // CraftBukkit start -+ WorldMap worldmap = (WorldMap) this.getServer().overworld().getDataStorage().get(WorldMap.factory(), mapid.key()); ++ WorldMap worldmap = (WorldMap) this.getServer().overworld().getDataStorage().get(WorldMap.type(mapid)); + if (worldmap != null) { + worldmap.id = mapid; + } @@ -538,29 +540,16 @@ + // CraftBukkit end } - @Override public void setMapData(MapId mapid, WorldMap worldmap) { + // CraftBukkit start + worldmap.id = mapid; + MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView); + Bukkit.getServer().getPluginManager().callEvent(event); + // CraftBukkit end - this.getServer().overworld().getDataStorage().set(mapid.key(), worldmap); + this.getServer().overworld().getDataStorage().set(WorldMap.type(mapid), worldmap); } -@@ -1649,6 +1863,11 @@ - @Override - public void blockUpdated(BlockPosition blockposition, Block block) { - if (!this.isDebug()) { -+ // CraftBukkit start -+ if (populating) { -+ return; -+ } -+ // CraftBukkit end - this.updateNeighborsAt(blockposition, block); - } - -@@ -1668,12 +1887,12 @@ +@@ -1557,12 +1775,12 @@ } public boolean isFlat() { @@ -575,16 +564,7 @@ } @Nullable -@@ -1696,7 +1915,7 @@ - private static String getTypeCount(Iterable iterable, Function function) { - try { - Object2IntOpenHashMap object2intopenhashmap = new Object2IntOpenHashMap(); -- Iterator iterator = iterable.iterator(); -+ Iterator iterator = iterable.iterator(); // CraftBukkit - decompile error - - while (iterator.hasNext()) { - T t0 = iterator.next(); -@@ -1705,7 +1924,7 @@ +@@ -1592,7 +1810,7 @@ object2intopenhashmap.addTo(s, 1); } @@ -593,7 +573,7 @@ String s1 = (String) entry.getKey(); return s1 + ":" + entry.getIntValue(); -@@ -1864,6 +2083,8 @@ +@@ -1754,6 +1972,8 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -602,7 +582,7 @@ } public void onTrackingEnd(Entity entity) { -@@ -1895,6 +2116,14 @@ +@@ -1780,6 +2000,14 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); diff --git a/nms-patches/net/minecraft/server/network/HandshakeListener.patch b/nms-patches/net/minecraft/server/network/HandshakeListener.patch index 3b369126f..54fd1c3d1 100644 --- a/nms-patches/net/minecraft/server/network/HandshakeListener.patch +++ b/nms-patches/net/minecraft/server/network/HandshakeListener.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/HandshakeListener.java +++ b/net/minecraft/server/network/HandshakeListener.java -@@ -13,8 +13,17 @@ +@@ -12,8 +12,17 @@ import net.minecraft.network.protocol.status.StatusProtocols; import net.minecraft.server.MinecraftServer; @@ -18,7 +18,7 @@ private static final IChatBaseComponent IGNORE_STATUS_REASON = IChatBaseComponent.translatable("disconnect.ignoring_status_request"); private final MinecraftServer server; private final NetworkManager connection; -@@ -26,6 +35,7 @@ +@@ -25,6 +34,7 @@ @Override public void handleIntention(PacketHandshakingInSetProtocol packethandshakinginsetprotocol) { @@ -26,7 +26,7 @@ switch (packethandshakinginsetprotocol.intention()) { case LOGIN: this.beginLogin(packethandshakinginsetprotocol, false); -@@ -59,6 +69,40 @@ +@@ -58,6 +68,40 @@ private void beginLogin(PacketHandshakingInSetProtocol packethandshakinginsetprotocol, boolean flag) { this.connection.setupOutboundProtocol(LoginProtocols.CLIENTBOUND); @@ -39,7 +39,7 @@ + synchronized (throttleTracker) { + if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) { + throttleTracker.put(address, currentTime); -+ IChatMutableComponent chatmessage = IChatBaseComponent.literal("Connection throttled! Please wait before reconnecting."); ++ IChatBaseComponent chatmessage = IChatBaseComponent.literal("Connection throttled! Please wait before reconnecting."); + this.connection.send(new PacketLoginOutDisconnect(chatmessage)); + this.connection.disconnect(chatmessage); + return; @@ -65,5 +65,5 @@ + } + // CraftBukkit end if (packethandshakinginsetprotocol.protocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) { - IChatMutableComponent ichatmutablecomponent; + IChatBaseComponent ichatbasecomponent; diff --git a/nms-patches/net/minecraft/server/network/LegacyPingHandler.patch b/nms-patches/net/minecraft/server/network/LegacyPingHandler.patch index bed960eee..e926db1ae 100644 --- a/nms-patches/net/minecraft/server/network/LegacyPingHandler.patch +++ b/nms-patches/net/minecraft/server/network/LegacyPingHandler.patch @@ -1,28 +1,28 @@ --- a/net/minecraft/server/network/LegacyPingHandler.java +++ b/net/minecraft/server/network/LegacyPingHandler.java -@@ -35,10 +35,11 @@ +@@ -30,10 +30,11 @@ + if (bytebuf.readUnsignedByte() == 254) { SocketAddress socketaddress = channelhandlercontext.channel().remoteAddress(); int i = bytebuf.readableBytes(); - String s; + org.bukkit.event.server.ServerListPingEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(socketaddress, server.getMotd(), server.getPlayerCount(), server.getMaxPlayers()); // CraftBukkit if (i == 0) { LegacyPingHandler.LOGGER.debug("Ping: (<1.3.x) from {}", socketaddress); -- s = createVersion0Response(this.server); -+ s = createVersion0Response(this.server, event); // CraftBukkit +- String s = createVersion0Response(this.server); ++ String s = createVersion0Response(this.server, event); // CraftBukkit + sendFlushAndClose(channelhandlercontext, createLegacyDisconnectPacket(channelhandlercontext.alloc(), s)); } else { - if (bytebuf.readUnsignedByte() != 1) { -@@ -55,7 +56,7 @@ +@@ -51,7 +52,7 @@ LegacyPingHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}", socketaddress); } -- s = createVersion1Response(this.server); -+ s = createVersion1Response(this.server, event); // CraftBukkit - sendFlushAndClose(channelhandlercontext, createLegacyDisconnectPacket(channelhandlercontext.alloc(), s)); - } +- String s1 = createVersion1Response(this.server); ++ String s1 = createVersion1Response(this.server, event); // CraftBukkit -@@ -106,12 +107,16 @@ + sendFlushAndClose(channelhandlercontext, createLegacyDisconnectPacket(channelhandlercontext.alloc(), s1)); + } +@@ -104,12 +105,16 @@ } } diff --git a/nms-patches/net/minecraft/server/network/PlayerConnection.patch b/nms-patches/net/minecraft/server/network/PlayerConnection.patch index c8baccb03..f926996b8 100644 --- a/nms-patches/net/minecraft/server/network/PlayerConnection.patch +++ b/nms-patches/net/minecraft/server/network/PlayerConnection.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/PlayerConnection.java +++ b/net/minecraft/server/network/PlayerConnection.java -@@ -198,6 +198,71 @@ +@@ -208,6 +208,71 @@ import net.minecraft.world.phys.shapes.VoxelShapes; import org.slf4j.Logger; @@ -69,10 +69,10 @@ +import org.bukkit.util.Vector; +// CraftBukkit end + - public class PlayerConnection extends ServerCommonPacketListenerImpl implements PacketListenerPlayIn, ServerPlayerConnection, TickablePacketListener { + public class PlayerConnection extends ServerCommonPacketListenerImpl implements GameProtocols.a, PacketListenerPlayIn, ServerPlayerConnection, TickablePacketListener { static final Logger LOGGER = LogUtils.getLogger(); -@@ -247,7 +312,7 @@ +@@ -258,7 +323,7 @@ private boolean waitingForSwitchToConfig; public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer, CommonListenerCookie commonlistenercookie) { @@ -81,7 +81,7 @@ this.chunkSender = new PlayerChunkSender(networkmanager.isMemoryConnection()); this.player = entityplayer; entityplayer.connection = this; -@@ -256,9 +321,25 @@ +@@ -267,9 +332,25 @@ Objects.requireNonNull(minecraftserver); this.signedMessageDecoder = SignedMessageChain.b.unsigned(uuid, minecraftserver::enforceSecureProfile); @@ -108,7 +108,7 @@ @Override public void tick() { if (this.ackBlockChangesUpTo > -1) { -@@ -313,6 +394,7 @@ +@@ -324,6 +405,7 @@ this.chatSpamThrottler.tick(); this.dropSpamThrottler.tick(); if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && SystemUtils.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L) { @@ -116,7 +116,7 @@ this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.idling")); } -@@ -376,6 +458,12 @@ +@@ -387,6 +469,12 @@ @Override public void handlePlayerInput(PacketPlayInSteerVehicle packetplayinsteervehicle) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinsteervehicle, this, this.player.serverLevel()); @@ -129,7 +129,7 @@ this.player.setLastClientInput(packetplayinsteervehicle.input()); } -@@ -401,6 +489,13 @@ +@@ -412,6 +500,13 @@ if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) { WorldServer worldserver = this.player.serverLevel(); @@ -143,7 +143,7 @@ double d0 = entity.getX(); double d1 = entity.getY(); double d2 = entity.getZ(); -@@ -415,7 +510,33 @@ +@@ -426,7 +521,33 @@ double d9 = entity.getDeltaMovement().lengthSqr(); double d10 = d6 * d6 + d7 * d7 + d8 * d8; @@ -178,17 +178,18 @@ PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8}); this.send(PacketPlayOutVehicleMove.fromEntity(entity)); return; -@@ -455,14 +576,67 @@ +@@ -466,15 +587,68 @@ } - entity.absMoveTo(d3, d4, d5, f, f1); -+ player.absMoveTo(d3, d4, d5, this.player.getYRot(), this.player.getXRot()); // CraftBukkit + entity.absSnapTo(d3, d4, d5, f, f1); ++ player.absSnapTo(d3, d4, d5, this.player.getYRot(), this.player.getXRot()); // CraftBukkit boolean flag3 = worldserver.noCollision(entity, entity.getBoundingBox().deflate(0.0625D)); if (flag && (flag2 || !flag3)) { - entity.absMoveTo(d0, d1, d2, f, f1); -+ player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit + entity.absSnapTo(d0, d1, d2, f, f1); ++ player.absSnapTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit this.send(PacketPlayOutVehicleMove.fromEntity(entity)); + entity.removeLatestMovementRecordingBatch(); return; } @@ -244,9 +245,9 @@ + // CraftBukkit end + this.player.serverLevel().getChunkSource().move(this.player); - entity.recordMovementThroughBlocks(new Vec3D(d0, d1, d2), entity.position()); Vec3D vec3d = new Vec3D(entity.getX() - d0, entity.getY() - d1, entity.getZ() - d2); -@@ -499,6 +673,7 @@ + +@@ -510,6 +684,7 @@ this.lastGoodZ = this.awaitingPositionFromClient.z; this.player.hasChangedDimension(); this.awaitingPositionFromClient = null; @@ -254,7 +255,7 @@ } } -@@ -528,6 +703,7 @@ +@@ -540,6 +715,7 @@ @Override public void handleRecipeBookChangeSettingsPacket(PacketPlayInRecipeSettings packetplayinrecipesettings) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipesettings, this, this.player.serverLevel()); @@ -262,7 +263,7 @@ this.player.getRecipeBook().setBookSetting(packetplayinrecipesettings.getBookType(), packetplayinrecipesettings.isOpen(), packetplayinrecipesettings.isFiltering()); } -@@ -548,6 +724,12 @@ +@@ -560,6 +736,12 @@ @Override public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.serverLevel()); @@ -275,7 +276,7 @@ StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand()); if (stringreader.canRead() && stringreader.peek() == '/') { -@@ -557,6 +739,7 @@ +@@ -569,6 +751,7 @@ ParseResults parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { @@ -283,7 +284,16 @@ Suggestions suggestions1 = suggestions.getList().size() <= 1000 ? suggestions : new Suggestions(suggestions.getRange(), suggestions.getList().subList(0, 1000)); this.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions1)); -@@ -866,6 +1049,13 @@ +@@ -891,7 +1074,7 @@ + this.player.level().sendBlockUpdated(blockposition, Blocks.AIR.defaultBlockState(), iblockdata, 3); + } else { + IRegistry iregistry = this.player.registryAccess().lookupOrThrow(Registries.TEST_INSTANCE); +- Optional optional = serverboundtestinstanceblockactionpacket.data().test(); ++ Optional> optional = serverboundtestinstanceblockactionpacket.data().test(); // CraftBukkit - decompile error + + Objects.requireNonNull(iregistry); + Optional> optional1 = optional.flatMap(iregistry::get); +@@ -970,6 +1153,13 @@ Container container = this.player.containerMenu; if (container instanceof ContainerMerchant containermerchant) { @@ -297,7 +307,7 @@ if (!containermerchant.stillValid(this.player)) { PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant); return; -@@ -879,6 +1069,13 @@ +@@ -983,6 +1173,13 @@ @Override public void handleEditBook(PacketPlayInBEdit packetplayinbedit) { @@ -311,7 +321,7 @@ int i = packetplayinbedit.slot(); if (PlayerInventory.isHotbarSlot(i) || i == 40) { -@@ -899,12 +1096,16 @@ +@@ -1003,12 +1200,16 @@ } private void updateBookContents(List list, int i) { @@ -329,7 +339,7 @@ } } -@@ -915,12 +1116,13 @@ +@@ -1019,12 +1220,13 @@ ItemStack itemstack1 = itemstack.transmuteCopy(Items.WRITTEN_BOOK); itemstack1.remove(DataComponents.WRITABLE_BOOK_CONTENT); @@ -345,7 +355,7 @@ } } -@@ -982,7 +1184,7 @@ +@@ -1086,7 +1288,7 @@ } else { WorldServer worldserver = this.player.serverLevel(); @@ -354,144 +364,145 @@ if (this.tickCount == 0) { this.resetPosition(); } -@@ -997,7 +1199,15 @@ - 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 - } else { -+ // CraftBukkit - Make sure the move is valid but then reset it for plugins to modify -+ double prevX = player.getX(); -+ double prevY = player.getY(); -+ double prevZ = player.getZ(); -+ float prevYaw = player.getYRot(); -+ float prevPitch = player.getXRot(); -+ // CraftBukkit end - double d3 = this.player.getX(); - double d4 = this.player.getY(); - double d5 = this.player.getZ(); -@@ -1019,15 +1229,33 @@ - ++this.receivedMovePacketCount; - int i = this.receivedMovePacketCount - this.knownMovePacketCount; +@@ -1105,7 +1307,15 @@ + 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 = player.getX(); ++ double prevY = player.getY(); ++ double prevZ = player.getZ(); ++ float prevYaw = player.getYRot(); ++ float prevPitch = player.getXRot(); ++ // CraftBukkit end + double d3 = this.player.getX(); + double d4 = this.player.getY(); + double d5 = this.player.getZ(); +@@ -1127,15 +1337,33 @@ + ++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); +- 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); + -+ if (i > Math.max(this.allowedPlayerTicks, 5)) { - PlayerConnection.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", this.player.getName().getString(), i); - i = 1; ++ if (i > Math.max(this.allowedPlayerTicks, 5)) { + PlayerConnection.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", this.player.getName().getString(), i); + i = 1; + } + ++ if (packetplayinflying.hasRot || d10 > 0) { ++ allowedPlayerTicks -= 1; ++ } else { ++ allowedPlayerTicks = 20; ++ } ++ double speed; ++ if (player.getAbilities().flying) { ++ speed = player.getAbilities().flyingSpeed * 20f; ++ } else { ++ speed = player.getAbilities().walkingSpeed * 10f; ++ } ++ + if (this.shouldCheckPlayerMovement(flag)) { + float f2 = flag ? 300.0F : 100.0F; + +- if (d10 - d9 > (double) (f2 * (float) i)) { ++ if (d10 - d9 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2))) { ++ // CraftBukkit end + PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8}); + this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot()); + return; +@@ -1157,6 +1385,7 @@ + boolean flag2 = this.player.verticalCollisionBelow; + + this.player.move(EnumMoveType.PLAYER, new Vec3D(d6, d7, d8)); ++ this.player.onGround = packetplayinflying.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move + double d11 = d7; + + d6 = d0 - this.player.getX(); +@@ -1175,10 +1404,76 @@ } -+ if (packetplayinflying.hasRot || d10 > 0) { -+ allowedPlayerTicks -= 1; -+ } else { -+ allowedPlayerTicks = 20; -+ } -+ double speed; -+ if (player.getAbilities().flying) { -+ speed = player.getAbilities().flyingSpeed * 20f; -+ } else { -+ speed = player.getAbilities().walkingSpeed * 10f; -+ } + if (!this.player.noPhysics && !this.player.isSleeping() && (flag3 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) { +- this.teleport(d3, d4, d5, f, f1); ++ this.internalTeleport(d3, d4, d5, 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() - d3, this.player.getY() - d4, this.player.getZ() - d5, packetplayinflying.isOnGround()); + this.player.removeLatestMovementRecordingBatch(); + } else { ++ // CraftBukkit start - fire PlayerMoveEvent ++ // Reset to old location first ++ this.player.absSnapTo(prevX, prevY, prevZ, prevYaw, prevPitch); + - if (this.shouldCheckPlayerMovement(flag)) { - float f2 = flag ? 300.0F : 100.0F; - -- if (d10 - d9 > (double) (f2 * (float) i)) { -+ if (d10 - d9 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2))) { ++ 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(), lastPosX, lastPosY, lastPosZ, lastYaw, 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 (packetplayinflying.hasPos) { ++ to.setX(packetplayinflying.x); ++ to.setY(packetplayinflying.y); ++ to.setZ(packetplayinflying.z); ++ } ++ ++ // If the packet contains look information then we update the To location with the correct Yaw & Pitch. ++ if (packetplayinflying.hasRot) { ++ to.setYaw(packetplayinflying.yRot); ++ to.setPitch(packetplayinflying.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()) { ++ 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 - PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8}); - this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot()); - return; -@@ -1049,6 +1277,7 @@ - boolean flag2 = this.player.verticalCollisionBelow; + this.player.absSnapTo(d0, d1, d2, f, f1); + boolean flag4 = this.player.isAutoSpinAttack(); - this.player.move(EnumMoveType.PLAYER, new Vec3D(d6, d7, d8)); -+ this.player.onGround = packetplayinflying.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move - double d11 = d7; - - d6 = d0 - this.player.getX(); -@@ -1067,9 +1296,75 @@ - } - - if (!this.player.noPhysics && !this.player.isSleeping() && (flag3 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) { -- this.teleport(d3, d4, d5, f, f1); -+ this.internalTeleport(d3, d4, d5, 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() - d3, this.player.getY() - d4, this.player.getZ() - d5, packetplayinflying.isOnGround()); - } else { -+ // CraftBukkit start - fire PlayerMoveEvent -+ // Reset to old location first -+ this.player.absMoveTo(prevX, prevY, prevZ, prevYaw, prevPitch); -+ -+ 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(), lastPosX, lastPosY, lastPosZ, lastYaw, 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 (packetplayinflying.hasPos) { -+ to.setX(packetplayinflying.x); -+ to.setY(packetplayinflying.y); -+ to.setZ(packetplayinflying.z); -+ } -+ -+ // If the packet contains look information then we update the To location with the correct Yaw & Pitch. -+ if (packetplayinflying.hasRot) { -+ to.setYaw(packetplayinflying.yRot); -+ to.setPitch(packetplayinflying.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()) { -+ 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.absMoveTo(d0, d1, d2, f, f1); - boolean flag4 = this.player.isAutoSpinAttack(); - -@@ -1119,6 +1414,7 @@ +@@ -1228,6 +1523,7 @@ this.awaitingTeleportTime = this.tickCount; this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); } @@ -499,7 +510,7 @@ return true; } else { -@@ -1147,10 +1443,62 @@ +@@ -1251,10 +1547,62 @@ } public void teleport(double d0, double d1, double d2, float f, float f1) { @@ -563,7 +574,7 @@ this.awaitingTeleportTime = this.tickCount; if (++this.awaitingTeleport == Integer.MAX_VALUE) { this.awaitingTeleport = 0; -@@ -1158,12 +1506,20 @@ +@@ -1262,12 +1610,20 @@ this.player.teleportSetPosition(positionmoverotation, set); this.awaitingPositionFromClient = this.player.position(); @@ -584,7 +595,7 @@ if (this.player.hasClientLoaded()) { BlockPosition blockposition = packetplayinblockdig.getPos(); -@@ -1175,14 +1531,46 @@ +@@ -1279,14 +1635,46 @@ if (!this.player.isSpectator()) { ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND); @@ -633,7 +644,7 @@ this.player.drop(false); } -@@ -1221,6 +1609,7 @@ +@@ -1325,6 +1713,7 @@ @Override public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.serverLevel()); @@ -641,7 +652,7 @@ if (this.player.hasClientLoaded()) { this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence()); WorldServer worldserver = this.player.serverLevel(); -@@ -1244,6 +1633,7 @@ +@@ -1348,6 +1737,7 @@ if (blockposition.getY() <= i) { if (this.awaitingPositionFromClient == null && worldserver.mayInteract(this.player, blockposition)) { @@ -649,7 +660,7 @@ EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); if (enuminteractionresult.consumesAction()) { -@@ -1281,6 +1671,7 @@ +@@ -1385,6 +1775,7 @@ @Override public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.serverLevel()); @@ -657,8 +668,8 @@ if (this.player.hasClientLoaded()) { this.ackBlockChangesUpTo(packetplayinblockplace.getSequence()); WorldServer worldserver = this.player.serverLevel(); -@@ -1296,6 +1687,47 @@ - this.player.absRotateTo(f, f1); +@@ -1400,6 +1791,47 @@ + this.player.absSnapRotationTo(f, f1); } + // CraftBukkit start @@ -705,7 +716,7 @@ EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand); if (enuminteractionresult instanceof EnumInteractionResult.d) { -@@ -1321,7 +1753,7 @@ +@@ -1422,7 +1854,7 @@ Entity entity = packetplayinspectate.getEntity(worldserver); if (entity != null) { @@ -714,7 +725,7 @@ return; } } -@@ -1342,6 +1774,13 @@ +@@ -1443,6 +1875,13 @@ @Override public void onDisconnect(DisconnectionDetails disconnectiondetails) { @@ -728,7 +739,7 @@ PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), disconnectiondetails.reason().getString()); this.removePlayerFromWorld(); super.onDisconnect(disconnectiondetails); -@@ -1349,10 +1788,18 @@ +@@ -1450,10 +1889,18 @@ private void removePlayerFromWorld() { this.chatMessageChain.close(); @@ -748,24 +759,24 @@ this.player.getTextFilter().leave(); } -@@ -1367,7 +1814,16 @@ +@@ -1468,7 +1915,16 @@ @Override public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.serverLevel()); + if (this.player.isImmobile()) return; // CraftBukkit if (packetplayinhelditemslot.getSlot() >= 0 && packetplayinhelditemslot.getSlot() < PlayerInventory.getSelectionSize()) { -+ PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getCraftPlayer(), this.player.getInventory().selected, packetplayinhelditemslot.getSlot()); ++ PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getCraftPlayer(), this.player.getInventory().getSelectedSlot(), packetplayinhelditemslot.getSlot()); + this.cserver.getPluginManager().callEvent(event); + if (event.isCancelled()) { -+ this.send(new PacketPlayOutHeldItemSlot(this.player.getInventory().selected)); ++ this.send(new PacketPlayOutHeldItemSlot(this.player.getInventory().getSelectedSlot())); + this.player.resetLastActionTime(); + return; + } + // CraftBukkit end - if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) { + if (this.player.getInventory().getSelectedSlot() != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) { this.player.stopUsingItem(); } -@@ -1376,11 +1832,18 @@ +@@ -1477,11 +1933,18 @@ this.player.resetLastActionTime(); } else { PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString()); @@ -784,7 +795,7 @@ Optional optional = this.unpackAndApplyLastSeen(packetplayinchat.lastSeenMessages()); if (!optional.isEmpty()) { -@@ -1394,7 +1857,7 @@ +@@ -1495,7 +1958,7 @@ return; } @@ -793,7 +804,7 @@ IChatBaseComponent ichatbasecomponent = this.server.getChatDecorator().decorate(this.player, playerchatmessage.decoratedContent()); this.chatMessageChain.append(completablefuture, (filteredtext) -> { -@@ -1402,19 +1865,36 @@ +@@ -1503,19 +1966,36 @@ this.broadcastChatMessage(playerchatmessage1); }); @@ -832,7 +843,7 @@ ParseResults parseresults = this.parseCommand(s); if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) { -@@ -1431,19 +1911,37 @@ +@@ -1532,19 +2012,37 @@ if (!optional.isEmpty()) { this.tryHandleChat(serverboundchatcommandsignedpacket.command(), () -> { @@ -865,7 +876,7 @@ + ParseResults parseresults = this.parseCommand(command); + // CraftBukkit end - Map map; + Map map; try { - map = this.collectSignedArguments(serverboundchatcommandsignedpacket, SignableCommand.of(parseresults), lastseenmessages); @@ -873,21 +884,17 @@ } catch (SignedMessageChain.a signedmessagechain_a) { this.handleMessageDecodeFailure(signedmessagechain_a); return; -@@ -1451,10 +1949,10 @@ - - CommandSigningContext.a commandsigningcontext_a = new CommandSigningContext.a(map); - -- parseresults = CommandDispatcher.mapSource(parseresults, (commandlistenerwrapper) -> { -+ parseresults = CommandDispatcher.mapSource(parseresults, (commandlistenerwrapper) -> { // CraftBukkit - decompile error - return commandlistenerwrapper.withSigningContext(commandsigningcontext_a, this.chatMessageChain); +@@ -1555,7 +2053,7 @@ + parseresults = net.minecraft.commands.CommandDispatcher.mapSource(parseresults, (commandlistenerwrapper) -> { + return commandlistenerwrapper.withSigningContext(commandsigningcontext, this.chatMessageChain); }); - this.server.getCommands().performCommand(parseresults, serverboundchatcommandsignedpacket.command()); + this.server.getCommands().performCommand(parseresults, command); // CraftBukkit } private void handleMessageDecodeFailure(SignedMessageChain.a signedmessagechain_a) { -@@ -1530,14 +2028,20 @@ - return com_mojang_brigadier_commanddispatcher.parse(s, this.player.createCommandSourceStack()); +@@ -1621,14 +2119,20 @@ + return commanddispatcher.parse(s, this.player.createCommandSourceStack()); } - private void tryHandleChat(String s, Runnable runnable) { @@ -910,7 +917,7 @@ } } -@@ -1566,6 +2070,116 @@ +@@ -1660,6 +2164,116 @@ return false; } @@ -1027,7 +1034,7 @@ private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a { SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages); -@@ -1573,13 +2187,33 @@ +@@ -1667,13 +2281,33 @@ } private void broadcastChatMessage(PlayerChatMessage playerchatmessage) { @@ -1064,7 +1071,7 @@ this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("disconnect.spam")); } -@@ -1601,7 +2235,39 @@ +@@ -1695,7 +2329,39 @@ @Override public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.serverLevel()); @@ -1086,12 +1093,12 @@ + return entity != this.player.getBukkitEntity() && this.player.getBukkitEntity().canSee(entity) && !handle.isSpectator() && handle.isPickable() && !handle.isPassengerOfSameVehicle(player); + }); + if (result == null) { -+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), EnumHand.MAIN_HAND); ++ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelectedItem(), EnumHand.MAIN_HAND); + } else if (this.player.gameMode.getGameModeForPlayer() == EnumGamemode.ADVENTURE) { + Block block = result.getHitBlock(); + if (block != null) { + Vector hitPosition = result.getHitPosition().subtract(block.getLocation().toVector()); -+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, block, result.getHitBlockFace(), this.player.getInventory().getSelected(), true, EnumHand.MAIN_HAND, hitPosition); ++ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, block, result.getHitBlockFace(), this.player.getInventory().getSelectedItem(), true, EnumHand.MAIN_HAND, hitPosition); + } + } + @@ -1104,7 +1111,7 @@ this.player.swing(packetplayinarmanimation.getHand()); } -@@ -1609,6 +2275,29 @@ +@@ -1703,6 +2369,29 @@ public void handlePlayerCommand(PacketPlayInEntityAction packetplayinentityaction) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinentityaction, this, this.player.serverLevel()); if (this.player.hasClientLoaded()) { @@ -1132,9 +1139,9 @@ + } + // CraftBukkit end this.player.resetLastActionTime(); - Entity entity; - IJumpable ijumpable; -@@ -1691,6 +2380,12 @@ + switch (packetplayinentityaction.getAction()) { + case PRESS_SHIFT_KEY: +@@ -1766,6 +2455,12 @@ } public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) { @@ -1144,10 +1151,10 @@ + return; + } + // CraftBukkit end - this.send(new ClientboundPlayerChatPacket(playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a)); - this.addPendingMessage(playerchatmessage); - } -@@ -1718,6 +2413,7 @@ + this.send(new ClientboundPlayerChatPacket(this.nextChatIndex++, playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a)); + MessageSignature messagesignature = playerchatmessage.signature(); + +@@ -1808,6 +2503,7 @@ @Override public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.serverLevel()); @@ -1155,7 +1162,7 @@ if (this.player.hasClientLoaded()) { final WorldServer worldserver = this.player.serverLevel(); final Entity entity = packetplayinuseentity.getTarget(worldserver); -@@ -1733,13 +2429,51 @@ +@@ -1823,13 +2519,51 @@ if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) { packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() { @@ -1168,22 +1175,22 @@ + // CraftBukkit start + ItemStack itemInHand = PlayerConnection.this.player.getItemInHand(enumhand); + boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient; -+ Item origItem = player.getInventory().getSelected() == null ? null : player.getInventory().getSelected().getItem(); ++ Item origItem = player.getInventory().getSelectedItem() == null ? null : player.getInventory().getSelectedItem().getItem(); + + cserver.getPluginManager().callEvent(event); + + // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a -+ if ((entity instanceof Bucketable && entity instanceof EntityLiving && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) { ++ if ((entity instanceof Bucketable && entity instanceof EntityLiving && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || player.getInventory().getSelectedItem() == null || player.getInventory().getSelectedItem().getItem() != origItem)) { + entity.getBukkitEntity().update(player); + player.containerMenu.sendAllDataToRemote(); + } + -+ if (triggerLeashUpdate && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) { ++ if (triggerLeashUpdate && (event.isCancelled() || player.getInventory().getSelectedItem() == null || player.getInventory().getSelectedItem().getItem() != origItem)) { + // Refresh the current leash state + send(new PacketPlayOutAttachEntity(entity, ((EntityInsentient) entity).getLeashHolder())); + } + -+ if (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem) { ++ if (event.isCancelled() || player.getInventory().getSelectedItem() == null || player.getInventory().getSelectedItem().getItem() != origItem) { + // Refresh the current entity metadata + entity.refreshEntityData(player); + // SPIGOT-7136 - Allays @@ -1208,7 +1215,7 @@ if (enuminteractionresult instanceof EnumInteractionResult.d) { EnumInteractionResult.d enuminteractionresult_d = (EnumInteractionResult.d) enuminteractionresult; ItemStack itemstack2 = enuminteractionresult_d.wasItemInteraction() ? itemstack1 : ItemStack.EMPTY; -@@ -1755,19 +2489,20 @@ +@@ -1845,19 +2579,20 @@ @Override public void onInteraction(EnumHand enumhand) { @@ -1232,7 +1239,7 @@ label23: { if (entity instanceof EntityArrow) { -@@ -1785,6 +2520,11 @@ +@@ -1875,6 +2610,11 @@ } PlayerConnection.this.player.attack(entity); @@ -1244,7 +1251,7 @@ return; } } -@@ -1809,7 +2549,7 @@ +@@ -1899,7 +2639,7 @@ case PERFORM_RESPAWN: if (this.player.wonGame) { this.player.wonGame = false; @@ -1253,7 +1260,7 @@ this.resetPosition(); CriterionTriggers.CHANGED_DIMENSION.trigger(this.player, World.END, World.OVERWORLD); } else { -@@ -1817,11 +2557,11 @@ +@@ -1907,11 +2647,11 @@ return; } @@ -1267,7 +1274,7 @@ } } break; -@@ -1834,15 +2574,21 @@ +@@ -1924,15 +2664,21 @@ @Override public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.serverLevel()); @@ -1283,26 +1290,26 @@ PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinwindowclick, this, this.player.serverLevel()); + if (this.player.isImmobile()) return; // CraftBukkit this.player.resetLastActionTime(); -- if (this.player.containerMenu.containerId == packetplayinwindowclick.getContainerId()) { +- if (this.player.containerMenu.containerId == packetplayinwindowclick.containerId()) { - if (this.player.isSpectator()) { -+ if (this.player.containerMenu.containerId == packetplayinwindowclick.getContainerId() && this.player.containerMenu.stillValid(this.player)) { // CraftBukkit ++ if (this.player.containerMenu.containerId == packetplayinwindowclick.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)) { PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); -@@ -1855,7 +2601,284 @@ - boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId(); +@@ -1945,7 +2691,284 @@ + boolean flag = packetplayinwindowclick.stateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); -- this.player.containerMenu.clicked(i, packetplayinwindowclick.getButtonNum(), packetplayinwindowclick.getClickType(), this.player); +- this.player.containerMenu.clicked(i, packetplayinwindowclick.buttonNum(), packetplayinwindowclick.clickType(), this.player); + // CraftBukkit start - Call InventoryClickEvent -+ if (packetplayinwindowclick.getSlotNum() < -1 && packetplayinwindowclick.getSlotNum() != -999) { ++ if (packetplayinwindowclick.slotNum() < -1 && packetplayinwindowclick.slotNum() != -999) { + return; + } + + InventoryView inventory = this.player.containerMenu.getBukkitView(); -+ SlotType type = inventory.getSlotType(packetplayinwindowclick.getSlotNum()); ++ SlotType type = inventory.getSlotType(packetplayinwindowclick.slotNum()); + + InventoryClickEvent event; + ClickType click = ClickType.UNKNOWN; @@ -1310,36 +1317,36 @@ + + ItemStack itemstack = ItemStack.EMPTY; + -+ switch (packetplayinwindowclick.getClickType()) { ++ switch (packetplayinwindowclick.clickType()) { + case PICKUP: -+ if (packetplayinwindowclick.getButtonNum() == 0) { ++ if (packetplayinwindowclick.buttonNum()== 0) { + click = ClickType.LEFT; -+ } else if (packetplayinwindowclick.getButtonNum() == 1) { ++ } else if (packetplayinwindowclick.buttonNum() == 1) { + click = ClickType.RIGHT; + } -+ if (packetplayinwindowclick.getButtonNum() == 0 || packetplayinwindowclick.getButtonNum() == 1) { ++ if (packetplayinwindowclick.buttonNum() == 0 || packetplayinwindowclick.buttonNum() == 1) { + action = InventoryAction.NOTHING; // Don't want to repeat ourselves -+ if (packetplayinwindowclick.getSlotNum() == -999) { ++ if (packetplayinwindowclick.slotNum() == -999) { + if (!player.containerMenu.getCarried().isEmpty()) { -+ action = packetplayinwindowclick.getButtonNum() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR; ++ action = packetplayinwindowclick.buttonNum() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR; + } -+ } else if (packetplayinwindowclick.getSlotNum() < 0) { ++ } else if (packetplayinwindowclick.slotNum() < 0) { + action = InventoryAction.NOTHING; + } else { -+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); ++ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.slotNum()); + if (slot != null) { + ItemStack clickedItem = slot.getItem(); + ItemStack cursor = player.containerMenu.getCarried(); + if (clickedItem.isEmpty()) { + if (!cursor.isEmpty()) { -+ action = packetplayinwindowclick.getButtonNum() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE; ++ action = packetplayinwindowclick.buttonNum() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE; + } + } else if (slot.mayPickup(player)) { + if (cursor.isEmpty()) { -+ action = packetplayinwindowclick.getButtonNum() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF; ++ action = packetplayinwindowclick.buttonNum() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF; + } else if (slot.mayPlace(cursor)) { + if (ItemStack.isSameItemSameComponents(clickedItem, cursor)) { -+ int toPlace = packetplayinwindowclick.getButtonNum() == 0 ? cursor.getCount() : 1; ++ int toPlace = packetplayinwindowclick.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) { @@ -1369,16 +1376,16 @@ + break; + // TODO check on updates + case QUICK_MOVE: -+ if (packetplayinwindowclick.getButtonNum() == 0) { ++ if (packetplayinwindowclick.buttonNum() == 0) { + click = ClickType.SHIFT_LEFT; -+ } else if (packetplayinwindowclick.getButtonNum() == 1) { ++ } else if (packetplayinwindowclick.buttonNum() == 1) { + click = ClickType.SHIFT_RIGHT; + } -+ if (packetplayinwindowclick.getButtonNum() == 0 || packetplayinwindowclick.getButtonNum() == 1) { -+ if (packetplayinwindowclick.getSlotNum() < 0) { ++ if (packetplayinwindowclick.buttonNum() == 0 || packetplayinwindowclick.buttonNum() == 1) { ++ if (packetplayinwindowclick.slotNum() < 0) { + action = InventoryAction.NOTHING; + } else { -+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); ++ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.slotNum()); + if (slot != null && slot.mayPickup(this.player) && slot.hasItem()) { + action = InventoryAction.MOVE_TO_OTHER_INVENTORY; + } else { @@ -1388,11 +1395,11 @@ + } + break; + case SWAP: -+ if ((packetplayinwindowclick.getButtonNum() >= 0 && packetplayinwindowclick.getButtonNum() < 9) || packetplayinwindowclick.getButtonNum() == 40) { -+ click = (packetplayinwindowclick.getButtonNum() == 40) ? ClickType.SWAP_OFFHAND : ClickType.NUMBER_KEY; -+ Slot clickedSlot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); ++ if ((packetplayinwindowclick.buttonNum() >= 0 && packetplayinwindowclick.buttonNum() < 9) || packetplayinwindowclick.buttonNum() == 40) { ++ click = (packetplayinwindowclick.buttonNum() == 40) ? ClickType.SWAP_OFFHAND : ClickType.NUMBER_KEY; ++ Slot clickedSlot = this.player.containerMenu.getSlot(packetplayinwindowclick.slotNum()); + if (clickedSlot.mayPickup(player)) { -+ ItemStack hotbar = this.player.getInventory().getItem(packetplayinwindowclick.getButtonNum()); ++ ItemStack hotbar = this.player.getInventory().getItem(packetplayinwindowclick.buttonNum()); + boolean canCleanSwap = hotbar.isEmpty() || (clickedSlot.container == player.getInventory() && clickedSlot.mayPlace(hotbar)); // the slot will accept the hotbar item + if (clickedSlot.hasItem()) { + if (canCleanSwap) { @@ -1411,12 +1418,12 @@ + } + break; + case CLONE: -+ if (packetplayinwindowclick.getButtonNum() == 2) { ++ if (packetplayinwindowclick.buttonNum() == 2) { + click = ClickType.MIDDLE; -+ if (packetplayinwindowclick.getSlotNum() < 0) { ++ if (packetplayinwindowclick.slotNum() < 0) { + action = InventoryAction.NOTHING; + } else { -+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); ++ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.slotNum()); + if (slot != null && slot.hasItem() && player.getAbilities().instabuild && player.containerMenu.getCarried().isEmpty()) { + action = InventoryAction.CLONE_STACK; + } else { @@ -1429,18 +1436,18 @@ + } + break; + case THROW: -+ if (packetplayinwindowclick.getSlotNum() >= 0) { -+ if (packetplayinwindowclick.getButtonNum() == 0) { ++ if (packetplayinwindowclick.slotNum() >= 0) { ++ if (packetplayinwindowclick.buttonNum() == 0) { + click = ClickType.DROP; -+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); ++ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.slotNum()); + if (slot != null && slot.hasItem() && slot.mayPickup(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.byBlock(Blocks.AIR)) { + action = InventoryAction.DROP_ONE_SLOT; + } else { + action = InventoryAction.NOTHING; + } -+ } else if (packetplayinwindowclick.getButtonNum() == 1) { ++ } else if (packetplayinwindowclick.buttonNum() == 1) { + click = ClickType.CONTROL_DROP; -+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); ++ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.slotNum()); + if (slot != null && slot.hasItem() && slot.mayPickup(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.byBlock(Blocks.AIR)) { + action = InventoryAction.DROP_ALL_SLOT; + } else { @@ -1450,19 +1457,19 @@ + } else { + // Sane default (because this happens when they are holding nothing. Don't ask why.) + click = ClickType.LEFT; -+ if (packetplayinwindowclick.getButtonNum() == 1) { ++ if (packetplayinwindowclick.buttonNum() == 1) { + click = ClickType.RIGHT; + } + action = InventoryAction.NOTHING; + } + break; + case QUICK_CRAFT: -+ this.player.containerMenu.clicked(packetplayinwindowclick.getSlotNum(), packetplayinwindowclick.getButtonNum(), packetplayinwindowclick.getClickType(), this.player); ++ this.player.containerMenu.clicked(packetplayinwindowclick.slotNum(), packetplayinwindowclick.buttonNum(), packetplayinwindowclick.clickType(), this.player); + break; + case PICKUP_ALL: + click = ClickType.DOUBLE_CLICK; + action = InventoryAction.NOTHING; -+ if (packetplayinwindowclick.getSlotNum() >= 0 && !this.player.containerMenu.getCarried().isEmpty()) { ++ if (packetplayinwindowclick.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 @@ -1475,32 +1482,32 @@ + break; + } + -+ if (packetplayinwindowclick.getClickType() != InventoryClickType.QUICK_CRAFT) { ++ if (packetplayinwindowclick.clickType() != InventoryClickType.QUICK_CRAFT) { + if (click == ClickType.NUMBER_KEY) { -+ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action, packetplayinwindowclick.getButtonNum()); ++ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.slotNum(), click, action, packetplayinwindowclick.buttonNum()); + } else { -+ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action); ++ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.slotNum(), click, action); + } + + org.bukkit.inventory.Inventory top = inventory.getTopInventory(); -+ if (packetplayinwindowclick.getSlotNum() == 0 && top instanceof CraftingInventory) { ++ if (packetplayinwindowclick.slotNum() == 0 && top instanceof CraftingInventory) { + org.bukkit.inventory.Recipe recipe = ((CraftingInventory) top).getRecipe(); + if (recipe != null) { + if (click == ClickType.NUMBER_KEY) { -+ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.getSlotNum(), click, action, packetplayinwindowclick.getButtonNum()); ++ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.slotNum(), click, action, packetplayinwindowclick.buttonNum()); + } else { -+ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.getSlotNum(), click, action); ++ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.slotNum(), click, action); + } + } + } + -+ if (packetplayinwindowclick.getSlotNum() == 3 && top instanceof SmithingInventory) { ++ if (packetplayinwindowclick.slotNum() == 3 && top instanceof SmithingInventory) { + org.bukkit.inventory.ItemStack result = ((SmithingInventory) top).getResult(); + if (result != null) { + if (click == ClickType.NUMBER_KEY) { -+ event = new SmithItemEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action, packetplayinwindowclick.getButtonNum()); ++ event = new SmithItemEvent(inventory, type, packetplayinwindowclick.slotNum(), click, action, packetplayinwindowclick.buttonNum()); + } else { -+ event = new SmithItemEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action); ++ event = new SmithItemEvent(inventory, type, packetplayinwindowclick.slotNum(), click, action); + } + } + } @@ -1515,7 +1522,7 @@ + switch (event.getResult()) { + case ALLOW: + case DEFAULT: -+ this.player.containerMenu.clicked(i, packetplayinwindowclick.getButtonNum(), packetplayinwindowclick.getClickType(), this.player); ++ this.player.containerMenu.clicked(i, packetplayinwindowclick.buttonNum(), packetplayinwindowclick.clickType(), this.player); + break; + case DENY: + /* Needs enum constructor in InventoryAction @@ -1548,12 +1555,12 @@ + case PLACE_ONE: + case SWAP_WITH_CURSOR: + this.player.connection.send(new PacketPlayOutSetSlot(-1, -1, this.player.inventoryMenu.incrementStateId(), this.player.containerMenu.getCarried())); -+ this.player.connection.send(new PacketPlayOutSetSlot(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), packetplayinwindowclick.getSlotNum(), this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()).getItem())); ++ this.player.connection.send(new PacketPlayOutSetSlot(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), packetplayinwindowclick.slotNum(), this.player.containerMenu.getSlot(packetplayinwindowclick.slotNum()).getItem())); + break; + // Modified clicked only + case DROP_ALL_SLOT: + case DROP_ONE_SLOT: -+ this.player.connection.send(new PacketPlayOutSetSlot(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), packetplayinwindowclick.getSlotNum(), this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()).getItem())); ++ this.player.connection.send(new PacketPlayOutSetSlot(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), packetplayinwindowclick.slotNum(), this.player.containerMenu.getSlot(packetplayinwindowclick.slotNum()).getItem())); + break; + // Modified cursor only + case DROP_ALL_CURSOR: @@ -1574,10 +1581,10 @@ + } + } + // CraftBukkit end - ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator(); + ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.changedSlots()).iterator(); while (objectiterator.hasNext()) { -@@ -1901,7 +2924,21 @@ +@@ -1991,7 +3014,21 @@ return; } @@ -1600,7 +1607,7 @@ if (containerrecipebook_a == ContainerRecipeBook.a.PLACE_GHOST_RECIPE) { this.player.connection.send(new PacketPlayOutAutoRecipe(this.player.containerMenu.containerId, craftingmanager_d.display().display())); -@@ -1917,6 +2954,7 @@ +@@ -2007,6 +3044,7 @@ @Override public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.serverLevel()); @@ -1608,7 +1615,7 @@ this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packetplayinenchantitem.containerId() && !this.player.isSpectator()) { if (!this.player.containerMenu.stillValid(this.player)) { -@@ -1945,6 +2983,42 @@ +@@ -2035,6 +3073,42 @@ boolean flag1 = packetplayinsetcreativeslot.slotNum() >= 1 && packetplayinsetcreativeslot.slotNum() <= 45; boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize(); @@ -1651,7 +1658,7 @@ if (flag1 && flag2) { this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.slotNum()).setByPlayer(itemstack); -@@ -1972,6 +3046,7 @@ +@@ -2062,6 +3136,7 @@ } private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List list) { @@ -1659,7 +1666,7 @@ this.player.resetLastActionTime(); WorldServer worldserver = this.player.serverLevel(); BlockPosition blockposition = packetplayinupdatesign.getPos(); -@@ -1993,7 +3068,17 @@ +@@ -2083,7 +3158,17 @@ @Override public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.serverLevel()); @@ -1678,7 +1685,7 @@ } @Override -@@ -2058,7 +3143,7 @@ +@@ -2148,7 +3233,7 @@ if (!this.waitingForSwitchToConfig) { throw new IllegalStateException("Client acknowledged config, but none was requested"); } else { @@ -1687,7 +1694,7 @@ } } -@@ -2083,8 +3168,10 @@ +@@ -2173,8 +3258,10 @@ }); } diff --git a/nms-patches/net/minecraft/server/network/ServerConnection.patch b/nms-patches/net/minecraft/server/network/ServerConnection.patch index 3c67718d6..91fac6e2a 100644 --- a/nms-patches/net/minecraft/server/network/ServerConnection.patch +++ b/nms-patches/net/minecraft/server/network/ServerConnection.patch @@ -1,15 +1,8 @@ --- a/net/minecraft/server/network/ServerConnection.java +++ b/net/minecraft/server/network/ServerConnection.java -@@ -100,15 +100,25 @@ - - NetworkManager.configureSerialization(channelpipeline, EnumProtocolDirection.SERVERBOUND, false, (BandwidthDebugMonitor) null); - int j = ServerConnection.this.server.getRateLimitPacketsPerSecond(); -- Object object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND); -+ NetworkManager object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND); // CraftBukkit - decompile error - - ServerConnection.this.connections.add(object); - ((NetworkManager) object).configurePacketHandler(channelpipeline); - ((NetworkManager) object).setListenerForServerboundHandshake(new HandshakeListener(ServerConnection.this.server, (NetworkManager) object)); +@@ -103,9 +103,19 @@ + networkmanager.configurePacketHandler(channelpipeline); + networkmanager.setListenerForServerboundHandshake(new HandshakeListener(ServerConnection.this.server, networkmanager)); } - }).group(eventloopgroup).localAddress(inetaddress, i)).bind().syncUninterruptibly()); + }).group(eventloopgroup).localAddress(inetaddress, i)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit @@ -27,4 +20,4 @@ + // CraftBukkit end public SocketAddress startMemoryChannel() { - List list = this.channels; + ChannelFuture channelfuture; diff --git a/nms-patches/net/minecraft/server/players/JsonList.patch b/nms-patches/net/minecraft/server/players/JsonList.patch index 411461f15..d28863878 100644 --- a/nms-patches/net/minecraft/server/players/JsonList.patch +++ b/nms-patches/net/minecraft/server/players/JsonList.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/players/JsonList.java +++ b/net/minecraft/server/players/JsonList.java -@@ -54,7 +54,7 @@ - @Nullable - public V get(K k0) { - this.removeExpired(); -- return (JsonListEntry) this.map.get(this.getKeyForUser(k0)); -+ return (V) this.map.get(this.getKeyForUser(k0)); // CraftBukkit - fix decompile error +@@ -40,7 +40,7 @@ } - public void remove(K k0) { -@@ -85,6 +85,7 @@ + public void add(V v0) { +- this.map.put(this.getKeyForUser(((JsonListEntry) v0).getUser()), v0); ++ this.map.put(this.getKeyForUser((v0).getUser()), v0); // CraftBukkit - decompile error + + try { + this.save(); +@@ -84,6 +84,7 @@ } protected boolean contains(K k0) { @@ -17,25 +17,16 @@ return this.map.containsKey(this.getKeyForUser(k0)); } -@@ -93,7 +94,7 @@ - Iterator iterator = this.map.values().iterator(); - - while (iterator.hasNext()) { -- V v0 = (JsonListEntry) iterator.next(); -+ V v0 = (V) iterator.next(); // CraftBukkit - decompile error +@@ -92,7 +93,7 @@ + for (V v0 : this.map.values()) { if (v0.hasExpired()) { - list.add(v0.getUser()); -@@ -103,7 +104,7 @@ - iterator = list.iterator(); - - while (iterator.hasNext()) { -- K k0 = iterator.next(); -+ K k0 = (K) iterator.next(); // CraftBukkit - decompile error - - this.map.remove(this.getKeyForUser(k0)); +- list.add(((JsonListEntry) v0).getUser()); ++ list.add((v0).getUser()); // CraftBukkit - decompile error + } } -@@ -118,7 +119,7 @@ + +@@ -110,7 +111,7 @@ public void save() throws IOException { JsonArray jsonarray = new JsonArray(); @@ -44,12 +35,12 @@ JsonObject jsonobject = new JsonObject(); Objects.requireNonNull(jsonlistentry); -@@ -171,7 +172,7 @@ - JsonListEntry jsonlistentry = this.createEntry(jsonobject); +@@ -141,7 +142,7 @@ + JsonListEntry jsonlistentry = this.createEntry(jsonobject); - if (jsonlistentry.getUser() != null) { -- this.map.put(this.getKeyForUser(jsonlistentry.getUser()), jsonlistentry); -+ this.map.put(this.getKeyForUser(jsonlistentry.getUser()), (V) jsonlistentry); // CraftBukkit - decompile error - } + if (jsonlistentry.getUser() != null) { +- this.map.put(this.getKeyForUser(jsonlistentry.getUser()), jsonlistentry); ++ this.map.put(this.getKeyForUser(jsonlistentry.getUser()), (V) jsonlistentry); // CraftBukkit - decompile error } - } catch (Throwable throwable) { + } + } diff --git a/nms-patches/net/minecraft/server/players/NameReferencingFileConverter.patch b/nms-patches/net/minecraft/server/players/NameReferencingFileConverter.patch index 57e1d5a7c..f316dd764 100644 --- a/nms-patches/net/minecraft/server/players/NameReferencingFileConverter.patch +++ b/nms-patches/net/minecraft/server/players/NameReferencingFileConverter.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/NameReferencingFileConverter.java +++ b/net/minecraft/server/players/NameReferencingFileConverter.java -@@ -27,6 +27,12 @@ +@@ -26,6 +26,12 @@ import net.minecraft.world.level.storage.SavedFile; import org.slf4j.Logger; @@ -13,7 +13,7 @@ public class NameReferencingFileConverter { static final Logger LOGGER = LogUtils.getLogger(); -@@ -85,7 +91,7 @@ +@@ -76,7 +82,7 @@ try { gameprofilebanlist.load(); } catch (IOException ioexception) { @@ -22,7 +22,7 @@ } } -@@ -143,7 +149,7 @@ +@@ -134,7 +140,7 @@ try { ipbanlist.load(); } catch (IOException ioexception) { @@ -31,7 +31,7 @@ } } -@@ -184,7 +190,7 @@ +@@ -173,7 +179,7 @@ try { oplist.load(); } catch (IOException ioexception) { @@ -40,7 +40,7 @@ } } -@@ -228,7 +234,7 @@ +@@ -217,7 +223,7 @@ try { whitelist.load(); } catch (IOException ioexception) { @@ -49,7 +49,7 @@ } } -@@ -347,6 +353,30 @@ +@@ -333,6 +339,30 @@ File file5 = new File(file, s2 + ".dat"); File file6 = new File(file4, s3 + ".dat"); @@ -66,7 +66,7 @@ + if (!root.contains("bukkit")) { + root.put("bukkit", new NBTTagCompound()); + } -+ NBTTagCompound data = root.getCompound("bukkit"); ++ NBTTagCompound data = root.getCompoundOrEmpty("bukkit"); + data.putString("lastKnownName", s2); + + try { diff --git a/nms-patches/net/minecraft/server/players/PlayerList.patch b/nms-patches/net/minecraft/server/players/PlayerList.patch index f7122713b..0ec158966 100644 --- a/nms-patches/net/minecraft/server/players/PlayerList.patch +++ b/nms-patches/net/minecraft/server/players/PlayerList.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -104,6 +104,27 @@ - import net.minecraft.world.scores.ScoreboardTeam; +@@ -103,6 +103,27 @@ + import net.minecraft.world.scores.ScoreboardTeamBase; import org.slf4j.Logger; +// CraftBukkit start @@ -28,7 +28,7 @@ public abstract class PlayerList { public static final File USERBANLIST_FILE = new File("banned-players.json"); -@@ -116,14 +137,16 @@ +@@ -115,14 +136,16 @@ private static final int SEND_PLAYER_INFO_INTERVAL = 600; private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); private final MinecraftServer server; @@ -48,7 +48,7 @@ public final WorldNBTStorage playerIo; private boolean doWhiteList; private final LayeredRegistryAccess registries; -@@ -134,13 +157,23 @@ +@@ -133,13 +156,23 @@ private static final boolean ALLOW_LOGOUTIVATOR = false; private int sendAllPlayerInfoIn; @@ -74,35 +74,20 @@ this.server = minecraftserver; this.registries = layeredregistryaccess; this.maxPlayers = i; -@@ -150,25 +183,34 @@ - public void placeNewPlayer(NetworkManager networkmanager, EntityPlayer entityplayer, CommonListenerCookie commonlistenercookie) { - GameProfile gameprofile = entityplayer.getGameProfile(); - UserCache usercache = this.server.getProfileCache(); -- Optional optional; -+ // Optional optional; // CraftBukkit - decompile error - String s; - - if (usercache != null) { -- optional = usercache.get(gameprofile.getId()); -+ Optional optional = usercache.get(gameprofile.getId()); // CraftBukkit - decompile error - s = (String) optional.map(GameProfile::getName).orElse(gameprofile.getName()); - usercache.add(gameprofile); - } else { - s = gameprofile.getName(); +@@ -161,13 +194,22 @@ } -- optional = this.load(entityplayer); -+ Optional optional = this.load(entityplayer); // CraftBukkit - decompile error + Optional optional1 = this.load(entityplayer); + // CraftBukkit start - Better rename detection -+ if (optional.isPresent()) { -+ NBTTagCompound nbttagcompound = optional.get(); ++ if (optional1.isPresent()) { ++ NBTTagCompound nbttagcompound = optional1.get(); + if (nbttagcompound.contains("bukkit")) { -+ NBTTagCompound bukkit = nbttagcompound.getCompound("bukkit"); -+ s = bukkit.contains("lastKnownName", 8) ? bukkit.getString("lastKnownName") : s; ++ NBTTagCompound bukkit = nbttagcompound.getCompoundOrEmpty("bukkit"); ++ s = bukkit.getStringOr("lastKnownName", s); + } + } + // CraftBukkit end - ResourceKey resourcekey = (ResourceKey) optional.flatMap((nbttagcompound) -> { + ResourceKey resourcekey = (ResourceKey) optional1.flatMap((nbttagcompound) -> { - DataResult dataresult = DimensionManager.parseLegacy(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("Dimension"))); + DataResult> dataresult = DimensionManager.parseLegacy(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("Dimension"))); // CraftBukkit - decompile error Logger logger = PlayerList.LOGGER; @@ -114,7 +99,7 @@ WorldServer worldserver = this.server.getLevel(resourcekey); WorldServer worldserver1; -@@ -182,10 +224,11 @@ +@@ -181,10 +223,11 @@ entityplayer.setServerLevel(worldserver1); String s1 = networkmanager.getLoggableAddress(this.server.logIPs()); @@ -123,20 +108,20 @@ + // PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", new Object[]{entityplayer.getName().getString(), s1, entityplayer.getId(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ()}); WorldData worlddata = worldserver1.getLevelData(); -- entityplayer.loadGameTypes((NBTTagCompound) optional.orElse((Object) null)); -+ entityplayer.loadGameTypes((NBTTagCompound) optional.orElse(null)); // CraftBukkit - decompile error +- entityplayer.loadGameTypes((NBTTagCompound) optional1.orElse((Object) null)); ++ entityplayer.loadGameTypes((NBTTagCompound) optional1.orElse(null)); // CraftBukkit - decompile error PlayerConnection playerconnection = new PlayerConnection(this.server, networkmanager, entityplayer, commonlistenercookie); - networkmanager.setupInboundProtocol(GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess())), playerconnection); -@@ -195,6 +238,7 @@ + networkmanager.setupInboundProtocol(GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess()), playerconnection), playerconnection); +@@ -194,6 +237,7 @@ boolean flag2 = gamerules.getBoolean(GameRules.RULE_LIMITED_CRAFTING); playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), this.server.levelKeys(), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, flag2, entityplayer.createCommonSpawnInfo(worldserver1), this.server.enforceSecureProfile())); + entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit playerconnection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); playerconnection.send(new PacketPlayOutAbilities(entityplayer.getAbilities())); - playerconnection.send(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().selected)); -@@ -213,8 +257,10 @@ + playerconnection.send(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().getSelectedSlot())); +@@ -212,8 +256,10 @@ } else { ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.player.joined.renamed", entityplayer.getDisplayName(), s); } @@ -148,7 +133,7 @@ playerconnection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot()); ServerPing serverping = this.server.getStatus(); -@@ -222,17 +268,70 @@ +@@ -221,19 +267,72 @@ entityplayer.sendServerStatus(serverping); } @@ -215,15 +200,17 @@ + worldserver1 = entityplayer.serverLevel(); // CraftBukkit - Update in case join event changed it + // CraftBukkit end this.sendActivePlayerEffects(entityplayer); - entityplayer.loadAndSpawnEnderpearls(optional); - entityplayer.loadAndSpawnParentVehicle(optional); + optional1.ifPresent((nbttagcompound) -> { + entityplayer.loadAndSpawnEnderPearls(nbttagcompound); + entityplayer.loadAndSpawnParentVehicle(nbttagcompound); + }); entityplayer.initInventoryMenu(); + // CraftBukkit - Moved from above, added world + PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getName().getString(), s1, entityplayer.getId(), worldserver1.serverLevelData.getLevelName(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ()); } public void updateEntireScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { -@@ -269,30 +368,31 @@ +@@ -258,30 +357,31 @@ } public void addWorldborderListener(WorldServer worldserver) { @@ -260,7 +247,7 @@ } @Override -@@ -319,14 +419,15 @@ +@@ -308,14 +408,15 @@ } protected void save(EntityPlayer entityplayer) { @@ -278,7 +265,7 @@ if (advancementdataplayer != null) { advancementdataplayer.save(); -@@ -334,10 +435,24 @@ +@@ -323,10 +424,24 @@ } @@ -304,7 +291,7 @@ this.save(entityplayer); if (entityplayer.isPassenger()) { Entity entity = entityplayer.getRootVehicle(); -@@ -346,7 +461,7 @@ +@@ -335,7 +450,7 @@ PlayerList.LOGGER.debug("Removing player mount"); entityplayer.stopRiding(); entity.getPassengersAndSelf().forEach((entity1) -> { @@ -313,16 +300,16 @@ }); } } -@@ -357,7 +472,7 @@ - while (iterator.hasNext()) { - EntityEnderPearl entityenderpearl = (EntityEnderPearl) iterator.next(); +@@ -343,7 +458,7 @@ + entityplayer.unRide(); + for (EntityEnderPearl entityenderpearl : entityplayer.getEnderPearls()) { - entityenderpearl.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER); + entityenderpearl.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER, EntityRemoveEvent.Cause.PLAYER_QUIT); // CraftBukkit - add Bukkit remove cause } worldserver.removePlayerImmediately(entityplayer, Entity.RemovalReason.UNLOADED_WITH_PLAYER); -@@ -369,17 +484,66 @@ +@@ -355,15 +470,58 @@ if (entityplayer1 == entityplayer) { this.playersByUUID.remove(uuid); @@ -358,27 +345,19 @@ - public IChatBaseComponent canPlayerLogin(SocketAddress socketaddress, GameProfile gameprofile) { + // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer + public EntityPlayer canPlayerLogin(LoginListener loginlistener, GameProfile gameprofile) { - IChatMutableComponent ichatmutablecomponent; - + // Moved from processLogin + UUID uuid = gameprofile.getId(); -+ List list = Lists.newArrayList(); ++ Set set = Sets.newIdentityHashSet(); + -+ EntityPlayer entityplayer; -+ -+ for (int i = 0; i < this.players.size(); ++i) { -+ entityplayer = (EntityPlayer) this.players.get(i); ++ for (EntityPlayer entityplayer : this.players) { + if (entityplayer.getUUID().equals(uuid)) { -+ list.add(entityplayer); ++ set.add(entityplayer); + } + } + -+ Iterator iterator = list.iterator(); -+ -+ while (iterator.hasNext()) { -+ entityplayer = (EntityPlayer) iterator.next(); -+ save(entityplayer); // CraftBukkit - Force the player's inventory to be saved -+ entityplayer.connection.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.duplicate_login")); ++ for (EntityPlayer entityplayer2 : set) { ++ save(entityplayer2); // CraftBukkit - Force the player's inventory to be saved ++ entityplayer2.connection.disconnect(PlayerList.DUPLICATE_LOGIN_DISCONNECT_MESSAGE); + } + + // Instead of kicking then returning, we need to store the kick reason @@ -393,28 +372,28 @@ + if (this.bans.isBanned(gameprofile)) { GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile); - -@@ -388,9 +552,11 @@ + IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason()); +@@ -372,9 +530,11 @@ ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires()))); } - return ichatmutablecomponent; -+ // return chatmessage; ++ // return ichatmutablecomponent; + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(ichatmutablecomponent)); } else if (!this.isWhiteListed(gameprofile)) { - return IChatBaseComponent.translatable("multiplayer.disconnect.not_whitelisted"); -+ ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.not_whitelisted"); ++ IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.not_whitelisted"); + event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, CraftChatMessage.fromComponent(ichatmutablecomponent)); } else if (this.ipBans.isBanned(socketaddress)) { IpBanEntry ipbanentry = this.ipBans.get(socketaddress); - -@@ -399,17 +565,32 @@ - ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires()))); + IChatMutableComponent ichatmutablecomponent1 = IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.reason", ipbanentry.getReason()); +@@ -383,17 +543,32 @@ + ichatmutablecomponent1.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires()))); } -- return ichatmutablecomponent; -+ // return chatmessage; -+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(ichatmutablecomponent)); +- return ichatmutablecomponent1; ++ // return ichatmutablecomponent1; ++ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(ichatmutablecomponent1)); } else { - return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? IChatBaseComponent.translatable("multiplayer.disconnect.server_full") : null; + // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? IChatBaseComponent.translatable("multiplayer.disconnect.server_full") : null; @@ -445,8 +424,8 @@ + /* CraftBukkit startMoved up UUID uuid = gameprofile.getId(); Set set = Sets.newIdentityHashSet(); - Iterator iterator = this.players.iterator(); -@@ -437,22 +618,41 @@ + +@@ -414,32 +589,66 @@ } return !set.isEmpty(); @@ -487,9 +466,7 @@ + */ + // CraftBukkit end - Iterator iterator = entityplayer.getTags().iterator(); - -@@ -462,11 +662,26 @@ + for (String s : entityplayer.getTags()) { entityplayer1.addTag(s); } @@ -503,24 +480,24 @@ + teleporttransition = new TeleportTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), Vec3D.ZERO, location.getYaw(), location.getPitch(), TeleportTransition.DO_NOTHING); + } + WorldServer worldserver = teleporttransition.newLevel(); -+ entityplayer1.spawnIn(worldserver); ++ entityplayer1.spawnIn(worldserver, flag); + entityplayer1.unsetRemoved(); + entityplayer1.setShiftKeyDown(false); Vec3D vec3d = teleporttransition.position(); -- entityplayer1.moveTo(vec3d.x, vec3d.y, vec3d.z, teleporttransition.yRot(), teleporttransition.xRot()); +- entityplayer1.snapTo(vec3d.x, vec3d.y, vec3d.z, teleporttransition.yRot(), teleporttransition.xRot()); + entityplayer1.forceSetPositionRotation(vec3d.x, vec3d.y, vec3d.z, teleporttransition.yRot(), teleporttransition.xRot()); + // CraftBukkit end if (teleporttransition.missingRespawnBlock()) { entityplayer1.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); -+ entityplayer1.setRespawnPosition(null, null, 0f, false, false, PlayerSpawnChangeEvent.Cause.RESET); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed ++ entityplayer1.setRespawnPosition(null, false, PlayerSpawnChangeEvent.Cause.RESET); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed } - int i = flag ? 1 : 0; -@@ -474,17 +689,19 @@ + byte b0 = (byte) (flag ? 1 : 0); +@@ -447,17 +656,19 @@ WorldData worlddata = worldserver1.getLevelData(); - entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.createCommonSpawnInfo(worldserver1), (byte) i)); + entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.createCommonSpawnInfo(worldserver1), b0)); - entityplayer1.connection.teleport(entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot()); + entityplayer1.connection.teleport(CraftLocation.toBukkit(entityplayer1.position(), worldserver1.getWorld(), entityplayer1.getYRot(), entityplayer1.getXRot())); // CraftBukkit entityplayer1.connection.send(new PacketPlayOutSpawnPosition(worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle())); @@ -540,10 +517,10 @@ + } + // entityplayer1.initInventoryMenu(); entityplayer1.setHealth(entityplayer1.getHealth()); - BlockPosition blockposition = entityplayer1.getRespawnPosition(); - WorldServer worldserver2 = this.server.getLevel(entityplayer1.getRespawnDimension()); -@@ -496,6 +713,27 @@ - entityplayer1.connection.send(new PacketPlayOutNamedSoundEffect(SoundEffects.RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F, worldserver.getRandom().nextLong())); + EntityPlayer.RespawnConfig entityplayer_respawnconfig = entityplayer1.getRespawnConfig(); + +@@ -473,6 +684,27 @@ + } } } + // Added from changeDimension @@ -570,7 +547,7 @@ return entityplayer1; } -@@ -524,7 +762,18 @@ +@@ -497,7 +729,18 @@ public void tick() { if (++this.sendAllPlayerInfoIn > 600) { @@ -590,7 +567,7 @@ this.sendAllPlayerInfoIn = 0; } -@@ -541,6 +790,25 @@ +@@ -510,6 +753,25 @@ } @@ -614,18 +591,9 @@ + // CraftBukkit end + public void broadcastAll(Packet packet, ResourceKey resourcekey) { - Iterator iterator = this.players.iterator(); - -@@ -619,7 +887,7 @@ - } - - public void deop(GameProfile gameprofile) { -- this.ops.remove((Object) gameprofile); -+ this.ops.remove(gameprofile); // CraftBukkit - decompile error - EntityPlayer entityplayer = this.getPlayer(gameprofile.getId()); - - if (entityplayer != null) { -@@ -643,6 +911,7 @@ + for (EntityPlayer entityplayer : this.players) { + if (entityplayer.level().dimension() == resourcekey) { +@@ -604,6 +866,7 @@ entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0)); } @@ -633,7 +601,7 @@ this.server.getCommands().sendCommands(entityplayer); } -@@ -673,6 +942,12 @@ +@@ -634,6 +897,12 @@ for (int i = 0; i < this.players.size(); ++i) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(i); @@ -646,7 +614,7 @@ if (entityplayer != entityhuman && entityplayer.level().dimension() == resourcekey) { double d4 = d0 - entityplayer.getX(); double d5 = d1 - entityplayer.getY(); -@@ -712,15 +987,19 @@ +@@ -673,15 +942,19 @@ public void reloadWhiteList() {} public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) { @@ -670,7 +638,7 @@ } entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.LEVEL_CHUNKS_LOAD_START, 0.0F)); -@@ -729,8 +1008,16 @@ +@@ -690,8 +963,16 @@ public void sendAllPlayerInfo(EntityPlayer entityplayer) { entityplayer.inventoryMenu.sendAllDataToRemote(); @@ -678,7 +646,7 @@ + // entityplayer.resetSentInfo(); + entityplayer.getBukkitEntity().updateScaledHealth(); // CraftBukkit - Update scaled health on respawn and worldchange + entityplayer.refreshEntityData(entityplayer); // CraftBukkkit - SPIGOT-7218: sync metadata - entityplayer.connection.send(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().selected)); + entityplayer.connection.send(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().getSelectedSlot())); + // CraftBukkit start - from GameRules + int i = entityplayer.serverLevel().getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23; + entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, (byte) i)); @@ -688,7 +656,7 @@ } public int getPlayerCount() { -@@ -786,12 +1073,22 @@ +@@ -744,12 +1025,22 @@ } public void removeAll() { @@ -713,7 +681,7 @@ public void broadcastSystemMessage(IChatBaseComponent ichatbasecomponent, boolean flag) { this.broadcastSystemMessage(ichatbasecomponent, (entityplayer) -> { return ichatbasecomponent; -@@ -849,16 +1146,23 @@ +@@ -803,16 +1094,23 @@ return playerchatmessage.hasSignature() && !playerchatmessage.hasExpiredServer(Instant.now()); } @@ -741,7 +709,7 @@ Path path = file2.toPath(); if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) { -@@ -867,7 +1171,7 @@ +@@ -821,7 +1119,7 @@ } serverstatisticmanager = new ServerStatisticManager(this.server, file1); @@ -750,7 +718,7 @@ } return serverstatisticmanager; -@@ -875,13 +1179,13 @@ +@@ -829,13 +1127,13 @@ public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) { UUID uuid = entityplayer.getUUID(); @@ -766,23 +734,19 @@ } advancementdataplayer.setPlayer(entityplayer); -@@ -932,15 +1236,28 @@ +@@ -880,11 +1178,24 @@ } public void reloadResources() { -- Iterator iterator = this.advancements.values().iterator(); +- for (AdvancementDataPlayer advancementdataplayer : this.advancements.values()) { + // CraftBukkit start -+ /*Iterator iterator = this.advancements.values().iterator(); - - while (iterator.hasNext()) { - AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) iterator.next(); - ++ /*for (AdvancementDataPlayer advancementdataplayer : this.advancements.values()) { advancementdataplayer.reload(this.server.getAdvancements()); + }*/ + + for (EntityPlayer player : 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 @@ -795,4 +759,4 @@ + // CraftBukkit end CraftingManager craftingmanager = this.server.getRecipeManager(); PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(craftingmanager.getSynchronizedItemProperties(), craftingmanager.getSynchronizedStonecutterRecipes()); - Iterator iterator1 = this.players.iterator(); + diff --git a/nms-patches/net/minecraft/server/players/SleepStatus.patch b/nms-patches/net/minecraft/server/players/SleepStatus.patch index 3af51ebff..3d8bb4020 100644 --- a/nms-patches/net/minecraft/server/players/SleepStatus.patch +++ b/nms-patches/net/minecraft/server/players/SleepStatus.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/SleepStatus.java +++ b/net/minecraft/server/players/SleepStatus.java -@@ -18,9 +18,12 @@ +@@ -17,9 +17,12 @@ } public boolean areEnoughDeepSleeping(int i, List list) { @@ -15,15 +15,13 @@ } public int sleepersNeeded(int i) { -@@ -42,18 +45,24 @@ +@@ -40,16 +43,22 @@ + this.activePlayers = 0; this.sleepingPlayers = 0; - Iterator iterator = list.iterator(); + boolean anySleep = false; // CraftBukkit - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); - + for (EntityPlayer entityplayer : list) { if (!entityplayer.isSpectator()) { ++this.activePlayers; - if (entityplayer.isSleeping()) { diff --git a/nms-patches/net/minecraft/server/players/UserCache.patch b/nms-patches/net/minecraft/server/players/UserCache.patch index 3199cd6ea..c61e1a100 100644 --- a/nms-patches/net/minecraft/server/players/UserCache.patch +++ b/nms-patches/net/minecraft/server/players/UserCache.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/server/players/UserCache.java +++ b/net/minecraft/server/players/UserCache.java -@@ -85,7 +85,7 @@ - } - - public void onProfileLookupFailed(String s1, Exception exception) { -- atomicreference.set((Object) null); -+ atomicreference.set(null); // CraftBukkit - decompile error - } - }; - -@@ -142,7 +142,7 @@ +@@ -127,7 +127,7 @@ usercache_usercacheentry.setLastAccess(this.getNextOperation()); optional = Optional.of(usercache_usercacheentry.getProfile()); } else { @@ -18,21 +9,12 @@ if (optional.isPresent()) { this.add((GameProfile) optional.get()); flag = false; -@@ -208,7 +208,7 @@ +@@ -198,7 +198,7 @@ + DateFormat dateformat = createDateFormat(); - label54: - { -- ArrayList arraylist; -+ List arraylist; // CraftBukkit - decompile error + jsonarray.forEach((jsonelement) -> { +- Optional optional = readGameProfile(jsonelement, dateformat); ++ Optional optional = readGameProfile(jsonelement, dateformat); // CraftBukkit - decompile error - try { - JsonArray jsonarray = (JsonArray) this.gson.fromJson(bufferedreader, JsonArray.class); -@@ -217,7 +217,7 @@ - DateFormat dateformat = createDateFormat(); - - jsonarray.forEach((jsonelement) -> { -- Optional optional = readGameProfile(jsonelement, dateformat); -+ Optional optional = readGameProfile(jsonelement, dateformat); // CraftBukkit - decompile error - - Objects.requireNonNull(list); - optional.ifPresent(list::add); + Objects.requireNonNull(list); + optional.ifPresent(list::add); diff --git a/nms-patches/net/minecraft/server/rcon/thread/RemoteControlSession.patch b/nms-patches/net/minecraft/server/rcon/thread/RemoteControlSession.patch index 3feb32243..ae9d40036 100644 --- a/nms-patches/net/minecraft/server/rcon/thread/RemoteControlSession.patch +++ b/nms-patches/net/minecraft/server/rcon/thread/RemoteControlSession.patch @@ -28,7 +28,7 @@ this.client = socket; try { -@@ -38,11 +45,14 @@ +@@ -38,6 +45,7 @@ } this.rconPassword = s; @@ -36,16 +36,7 @@ } public void run() { -- while (true) { -- try { -+ // CraftBukkit start - decompile error: switch try / while statement -+ try { -+ while (true) { -+ // CraftBukkit end - if (!this.running) { - return; - } -@@ -71,7 +81,7 @@ +@@ -71,7 +79,7 @@ String s = StatusChallengeUtils.stringFromByteArray(this.buf, j, i); try { @@ -54,24 +45,3 @@ } catch (Exception exception) { this.sendCmdResponse(l, "Error executing: " + s + " (" + exception.getMessage() + ")"); } -@@ -98,6 +108,7 @@ - continue; - } - } -+ } // CraftBukkit - decompile error: switch try / while statement - } catch (IOException ioexception) { - return; - } catch (Exception exception1) { -@@ -109,8 +120,10 @@ - this.running = false; - } - -- return; -- } -+ // CraftBukkit start - decompile error: switch try / while statement -+ // return; -+ // } -+ // CraftBukkit end - } - - private void send(int i, int j, String s) throws IOException { diff --git a/nms-patches/net/minecraft/stats/RecipeBookServer.patch b/nms-patches/net/minecraft/stats/RecipeBookServer.patch index 38c18d212..a04365ccb 100644 --- a/nms-patches/net/minecraft/stats/RecipeBookServer.patch +++ b/nms-patches/net/minecraft/stats/RecipeBookServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/stats/RecipeBookServer.java +++ b/net/minecraft/stats/RecipeBookServer.java -@@ -29,6 +29,8 @@ +@@ -26,6 +26,8 @@ import net.minecraft.world.item.crafting.display.RecipeDisplayId; import org.slf4j.Logger; @@ -9,8 +9,8 @@ public class RecipeBookServer extends RecipeBook { public static final String RECIPE_BOOK_TAG = "recipeBook"; -@@ -72,7 +74,7 @@ - RecipeHolder recipeholder = (RecipeHolder) iterator.next(); +@@ -68,7 +70,7 @@ + for (RecipeHolder recipeholder : collection) { ResourceKey> resourcekey = recipeholder.id(); - if (!this.known.contains(resourcekey) && !recipeholder.value().isSpecial()) { @@ -18,7 +18,7 @@ this.add(resourcekey); this.addHighlight(resourcekey); this.displayResolver.displaysForRecipe(resourcekey, (recipedisplayentry) -> { -@@ -82,7 +84,7 @@ +@@ -78,7 +80,7 @@ } } @@ -27,7 +27,7 @@ entityplayer.connection.send(new ClientboundRecipeBookAddPacket(list, false)); } -@@ -105,7 +107,7 @@ +@@ -99,7 +101,7 @@ } } diff --git a/nms-patches/net/minecraft/stats/ServerStatisticManager.patch b/nms-patches/net/minecraft/stats/ServerStatisticManager.patch index ac3c4fffd..2288b29e1 100644 --- a/nms-patches/net/minecraft/stats/ServerStatisticManager.patch +++ b/nms-patches/net/minecraft/stats/ServerStatisticManager.patch @@ -4,23 +4,18 @@ +// mc-dev import package net.minecraft.stats; - import com.google.common.collect.Maps; -@@ -158,13 +159,12 @@ - } + import com.google.common.collect.Sets; +@@ -53,11 +54,11 @@ + private final File file; + private final Set> dirty = Sets.newHashSet(); - private Optional> getStat(StatisticWrapper statisticwrapper, String s) { -- Optional optional = Optional.ofNullable(MinecraftKey.tryParse(s)); -- IRegistry iregistry = statisticwrapper.getRegistry(); -+ // CraftBukkit - decompile error start -+ Optional optional = Optional.ofNullable(MinecraftKey.tryParse(s)); -+ IRegistry iregistry = statisticwrapper.getRegistry(); +- private static Codec, Integer>> createTypedStatsCodec(StatisticWrapper statisticwrapper) { ++ private static Codec, Integer>> createTypedStatsCodec(StatisticWrapper statisticwrapper) { // CraftBukkit - decompile error + Codec codec = statisticwrapper.getRegistry().byNameCodec(); -- Objects.requireNonNull(iregistry); -- optional = optional.flatMap(iregistry::getOptional); -- Objects.requireNonNull(statisticwrapper); -- return optional.map(statisticwrapper::get); -+ return optional.flatMap(iregistry::getOptional).map(statisticwrapper::get); -+ // CraftBukkit - decompile error end - } + Objects.requireNonNull(statisticwrapper); +- Codec> codec1 = codec.flatComapMap(statisticwrapper::get, (statistic) -> { ++ Codec> codec1 = codec.flatComapMap(statisticwrapper::get, (statistic) -> { // CraftBukkit - decompile error + return statistic.getType() == statisticwrapper ? DataResult.success(statistic.getValue()) : DataResult.error(() -> { + String s = String.valueOf(statisticwrapper); - private static NBTTagCompound fromJson(JsonObject jsonobject) { diff --git a/nms-patches/net/minecraft/util/SpawnUtil.patch b/nms-patches/net/minecraft/util/SpawnUtil.patch index 7e75aa0c2..c1fbef81d 100644 --- a/nms-patches/net/minecraft/util/SpawnUtil.patch +++ b/nms-patches/net/minecraft/util/SpawnUtil.patch @@ -17,7 +17,7 @@ blockposition_mutableblockposition.setWithOffset(blockposition, i1, k, j1); if (worldserver.getWorldBorder().isWithinBounds((BlockPosition) blockposition_mutableblockposition) && moveToPossibleSpawnPosition(worldserver, k, blockposition_mutableblockposition, spawnutil_a) && (!flag || worldserver.noCollision(entitytypes.getSpawnAABB((double) blockposition_mutableblockposition.getX() + 0.5D, (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + 0.5D)))) { -- T t0 = (EntityInsentient) entitytypes.create(worldserver, (Consumer) null, blockposition_mutableblockposition, entityspawnreason, false, false); +- T t0 = entitytypes.create(worldserver, (Consumer) null, blockposition_mutableblockposition, entityspawnreason, false, false); + T t0 = entitytypes.create(worldserver, (Consumer) null, blockposition_mutableblockposition, entityspawnreason, false, false); // CraftBukkit - decompile error if (t0 != null) { diff --git a/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch b/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch index f801d0557..1295c92b8 100644 --- a/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch +++ b/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/util/datafix/DataConverterRegistry.java +++ b/net/minecraft/util/datafix/DataConverterRegistry.java -@@ -517,6 +517,18 @@ +@@ -553,6 +553,20 @@ datafixerbuilder.addFixer(new DataConverterItemFrame(schema44, false)); - Schema schema45 = datafixerbuilder.addSchema(1458, DataConverterRegistry.SAME_NAMESPACED); + Schema schema45 = datafixerbuilder.addSchema(1458, V1458::new); + // CraftBukkit start + datafixerbuilder.addFixer(new com.mojang.datafixers.DataFix(schema45, false) { @@ -10,73 +10,84 @@ + protected com.mojang.datafixers.TypeRewriteRule makeRule() { + return this.fixTypeEverywhereTyped("Player CustomName", this.getInputSchema().getType(DataConverterTypes.PLAYER), (typed) -> { + return typed.update(DSL.remainderFinder(), (dynamic) -> { -+ return DataConverterCustomNameEntity.fixTagCustomName(dynamic); ++ String s = dynamic.get("CustomName").asString(""); ++ ++ return s.isEmpty() ? dynamic.remove("CustomName") : dynamic.set("CustomName", LegacyComponentDataFixUtils.createPlainTextComponent(dynamic.getOps(), s)); + }); + }); + } + }); + // CraftBukkit end - datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema45, false)); - datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema45, false)); - datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema45, false)); -@@ -775,7 +787,8 @@ - datafixerbuilder.addFixer(new DataConverterAddChoices(schema110, "Added Zoglin", DataConverterTypes.ENTITY)); - Schema schema111 = datafixerbuilder.addSchema(2523, DataConverterRegistry.SAME_NAMESPACED); + datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema45)); + datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema45)); + datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema45)); +@@ -617,7 +631,7 @@ + Type type = this.getInputSchema().getType(DataConverterTypes.ENTITY); + OpticFinder opticfinder = DSL.fieldFinder("id", DataConverterSchemaNamed.namespacedString()); + OpticFinder opticfinder1 = type.findField("CustomName"); +- OpticFinder> opticfinder2 = DSL.typeFinder(this.getInputSchema().getType(DataConverterTypes.TEXT_COMPONENT)); ++ OpticFinder> opticfinder2 = (OpticFinder>) DSL.typeFinder(this.getInputSchema().getType(DataConverterTypes.TEXT_COMPONENT)); // CraftBukkit - decompile error -- datafixerbuilder.addFixer(new DataConverterAttributes(schema111, "Attribute renames", createRenamerNoNamespace(ImmutableMap.builder().put("generic.maxHealth", "minecraft:generic.max_health").put("Max Health", "minecraft:generic.max_health").put("zombie.spawnReinforcements", "minecraft:zombie.spawn_reinforcements").put("Spawn Reinforcements Chance", "minecraft:zombie.spawn_reinforcements").put("horse.jumpStrength", "minecraft:horse.jump_strength").put("Jump Strength", "minecraft:horse.jump_strength").put("generic.followRange", "minecraft:generic.follow_range").put("Follow Range", "minecraft:generic.follow_range").put("generic.knockbackResistance", "minecraft:generic.knockback_resistance").put("Knockback Resistance", "minecraft:generic.knockback_resistance").put("generic.movementSpeed", "minecraft:generic.movement_speed").put("Movement Speed", "minecraft:generic.movement_speed").put("generic.flyingSpeed", "minecraft:generic.flying_speed").put("Flying Speed", "minecraft:generic.flying_speed").put("generic.attackDamage", "minecraft:generic.attack_damage").put("generic.attackKnockback", "minecraft:generic.attack_knockback").put("generic.attackSpeed", "minecraft:generic.attack_speed").put("generic.armorToughness", "minecraft:generic.armor_toughness").build()))); + return this.fixTypeEverywhereTyped("Command block minecart custom name fix", type, (typed) -> { + String s = (String) typed.getOptional(opticfinder).orElse(""); +@@ -826,7 +840,8 @@ + datafixerbuilder.addFixer(new DataConverterAddChoices(schema111, "Added Zoglin", DataConverterTypes.ENTITY)); + Schema schema112 = datafixerbuilder.addSchema(2523, DataConverterRegistry.SAME_NAMESPACED); + +- datafixerbuilder.addFixer(new DataConverterAttributes(schema112, "Attribute renames", createRenamerNoNamespace(ImmutableMap.builder().put("generic.maxHealth", "minecraft:generic.max_health").put("Max Health", "minecraft:generic.max_health").put("zombie.spawnReinforcements", "minecraft:zombie.spawn_reinforcements").put("Spawn Reinforcements Chance", "minecraft:zombie.spawn_reinforcements").put("horse.jumpStrength", "minecraft:horse.jump_strength").put("Jump Strength", "minecraft:horse.jump_strength").put("generic.followRange", "minecraft:generic.follow_range").put("Follow Range", "minecraft:generic.follow_range").put("generic.knockbackResistance", "minecraft:generic.knockback_resistance").put("Knockback Resistance", "minecraft:generic.knockback_resistance").put("generic.movementSpeed", "minecraft:generic.movement_speed").put("Movement Speed", "minecraft:generic.movement_speed").put("generic.flyingSpeed", "minecraft:generic.flying_speed").put("Flying Speed", "minecraft:generic.flying_speed").put("generic.attackDamage", "minecraft:generic.attack_damage").put("generic.attackKnockback", "minecraft:generic.attack_knockback").put("generic.attackSpeed", "minecraft:generic.attack_speed").put("generic.armorToughness", "minecraft:generic.armor_toughness").build()))); + // CraftBukkit - decompile error -+ datafixerbuilder.addFixer(new DataConverterAttributes(schema111, "Attribute renames", createRenamerNoNamespace(ImmutableMap.builder().put("generic.maxHealth", "minecraft:generic.max_health").put("Max Health", "minecraft:generic.max_health").put("zombie.spawnReinforcements", "minecraft:zombie.spawn_reinforcements").put("Spawn Reinforcements Chance", "minecraft:zombie.spawn_reinforcements").put("horse.jumpStrength", "minecraft:horse.jump_strength").put("Jump Strength", "minecraft:horse.jump_strength").put("generic.followRange", "minecraft:generic.follow_range").put("Follow Range", "minecraft:generic.follow_range").put("generic.knockbackResistance", "minecraft:generic.knockback_resistance").put("Knockback Resistance", "minecraft:generic.knockback_resistance").put("generic.movementSpeed", "minecraft:generic.movement_speed").put("Movement Speed", "minecraft:generic.movement_speed").put("generic.flyingSpeed", "minecraft:generic.flying_speed").put("Flying Speed", "minecraft:generic.flying_speed").put("generic.attackDamage", "minecraft:generic.attack_damage").put("generic.attackKnockback", "minecraft:generic.attack_knockback").put("generic.attackSpeed", "minecraft:generic.attack_speed").put("generic.armorToughness", "minecraft:generic.armor_toughness").build()))); - Schema schema112 = datafixerbuilder.addSchema(2527, DataConverterRegistry.SAME_NAMESPACED); ++ datafixerbuilder.addFixer(new DataConverterAttributes(schema112, "Attribute renames", createRenamerNoNamespace(ImmutableMap.builder().put("generic.maxHealth", "minecraft:generic.max_health").put("Max Health", "minecraft:generic.max_health").put("zombie.spawnReinforcements", "minecraft:zombie.spawn_reinforcements").put("Spawn Reinforcements Chance", "minecraft:zombie.spawn_reinforcements").put("horse.jumpStrength", "minecraft:horse.jump_strength").put("Jump Strength", "minecraft:horse.jump_strength").put("generic.followRange", "minecraft:generic.follow_range").put("Follow Range", "minecraft:generic.follow_range").put("generic.knockbackResistance", "minecraft:generic.knockback_resistance").put("Knockback Resistance", "minecraft:generic.knockback_resistance").put("generic.movementSpeed", "minecraft:generic.movement_speed").put("Movement Speed", "minecraft:generic.movement_speed").put("generic.flyingSpeed", "minecraft:generic.flying_speed").put("Flying Speed", "minecraft:generic.flying_speed").put("generic.attackDamage", "minecraft:generic.attack_damage").put("generic.attackKnockback", "minecraft:generic.attack_knockback").put("generic.attackSpeed", "minecraft:generic.attack_speed").put("generic.armorToughness", "minecraft:generic.armor_toughness").build()))); + Schema schema113 = datafixerbuilder.addSchema(2527, DataConverterRegistry.SAME_NAMESPACED); - datafixerbuilder.addFixer(new DataConverterBitStorageAlign(schema112)); -@@ -838,12 +851,14 @@ - datafixerbuilder.addFixer(new DataConverterAddChoices(schema130, "Added Glow Squid", DataConverterTypes.ENTITY)); - datafixerbuilder.addFixer(new DataConverterAddChoices(schema130, "Added Glow Item Frame", DataConverterTypes.ENTITY)); - Schema schema131 = datafixerbuilder.addSchema(2690, DataConverterRegistry.SAME_NAMESPACED); + datafixerbuilder.addFixer(new DataConverterBitStorageAlign(schema113)); +@@ -889,12 +904,14 @@ + datafixerbuilder.addFixer(new DataConverterAddChoices(schema131, "Added Glow Squid", DataConverterTypes.ENTITY)); + datafixerbuilder.addFixer(new DataConverterAddChoices(schema131, "Added Glow Item Frame", DataConverterTypes.ENTITY)); + Schema schema132 = datafixerbuilder.addSchema(2690, DataConverterRegistry.SAME_NAMESPACED); - ImmutableMap immutablemap = ImmutableMap.builder().put("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block").put("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block").put("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block").put("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper").put("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper").put("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper").put("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs").put("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs").put("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs").put("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab").put("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab").put("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab").put("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper").put("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper").put("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper").put("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper").put("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs").put("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs").put("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab").put("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab").build(); + // CraftBukkit - decompile error + ImmutableMap immutablemap = ImmutableMap.builder().put("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block").put("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block").put("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block").put("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper").put("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper").put("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper").put("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs").put("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs").put("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs").put("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab").put("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab").put("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab").put("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper").put("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper").put("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper").put("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper").put("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs").put("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs").put("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab").put("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab").build(); - datafixerbuilder.addFixer(DataConverterItemName.create(schema131, "Renamed copper block items to new oxidized terms", createRenamer(immutablemap))); - datafixerbuilder.addFixer(DataConverterBlockRename.create(schema131, "Renamed copper blocks to new oxidized terms", createRenamer(immutablemap))); - Schema schema132 = datafixerbuilder.addSchema(2691, DataConverterRegistry.SAME_NAMESPACED); + datafixerbuilder.addFixer(DataConverterItemName.create(schema132, "Renamed copper block items to new oxidized terms", createRenamer(immutablemap))); + datafixerbuilder.addFixer(DataConverterBlockRename.create(schema132, "Renamed copper blocks to new oxidized terms", createRenamer(immutablemap))); + Schema schema133 = datafixerbuilder.addSchema(2691, DataConverterRegistry.SAME_NAMESPACED); - ImmutableMap immutablemap1 = ImmutableMap.builder().put("minecraft:waxed_copper", "minecraft:waxed_copper_block").put("minecraft:oxidized_copper_block", "minecraft:oxidized_copper").put("minecraft:weathered_copper_block", "minecraft:weathered_copper").put("minecraft:exposed_copper_block", "minecraft:exposed_copper").build(); + // CraftBukkit - decompile error + ImmutableMap immutablemap1 = ImmutableMap.builder().put("minecraft:waxed_copper", "minecraft:waxed_copper_block").put("minecraft:oxidized_copper_block", "minecraft:oxidized_copper").put("minecraft:weathered_copper_block", "minecraft:weathered_copper").put("minecraft:exposed_copper_block", "minecraft:exposed_copper").build(); - datafixerbuilder.addFixer(DataConverterItemName.create(schema132, "Rename copper item suffixes", createRenamer(immutablemap1))); - datafixerbuilder.addFixer(DataConverterBlockRename.create(schema132, "Rename copper blocks suffixes", createRenamer(immutablemap1))); -@@ -851,7 +866,8 @@ + datafixerbuilder.addFixer(DataConverterItemName.create(schema133, "Rename copper item suffixes", createRenamer(immutablemap1))); + datafixerbuilder.addFixer(DataConverterBlockRename.create(schema133, "Rename copper blocks suffixes", createRenamer(immutablemap1))); +@@ -902,7 +919,8 @@ - datafixerbuilder.addFixer(new AddFlagIfNotPresentFix(schema133, DataConverterTypes.WORLD_GEN_SETTINGS, "has_increased_height_already", false)); - Schema schema134 = datafixerbuilder.addSchema(2696, DataConverterRegistry.SAME_NAMESPACED); + datafixerbuilder.addFixer(new AddFlagIfNotPresentFix(schema134, DataConverterTypes.WORLD_GEN_SETTINGS, "has_increased_height_already", false)); + Schema schema135 = datafixerbuilder.addSchema(2696, DataConverterRegistry.SAME_NAMESPACED); - ImmutableMap immutablemap2 = ImmutableMap.builder().put("minecraft:grimstone", "minecraft:deepslate").put("minecraft:grimstone_slab", "minecraft:cobbled_deepslate_slab").put("minecraft:grimstone_stairs", "minecraft:cobbled_deepslate_stairs").put("minecraft:grimstone_wall", "minecraft:cobbled_deepslate_wall").put("minecraft:polished_grimstone", "minecraft:polished_deepslate").put("minecraft:polished_grimstone_slab", "minecraft:polished_deepslate_slab").put("minecraft:polished_grimstone_stairs", "minecraft:polished_deepslate_stairs").put("minecraft:polished_grimstone_wall", "minecraft:polished_deepslate_wall").put("minecraft:grimstone_tiles", "minecraft:deepslate_tiles").put("minecraft:grimstone_tile_slab", "minecraft:deepslate_tile_slab").put("minecraft:grimstone_tile_stairs", "minecraft:deepslate_tile_stairs").put("minecraft:grimstone_tile_wall", "minecraft:deepslate_tile_wall").put("minecraft:grimstone_bricks", "minecraft:deepslate_bricks").put("minecraft:grimstone_brick_slab", "minecraft:deepslate_brick_slab").put("minecraft:grimstone_brick_stairs", "minecraft:deepslate_brick_stairs").put("minecraft:grimstone_brick_wall", "minecraft:deepslate_brick_wall").put("minecraft:chiseled_grimstone", "minecraft:chiseled_deepslate").build(); + // CraftBukkit - decompile error + ImmutableMap immutablemap2 = ImmutableMap.builder().put("minecraft:grimstone", "minecraft:deepslate").put("minecraft:grimstone_slab", "minecraft:cobbled_deepslate_slab").put("minecraft:grimstone_stairs", "minecraft:cobbled_deepslate_stairs").put("minecraft:grimstone_wall", "minecraft:cobbled_deepslate_wall").put("minecraft:polished_grimstone", "minecraft:polished_deepslate").put("minecraft:polished_grimstone_slab", "minecraft:polished_deepslate_slab").put("minecraft:polished_grimstone_stairs", "minecraft:polished_deepslate_stairs").put("minecraft:polished_grimstone_wall", "minecraft:polished_deepslate_wall").put("minecraft:grimstone_tiles", "minecraft:deepslate_tiles").put("minecraft:grimstone_tile_slab", "minecraft:deepslate_tile_slab").put("minecraft:grimstone_tile_stairs", "minecraft:deepslate_tile_stairs").put("minecraft:grimstone_tile_wall", "minecraft:deepslate_tile_wall").put("minecraft:grimstone_bricks", "minecraft:deepslate_bricks").put("minecraft:grimstone_brick_slab", "minecraft:deepslate_brick_slab").put("minecraft:grimstone_brick_stairs", "minecraft:deepslate_brick_stairs").put("minecraft:grimstone_brick_wall", "minecraft:deepslate_brick_wall").put("minecraft:chiseled_grimstone", "minecraft:chiseled_deepslate").build(); - datafixerbuilder.addFixer(DataConverterItemName.create(schema134, "Renamed grimstone block items to deepslate", createRenamer(immutablemap2))); - datafixerbuilder.addFixer(DataConverterBlockRename.create(schema134, "Renamed grimstone blocks to deepslate", createRenamer(immutablemap2))); -@@ -938,10 +954,11 @@ - datafixerbuilder.addFixer(new DataConverterAddChoices(schema159, "Added Allay", DataConverterTypes.ENTITY)); - Schema schema160 = datafixerbuilder.addSchema(3084, DataConverterRegistry.SAME_NAMESPACED); + datafixerbuilder.addFixer(DataConverterItemName.create(schema135, "Renamed grimstone block items to deepslate", createRenamer(immutablemap2))); + datafixerbuilder.addFixer(DataConverterBlockRename.create(schema135, "Renamed grimstone blocks to deepslate", createRenamer(immutablemap2))); +@@ -989,10 +1007,11 @@ + datafixerbuilder.addFixer(new DataConverterAddChoices(schema160, "Added Allay", DataConverterTypes.ENTITY)); + Schema schema161 = datafixerbuilder.addSchema(3084, DataConverterRegistry.SAME_NAMESPACED); -- datafixerbuilder.addFixer(new NamespacedTypeRenameFix(schema160, "game_event_renames_3084", DataConverterTypes.GAME_EVENT_NAME, createRenamer(ImmutableMap.builder().put("minecraft:block_press", "minecraft:block_activate").put("minecraft:block_switch", "minecraft:block_activate").put("minecraft:block_unpress", "minecraft:block_deactivate").put("minecraft:block_unswitch", "minecraft:block_deactivate").put("minecraft:drinking_finish", "minecraft:drink").put("minecraft:elytra_free_fall", "minecraft:elytra_glide").put("minecraft:entity_damaged", "minecraft:entity_damage").put("minecraft:entity_dying", "minecraft:entity_die").put("minecraft:entity_killed", "minecraft:entity_die").put("minecraft:mob_interact", "minecraft:entity_interact").put("minecraft:ravager_roar", "minecraft:entity_roar").put("minecraft:ring_bell", "minecraft:block_change").put("minecraft:shulker_close", "minecraft:container_close").put("minecraft:shulker_open", "minecraft:container_open").put("minecraft:wolf_shaking", "minecraft:entity_shake").build()))); +- datafixerbuilder.addFixer(new NamespacedTypeRenameFix(schema161, "game_event_renames_3084", DataConverterTypes.GAME_EVENT_NAME, createRenamer(ImmutableMap.builder().put("minecraft:block_press", "minecraft:block_activate").put("minecraft:block_switch", "minecraft:block_activate").put("minecraft:block_unpress", "minecraft:block_deactivate").put("minecraft:block_unswitch", "minecraft:block_deactivate").put("minecraft:drinking_finish", "minecraft:drink").put("minecraft:elytra_free_fall", "minecraft:elytra_glide").put("minecraft:entity_damaged", "minecraft:entity_damage").put("minecraft:entity_dying", "minecraft:entity_die").put("minecraft:entity_killed", "minecraft:entity_die").put("minecraft:mob_interact", "minecraft:entity_interact").put("minecraft:ravager_roar", "minecraft:entity_roar").put("minecraft:ring_bell", "minecraft:block_change").put("minecraft:shulker_close", "minecraft:container_close").put("minecraft:shulker_open", "minecraft:container_open").put("minecraft:wolf_shaking", "minecraft:entity_shake").build()))); + // CraftBukkit - decompile error -+ datafixerbuilder.addFixer(new NamespacedTypeRenameFix(schema160, "game_event_renames_3084", DataConverterTypes.GAME_EVENT_NAME, createRenamer(ImmutableMap.builder().put("minecraft:block_press", "minecraft:block_activate").put("minecraft:block_switch", "minecraft:block_activate").put("minecraft:block_unpress", "minecraft:block_deactivate").put("minecraft:block_unswitch", "minecraft:block_deactivate").put("minecraft:drinking_finish", "minecraft:drink").put("minecraft:elytra_free_fall", "minecraft:elytra_glide").put("minecraft:entity_damaged", "minecraft:entity_damage").put("minecraft:entity_dying", "minecraft:entity_die").put("minecraft:entity_killed", "minecraft:entity_die").put("minecraft:mob_interact", "minecraft:entity_interact").put("minecraft:ravager_roar", "minecraft:entity_roar").put("minecraft:ring_bell", "minecraft:block_change").put("minecraft:shulker_close", "minecraft:container_close").put("minecraft:shulker_open", "minecraft:container_open").put("minecraft:wolf_shaking", "minecraft:entity_shake").build()))); - Schema schema161 = datafixerbuilder.addSchema(3086, DataConverterRegistry.SAME_NAMESPACED); ++ datafixerbuilder.addFixer(new NamespacedTypeRenameFix(schema161, "game_event_renames_3084", DataConverterTypes.GAME_EVENT_NAME, createRenamer(ImmutableMap.builder().put("minecraft:block_press", "minecraft:block_activate").put("minecraft:block_switch", "minecraft:block_activate").put("minecraft:block_unpress", "minecraft:block_deactivate").put("minecraft:block_unswitch", "minecraft:block_deactivate").put("minecraft:drinking_finish", "minecraft:drink").put("minecraft:elytra_free_fall", "minecraft:elytra_glide").put("minecraft:entity_damaged", "minecraft:entity_damage").put("minecraft:entity_dying", "minecraft:entity_die").put("minecraft:entity_killed", "minecraft:entity_die").put("minecraft:mob_interact", "minecraft:entity_interact").put("minecraft:ravager_roar", "minecraft:entity_roar").put("minecraft:ring_bell", "minecraft:block_change").put("minecraft:shulker_close", "minecraft:container_close").put("minecraft:shulker_open", "minecraft:container_open").put("minecraft:wolf_shaking", "minecraft:entity_shake").build()))); + Schema schema162 = datafixerbuilder.addSchema(3086, DataConverterRegistry.SAME_NAMESPACED); TypeReference typereference = DataConverterTypes.ENTITY; - Int2ObjectOpenHashMap int2objectopenhashmap = (Int2ObjectOpenHashMap) SystemUtils.make(new Int2ObjectOpenHashMap(), (int2objectopenhashmap1) -> { + Int2ObjectOpenHashMap int2objectopenhashmap = (Int2ObjectOpenHashMap) SystemUtils.make(new Int2ObjectOpenHashMap(), (int2objectopenhashmap1) -> { // CraftBukkit - decompile error int2objectopenhashmap1.defaultReturnValue("minecraft:tabby"); int2objectopenhashmap1.put(0, "minecraft:tabby"); int2objectopenhashmap1.put(1, "minecraft:black"); -@@ -958,7 +975,8 @@ +@@ -1009,7 +1028,8 @@ Objects.requireNonNull(int2objectopenhashmap); - datafixerbuilder.addFixer(new EntityVariantFix(schema161, "Change cat variant type", typereference, "minecraft:cat", "CatType", int2objectopenhashmap::get)); + datafixerbuilder.addFixer(new EntityVariantFix(schema162, "Change cat variant type", typereference, "minecraft:cat", "CatType", int2objectopenhashmap::get)); - ImmutableMap immutablemap3 = ImmutableMap.builder().put("textures/entity/cat/tabby.png", "minecraft:tabby").put("textures/entity/cat/black.png", "minecraft:black").put("textures/entity/cat/red.png", "minecraft:red").put("textures/entity/cat/siamese.png", "minecraft:siamese").put("textures/entity/cat/british_shorthair.png", "minecraft:british").put("textures/entity/cat/calico.png", "minecraft:calico").put("textures/entity/cat/persian.png", "minecraft:persian").put("textures/entity/cat/ragdoll.png", "minecraft:ragdoll").put("textures/entity/cat/white.png", "minecraft:white").put("textures/entity/cat/jellie.png", "minecraft:jellie").put("textures/entity/cat/all_black.png", "minecraft:all_black").build(); + // CraftBukkit - decompile error + ImmutableMap immutablemap3 = ImmutableMap.builder().put("textures/entity/cat/tabby.png", "minecraft:tabby").put("textures/entity/cat/black.png", "minecraft:black").put("textures/entity/cat/red.png", "minecraft:red").put("textures/entity/cat/siamese.png", "minecraft:siamese").put("textures/entity/cat/british_shorthair.png", "minecraft:british").put("textures/entity/cat/calico.png", "minecraft:calico").put("textures/entity/cat/persian.png", "minecraft:persian").put("textures/entity/cat/ragdoll.png", "minecraft:ragdoll").put("textures/entity/cat/white.png", "minecraft:white").put("textures/entity/cat/jellie.png", "minecraft:jellie").put("textures/entity/cat/all_black.png", "minecraft:all_black").build(); - datafixerbuilder.addFixer(new CriteriaRenameFix(schema161, "Migrate cat variant advancement", "minecraft:husbandry/complete_catalogue", (s) -> { + datafixerbuilder.addFixer(new CriteriaRenameFix(schema162, "Migrate cat variant advancement", "minecraft:husbandry/complete_catalogue", (s) -> { return (String) immutablemap3.getOrDefault(s, s); diff --git a/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch b/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch index 722e0a99b..f61fedb5f 100644 --- a/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch +++ b/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/util/worldupdate/WorldUpgrader.java +++ b/net/minecraft/util/worldupdate/WorldUpgrader.java -@@ -80,7 +80,7 @@ +@@ -82,7 +82,7 @@ - public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, IRegistryCustom iregistrycustom, boolean flag, boolean flag1) { + public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, SaveData savedata, IRegistryCustom iregistrycustom, boolean flag, boolean flag1) { this.dimensions = iregistrycustom.lookupOrThrow(Registries.LEVEL_STEM); - this.levels = (Set) this.dimensions.registryKeySet().stream().map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet()); + this.levels = (Set) java.util.stream.Stream.of(convertable_conversionsession.dimensionType).map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet()); // CraftBukkit this.eraseCache = flag; this.dataFixer = datafixer; this.levelStorage = convertable_conversionsession; -@@ -197,9 +197,9 @@ +@@ -446,9 +446,9 @@ if (nbttagcompound != null) { int i = IChunkLoader.getVersion(nbttagcompound); ChunkGenerator chunkgenerator = ((WorldDimension) WorldUpgrader.this.dimensions.getValueOrThrow(Registries.levelToLevelStem(resourcekey))).generator(); @@ -18,15 +18,6 @@ return WorldUpgrader.this.overworldDataStorage; - }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer()); + }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer(), chunkcoordintpair, null); // CraftBukkit - ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos")); + ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound1.getIntOr("xPos", 0), nbttagcompound1.getIntOr("zPos", 0)); if (!chunkcoordintpair1.equals(chunkcoordintpair)) { -@@ -321,7 +321,7 @@ - WorldUpgrader.c worldupgrader_c = (WorldUpgrader.c) iterator.next(); - ResourceKey resourcekey = worldupgrader_c.dimensionKey; - ListIterator listiterator = worldupgrader_c.files; -- T t0 = (AutoCloseable) worldupgrader_c.storage; -+ T t0 = (T) worldupgrader_c.storage; // CraftBukkit - decompile error - - if (listiterator.hasNext()) { - WorldUpgrader.e worldupgrader_e = (WorldUpgrader.e) listiterator.next(); diff --git a/nms-patches/net/minecraft/world/IInventory.patch b/nms-patches/net/minecraft/world/IInventory.patch index 90d9dcf5a..c0a8e4226 100644 --- a/nms-patches/net/minecraft/world/IInventory.patch +++ b/nms-patches/net/minecraft/world/IInventory.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/IInventory.java +++ b/net/minecraft/world/IInventory.java -@@ -9,6 +9,11 @@ +@@ -11,6 +11,11 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.block.entity.TileEntity; @@ -9,10 +9,10 @@ +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +// CraftBukkit end + - public interface IInventory extends Clearable { + public interface IInventory extends Clearable, Iterable { float DEFAULT_DISTANCE_BUFFER = 4.0F; -@@ -25,9 +30,7 @@ +@@ -27,9 +32,7 @@ void setItem(int i, ItemStack itemstack); @@ -23,11 +23,10 @@ default int getMaxStackSize(ItemStack itemstack) { return Math.min(this.getMaxStackSize(), itemstack.getMaxStackSize()); -@@ -91,4 +94,22 @@ - - return world == null ? false : (world.getBlockEntity(blockposition) != tileentity ? false : entityhuman.canInteractWithBlock(blockposition, (double) f)); +@@ -94,6 +97,24 @@ + return new IInventory.a(this); } -+ + + // CraftBukkit start + java.util.List getContents(); + @@ -45,4 +44,7 @@ + + int MAX_STACK = 99; + // CraftBukkit end - } ++ + public static class a implements Iterator { + + private final IInventory container; diff --git a/nms-patches/net/minecraft/world/InventorySubcontainer.patch b/nms-patches/net/minecraft/world/InventorySubcontainer.patch index c77b2aa78..c87031c60 100644 --- a/nms-patches/net/minecraft/world/InventorySubcontainer.patch +++ b/nms-patches/net/minecraft/world/InventorySubcontainer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/InventorySubcontainer.java +++ b/net/minecraft/world/InventorySubcontainer.java -@@ -14,6 +14,12 @@ +@@ -13,6 +13,12 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -13,7 +13,7 @@ public class InventorySubcontainer implements IInventory, AutoRecipeOutput { private final int size; -@@ -21,7 +27,59 @@ +@@ -20,7 +26,59 @@ @Nullable private List listeners; @@ -71,5 +71,5 @@ + this.bukkitOwner = owner; + // CraftBukkit end this.size = i; - this.items = NonNullList.withSize(i, ItemStack.EMPTY); + this.items = NonNullList.withSize(i, ItemStack.EMPTY); } diff --git a/nms-patches/net/minecraft/world/effect/HealOrHarmMobEffect.patch b/nms-patches/net/minecraft/world/effect/HealOrHarmMobEffect.patch index f6f281102..3f2167aa9 100644 --- a/nms-patches/net/minecraft/world/effect/HealOrHarmMobEffect.patch +++ b/nms-patches/net/minecraft/world/effect/HealOrHarmMobEffect.patch @@ -9,12 +9,12 @@ } else { entityliving.hurtServer(worldserver, entityliving.damageSources().magic(), (float) (6 << i)); } -@@ -31,7 +31,7 @@ - +@@ -30,7 +30,7 @@ if (this.isHarm == entityliving.isInvertedHealAndHarm()) { - j = (int) (d0 * (double) (4 << i) + 0.5D); + int j = (int) (d0 * (double) (4 << i) + 0.5D); + - entityliving.heal((float) j); + entityliving.heal((float) j, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); // CraftBukkit } else { - j = (int) (d0 * (double) (6 << i) + 0.5D); - if (entity == null) { + int k = (int) (d0 * (double) (6 << i) + 0.5D); + diff --git a/nms-patches/net/minecraft/world/effect/InfestedMobEffect.patch b/nms-patches/net/minecraft/world/effect/InfestedMobEffect.patch index ce145e522..b594a5e46 100644 --- a/nms-patches/net/minecraft/world/effect/InfestedMobEffect.patch +++ b/nms-patches/net/minecraft/world/effect/InfestedMobEffect.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/effect/InfestedMobEffect.java @@ -48,7 +48,11 @@ - entitysilverfish.moveTo(d0, d1, d2, worldserver.getRandom().nextFloat() * 360.0F, 0.0F); + entitysilverfish.snapTo(d0, d1, d2, worldserver.getRandom().nextFloat() * 360.0F, 0.0F); entitysilverfish.setDeltaMovement(new Vec3D(vector3f)); - worldserver.addFreshEntity(entitysilverfish); + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/effect/OozingMobEffect.patch b/nms-patches/net/minecraft/world/effect/OozingMobEffect.patch index 1619b9769..a5bad2030 100644 --- a/nms-patches/net/minecraft/world/effect/OozingMobEffect.patch +++ b/nms-patches/net/minecraft/world/effect/OozingMobEffect.patch @@ -3,7 +3,7 @@ @@ -52,7 +52,7 @@ if (entityslime != null) { entityslime.setSize(2, true); - entityslime.moveTo(d0, d1, d2, world.getRandom().nextFloat() * 360.0F, 0.0F); + entityslime.snapTo(d0, d1, d2, world.getRandom().nextFloat() * 360.0F, 0.0F); - world.addFreshEntity(entityslime); + world.addFreshEntity(entityslime, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.POTION_EFFECT); // CraftBukkit } diff --git a/nms-patches/net/minecraft/world/entity/ConversionType.patch b/nms-patches/net/minecraft/world/entity/ConversionType.patch index f3c873dd3..34cc2c282 100644 --- a/nms-patches/net/minecraft/world/entity/ConversionType.patch +++ b/nms-patches/net/minecraft/world/entity/ConversionType.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ConversionType.java +++ b/net/minecraft/world/entity/ConversionType.java -@@ -12,6 +12,11 @@ +@@ -11,6 +11,11 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.scores.Scoreboard; @@ -12,25 +12,25 @@ public enum ConversionType { SINGLE(true) { -@@ -31,7 +36,7 @@ - while (iterator.hasNext()) { - entity1 = (Entity) iterator.next(); +@@ -26,7 +31,7 @@ + + for (Entity entity1 : entityinsentient1.getPassengers()) { entity1.stopRiding(); - entity1.remove(Entity.RemovalReason.DISCARDED); + entity1.remove(Entity.RemovalReason.DISCARDED, EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause } entity.startRiding(entityinsentient1); -@@ -52,7 +57,7 @@ +@@ -44,7 +49,7 @@ ItemStack itemstack = entityinsentient.getItemBySlot(enumitemslot); if (!itemstack.isEmpty()) { - entityinsentient1.setItemSlot(enumitemslot, itemstack.copyAndClear()); + entityinsentient1.setItemSlot(enumitemslot, itemstack.copy()); // CraftBukkit - SPIGOT-7996: don't clear yet - entityinsentient1.setDropChance(enumitemslot, entityinsentient.getEquipmentDropChance(enumitemslot)); + entityinsentient1.setDropChance(enumitemslot, entityinsentient.getDropChances().byEquipment(enumitemslot)); } } -@@ -64,7 +69,7 @@ +@@ -56,7 +61,7 @@ entityinsentient1.hurtTime = entityinsentient.hurtTime; entityinsentient1.yBodyRot = entityinsentient.yBodyRot; entityinsentient1.setOnGround(entityinsentient.onGround()); @@ -39,7 +39,7 @@ Objects.requireNonNull(entityinsentient1); optional.ifPresent(entityinsentient1::setSleepingPos); -@@ -75,6 +80,21 @@ +@@ -68,6 +73,21 @@ this.convertCommon(entityinsentient, entityinsentient1, conversionparams); } @@ -61,7 +61,7 @@ }, SPLIT_ON_DEATH(false) { @Override -@@ -107,6 +127,8 @@ +@@ -100,6 +120,8 @@ abstract void convert(EntityInsentient entityinsentient, EntityInsentient entityinsentient1, ConversionParams conversionparams); @@ -69,8 +69,8 @@ + void convertCommon(EntityInsentient entityinsentient, EntityInsentient entityinsentient1, ConversionParams conversionparams) { entityinsentient1.setAbsorptionAmount(entityinsentient.getAbsorptionAmount()); - Iterator iterator = entityinsentient.getActiveEffects().iterator(); -@@ -156,7 +178,7 @@ + +@@ -146,7 +168,7 @@ entityinsentient1.setNoGravity(entityinsentient.isNoGravity()); entityinsentient1.setPortalCooldown(entityinsentient.getPortalCooldown()); entityinsentient1.setSilent(entityinsentient.isSilent()); diff --git a/nms-patches/net/minecraft/world/entity/Entity.patch b/nms-patches/net/minecraft/world/entity/Entity.patch index 4a5f08dd3..e79f5dd45 100644 --- a/nms-patches/net/minecraft/world/entity/Entity.patch +++ b/nms-patches/net/minecraft/world/entity/Entity.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -139,8 +139,68 @@ +@@ -144,8 +144,68 @@ import net.minecraft.world.scores.ScoreboardTeamBase; - import org.slf4j.Logger; + import org.jetbrains.annotations.Contract; +// CraftBukkit start +import net.minecraft.network.protocol.game.PacketPlayOutAttachEntity; @@ -43,12 +43,12 @@ +import org.bukkit.plugin.PluginManager; +// CraftBukkit end + - public abstract class Entity implements SyncedDataHolder, INamableTileEntity, EntityAccess, ScoreHolder { + public abstract class Entity implements SyncedDataHolder, INamableTileEntity, EntityAccess, ScoreHolder, DataComponentGetter { + // CraftBukkit start + private static final int CURRENT_LEVEL = 2; + static boolean isLevelAtLeast(NBTTagCompound tag, int level) { -+ return tag.contains("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level; ++ return tag.contains("Bukkit.updateLevel") && tag.getIntOr("Bukkit.updateLevel", -1) >= level; + } + + private CraftEntity bukkitEntity; @@ -66,13 +66,13 @@ + } + // CraftBukkit end + - private static final Logger LOGGER = LogUtils.getLogger(); public static final String ID_TAG = "id"; public static final String PASSENGERS_TAG = "Passengers"; -@@ -253,6 +313,30 @@ - private final List movementThisTick; - private final Set blocksInside; + private static final String DATA_TAG = "data"; +@@ -262,6 +322,30 @@ private final LongSet visitedBlocks; + private final InsideBlockEffectApplier.a insideEffectCollector; + private CustomData customData; + // CraftBukkit start + public boolean forceDrops; + public boolean persist = true; @@ -100,7 +100,7 @@ public Entity(EntityTypes entitytypes, World world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -362,12 +446,18 @@ +@@ -372,12 +456,18 @@ } public void kill(WorldServer worldserver) { @@ -121,7 +121,7 @@ } protected abstract void defineSynchedData(DataWatcher.a datawatcher_a); -@@ -376,6 +466,16 @@ +@@ -386,6 +476,16 @@ return this.entityData; } @@ -138,7 +138,7 @@ public boolean equals(Object object) { return object instanceof Entity ? ((Entity) object).id == this.id : false; } -@@ -385,7 +485,13 @@ +@@ -395,7 +495,13 @@ } public void remove(Entity.RemovalReason entity_removalreason) { @@ -153,7 +153,7 @@ } public void onClientRemoval() {} -@@ -393,6 +499,12 @@ +@@ -403,6 +509,12 @@ public void onRemoval(Entity.RemovalReason entity_removalreason) {} public void setPose(EntityPose entitypose) { @@ -166,7 +166,7 @@ this.entityData.set(Entity.DATA_POSE, entitypose); } -@@ -417,6 +529,33 @@ +@@ -427,6 +539,33 @@ } protected void setRot(float f, float f1) { @@ -200,7 +200,7 @@ this.setYRot(f % 360.0F); this.setXRot(f1 % 360.0F); } -@@ -462,6 +601,15 @@ +@@ -472,6 +611,15 @@ this.baseTick(); } @@ -216,7 +216,7 @@ public void baseTick() { GameProfilerFiller gameprofilerfiller = Profiler.get(); -@@ -475,7 +623,7 @@ +@@ -485,7 +633,7 @@ --this.boardingCooldown; } @@ -225,10 +225,10 @@ if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -514,6 +662,10 @@ +@@ -518,6 +666,10 @@ + if (this.isInLava()) { - this.lavaHurt(); - this.fallDistance *= 0.5F; + this.fallDistance *= 0.5D; + // CraftBukkit start + } else { + this.lastLavaContact = null; @@ -236,18 +236,18 @@ } this.checkBelowWorld(); -@@ -525,7 +677,7 @@ +@@ -529,7 +681,7 @@ world = this.level(); - if (world instanceof WorldServer worldserver) { + if (world instanceof WorldServer worldserver1) { if (this instanceof Leashable) { -- Leashable.tickLeash(worldserver, (Entity) ((Leashable) this)); -+ Leashable.tickLeash(worldserver, (Entity & Leashable) this); // CraftBukkit - decompile error +- Leashable.tickLeash(worldserver1, (Entity) ((Leashable) this)); ++ Leashable.tickLeash(worldserver1, (Entity & Leashable) this); // CraftBukkit - decompile error } } -@@ -568,15 +720,32 @@ +@@ -572,7 +724,22 @@ - public void lavaHurt() { + public void lavaIgnite() { if (!this.fireImmune()) { - this.igniteForSeconds(15.0F); + // CraftBukkit start - Fallen in lava TODO: this event spams! @@ -266,21 +266,19 @@ + this.igniteForSeconds(15.0F, false); + } + // CraftBukkit end - World world = this.level(); + } + } +@@ -583,7 +750,7 @@ if (world instanceof WorldServer) { WorldServer worldserver = (WorldServer) world; - if (this.hurtServer(worldserver, this.damageSources().lava(), 4.0F) && this.shouldPlayLavaHurtSound() && !this.isSilent()) { -+ // CraftBukkit start -+ if (this.hurtServer(worldserver, this.damageSources().lava().directBlock(level, lastLavaContact), 4.0F) && this.shouldPlayLavaHurtSound() && !this.isSilent()) { - worldserver.playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.GENERIC_BURN, this.getSoundSource(), 0.4F, 2.0F + this.random.nextFloat() * 0.4F); ++ if (this.hurtServer(worldserver, this.damageSources().lava().directBlock(level, lastLavaContact), 4.0F) && this.shouldPlayLavaHurtSound() && !this.isSilent()) { // CraftBukkit + worldserver.playSound((Entity) null, this.getX(), this.getY(), this.getZ(), SoundEffects.GENERIC_BURN, this.getSoundSource(), 0.4F, 2.0F + this.random.nextFloat() * 0.4F); } -+ // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls } - - } -@@ -587,6 +756,22 @@ +@@ -596,6 +763,22 @@ } public final void igniteForSeconds(float f) { @@ -303,7 +301,7 @@ this.igniteForTicks(MathHelper.floor(f * 20.0F)); } -@@ -610,7 +795,7 @@ +@@ -620,7 +803,7 @@ } protected void onBelowWorld() { @@ -312,7 +310,7 @@ } public boolean isFree(double d0, double d1, double d2) { -@@ -750,6 +935,28 @@ +@@ -774,6 +957,28 @@ } } @@ -338,10 +336,19 @@ + } + // CraftBukkit end + - if (!this.level().isClientSide() || this.isControlledByLocalInstance()) { + if (!this.level().isClientSide() || this.isLocalInstanceAuthoritative()) { Entity.MovementEmission entity_movementemission = this.getMovementEmission(); -@@ -1133,6 +1340,20 @@ +@@ -828,7 +1033,7 @@ + + protected void applyEffectsFromBlocks() { + this.finalMovementsThisTick.clear(); +- List list = this.movementThisTick; ++ List> list = this.movementThisTick; // CraftBukkit - decompile error + List list1 = this.finalMovementsThisTick; + + Objects.requireNonNull(this.finalMovementsThisTick); +@@ -1158,6 +1363,20 @@ return SoundEffects.GENERIC_SPLASH; } @@ -359,18 +366,18 @@ + } + // CraftBukkit end + - public void recordMovementThroughBlocks(Vec3D vec3d, Vec3D vec3d1) { - this.movementThisTick.add(new Entity.b(vec3d, vec3d1)); - } -@@ -1609,6 +1830,7 @@ + private void checkInsideBlocks(List list, InsideBlockEffectApplier.a insideblockeffectapplier_a) { + if (this.isAffectedByBlocks()) { + LongSet longset = this.visitedBlocks; +@@ -1624,6 +1843,7 @@ this.yo = d1; this.zo = d4; this.setPos(d3, d1, d4); + if (valid) level.getChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4); // CraftBukkit } - public void moveTo(Vec3D vec3d) { -@@ -1861,6 +2083,12 @@ + public void snapTo(Vec3D vec3d) { +@@ -1876,6 +2096,12 @@ return false; } @@ -383,7 +390,7 @@ public void awardKillScore(Entity entity, DamageSource damagesource) { if (entity instanceof EntityPlayer) { CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource); -@@ -1889,16 +2117,22 @@ +@@ -1904,16 +2130,22 @@ } public boolean saveAsPassenger(NBTTagCompound nbttagcompound) { @@ -408,7 +415,7 @@ return true; } } -@@ -1909,16 +2143,38 @@ +@@ -1924,14 +2156,34 @@ } public NBTTagCompound saveWithoutId(NBTTagCompound nbttagcompound) { @@ -420,23 +427,20 @@ + // CraftBukkit end try { - if (this.vehicle != null) { -- nbttagcompound.put("Pos", this.newDoubleList(this.vehicle.getX(), this.getY(), this.vehicle.getZ())); +- nbttagcompound.store("Pos", Vec3D.CODEC, new Vec3D(this.vehicle.getX(), this.getY(), this.vehicle.getZ())); - } else { -- nbttagcompound.put("Pos", this.newDoubleList(this.getX(), this.getY(), this.getZ())); +- nbttagcompound.store("Pos", Vec3D.CODEC, this.position()); + // CraftBukkit start - selectively save position + if (includeAll) { + if (this.vehicle != null) { -+ nbttagcompound.put("Pos", this.newDoubleList(this.vehicle.getX(), this.getY(), this.vehicle.getZ())); ++ nbttagcompound.store("Pos", Vec3D.CODEC, new Vec3D(this.vehicle.getX(), this.getY(), this.vehicle.getZ())); + } else { -+ nbttagcompound.put("Pos", this.newDoubleList(this.getX(), this.getY(), this.getZ())); ++ nbttagcompound.store("Pos", Vec3D.CODEC, this.position()); + } } + // CraftBukkit end - Vec3D vec3d = this.getDeltaMovement(); - - nbttagcompound.put("Motion", this.newDoubleList(vec3d.x, vec3d.y, vec3d.z)); -+ + nbttagcompound.store("Motion", Vec3D.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)) { @@ -447,18 +451,17 @@ + this.xRot = 0; + } + // CraftBukkit end -+ - nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot())); - nbttagcompound.putFloat("FallDistance", this.fallDistance); + nbttagcompound.store("Rotation", Vec2F.CODEC, new Vec2F(this.getYRot(), this.getXRot())); + nbttagcompound.putDouble("fall_distance", this.fallDistance); nbttagcompound.putShort("Fire", (short) this.remainingFireTicks); -@@ -1926,7 +2182,28 @@ +@@ -1939,7 +2191,28 @@ nbttagcompound.putBoolean("OnGround", this.onGround()); nbttagcompound.putBoolean("Invulnerable", this.invulnerable); nbttagcompound.putInt("PortalCooldown", this.portalCooldown); -- nbttagcompound.putUUID("UUID", this.getUUID()); +- nbttagcompound.store("UUID", UUIDUtil.CODEC, this.getUUID()); + // CraftBukkit start - selectively save uuid and world + if (includeAll) { -+ nbttagcompound.putUUID("UUID", this.getUUID()); ++ nbttagcompound.store("UUID", UUIDUtil.CODEC, this.getUUID()); + // PAIL: Check above UUID reads 1.8 properly, ie: UUIDMost / UUIDLeast + nbttagcompound.putLong("WorldUUIDLeast", ((WorldServer) this.level).getWorld().getUID().getLeastSignificantBits()); + nbttagcompound.putLong("WorldUUIDMost", ((WorldServer) this.level).getWorld().getUID().getMostSignificantBits()); @@ -481,17 +484,16 @@ IChatBaseComponent ichatbasecomponent = this.getCustomName(); if (ichatbasecomponent != null) { -@@ -1975,7 +2252,7 @@ - nbttagcompound.put("Tags", nbttaglist); +@@ -1982,14 +2255,14 @@ + nbttagcompound.store("data", CustomData.CODEC, this.customData); } - this.addAdditionalSaveData(nbttagcompound); + this.addAdditionalSaveData(nbttagcompound, includeAll); // CraftBukkit - pass on includeAll if (this.isVehicle()) { - nbttaglist = new NBTTagList(); - iterator = this.getPassengers().iterator(); -@@ -1984,7 +2261,7 @@ - Entity entity = (Entity) iterator.next(); + NBTTagList nbttaglist = new NBTTagList(); + + for (Entity entity : this.getPassengers()) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - if (entity.saveAsPassenger(nbttagcompound1)) { @@ -499,7 +501,7 @@ nbttaglist.add(nbttagcompound1); } } -@@ -1994,6 +2271,11 @@ +@@ -1999,6 +2272,11 @@ } } @@ -511,18 +513,34 @@ return nbttagcompound; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); -@@ -2080,6 +2362,45 @@ +@@ -2041,7 +2319,7 @@ + this.setRot(this.getYRot(), this.getXRot()); + RegistryOps registryops = this.registryAccess().createSerializationContext(DynamicOpsNBT.INSTANCE); + +- this.setCustomName((IChatBaseComponent) nbttagcompound.read("CustomName", ComponentSerialization.CODEC, registryops).orElse((Object) null)); ++ this.setCustomName((IChatBaseComponent) nbttagcompound.read("CustomName", ComponentSerialization.CODEC, registryops).orElse(null)); // CraftBukkit - decompile error + this.setCustomNameVisible(nbttagcompound.getBooleanOr("CustomNameVisible", false)); + this.setSilent(nbttagcompound.getBooleanOr("Silent", false)); + this.setNoGravity(nbttagcompound.getBooleanOr("NoGravity", false)); +@@ -2050,7 +2328,7 @@ + this.hasVisualFire = nbttagcompound.getBooleanOr("HasVisualFire", false); + this.customData = (CustomData) nbttagcompound.read("data", CustomData.CODEC).orElse(CustomData.EMPTY); + this.tags.clear(); +- Optional optional = nbttagcompound.read("Tags", Entity.TAG_LIST_CODEC); ++ Optional> optional = nbttagcompound.read("Tags", Entity.TAG_LIST_CODEC); // CraftBukkit - deocmpile error + Set set = this.tags; + + Objects.requireNonNull(this.tags); +@@ -2066,6 +2344,43 @@ } else { throw new IllegalStateException("Entity has invalid position"); } + + // CraftBukkit start -+ this.persist = !nbttagcompound.contains("Bukkit.persist") || nbttagcompound.getBoolean("Bukkit.persist"); -+ this.visibleByDefault = !nbttagcompound.contains("Bukkit.visibleByDefault") || nbttagcompound.getBoolean("Bukkit.visibleByDefault"); ++ this.persist = nbttagcompound.getBooleanOr("Bukkit.persist", this.persist); ++ this.visibleByDefault = nbttagcompound.getBooleanOr("Bukkit.visibleByDefault", this.visibleByDefault); + // SPIGOT-6907: re-implement LivingEntity#setMaximumAir() -+ if (nbttagcompound.contains("Bukkit.MaxAirSupply")) { -+ maxAirTicks = nbttagcompound.getInt("Bukkit.MaxAirSupply"); -+ } ++ this.maxAirTicks = nbttagcompound.getIntOr("Bukkit.MaxAirSupply", this.maxAirTicks); + // CraftBukkit end + + // CraftBukkit start - Reset world @@ -531,10 +549,10 @@ + org.bukkit.World bworld = null; + + // TODO: Remove World related checks, replaced with WorldUID -+ String worldName = nbttagcompound.getString("world"); ++ String worldName = nbttagcompound.getStringOr("world", ""); + + if (nbttagcompound.contains("WorldUUIDMost") && nbttagcompound.contains("WorldUUIDLeast")) { -+ UUID uid = new UUID(nbttagcompound.getLong("WorldUUIDMost"), nbttagcompound.getLong("WorldUUIDLeast")); ++ UUID uid = new UUID(nbttagcompound.getLongOr("WorldUUIDMost", -1), nbttagcompound.getLongOr("WorldUUIDLeast", -1)); + bworld = server.getWorld(uid); + } else { + bworld = server.getWorld(worldName); @@ -548,7 +566,7 @@ + } + this.getBukkitEntity().readBukkitValues(nbttagcompound); + if (nbttagcompound.contains("Bukkit.invisible")) { -+ boolean bukkitInvisible = nbttagcompound.getBoolean("Bukkit.invisible"); ++ boolean bukkitInvisible = nbttagcompound.getBooleanOr("Bukkit.invisible", false); + this.setInvisible(bukkitInvisible); + this.persistentInvisibility = bukkitInvisible; + } @@ -557,7 +575,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded"); -@@ -2101,6 +2422,12 @@ +@@ -2087,6 +2402,12 @@ return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null; } @@ -570,7 +588,7 @@ protected abstract void readAdditionalSaveData(NBTTagCompound nbttagcompound); protected abstract void addAdditionalSaveData(NBTTagCompound nbttagcompound); -@@ -2153,9 +2480,22 @@ +@@ -2111,9 +2432,22 @@ if (itemstack.isEmpty()) { return null; } else { @@ -593,7 +611,7 @@ worldserver.addFreshEntity(entityitem); return entityitem; } -@@ -2184,6 +2524,12 @@ +@@ -2142,6 +2476,12 @@ if (this.isAlive() && this instanceof Leashable leashable) { if (leashable.getLeashHolder() == entityhuman) { if (!this.level().isClientSide()) { @@ -606,7 +624,7 @@ if (entityhuman.hasInfiniteMaterials()) { leashable.removeLeash(); } else { -@@ -2200,6 +2546,13 @@ +@@ -2158,6 +2498,13 @@ if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) { if (!this.level().isClientSide()) { @@ -620,7 +638,7 @@ leashable.setLeashedTo(entityhuman, true); } -@@ -2273,7 +2626,7 @@ +@@ -2231,7 +2578,7 @@ return false; } else if (!entity.couldAcceptPassenger()) { return false; @@ -629,7 +647,7 @@ return false; } else { for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) { -@@ -2285,6 +2638,27 @@ +@@ -2243,6 +2590,27 @@ if (!flag && (!this.canRide(entity) || !entity.canAddPassenger(this))) { return false; } else { @@ -657,7 +675,7 @@ if (this.isPassenger()) { this.stopRiding(); } -@@ -2318,7 +2692,7 @@ +@@ -2276,7 +2644,7 @@ Entity entity = this.vehicle; this.vehicle = null; @@ -666,7 +684,7 @@ } } -@@ -2349,10 +2723,38 @@ +@@ -2307,10 +2675,38 @@ } } @@ -706,7 +724,7 @@ if (this.passengers.size() == 1 && this.passengers.get(0) == entity) { this.passengers = ImmutableList.of(); } else { -@@ -2364,6 +2766,7 @@ +@@ -2322,6 +2718,7 @@ entity.boardingCooldown = 60; this.gameEvent(GameEvent.ENTITY_DISMOUNT, entity); } @@ -714,7 +732,7 @@ } protected boolean canAddPassenger(Entity entity) { -@@ -2464,7 +2867,7 @@ +@@ -2416,7 +2813,7 @@ if (teleporttransition != null) { WorldServer worldserver1 = teleporttransition.newLevel(); @@ -723,7 +741,7 @@ this.teleport(teleporttransition); } } -@@ -2571,6 +2974,13 @@ +@@ -2523,6 +2920,13 @@ } public void setSwimming(boolean flag) { @@ -737,7 +755,7 @@ this.setSharedFlag(4, flag); } -@@ -2624,8 +3034,12 @@ +@@ -2576,8 +2980,12 @@ return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false; } @@ -751,7 +769,7 @@ } public boolean getSharedFlag(int i) { -@@ -2644,7 +3058,7 @@ +@@ -2596,7 +3004,7 @@ } public int getMaxAirSupply() { @@ -760,7 +778,7 @@ } public int getAirSupply() { -@@ -2652,7 +3066,18 @@ +@@ -2604,7 +3012,18 @@ } public void setAirSupply(int i) { @@ -779,8 +797,8 @@ + // CraftBukkit end } - public int getTicksFrozen() { -@@ -2679,11 +3104,40 @@ + public void clearFreeze() { +@@ -2635,11 +3054,40 @@ public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -822,11 +840,17 @@ + // CraftBukkit end } - public void onAboveBubbleCol(boolean flag) { -@@ -2852,6 +3306,18 @@ + public void onAboveBubbleColumn(boolean flag, BlockPosition blockposition) { +@@ -2816,11 +3264,23 @@ - if (world instanceof WorldServer worldserver) { + @Nullable + public Entity teleport(TeleportTransition teleporttransition) { +- WorldServer worldserver = this.level(); ++ World worldserver = this.level(); // CraftBukkit - decompile error + + if (worldserver instanceof WorldServer worldserver1) { if (!this.isRemoved()) { +- worldserver = teleporttransition.newLevel(); + // CraftBukkit start + PositionMoveRotation absolutePosition = PositionMoveRotation.calculateAbsolute(PositionMoveRotation.of(this), PositionMoveRotation.of(teleporttransition), teleporttransition.relatives()); + Location to = CraftLocation.toBukkit(absolutePosition.position(), teleporttransition.newLevel().getWorld(), absolutePosition.yRot(), absolutePosition.xRot()); @@ -839,24 +863,34 @@ + teleporttransition = new TeleportTransition(((CraftWorld) to.getWorld()).getHandle(), CraftLocation.toVec3D(to), Vec3D.ZERO, to.getYaw(), to.getPitch(), teleporttransition.missingRespawnBlock(), teleporttransition.asPassenger(), Set.of(), teleporttransition.postTeleportTransition(), teleporttransition.cause()); + } + // CraftBukkit end - WorldServer worldserver1 = teleporttransition.newLevel(); - boolean flag = worldserver1.dimension() != worldserver.dimension(); ++ worldserver1 = teleporttransition.newLevel(); + boolean flag = worldserver.dimension() != worldserver1.dimension(); -@@ -2920,8 +3386,12 @@ + if (!teleporttransition.asPassenger()) { +@@ -2828,7 +3288,7 @@ + } + + if (flag) { +- return this.teleportCrossDimension(worldserver, teleporttransition); ++ return this.teleportCrossDimension(worldserver1, teleporttransition); // CraftBukkit - decompile error + } + + return this.teleportSameDimension(worldserver1, teleporttransition); +@@ -2881,8 +3341,12 @@ } else { - entity.restoreFrom(this); + entity2.restoreFrom(this); this.removeAfterChangingDimensions(); + // CraftBukkit start - Forward the CraftEntity to the new entity -+ this.getBukkitEntity().setHandle(entity); -+ entity.bukkitEntity = this.getBukkitEntity(); ++ this.getBukkitEntity().setHandle(entity2); ++ entity2.bukkitEntity = this.getBukkitEntity(); + // CraftBukkit end - entity.teleportSetPosition(PositionMoveRotation.of(teleporttransition), teleporttransition.relatives()); -- worldserver.addDuringTeleport(entity); -+ if (this.inWorld) worldserver.addDuringTeleport(entity); // CraftBukkit - Don't spawn the new entity if the current entity isn't spawned - Iterator iterator1 = list1.iterator(); + entity2.teleportSetPosition(PositionMoveRotation.of(teleporttransition), teleporttransition.relatives()); +- worldserver.addDuringTeleport(entity2); ++ if (this.inWorld) worldserver.addDuringTeleport(entity2); // CraftBukkit - Don't spawn the new entity if the current entity isn't spawned - while (iterator1.hasNext()) { -@@ -2995,8 +3465,9 @@ + for (Entity entity3 : list1) { + entity3.startRiding(entity2, true); +@@ -2950,8 +3414,9 @@ } protected void removeAfterChangingDimensions() { @@ -867,7 +901,7 @@ leashable.removeLeash(); } -@@ -3006,6 +3477,20 @@ +@@ -2961,6 +3426,20 @@ return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose())); } @@ -888,25 +922,24 @@ public boolean canUsePortal(boolean flag) { return (flag || !this.isPassenger()) && this.isAlive(); } -@@ -3134,9 +3619,15 @@ +@@ -3085,8 +3564,14 @@ return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE); } - public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1, boolean flag) { +- Entity entity = this.teleport(new TeleportTransition(worldserver, new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f1, set, TeleportTransition.DO_NOTHING)); + // CraftBukkit start + public final boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1, boolean flag) { + return teleportTo(worldserver, d0, d1, d2, set, f, f1, flag, PlayerTeleportEvent.TeleportCause.UNKNOWN); + } + + public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1, boolean flag, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { - float f2 = MathHelper.clamp(f1, -90.0F, 90.0F); -- Entity entity = this.teleport(new TeleportTransition(worldserver, new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f2, set, TeleportTransition.DO_NOTHING)); -+ Entity entity = this.teleport(new TeleportTransition(worldserver, new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f2, set, TeleportTransition.DO_NOTHING, cause)); ++ Entity entity = this.teleport(new TeleportTransition(worldserver, new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f1, set, TeleportTransition.DO_NOTHING, cause)); + // CraftBukkit end return entity != null; } -@@ -3258,7 +3749,26 @@ +@@ -3208,7 +3693,26 @@ } public final void setBoundingBox(AxisAlignedBB axisalignedbb) { @@ -934,7 +967,7 @@ } public final float getEyeHeight(EntityPose entitypose) { -@@ -3489,8 +3999,37 @@ +@@ -3433,8 +3937,37 @@ return 1; } @@ -973,7 +1006,7 @@ } public void lookAt(ArgumentAnchor.Anchor argumentanchor_anchor, Vec3D vec3d) { -@@ -3551,6 +4090,11 @@ +@@ -3495,6 +4028,11 @@ vec3d = vec3d.add(vec3d1); ++k1; } @@ -985,7 +1018,7 @@ } } } -@@ -3818,6 +4362,14 @@ +@@ -3766,6 +4304,14 @@ @Override public final void setRemoved(Entity.RemovalReason entity_removalreason) { diff --git a/nms-patches/net/minecraft/world/entity/EntityAgeable.patch b/nms-patches/net/minecraft/world/entity/EntityAgeable.patch index 77d10c6a1..070b302cd 100644 --- a/nms-patches/net/minecraft/world/entity/EntityAgeable.patch +++ b/nms-patches/net/minecraft/world/entity/EntityAgeable.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/EntityAgeable.java +++ b/net/minecraft/world/entity/EntityAgeable.java -@@ -21,6 +21,7 @@ - protected int age; - protected int forcedAge; +@@ -23,6 +23,7 @@ + protected int age = 0; + protected int forcedAge = 0; protected int forcedAgeTimer; + public boolean ageLocked; // CraftBukkit protected EntityAgeable(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -104,6 +105,7 @@ +@@ -106,6 +107,7 @@ super.addAdditionalSaveData(nbttagcompound); nbttagcompound.putInt("Age", this.getAge()); nbttagcompound.putInt("ForcedAge", this.forcedAge); @@ -16,15 +16,15 @@ } @Override -@@ -111,6 +113,7 @@ +@@ -113,6 +115,7 @@ super.readAdditionalSaveData(nbttagcompound); - this.setAge(nbttagcompound.getInt("Age")); - this.forcedAge = nbttagcompound.getInt("ForcedAge"); -+ this.ageLocked = nbttagcompound.getBoolean("AgeLocked"); // CraftBukkit + this.setAge(nbttagcompound.getIntOr("Age", 0)); + this.forcedAge = nbttagcompound.getIntOr("ForcedAge", 0); ++ this.ageLocked = nbttagcompound.getBooleanOr("AgeLocked", this.ageLocked); // CraftBukkit } @Override -@@ -125,7 +128,7 @@ +@@ -127,7 +130,7 @@ @Override public void aiStep() { super.aiStep(); diff --git a/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch b/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch index 3f2bb9412..418fda610 100644 --- a/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch +++ b/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/EntityAreaEffectCloud.java +++ b/net/minecraft/world/entity/EntityAreaEffectCloud.java -@@ -33,6 +33,12 @@ +@@ -32,6 +32,12 @@ + import net.minecraft.world.level.World; import net.minecraft.world.level.material.EnumPistonReaction; - import org.slf4j.Logger; +// CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftLivingEntity; @@ -12,17 +12,17 @@ + public class EntityAreaEffectCloud extends Entity implements TraceableEntity { - private static final Logger LOGGER = LogUtils.getLogger(); -@@ -200,7 +206,7 @@ + private static final int TIME_BETWEEN_APPLICATIONS = 5; +@@ -217,7 +223,7 @@ private void serverTick(WorldServer worldserver) { - if (this.tickCount >= this.waitTime + this.duration) { + if (this.duration != -1 && this.tickCount >= this.waitTime + this.duration) { - this.discard(); + this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } else { boolean flag = this.isWaiting(); boolean flag1 = this.tickCount < this.waitTime; -@@ -215,7 +221,7 @@ +@@ -232,7 +238,7 @@ if (this.radiusPerTick != 0.0F) { f += this.radiusPerTick; if (f < 0.5F) { @@ -31,21 +31,19 @@ return; } -@@ -249,11 +255,12 @@ +@@ -254,9 +260,10 @@ + List list1 = this.level().getEntitiesOfClass(EntityLiving.class, this.getBoundingBox()); + if (!list1.isEmpty()) { - Iterator iterator1 = list1.iterator(); - + List entities = new java.util.ArrayList(); // CraftBukkit - while (iterator1.hasNext()) { - EntityLiving entityliving = (EntityLiving) iterator1.next(); - + for (EntityLiving entityliving : list1) { if (!this.victims.containsKey(entityliving) && entityliving.isAffectedByPotions()) { - Stream stream = list.stream(); + Stream stream = list.stream(); // CraftBukkit - decompile error Objects.requireNonNull(entityliving); if (!stream.noneMatch(entityliving::canBeAffected)) { -@@ -262,6 +269,19 @@ +@@ -265,20 +272,33 @@ double d2 = d0 * d0 + d1 * d1; if (d2 <= (double) (f * f)) { @@ -63,14 +61,13 @@ + EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle(); + // CraftBukkit end this.victims.put(entityliving, this.tickCount + this.reapplicationDelay); - Iterator iterator2 = list.iterator(); -@@ -271,14 +291,14 @@ - if (((MobEffectList) mobeffect1.getEffect().value()).isInstantenous()) { - ((MobEffectList) mobeffect1.getEffect().value()).applyInstantenousEffect(worldserver, this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D); + for (MobEffect mobeffect : list) { + if (((MobEffectList) mobeffect.getEffect().value()).isInstantenous()) { + ((MobEffectList) mobeffect.getEffect().value()).applyInstantenousEffect(worldserver, this, this.getOwner(), entityliving, mobeffect.getAmplifier(), 0.5D); } else { -- entityliving.addEffect(new MobEffect(mobeffect1), this); -+ entityliving.addEffect(new MobEffect(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit +- entityliving.addEffect(new MobEffect(mobeffect), this); ++ entityliving.addEffect(new MobEffect(mobeffect), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit } } @@ -83,7 +80,7 @@ } @@ -288,7 +308,7 @@ - if (this.durationOnUse != 0) { + if (this.durationOnUse != 0 && this.duration != -1) { this.duration += this.durationOnUse; if (this.duration <= 0) { - this.discard(); @@ -91,3 +88,12 @@ return; } } +@@ -381,7 +401,7 @@ + this.radiusOnUse = nbttagcompound.getFloatOr("RadiusOnUse", 0.0F); + this.radiusPerTick = nbttagcompound.getFloatOr("RadiusPerTick", 0.0F); + this.setRadius(nbttagcompound.getFloatOr("Radius", 3.0F)); +- this.ownerUUID = (UUID) nbttagcompound.read("Owner", UUIDUtil.CODEC).orElse((Object) null); ++ this.ownerUUID = (UUID) nbttagcompound.read("Owner", UUIDUtil.CODEC).orElse(null); // CraftBukkit - decompile error + RegistryOps registryops = this.registryAccess().createSerializationContext(DynamicOpsNBT.INSTANCE); + + this.setParticle((ParticleParam) nbttagcompound.read("Particle", Particles.CODEC, registryops).orElse(EntityAreaEffectCloud.DEFAULT_PARTICLE)); diff --git a/nms-patches/net/minecraft/world/entity/EntityCreature.patch b/nms-patches/net/minecraft/world/entity/EntityCreature.patch index 9834a2c81..d82686a5a 100644 --- a/nms-patches/net/minecraft/world/entity/EntityCreature.patch +++ b/nms-patches/net/minecraft/world/entity/EntityCreature.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityCreature.java +++ b/net/minecraft/world/entity/EntityCreature.java -@@ -11,6 +11,10 @@ +@@ -10,6 +10,10 @@ import net.minecraft.world.level.World; import net.minecraft.world.phys.Vec3D; diff --git a/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch b/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch index c41a98ad2..480bb2570 100644 --- a/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch +++ b/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityExperienceOrb.java +++ b/net/minecraft/world/entity/EntityExperienceOrb.java -@@ -25,6 +25,14 @@ +@@ -24,6 +24,14 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -14,17 +14,25 @@ + public class EntityExperienceOrb extends Entity { - private static final int LIFETIME = 6000; -@@ -68,6 +76,7 @@ - @Override - public void tick() { - super.tick(); + protected static final DataWatcherObject DATA_VALUE = DataWatcher.defineId(EntityExperienceOrb.class, DataWatcherRegistry.INT); +@@ -123,13 +131,14 @@ + + ++this.age; + if (this.age >= 6000) { +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + } + + } + } + + private void followNearbyPlayer() { + EntityHuman prevTarget = this.followingPlayer;// CraftBukkit - store old target - this.xo = this.getX(); - this.yo = this.getY(); - this.zo = this.getZ(); -@@ -93,7 +102,22 @@ - this.followingPlayer = null; + if (this.followingPlayer == null || this.followingPlayer.isSpectator() || this.followingPlayer.distanceToSqr((Entity) this) > 64.0D) { + EntityHuman entityhuman = this.level().getNearestPlayer(this, 8.0D); + +@@ -140,7 +149,22 @@ + } } - if (this.followingPlayer != null) { @@ -46,17 +54,8 @@ + // CraftBukkit end Vec3D vec3d = new Vec3D(this.followingPlayer.getX() - this.getX(), this.followingPlayer.getY() + (double) this.followingPlayer.getEyeHeight() / 2.0D - this.getY(), this.followingPlayer.getZ() - this.getZ()); double d0 = vec3d.lengthSqr(); - -@@ -121,7 +145,7 @@ - - ++this.age; - if (this.age >= 6000) { -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause - } - - } -@@ -190,7 +214,7 @@ + double d1 = 1.0D - Math.sqrt(d0) / 8.0D; +@@ -205,7 +229,7 @@ private void merge(EntityExperienceOrb entityexperienceorb) { this.count += entityexperienceorb.count; this.age = Math.min(this.age, entityexperienceorb.age); @@ -65,7 +64,7 @@ } private void setUnderwaterMovement() { -@@ -215,7 +239,7 @@ +@@ -230,7 +254,7 @@ this.markHurt(); this.health = (int) ((float) this.health - f); if (this.health <= 0) { @@ -74,14 +73,14 @@ } return true; -@@ -242,17 +266,17 @@ +@@ -257,17 +281,17 @@ public void playerTouch(EntityHuman entityhuman) { if (entityhuman instanceof EntityPlayer entityplayer) { if (entityhuman.takeXpDelay == 0) { - entityhuman.takeXpDelay = 2; + entityhuman.takeXpDelay = CraftEventFactory.callPlayerXpCooldownEvent(entityhuman, 2, PlayerExpCooldownChangeEvent.ChangeReason.PICKUP_ORB).getNewCooldown(); // CraftBukkit - entityhuman.takeXpDelay = 2; entityhuman.take(this, 1); - int i = this.repairPlayerItems(entityplayer, this.value); + int i = this.repairPlayerItems(entityplayer, this.getValue()); if (i > 0) { - entityhuman.giveExperiencePoints(i); @@ -95,7 +94,7 @@ } } -@@ -266,12 +290,20 @@ +@@ -281,12 +305,20 @@ ItemStack itemstack = ((EnchantedItemInUse) optional.get()).itemStack(); int j = EnchantmentManager.modifyDurabilityToRepairFromXp(entityplayer.serverLevel(), itemstack, i); int k = Math.min(j, itemstack.getDamageValue()); @@ -112,11 +111,11 @@ int l = i - k * i / j; if (l > 0) { -+ this.value = l; // CraftBukkit - update exp value of orb for PlayerItemMendEvent calls ++ this.setValue(l); // CraftBukkit - update exp value of orb for PlayerItemMendEvent calls return this.repairPlayerItems(entityplayer, l); } } -@@ -291,6 +323,24 @@ +@@ -312,6 +344,24 @@ } public static int getExperienceValue(int i) { diff --git a/nms-patches/net/minecraft/world/entity/EntityInsentient.patch b/nms-patches/net/minecraft/world/entity/EntityInsentient.patch index 0ad51e354..5b75be2f9 100644 --- a/nms-patches/net/minecraft/world/entity/EntityInsentient.patch +++ b/nms-patches/net/minecraft/world/entity/EntityInsentient.patch @@ -1,12 +1,16 @@ --- a/net/minecraft/world/entity/EntityInsentient.java +++ b/net/minecraft/world/entity/EntityInsentient.java -@@ -85,6 +85,18 @@ - import net.minecraft.world.level.storage.loot.parameters.LootContextParameters; +@@ -83,6 +83,23 @@ import net.minecraft.world.phys.AxisAlignedBB; + import net.minecraft.world.ticks.ContainerSingleItem; +// CraftBukkit start ++import java.util.Arrays; ++import org.bukkit.Location; +import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.entity.CraftLivingEntity; ++import org.bukkit.entity.HumanEntity; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityRemoveEvent; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; @@ -14,12 +18,13 @@ +import org.bukkit.event.entity.EntityTransformEvent; +import org.bukkit.event.entity.EntityUnleashEvent; +import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason; ++import org.bukkit.inventory.InventoryHolder; +// CraftBukkit end + public abstract class EntityInsentient extends EntityLiving implements EquipmentUser, Leashable, Targeting { - private static final DataWatcherObject DATA_MOB_FLAGS_ID = DataWatcher.defineId(EntityInsentient.class, DataWatcherRegistry.BYTE); -@@ -132,6 +144,8 @@ + private static final DataWatcherObject DATA_MOB_FLAGS_ID = DataWatcher.defineId(EntityInsentient.class, DataWatcherRegistry.BYTE); +@@ -126,6 +143,8 @@ private BlockPosition restrictCenter; private float restrictRadius; @@ -27,8 +32,8 @@ + protected EntityInsentient(EntityTypes entitytypes, World world) { super(entitytypes, world); - this.handItems = NonNullList.withSize(2, ItemStack.EMPTY); -@@ -160,6 +174,12 @@ + this.dropChances = DropChances.DEFAULT; +@@ -149,6 +168,12 @@ } @@ -41,7 +46,7 @@ protected void registerGoals() {} public static AttributeProvider.Builder createMobAttributes() { -@@ -264,11 +284,42 @@ +@@ -253,11 +278,42 @@ @Nullable protected final EntityLiving getTargetFromBrain() { @@ -85,7 +90,7 @@ } @Override -@@ -399,6 +450,12 @@ +@@ -379,6 +435,12 @@ return null; } @@ -98,7 +103,7 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(nbttagcompound); -@@ -473,13 +530,25 @@ +@@ -403,13 +465,25 @@ nbttagcompound.putBoolean("NoAI", this.isNoAi()); } @@ -108,37 +113,35 @@ @Override public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { super.readAdditionalSaveData(nbttagcompound); -- this.setCanPickUpLoot(nbttagcompound.getBoolean("CanPickUpLoot")); -- this.persistenceRequired = nbttagcompound.getBoolean("PersistenceRequired"); +- this.setCanPickUpLoot(nbttagcompound.getBooleanOr("CanPickUpLoot", false)); +- this.persistenceRequired = nbttagcompound.getBooleanOr("PersistenceRequired", false); + // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it -+ if (nbttagcompound.contains("CanPickUpLoot", 99)) { -+ boolean data = nbttagcompound.getBoolean("CanPickUpLoot"); ++ if (nbttagcompound.contains("CanPickUpLoot")) { ++ boolean data = nbttagcompound.getBooleanOr("CanPickUpLoot", false); + if (isLevelAtLeast(nbttagcompound, 1) || data) { + this.setCanPickUpLoot(data); + } + } + -+ boolean data = nbttagcompound.getBoolean("PersistenceRequired"); ++ boolean data = nbttagcompound.getBooleanOr("PersistenceRequired", false); + if (isLevelAtLeast(nbttagcompound, 1) || data) { + this.persistenceRequired = data; + } + // CraftBukkit end - NBTTagList nbttaglist; - NBTTagCompound nbttagcompound1; - int i; -@@ -547,6 +616,11 @@ + RegistryOps registryops = this.registryAccess().createSerializationContext(DynamicOpsNBT.INSTANCE); - this.lootTableSeed = nbttagcompound.getLong("DeathLootTableSeed"); - this.setNoAi(nbttagcompound.getBoolean("NoAI")); + this.dropChances = (DropChances) nbttagcompound.read("drop_chances", DropChances.CODEC, registryops).orElse(DropChances.DEFAULT); +@@ -418,6 +492,9 @@ + this.lootTable = nbttagcompound.read("DeathLootTable", LootTable.KEY_CODEC); + this.lootTableSeed = nbttagcompound.getLongOr("DeathLootTableSeed", 0L); + this.setNoAi(nbttagcompound.getBooleanOr("NoAI", false)); + // CraftBukkit start -+ if (nbttagcompound.contains("Bukkit.Aware")) { -+ this.aware = nbttagcompound.getBoolean("Bukkit.Aware"); -+ } ++ this.aware = nbttagcompound.getBooleanOr("Bukkit.Aware", this.aware); + // CraftBukkit end } @Override -@@ -623,20 +697,26 @@ +@@ -490,20 +567,26 @@ protected void pickUpItem(WorldServer worldserver, EntityItem entityitem) { ItemStack itemstack = entityitem.getItem(); @@ -165,39 +168,39 @@ + public ItemStack equipItemIfPossible(WorldServer worldserver, ItemStack itemstack, EntityItem entityitem) { + // CraftBukkit end EnumItemSlot enumitemslot = this.getEquipmentSlotForItem(itemstack); - ItemStack itemstack1 = this.getItemBySlot(enumitemslot); - boolean flag = this.canReplaceCurrentItem(itemstack, itemstack1, enumitemslot); -@@ -647,11 +727,19 @@ - flag = itemstack1.isEmpty(); - } -- if (flag && this.canHoldItem(itemstack)) { -+ // CraftBukkit start -+ boolean canPickup = flag && this.canHoldItem(itemstack); -+ if (entityitem != null) { -+ canPickup = !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !canPickup).isCancelled(); -+ } -+ if (canPickup) { -+ // CraftBukkit end - double d0 = (double) this.getEquipmentDropChance(enumitemslot); - - if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) { -+ this.forceDrops = true; // CraftBukkit - this.spawnAtLocation(worldserver, itemstack1); -+ this.forceDrops = false; // CraftBukkit + if (!this.isEquippableInSlot(itemstack, enumitemslot)) { +@@ -518,11 +601,19 @@ + flag = itemstack1.isEmpty(); } - ItemStack itemstack2 = enumitemslot.limit(itemstack); -@@ -768,7 +856,7 @@ +- if (flag && this.canHoldItem(itemstack)) { ++ // CraftBukkit start ++ boolean canPickup = flag && this.canHoldItem(itemstack); ++ if (entityitem != null) { ++ canPickup = !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !canPickup).isCancelled(); ++ } ++ if (canPickup) { ++ // CraftBukkit end + double d0 = (double) this.dropChances.byEquipment(enumitemslot); + + if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) { ++ this.forceDrops = true; // CraftBukkit + this.spawnAtLocation(worldserver, itemstack1); ++ this.forceDrops = false; // CraftBukkit + } + + ItemStack itemstack2 = enumitemslot.limit(itemstack); +@@ -630,7 +721,7 @@ @Override public void checkDespawn() { if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.shouldDespawnInPeaceful()) { - this.discard(); + this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) { - EntityHuman entityhuman = this.level().getNearestPlayer(this, -1.0D); + Entity entity = this.level().getNearestPlayer(this, -1.0D); -@@ -778,14 +866,14 @@ +@@ -640,14 +731,14 @@ int j = i * i; if (d0 > (double) j && this.removeWhenFarAway(d0)) { @@ -214,7 +217,7 @@ } else if (d0 < (double) l) { this.noActionTime = 0; } -@@ -799,6 +887,7 @@ +@@ -661,6 +752,7 @@ @Override protected final void serverAiStep() { ++this.noActionTime; @@ -222,7 +225,59 @@ GameProfilerFiller gameprofilerfiller = Profiler.get(); gameprofilerfiller.push("sensing"); -@@ -1338,7 +1427,7 @@ +@@ -841,6 +933,51 @@ + public boolean stillValid(EntityHuman entityhuman) { + return entityhuman.getVehicle() == EntityInsentient.this || entityhuman.canInteractWithEntity((Entity) EntityInsentient.this, 4.0D); + } ++ ++ // CraftBukkit start - add fields and methods ++ public 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 who) { ++ transaction.add(who); ++ } ++ ++ @Override ++ public void onClose(CraftHumanEntity who) { ++ transaction.remove(who); ++ } ++ ++ @Override ++ public List getViewers() { ++ return transaction; ++ } ++ ++ @Override ++ public int getMaxStackSize() { ++ return maxStack; ++ } ++ ++ @Override ++ public void setMaxStackSize(int size) { ++ maxStack = size; ++ } ++ ++ @Override ++ public InventoryHolder getOwner() { ++ return (InventoryHolder) EntityInsentient.this.getBukkitEntity(); ++ } ++ ++ @Override ++ public Location getLocation() { ++ return EntityInsentient.this.getBukkitEntity().getLocation(); ++ } ++ // CraftBukkit end + }; + } + +@@ -1132,7 +1269,7 @@ if (itemstack.getItem() instanceof ItemMonsterEgg) { if (this.level() instanceof WorldServer) { ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem(); @@ -231,13 +286,11 @@ optional.ifPresent((entityinsentient) -> { this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient); -@@ -1389,12 +1478,19 @@ - return this.restrictRadius != -1.0F; - } +@@ -1185,6 +1322,13 @@ -+ // CraftBukkit start @Nullable public T convertTo(EntityTypes entitytypes, ConversionParams conversionparams, EntitySpawnReason entityspawnreason, ConversionParams.a conversionparams_a) { ++ // CraftBukkit start + return this.convertTo(entitytypes, conversionparams, entityspawnreason, conversionparams_a, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT); + } + @@ -247,12 +300,7 @@ if (this.isRemoved()) { return null; } else { -- T t0 = (EntityInsentient) entitytypes.create(this.level(), entityspawnreason); -+ T t0 = entitytypes.create(this.level(), EntitySpawnReason.CONVERSION); // CraftBukkit - decompile error - - if (t0 == null) { - return null; -@@ -1403,14 +1499,26 @@ +@@ -1197,14 +1341,26 @@ conversionparams_a.finalizeConversion(t0); World world = this.level(); @@ -281,23 +329,23 @@ } return t0; -@@ -1420,7 +1528,14 @@ +@@ -1214,7 +1370,14 @@ @Nullable public T convertTo(EntityTypes entitytypes, ConversionParams conversionparams, ConversionParams.a conversionparams_a) { -- return this.convertTo(entitytypes, conversionparams, EntitySpawnReason.CONVERSION, conversionparams_a); +- return (T) this.convertTo(entitytypes, conversionparams, EntitySpawnReason.CONVERSION, conversionparams_a); + // CraftBukkit start -+ return this.convertTo(entitytypes, conversionparams, conversionparams_a, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT); ++ return (T) this.convertTo(entitytypes, conversionparams, conversionparams_a, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT); + } + + @Nullable + public T convertTo(EntityTypes entitytypes, ConversionParams conversionparams, ConversionParams.a conversionparams_a, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) { -+ return this.convertTo(entitytypes, conversionparams, EntitySpawnReason.CONVERSION, conversionparams_a, transformReason, spawnReason); ++ return (T) this.convertTo(entitytypes, conversionparams, EntitySpawnReason.CONVERSION, conversionparams_a, transformReason, spawnReason); + // CraftBukkit end } @Nullable -@@ -1458,6 +1573,7 @@ +@@ -1252,6 +1415,7 @@ boolean flag1 = super.startRiding(entity, flag); if (flag1 && this.isLeashed()) { @@ -305,12 +353,12 @@ this.dropLeash(); } -@@ -1542,7 +1658,7 @@ - +@@ -1341,7 +1505,7 @@ if (f1 > 0.0F && entity instanceof EntityLiving) { - entityliving = (EntityLiving) entity; -- entityliving.knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F))); -+ entityliving.knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F)), this, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit + EntityLiving entityliving = (EntityLiving) entity; + +- entityliving.knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * ((float) Math.PI / 180F)), (double) (-MathHelper.cos(this.getYRot() * ((float) Math.PI / 180F)))); ++ entityliving.knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * ((float) Math.PI / 180F)), (double) (-MathHelper.cos(this.getYRot() * ((float) Math.PI / 180F))), this, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D)); } diff --git a/nms-patches/net/minecraft/world/entity/EntityLightning.patch b/nms-patches/net/minecraft/world/entity/EntityLightning.patch index 04073819b..1d3df93a2 100644 --- a/nms-patches/net/minecraft/world/entity/EntityLightning.patch +++ b/nms-patches/net/minecraft/world/entity/EntityLightning.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityLightning.java +++ b/net/minecraft/world/entity/EntityLightning.java -@@ -31,6 +31,11 @@ +@@ -29,6 +29,11 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -12,7 +12,7 @@ public class EntityLightning extends Entity { private static final int START_LIFE = 2; -@@ -120,7 +125,7 @@ +@@ -112,7 +117,7 @@ } } @@ -21,7 +21,7 @@ } else if (this.life < -this.random.nextInt(10)) { --this.flashes; this.life = 1; -@@ -129,7 +134,7 @@ +@@ -121,7 +126,7 @@ } } @@ -30,7 +30,7 @@ if (!(this.level() instanceof WorldServer)) { this.level().setSkyFlashTime(2); } else if (!this.visualOnly) { -@@ -169,8 +174,12 @@ +@@ -158,8 +163,12 @@ IBlockData iblockdata = BlockFireAbstract.getState(this.level(), blockposition); if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) { @@ -45,7 +45,7 @@ } for (int j = 0; j < i; ++j) { -@@ -178,8 +187,12 @@ +@@ -167,8 +176,12 @@ iblockdata = BlockFireAbstract.getState(this.level(), blockposition1); if (this.level().getBlockState(blockposition1).isAir() && iblockdata.canSurvive(this.level(), blockposition1)) { @@ -60,14 +60,3 @@ } } -@@ -247,8 +260,9 @@ - iblockdata = world.getBlockState(blockposition1); - } while (!(iblockdata.getBlock() instanceof WeatheringCopper)); - -+ BlockPosition blockposition1Final = blockposition1; // CraftBukkit - decompile error - WeatheringCopper.getPrevious(iblockdata).ifPresent((iblockdata1) -> { -- world.setBlockAndUpdate(blockposition1, iblockdata1); -+ world.setBlockAndUpdate(blockposition1Final, iblockdata1); // CraftBukkit - decompile error - }); - world.levelEvent(3002, blockposition1, -1); - return Optional.of(blockposition1); diff --git a/nms-patches/net/minecraft/world/entity/EntityLiving.patch b/nms-patches/net/minecraft/world/entity/EntityLiving.patch index 0e8567adf..dc765ccb7 100644 --- a/nms-patches/net/minecraft/world/entity/EntityLiving.patch +++ b/nms-patches/net/minecraft/world/entity/EntityLiving.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/EntityLiving.java +++ b/net/minecraft/world/entity/EntityLiving.java -@@ -136,6 +136,33 @@ - import net.minecraft.world.scores.ScoreboardTeam; +@@ -134,6 +134,36 @@ + import org.jetbrains.annotations.Contract; import org.slf4j.Logger; +// CraftBukkit start @@ -12,6 +12,8 @@ +import java.util.UUID; +import net.minecraft.nbt.NBTTagFloat; +import net.minecraft.nbt.NBTTagInt; ++import net.minecraft.nbt.NBTTagList; ++import net.minecraft.world.damagesource.DamageType; +import net.minecraft.world.item.component.Consumable; +import org.bukkit.Location; +import org.bukkit.craftbukkit.attribute.CraftAttributeMap; @@ -28,16 +30,17 @@ +import org.bukkit.event.entity.EntityRemoveEvent; +import org.bukkit.event.entity.EntityResurrectEvent; +import org.bukkit.event.entity.EntityTeleportEvent; ++import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerItemConsumeEvent; +// CraftBukkit end + public abstract class EntityLiving extends Entity implements Attackable { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -260,6 +287,19 @@ +@@ -246,6 +276,19 @@ protected boolean skipDropExperience; private final EnumMap>> activeLocationDependentEnchantments; - protected float appliedScale; + protected final EntityEquipment equipment; + // CraftBukkit start + public int expToDrop; + public ArrayList drops = new ArrayList(); @@ -54,33 +57,42 @@ protected EntityLiving(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -276,7 +316,9 @@ +@@ -253,7 +296,9 @@ + this.lastClimbablePos = Optional.empty(); this.activeLocationDependentEnchantments = new EnumMap(EnumItemSlot.class); - this.appliedScale = 1.0F; this.attributes = new AttributeMapBase(AttributeDefaults.getSupplier(entitytypes)); - this.setHealth(this.getMaxHealth()); + this.craftAttributes = new CraftAttributeMap(attributes); // CraftBukkit + // CraftBukkit - setHealth(getMaxHealth()) inlined and simplified to skip the instanceof check for EntityPlayer, as getBukkitEntity() is not initialized in constructor + this.entityData.set(EntityLiving.DATA_HEALTH_ID, (float) this.getAttribute(GenericAttributes.MAX_HEALTH).getValue()); + this.equipment = this.createEquipment(); this.blocksBuilding = true; - this.rotA = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); this.reapplyPosition(); -@@ -356,7 +398,13 @@ - double d8 = Math.min((double) (0.2F + f / 15.0F), 2.5D); +@@ -336,7 +381,13 @@ + double d8 = Math.min((double) 0.2F + d1 / 15.0D, 2.5D); int i = (int) (150.0D * d8); -- worldserver.sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); +- worldserver.sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, (double) 0.15F); + // CraftBukkit start - visiblity api + if (this instanceof EntityPlayer) { -+ worldserver.sendParticlesSource((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), false, false, d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); ++ worldserver.sendParticlesSource((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), false, false, d2, d3, d4, i, 0.0D, 0.0D, 0.0D, (double) 0.15F); + } else { -+ worldserver.sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); ++ worldserver.sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, (double) 0.15F); + } + // CraftBukkit end } } } -@@ -573,7 +621,7 @@ +@@ -367,7 +418,7 @@ + this.getSleepingPos().ifPresent(this::setPosToBed); + } + +- WorldServer worldserver = this.level(); ++ WorldServer worldserver = (WorldServer) this.level(); // CraftBukkit - decompile error + + if (worldserver instanceof WorldServer worldserver1) { + EnchantmentManager.tickEffects(worldserver1, this); +@@ -541,7 +592,7 @@ ++this.deathTime; if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) { this.level().broadcastEntityEvent(this, (byte) 60); @@ -89,7 +101,7 @@ } } -@@ -679,13 +727,19 @@ +@@ -660,11 +711,17 @@ } public void onEquipItem(EnumItemSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1) { @@ -100,17 +112,15 @@ + public void onEquipItem(EnumItemSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1, boolean silent) { + // CraftBukkit end if (!this.level().isClientSide() && !this.isSpectator()) { - boolean flag = itemstack1.isEmpty() && itemstack.isEmpty(); - - if (!flag && !ItemStack.isSameItemSameComponents(itemstack, itemstack1) && !this.firstTick) { + if (!ItemStack.isSameItemSameComponents(itemstack, itemstack1) && !this.firstTick) { Equippable equippable = (Equippable) itemstack1.get(DataComponents.EQUIPPABLE); - if (!this.isSilent() && equippable != null && enumitemslot == equippable.slot()) { + if (!this.isSilent() && equippable != null && enumitemslot == equippable.slot() && !silent) { // CraftBukkit - this.level().playSeededSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), equippable.equipSound(), this.getSoundSource(), 1.0F, 1.0F, this.random.nextLong()); + this.level().playSeededSound((Entity) null, this.getX(), this.getY(), this.getZ(), this.getEquipSound(enumitemslot, itemstack1, equippable), this.getSoundSource(), 1.0F, 1.0F, this.random.nextLong()); } -@@ -699,6 +753,13 @@ +@@ -682,6 +739,13 @@ @Override public void remove(Entity.RemovalReason entity_removalreason) { @@ -124,7 +134,7 @@ if (entity_removalreason == Entity.RemovalReason.KILLED || entity_removalreason == Entity.RemovalReason.DISCARDED) { World world = this.level(); -@@ -709,7 +770,7 @@ +@@ -692,7 +756,7 @@ } } @@ -133,7 +143,7 @@ this.brain.clearMemories(); } -@@ -722,6 +783,7 @@ +@@ -701,6 +765,7 @@ mobeffect.onMobRemoved(worldserver, this, entity_removalreason); } @@ -141,26 +151,81 @@ this.activeEffects.clear(); } -@@ -781,6 +843,17 @@ +@@ -747,6 +812,13 @@ + + @Nullable + public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1) { ++ // CraftBukkit start - SPIGOT-2942: Add boolean to call event ++ return drop(itemstack, flag, flag1, true); ++ } ++ ++ @Nullable ++ public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1, boolean callEvent) { ++ // CraftBukkit end + if (itemstack.isEmpty()) { + return null; + } else if (this.level().isClientSide) { +@@ -756,6 +828,31 @@ + EntityItem entityitem = this.createItemStackToDrop(itemstack, flag, flag1); + + if (entityitem != null) { ++ // CraftBukkit start - fire PlayerDropItemEvent ++ if (callEvent && this instanceof EntityPlayer) { ++ Player player = (Player) this.getBukkitEntity(); ++ org.bukkit.entity.Item drop = (org.bukkit.entity.Item) entityitem.getBukkitEntity(); ++ ++ PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop); ++ this.level().getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand(); ++ if (flag1 && (cur == null || cur.getAmount() == 0)) { ++ // The complete stack was dropped ++ player.getInventory().setItemInHand(drop.getItemStack()); ++ } else if (flag1 && 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(entityitem); } + +@@ -767,7 +864,7 @@ + public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { + this.internalSetAbsorptionAmount(nbttagcompound.getFloatOr("AbsorptionAmount", 0.0F)); + if (this.level() != null && !this.level().isClientSide) { +- Optional optional = nbttagcompound.getList("attributes"); ++ Optional optional = nbttagcompound.getList("attributes"); // CraftBukkit - decompile error + AttributeMapBase attributemapbase = this.getAttributes(); + + java.util.Objects.requireNonNull(attributemapbase); +@@ -783,6 +880,17 @@ + this.activeEffects.put(mobeffect.getEffect(), mobeffect); } + // CraftBukkit start + if (nbttagcompound.contains("Bukkit.MaxHealth")) { + NBTBase nbtbase = nbttagcompound.get("Bukkit.MaxHealth"); + if (nbtbase.getId() == 5) { -+ this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(((NBTTagFloat) nbtbase).getAsDouble()); ++ this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(((NBTTagFloat) nbtbase).doubleValue()); + } else if (nbtbase.getId() == 3) { -+ this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(((NBTTagInt) nbtbase).getAsDouble()); ++ this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(((NBTTagInt) nbtbase).doubleValue()); + } + } + // CraftBukkit end + - if (nbttagcompound.contains("Health", 99)) { - this.setHealth(nbttagcompound.getFloat("Health")); - } -@@ -819,9 +892,32 @@ - + this.setHealth(nbttagcompound.getFloatOr("Health", this.getMaxHealth())); + this.hurtTime = nbttagcompound.getShortOr("HurtTime", (short) 0); + this.deathTime = nbttagcompound.getShortOr("DeathTime", (short) 0); +@@ -816,12 +924,35 @@ + this.equipment.setAll((EntityEquipment) nbttagcompound.read("equipment", EntityEquipment.CODEC, registryops).orElseGet(EntityEquipment::new)); } + // CraftBukkit start @@ -186,16 +251,19 @@ + // CraftBukkit end + protected void tickEffects() { - Iterator> iterator = this.activeEffects.keySet().iterator(); + World world = this.level(); -+ isTickingEffects = true; // CraftBukkit - try { - while (iterator.hasNext()) { - Holder holder = (Holder) iterator.next(); -@@ -831,6 +927,12 @@ - this.onEffectUpdated(mobeffect, true, (Entity) null); - })) { - if (!this.level().isClientSide) { + if (world instanceof WorldServer worldserver) { + Iterator> iterator = this.activeEffects.keySet().iterator(); + ++ isTickingEffects = true; // CraftBukkit + try { + while (iterator.hasNext()) { + Holder holder = (Holder) iterator.next(); +@@ -830,6 +961,12 @@ + if (!mobeffect.tickServer(worldserver, this, () -> { + this.onEffectUpdated(mobeffect, true, (Entity) null); + })) { + // CraftBukkit start + EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, mobeffect, null, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.EXPIRATION); + if (event.isCancelled()) { @@ -204,26 +272,26 @@ + // CraftBukkit end iterator.remove(); this.onEffectsRemoved(List.of(mobeffect)); - } -@@ -841,6 +943,17 @@ - } catch (ConcurrentModificationException concurrentmodificationexception) { - ; - } -+ // CraftBukkit start -+ isTickingEffects = false; -+ for (ProcessableEffect e : effectsToProcess) { -+ if (e.effect != null) { -+ addEffect(e.effect, e.cause); -+ } else { -+ removeEffect(e.type, e.cause); + } else if (mobeffect.getDuration() % 600 == 0) { +@@ -839,6 +976,17 @@ + } catch (ConcurrentModificationException concurrentmodificationexception) { + ; + } ++ // CraftBukkit start ++ isTickingEffects = false; ++ for (ProcessableEffect e : effectsToProcess) { ++ if (e.effect != null) { ++ addEffect(e.effect, e.cause); ++ } else { ++ removeEffect(e.type, e.cause); ++ } + } -+ } -+ effectsToProcess.clear(); -+ // CraftBukkit end ++ effectsToProcess.clear(); ++ // CraftBukkit end - if (this.effectsDirty) { - if (!this.level().isClientSide) { -@@ -952,17 +1065,36 @@ + if (this.effectsDirty) { + this.updateInvisibilityStatus(); +@@ -946,17 +1094,36 @@ this.entityData.set(EntityLiving.DATA_EFFECT_PARTICLES, List.of()); } @@ -264,7 +332,7 @@ } } -@@ -987,20 +1119,50 @@ +@@ -987,20 +1154,50 @@ return this.addEffect(mobeffect, (Entity) null); } @@ -316,18 +384,18 @@ flag = true; } -@@ -1031,13 +1193,39 @@ +@@ -1031,13 +1228,39 @@ return this.getType().is(TagsEntity.INVERTED_HEALING_AND_HARM); } + // CraftBukkit start @Nullable - public MobEffect removeEffectNoUpdate(Holder holder) { + public final MobEffect removeEffectNoUpdate(Holder holder) { + return removeEffectNoUpdate(holder, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN); + } + + @Nullable -+ public MobEffect removeEffectNoUpdate(Holder holder, EntityPotionEffectEvent.Cause cause) { ++ public final MobEffect removeEffectNoUpdate(Holder holder, EntityPotionEffectEvent.Cause cause) { + if (isTickingEffects) { + effectsToProcess.add(new ProcessableEffect(holder, cause)); + return null; @@ -357,7 +425,7 @@ if (mobeffect != null) { this.onEffectsRemoved(List.of(mobeffect)); -@@ -1142,20 +1330,55 @@ +@@ -1129,20 +1352,55 @@ } @@ -414,7 +482,7 @@ this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.clamp(f, 0.0F, this.getMaxHealth())); } -@@ -1167,7 +1390,7 @@ +@@ -1154,7 +1412,7 @@ public boolean hurtServer(WorldServer worldserver, DamageSource damagesource, float f) { if (this.isInvulnerableTo(worldserver, damagesource)) { return false; @@ -423,23 +491,16 @@ return false; } else if (damagesource.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -1182,10 +1405,11 @@ +@@ -1169,38 +1427,64 @@ } float f1 = f; -- boolean flag = false; -+ boolean flag = f > 0.0F && this.isDamageSourceBlocked(damagesource); // Copied from below - float f2 = 0.0F; ++ /* // CraftBukkit start - Moved into handleEntityDamage(DamageSource, float) for get f and actuallyHurt(DamageSource, float, EntityDamageEvent) for handle damage + float f2 = this.applyItemBlocking(worldserver, damagesource, f); -- if (f > 0.0F && this.isDamageSourceBlocked(damagesource)) { -+ // CraftBukkit - Moved into handleEntityDamage(DamageSource, float) for get f and actuallyHurt(DamageSource, float, EntityDamageEvent) for handle damage -+ if (false && f > 0.0F && this.isDamageSourceBlocked(damagesource)) { - this.hurtCurrentlyUsedShield(f); - f2 = f; - f = 0.0F; -@@ -1202,15 +1426,26 @@ - flag = true; - } + f -= f2; + boolean flag = f2 > 0.0F; ++ */ // CraftBukkit end - if (damagesource.is(DamageTypeTags.IS_FREEZING) && this.getType().is(TagsEntity.FREEZE_HURTS_EXTRA_TYPES)) { + // CraftBukkit - Moved into handleEntityDamage(DamageSource, float) for get f @@ -458,15 +519,18 @@ + EntityDamageEvent event = handleEntityDamage(damagesource, f); + f = 0; + f += (float) event.getDamage(DamageModifier.BASE); -+ f += (float) event.getDamage(DamageModifier.BLOCKING); + f += (float) event.getDamage(DamageModifier.FREEZING); + f += (float) event.getDamage(DamageModifier.HARD_HAT); ++ ++ float f2 = (float) -event.getDamage(DamageModifier.BLOCKING); ++ ++ f -= f2; ++ boolean flag = f2 > 0.0F; + // CraftBukkit end + - this.walkAnimation.setSpeed(1.5F); if (Float.isNaN(f) || Float.isInfinite(f)) { f = Float.MAX_VALUE; -@@ -1218,18 +1453,27 @@ + } boolean flag1 = true; @@ -498,7 +562,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; } -@@ -1243,7 +1487,7 @@ +@@ -1216,7 +1500,7 @@ worldserver.broadcastDamageEvent(this, damagesource); } @@ -507,17 +571,17 @@ this.markHurt(); } -@@ -1263,7 +1507,7 @@ +@@ -1236,7 +1520,7 @@ d1 = damagesource.getSourcePosition().z() - this.getZ(); } -- this.knockback(0.4000000059604645D, d0, d1); -+ this.knockback(0.4000000059604645D, d0, d1, entity1, entity1 == null ? EntityKnockbackEvent.KnockbackCause.DAMAGE : EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit +- this.knockback((double) 0.4F, d0, d1); ++ this.knockback((double) 0.4F, d0, d1, entity, entity == null ? EntityKnockbackEvent.KnockbackCause.DAMAGE : EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit if (!flag) { this.indicateDamage(d0, d1); } -@@ -1282,12 +1526,12 @@ - this.playHurtSound(damagesource); +@@ -1257,13 +1541,13 @@ + this.playSecondaryHurtSound(damagesource); } - boolean flag2 = !flag || f > 0.0F; @@ -526,29 +590,78 @@ if (flag2) { this.lastDamageSource = damagesource; this.lastDamageStamp = this.level().getGameTime(); -- Iterator iterator = this.getActiveEffects().iterator(); -+ Iterator iterator = new LinkedList<>(this.getActiveEffects()).iterator(); // CraftBukkit - SPIGOT-7999: copy to prevent CME in unrelated events - while (iterator.hasNext()) { - MobEffect mobeffect = (MobEffect) iterator.next(); -@@ -1363,7 +1607,7 @@ +- for (MobEffect mobeffect : this.getActiveEffects()) { ++ for (MobEffect mobeffect : new LinkedList<>(this.getActiveEffects())) { // CraftBukkit - SPIGOT-7999: copy to prevent CME in unrelated events + mobeffect.onMobHurt(worldserver, this, damagesource, f); + } + } +@@ -1290,6 +1574,12 @@ } - protected void blockedByShield(EntityLiving entityliving) { + public float applyItemBlocking(WorldServer worldserver, DamageSource damagesource, float f) { ++ // CraftBukkit start ++ return actuallyDoItemBlocking(worldserver, damagesource, calculateItemBlocking(damagesource, f)); ++ } ++ ++ private float calculateItemBlocking(DamageSource damagesource, float f) { ++ // CraftBukkit end + if (f <= 0.0F) { + return 0.0F; + } else { +@@ -1301,7 +1591,7 @@ + BlocksAttacks blocksattacks = (BlocksAttacks) itemstack.get(DataComponents.BLOCKS_ATTACKS); + + if (blocksattacks != null) { +- Optional optional = blocksattacks.bypassedBy(); ++ Optional> optional = blocksattacks.bypassedBy(); // CraftBukkit - decompile error + + java.util.Objects.requireNonNull(damagesource); + if (!(Boolean) optional.map(damagesource::is).orElse(false)) { +@@ -1330,6 +1620,26 @@ + + float f1 = blocksattacks.resolveBlockedDamage(damagesource, f, d0); + ++ // CraftBukkit start ++ return f1; ++ } ++ } ++ ++ return 0.0F; ++ } ++ } ++ } ++ ++ private float actuallyDoItemBlocking(WorldServer worldserver, DamageSource damagesource, float f1) { ++ { ++ { ++ ItemStack itemstack = this.getItemBlockingWith(); ++ ++ if (itemstack != null) { ++ BlocksAttacks blocksattacks = (BlocksAttacks) itemstack.get(DataComponents.BLOCKS_ATTACKS); ++ ++ if (blocksattacks != null) { ++ // CraftBukkit end + blocksattacks.hurtBlockingItem(this.level(), itemstack, this, this.getUsedItemHand(), f1); + if (!damagesource.is(DamageTypeTags.IS_PROJECTILE)) { + Entity entity1 = damagesource.getDirectEntity(); +@@ -1395,7 +1705,7 @@ + } + + protected void blockedByItem(EntityLiving entityliving) { - entityliving.knockback(0.5D, entityliving.getX() - this.getX(), entityliving.getZ() - this.getZ()); + entityliving.knockback(0.5D, entityliving.getX() - this.getX(), entityliving.getZ() - this.getZ(), null, EntityKnockbackEvent.KnockbackCause.SHIELD_BLOCK); // CraftBukkit } private boolean checkTotemDeathProtection(DamageSource damagesource) { -@@ -1375,20 +1619,33 @@ - EnumHand[] aenumhand = EnumHand.values(); - int i = aenumhand.length; +@@ -1405,19 +1715,32 @@ + ItemStack itemstack = null; + DeathProtection deathprotection = null; + // CraftBukkit start + EnumHand hand = null; + ItemStack itemstack1 = ItemStack.EMPTY; - for (int j = 0; j < i; ++j) { - EnumHand enumhand = aenumhand[j]; + for (EnumHand enumhand : EnumHand.values()) { - ItemStack itemstack1 = this.getItemInHand(enumhand); + itemstack1 = this.getItemInHand(enumhand); @@ -557,7 +670,7 @@ + hand = enumhand; // CraftBukkit itemstack = itemstack1.copy(); - itemstack1.shrink(1); -+ // itemstack1.subtract(1); // CraftBukkit ++ // itemstack1.shrink(1); // CraftBukkit break; } } @@ -578,7 +691,7 @@ EntityPlayer entityplayer = (EntityPlayer) this; entityplayer.awardStat(StatisticList.ITEM_USED.get(itemstack.getItem())); -@@ -1512,14 +1769,22 @@ +@@ -1516,14 +1839,22 @@ IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState(); if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) { @@ -603,9 +716,9 @@ this.level().addFreshEntity(entityitem); } } -@@ -1530,22 +1795,37 @@ +@@ -1534,22 +1865,37 @@ protected void dropAllDeathLoot(WorldServer worldserver, DamageSource damagesource) { - boolean flag = this.lastHurtByPlayerTime > 0; + boolean flag = this.lastHurtByPlayerMemoryTime > 0; + this.dropEquipment(worldserver); // CraftBukkit - from below if (this.shouldDropLoot() && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { @@ -626,9 +739,9 @@ - protected void dropExperience(WorldServer worldserver, @Nullable Entity entity) { + public int getExpReward(WorldServer worldserver, @Nullable Entity entity) { // CraftBukkit - if (!this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) { + if (!this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerMemoryTime > 0 && this.shouldDropExperience() && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) { - EntityExperienceOrb.award(worldserver, this.position(), this.getExperienceReward(worldserver, entity)); -+ return this.getExperienceReward(worldserver, entity); // CraftBukkit } ++ return this.getExperienceReward(worldserver, entity); // CraftBukkit } + return 0; // CraftBukkit @@ -644,7 +757,7 @@ } protected void dropCustomDeathLoot(WorldServer worldserver, DamageSource damagesource, boolean flag) {} -@@ -1612,9 +1892,14 @@ +@@ -1617,9 +1963,14 @@ } public void knockback(double d0, double d1, double d2) { @@ -661,7 +774,7 @@ Vec3D vec3d; -@@ -1624,7 +1909,14 @@ +@@ -1629,7 +1980,14 @@ Vec3D vec3d1 = (new Vec3D(d1, 0.0D, d2)).normalize().scale(d0); @@ -677,7 +790,7 @@ } } -@@ -1683,6 +1975,20 @@ +@@ -1684,6 +2042,20 @@ return new EntityLiving.a(SoundEffects.GENERIC_SMALL_FALL, SoundEffects.GENERIC_BIG_FALL); } @@ -698,8 +811,8 @@ public Optional getLastClimbablePos() { return this.lastClimbablePos; } -@@ -1757,9 +2063,14 @@ - int i = this.calculateFallDamage(f, f1); +@@ -1755,9 +2127,14 @@ + int i = this.calculateFallDamage(d0, f); if (i > 0) { + // CraftBukkit start @@ -714,7 +827,7 @@ return true; } else { return flag; -@@ -1830,7 +2141,7 @@ +@@ -1826,7 +2203,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) { if (!damagesource.is(DamageTypeTags.BYPASSES_ARMOR)) { @@ -723,17 +836,17 @@ f = CombatMath.getDamageAfterAbsorb(this, f, damagesource, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS)); } -@@ -1841,7 +2152,8 @@ +@@ -1837,7 +2214,8 @@ if (damagesource.is(DamageTypeTags.BYPASSES_EFFECTS)) { return f; } 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 j = 25 - i; float f1 = f * (float) j; -@@ -1884,15 +2196,141 @@ +@@ -1880,15 +2258,136 @@ } } @@ -769,7 +882,7 @@ + com.google.common.base.Function blocking = new com.google.common.base.Function() { + @Override + public Double apply(Double f) { -+ return -((EntityLiving.this.isDamageSourceBlocked(damagesource)) ? f : 0.0); ++ return -((double) EntityLiving.this.calculateItemBlocking(damagesource, f.floatValue())); + } + }; + float blockingModifier = blocking.apply((double) f).floatValue(); @@ -787,8 +900,8 @@ + com.google.common.base.Function resistance = new com.google.common.base.Function() { + @Override + public Double apply(Double f) { -+ if (!damagesource.is(DamageTypeTags.BYPASSES_EFFECTS) && EntityLiving.this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && !damagesource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { -+ int i = (EntityLiving.this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; ++ if (!damagesource.is(DamageTypeTags.BYPASSES_EFFECTS) && EntityLiving.this.hasEffect(MobEffects.RESISTANCE) && !damagesource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { ++ int i = (EntityLiving.this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; + int j = 25 - i; + float f1 = f.floatValue() * (float) j; + @@ -861,12 +974,7 @@ + + // Apply blocking code // PAIL: steal from above + if (event.getDamage(DamageModifier.BLOCKING) < 0) { -+ this.hurtCurrentlyUsedShield((float) -event.getDamage(DamageModifier.BLOCKING)); -+ Entity entity = damagesource.getDirectEntity(); -+ -+ if (entity instanceof EntityLiving) { -+ this.blockUsingShield((EntityLiving) entity); -+ } ++ actuallyDoItemBlocking(worldserver, damagesource, (float) -event.getDamage(DamageModifier.BLOCKING)); + } + + boolean human = this instanceof EntityHuman; @@ -882,7 +990,7 @@ if (f2 > 0.0F && f2 < 3.4028235E37F) { Entity entity = damagesource.getEntity(); -@@ -1904,13 +2342,48 @@ +@@ -1900,13 +2399,48 @@ } } @@ -933,7 +1041,7 @@ } public CombatTracker getCombatTracker() { -@@ -1935,9 +2408,19 @@ +@@ -1931,9 +2465,19 @@ } public final void setArrowCount(int i) { @@ -954,20 +1062,34 @@ public final int getStingerCount() { return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID); } -@@ -2182,6 +2665,12 @@ +@@ -2191,7 +2735,13 @@ + } - public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot); - -+ // CraftBukkit start -+ public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) { -+ this.setItemSlot(enumitemslot, itemstack); + public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { +- this.onEquipItem(enumitemslot, this.equipment.set(enumitemslot, itemstack), itemstack); ++ // CraftBukkit start ++ this.setItemSlot(enumitemslot, itemstack, false); + } -+ // CraftBukkit end + - public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack); ++ public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) { ++ this.onEquipItem(enumitemslot, this.equipment.set(enumitemslot, itemstack), itemstack, silent); ++ // CraftBukkit end + } - public Iterable getHandSlots() { -@@ -2634,7 +3123,7 @@ + public float getArmorCoverPercentage() { +@@ -2455,6 +3005,11 @@ + } + + public void stopFallFlying() { ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + this.setSharedFlag(7, true); + this.setSharedFlag(7, false); + } +@@ -2640,7 +3195,7 @@ } } @@ -976,7 +1098,7 @@ if (this.tickCount % 20 == 0) { this.getCombatTracker().recheckStatus(); } -@@ -2741,7 +3230,7 @@ +@@ -2728,7 +3283,7 @@ this.elytraAnimationState.tick(); } @@ -985,7 +1107,7 @@ Map map = this.collectEquipmentChanges(); if (map != null) { -@@ -3063,6 +3552,7 @@ +@@ -3005,6 +3560,7 @@ this.checkSlowFallDistance(); if (!this.level().isClientSide) { if (!this.canGlide()) { @@ -993,7 +1115,7 @@ this.setSharedFlag(7, false); return; } -@@ -3305,14 +3795,21 @@ +@@ -3192,14 +3748,21 @@ @Override public boolean isPickable() { @@ -1017,7 +1139,7 @@ @Override public float getYHeadRot() { return this.yHeadRot; -@@ -3483,7 +3980,30 @@ +@@ -3404,7 +3967,30 @@ this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -1049,7 +1171,7 @@ if (itemstack != this.useItem) { this.setItemInHand(enumhand, itemstack); -@@ -3568,6 +4088,12 @@ +@@ -3500,6 +4086,12 @@ } public boolean randomTeleport(double d0, double d1, double d2, boolean flag) { @@ -1062,7 +1184,7 @@ double d3 = this.getX(); double d4 = this.getY(); double d5 = this.getZ(); -@@ -3592,16 +4118,41 @@ +@@ -3524,16 +4116,41 @@ } if (flag2) { @@ -1107,7 +1229,7 @@ } else { if (flag) { world.broadcastEntityEvent(this, (byte) 46); -@@ -3613,7 +4164,7 @@ +@@ -3545,7 +4162,7 @@ entitycreature.getNavigation().stop(); } @@ -1116,7 +1238,7 @@ } } -@@ -3706,7 +4257,7 @@ +@@ -3638,7 +4255,7 @@ } public void stopSleeping() { @@ -1125,7 +1247,7 @@ World world = this.level(); java.util.Objects.requireNonNull(world); -@@ -3740,7 +4291,7 @@ +@@ -3672,7 +4289,7 @@ @Nullable public EnumDirection getBedOrientation() { diff --git a/nms-patches/net/minecraft/world/entity/EntityTameableAnimal.patch b/nms-patches/net/minecraft/world/entity/EntityTameableAnimal.patch index 3825a9b7f..7e6a4ab81 100644 --- a/nms-patches/net/minecraft/world/entity/EntityTameableAnimal.patch +++ b/nms-patches/net/minecraft/world/entity/EntityTameableAnimal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityTameableAnimal.java +++ b/net/minecraft/world/entity/EntityTameableAnimal.java -@@ -28,6 +28,12 @@ +@@ -26,6 +26,12 @@ import net.minecraft.world.level.pathfinder.PathfinderNormal; import net.minecraft.world.scores.ScoreboardTeam; @@ -13,18 +13,18 @@ public abstract class EntityTameableAnimal extends EntityAnimal implements OwnableEntity { public static final int TELEPORT_WHEN_DISTANCE_IS_SQ = 144; -@@ -295,7 +301,14 @@ +@@ -299,7 +305,14 @@ if (!this.canTeleportTo(new BlockPosition(i, j, k))) { return false; } else { -- this.moveTo((double) i + 0.5D, (double) j, (double) k + 0.5D, this.getYRot(), this.getXRot()); +- this.snapTo((double) i + 0.5D, (double) j, (double) k + 0.5D, this.getYRot(), this.getXRot()); + // CraftBukkit start + EntityTeleportEvent event = CraftEventFactory.callEntityTeleportEvent(this, (double) i + 0.5D, (double) j, (double) k + 0.5D); + if (event.isCancelled()) { + return false; + } + 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/nms-patches/net/minecraft/world/entity/EntityTypes.patch b/nms-patches/net/minecraft/world/entity/EntityTypes.patch index 7f9b3654d..67f386ab7 100644 --- a/nms-patches/net/minecraft/world/entity/EntityTypes.patch +++ b/nms-patches/net/minecraft/world/entity/EntityTypes.patch @@ -8,7 +8,7 @@ import org.slf4j.Logger; public class EntityTypes implements FeatureElement, EntityTypeTest { -@@ -191,7 +192,7 @@ +@@ -192,7 +193,7 @@ return Items.ACACIA_CHEST_BOAT; }), EnumCreatureType.MISC).noLootTable().sized(1.375F, 0.5625F).eyeHeight(0.5625F).clientTrackingRange(10)); public static final EntityTypes ALLAY = register("allay", EntityTypes.Builder.of(Allay::new, EnumCreatureType.CREATURE).sized(0.35F, 0.6F).eyeHeight(0.36F).ridingOffset(0.04F).clientTrackingRange(8).updateInterval(2)); @@ -17,7 +17,7 @@ public static final EntityTypes ARMADILLO = register("armadillo", EntityTypes.Builder.of(Armadillo::new, EnumCreatureType.CREATURE).sized(0.7F, 0.65F).eyeHeight(0.26F).clientTrackingRange(10)); public static final EntityTypes ARMOR_STAND = register("armor_stand", EntityTypes.Builder.of(EntityArmorStand::new, EnumCreatureType.MISC).sized(0.5F, 1.975F).eyeHeight(1.7775F).clientTrackingRange(10)); public static final EntityTypes ARROW = register("arrow", EntityTypes.Builder.of(EntityTippedArrow::new, EnumCreatureType.MISC).noLootTable().sized(0.5F, 0.5F).eyeHeight(0.13F).clientTrackingRange(4).updateInterval(20)); -@@ -399,7 +400,7 @@ +@@ -401,7 +402,7 @@ return ResourceKey.create(Registries.ENTITY_TYPE, MinecraftKey.withDefaultNamespace(s)); } @@ -26,50 +26,48 @@ return register(vanillaEntityId(s), entitytypes_builder); } -@@ -431,7 +432,14 @@ +@@ -433,6 +434,13 @@ @Nullable - public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1) { -- Consumer consumer; + public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityLiving entityliving, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1) { + // CraftBukkit start -+ return this.spawn(worldserver, itemstack, entityhuman, blockposition, entityspawnreason, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); ++ return this.spawn(worldserver, itemstack, entityliving, blockposition, entityspawnreason, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); + } + + @Nullable -+ public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { ++ public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityLiving entityliving, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + // CraftBukkit end -+ Consumer consumer; // CraftBukkit - decompile error + Consumer consumer; if (itemstack != null) { - consumer = createDefaultStackConfig(worldserver, itemstack, entityhuman); -@@ -440,7 +448,7 @@ +@@ -442,7 +450,7 @@ }; } -- return this.spawn(worldserver, consumer, blockposition, entityspawnreason, flag, flag1); -+ return this.spawn(worldserver, consumer, blockposition, entityspawnreason, flag, flag1, spawnReason); // CraftBukkit +- return (T) this.spawn(worldserver, consumer, blockposition, entityspawnreason, flag, flag1); ++ return (T) this.spawn(worldserver, consumer, blockposition, entityspawnreason, flag, flag1, spawnReason); // CraftBukkit } - public static Consumer createDefaultStackConfig(World world, ItemStack itemstack, @Nullable EntityHuman entityhuman) { + public static Consumer createDefaultStackConfig(World world, ItemStack itemstack, @Nullable EntityLiving entityliving) { @@ -464,21 +472,40 @@ CustomData customdata = (CustomData) itemstack.getOrDefault(DataComponents.ENTITY_DATA, CustomData.EMPTY); return !customdata.isEmpty() ? consumer.andThen((entity) -> { -- updateCustomEntityTag(world, entityhuman, entity, customdata); -+ try { updateCustomEntityTag(world, entityhuman, entity, customdata); } catch (Throwable t) { LOGGER.warn("Error loading spawn egg NBT", t); } // CraftBukkit - SPIGOT-5665 +- updateCustomEntityTag(world, entityliving, entity, customdata); ++ try { updateCustomEntityTag(world, entityliving, entity, customdata); } catch (Throwable t) { LOGGER.warn("Error loading spawn egg NBT", t); } // CraftBukkit - SPIGOT-5665 }) : consumer; } @Nullable public T spawn(WorldServer worldserver, BlockPosition blockposition, EntitySpawnReason entityspawnreason) { -- return this.spawn(worldserver, (Consumer) null, blockposition, entityspawnreason, false, false); +- return (T) this.spawn(worldserver, (Consumer) null, blockposition, entityspawnreason, false, false); + // CraftBukkit start -+ return this.spawn(worldserver, blockposition, entityspawnreason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); ++ return (T) this.spawn(worldserver, blockposition, entityspawnreason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } + + @Nullable + public T spawn(WorldServer worldserver, BlockPosition blockposition, EntitySpawnReason entityspawnreason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { -+ return this.spawn(worldserver, (Consumer) null, blockposition, entityspawnreason, false, false, spawnReason); // CraftBukkit - decompile error ++ return (T) this.spawn(worldserver, (Consumer) null, blockposition, entityspawnreason, false, false, spawnReason); // CraftBukkit + // CraftBukkit end } @@ -95,7 +93,7 @@ if (t0 instanceof EntityInsentient) { EntityInsentient entityinsentient = (EntityInsentient) t0; -@@ -657,7 +684,7 @@ +@@ -668,7 +695,7 @@ } return entity; @@ -103,22 +101,13 @@ + }).orElse(null); // CraftBukkit - decompile error } - public static Stream loadEntitiesRecursive(final List list, final World world, final EntitySpawnReason entityspawnreason) { -@@ -718,7 +745,7 @@ - - @Nullable - public T tryCast(Entity entity) { -- return entity.getType() == this ? entity : null; -+ return entity.getType() == this ? (T) entity : null; // CraftBukkit - decompile error - } - - @Override -@@ -791,7 +818,7 @@ + public static Stream loadEntitiesRecursive(List list, World world, EntitySpawnReason entityspawnreason) { +@@ -786,7 +813,7 @@ this.canSpawnFarFromPlayer = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC; } - public static EntityTypes.Builder of(EntityTypes.b entitytypes_b, EnumCreatureType enumcreaturetype) { + public static EntityTypes.Builder of(EntityTypes.b entitytypes_b, EnumCreatureType enumcreaturetype) { // CraftBukkit - decompile error - return new EntityTypes.Builder<>(entitytypes_b, enumcreaturetype); + return new EntityTypes.Builder(entitytypes_b, enumcreaturetype); } diff --git a/nms-patches/net/minecraft/world/entity/IEntityAngerable.patch b/nms-patches/net/minecraft/world/entity/IEntityAngerable.patch index 13eea45b8..db72789a2 100644 --- a/nms-patches/net/minecraft/world/entity/IEntityAngerable.patch +++ b/nms-patches/net/minecraft/world/entity/IEntityAngerable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/IEntityAngerable.java +++ b/net/minecraft/world/entity/IEntityAngerable.java -@@ -9,6 +9,10 @@ +@@ -10,6 +10,10 @@ import net.minecraft.world.level.GameRules; import net.minecraft.world.level.World; @@ -11,24 +11,23 @@ public interface IEntityAngerable { String TAG_ANGER_TIME = "AngerTime"; -@@ -48,14 +52,14 @@ - if (entity instanceof EntityInsentient) { - EntityInsentient entityinsentient = (EntityInsentient) entity; +@@ -34,13 +38,13 @@ + default void readPersistentAngerSaveData(World world, NBTTagCompound nbttagcompound) { + this.setRemainingPersistentAngerTime(nbttagcompound.getIntOr("AngerTime", 0)); + if (world instanceof WorldServer worldserver) { +- UUID uuid = (UUID) nbttagcompound.read("AngryAt", UUIDUtil.CODEC).orElse((Object) null); ++ UUID uuid = (UUID) nbttagcompound.read("AngryAt", UUIDUtil.CODEC).orElse(null); // CraftBukkit - decompile error -- this.setTarget(entityinsentient); -+ this.setTarget(entityinsentient, EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit - this.setLastHurtByMob(entityinsentient); - } + this.setPersistentAngerTarget(uuid); + Entity entity = uuid != null ? worldserver.getEntity(uuid) : null; - if (entity instanceof EntityHuman) { - EntityHuman entityhuman = (EntityHuman) entity; + if (entity instanceof EntityLiving entityliving) { +- this.setTarget(entityliving); ++ this.setTarget(entityliving, EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit + } -- this.setTarget(entityhuman); -+ this.setTarget(entityhuman, EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit - this.setLastHurtByPlayer(entityhuman); - } - -@@ -114,7 +118,7 @@ + } +@@ -96,7 +100,7 @@ default void stopBeingAngry() { this.setLastHurtByMob((EntityLiving) null); this.setPersistentAngerTarget((UUID) null); @@ -37,7 +36,7 @@ this.setRemainingPersistentAngerTime(0); } -@@ -127,6 +131,8 @@ +@@ -107,6 +111,8 @@ void setTarget(@Nullable EntityLiving entityliving); diff --git a/nms-patches/net/minecraft/world/entity/IEntitySelector.patch b/nms-patches/net/minecraft/world/entity/IEntitySelector.patch index 35099c5ae..fa5c112ad 100644 --- a/nms-patches/net/minecraft/world/entity/IEntitySelector.patch +++ b/nms-patches/net/minecraft/world/entity/IEntitySelector.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/IEntitySelector.java +++ b/net/minecraft/world/entity/IEntitySelector.java -@@ -43,7 +43,7 @@ - ScoreboardTeamBase.EnumTeamPush scoreboardteambase_enumteampush = scoreboardteam == null ? ScoreboardTeamBase.EnumTeamPush.ALWAYS : scoreboardteam.getCollisionRule(); +@@ -52,7 +52,7 @@ + ScoreboardTeamBase.EnumTeamPush scoreboardteambase_enumteampush = scoreboardteambase == null ? ScoreboardTeamBase.EnumTeamPush.ALWAYS : scoreboardteambase.getCollisionRule(); - return (Predicate) (scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.NEVER ? Predicates.alwaysFalse() : IEntitySelector.NO_SPECTATORS.and((entity1) -> { + return (Predicate) (scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.NEVER ? Predicates.alwaysFalse() : IEntitySelector.NO_SPECTATORS.and((entity1) -> { - if (!entity1.isPushable()) { + if (!entity1.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(entity1)) { // CraftBukkit - collidable API return false; - } else if (entity.level().isClientSide && (!(entity1 instanceof EntityHuman) || !((EntityHuman) entity1).isLocalPlayer())) { - return false; + } else { + if (entity.level().isClientSide) { diff --git a/nms-patches/net/minecraft/world/entity/Interaction.patch b/nms-patches/net/minecraft/world/entity/Interaction.patch index e19f5f602..cd8147717 100644 --- a/nms-patches/net/minecraft/world/entity/Interaction.patch +++ b/nms-patches/net/minecraft/world/entity/Interaction.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/Interaction.java +++ b/net/minecraft/world/entity/Interaction.java -@@ -27,6 +27,12 @@ +@@ -21,6 +21,12 @@ + import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; - import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.world.damagesource.DamageSource; @@ -12,17 +12,19 @@ + public class Interaction extends Entity implements Attackable, Targeting { - private static final Logger LOGGER = LogUtils.getLogger(); -@@ -65,7 +71,7 @@ - this.setHeight(nbttagcompound.getFloat("height")); - } - -- DataResult dataresult; -+ DataResult> dataresult; // CraftBukkit - decompile error - Logger logger; - - if (nbttagcompound.contains("attack")) { -@@ -145,9 +151,16 @@ + private static final DataWatcherObject DATA_WIDTH_ID = DataWatcher.defineId(Interaction.class, DataWatcherRegistry.FLOAT); +@@ -55,8 +61,8 @@ + protected void readAdditionalSaveData(NBTTagCompound nbttagcompound) { + this.setWidth(nbttagcompound.getFloatOr("width", 1.0F)); + this.setHeight(nbttagcompound.getFloatOr("height", 1.0F)); +- this.attack = (Interaction.PlayerAction) nbttagcompound.read("attack", Interaction.PlayerAction.CODEC).orElse((Object) null); +- this.interaction = (Interaction.PlayerAction) nbttagcompound.read("interaction", Interaction.PlayerAction.CODEC).orElse((Object) null); ++ this.attack = (Interaction.PlayerAction) nbttagcompound.read("attack", Interaction.PlayerAction.CODEC).orElse(null); // CraftBukkit - decompile error ++ this.interaction = (Interaction.PlayerAction) nbttagcompound.read("interaction", Interaction.PlayerAction.CODEC).orElse(null); // CraftBukkit - decompile error + this.setResponse(nbttagcompound.getBooleanOr("response", false)); + this.setBoundingBox(this.makeBoundingBox()); + } +@@ -102,9 +108,16 @@ @Override public boolean skipAttackInteraction(Entity entity) { if (entity instanceof EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/entity/Leashable.patch b/nms-patches/net/minecraft/world/entity/Leashable.patch index eb60e25af..37a82ffe3 100644 --- a/nms-patches/net/minecraft/world/entity/Leashable.patch +++ b/nms-patches/net/minecraft/world/entity/Leashable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Leashable.java +++ b/net/minecraft/world/entity/Leashable.java -@@ -16,6 +16,11 @@ +@@ -17,6 +17,11 @@ import net.minecraft.world.level.IMaterial; import net.minecraft.world.level.World; @@ -12,7 +12,7 @@ public interface Leashable { String LEASH_TAG = "leash"; -@@ -45,7 +50,7 @@ +@@ -46,11 +51,11 @@ default void setDelayedLeashHolderId(int i) { this.setLeashData(new Leashable.a(i)); @@ -21,28 +21,27 @@ } default void readLeashData(NBTTagCompound nbttagcompound) { -@@ -64,7 +69,7 @@ - return new Leashable.a(Either.left(nbttagcompound.getCompound("leash").getUUID("UUID"))); - } else { - if (nbttagcompound.contains("leash", 11)) { -- Either either = (Either) GameProfileSerializer.readBlockPos(nbttagcompound, "leash").map(Either::right).orElse((Object) null); -+ Either either = (Either) GameProfileSerializer.readBlockPos(nbttagcompound, "leash").map(Either::right).orElse(null); // CraftBukkit - decompile error +- Leashable.a leashable_a = (Leashable.a) nbttagcompound.read("leash", Leashable.a.CODEC).orElse((Object) null); ++ Leashable.a leashable_a = (Leashable.a) nbttagcompound.read("leash", Leashable.a.CODEC).orElse(null); // CraftBukkit - decompile error - if (either != null) { - return new Leashable.a(either); -@@ -79,6 +84,11 @@ - if (leashable_a != null) { - Either either = leashable_a.delayedLeashInfo; - Entity entity = leashable_a.leashHolder; -+ // CraftBukkit start - SPIGOT-7487: Don't save (and possible drop) leash, when the holder was removed by a plugin + if (this.getLeashData() != null && leashable_a == null) { + this.removeLeash(); +@@ -60,6 +65,14 @@ + } + + default void writeLeashData(NBTTagCompound nbttagcompound, @Nullable Leashable.a leashable_a) { ++ // CraftBukkit start - SPIGOT-7487: Don't save (and possible drop) leash, when the holder was removed by a plugin ++ if (leashable_a != null) { ++ Entity entity = leashable_a.leashHolder; + if (entity != null && entity.pluginRemoved) { + return; + } -+ // CraftBukkit end ++ } ++ // CraftBukkit end + nbttagcompound.storeNullable("leash", Leashable.a.CODEC, leashable_a); + } - if (entity instanceof EntityLeash) { - EntityLeash entityleash = (EntityLeash) entity; -@@ -121,7 +131,9 @@ +@@ -85,7 +98,9 @@ } if (e0.tickCount > 100) { @@ -52,7 +51,7 @@ ((Leashable) e0).setLeashData((Leashable.a) null); } } -@@ -130,11 +142,11 @@ +@@ -94,11 +109,11 @@ } default void dropLeash() { @@ -66,7 +65,7 @@ } default void onLeashRemoved() {} -@@ -151,7 +163,9 @@ +@@ -115,7 +130,9 @@ WorldServer worldserver = (WorldServer) world; if (flag1) { @@ -76,7 +75,7 @@ } if (flag) { -@@ -171,7 +185,8 @@ +@@ -135,7 +152,8 @@ if (leashable_a != null && leashable_a.leashHolder != null) { if (!e0.isAlive() || !leashable_a.leashHolder.isAlive()) { @@ -86,7 +85,7 @@ ((Leashable) e0).dropLeash(); } else { ((Leashable) e0).removeLeash(); -@@ -205,13 +220,18 @@ +@@ -169,13 +187,18 @@ } default void leashTooFarBehaviour() { @@ -106,7 +105,7 @@ } private static void legacyElasticRangeLeashBehaviour(E e0, Entity entity, float f) { -@@ -223,7 +243,7 @@ +@@ -187,7 +210,7 @@ } default void setLeashedTo(Entity entity, boolean flag) { @@ -115,7 +114,7 @@ } private static void setLeashedTo(E e0, Entity entity, boolean flag) { -@@ -254,7 +274,7 @@ +@@ -218,7 +241,7 @@ @Nullable default Entity getLeashHolder() { diff --git a/nms-patches/net/minecraft/world/entity/SaddleStorage.patch b/nms-patches/net/minecraft/world/entity/SaddleStorage.patch index 087cd81c3..b20ec91ff 100644 --- a/nms-patches/net/minecraft/world/entity/SaddleStorage.patch +++ b/nms-patches/net/minecraft/world/entity/SaddleStorage.patch @@ -1,9 +1,10 @@ --- a/net/minecraft/world/entity/SaddleStorage.java +++ b/net/minecraft/world/entity/SaddleStorage.java -@@ -53,6 +53,14 @@ +@@ -49,4 +49,12 @@ + public int boostTimeTotal() { return (Integer) this.entityData.get(this.boostTimeAccessor); } - ++ + // CraftBukkit add setBoostTicks(int) + public void setBoostTicks(int ticks) { + this.boosting = true; @@ -11,7 +12,4 @@ + this.entityData.set(this.boostTimeAccessor, ticks); + } + // CraftBukkit end -+ - public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { - nbttagcompound.putBoolean("Saddle", this.hasSaddle()); - } + } diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorCareer.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorCareer.patch index ec8f9aad8..cc36fe567 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorCareer.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorCareer.patch @@ -14,17 +14,17 @@ public BehaviorCareer() {} @@ -37,7 +43,14 @@ - return villagerprofession.heldJobSite().test(holder); + return ((VillagerProfession) holder_c.value()).heldJobSite().test(holder); }).findFirst(); - }).ifPresent((villagerprofession) -> { -- entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(villagerprofession)); + }).ifPresent((holder_c) -> { +- entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(holder_c)); + // CraftBukkit start - Fire VillagerCareerChangeEvent where Villager gets employed -+ VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.CraftProfession.minecraftToBukkit(villagerprofession), VillagerCareerChangeEvent.ChangeReason.EMPLOYED); ++ VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.CraftProfession.minecraftHolderToBukkit(holder_c), VillagerCareerChangeEvent.ChangeReason.EMPLOYED); + if (event.isCancelled()) { + return; + } + -+ entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(CraftVillager.CraftProfession.bukkitToMinecraft(event.getProfession()))); ++ entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(CraftVillager.CraftProfession.bukkitToMinecraftHolder(event.getProfession()))); + // CraftBukkit end entityvillager.refreshBrain(worldserver); }); diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFarm.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFarm.patch index b02f71bc7..62d2e300c 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFarm.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFarm.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java -@@ -27,6 +27,11 @@ +@@ -26,6 +26,11 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.gameevent.GameEvent; @@ -12,18 +12,7 @@ public class BehaviorFarm extends Behavior { private static final int HARVEST_DURATION = 200; -@@ -82,8 +87,8 @@ - - protected void start(WorldServer worldserver, EntityVillager entityvillager, long i) { - if (i > this.nextOkStartTime && this.aboveFarmlandPos != null) { -- entityvillager.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(this.aboveFarmlandPos))); -- entityvillager.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(new BehaviorTarget(this.aboveFarmlandPos), 0.5F, 1))); -+ entityvillager.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(this.aboveFarmlandPos))); // CraftBukkit - decompile error -+ entityvillager.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(new BehaviorTarget(this.aboveFarmlandPos), 0.5F, 1))); // CraftBukkit - decompile error - } - - } -@@ -103,7 +108,9 @@ +@@ -102,7 +107,9 @@ Block block1 = worldserver.getBlockState(this.aboveFarmlandPos.below()).getBlock(); if (block instanceof BlockCrops && ((BlockCrops) block).isMaxAge(iblockdata)) { @@ -33,26 +22,15 @@ } if (iblockdata.isAir() && block1 instanceof BlockSoil && entityvillager.hasFarmSeeds()) { -@@ -120,9 +127,11 @@ +@@ -119,9 +126,11 @@ ItemBlock itemblock = (ItemBlock) item; IBlockData iblockdata1 = itemblock.getBlock().defaultBlockState(); + if (CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, iblockdata1)) { // CraftBukkit worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1); - worldserver.gameEvent((Holder) GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1)); + worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1)); flag = true; + } // CraftBukkit } } -@@ -142,8 +151,8 @@ - this.aboveFarmlandPos = this.getValidFarmland(worldserver); - if (this.aboveFarmlandPos != null) { - this.nextOkStartTime = i + 20L; -- entityvillager.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(new BehaviorTarget(this.aboveFarmlandPos), 0.5F, 1))); -- entityvillager.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(this.aboveFarmlandPos))); -+ entityvillager.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(new BehaviorTarget(this.aboveFarmlandPos), 0.5F, 1))); // CraftBukkit - decompile error -+ entityvillager.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(this.aboveFarmlandPos))); // CraftBukkit - decompile error - } - } - } diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.patch index b8033a44c..548c25276 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.patch @@ -19,7 +19,7 @@ - entityvillager.setAge(6000); - entityvillager1.setAge(6000); entityvillager2.setAge(-24000); - entityvillager2.moveTo(entityvillager.getX(), entityvillager.getY(), entityvillager.getZ(), 0.0F, 0.0F); + entityvillager2.snapTo(entityvillager.getX(), entityvillager.getY(), entityvillager.getZ(), 0.0F, 0.0F); - worldserver.addFreshEntityWithPassengers(entityvillager2); + // CraftBukkit start - call EntityBreedEvent + if (CraftEventFactory.callEntityBreedEvent(entityvillager2, entityvillager, entityvillager1, null, null, 0).isCancelled()) { @@ -33,11 +33,3 @@ worldserver.broadcastEntityEvent(entityvillager2, (byte) 12); return Optional.of(entityvillager2); } -@@ -127,6 +138,6 @@ - private void giveBedToChild(WorldServer worldserver, EntityVillager entityvillager, BlockPosition blockposition) { - GlobalPos globalpos = GlobalPos.of(worldserver.dimension(), blockposition); - -- entityvillager.getBrain().setMemory(MemoryModuleType.HOME, (Object) globalpos); -+ entityvillager.getBrain().setMemory(MemoryModuleType.HOME, globalpos); // CraftBukkit - decompile error - } - } diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorProfession.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorProfession.patch index 71a1571ee..af463ff59 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorProfession.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorProfession.patch @@ -13,18 +13,18 @@ public class BehaviorProfession { public BehaviorProfession() {} -@@ -17,7 +23,14 @@ - VillagerData villagerdata = entityvillager.getVillagerData(); +@@ -18,7 +24,14 @@ + boolean flag = !villagerdata.profession().is(VillagerProfession.NONE) && !villagerdata.profession().is(VillagerProfession.NITWIT); - if (villagerdata.getProfession() != VillagerProfession.NONE && villagerdata.getProfession() != VillagerProfession.NITWIT && entityvillager.getVillagerXp() == 0 && villagerdata.getLevel() <= 1) { -- entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(VillagerProfession.NONE)); + if (flag && entityvillager.getVillagerXp() == 0 && villagerdata.level() <= 1) { +- entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(worldserver.registryAccess(), VillagerProfession.NONE)); + // CraftBukkit start -+ VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.CraftProfession.minecraftToBukkit(VillagerProfession.NONE), VillagerCareerChangeEvent.ChangeReason.LOSING_JOB); ++ VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.CraftProfession.minecraftHolderToBukkit(worldserver.registryAccess().getOrThrow(VillagerProfession.NONE)), VillagerCareerChangeEvent.ChangeReason.LOSING_JOB); + if (event.isCancelled()) { + return false; + } + -+ entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(CraftVillager.CraftProfession.bukkitToMinecraft(event.getProfession()))); ++ entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(CraftVillager.CraftProfession.bukkitToMinecraftHolder(event.getProfession()))); + // CraftBukkit end entityvillager.refreshBrain(worldserver); return true; diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorUtil.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorUtil.patch index ffcb48472..dbce37f34 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorUtil.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorUtil.patch @@ -1,25 +1,5 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorUtil.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorUtil.java -@@ -60,7 +60,7 @@ - } - - public static void lookAtEntity(EntityLiving entityliving, EntityLiving entityliving1) { -- entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorPositionEntity(entityliving1, true))); -+ entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorPositionEntity(entityliving1, true))); // CraftBukkit - decompile error - } - - private static void setWalkAndLookTargetMemoriesToEachOther(EntityLiving entityliving, EntityLiving entityliving1, float f, int i) { -@@ -79,8 +79,8 @@ - public static void setWalkAndLookTargetMemories(EntityLiving entityliving, BehaviorPosition behaviorposition, float f, int i) { - MemoryTarget memorytarget = new MemoryTarget(behaviorposition, f, i); - -- entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (Object) behaviorposition); -- entityliving.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) memorytarget); -+ entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, behaviorposition); // CraftBukkit - decompile error -+ entityliving.getBrain().setMemory(MemoryModuleType.WALK_TARGET, memorytarget); // CraftBukkit - decompile error - } - - public static void throwItem(EntityLiving entityliving, ItemStack itemstack, Vec3D vec3d) { @@ -90,6 +90,7 @@ } diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.patch index eed68fa49..ab9ce4298 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java +++ b/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java -@@ -31,6 +31,13 @@ +@@ -29,6 +29,13 @@ import net.minecraft.world.level.pathfinder.PathfinderNormal; import net.minecraft.world.phys.Vec3D; @@ -14,7 +14,7 @@ public class PrepareRamNearestTarget extends Behavior { public static final int TIME_OUT_DURATION = 160; -@@ -63,6 +70,13 @@ +@@ -61,6 +68,13 @@ return this.ramTargeting.test(worldserver, entitycreature, entityliving); }); }).ifPresent((entityliving) -> { @@ -28,36 +28,7 @@ this.chooseRamPosition(entitycreature, entityliving); }); } -@@ -72,7 +86,7 @@ - - if (!behaviorcontroller.hasMemoryValue(MemoryModuleType.RAM_TARGET)) { - worldserver.broadcastEntityEvent(e0, (byte) 59); -- behaviorcontroller.setMemory(MemoryModuleType.RAM_COOLDOWN_TICKS, (Object) this.getCooldownOnFail.applyAsInt(e0)); -+ behaviorcontroller.setMemory(MemoryModuleType.RAM_COOLDOWN_TICKS, this.getCooldownOnFail.applyAsInt(e0)); // CraftBukkit - decompile error - } - - } -@@ -83,8 +97,8 @@ - - protected void tick(WorldServer worldserver, E e0, long i) { - if (!this.ramCandidate.isEmpty()) { -- e0.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(((PrepareRamNearestTarget.a) this.ramCandidate.get()).getStartPosition(), this.walkSpeed, 0))); -- e0.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorPositionEntity(((PrepareRamNearestTarget.a) this.ramCandidate.get()).getTarget(), true))); -+ e0.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(((PrepareRamNearestTarget.a) this.ramCandidate.get()).getStartPosition(), this.walkSpeed, 0))); // CraftBukkit - decompile error -+ e0.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorPositionEntity(((PrepareRamNearestTarget.a) this.ramCandidate.get()).getTarget(), true))); // CraftBukkit - decompile error - boolean flag = !((PrepareRamNearestTarget.a) this.ramCandidate.get()).getTarget().blockPosition().equals(((PrepareRamNearestTarget.a) this.ramCandidate.get()).getTargetPosition()); - - if (flag) { -@@ -101,7 +115,7 @@ - } - - if (i - (Long) this.reachedRamPositionTimestamp.get() >= (long) this.ramPrepareTime) { -- e0.getBrain().setMemory(MemoryModuleType.RAM_TARGET, (Object) this.getEdgeOfBlock(blockposition, ((PrepareRamNearestTarget.a) this.ramCandidate.get()).getTargetPosition())); -+ e0.getBrain().setMemory(MemoryModuleType.RAM_TARGET, this.getEdgeOfBlock(blockposition, ((PrepareRamNearestTarget.a) this.ramCandidate.get()).getTargetPosition())); // CraftBukkit - decompile error - worldserver.playSound((EntityHuman) null, (Entity) e0, (SoundEffect) this.getPrepareRamSound.apply(e0), SoundCategory.NEUTRAL, 1.0F, e0.getVoicePitch()); - this.ramCandidate = Optional.empty(); - } -@@ -153,7 +167,7 @@ +@@ -148,7 +162,7 @@ } NavigationAbstract navigationabstract = entitycreature.getNavigation(); diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.patch index e8c12b085..4af265541 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.java +++ b/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.java -@@ -39,6 +39,12 @@ +@@ -33,6 +33,12 @@ if (worldserver.getBlockState(blockposition2).isAir()) { IBlockData iblockdata = block.defaultBlockState(); @@ -11,5 +11,5 @@ + } + // CraftBukkit end worldserver.setBlock(blockposition2, iblockdata, 3); - worldserver.gameEvent((Holder) GameEvent.BLOCK_PLACE, blockposition2, GameEvent.a.of(entityliving, iblockdata)); - worldserver.playSound((EntityHuman) null, (Entity) entityliving, SoundEffects.FROG_LAY_SPAWN, SoundCategory.BLOCKS, 1.0F, 1.0F); + worldserver.gameEvent(GameEvent.BLOCK_PLACE, blockposition2, GameEvent.a.of(entityliving, iblockdata)); + worldserver.playSound((Entity) null, (Entity) entityliving, SoundEffects.FROG_LAY_SPAWN, SoundCategory.BLOCKS, 1.0F, 1.0F); diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.patch b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.patch index 34b12bbcc..8373bc93d 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.java +++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.java @@ -11,6 +11,10 @@ + import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; - import net.minecraft.world.level.block.state.predicate.BlockStatePredicate; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -11,16 +11,16 @@ public class PathfinderGoalEatTile extends PathfinderGoal { private static final int EAT_ANIMATION_TICKS = 40; -@@ -64,7 +68,7 @@ +@@ -66,7 +70,7 @@ BlockPosition blockposition = this.mob.blockPosition(); - if (PathfinderGoalEatTile.IS_TALL_GRASS.test(this.level.getBlockState(blockposition))) { + if (PathfinderGoalEatTile.IS_EDIBLE.test(this.level.getBlockState(blockposition))) { - if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.defaultBlockState(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit this.level.destroyBlock(blockposition, false); } -@@ -73,7 +77,7 @@ +@@ -75,7 +79,7 @@ BlockPosition blockposition1 = blockposition.below(); if (this.level.getBlockState(blockposition1).is(Blocks.GRASS_BLOCK)) { diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.patch b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.patch deleted file mode 100644 index 10fef72e3..000000000 --- a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.java -+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.java -@@ -22,7 +22,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/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.patch b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.patch index e5894e995..8a909e10c 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.patch @@ -1,6 +1,15 @@ --- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.java +++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.java -@@ -61,7 +61,7 @@ +@@ -30,7 +30,7 @@ + public boolean canUse() { + AxisAlignedBB axisalignedbb = this.golem.getBoundingBox().inflate(10.0D, 8.0D, 10.0D); + WorldServer worldserver = getServerLevel((Entity) this.golem); +- List list = worldserver.getNearbyEntities(EntityVillager.class, this.attackTargeting, this.golem, axisalignedbb); ++ List list = worldserver.getNearbyEntities(EntityVillager.class, this.attackTargeting, this.golem, axisalignedbb); // CraftBukkit - decompile error + List list1 = worldserver.getNearbyPlayers(this.attackTargeting, this.golem, axisalignedbb); + + for (EntityLiving entityliving : list) { +@@ -64,7 +64,7 @@ @Override public void start() { diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.patch b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.patch index 713349a4d..2db17c670 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.java +++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.java -@@ -67,7 +67,7 @@ +@@ -60,7 +60,7 @@ @Override public void start() { @@ -9,7 +9,7 @@ this.targetMob = this.mob.getTarget(); this.timestamp = this.mob.getLastHurtByMobTimestamp(); this.unseenMemoryTicks = 300; -@@ -114,6 +114,6 @@ +@@ -99,6 +99,6 @@ } protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) { diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.patch b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.patch index fa68981dc..08c6ae000 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.java @@ -11,6 +11,10 @@ import net.minecraft.world.level.pathfinder.PathPoint; - import net.minecraft.world.scores.ScoreboardTeam; + import net.minecraft.world.scores.ScoreboardTeamBase; +// CraftBukkit start +import org.bukkit.event.entity.EntityTargetEvent; diff --git a/nms-patches/net/minecraft/world/entity/ai/gossip/Reputation.patch b/nms-patches/net/minecraft/world/entity/ai/gossip/Reputation.patch index 155e36332..884a31675 100644 --- a/nms-patches/net/minecraft/world/entity/ai/gossip/Reputation.patch +++ b/nms-patches/net/minecraft/world/entity/ai/gossip/Reputation.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/ai/gossip/Reputation.java +++ b/net/minecraft/world/entity/ai/gossip/Reputation.java -@@ -30,13 +30,27 @@ +@@ -25,6 +25,14 @@ + import net.minecraft.util.RandomSource; import net.minecraft.util.VisibleForDebug; - import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.world.entity.npc.EntityVillager; @@ -14,22 +14,23 @@ + public class Reputation { - private static final Logger LOGGER = LogUtils.getLogger(); + public static final Codec CODEC = Reputation.b.CODEC.listOf().xmap(Reputation::new, (reputation) -> { +@@ -33,6 +41,14 @@ public static final int DISCARD_THRESHOLD = 2; - private final Map gossips = Maps.newHashMap(); + private final Map gossips = new HashMap(); -- public Reputation() {} + // CraftBukkit start - store reference to villager entity -+ private final EntityVillager villager; ++ public EntityVillager villager; + + public Reputation(EntityVillager villager) { + this.villager = villager; + } + // CraftBukkit end ++ + public Reputation() {} - @VisibleForDebug - public Map> getGossipEntries() { -@@ -51,15 +65,17 @@ + private Reputation(List list) { +@@ -54,15 +70,17 @@ } public void decay() { @@ -51,7 +52,7 @@ } } -@@ -112,16 +128,27 @@ +@@ -115,16 +133,27 @@ int j = reputation_b.value - reputation_b.type.decayPerTransfer; if (j >= 2) { @@ -81,7 +82,7 @@ } public long getCountForType(ReputationType reputationtype, DoublePredicate doublepredicate) { -@@ -131,27 +158,58 @@ +@@ -134,27 +163,58 @@ } public void add(UUID uuid, ReputationType reputationtype, int i) { @@ -145,7 +146,7 @@ if (reputation_a.isEmpty()) { this.gossips.remove(uuid); } -@@ -159,7 +217,16 @@ +@@ -162,7 +222,16 @@ } @@ -163,25 +164,16 @@ Iterator iterator = this.gossips.values().iterator(); while (iterator.hasNext()) { -@@ -174,7 +241,7 @@ +@@ -197,7 +266,7 @@ } - public T store(DynamicOps dynamicops) { -- Optional optional = Reputation.b.LIST_CODEC.encodeStart(dynamicops, this.unpack().toList()).resultOrPartial((s) -> { -+ Optional optional = Reputation.b.LIST_CODEC.encodeStart(dynamicops, this.unpack().toList()).resultOrPartial((s) -> { // CraftBukkit - missing generic parameter after decompile - Reputation.LOGGER.warn("Failed to serialize gossips: {}", s); - }); + public Reputation copy() { +- Reputation reputation = new Reputation(); ++ Reputation reputation = new Reputation(this.villager); // CraftBukkit -@@ -186,7 +253,7 @@ - Reputation.b.LIST_CODEC.decode(dynamic).resultOrPartial((s) -> { - Reputation.LOGGER.warn("Failed to deserialize gossips: {}", s); - }).stream().flatMap((pair) -> { -- return ((List) pair.getFirst()).stream(); -+ return ((List) pair.getFirst()).stream(); // CraftBukkit - missing generic parameter after decompile - }).forEach((reputation_b) -> { - this.getOrCreate(reputation_b.target).entries.put(reputation_b.type, reputation_b.value); - }); -@@ -216,18 +283,36 @@ + reputation.putAll(this); + return reputation; +@@ -228,18 +297,36 @@ }).sum(); } @@ -203,13 +195,13 @@ - public void decay() { + public void decay(EntityVillager villager, UUID uuid) { // CraftBukkit - add villager and entity uuid parameters - ObjectIterator> objectiterator = this.entries.object2IntEntrySet().iterator(); + ObjectIterator> objectiterator = this.entries.object2IntEntrySet().iterator(); while (objectiterator.hasNext()) { - Entry entry = (Entry) objectiterator.next(); - int i = entry.getIntValue() - ((ReputationType) entry.getKey()).decayPerDay; + Object2IntMap.Entry object2intmap_entry = (Entry) objectiterator.next(); + int i = object2intmap_entry.getIntValue() - ((ReputationType) object2intmap_entry.getKey()).decayPerDay; + // CraftBukkit start - fire event -+ VillagerReputationChangeEvent event = CraftEventFactory.callVillagerReputationChangeEvent((Villager) villager.getBukkitEntity(), uuid, Villager.ReputationEvent.DECAY, CraftReputationType.minecraftToBukkit(entry.getKey()), entry.getIntValue(), i, entry.getKey().max); ++ VillagerReputationChangeEvent event = CraftEventFactory.callVillagerReputationChangeEvent((Villager) villager.getBukkitEntity(), uuid, Villager.ReputationEvent.DECAY, CraftReputationType.minecraftToBukkit(object2intmap_entry.getKey()), object2intmap_entry.getIntValue(), i, object2intmap_entry.getKey().max); + if (event.isCancelled()) { + continue; + } else { diff --git a/nms-patches/net/minecraft/world/entity/ai/sensing/TemptingSensor.patch b/nms-patches/net/minecraft/world/entity/ai/sensing/TemptingSensor.patch index 0781087ad..b9f68d645 100644 --- a/nms-patches/net/minecraft/world/entity/ai/sensing/TemptingSensor.patch +++ b/nms-patches/net/minecraft/world/entity/ai/sensing/TemptingSensor.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/sensing/TemptingSensor.java +++ b/net/minecraft/world/entity/ai/sensing/TemptingSensor.java -@@ -19,6 +19,14 @@ +@@ -18,6 +18,14 @@ import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; @@ -15,7 +15,7 @@ public class TemptingSensor extends Sensor { private static final PathfinderTargetCondition TEMPT_TARGETING = PathfinderTargetCondition.forNonCombat().ignoreLineOfSight(); -@@ -31,7 +39,7 @@ +@@ -30,7 +38,7 @@ protected void doTick(WorldServer worldserver, EntityCreature entitycreature) { BehaviorController behaviorcontroller = entitycreature.getBrain(); PathfinderTargetCondition pathfindertargetcondition = TemptingSensor.TEMPT_TARGETING.copy().range((double) ((float) entitycreature.getAttributeValue(GenericAttributes.TEMPT_RANGE))); @@ -23,12 +23,12 @@ + Stream stream = worldserver.players().stream().filter(IEntitySelector.NO_SPECTATORS).filter((entityplayer) -> { // CraftBukkit - decompile error return pathfindertargetcondition.test(worldserver, entitycreature, entityplayer); }).filter(this::playerHoldingTemptation).filter((entityplayer) -> { - return !entitycreature.hasPassenger((Entity) entityplayer); -@@ -43,7 +51,17 @@ + return !entitycreature.hasPassenger(entityplayer); +@@ -42,7 +50,17 @@ if (!list.isEmpty()) { EntityHuman entityhuman = (EntityHuman) list.get(0); -- behaviorcontroller.setMemory(MemoryModuleType.TEMPTING_PLAYER, (Object) entityhuman); +- behaviorcontroller.setMemory(MemoryModuleType.TEMPTING_PLAYER, entityhuman); + // CraftBukkit start + EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(entitycreature, entityhuman, EntityTargetEvent.TargetReason.TEMPT); + if (event.isCancelled()) { diff --git a/nms-patches/net/minecraft/world/entity/ai/village/VillageSiege.patch b/nms-patches/net/minecraft/world/entity/ai/village/VillageSiege.patch index e048e9d58..872224943 100644 --- a/nms-patches/net/minecraft/world/entity/ai/village/VillageSiege.patch +++ b/nms-patches/net/minecraft/world/entity/ai/village/VillageSiege.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/ai/village/VillageSiege.java +++ b/net/minecraft/world/entity/ai/village/VillageSiege.java -@@ -121,7 +121,7 @@ +@@ -111,7 +111,7 @@ } - entityzombie.moveTo(vec3d.x, vec3d.y, vec3d.z, worldserver.random.nextFloat() * 360.0F, 0.0F); + entityzombie.snapTo(vec3d.x, vec3d.y, vec3d.z, worldserver.random.nextFloat() * 360.0F, 0.0F); - worldserver.addFreshEntityWithPassengers(entityzombie); + worldserver.addFreshEntityWithPassengers(entityzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_INVASION); // CraftBukkit } diff --git a/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch b/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch index fbac4f609..acc85c504 100644 --- a/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch +++ b/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ambient/EntityBat.java +++ b/net/minecraft/world/entity/ambient/EntityBat.java -@@ -30,6 +30,10 @@ +@@ -29,6 +29,10 @@ import net.minecraft.world.level.levelgen.HeightMap; import net.minecraft.world.phys.Vec3D; @@ -19,14 +19,14 @@ + if (worldserver.getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent this.setResting(false); if (!flag) { - worldserver.levelEvent((EntityHuman) null, 1025, blockposition, 0); + worldserver.levelEvent((Entity) null, 1025, blockposition, 0); } } - } else { + } else if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent this.setResting(false); if (!flag) { - worldserver.levelEvent((EntityHuman) null, 1025, blockposition, 0); + worldserver.levelEvent((Entity) null, 1025, blockposition, 0); @@ -177,7 +181,7 @@ this.zza = 0.5F; diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch b/nms-patches/net/minecraft/world/entity/animal/AbstractCow.patch similarity index 78% rename from nms-patches/net/minecraft/world/entity/animal/EntityCow.patch rename to nms-patches/net/minecraft/world/entity/animal/AbstractCow.patch index 35abe25cc..812b64baf 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch +++ b/nms-patches/net/minecraft/world/entity/animal/AbstractCow.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/EntityCow.java -+++ b/net/minecraft/world/entity/animal/EntityCow.java -@@ -31,6 +31,12 @@ +--- a/net/minecraft/world/entity/animal/AbstractCow.java ++++ b/net/minecraft/world/entity/animal/AbstractCow.java +@@ -27,6 +27,12 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.block.state.IBlockData; @@ -10,15 +10,15 @@ +import org.bukkit.event.player.PlayerBucketFillEvent; +// CraftBukkit end + - public class EntityCow extends EntityAnimal { + public abstract class AbstractCow extends EntityAnimal { private static final EntitySize BABY_DIMENSIONS = EntityTypes.COW.getDimensions().scale(0.5F).withEyeHeight(0.665F); -@@ -92,8 +98,16 @@ +@@ -88,8 +94,16 @@ ItemStack itemstack = entityhuman.getItemInHand(enumhand); if (itemstack.is(Items.BUCKET) && !this.isBaby()) { + // CraftBukkit start - Got milk? -+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level(), entityhuman, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, enumhand); ++ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman.level(), entityhuman, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, enumhand); + + if (event.isCancelled()) { + return EnumInteractionResult.PASS; diff --git a/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch b/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch index 1476f0500..6ead0ce2d 100644 --- a/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch +++ b/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Bucketable.java +++ b/net/minecraft/world/entity/animal/Bucketable.java -@@ -17,6 +17,14 @@ +@@ -18,6 +18,14 @@ import net.minecraft.world.item.component.CustomData; import net.minecraft.world.level.World; @@ -15,7 +15,27 @@ public interface Bucketable { boolean fromBucket(); -@@ -93,10 +101,22 @@ +@@ -64,7 +72,7 @@ + /** @deprecated */ + @Deprecated + static void loadDefaultDataFromBucketTag(EntityInsentient entityinsentient, NBTTagCompound nbttagcompound) { +- Optional optional = nbttagcompound.getBoolean("NoAI"); ++ Optional optional = nbttagcompound.getBoolean("NoAI"); // CraftBukkit - decompile error + + Objects.requireNonNull(entityinsentient); + optional.ifPresent(entityinsentient::setNoAi); +@@ -80,19 +88,31 @@ + optional = nbttagcompound.getBoolean("Invulnerable"); + Objects.requireNonNull(entityinsentient); + optional.ifPresent(entityinsentient::setInvulnerable); +- optional = nbttagcompound.getFloat("Health"); ++ Optional optional2 = nbttagcompound.getFloat("Health"); // CraftBukkit - decompile error + Objects.requireNonNull(entityinsentient); +- optional.ifPresent(entityinsentient::setHealth); ++ optional2.ifPresent(entityinsentient::setHealth); // CraftBukkit - decompile error + } + + static Optional bucketMobPickup(EntityHuman entityhuman, EnumHand enumhand, T t0) { ItemStack itemstack = entityhuman.getItemInHand(enumhand); if (itemstack.getItem() == Items.WATER_BUCKET && t0.isAlive()) { @@ -39,7 +59,7 @@ ItemStack itemstack2 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false); entityhuman.setItemInHand(enumhand, itemstack2); -@@ -106,7 +126,7 @@ +@@ -102,7 +122,7 @@ CriterionTriggers.FILLED_BUCKET.trigger((EntityPlayer) entityhuman, itemstack1); } diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch b/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch index 2a29f15fe..2595bf528 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityAnimal.java +++ b/net/minecraft/world/entity/animal/EntityAnimal.java -@@ -35,12 +35,20 @@ +@@ -36,6 +36,13 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.pathfinder.PathType; @@ -14,14 +14,15 @@ public abstract class EntityAnimal extends EntityAgeable { protected static final int PARENT_AGE_AFTER_BREEDING = 6000; - public int inLove; +@@ -43,6 +50,7 @@ + public int inLove = 0; @Nullable public UUID loveCause; + public ItemStack breedItem; // CraftBukkit - Add breedItem variable protected EntityAnimal(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -82,9 +90,15 @@ +@@ -84,9 +92,15 @@ } @Override @@ -39,7 +40,16 @@ } @Override -@@ -188,10 +202,17 @@ +@@ -105,7 +119,7 @@ + public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { + super.readAdditionalSaveData(nbttagcompound); + this.inLove = nbttagcompound.getIntOr("InLove", 0); +- this.loveCause = (UUID) nbttagcompound.read("LoveCause", UUIDUtil.CODEC).orElse((Object) null); ++ this.loveCause = (UUID) nbttagcompound.read("LoveCause", UUIDUtil.CODEC).orElse(null); // CraftBukkit - decompile error + } + + public static boolean checkAnimalSpawnRules(EntityTypes entitytypes, GeneratorAccess generatoraccess, EntitySpawnReason entityspawnreason, BlockPosition blockposition, RandomSource randomsource) { +@@ -187,10 +201,17 @@ } public void setInLove(@Nullable EntityHuman entityhuman) { @@ -54,14 +64,14 @@ if (entityhuman != null) { this.loveCause = entityhuman.getUUID(); } -+ this.breedItem = entityhuman.getInventory().getSelected(); // CraftBukkit ++ this.breedItem = entityhuman.getInventory().getSelectedItem(); // CraftBukkit this.level().broadcastEntityEvent(this, (byte) 18); } -@@ -233,12 +254,29 @@ +@@ -232,12 +253,29 @@ if (entityageable != null) { entityageable.setBaby(true); - entityageable.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F); + entityageable.snapTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F); - this.finalizeSpawnChildFromBreeding(worldserver, entityanimal, entityageable); - worldserver.addFreshEntityWithPassengers(entityageable); + // CraftBukkit start - call EntityBreedEvent @@ -90,7 +100,7 @@ Optional.ofNullable(this.getLoveCause()).or(() -> { return Optional.ofNullable(entityanimal.getLoveCause()); }).ifPresent((entityplayer) -> { -@@ -251,7 +289,11 @@ +@@ -250,7 +288,11 @@ entityanimal.resetLove(); worldserver.broadcastEntityEvent(this, (byte) 18); if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch b/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch index 5344d0cda..6896528cd 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityBee.java +++ b/net/minecraft/world/entity/animal/EntityBee.java -@@ -93,6 +93,12 @@ +@@ -91,6 +91,12 @@ import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.phys.Vec3D; @@ -13,7 +13,7 @@ public class EntityBee extends EntityAnimal implements IEntityAngerable, EntityBird { public static final float FLAP_DEGREES_PER_TICK = 120.32113F; -@@ -198,12 +204,19 @@ +@@ -201,9 +207,24 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { @@ -25,37 +25,42 @@ + public void addAdditionalSaveData(NBTTagCompound nbttagcompound, boolean includeAll) { + // CraftBukkit end super.addAdditionalSaveData(nbttagcompound); -- if (this.hasHive()) { -+ if (includeAll && this.hasHive()) { // CraftBukkit - selectively save hive - nbttagcompound.put("hive_pos", GameProfileSerializer.writeBlockPos(this.getHivePos())); - } - -- if (this.hasSavedFlowerPos()) { -+ if (includeAll && this.hasSavedFlowerPos()) { // CraftBukkit - selectively save flower - nbttagcompound.put("flower_pos", GameProfileSerializer.writeBlockPos(this.getSavedFlowerPos())); - } - -@@ -223,8 +236,8 @@ - this.ticksWithoutNectarSinceExitingHive = nbttagcompound.getInt("TicksSincePollination"); - this.stayOutOfHiveCountdown = nbttagcompound.getInt("CannotEnterHiveTicks"); - this.numCropsGrownSincePollination = nbttagcompound.getInt("CropsGrownSincePollination"); -- this.hivePos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "hive_pos").orElse((Object) null); -- this.savedFlowerPos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "flower_pos").orElse((Object) null); -+ this.hivePos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "hive_pos").orElse(null); // CraftBukkit - decompile error -+ this.savedFlowerPos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "flower_pos").orElse(null); // CraftBukkit - decompile error +- nbttagcompound.storeNullable("hive_pos", BlockPosition.CODEC, this.hivePos); +- nbttagcompound.storeNullable("flower_pos", BlockPosition.CODEC, this.savedFlowerPos); ++ // CraftBukkit start - selectively save hive ++ if (includeAll) { ++ nbttagcompound.storeNullable("hive_pos", BlockPosition.CODEC, this.hivePos); ++ } ++ // CraftBukkit end ++ // CraftBukkit start - selectively save flower ++ if (includeAll) { ++ nbttagcompound.storeNullable("flower_pos", BlockPosition.CODEC, this.savedFlowerPos); ++ } ++ // CraftBukkit end + nbttagcompound.putBoolean("HasNectar", this.hasNectar()); + nbttagcompound.putBoolean("HasStung", this.hasStung()); + nbttagcompound.putInt("TicksSincePollination", this.ticksWithoutNectarSinceExitingHive); +@@ -220,8 +241,8 @@ + this.ticksWithoutNectarSinceExitingHive = nbttagcompound.getIntOr("TicksSincePollination", 0); + this.stayOutOfHiveCountdown = nbttagcompound.getIntOr("CannotEnterHiveTicks", 0); + this.numCropsGrownSincePollination = nbttagcompound.getIntOr("CropsGrownSincePollination", 0); +- this.hivePos = (BlockPosition) nbttagcompound.read("hive_pos", BlockPosition.CODEC).orElse((Object) null); +- this.savedFlowerPos = (BlockPosition) nbttagcompound.read("flower_pos", BlockPosition.CODEC).orElse((Object) null); ++ this.hivePos = (BlockPosition) nbttagcompound.read("hive_pos", BlockPosition.CODEC).orElse(null); // CraftBukkit - decompile error ++ this.savedFlowerPos = (BlockPosition) nbttagcompound.read("flower_pos", BlockPosition.CODEC).orElse(null); // CraftBukkit - decompile error this.readPersistentAngerSaveData(this.level(), nbttagcompound); } -@@ -248,7 +261,7 @@ +@@ -245,7 +266,7 @@ } - if (b0 > 0) { -- entityliving.addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this); -+ entityliving.addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this, EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit + if (i > 0) { +- entityliving.addEffect(new MobEffect(MobEffects.POISON, i * 20, 0), this); ++ entityliving.addEffect(new MobEffect(MobEffects.POISON, i * 20, 0), this, EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } } -@@ -506,7 +519,7 @@ +@@ -503,7 +524,7 @@ @Nullable TileEntityBeehive getBeehiveBlockEntity() { @@ -64,7 +69,7 @@ } boolean isHiveValid() { -@@ -671,8 +684,14 @@ +@@ -668,8 +689,14 @@ if (this.isInvulnerableTo(worldserver, damagesource)) { return false; } else { @@ -80,34 +85,7 @@ } } -@@ -1082,7 +1101,7 @@ - - e() { - super(); -- this.travellingTicks = EntityBee.this.level().random.nextInt(10); -+ this.travellingTicks = EntityBee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues - this.blacklistedTargets = Lists.newArrayList(); - this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE)); - } -@@ -1196,7 +1215,7 @@ - - f() { - super(); -- this.travellingTicks = EntityBee.this.level().random.nextInt(10); -+ this.travellingTicks = EntityBee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues - this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE)); - } - -@@ -1301,7 +1320,7 @@ - } - } - -- if (iblockdata1 != null) { -+ if (iblockdata1 != null && CraftEventFactory.callEntityChangeBlockEvent(EntityBee.this, blockposition, iblockdata1)) { // CraftBukkit - EntityBee.this.level().levelEvent(2011, blockposition, 15); - EntityBee.this.level().setBlockAndUpdate(blockposition, iblockdata1); - EntityBee.this.incrementNumCropsGrownSincePollination(); -@@ -1378,7 +1397,7 @@ +@@ -709,7 +736,7 @@ @Override protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) { if (entityinsentient instanceof EntityBee && this.mob.hasLineOfSight(entityliving)) { @@ -116,7 +94,7 @@ } } -@@ -1387,7 +1406,7 @@ +@@ -718,7 +745,7 @@ private static class c extends PathfinderGoalNearestAttackableTarget { c(EntityBee entitybee) { @@ -125,3 +103,30 @@ super(entitybee, EntityHuman.class, 10, true, false, entitybee::isAngryAt); } +@@ -829,7 +856,7 @@ + private int ticksStuck; + + e() { +- this.travellingTicks = EntityBee.this.level().random.nextInt(10); ++ this.travellingTicks = EntityBee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues + this.blacklistedTargets = Lists.newArrayList(); + this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE)); + } +@@ -942,7 +969,7 @@ + int travellingTicks; + + f() { +- this.travellingTicks = EntityBee.this.level().random.nextInt(10); ++ this.travellingTicks = EntityBee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues + this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE)); + } + +@@ -1280,7 +1307,7 @@ + } + } + +- if (iblockdata1 != null) { ++ if (iblockdata1 != null && CraftEventFactory.callEntityChangeBlockEvent(EntityBee.this, blockposition, iblockdata1)) { // CraftBukkit + EntityBee.this.level().levelEvent(2011, blockposition, 15); + EntityBee.this.level().setBlockAndUpdate(blockposition, iblockdata1); + EntityBee.this.incrementNumCropsGrownSincePollination(); diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch b/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch index beee3ec81..2dfd5a09a 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch @@ -1,19 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityCat.java +++ b/net/minecraft/world/entity/animal/EntityCat.java -@@ -174,10 +174,10 @@ - @Override - public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { - super.readAdditionalSaveData(nbttagcompound); -- Optional optional = Optional.ofNullable(MinecraftKey.tryParse(nbttagcompound.getString("variant"))).map((minecraftkey) -> { -+ Optional> optional = Optional.ofNullable(MinecraftKey.tryParse(nbttagcompound.getString("variant"))).map((minecraftkey) -> { // CraftBukkit - decompile error - return ResourceKey.create(Registries.CAT_VARIANT, minecraftkey); - }); -- IRegistry iregistry = BuiltInRegistries.CAT_VARIANT; -+ IRegistry iregistry = BuiltInRegistries.CAT_VARIANT; // CraftBukkit - decompile error - - Objects.requireNonNull(iregistry); - optional.flatMap(iregistry::get).ifPresent(this::setVariant); -@@ -462,7 +462,7 @@ +@@ -460,7 +460,7 @@ } private void tryToTame(EntityHuman entityhuman) { @@ -22,33 +9,7 @@ this.tame(entityhuman); this.setOrderedToSit(true); this.level().broadcastEntityEvent(this, (byte) 7); -@@ -480,7 +480,7 @@ - private static class PathfinderGoalTemptChance extends PathfinderGoalTempt { - - @Nullable -- private EntityHuman selectedPlayer; -+ private EntityLiving selectedPlayer; // CraftBukkit - private final EntityCat cat; - - public PathfinderGoalTemptChance(EntityCat entitycat, double d0, Predicate predicate, boolean flag) { -@@ -614,7 +614,15 @@ - this.cat.randomTeleport((double) (blockposition_mutableblockposition.getX() + randomsource.nextInt(11) - 5), (double) (blockposition_mutableblockposition.getY() + randomsource.nextInt(5) - 2), (double) (blockposition_mutableblockposition.getZ() + randomsource.nextInt(11) - 5), false); - blockposition_mutableblockposition.set(this.cat.blockPosition()); - this.cat.dropFromGiftLootTable(getServerLevel((Entity) this.cat), LootTables.CAT_MORNING_GIFT, (worldserver, itemstack) -> { -- worldserver.addFreshEntity(new EntityItem(worldserver, (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.cat.yBodyRot * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.cat.yBodyRot * 0.017453292F), itemstack)); -+ // CraftBukkit start -+ EntityItem entityitem = new EntityItem(worldserver, (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.cat.yBodyRot * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.cat.yBodyRot * 0.017453292F), itemstack); -+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.cat.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); -+ entityitem.level().getCraftServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ return; -+ } -+ worldserver.addFreshEntity(entityitem); -+ // CraftBukkit end - }); - } - -@@ -645,10 +653,10 @@ +@@ -480,10 +480,10 @@ private final EntityCat cat; public a(EntityCat entitycat, Class oclass, float f, double d0, double d1) { @@ -62,3 +23,29 @@ this.cat = entitycat; } +@@ -501,7 +501,7 @@ + private static class PathfinderGoalTemptChance extends PathfinderGoalTempt { + + @Nullable +- private EntityHuman selectedPlayer; ++ private EntityLiving selectedPlayer; // CraftBukkit + private final EntityCat cat; + + public PathfinderGoalTemptChance(EntityCat entitycat, double d0, Predicate predicate, boolean flag) { +@@ -628,7 +628,15 @@ + this.cat.randomTeleport((double) (blockposition_mutableblockposition.getX() + randomsource.nextInt(11) - 5), (double) (blockposition_mutableblockposition.getY() + randomsource.nextInt(5) - 2), (double) (blockposition_mutableblockposition.getZ() + randomsource.nextInt(11) - 5), false); + blockposition_mutableblockposition.set(this.cat.blockPosition()); + this.cat.dropFromGiftLootTable(getServerLevel((Entity) this.cat), LootTables.CAT_MORNING_GIFT, (worldserver, itemstack) -> { +- worldserver.addFreshEntity(new EntityItem(worldserver, (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.cat.yBodyRot * ((float) Math.PI / 180F)), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.cat.yBodyRot * ((float) Math.PI / 180F)), itemstack)); ++ // CraftBukkit start ++ EntityItem entityitem = new EntityItem(worldserver, (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.cat.yBodyRot * ((float) Math.PI / 180F)), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.cat.yBodyRot * ((float) Math.PI / 180F)), itemstack); ++ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.cat.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); ++ entityitem.level().getCraftServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ return; ++ } ++ worldserver.addFreshEntity(entityitem); ++ // CraftBukkit end + }); + } + diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityChicken.patch b/nms-patches/net/minecraft/world/entity/animal/EntityChicken.patch index 11e71cc92..b333e0a71 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityChicken.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityChicken.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityChicken.java +++ b/net/minecraft/world/entity/animal/EntityChicken.java -@@ -99,10 +99,12 @@ +@@ -116,10 +116,12 @@ if (world instanceof WorldServer worldserver) { if (this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch b/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch index 27264decc..a312e17cf 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch @@ -18,10 +18,10 @@ + return TOTAL_AIR_SUPPLY; + } + // CraftBukkit end - private static final DataWatcherObject TREASURE_POS = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BLOCK_POS); - private static final DataWatcherObject GOT_FISH = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BOOLEAN); - private static final DataWatcherObject MOISTNESS_LEVEL = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.INT); -@@ -200,7 +212,7 @@ + private static final DataWatcherObject GOT_FISH = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BOOLEAN); + private static final DataWatcherObject MOISTNESS_LEVEL = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.INT); + static final PathfinderTargetCondition SWIM_WITH_PLAYER_TARGETING = PathfinderTargetCondition.forNonCombat().range(10.0D).ignoreLineOfSight(); +@@ -185,7 +197,7 @@ @Override public int getMaxAirSupply() { @@ -30,7 +30,7 @@ } @Override -@@ -234,11 +246,17 @@ +@@ -219,11 +231,17 @@ ItemStack itemstack = entityitem.getItem(); if (this.canHoldItem(itemstack)) { @@ -49,7 +49,7 @@ } } -@@ -495,7 +513,7 @@ +@@ -461,7 +479,7 @@ @Override public void start() { @@ -58,7 +58,7 @@ } @Override -@@ -514,7 +532,7 @@ +@@ -480,7 +498,7 @@ } if (this.player.isSwimming() && this.player.level().random.nextInt(6) == 0) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch b/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch index 2c4b0856d..daa495a80 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityFox.java +++ b/net/minecraft/world/entity/animal/EntityFox.java -@@ -91,6 +91,10 @@ +@@ -94,6 +94,10 @@ import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.phys.Vec3D; @@ -8,10 +8,37 @@ +import org.bukkit.event.entity.EntityRemoveEvent; +// CraftBukkit end + - public class EntityFox extends EntityAnimal implements VariantHolder { + public class EntityFox extends EntityAnimal { - private static final DataWatcherObject DATA_TYPE_ID = DataWatcher.defineId(EntityFox.class, DataWatcherRegistry.INT); -@@ -503,7 +507,8 @@ + private static final DataWatcherObject DATA_TYPE_ID = DataWatcher.defineId(EntityFox.class, DataWatcherRegistry.INT); +@@ -125,7 +129,7 @@ + }; + private static final int MIN_TICKS_BEFORE_EAT = 600; + private static final EntitySize BABY_DIMENSIONS = EntityTypes.FOX.getDimensions().scale(0.5F).withEyeHeight(0.2975F); +- private static final Codec>> TRUSTED_LIST_CODEC = EntityReference.codec().listOf(); ++ private static final Codec>> TRUSTED_LIST_CODEC = EntityReference.codec().listOf(); // CraftBukkit - decompile error + private static final boolean DEFAULT_SLEEPING = false; + private static final boolean DEFAULT_SITTING = false; + private static final boolean DEFAULT_CROUCHING = false; +@@ -171,7 +175,7 @@ + this.goalSelector.addGoal(1, new EntityFox.b()); + this.goalSelector.addGoal(2, new EntityFox.n(2.2D)); + this.goalSelector.addGoal(3, new EntityFox.e(1.0D)); +- this.goalSelector.addGoal(4, new PathfinderGoalAvoidTarget(this, EntityHuman.class, 16.0F, 1.6D, 1.4D, (entityliving) -> { ++ this.goalSelector.addGoal(4, new PathfinderGoalAvoidTarget<>(this, EntityHuman.class, 16.0F, 1.6D, 1.4D, (entityliving) -> { // CraftBukkit - decompile error + return EntityFox.AVOID_PLAYERS.test(entityliving) && !this.trusts(entityliving) && !this.isDefending(); + })); + this.goalSelector.addGoal(4, new PathfinderGoalAvoidTarget(this, EntityWolf.class, 8.0F, 1.6D, 1.4D, (entityliving) -> { +@@ -425,7 +429,7 @@ + public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { + super.readAdditionalSaveData(nbttagcompound); + this.clearTrusted(); +- ((List) nbttagcompound.read("Trusted", EntityFox.TRUSTED_LIST_CODEC).orElse(List.of())).forEach(this::addTrustedEntity); ++ (nbttagcompound.read("Trusted", EntityFox.TRUSTED_LIST_CODEC).orElse(List.of())).forEach(this::addTrustedEntity); // CraftBukkit - decompile error + this.setSleeping(nbttagcompound.getBooleanOr("Sleeping", false)); + this.setVariant((EntityFox.Type) nbttagcompound.read("Type", EntityFox.Type.CODEC).orElse(EntityFox.Type.DEFAULT)); + this.setSitting(nbttagcompound.getBooleanOr("Sitting", false)); +@@ -520,7 +524,8 @@ protected void pickUpItem(WorldServer worldserver, EntityItem entityitem) { ItemStack itemstack = entityitem.getItem(); @@ -21,7 +48,7 @@ int i = itemstack.getCount(); if (i > 1) { -@@ -515,7 +520,7 @@ +@@ -532,7 +537,7 @@ this.setItemSlot(EnumItemSlot.MAINHAND, itemstack.split(1)); this.setGuaranteedDrop(EnumItemSlot.MAINHAND); this.take(entityitem, itemstack.getCount()); @@ -30,13 +57,13 @@ this.ticksSinceEaten = 0; } -@@ -853,6 +858,16 @@ +@@ -954,6 +959,16 @@ if (entityplayer1 != null && entityplayer != entityplayer1) { - entityfox.addTrustedUUID(entityplayer1.getUUID()); + entityfox.addTrustedEntity(entityplayer1); } + // CraftBukkit start - call EntityBreedEvent + entityfox.setAge(-24000); -+ entityfox.moveTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F); ++ entityfox.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(entityfox, animal, partner, entityplayer, this.animal.breedItem, experience); + if (entityBreedEvent.isCancelled()) { @@ -47,12 +74,12 @@ if (entityplayer2 != null) { entityplayer2.awardStat(StatisticList.ANIMALS_BRED); -@@ -863,12 +878,14 @@ +@@ -964,12 +979,14 @@ this.partner.setAge(6000); this.animal.resetLove(); this.partner.resetLove(); - entityfox.setAge(-24000); -- entityfox.moveTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F); +- entityfox.snapTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F); - worldserver.addFreshEntityWithPassengers(entityfox); + worldserver.addFreshEntityWithPassengers(entityfox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason this.level.broadcastEntityEvent(this.animal, (byte) 18); @@ -66,7 +93,7 @@ } } -@@ -1264,6 +1281,11 @@ +@@ -1268,6 +1285,11 @@ int i = (Integer) iblockdata.getValue(BlockSweetBerryBush.AGE); iblockdata.setValue(BlockSweetBerryBush.AGE, 1); @@ -78,12 +105,3 @@ int j = 1 + EntityFox.this.level().random.nextInt(2) + (i == 3 ? 1 : 0); ItemStack itemstack = EntityFox.this.getItemBySlot(EnumItemSlot.MAINHAND); -@@ -1494,7 +1516,7 @@ - } - - public static EntityFox.Type byName(String s) { -- return (EntityFox.Type) EntityFox.Type.CODEC.byName(s, (Enum) EntityFox.Type.RED); -+ return (EntityFox.Type) EntityFox.Type.CODEC.byName(s, EntityFox.Type.RED); // CraftBukkit - decompile error - } - - public static EntityFox.Type byId(int i) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityIronGolem.patch b/nms-patches/net/minecraft/world/entity/animal/EntityIronGolem.patch index 0477fb552..42a1f8ea1 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityIronGolem.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityIronGolem.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityIronGolem.java +++ b/net/minecraft/world/entity/animal/EntityIronGolem.java -@@ -98,7 +98,7 @@ +@@ -99,7 +99,7 @@ @Override protected void doPush(Entity entity) { if (entity instanceof IMonster && !(entity instanceof EntityCreeper) && this.getRandom().nextInt(20) == 0) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch b/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch index 13fc6bcc6..7e2861011 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityMushroomCow.java +++ b/net/minecraft/world/entity/animal/EntityMushroomCow.java -@@ -43,6 +43,13 @@ +@@ -49,6 +49,13 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.storage.loot.LootTables; @@ -11,10 +11,10 @@ +import org.bukkit.event.entity.EntityTransformEvent; +// CraftBukkit end + - public class EntityMushroomCow extends EntityCow implements IShearable, VariantHolder { + public class EntityMushroomCow extends AbstractCow implements IShearable { - private static final DataWatcherObject DATA_TYPE = DataWatcher.defineId(EntityMushroomCow.class, DataWatcherRegistry.STRING); -@@ -120,6 +127,11 @@ + private static final DataWatcherObject DATA_TYPE = DataWatcher.defineId(EntityMushroomCow.class, DataWatcherRegistry.INT); +@@ -126,6 +133,11 @@ if (world instanceof WorldServer) { WorldServer worldserver = (WorldServer) world; @@ -26,7 +26,7 @@ this.shear(worldserver, SoundCategory.PLAYERS, itemstack); this.gameEvent(GameEvent.SHEAR, entityhuman); itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand)); -@@ -163,11 +175,19 @@ +@@ -167,11 +179,19 @@ worldserver.sendParticles(Particles.EXPLOSION, this.getX(), this.getY(0.5D), this.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D); this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_MOOSHROOM, itemstack, (worldserver1, itemstack1) -> { for (int i = 0; i < itemstack1.getCount(); ++i) { @@ -48,12 +48,12 @@ } @Override -@@ -263,7 +283,7 @@ - } - - static EntityMushroomCow.Type byName(String s) { -- return (EntityMushroomCow.Type) EntityMushroomCow.Type.CODEC.byName(s, (Enum) EntityMushroomCow.Type.RED); -+ return (EntityMushroomCow.Type) EntityMushroomCow.Type.CODEC.byName(s, EntityMushroomCow.Type.RED); // CraftBukkit - decompile error - } +@@ -190,7 +210,7 @@ + public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { + super.readAdditionalSaveData(nbttagcompound); + this.setVariant((EntityMushroomCow.Type) nbttagcompound.read("Type", EntityMushroomCow.Type.CODEC).orElse(EntityMushroomCow.Type.DEFAULT)); +- this.stewEffects = (SuspiciousStewEffects) nbttagcompound.read("stew_effects", SuspiciousStewEffects.CODEC).orElse((Object) null); ++ this.stewEffects = (SuspiciousStewEffects) nbttagcompound.read("stew_effects", SuspiciousStewEffects.CODEC).orElse(null); // CraftBukkit - decompile error } - } + + private Optional getEffectsFromItemStack(ItemStack itemstack) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch b/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch index 9c76590e3..43c1012ba 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityOcelot.java +++ b/net/minecraft/world/entity/animal/EntityOcelot.java -@@ -167,7 +167,7 @@ +@@ -168,7 +168,7 @@ if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemstack) && entityhuman.distanceToSqr((Entity) this) < 9.0D) { this.usePlayerItem(entityhuman, enumhand, itemstack); if (!this.level().isClientSide) { @@ -9,7 +9,7 @@ this.setTrusting(true); this.spawnTrustingParticles(true); this.level().broadcastEntityEvent(this, (byte) 41); -@@ -298,10 +298,10 @@ +@@ -284,10 +284,10 @@ private final EntityOcelot ocelot; public a(EntityOcelot entityocelot, Class oclass, float f, double d0, double d1) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch b/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch index 6dbcfc20f..b37dd905f 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch @@ -12,8 +12,8 @@ + public class EntityPanda extends EntityAnimal { - private static final DataWatcherObject UNHAPPY_COUNTER = DataWatcher.defineId(EntityPanda.class, DataWatcherRegistry.INT); -@@ -541,14 +547,14 @@ + private static final DataWatcherObject UNHAPPY_COUNTER = DataWatcher.defineId(EntityPanda.class, DataWatcherRegistry.INT); +@@ -537,14 +543,14 @@ @Override protected void pickUpItem(WorldServer worldserver, EntityItem entityitem) { @@ -30,16 +30,7 @@ } } -@@ -772,7 +778,7 @@ - } - - public static EntityPanda.Gene byName(String s) { -- return (EntityPanda.Gene) EntityPanda.Gene.CODEC.byName(s, (Enum) EntityPanda.Gene.NORMAL); -+ return (EntityPanda.Gene) EntityPanda.Gene.CODEC.byName(s, EntityPanda.Gene.NORMAL); // CraftBukkit - decompile error - } - - public static EntityPanda.Gene getRandom(RandomSource randomsource) { -@@ -876,10 +882,10 @@ +@@ -964,10 +970,10 @@ private final EntityPanda panda; public c(EntityPanda entitypanda, Class oclass, float f, double d0, double d1) { @@ -53,7 +44,7 @@ this.panda = entitypanda; } -@@ -1116,7 +1122,7 @@ +@@ -1088,7 +1094,7 @@ @Override protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) { if (entityinsentient instanceof EntityPanda && entityinsentient.isAggressive()) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch b/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch index 1b39ad897..ebe783be0 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityParrot.java +++ b/net/minecraft/world/entity/animal/EntityParrot.java -@@ -248,7 +248,7 @@ +@@ -254,7 +254,7 @@ } if (!this.level().isClientSide) { @@ -9,7 +9,7 @@ this.tame(entityhuman); this.level().broadcastEntityEvent(this, (byte) 7); } else { -@@ -269,7 +269,7 @@ +@@ -275,7 +275,7 @@ } } else { this.usePlayerItem(entityhuman, enumhand, itemstack); @@ -18,7 +18,7 @@ if (entityhuman.isCreative() || !this.isInvulnerable()) { this.hurt(this.damageSources().playerAttack(entityhuman), Float.MAX_VALUE); } -@@ -363,7 +363,7 @@ +@@ -369,7 +369,7 @@ @Override public boolean isPushable() { @@ -27,7 +27,7 @@ } @Override -@@ -378,8 +378,14 @@ +@@ -384,8 +384,14 @@ if (this.isInvulnerableTo(worldserver, damagesource)) { return false; } else { @@ -43,3 +43,14 @@ } } +@@ -485,8 +491,8 @@ + } + + static { +- PrimitiveCodec primitivecodec = Codec.INT; +- IntFunction intfunction = EntityParrot.Variant.BY_ID; ++ PrimitiveCodec primitivecodec = Codec.INT; // CraftBukkit - decompile error ++ IntFunction intfunction = EntityParrot.Variant.BY_ID; // CraftBukkit - decompile error + + Objects.requireNonNull(intfunction); + LEGACY_CODEC = primitivecodec.xmap(intfunction::apply, EntityParrot.Variant::getId); diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch b/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch index 0f44b395a..69355b20e 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityPig.java +++ b/net/minecraft/world/entity/animal/EntityPig.java -@@ -50,6 +50,11 @@ +@@ -58,6 +58,11 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -9,10 +9,10 @@ +import org.bukkit.event.entity.EntityRemoveEvent; +// CraftBukkit end + - public class EntityPig extends EntityAnimal implements ISteerable, ISaddleable { + public class EntityPig extends EntityAnimal implements ISteerable { - private static final DataWatcherObject DATA_SADDLE_ID = DataWatcher.defineId(EntityPig.class, DataWatcherRegistry.BOOLEAN); -@@ -247,7 +252,14 @@ + private static final DataWatcherObject DATA_BOOST_TIME = DataWatcher.defineId(EntityPig.class, DataWatcherRegistry.INT); +@@ -238,7 +243,14 @@ } entitypigzombie1.setPersistenceRequired(); diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch b/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch index 10104083f..49dad4e79 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityPufferFish.java +++ b/net/minecraft/world/entity/animal/EntityPufferFish.java -@@ -155,7 +155,7 @@ +@@ -150,7 +150,7 @@ int i = this.getPuffState(); if (entityinsentient.hurtServer(worldserver, this.damageSources().mobAttack(this), (float) (1 + i))) { @@ -9,7 +9,7 @@ this.playSound(SoundEffects.PUFFER_FISH_STING, 1.0F, 1.0F); } -@@ -171,7 +171,7 @@ +@@ -166,7 +166,7 @@ entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.PUFFER_FISH_STING, 0.0F)); } diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch b/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch index 60b150a8b..781840061 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityRabbit.java +++ b/net/minecraft/world/entity/animal/EntityRabbit.java -@@ -66,6 +66,10 @@ +@@ -74,6 +74,10 @@ import net.minecraft.world.level.pathfinder.PathEntity; import net.minecraft.world.phys.Vec3D; @@ -8,10 +8,10 @@ +import org.bukkit.craftbukkit.event.CraftEventFactory; +// CraftBukkit end + - public class EntityRabbit extends EntityAnimal implements VariantHolder { + public class EntityRabbit extends EntityAnimal { public static final double STROLL_SPEED_MOD = 0.6D; -@@ -90,7 +94,6 @@ +@@ -99,7 +103,6 @@ super(entitytypes, world); this.jumpControl = new EntityRabbit.ControllerJumpRabbit(this); this.moveControl = new EntityRabbit.ControllerMoveRabbit(this); @@ -19,7 +19,18 @@ } @Override -@@ -577,9 +580,19 @@ +@@ -498,8 +501,8 @@ + } + + static { +- PrimitiveCodec primitivecodec = Codec.INT; +- IntFunction intfunction = EntityRabbit.Variant.BY_ID; ++ PrimitiveCodec primitivecodec = Codec.INT; // CraftBukkit - decompile error ++ IntFunction intfunction = EntityRabbit.Variant.BY_ID; // CraftBukkit - decompile error + + Objects.requireNonNull(intfunction); + LEGACY_CODEC = primitivecodec.xmap(intfunction::apply, EntityRabbit.Variant::id); +@@ -643,9 +646,19 @@ int i = (Integer) iblockdata.getValue(BlockCarrots.AGE); if (i == 0) { @@ -37,5 +48,5 @@ + } + // CraftBukkit end world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockCarrots.AGE, i - 1), 2); - world.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of((Entity) this.rabbit)); + world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of((Entity) this.rabbit)); world.levelEvent(2001, blockposition, Block.getId(iblockdata)); diff --git a/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch b/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch index f662758d5..d9119d202 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntitySnowman.java +++ b/net/minecraft/world/entity/animal/EntitySnowman.java -@@ -43,6 +43,10 @@ +@@ -42,6 +42,10 @@ import net.minecraft.world.level.storage.loot.LootTables; import net.minecraft.world.phys.Vec3D; @@ -10,8 +10,8 @@ + public class EntitySnowman extends EntityGolem implements IShearable, IRangedEntity { - private static final DataWatcherObject DATA_PUMPKIN_ID = DataWatcher.defineId(EntitySnowman.class, DataWatcherRegistry.BYTE); -@@ -100,7 +104,7 @@ + private static final DataWatcherObject DATA_PUMPKIN_ID = DataWatcher.defineId(EntitySnowman.class, DataWatcherRegistry.BYTE); +@@ -97,7 +101,7 @@ if (world instanceof WorldServer worldserver) { if (this.level().getBiome(this.blockPosition()).is(BiomeTags.SNOW_GOLEM_MELTS)) { @@ -20,7 +20,7 @@ } if (!worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -@@ -116,7 +120,11 @@ +@@ -113,7 +117,11 @@ BlockPosition blockposition = new BlockPosition(j, k, l); if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) { @@ -30,10 +30,10 @@ + continue; + } + // CraftBukkit end - this.level().gameEvent((Holder) GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(this, iblockdata)); + this.level().gameEvent(GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(this, iblockdata)); } } -@@ -153,6 +161,11 @@ +@@ -150,6 +158,11 @@ if (world instanceof WorldServer) { WorldServer worldserver = (WorldServer) world; @@ -45,8 +45,8 @@ this.shear(worldserver, SoundCategory.PLAYERS, itemstack); this.gameEvent(GameEvent.SHEAR, entityhuman); itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand)); -@@ -169,7 +182,9 @@ - worldserver.playSound((EntityHuman) null, (Entity) this, SoundEffects.SNOW_GOLEM_SHEAR, soundcategory, 1.0F, 1.0F); +@@ -166,7 +179,9 @@ + worldserver.playSound((Entity) null, (Entity) this, SoundEffects.SNOW_GOLEM_SHEAR, soundcategory, 1.0F, 1.0F); this.setPumpkin(false); this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_SNOW_GOLEM, itemstack, (worldserver1, itemstack1) -> { + this.forceDrops = true; // CraftBukkit diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch b/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch index 5484958bc..922af99d3 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityTurtle.java +++ b/net/minecraft/world/entity/animal/EntityTurtle.java -@@ -310,7 +310,9 @@ +@@ -265,7 +265,9 @@ WorldServer worldserver = (WorldServer) world; if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { @@ -10,7 +10,7 @@ } } } -@@ -339,7 +341,7 @@ +@@ -294,7 +296,7 @@ @Override public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { @@ -19,17 +19,17 @@ } @Override -@@ -496,12 +498,14 @@ +@@ -544,12 +546,14 @@ } else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) { World world = this.turtle.level(); + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), (IBlockData) Blocks.TURTLE_EGG.defaultBlockState().setValue(BlockTurtleEgg.EGGS, this.turtle.random.nextInt(4) + 1))) { // CraftBukkit - world.playSound((EntityHuman) null, blockposition, SoundEffects.TURTLE_LAY_EGG, SoundCategory.BLOCKS, 0.3F, 0.9F + world.random.nextFloat() * 0.2F); + world.playSound((Entity) null, blockposition, SoundEffects.TURTLE_LAY_EGG, SoundCategory.BLOCKS, 0.3F, 0.9F + world.random.nextFloat() * 0.2F); BlockPosition blockposition1 = this.blockPos.above(); IBlockData iblockdata = (IBlockData) Blocks.TURTLE_EGG.defaultBlockState().setValue(BlockTurtleEgg.EGGS, this.turtle.random.nextInt(4) + 1); world.setBlock(blockposition1, iblockdata, 3); - world.gameEvent((Holder) GameEvent.BLOCK_PLACE, blockposition1, GameEvent.a.of(this.turtle, iblockdata)); + world.gameEvent(GameEvent.BLOCK_PLACE, blockposition1, GameEvent.a.of(this.turtle, iblockdata)); + } // CraftBukkit this.turtle.setHasEgg(false); this.turtle.setLayingEgg(false); diff --git a/nms-patches/net/minecraft/world/entity/animal/allay/Allay.patch b/nms-patches/net/minecraft/world/entity/animal/allay/Allay.patch index 4f81cea4a..aa5e18aa6 100644 --- a/nms-patches/net/minecraft/world/entity/animal/allay/Allay.patch +++ b/nms-patches/net/minecraft/world/entity/animal/allay/Allay.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/allay/Allay.java +++ b/net/minecraft/world/entity/animal/allay/Allay.java -@@ -103,6 +103,7 @@ +@@ -100,6 +100,7 @@ private float dancingAnimationTicks; private float spinningAnimationTicks; private float spinningAnimationTicks0; @@ -8,8 +8,8 @@ public Allay(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -114,6 +115,12 @@ - this.dynamicJukeboxListener = new DynamicGameEventListener<>(new Allay.a(this.vibrationUser.getPositionSource(), ((GameEvent) GameEvent.JUKEBOX_PLAY.value()).notificationRadius())); +@@ -111,6 +112,12 @@ + this.dynamicJukeboxListener = new DynamicGameEventListener(new Allay.a(this.vibrationUser.getPositionSource(), ((GameEvent) GameEvent.JUKEBOX_PLAY.value()).notificationRadius())); } + // CraftBukkit start @@ -20,8 +20,8 @@ + @Override protected BehaviorController.b brainProvider() { - return BehaviorController.provider(Allay.MEMORY_TYPES, Allay.SENSOR_TYPES); -@@ -126,7 +133,7 @@ + return BehaviorController.provider(Allay.MEMORY_TYPES, Allay.SENSOR_TYPES); +@@ -123,7 +130,7 @@ @Override public BehaviorController getBrain() { @@ -30,7 +30,7 @@ } public static AttributeProvider.Builder createAttributes() { -@@ -233,7 +240,7 @@ +@@ -228,7 +235,7 @@ public void aiStep() { super.aiStep(); if (!this.level().isClientSide && this.isAlive() && this.tickCount % 10 == 0) { @@ -39,7 +39,7 @@ } if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) { -@@ -303,7 +310,12 @@ +@@ -298,7 +305,12 @@ ItemStack itemstack1 = this.getItemInHand(EnumHand.MAIN_HAND); if (this.isDancing() && itemstack.is(TagsItem.DUPLICATES_ALLAYS) && this.canDuplicate()) { @@ -53,16 +53,7 @@ this.level().broadcastEntityEvent(this, (byte) 18); this.level().playSound(entityhuman, (Entity) this, SoundEffects.AMETHYST_BLOCK_CHIME, SoundCategory.NEUTRAL, 2.0F, 1.0F); this.removeInteractionItem(entityhuman, itemstack); -@@ -314,7 +326,7 @@ - this.setItemInHand(EnumHand.MAIN_HAND, itemstack2); - this.removeInteractionItem(entityhuman, itemstack); - this.level().playSound(entityhuman, (Entity) this, SoundEffects.ALLAY_ITEM_GIVEN, SoundCategory.NEUTRAL, 2.0F, 1.0F); -- this.getBrain().setMemory(MemoryModuleType.LIKED_PLAYER, (Object) entityhuman.getUUID()); -+ this.getBrain().setMemory(MemoryModuleType.LIKED_PLAYER, entityhuman.getUUID()); // CraftBukkit - decompile error - return EnumInteractionResult.SUCCESS; - } else if (!itemstack1.isEmpty() && enumhand == EnumHand.MAIN_HAND && itemstack.isEmpty()) { - this.setItemSlot(EnumItemSlot.MAINHAND, ItemStack.EMPTY); -@@ -415,6 +427,7 @@ +@@ -407,6 +419,7 @@ } private boolean shouldStopDancing() { @@ -70,16 +61,16 @@ return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), (double) ((GameEvent) GameEvent.JUKEBOX_PLAY.value()).notificationRadius()) || !this.level().getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX); } -@@ -506,7 +519,7 @@ - +@@ -486,7 +499,7 @@ + this.entityData.set(Allay.DATA_CAN_DUPLICATE, i == 0L); } - public void duplicateAllay() { + public Allay duplicateAllay() { // CraftBukkit - return allay - Allay allay = (Allay) EntityTypes.ALLAY.create(this.level(), EntitySpawnReason.BREEDING); + Allay allay = EntityTypes.ALLAY.create(this.level(), EntitySpawnReason.BREEDING); if (allay != null) { -@@ -514,9 +527,9 @@ +@@ -494,9 +507,9 @@ allay.setPersistenceRequired(); allay.resetDuplicationCooldown(); this.resetDuplicationCooldown(); diff --git a/nms-patches/net/minecraft/world/entity/animal/armadillo/Armadillo.patch b/nms-patches/net/minecraft/world/entity/animal/armadillo/Armadillo.patch index 8187e9f14..d5c9819bb 100644 --- a/nms-patches/net/minecraft/world/entity/animal/armadillo/Armadillo.patch +++ b/nms-patches/net/minecraft/world/entity/animal/armadillo/Armadillo.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java +++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java -@@ -48,6 +48,10 @@ +@@ -49,6 +49,10 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.storage.loot.LootTables; @@ -11,7 +11,7 @@ public class Armadillo extends EntityAnimal { public static final float BABY_SCALE = 0.6F; -@@ -135,16 +139,18 @@ +@@ -136,16 +140,18 @@ GameProfilerFiller gameprofilerfiller = Profiler.get(); gameprofilerfiller.push("armadilloBrain"); @@ -65,12 +65,3 @@ this.gameEvent(GameEvent.ENTITY_INTERACT); this.playSound(SoundEffects.ARMADILLO_BRUSH); } -@@ -431,7 +445,7 @@ - } - - public static Armadillo.a fromName(String s) { -- return (Armadillo.a) Armadillo.a.CODEC.byName(s, (Enum) Armadillo.a.IDLE); -+ return (Armadillo.a) Armadillo.a.CODEC.byName(s, Armadillo.a.IDLE); // CraftBukkit - decompile error - } - - @Override diff --git a/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch b/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch index b97522852..28fee4c59 100644 --- a/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch +++ b/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java +++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java -@@ -67,10 +67,17 @@ +@@ -73,10 +73,17 @@ - public class Axolotl extends EntityAnimal implements VariantHolder, Bucketable { + public class Axolotl extends EntityAnimal implements Bucketable { + // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + @Override @@ -16,10 +16,10 @@ - protected static final ImmutableList> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.BREED_TARGET, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT, new MemoryModuleType[]{MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.PLAY_DEAD_TICKS, MemoryModuleType.NEAREST_ATTACKABLE, MemoryModuleType.TEMPTING_PLAYER, MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, MemoryModuleType.IS_TEMPTED, MemoryModuleType.HAS_HUNTING_COOLDOWN, MemoryModuleType.IS_PANICKING}); + // CraftBukkit - decompile error + protected static final ImmutableList> MEMORY_TYPES = ImmutableList.>of(MemoryModuleType.BREED_TARGET, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT, new MemoryModuleType[]{MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.PLAY_DEAD_TICKS, MemoryModuleType.NEAREST_ATTACKABLE, MemoryModuleType.TEMPTING_PLAYER, MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, MemoryModuleType.IS_TEMPTED, MemoryModuleType.HAS_HUNTING_COOLDOWN, MemoryModuleType.IS_PANICKING}); - private static final DataWatcherObject DATA_VARIANT = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.INT); - private static final DataWatcherObject DATA_PLAYING_DEAD = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN); - private static final DataWatcherObject FROM_BUCKET = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN); -@@ -210,7 +217,7 @@ + private static final DataWatcherObject DATA_VARIANT = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.INT); + private static final DataWatcherObject DATA_PLAYING_DEAD = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN); + private static final DataWatcherObject FROM_BUCKET = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN); +@@ -223,7 +230,7 @@ @Override public int getMaxAirSupply() { @@ -27,8 +27,8 @@ + return maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() } - @Override -@@ -414,7 +421,7 @@ + public Axolotl.Variant getVariant() { +@@ -445,7 +452,7 @@ int i = mobeffect != null ? mobeffect.getDuration() : 0; int j = Math.min(2400, 100 + i); @@ -36,8 +36,8 @@ + entityhuman.addEffect(new MobEffect(MobEffects.REGENERATION, j, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AXOLOTL); // CraftBukkit } - entityhuman.removeEffect(MobEffects.DIG_SLOWDOWN); -@@ -464,7 +471,7 @@ + entityhuman.removeEffect(MobEffects.MINING_FATIGUE); +@@ -495,7 +502,7 @@ @Override public BehaviorController getBrain() { @@ -46,3 +46,14 @@ } @Override +@@ -598,8 +605,8 @@ + } + + static { +- PrimitiveCodec primitivecodec = Codec.INT; +- IntFunction intfunction = Axolotl.Variant.BY_ID; ++ PrimitiveCodec primitivecodec = Codec.INT; // CraftBukkit - decompile error ++ IntFunction intfunction = Axolotl.Variant.BY_ID; // CraftBukkit - decompile error + + Objects.requireNonNull(intfunction); + LEGACY_CODEC = primitivecodec.xmap(intfunction::apply, Axolotl.Variant::getId); diff --git a/nms-patches/net/minecraft/world/entity/animal/camel/Camel.patch b/nms-patches/net/minecraft/world/entity/animal/camel/Camel.patch index 1c78bcdba..7c93afb05 100644 --- a/nms-patches/net/minecraft/world/entity/animal/camel/Camel.patch +++ b/nms-patches/net/minecraft/world/entity/animal/camel/Camel.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/camel/Camel.java +++ b/net/minecraft/world/entity/animal/camel/Camel.java -@@ -50,6 +50,10 @@ +@@ -55,6 +55,10 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public class Camel extends EntityHorseAbstract { public static final float BABY_SCALE = 0.45F; -@@ -143,7 +147,7 @@ +@@ -153,7 +157,7 @@ GameProfilerFiller gameprofilerfiller = Profiler.get(); gameprofilerfiller.push("camelBrain"); @@ -20,7 +20,7 @@ behaviorcontroller.tick(worldserver, this); gameprofilerfiller.pop(); -@@ -454,9 +458,15 @@ +@@ -464,9 +468,15 @@ } @Override diff --git a/nms-patches/net/minecraft/world/entity/animal/frog/ShootTongue.patch b/nms-patches/net/minecraft/world/entity/animal/frog/ShootTongue.patch index 00ad10cb2..a2e6b357a 100644 --- a/nms-patches/net/minecraft/world/entity/animal/frog/ShootTongue.patch +++ b/nms-patches/net/minecraft/world/entity/animal/frog/ShootTongue.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/frog/ShootTongue.java +++ b/net/minecraft/world/entity/animal/frog/ShootTongue.java -@@ -20,6 +20,10 @@ +@@ -19,6 +19,10 @@ import net.minecraft.world.level.pathfinder.PathEntity; import net.minecraft.world.phys.Vec3D; @@ -11,16 +11,7 @@ public class ShootTongue extends Behavior { public static final int TIME_OUT_DURATION = 100; -@@ -64,7 +68,7 @@ - - BehaviorUtil.lookAtEntity(frog, entityliving); - frog.setTongueTarget(entityliving); -- frog.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(entityliving.position(), 2.0F, 0))); -+ frog.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(entityliving.position(), 2.0F, 0))); // CraftBukkit - decompile error - this.calculatePathCounter = 10; - this.state = ShootTongue.a.MOVE_TO_TARGET; - } -@@ -85,7 +89,7 @@ +@@ -84,7 +88,7 @@ if (entity.isAlive()) { frog.doHurtTarget(worldserver, entity); if (!entity.isAlive()) { @@ -29,12 +20,3 @@ } } } -@@ -106,7 +110,7 @@ - this.eatAnimationTimer = 0; - this.state = ShootTongue.a.CATCH_ANIMATION; - } else if (this.calculatePathCounter <= 0) { -- frog.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(entityliving.position(), 2.0F, 0))); -+ frog.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(entityliving.position(), 2.0F, 0))); // CraftBukkit - decompile error - this.calculatePathCounter = 10; - } else { - --this.calculatePathCounter; diff --git a/nms-patches/net/minecraft/world/entity/animal/frog/Tadpole.patch b/nms-patches/net/minecraft/world/entity/animal/frog/Tadpole.patch index d8295126d..f315f5c16 100644 --- a/nms-patches/net/minecraft/world/entity/animal/frog/Tadpole.patch +++ b/nms-patches/net/minecraft/world/entity/animal/frog/Tadpole.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/frog/Tadpole.java +++ b/net/minecraft/world/entity/animal/frog/Tadpole.java -@@ -74,7 +74,7 @@ +@@ -75,7 +75,7 @@ @Override public BehaviorController getBrain() { @@ -9,7 +9,7 @@ } @Override -@@ -225,12 +225,17 @@ +@@ -223,12 +223,17 @@ World world = this.level(); if (world instanceof WorldServer worldserver) { diff --git a/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch b/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch index fa246c2f2..d9333c806 100644 --- a/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch +++ b/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch @@ -13,7 +13,7 @@ public class Goat extends EntityAnimal { public static final EntitySize LONG_JUMPING_DIMENSIONS = EntitySize.scalable(0.9F, 1.3F).scale(0.7F); -@@ -184,7 +190,7 @@ +@@ -187,7 +193,7 @@ @Override public BehaviorController getBrain() { @@ -22,7 +22,7 @@ } @Override -@@ -229,8 +235,15 @@ +@@ -232,8 +238,15 @@ ItemStack itemstack = entityhuman.getItemInHand(enumhand); if (itemstack.is(Items.BUCKET) && !this.isBaby()) { diff --git a/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch b/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch index 685772745..081caa33c 100644 --- a/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch +++ b/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch @@ -1,88 +1,36 @@ --- a/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java +++ b/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java -@@ -79,6 +79,18 @@ +@@ -74,6 +74,12 @@ + import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; - 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.AbstractHorse; -+import org.bukkit.entity.HumanEntity; +import org.bukkit.event.entity.EntityRegainHealthEvent; -+import org.bukkit.inventory.InventoryHolder; +// CraftBukkit end + - public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, HasCustomInventoryScreen, OwnableEntity, IJumpable, ISaddleable { + public abstract class EntityHorseAbstract extends EntityAnimal implements HasCustomInventoryScreen, OwnableEntity, IJumpable { - public static final int EQUIPMENT_SLOT_OFFSET = 400; -@@ -167,7 +179,53 @@ - public boolean stillValid(EntityHuman entityhuman) { - return entityhuman.getVehicle() == EntityHorseAbstract.this || entityhuman.canInteractWithEntity((Entity) EntityHorseAbstract.this, 4.0D); - } -+ -+ // CraftBukkit start - add fields and methods -+ public 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 who) { -+ transaction.add(who); -+ } -+ -+ @Override -+ public void onClose(CraftHumanEntity who) { -+ transaction.remove(who); -+ } -+ -+ @Override -+ public List getViewers() { -+ return transaction; -+ } -+ -+ @Override -+ public int getMaxStackSize() { -+ return maxStack; -+ } -+ -+ @Override -+ public void setMaxStackSize(int size) { -+ maxStack = size; -+ } -+ -+ @Override -+ public InventoryHolder getOwner() { -+ return (AbstractHorse) EntityHorseAbstract.this.getBukkitEntity(); -+ } -+ -+ @Override -+ public Location getLocation() { -+ return EntityHorseAbstract.this.getBukkitEntity().getLocation(); -+ } -+ // CraftBukkit end - }; + public static final int CHEST_SLOT_OFFSET = 499; +@@ -144,6 +150,7 @@ + protected int gallopSoundCounter; + @Nullable + public EntityReference owner; + public int maxDomestication = 100; // CraftBukkit - store max domestication value protected EntityHorseAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -366,7 +424,7 @@ +@@ -323,7 +330,7 @@ public void createInventory() { InventorySubcontainer inventorysubcontainer = this.inventory; - this.inventory = new InventorySubcontainer(this.getInventorySize()); + this.inventory = new InventorySubcontainer(this.getInventorySize(), (AbstractHorse) this.getBukkitEntity()); // CraftBukkit if (inventorysubcontainer != null) { - inventorysubcontainer.removeListener(this); int i = Math.min(inventorysubcontainer.getContainerSize(), this.inventory.getContainerSize()); -@@ -470,7 +528,7 @@ + +@@ -412,7 +419,7 @@ } public int getMaxTemper() { @@ -91,7 +39,7 @@ } @Override -@@ -541,7 +599,7 @@ +@@ -483,7 +490,7 @@ } if (this.getHealth() < this.getMaxHealth() && f > 0.0F) { @@ -100,7 +48,7 @@ flag = true; } -@@ -618,7 +676,7 @@ +@@ -560,7 +567,7 @@ if (world instanceof WorldServer worldserver) { if (this.isAlive()) { if (this.random.nextInt(900) == 0 && this.deathTime == 0) { @@ -109,27 +57,25 @@ } if (this.canEatGrass()) { -@@ -883,6 +941,7 @@ - if (this.getOwnerUUID() != null) { - nbttagcompound.putUUID("Owner", this.getOwnerUUID()); +@@ -825,6 +832,7 @@ + if (this.owner != null) { + this.owner.store(nbttagcompound, "Owner"); } + nbttagcompound.putInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit - if (!this.inventory.getItem(0).isEmpty()) { - nbttagcompound.put("SaddleItem", this.inventory.getItem(0).save(this.registryAccess())); -@@ -910,6 +969,11 @@ - if (uuid != null) { - this.setOwnerUUID(uuid); - } -+ // CraftBukkit start -+ if (nbttagcompound.contains("Bukkit.MaxDomestication")) { -+ this.maxDomestication = nbttagcompound.getInt("Bukkit.MaxDomestication"); -+ } -+ // CraftBukkit end + } - if (nbttagcompound.contains("SaddleItem", 10)) { - ItemStack itemstack = (ItemStack) ItemStack.parse(this.registryAccess(), nbttagcompound.getCompound("SaddleItem")).orElse(ItemStack.EMPTY); -@@ -1012,6 +1076,17 @@ +@@ -836,6 +844,9 @@ + this.setTemper(nbttagcompound.getIntOr("Temper", 0)); + this.setTamed(nbttagcompound.getBooleanOr("Tame", false)); + this.owner = EntityReference.readWithOldOwnerConversion(nbttagcompound, "Owner", this.level()); ++ // CraftBukkit start ++ this.maxDomestication = nbttagcompound.getIntOr("Bukkit.MaxDomestication", this.maxDomestication); ++ // CraftBukkit end + } + + @Override +@@ -929,6 +940,17 @@ @Override public void handleStartJump(int i) { diff --git a/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseSkeleton.patch b/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseSkeleton.patch index b63cd2431..df9f657ab 100644 --- a/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseSkeleton.patch +++ b/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseSkeleton.patch @@ -11,7 +11,7 @@ public class EntityHorseSkeleton extends EntityHorseAbstract { private final PathfinderGoalHorseTrap skeletonTrapGoal = new PathfinderGoalHorseTrap(this); -@@ -122,7 +126,7 @@ +@@ -124,7 +128,7 @@ public void aiStep() { super.aiStep(); if (this.isTrap() && this.trapTime++ >= 18000) { diff --git a/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlama.patch b/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlama.patch index edd02d7ad..05619a8c2 100644 --- a/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlama.patch +++ b/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlama.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/EntityLlama.java +++ b/net/minecraft/world/entity/animal/horse/EntityLlama.java -@@ -82,6 +82,11 @@ +@@ -88,6 +88,11 @@ return false; } @@ -12,3 +12,14 @@ private void setStrength(int i) { this.entityData.set(EntityLlama.DATA_STRENGTH_ID, Math.max(1, Math.min(5, i))); } +@@ -479,8 +484,8 @@ + } + + static { +- PrimitiveCodec primitivecodec = Codec.INT; +- IntFunction intfunction = EntityLlama.Variant.BY_ID; ++ PrimitiveCodec primitivecodec = Codec.INT; // CraftBukkit - decompile error ++ IntFunction intfunction = EntityLlama.Variant.BY_ID; // CraftBukkit - decompile error + + Objects.requireNonNull(intfunction); + LEGACY_CODEC = primitivecodec.xmap(intfunction::apply, EntityLlama.Variant::getId); diff --git a/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch b/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch index 0c8602cd2..fdbe00fd2 100644 --- a/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch +++ b/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch @@ -10,8 +10,8 @@ + public class EntityLlamaTrader extends EntityLlama { - private int despawnDelay = 47999; -@@ -94,7 +98,7 @@ + private static final int DEFAULT_DESPAWN_DELAY = 47999; +@@ -92,7 +96,7 @@ this.despawnDelay = this.isLeashedToWanderingTrader() ? ((EntityVillagerTrader) this.getLeashHolder()).getDespawnDelay() - 1 : this.despawnDelay - 1; if (this.despawnDelay <= 0) { this.removeLeash(); @@ -20,7 +20,7 @@ } } -@@ -160,7 +164,7 @@ +@@ -158,7 +162,7 @@ @Override public void start() { diff --git a/nms-patches/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.patch b/nms-patches/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.patch index d004aa143..54bd91e42 100644 --- a/nms-patches/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.patch +++ b/nms-patches/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.java @@ -43,12 +43,12 @@ if (entitylightning != null) { - entitylightning.moveTo(this.horse.getX(), this.horse.getY(), this.horse.getZ()); + entitylightning.snapTo(this.horse.getX(), this.horse.getY(), this.horse.getZ()); entitylightning.setVisualOnly(true); - worldserver.addFreshEntity(entitylightning); + worldserver.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRAP); // CraftBukkit diff --git a/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch b/nms-patches/net/minecraft/world/entity/animal/sheep/EntitySheep.patch similarity index 85% rename from nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch rename to nms-patches/net/minecraft/world/entity/animal/sheep/EntitySheep.patch index ad06fe3b2..486ce80a6 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch +++ b/nms-patches/net/minecraft/world/entity/animal/sheep/EntitySheep.patch @@ -1,11 +1,10 @@ ---- a/net/minecraft/world/entity/animal/EntitySheep.java -+++ b/net/minecraft/world/entity/animal/EntitySheep.java -@@ -50,6 +50,12 @@ +--- a/net/minecraft/world/entity/animal/sheep/EntitySheep.java ++++ b/net/minecraft/world/entity/animal/sheep/EntitySheep.java +@@ -53,6 +53,11 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.storage.loot.LootTables; +// CraftBukkit start -+import net.minecraft.world.item.Item; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.SheepRegrowWoolEvent; +// CraftBukkit end @@ -13,7 +12,7 @@ public class EntitySheep extends EntityAnimal implements IShearable { private static final int EAT_ANIMATION_TICKS = 40; -@@ -160,6 +166,11 @@ +@@ -163,6 +168,11 @@ WorldServer worldserver = (WorldServer) world; if (this.readyForShearing()) { @@ -25,8 +24,8 @@ this.shear(worldserver, SoundCategory.PLAYERS, itemstack); this.gameEvent(GameEvent.SHEAR, entityhuman); itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand)); -@@ -178,7 +189,9 @@ - worldserver.playSound((EntityHuman) null, (Entity) this, SoundEffects.SHEEP_SHEAR, soundcategory, 1.0F, 1.0F); +@@ -181,7 +191,9 @@ + worldserver.playSound((Entity) null, (Entity) this, SoundEffects.SHEEP_SHEAR, soundcategory, 1.0F, 1.0F); this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_SHEEP, itemstack, (worldserver1, itemstack1) -> { for (int i = 0; i < itemstack1.getCount(); ++i) { + this.forceDrops = true; // CraftBukkit @@ -35,7 +34,7 @@ if (entityitem != null) { entityitem.setDeltaMovement(entityitem.getDeltaMovement().add((double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (this.random.nextFloat() * 0.05F), (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F))); -@@ -276,6 +289,12 @@ +@@ -301,6 +313,12 @@ @Override public void ate() { diff --git a/nms-patches/net/minecraft/world/entity/animal/sniffer/Sniffer.patch b/nms-patches/net/minecraft/world/entity/animal/sniffer/Sniffer.patch index a100d9df9..8fb6bf9a6 100644 --- a/nms-patches/net/minecraft/world/entity/animal/sniffer/Sniffer.patch +++ b/nms-patches/net/minecraft/world/entity/animal/sniffer/Sniffer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java +++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java -@@ -267,6 +267,13 @@ +@@ -266,6 +266,13 @@ this.dropFromGiftLootTable(worldserver, LootTables.SNIFFER_DIGGING, (worldserver1, itemstack) -> { EntityItem entityitem = new EntityItem(this.level(), (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack); @@ -14,16 +14,7 @@ entityitem.setDefaultPickUpDelay(); worldserver1.addFreshEntity(entityitem); }); -@@ -308,7 +315,7 @@ - List list = (List) this.getExploredPositions().limit(20L).collect(Collectors.toList()); - - list.add(0, GlobalPos.of(this.level().dimension(), blockposition)); -- this.getBrain().setMemory(MemoryModuleType.SNIFFER_EXPLORED_POSITIONS, (Object) list); -+ this.getBrain().setMemory(MemoryModuleType.SNIFFER_EXPLORED_POSITIONS, list); // CraftBukkit - decompile error - return this; - } - -@@ -444,7 +451,7 @@ +@@ -443,7 +450,7 @@ @Override public BehaviorController getBrain() { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch b/nms-patches/net/minecraft/world/entity/animal/wolf/EntityWolf.patch similarity index 69% rename from nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch rename to nms-patches/net/minecraft/world/entity/animal/wolf/EntityWolf.patch index e29a99b4b..7c063dec0 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch +++ b/nms-patches/net/minecraft/world/entity/animal/wolf/EntityWolf.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/EntityWolf.java -+++ b/net/minecraft/world/entity/animal/EntityWolf.java -@@ -86,6 +86,13 @@ +--- a/net/minecraft/world/entity/animal/wolf/EntityWolf.java ++++ b/net/minecraft/world/entity/animal/wolf/EntityWolf.java +@@ -89,6 +89,13 @@ import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.phys.Vec3D; @@ -11,10 +11,10 @@ +import org.bukkit.craftbukkit.event.CraftEventFactory; +// CraftBukkit end + - public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable, VariantHolder> { + public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable { - private static final DataWatcherObject DATA_INTERESTED_ID = DataWatcher.defineId(EntityWolf.class, DataWatcherRegistry.BOOLEAN); -@@ -345,8 +352,14 @@ + private static final DataWatcherObject DATA_INTERESTED_ID = DataWatcher.defineId(EntityWolf.class, DataWatcherRegistry.BOOLEAN); +@@ -386,16 +393,27 @@ if (this.isInvulnerableTo(worldserver, damagesource)) { return false; } else { @@ -30,9 +30,6 @@ } } -@@ -356,10 +369,15 @@ - } - @Override - protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) { + public boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) { // CraftBukkit - void -> boolean @@ -48,7 +45,7 @@ ItemStack itemstack = this.getBodyArmorItem(); int i = itemstack.getDamageValue(); int j = itemstack.getMaxDamage(); -@@ -371,6 +389,7 @@ +@@ -407,6 +425,7 @@ } } @@ -56,7 +53,7 @@ } private boolean canArmorAbsorb(DamageSource damagesource) { -@@ -381,7 +400,7 @@ +@@ -417,7 +436,7 @@ protected void applyTamingSideEffects() { if (this.isTame()) { this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(40.0D); @@ -65,7 +62,7 @@ } else { this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(8.0D); } -@@ -404,7 +423,7 @@ +@@ -440,7 +459,7 @@ FoodInfo foodinfo = (FoodInfo) itemstack.get(DataComponents.FOOD); float f = foodinfo != null ? (float) foodinfo.nutrition() : 1.0F; @@ -74,26 +71,26 @@ return EnumInteractionResult.SUCCESS; } else { if (item instanceof ItemDye) { -@@ -440,7 +459,9 @@ - if (world instanceof WorldServer) { - WorldServer worldserver = (WorldServer) world; +@@ -474,7 +493,9 @@ + if (world instanceof WorldServer) { + WorldServer worldserver = (WorldServer) world; -+ this.forceDrops = true; // CraftBukkit - this.spawnAtLocation(worldserver, itemstack1); -+ this.forceDrops = false; // CraftBukkit - } ++ this.forceDrops = true; // CraftBukkit + this.spawnAtLocation(worldserver, itemstack1); ++ this.forceDrops = false; // CraftBukkit + } - return EnumInteractionResult.SUCCESS; -@@ -459,7 +480,7 @@ - this.setOrderedToSit(!this.isOrderedToSit()); - this.jumping = false; - this.navigation.stop(); -- this.setTarget((EntityLiving) null); -+ this.setTarget((EntityLiving) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason - return EnumInteractionResult.SUCCESS.withoutItem(); - } else { - return enuminteractionresult; -@@ -477,7 +498,8 @@ + return EnumInteractionResult.SUCCESS; +@@ -493,7 +514,7 @@ + this.setOrderedToSit(!this.isOrderedToSit()); + this.jumping = false; + this.navigation.stop(); +- this.setTarget((EntityLiving) null); ++ this.setTarget((EntityLiving) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason + return EnumInteractionResult.SUCCESS.withoutItem(); + } else { + return enuminteractionresult; +@@ -510,7 +531,8 @@ } private void tryToTame(EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch b/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch index 1bc0b773e..61a114de9 100644 --- a/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch +++ b/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.java +++ b/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.java -@@ -20,6 +20,12 @@ +@@ -19,6 +19,12 @@ import net.minecraft.world.level.block.BlockFireAbstract; import net.minecraft.world.level.dimension.end.EnderDragonBattle; @@ -12,7 +12,7 @@ + public class EntityEnderCrystal extends Entity { - private static final DataWatcherObject> DATA_BEAM_TARGET = DataWatcher.defineId(EntityEnderCrystal.class, DataWatcherRegistry.OPTIONAL_BLOCK_POS); + private static final DataWatcherObject> DATA_BEAM_TARGET = DataWatcher.>defineId(EntityEnderCrystal.class, DataWatcherRegistry.OPTIONAL_BLOCK_POS); @@ -57,7 +63,11 @@ BlockPosition blockposition = this.blockPosition(); @@ -26,7 +26,16 @@ } } -@@ -99,12 +109,26 @@ +@@ -71,7 +81,7 @@ + + @Override + protected void readAdditionalSaveData(NBTTagCompound nbttagcompound) { +- this.setBeamTarget((BlockPosition) nbttagcompound.read("beam_target", BlockPosition.CODEC).orElse((Object) null)); ++ this.setBeamTarget((BlockPosition) nbttagcompound.read("beam_target", BlockPosition.CODEC).orElse(null)); // CraftBukkit - decompile error + this.setShowBottom(nbttagcompound.getBooleanOr("ShowBottom", true)); + } + +@@ -93,12 +103,26 @@ return false; } else { if (!this.isRemoved()) { diff --git a/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch b/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch index d98583e7f..484fa0764 100644 --- a/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch +++ b/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java +++ b/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java -@@ -52,6 +52,22 @@ +@@ -51,6 +51,22 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -39,7 +39,7 @@ } public void setDragonFight(EnderDragonBattle enderdragonbattle) { -@@ -218,7 +236,7 @@ +@@ -212,7 +230,7 @@ Vec3D vec3d1 = idragoncontroller.getFlyTargetLocation(); @@ -48,7 +48,7 @@ double d0 = vec3d1.x - this.getX(); double d1 = vec3d1.y - this.getY(); double d2 = vec3d1.z - this.getZ(); -@@ -379,7 +397,14 @@ +@@ -369,7 +387,14 @@ if (this.nearestCrystal.isRemoved()) { this.nearestCrystal = null; } else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) { @@ -64,7 +64,7 @@ } } -@@ -458,6 +483,9 @@ +@@ -439,6 +464,9 @@ int j1 = MathHelper.floor(axisalignedbb.maxZ); boolean flag = false; boolean flag1 = false; @@ -74,7 +74,7 @@ for (int k1 = i; k1 <= l; ++k1) { for (int l1 = j; l1 <= i1; ++l1) { -@@ -467,7 +495,11 @@ +@@ -448,7 +476,11 @@ if (!iblockdata.isAir() && !iblockdata.is(TagsBlock.DRAGON_TRANSPARENT)) { if (worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.is(TagsBlock.DRAGON_IMMUNE)) { @@ -87,7 +87,7 @@ } else { flag = true; } -@@ -476,6 +508,49 @@ +@@ -457,6 +489,49 @@ } } @@ -137,7 +137,7 @@ if (flag1) { BlockPosition blockposition1 = new BlockPosition(i + this.random.nextInt(l - i + 1), j + this.random.nextInt(i1 - j + 1), k + this.random.nextInt(j1 - k + 1)); -@@ -531,7 +606,7 @@ +@@ -512,7 +587,7 @@ @Override public void kill(WorldServer worldserver) { @@ -146,7 +146,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); if (this.dragonFight != null) { this.dragonFight.updateDragon(this); -@@ -540,6 +615,21 @@ +@@ -521,6 +596,21 @@ } @@ -168,19 +168,19 @@ @Override protected void tickDeath() { if (this.dragonFight != null) { -@@ -555,16 +645,21 @@ +@@ -536,16 +626,21 @@ this.level().addParticle(Particles.EXPLOSION_EMITTER, this.getX() + (double) f, this.getY() + 2.0D + (double) f1, this.getZ() + (double) f2, 0.0D, 0.0D, 0.0D); } + // CraftBukkit start - SPIGOT-2420: Moved up to #getExpReward method + /* - short short0 = 500; + int i = 500; if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) { - short0 = 12000; + i = 12000; } + */ -+ int short0 = expToDrop; ++ int i = expToDrop; + // CraftBukkit end World world = this.level(); @@ -188,19 +188,19 @@ if (world instanceof WorldServer worldserver) { - if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && true) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp - EntityExperienceOrb.award(worldserver, this.position(), MathHelper.floor((float) short0 * 0.08F)); + EntityExperienceOrb.award(worldserver, this.position(), MathHelper.floor((float) i * 0.08F)); } -@@ -592,7 +687,7 @@ +@@ -569,7 +664,7 @@ if (world1 instanceof WorldServer) { WorldServer worldserver1 = (WorldServer) world1; - if (worldserver1.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + if (true) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp - EntityExperienceOrb.award(worldserver1, this.position(), MathHelper.floor((float) short0 * 0.2F)); + EntityExperienceOrb.award(worldserver1, this.position(), MathHelper.floor((float) i * 0.2F)); } -@@ -600,7 +695,7 @@ +@@ -577,7 +672,7 @@ this.dragonFight.setDragonKilled(this); } @@ -209,7 +209,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); } } -@@ -814,6 +909,7 @@ +@@ -788,6 +883,7 @@ super.addAdditionalSaveData(nbttagcompound); nbttagcompound.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId()); nbttagcompound.putInt("DragonDeathTime", this.dragonDeathTime); @@ -217,15 +217,11 @@ } @Override -@@ -827,6 +923,11 @@ - this.dragonDeathTime = nbttagcompound.getInt("DragonDeathTime"); - } - -+ // CraftBukkit start - SPIGOT-2420: The ender dragon drops xp over time which can also happen between server starts -+ if (nbttagcompound.contains("Bukkit.expToDrop")) { -+ this.expToDrop = nbttagcompound.getInt("Bukkit.expToDrop"); -+ } -+ // CraftBukkit end +@@ -797,6 +893,7 @@ + this.phaseManager.setPhase(DragonControllerPhase.getById(integer)); + }); + this.dragonDeathTime = nbttagcompound.getIntOr("DragonDeathTime", 0); ++ this.expToDrop = nbttagcompound.getIntOr("Bukkit.expToDrop", this.expToDrop); // CraftBukkit - SPIGOT-2420: The ender dragon drops xp over time which can also happen between server starts } @Override diff --git a/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerLandedFlame.patch b/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerLandedFlame.patch index b38a3a09c..c8e6e095e 100644 --- a/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerLandedFlame.patch +++ b/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerLandedFlame.patch @@ -11,7 +11,7 @@ public class DragonControllerLandedFlame extends AbstractDragonControllerLanded { private static final int FLAME_DURATION = 200; -@@ -100,7 +104,7 @@ +@@ -101,7 +105,7 @@ @Override public void end() { if (this.flame != null) { diff --git a/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.patch b/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.patch index 21603a23d..60cc411aa 100644 --- a/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.patch +++ b/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.patch @@ -32,11 +32,3 @@ this.currentPhase = this.getPhase(dragoncontrollerphase); if (!this.dragon.level().isClientSide) { this.dragon.getEntityData().set(EntityEnderDragon.DATA_PHASE, dragoncontrollerphase.getId()); -@@ -45,6 +63,6 @@ - this.phases[i] = dragoncontrollerphase.createInstance(this.dragon); - } - -- return this.phases[i]; -+ return (T) this.phases[i]; // CraftBukkit - decompile error - } - } diff --git a/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch b/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch index d814839e7..811849ba8 100644 --- a/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch +++ b/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/wither/EntityWither.java +++ b/net/minecraft/world/entity/boss/wither/EntityWither.java -@@ -57,6 +57,18 @@ +@@ -56,6 +56,18 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.Vec3D; @@ -18,9 +18,9 @@ + public class EntityWither extends EntityMonster implements IRangedEntity { - private static final DataWatcherObject DATA_TARGET_A = DataWatcher.defineId(EntityWither.class, DataWatcherRegistry.INT); -@@ -252,15 +264,40 @@ - i = this.getInvulnerableTicks() - 1; + private static final DataWatcherObject DATA_TARGET_A = DataWatcher.defineId(EntityWither.class, DataWatcherRegistry.INT); +@@ -247,15 +259,40 @@ + this.bossEvent.setProgress(1.0F - (float) i / 220.0F); if (i <= 0) { - worldserver.explode(this, this.getX(), this.getEyeY(), this.getZ(), 7.0F, false, World.a.MOB); @@ -63,15 +63,15 @@ } } else { -@@ -305,6 +342,7 @@ +@@ -299,6 +336,7 @@ if (!list.isEmpty()) { EntityLiving entityliving1 = (EntityLiving) list.get(this.random.nextInt(list.size())); + if (CraftEventFactory.callEntityTargetLivingEvent(this, entityliving1, EntityTargetEvent.TargetReason.CLOSEST_ENTITY).isCancelled()) continue; // CraftBukkit - this.setAlternativeTarget(i, entityliving1.getId()); + this.setAlternativeTarget(j, entityliving1.getId()); } } -@@ -331,6 +369,11 @@ +@@ -322,6 +360,11 @@ IBlockData iblockdata = worldserver.getBlockState(blockposition); if (canDestroy(iblockdata)) { @@ -83,7 +83,7 @@ flag = worldserver.destroyBlock(blockposition, true, this) || flag; } } -@@ -342,7 +385,7 @@ +@@ -333,7 +376,7 @@ } if (this.tickCount % 20 == 0) { @@ -92,7 +92,7 @@ } this.bossEvent.setProgress(this.getHealth() / this.getMaxHealth()); -@@ -499,7 +542,7 @@ +@@ -490,7 +533,7 @@ @Override public void checkDespawn() { if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.shouldDespawnInPeaceful()) { diff --git a/nms-patches/net/minecraft/world/entity/decoration/BlockAttachedEntity.patch b/nms-patches/net/minecraft/world/entity/decoration/BlockAttachedEntity.patch index 27d3b35bb..d642bcc12 100644 --- a/nms-patches/net/minecraft/world/entity/decoration/BlockAttachedEntity.patch +++ b/nms-patches/net/minecraft/world/entity/decoration/BlockAttachedEntity.patch @@ -107,4 +107,13 @@ + @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { - BlockPosition blockposition = this.getPos(); + nbttagcompound.store("block_pos", BlockPosition.CODEC, this.getPos()); +@@ -128,7 +190,7 @@ + + @Override + public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { +- BlockPosition blockposition = (BlockPosition) nbttagcompound.read("block_pos", BlockPosition.CODEC).orElse((Object) null); ++ BlockPosition blockposition = (BlockPosition) nbttagcompound.read("block_pos", BlockPosition.CODEC).orElse(null); // CraftBukkit - decompile error + + if (blockposition != null && blockposition.closerThan(this.blockPosition(), 16.0D)) { + this.pos = blockposition; diff --git a/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch b/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch index 159454706..9ef1db97e 100644 --- a/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch +++ b/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/EntityArmorStand.java +++ b/net/minecraft/world/entity/decoration/EntityArmorStand.java -@@ -48,6 +48,16 @@ +@@ -44,6 +44,16 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -31,30 +31,7 @@ @Override public void refreshDimensions() { double d0 = this.getX(); -@@ -183,13 +200,20 @@ - - @Override - public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { -+ // CraftBukkit start -+ this.setItemSlot(enumitemslot, itemstack, false); -+ } -+ -+ @Override -+ public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) { -+ // CraftBukkit end - this.verifyEquippedItem(itemstack); - switch (enumitemslot.getType()) { - case HAND: -- this.onEquipItem(enumitemslot, (ItemStack) this.handItems.set(enumitemslot.getIndex(), itemstack), itemstack); -+ this.onEquipItem(enumitemslot, (ItemStack) this.handItems.set(enumitemslot.getIndex(), itemstack), itemstack, silent); // CraftBukkit - break; - case HUMANOID_ARMOR: -- this.onEquipItem(enumitemslot, (ItemStack) this.armorItems.set(enumitemslot.getIndex(), itemstack), itemstack); -+ this.onEquipItem(enumitemslot, (ItemStack) this.armorItems.set(enumitemslot.getIndex(), itemstack), itemstack, silent); // CraftBukkit - } - - } -@@ -412,7 +436,25 @@ +@@ -316,7 +333,25 @@ return false; } else if (itemstack1.isEmpty() && (this.disabledSlots & 1 << enumitemslot.getFilterBit(16)) != 0) { return false; @@ -81,7 +58,7 @@ this.setItemSlot(enumitemslot, itemstack.copyWithCount(1)); return true; } else if (!itemstack.isEmpty() && itemstack.getCount() > 1) { -@@ -427,6 +469,7 @@ +@@ -331,6 +366,7 @@ entityhuman.setItemInHand(enumhand, itemstack1); return true; } @@ -89,7 +66,7 @@ } @Override -@@ -436,12 +479,22 @@ +@@ -340,12 +376,22 @@ } else if (!worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && damagesource.getEntity() instanceof EntityInsentient) { return false; } else if (damagesource.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { @@ -115,7 +92,7 @@ return false; } else if (damagesource.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) { if (this.isOnFire()) { -@@ -474,7 +527,7 @@ +@@ -378,7 +424,7 @@ if (damagesource.isCreativePlayer()) { this.playBrokenSound(); this.showBreakingParticles(); @@ -124,7 +101,7 @@ return true; } else { long i = worldserver.getGameTime(); -@@ -486,7 +539,7 @@ +@@ -390,7 +436,7 @@ } else { this.brokenByPlayer(worldserver, damagesource); this.showBreakingParticles(); @@ -133,7 +110,7 @@ } return true; -@@ -536,7 +589,7 @@ +@@ -440,7 +486,7 @@ f1 -= f; if (f1 <= 0.5F) { this.brokenByAnything(worldserver, damagesource); @@ -142,7 +119,7 @@ } else { this.setHealth(f1); this.gameEvent(GameEvent.ENTITY_DAMAGE, damagesource.getEntity()); -@@ -548,13 +601,13 @@ +@@ -452,21 +498,22 @@ ItemStack itemstack = new ItemStack(Items.ARMOR_STAND); itemstack.set(DataComponents.CUSTOM_NAME, this.getCustomName()); @@ -156,31 +133,19 @@ - this.dropAllDeathLoot(worldserver, damagesource); + // this.dropAllDeathLoot(worldserver, damagesource); // CraftBukkit - moved down - ItemStack itemstack; - int i; -@@ -562,7 +615,7 @@ - for (i = 0; i < this.handItems.size(); ++i) { - itemstack = (ItemStack) this.handItems.get(i); + for (EnumItemSlot enumitemslot : EnumItemSlot.VALUES) { + ItemStack itemstack = this.equipment.set(enumitemslot, ItemStack.EMPTY); + if (!itemstack.isEmpty()) { - Block.popResource(this.level(), this.blockPosition().above(), itemstack); + drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops - this.handItems.set(i, ItemStack.EMPTY); - } - } -@@ -570,10 +623,11 @@ - for (i = 0; i < this.armorItems.size(); ++i) { - itemstack = (ItemStack) this.armorItems.get(i); - if (!itemstack.isEmpty()) { -- Block.popResource(this.level(), this.blockPosition().above(), itemstack); -+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops - this.armorItems.set(i, ItemStack.EMPTY); } } + this.dropAllDeathLoot(worldserver, damagesource); // CraftBukkit - moved from above } -@@ -664,9 +718,23 @@ +@@ -556,9 +603,23 @@ return this.isSmall(); } diff --git a/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch b/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch index 26a8dd92d..0334666d4 100644 --- a/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch +++ b/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/EntityItemFrame.java +++ b/net/minecraft/world/entity/decoration/EntityItemFrame.java -@@ -91,6 +91,12 @@ +@@ -102,6 +102,12 @@ @Override protected AxisAlignedBB calculateBoundingBox(BlockPosition blockposition, EnumDirection enumdirection) { @@ -13,7 +13,7 @@ float f = 0.46875F; Vec3D vec3d = Vec3D.atCenterOf(blockposition).relative(enumdirection, -0.46875D); EnumDirection.EnumAxis enumdirection_enumaxis = enumdirection.getAxis(); -@@ -155,6 +161,11 @@ +@@ -166,6 +172,11 @@ if (this.isInvulnerableToBase(damagesource)) { return false; } else if (this.shouldDamageDropItem(damagesource)) { @@ -25,7 +25,7 @@ this.dropItem(worldserver, damagesource.getEntity(), false); this.gameEvent(GameEvent.BLOCK_CHANGE, damagesource.getEntity()); this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F); -@@ -267,13 +278,19 @@ +@@ -278,13 +289,19 @@ } public void setItem(ItemStack itemstack, boolean flag) { diff --git a/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch b/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch index ea827c1f5..2c134df21 100644 --- a/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch +++ b/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/EntityLeash.java +++ b/net/minecraft/world/entity/decoration/EntityLeash.java -@@ -27,6 +27,13 @@ +@@ -26,6 +26,13 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -14,9 +14,9 @@ public class EntityLeash extends BlockAttachedEntity { public static final double OFFSET_Y = 0.375D; -@@ -85,6 +92,15 @@ - Leashable leashable = (Leashable) iterator.next(); +@@ -81,6 +88,15 @@ + for (Leashable leashable : list) { if (leashable.getLeashHolder() == entityhuman) { + // CraftBukkit start + if (leashable instanceof Entity leashed) { @@ -30,7 +30,7 @@ leashable.setLeashedTo(this, true); flag = true; } -@@ -93,18 +109,38 @@ +@@ -89,14 +105,34 @@ boolean flag1 = false; if (!flag) { @@ -41,11 +41,7 @@ + boolean die = true; + // CraftBukkit end + if (true || entityhuman.getAbilities().instabuild) { // CraftBukkit - Process for non-creative as well - Iterator iterator1 = list.iterator(); - - while (iterator1.hasNext()) { - Leashable leashable1 = (Leashable) iterator1.next(); - + for (Leashable leashable1 : list) { if (leashable1.isLeashed() && leashable1.getLeashHolder() == this) { - leashable1.removeLeash(); + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch b/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch index ac5b3f26b..691bdaf59 100644 --- a/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch +++ b/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/EntityPainting.java +++ b/net/minecraft/world/entity/decoration/EntityPainting.java -@@ -72,7 +72,7 @@ +@@ -91,7 +91,7 @@ public static Optional create(World world, BlockPosition blockposition, EnumDirection enumdirection) { EntityPainting entitypainting = new EntityPainting(world, blockposition); List> list = new ArrayList(); @@ -9,7 +9,7 @@ Objects.requireNonNull(list); iterable.forEach(list::add); -@@ -138,22 +138,32 @@ +@@ -155,22 +155,32 @@ @Override protected AxisAlignedBB calculateBoundingBox(BlockPosition blockposition, EnumDirection enumdirection) { diff --git a/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch b/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch index 183c3b957..3a55f8240 100644 --- a/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch +++ b/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch @@ -12,7 +12,7 @@ public class EntityFallingBlock extends Entity { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -87,10 +92,17 @@ +@@ -96,10 +101,17 @@ } public static EntityFallingBlock fall(World world, BlockPosition blockposition, IBlockData iblockdata) { @@ -31,7 +31,7 @@ return entityfallingblock; } -@@ -139,7 +151,7 @@ +@@ -148,7 +160,7 @@ @Override public void tick() { if (this.blockState.isAir()) { @@ -40,7 +40,7 @@ } else { Block block = this.blockState.getBlock(); -@@ -174,7 +186,7 @@ +@@ -183,7 +195,7 @@ this.spawnAtLocation(worldserver, (IMaterial) block); } @@ -49,7 +49,7 @@ } } else { IBlockData iblockdata = this.level().getBlockState(blockposition); -@@ -191,9 +203,15 @@ +@@ -200,9 +212,15 @@ this.blockState = (IBlockData) this.blockState.setValue(BlockProperties.WATERLOGGED, true); } @@ -66,7 +66,7 @@ if (block instanceof Fallable) { ((Fallable) block).onLand(this.level(), blockposition, this.blockState, iblockdata, this); } -@@ -221,19 +239,19 @@ +@@ -227,19 +245,19 @@ } } } else if (this.dropItem && worldserver.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { @@ -89,3 +89,12 @@ this.callOnBrokenAfterFall(block, blockposition); } } +@@ -332,7 +350,7 @@ + this.fallDamagePerDistance = nbttagcompound.getFloatOr("FallHurtAmount", 0.0F); + this.fallDamageMax = nbttagcompound.getIntOr("FallHurtMax", 40); + this.dropItem = nbttagcompound.getBooleanOr("DropItem", true); +- this.blockData = (NBTTagCompound) nbttagcompound.getCompound("TileEntityData").map(NBTTagCompound::copy).orElse((Object) null); ++ this.blockData = (NBTTagCompound) nbttagcompound.getCompound("TileEntityData").map(NBTTagCompound::copy).orElse(null); // CraftBukkit - decompile error + this.cancelDrop = nbttagcompound.getBooleanOr("CancelDrop", false); + } + diff --git a/nms-patches/net/minecraft/world/entity/item/EntityItem.patch b/nms-patches/net/minecraft/world/entity/item/EntityItem.patch index 7dac6e9b4..d4234eda6 100644 --- a/nms-patches/net/minecraft/world/entity/item/EntityItem.patch +++ b/nms-patches/net/minecraft/world/entity/item/EntityItem.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/EntityItem.java +++ b/net/minecraft/world/entity/item/EntityItem.java -@@ -34,6 +34,15 @@ +@@ -36,6 +36,15 @@ import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.Vec3D; @@ -15,8 +15,8 @@ + public class EntityItem extends Entity implements TraceableEntity { - private static final DataWatcherObject DATA_ITEM = DataWatcher.defineId(EntityItem.class, DataWatcherRegistry.ITEM_STACK); -@@ -52,6 +61,7 @@ + private static final DataWatcherObject DATA_ITEM = DataWatcher.defineId(EntityItem.class, DataWatcherRegistry.ITEM_STACK); +@@ -57,6 +66,7 @@ @Nullable public UUID target; public final float bobOffs; @@ -24,7 +24,7 @@ public EntityItem(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -133,12 +143,15 @@ +@@ -142,12 +152,15 @@ @Override public void tick() { if (this.getItem().isEmpty()) { @@ -44,7 +44,7 @@ this.xo = this.getX(); this.yo = this.getY(); -@@ -188,9 +201,11 @@ +@@ -197,9 +210,11 @@ this.mergeWithNeighbours(); } @@ -56,7 +56,7 @@ this.hasImpulse |= this.updateInWaterStateAndDoFluidPushing(); if (!this.level().isClientSide) { -@@ -202,7 +217,13 @@ +@@ -211,7 +226,13 @@ } if (!this.level().isClientSide && this.age >= 6000) { @@ -71,7 +71,7 @@ } } -@@ -287,11 +308,16 @@ +@@ -291,11 +312,16 @@ } private static void merge(EntityItem entityitem, ItemStack itemstack, EntityItem entityitem1, ItemStack itemstack1) { @@ -89,7 +89,7 @@ } } -@@ -320,12 +346,17 @@ +@@ -324,12 +350,17 @@ } else if (!this.getItem().canBeHurtBy(damagesource)) { return false; } else { @@ -108,16 +108,25 @@ } return true; -@@ -382,7 +413,7 @@ - } +@@ -361,14 +392,14 @@ + this.health = nbttagcompound.getShortOr("Health", (short) 5); + this.age = nbttagcompound.getShortOr("Age", (short) 0); + this.pickupDelay = nbttagcompound.getShortOr("PickupDelay", (short) 0); +- this.target = (UUID) nbttagcompound.read("Owner", UUIDUtil.CODEC).orElse((Object) null); +- this.thrower = (UUID) nbttagcompound.read("Thrower", UUIDUtil.CODEC).orElse((Object) null); ++ this.target = (UUID) nbttagcompound.read("Owner", UUIDUtil.CODEC).orElse(null); // CraftBukkit - decompile error ++ this.thrower = (UUID) nbttagcompound.read("Thrower", UUIDUtil.CODEC).orElse(null); // CraftBukkit - decompile error + this.cachedThrower = null; + RegistryOps registryops = this.registryAccess().createSerializationContext(DynamicOpsNBT.INSTANCE); + this.setItem((ItemStack) nbttagcompound.read("Item", ItemStack.CODEC, registryops).orElse(ItemStack.EMPTY)); if (this.getItem().isEmpty()) { - this.discard(); + this.discard(null); // CraftBukkit - add Bukkit remove cause } } -@@ -394,10 +425,50 @@ +@@ -380,10 +411,50 @@ Item item = itemstack.getItem(); int i = itemstack.getCount(); diff --git a/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch b/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch index d4ea5a67d..68aacd512 100644 --- a/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch +++ b/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/EntityTNTPrimed.java +++ b/net/minecraft/world/entity/item/EntityTNTPrimed.java -@@ -27,6 +27,12 @@ +@@ -29,6 +29,12 @@ import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.portal.TeleportTransition; @@ -12,8 +12,8 @@ + public class EntityTNTPrimed extends Entity implements TraceableEntity { - private static final DataWatcherObject DATA_FUSE_ID = DataWatcher.defineId(EntityTNTPrimed.class, DataWatcherRegistry.INT); -@@ -51,6 +57,7 @@ + private static final DataWatcherObject DATA_FUSE_ID = DataWatcher.defineId(EntityTNTPrimed.class, DataWatcherRegistry.INT); +@@ -54,6 +60,7 @@ public EntityLiving owner; private boolean usedPortal; public float explosionPower; @@ -21,7 +21,7 @@ public EntityTNTPrimed(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -107,10 +114,13 @@ +@@ -110,10 +117,13 @@ this.setFuse(i); if (i <= 0) { @@ -36,18 +36,18 @@ } else { this.updateInWaterStateAndDoFluidPushing(); if (this.level().isClientSide) { -@@ -121,7 +131,13 @@ - } +@@ -128,7 +138,13 @@ - private void explode() { -- this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? EntityTNTPrimed.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), this.getY(0.0625D), this.getZ(), this.explosionPower, false, World.a.TNT); -+ // CraftBukkit start -+ ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); -+ if (event.isCancelled()) { -+ return; -+ } -+ this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? EntityTNTPrimed.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT); -+ // CraftBukkit end - } + if (world instanceof WorldServer worldserver) { + if (worldserver.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES)) { +- this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? EntityTNTPrimed.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), this.getY(0.0625D), this.getZ(), this.explosionPower, false, World.a.TNT); ++ // CraftBukkit start ++ ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); ++ if (event.isCancelled()) { ++ return; ++ } ++ this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? EntityTNTPrimed.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT); ++ // CraftBukkit end + } + } - @Override diff --git a/nms-patches/net/minecraft/world/entity/monster/Bogged.patch b/nms-patches/net/minecraft/world/entity/monster/Bogged.patch index 8a45b0e81..2553010d1 100644 --- a/nms-patches/net/minecraft/world/entity/monster/Bogged.patch +++ b/nms-patches/net/minecraft/world/entity/monster/Bogged.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Bogged.java +++ b/net/minecraft/world/entity/monster/Bogged.java -@@ -79,6 +79,12 @@ +@@ -80,6 +80,12 @@ if (world instanceof WorldServer) { WorldServer worldserver = (WorldServer) world; diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityCaveSpider.patch b/nms-patches/net/minecraft/world/entity/monster/EntityCaveSpider.patch index f70d92bc9..ae397f12f 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityCaveSpider.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityCaveSpider.patch @@ -3,9 +3,9 @@ @@ -40,7 +40,7 @@ } - if (b0 > 0) { -- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this); -+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit + if (i > 0) { +- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, i * 20, 0), this); ++ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, i * 20, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch b/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch index 158cbcb19..78d5ac648 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityCreeper.java +++ b/net/minecraft/world/entity/monster/EntityCreeper.java -@@ -42,6 +42,13 @@ +@@ -41,6 +41,13 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.gameevent.GameEvent; @@ -13,8 +13,8 @@ + public class EntityCreeper extends EntityMonster { - private static final DataWatcherObject DATA_SWELL_DIR = DataWatcher.defineId(EntityCreeper.class, DataWatcherRegistry.INT); -@@ -52,6 +59,7 @@ + private static final DataWatcherObject DATA_SWELL_DIR = DataWatcher.defineId(EntityCreeper.class, DataWatcherRegistry.INT); +@@ -55,6 +62,7 @@ public int maxSwell = 30; public int explosionRadius = 3; private int droppedSkulls; @@ -22,7 +22,7 @@ public EntityCreeper(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -214,9 +222,20 @@ +@@ -208,9 +216,20 @@ @Override public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { super.thunderHit(worldserver, entitylightning); @@ -43,7 +43,7 @@ @Override protected EnumInteractionResult mobInteract(EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.getItemInHand(enumhand); -@@ -226,8 +245,9 @@ +@@ -220,8 +239,9 @@ this.level().playSound(entityhuman, this.getX(), this.getY(), this.getZ(), soundeffect, this.getSoundSource(), 1.0F, this.random.nextFloat() * 0.4F + 0.8F); if (!this.level().isClientSide) { @@ -54,7 +54,7 @@ itemstack.shrink(1); } else { itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand)); -@@ -246,11 +266,20 @@ +@@ -240,11 +260,20 @@ if (world instanceof WorldServer worldserver) { float f = this.isPowered() ? 2.0F : 1.0F; @@ -77,7 +77,7 @@ } } -@@ -261,6 +290,7 @@ +@@ -255,6 +284,7 @@ if (!collection.isEmpty()) { EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ()); @@ -85,7 +85,7 @@ entityareaeffectcloud.setRadius(2.5F); entityareaeffectcloud.setRadiusOnUse(-0.5F); entityareaeffectcloud.setWaitTime(10); -@@ -274,7 +304,7 @@ +@@ -266,7 +296,7 @@ entityareaeffectcloud.addEffect(new MobEffect(mobeffect)); } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch b/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch index a8a1cf406..c3208f008 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityEnderman.java +++ b/net/minecraft/world/entity/monster/EntityEnderman.java -@@ -69,6 +69,11 @@ +@@ -67,6 +67,11 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.Vec3D; @@ -12,7 +12,7 @@ public class EntityEnderman extends EntityMonster implements IEntityAngerable { private static final MinecraftKey SPEED_MODIFIER_ATTACKING_ID = MinecraftKey.withDefaultNamespace("attacking"); -@@ -112,7 +117,17 @@ +@@ -110,7 +115,17 @@ @Override public void setTarget(@Nullable EntityLiving entityliving) { @@ -31,7 +31,7 @@ AttributeModifiable attributemodifiable = this.getAttribute(GenericAttributes.MOVEMENT_SPEED); if (entityliving == null) { -@@ -127,6 +142,7 @@ +@@ -125,6 +140,7 @@ attributemodifiable.addTransientModifier(EntityEnderman.SPEED_MODIFIER_ATTACKING); } } @@ -39,25 +39,34 @@ } -@@ -465,9 +481,11 @@ +@@ -202,7 +218,7 @@ + + this.setCarriedBlock((IBlockData) nbttagcompound.read("carriedBlockState", IBlockData.CODEC, registryops).filter((iblockdata) -> { + return !iblockdata.isAir(); +- }).orElse((Object) null)); ++ }).orElse(null)); // CraftBukkit - decompile error + this.readPersistentAngerSaveData(this.level(), nbttagcompound); + } + +@@ -563,9 +579,11 @@ if (iblockdata2 != null) { iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level(), blockposition); if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) { + if (CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, iblockdata2)) { // CraftBukkit - Place event world.setBlock(blockposition, iblockdata2, 3); - world.gameEvent((Holder) GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(this.enderman, iblockdata2)); + world.gameEvent(GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(this.enderman, iblockdata2)); this.enderman.setCarriedBlock((IBlockData) null); + } // CraftBukkit } } -@@ -506,9 +524,11 @@ +@@ -604,9 +622,11 @@ boolean flag = movingobjectpositionblock.getBlockPos().equals(blockposition); if (iblockdata.is(TagsBlock.ENDERMAN_HOLDABLE) && flag) { + if (CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.defaultBlockState())) { // CraftBukkit - Place event world.removeBlock(blockposition, false); - world.gameEvent((Holder) GameEvent.BLOCK_DESTROY, blockposition, GameEvent.a.of(this.enderman, iblockdata)); + world.gameEvent(GameEvent.BLOCK_DESTROY, blockposition, GameEvent.a.of(this.enderman, iblockdata)); this.enderman.setCarriedBlock(iblockdata.getBlock().defaultBlockState()); + } // CraftBukkit } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityEndermite.patch b/nms-patches/net/minecraft/world/entity/monster/EntityEndermite.patch index 6ba986318..3b2711b13 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityEndermite.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityEndermite.patch @@ -11,7 +11,7 @@ public class EntityEndermite extends EntityMonster { private static final int MAX_LIFE = 2400; -@@ -113,7 +117,7 @@ +@@ -114,7 +118,7 @@ } if (this.life >= 2400) { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityEvoker.patch b/nms-patches/net/minecraft/world/entity/monster/EntityEvoker.patch index 5a0334020..feb63a71d 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityEvoker.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityEvoker.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/monster/EntityEvoker.java +++ b/net/minecraft/world/entity/monster/EntityEvoker.java -@@ -212,7 +212,7 @@ +@@ -295,7 +295,7 @@ worldserver.getScoreboard().addPlayerToTeam(entityvex.getScoreboardName(), scoreboardteam); } - worldserver.addFreshEntityWithPassengers(entityvex); + worldserver.addFreshEntityWithPassengers(entityvex, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPELL); // CraftBukkit - Add SpawnReason - worldserver.gameEvent((Holder) GameEvent.ENTITY_PLACE, blockposition, GameEvent.a.of((Entity) EntityEvoker.this)); + worldserver.gameEvent(GameEvent.ENTITY_PLACE, blockposition, GameEvent.a.of((Entity) EntityEvoker.this)); } } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch b/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch index 69f630ae8..35e0ce54f 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityGhast.java +++ b/net/minecraft/world/entity/monster/EntityGhast.java -@@ -333,6 +333,8 @@ +@@ -331,6 +331,8 @@ EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, vec3d1.normalize(), this.ghast.getExplosionPower()); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityGuardianElder.patch b/nms-patches/net/minecraft/world/entity/monster/EntityGuardianElder.patch index a3cce2e70..7695ba74e 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityGuardianElder.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityGuardianElder.patch @@ -3,7 +3,7 @@ @@ -67,7 +67,7 @@ super.customServerAiStep(worldserver); if ((this.tickCount + this.getId()) % 1200 == 0) { - MobEffect mobeffect = new MobEffect(MobEffects.DIG_SLOWDOWN, 6000, 2); + MobEffect mobeffect = new MobEffect(MobEffects.MINING_FATIGUE, 6000, 2); - List list = MobEffectUtil.addEffectToPlayersAround(worldserver, this, this.position(), 50.0D, mobeffect, 1200); + List list = MobEffectUtil.addEffectToPlayersAround(worldserver, this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch b/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch index 6bcb758d3..b5493cff3 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityIllagerIllusioner.java +++ b/net/minecraft/world/entity/monster/EntityIllagerIllusioner.java -@@ -218,7 +218,7 @@ +@@ -214,7 +214,7 @@ @Override protected void performSpellCasting() { @@ -9,7 +9,7 @@ } @Nullable -@@ -269,7 +269,7 @@ +@@ -263,7 +263,7 @@ @Override protected void performSpellCasting() { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityIllagerWizard.patch b/nms-patches/net/minecraft/world/entity/monster/EntityIllagerWizard.patch index 0b26a8069..4282dc1fd 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityIllagerWizard.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityIllagerWizard.patch @@ -10,8 +10,8 @@ + public abstract class EntityIllagerWizard extends EntityIllagerAbstract { - private static final DataWatcherObject DATA_SPELL_CASTING_ID = DataWatcher.defineId(EntityIllagerWizard.class, DataWatcherRegistry.BYTE); -@@ -159,6 +163,11 @@ + private static final DataWatcherObject DATA_SPELL_CASTING_ID = DataWatcher.defineId(EntityIllagerWizard.class, DataWatcherRegistry.BYTE); +@@ -172,6 +176,11 @@ public void tick() { --this.attackWarmupDelay; if (this.attackWarmupDelay == 0) { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch b/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch index 94a1d8486..ffaa6fd1b 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch @@ -1,16 +1,22 @@ --- a/net/minecraft/world/entity/monster/EntityPhantom.java +++ b/net/minecraft/world/entity/monster/EntityPhantom.java -@@ -522,14 +522,14 @@ +@@ -155,7 +155,7 @@ + @Override + public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { + super.readAdditionalSaveData(nbttagcompound); +- this.anchorPoint = (BlockPosition) nbttagcompound.read("anchor_pos", BlockPosition.CODEC).orElse((Object) null); ++ this.anchorPoint = (BlockPosition) nbttagcompound.read("anchor_pos", BlockPosition.CODEC).orElse(null); // CraftBukkit - decompile error + this.setPhantomSize(nbttagcompound.getIntOr("size", 0)); + } + +@@ -525,11 +525,11 @@ List list = worldserver.getNearbyPlayers(this.attackTargeting, EntityPhantom.this, EntityPhantom.this.getBoundingBox().inflate(16.0D, 64.0D, 16.0D)); if (!list.isEmpty()) { - list.sort(Comparator.comparing(Entity::getY).reversed()); + list.sort(Comparator.comparing((Entity e) -> { return e.getY(); }).reversed()); // CraftBukkit - decompile error - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityHuman entityhuman = (EntityHuman) iterator.next(); + for (EntityHuman entityhuman : list) { if (EntityPhantom.this.canAttack(worldserver, entityhuman, PathfinderTargetCondition.DEFAULT)) { - EntityPhantom.this.setTarget(entityhuman); + EntityPhantom.this.setTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit - reason diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch b/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch index f0a0fd531..8c39bab20 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityPigZombie.java +++ b/net/minecraft/world/entity/monster/EntityPigZombie.java -@@ -149,7 +149,7 @@ +@@ -145,7 +145,7 @@ }).filter((entitypigzombie) -> { return !entitypigzombie.isAlliedTo((Entity) this.getTarget()); }).forEach((entitypigzombie) -> { @@ -9,7 +9,7 @@ }); } -@@ -158,7 +158,7 @@ +@@ -154,18 +154,27 @@ } @Override @@ -18,8 +18,6 @@ if (this.getTarget() == null && entityliving != null) { this.playFirstAngerSoundIn = EntityPigZombie.FIRST_ANGER_SOUND_DELAY.sample(this.random); this.ticksUntilNextAlert = EntityPigZombie.ALERT_INTERVAL.sample(this.random); -@@ -168,12 +168,21 @@ - this.setLastHurtByPlayer((EntityHuman) entityliving); } - super.setTarget(entityliving); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch b/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch index 5a0987400..5c38f04d4 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch @@ -10,7 +10,7 @@ + public class EntityPillager extends EntityIllagerAbstract implements ICrossbow, InventoryCarrier { - private static final DataWatcherObject IS_CHARGING_CROSSBOW = DataWatcher.defineId(EntityPillager.class, DataWatcherRegistry.BOOLEAN); + private static final DataWatcherObject IS_CHARGING_CROSSBOW = DataWatcher.defineId(EntityPillager.class, DataWatcherRegistry.BOOLEAN); @@ -206,7 +210,7 @@ ItemStack itemstack1 = this.inventory.addItem(itemstack); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch b/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch index 886c966a0..b4a66dc51 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityRavager.java +++ b/net/minecraft/world/entity/monster/EntityRavager.java -@@ -43,6 +43,10 @@ +@@ -41,6 +41,10 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public class EntityRavager extends EntityRaider { private static final Predicate ROAR_TARGET_WITH_GRIEFING = (entity) -> { -@@ -158,6 +162,11 @@ +@@ -157,6 +161,11 @@ Block block = iblockdata.getBlock(); if (block instanceof BlockLeaves) { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch b/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch index 611d16c84..f6771ea17 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch @@ -10,10 +10,10 @@ +import org.bukkit.craftbukkit.event.CraftEventFactory; +// CraftBukkit end + - public class EntityShulker extends EntityGolem implements VariantHolder>, IMonster { + public class EntityShulker extends EntityGolem implements IMonster { private static final MinecraftKey COVERED_ARMOR_MODIFIER_ID = MinecraftKey.withDefaultNamespace("covered"); -@@ -402,6 +408,14 @@ +@@ -391,6 +397,14 @@ EnumDirection enumdirection = this.findAttachableSurface(blockposition1); if (enumdirection != null) { @@ -28,10 +28,10 @@ this.unRide(); this.setAttachFace(enumdirection); this.playSound(SoundEffects.SHULKER_TELEPORT, 1.0F, 1.0F); -@@ -472,7 +486,7 @@ +@@ -459,7 +473,7 @@ if (entityshulker != null) { entityshulker.setVariant(this.getVariant()); - entityshulker.moveTo(vec3d); + entityshulker.snapTo(vec3d); - this.level().addFreshEntity(entityshulker); + this.level().addFreshEntity(entityshulker, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - the mysteries of life } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch b/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch index e2516beaa..f242fd019 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch @@ -25,7 +25,7 @@ world.destroyBlock(blockposition1, true, this.silverfish); } else { @@ -229,9 +239,14 @@ - IBlockData iblockdata = world.getBlockState(blockposition); + IBlockData iblockdata = generatoraccess.getBlockState(blockposition); if (BlockMonsterEggs.isCompatibleHostBlock(iblockdata)) { + // CraftBukkit start @@ -33,7 +33,7 @@ + return; + } + // CraftBukkit end - world.setBlock(blockposition, BlockMonsterEggs.infestedStateByHost(iblockdata), 3); + generatoraccess.setBlock(blockposition, BlockMonsterEggs.infestedStateByHost(iblockdata), 3); this.mob.spawnAnim(); - this.mob.discard(); + this.mob.discard(EntityRemoveEvent.Cause.ENTER_BLOCK); // CraftBukkit - add Bukkit remove cause diff --git a/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch b/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch index 6cb71e564..f14f8309c 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/world/entity/monster/EntitySkeleton.java +++ b/net/minecraft/world/entity/monster/EntitySkeleton.java -@@ -94,12 +94,17 @@ +@@ -98,12 +98,17 @@ } protected void doFreezeConversion() { - this.convertTo(EntityTypes.STRAY, ConversionParams.single(this, true, true), (entityskeletonstray) -> { + net.minecraft.world.entity.monster.EntitySkeletonStray converted = this.convertTo(EntityTypes.STRAY, ConversionParams.single(this, true, true), (entityskeletonstray) -> { // CraftBukkit if (!this.isSilent()) { - this.level().levelEvent((EntityHuman) null, 1048, this.blockPosition(), 0); + this.level().levelEvent((Entity) null, 1048, this.blockPosition(), 0); } - }); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch b/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch index 3b3d0eb4e..34d35cf8b 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch @@ -4,7 +4,7 @@ World world = this.level(); if (world instanceof WorldServer worldserver) { -- IProjectile.spawnProjectileUsingShoot(entityarrow, worldserver, itemstack1, d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - worldserver.getDifficulty().getId() * 4)); +- IProjectile.spawnProjectileUsingShoot(entityarrow, worldserver, itemstack1, d0, d1 + d3 * (double) 0.2F, d2, 1.6F, (float) (14 - worldserver.getDifficulty().getId() * 4)); + // CraftBukkit start + org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getMainHandItem(), null, entityarrow, net.minecraft.world.EnumHand.MAIN_HAND, 0.8F, true); + if (event.isCancelled()) { @@ -13,7 +13,7 @@ + } + + if (event.getProjectile() == entityarrow.getBukkitEntity()) { -+ IProjectile.spawnProjectileUsingShoot(entityarrow, worldserver, itemstack1, d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - worldserver.getDifficulty().getId() * 4)); ++ IProjectile.spawnProjectileUsingShoot(entityarrow, worldserver, itemstack1, d0, d1 + d3 * (double) 0.2F, d2, 1.6F, (float) (14 - worldserver.getDifficulty().getId() * 4)); + } + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch b/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch index 73994c5c6..b3ea4cb8c 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch @@ -15,8 +15,8 @@ + public class EntitySlime extends EntityInsentient implements IMonster { - private static final DataWatcherObject ID_SIZE = DataWatcher.defineId(EntitySlime.class, DataWatcherRegistry.INT); -@@ -197,11 +206,18 @@ + private static final DataWatcherObject ID_SIZE = DataWatcher.defineId(EntitySlime.class, DataWatcherRegistry.INT); +@@ -198,11 +207,18 @@ @Override public EntityTypes getType() { @@ -36,7 +36,7 @@ int i = this.getSize(); if (!this.level().isClientSide && i > 1 && this.isDeadOrDying()) { -@@ -211,18 +227,45 @@ +@@ -212,18 +228,45 @@ int k = 2 + this.random.nextInt(3); ScoreboardTeam scoreboardteam = this.getTeam(); @@ -60,7 +60,7 @@ - this.convertTo(this.getType(), new ConversionParams(ConversionType.SPLIT_ON_DEATH, false, false, scoreboardteam), EntitySpawnReason.TRIGGERED, (entityslime) -> { + EntitySlime converted = this.convertTo(this.getType(), new ConversionParams(ConversionType.SPLIT_ON_DEATH, false, false, scoreboardteam), EntitySpawnReason.TRIGGERED, (entityslime) -> { // CraftBukkit entityslime.setSize(j, true); - entityslime.moveTo(this.getX() + (double) f2, this.getY() + 0.5D, this.getZ() + (double) f3, this.random.nextFloat() * 360.0F, 0.0F); + entityslime.snapTo(this.getX() + (double) f2, this.getY() + 0.5D, this.getZ() + (double) f3, this.random.nextFloat() * 360.0F, 0.0F); - }); + // CraftBukkit start + }, null, null); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch b/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch index a17b5b266..a6cd162fd 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityStrider.java +++ b/net/minecraft/world/entity/monster/EntityStrider.java -@@ -350,7 +350,14 @@ +@@ -325,7 +325,14 @@ boolean flag2 = flag1; diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch b/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch index 4f8bf90a9..712b3445d 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch @@ -1,6 +1,15 @@ --- a/net/minecraft/world/entity/monster/EntityVex.java +++ b/net/minecraft/world/entity/monster/EntityVex.java -@@ -381,7 +381,7 @@ +@@ -108,7 +108,7 @@ + @Override + public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { + super.readAdditionalSaveData(nbttagcompound); +- this.boundOrigin = (BlockPosition) nbttagcompound.read("bound_pos", BlockPosition.CODEC).orElse((Object) null); ++ this.boundOrigin = (BlockPosition) nbttagcompound.read("bound_pos", BlockPosition.CODEC).orElse(null); // CraftBukkit - decompile error + nbttagcompound.getInt("life_ticks").ifPresentOrElse(this::setLimitedLife, () -> { + this.hasLimitedLife = false; + }); +@@ -372,7 +372,7 @@ @Override public void start() { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch b/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch index d0b562f1f..195f7a65a 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch @@ -4,8 +4,8 @@ PotionContents potioncontents = (PotionContents) itemstack.get(DataComponents.POTION_CONTENTS); if (itemstack.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, (Float) itemstack.getOrDefault(DataComponents.POTION_DURATION_SCALE, 1.0F)); ++ potioncontents.forEachEffect((effect) -> this.addEffect(effect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK), (Float) itemstack.getOrDefault(DataComponents.POTION_DURATION_SCALE, 1.0F)); // CraftBukkit } this.gameEvent(GameEvent.DRINK); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch b/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch index 1eed7427b..dfb599687 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityZombie.java +++ b/net/minecraft/world/entity/monster/EntityZombie.java -@@ -67,6 +67,15 @@ +@@ -66,6 +66,15 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; @@ -16,7 +16,7 @@ public class EntityZombie extends EntityMonster { private static final MinecraftKey SPEED_MODIFIER_BABY_ID = MinecraftKey.withDefaultNamespace("baby"); -@@ -91,6 +100,7 @@ +@@ -94,6 +103,7 @@ private boolean canBreakDoors; private int inWaterTime; public int conversionTime; @@ -24,7 +24,7 @@ public EntityZombie(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -203,7 +213,10 @@ +@@ -208,7 +218,10 @@ public void tick() { if (!this.level().isClientSide && this.isAlive() && !this.isNoAi()) { if (this.isUnderWaterConverting()) { @@ -36,7 +36,7 @@ if (this.conversionTime < 0) { this.doUnderWaterConversion(); } -@@ -220,6 +233,7 @@ +@@ -225,6 +238,7 @@ } super.tick(); @@ -44,7 +44,7 @@ } @Override -@@ -254,6 +268,7 @@ +@@ -259,6 +273,7 @@ } public void startUnderWaterConversion(int i) { @@ -52,7 +52,7 @@ this.conversionTime = i; this.getEntityData().set(EntityZombie.DATA_DROWNED_CONVERSION_ID, true); } -@@ -267,26 +282,39 @@ +@@ -272,26 +287,39 @@ } protected void convertToZombieType(EntityTypes entitytypes) { @@ -79,14 +79,14 @@ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, ConversionParams.single(entityvillager, true, true), (entityzombievillager1) -> { entityzombievillager1.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombievillager1.blockPosition()), EntitySpawnReason.CONVERSION, new EntityZombie.GroupDataZombie(false, true)); entityzombievillager1.setVillagerData(entityvillager.getVillagerData()); - entityzombievillager1.setGossips((NBTBase) entityvillager.getGossips().store(DynamicOpsNBT.INSTANCE)); + entityzombievillager1.setGossips(entityvillager.getGossips().copy()); entityzombievillager1.setTradeOffers(entityvillager.getOffers().copy()); entityzombievillager1.setVillagerXp(entityvillager.getVillagerXp()); - if (!this.isSilent()) { -- worldserver.levelEvent((EntityHuman) null, 1026, this.blockPosition(), 0); +- worldserver.levelEvent((Entity) null, 1026, this.blockPosition(), 0); + // CraftBukkit start + if (!silent) { -+ worldserver.levelEvent((EntityHuman) null, 1026, blockPosition, 0); ++ worldserver.levelEvent((Entity) null, 1026, blockPosition, 0); } - }); @@ -98,7 +98,7 @@ } protected boolean isSunSensitive() { -@@ -324,9 +352,9 @@ +@@ -329,9 +357,9 @@ if (EntityPositionTypes.isSpawnPositionOk(entitytypes, worldserver, blockposition) && EntityPositionTypes.checkSpawnRules(entitytypes, worldserver, EntitySpawnReason.REINFORCEMENT, blockposition, worldserver.random)) { entityzombie.setPos((double) i1, (double) j1, (double) k1); if (!worldserver.hasNearbyAlivePlayer((double) i1, (double) j1, (double) k1, 7.0D) && worldserver.isUnobstructed(entityzombie) && worldserver.noCollision((Entity) entityzombie) && (entityzombie.canSpawnInLiquids() || !worldserver.containsAnyLiquid(entityzombie.getBoundingBox()))) { @@ -110,7 +110,7 @@ AttributeModifiable attributemodifiable = this.getAttribute(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE); AttributeModifier attributemodifier = attributemodifiable.getModifier(EntityZombie.REINFORCEMENT_CALLER_CHARGE_ID); double d0 = attributemodifier != null ? attributemodifier.amount() : 0.0D; -@@ -352,7 +380,14 @@ +@@ -357,7 +385,14 @@ float f = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < f * 0.3F) { @@ -126,7 +126,7 @@ } } -@@ -385,7 +420,7 @@ +@@ -390,7 +425,7 @@ @Override public EntityTypes getType() { @@ -135,7 +135,7 @@ } protected boolean canSpawnInLiquids() { -@@ -496,7 +531,7 @@ +@@ -506,7 +541,7 @@ entitychicken1.finalizeSpawn(worldaccess, difficultydamagescaler, EntitySpawnReason.JOCKEY, (GroupDataEntity) null); entitychicken1.setChickenJockey(true); this.startRiding(entitychicken1); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityZombieHusk.patch b/nms-patches/net/minecraft/world/entity/monster/EntityZombieHusk.patch index ae2ac43bc..dab22fcd4 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityZombieHusk.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityZombieHusk.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityZombieHusk.java +++ b/net/minecraft/world/entity/monster/EntityZombieHusk.java -@@ -59,7 +59,7 @@ +@@ -58,7 +58,7 @@ if (flag && this.getMainHandItem().isEmpty() && entity instanceof EntityLiving) { float f = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch b/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch index 96e3b9c0e..67ab65e07 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/monster/EntityZombieVillager.java +++ b/net/minecraft/world/entity/monster/EntityZombieVillager.java -@@ -52,6 +52,14 @@ +@@ -51,6 +51,14 @@ + import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; - import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.server.MinecraftServer; @@ -14,34 +14,32 @@ + public class EntityZombieVillager extends EntityZombie implements VillagerDataHolder { - private static final Logger LOGGER = LogUtils.getLogger(); + public static final DataWatcherObject DATA_CONVERTING_ID = DataWatcher.defineId(EntityZombieVillager.class, DataWatcherRegistry.BOOLEAN); @@ -69,6 +77,7 @@ @Nullable private MerchantRecipeList tradeOffers; - private int villagerXp; + private int villagerXp = 0; + private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field public EntityZombieVillager(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -87,7 +96,7 @@ - @Override - public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { - super.addAdditionalSaveData(nbttagcompound); -- DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); -+ DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); // CraftBukkit - decompile error - Logger logger = EntityZombieVillager.LOGGER; +@@ -99,12 +108,12 @@ + public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { + super.readAdditionalSaveData(nbttagcompound); + this.entityData.set(EntityZombieVillager.DATA_VILLAGER_DATA, (VillagerData) nbttagcompound.read("VillagerData", VillagerData.CODEC).orElseGet(EntityVillager::createDefaultVillagerData)); +- this.tradeOffers = (MerchantRecipeList) nbttagcompound.read("Offers", MerchantRecipeList.CODEC, this.registryAccess().createSerializationContext(DynamicOpsNBT.INSTANCE)).orElse((Object) null); +- this.gossips = (Reputation) nbttagcompound.read("Gossips", Reputation.CODEC).orElse((Object) null); ++ this.tradeOffers = (MerchantRecipeList) nbttagcompound.read("Offers", MerchantRecipeList.CODEC, this.registryAccess().createSerializationContext(DynamicOpsNBT.INSTANCE)).orElse(null); // CraftBukkit - decompile error ++ this.gossips = (Reputation) nbttagcompound.read("Gossips", Reputation.CODEC).orElse(null); // CraftBukkit - decompile error + int i = nbttagcompound.getIntOr("ConversionTime", -1); - Objects.requireNonNull(logger); -@@ -122,7 +131,7 @@ - } + if (i != -1) { +- UUID uuid = (UUID) nbttagcompound.read("ConversionPlayer", UUIDUtil.CODEC).orElse((Object) null); ++ UUID uuid = (UUID) nbttagcompound.read("ConversionPlayer", UUIDUtil.CODEC).orElse(null); // CraftBukkit - decompile error - if (nbttagcompound.contains("Offers")) { -- DataResult dataresult1 = MerchantRecipeList.CODEC.parse(this.registryAccess().createSerializationContext(DynamicOpsNBT.INSTANCE), nbttagcompound.get("Offers")); -+ DataResult dataresult1 = MerchantRecipeList.CODEC.parse(this.registryAccess().createSerializationContext(DynamicOpsNBT.INSTANCE), nbttagcompound.get("Offers")); // CraftBukkit - decompile error - Logger logger1 = EntityZombieVillager.LOGGER; - - Objects.requireNonNull(logger1); -@@ -149,6 +158,10 @@ + this.startConverting(uuid, i); + } else { +@@ -119,6 +128,10 @@ public void tick() { if (!this.level().isClientSide && this.isAlive() && this.isConverting()) { int i = this.getConversionProgress(); @@ -52,7 +50,7 @@ this.villagerConversionTime -= i; if (this.villagerConversionTime <= 0) { -@@ -157,6 +170,7 @@ +@@ -127,6 +140,7 @@ } super.tick(); @@ -60,40 +58,37 @@ } @Override -@@ -197,8 +211,10 @@ +@@ -167,8 +181,10 @@ this.conversionStarter = uuid; this.villagerConversionTime = i; this.getEntityData().set(EntityZombieVillager.DATA_CONVERTING_ID, true); - this.removeEffect(MobEffects.WEAKNESS); -- this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level().getDifficulty().getId() - 1, 0))); +- this.addEffect(new MobEffect(MobEffects.STRENGTH, i, Math.min(this.level().getDifficulty().getId() - 1, 0))); + // CraftBukkit start + this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); -+ this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level().getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); ++ this.addEffect(new MobEffect(MobEffects.STRENGTH, i, Math.min(this.level().getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); + // CraftBukkit end this.level().broadcastEntityEvent(this, (byte) 16); } -@@ -215,10 +231,11 @@ +@@ -185,7 +201,8 @@ } private void finishConversion(WorldServer worldserver) { - this.convertTo(EntityTypes.VILLAGER, ConversionParams.single(this, false, false), (entityvillager) -> { + EntityVillager converted = this.convertTo(EntityTypes.VILLAGER, ConversionParams.single(this, false, false), (entityvillager) -> { // CraftBukkit - Iterator iterator = this.dropPreservedEquipment(worldserver, (itemstack) -> { - return !EnchantmentManager.has(itemstack, EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE); - }).iterator(); + this.forceDrops = false; // CraftBukkit - - while (iterator.hasNext()) { - EnumItemSlot enumitemslot = (EnumItemSlot) iterator.next(); -@@ -248,12 +265,16 @@ + for (EnumItemSlot enumitemslot : this.dropPreservedEquipment(worldserver, (itemstack) -> { + return !EnchantmentManager.has(itemstack, EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE); + })) { +@@ -215,12 +232,16 @@ } } -- entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0)); -+ entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit +- entityvillager.addEffect(new MobEffect(MobEffects.NAUSEA, 200, 0)); ++ entityvillager.addEffect(new MobEffect(MobEffects.NAUSEA, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit if (!this.isSilent()) { - worldserver.levelEvent((EntityHuman) null, 1027, this.blockPosition(), 0); + worldserver.levelEvent((Entity) null, 1027, this.blockPosition(), 0); } - - }); diff --git a/nms-patches/net/minecraft/world/entity/monster/breeze/Breeze.patch b/nms-patches/net/minecraft/world/entity/monster/breeze/Breeze.patch index 2050f356f..e3d16fbb3 100644 --- a/nms-patches/net/minecraft/world/entity/monster/breeze/Breeze.patch +++ b/nms-patches/net/minecraft/world/entity/monster/breeze/Breeze.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/breeze/Breeze.java +++ b/net/minecraft/world/entity/monster/breeze/Breeze.java -@@ -77,7 +77,7 @@ +@@ -76,7 +76,7 @@ @Override public BehaviorController getBrain() { @@ -9,7 +9,7 @@ } @Override -@@ -252,6 +252,7 @@ +@@ -251,6 +251,7 @@ @Override public boolean canAttackType(EntityTypes entitytypes) { diff --git a/nms-patches/net/minecraft/world/entity/monster/creaking/Creaking.patch b/nms-patches/net/minecraft/world/entity/monster/creaking/Creaking.patch index 80e612bda..f8950fe3b 100644 --- a/nms-patches/net/minecraft/world/entity/monster/creaking/Creaking.patch +++ b/nms-patches/net/minecraft/world/entity/monster/creaking/Creaking.patch @@ -18,7 +18,7 @@ } public void creakingDeathEffects(DamageSource damagesource) { -@@ -476,7 +476,7 @@ +@@ -458,7 +458,7 @@ @Override protected SoundEffect getHurtSound(DamageSource damagesource) { @@ -27,12 +27,3 @@ } @Override -@@ -549,7 +549,7 @@ - } - - public void activate(EntityHuman entityhuman) { -- this.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, (Object) entityhuman); -+ this.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, entityhuman); // CraftBukkit - decompile error - this.gameEvent(GameEvent.ENTITY_ACTION); - this.makeSound(SoundEffects.CREAKING_ACTIVATE); - this.setIsActive(true); diff --git a/nms-patches/net/minecraft/world/entity/monster/hoglin/EntityHoglin.patch b/nms-patches/net/minecraft/world/entity/monster/hoglin/EntityHoglin.patch index 84d7e913f..f2e7a155e 100644 --- a/nms-patches/net/minecraft/world/entity/monster/hoglin/EntityHoglin.patch +++ b/nms-patches/net/minecraft/world/entity/monster/hoglin/EntityHoglin.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/monster/hoglin/EntityHoglin.java +++ b/net/minecraft/world/entity/monster/hoglin/EntityHoglin.java -@@ -63,7 +63,8 @@ - public int timeInOverworld; - public boolean cannotBeHunted; +@@ -66,7 +66,8 @@ + public int timeInOverworld = 0; + public boolean cannotBeHunted = false; protected static final ImmutableList>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.NEAREST_ADULT, SensorType.HOGLIN_SPECIFIC_SENSOR); - protected static final ImmutableList> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.BREED_TARGET, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLIN, new MemoryModuleType[]{MemoryModuleType.AVOID_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_ADULT_HOGLINS, MemoryModuleType.NEAREST_VISIBLE_ADULT, MemoryModuleType.NEAREST_REPELLENT, MemoryModuleType.PACIFIED, MemoryModuleType.IS_PANICKING}); + // CraftBukkit - decompile error @@ -10,7 +10,7 @@ public EntityHoglin(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -134,7 +135,7 @@ +@@ -137,7 +138,7 @@ @Override public BehaviorController getBrain() { @@ -19,16 +19,16 @@ } @Override -@@ -242,7 +243,7 @@ +@@ -245,7 +246,7 @@ private void finishConversion() { this.convertTo(EntityTypes.ZOGLIN, ConversionParams.single(this, true, false), (entityzoglin) -> { - entityzoglin.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0)); + entityzoglin.addEffect(new MobEffect(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 } @Override -@@ -326,7 +327,7 @@ +@@ -323,7 +324,7 @@ @Override protected SoundEffect getAmbientSound() { diff --git a/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch b/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch index 3e139a4f3..f7f9c6d9f 100644 --- a/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch +++ b/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch @@ -18,9 +18,9 @@ + public class EntityPiglin extends EntityPiglinAbstract implements ICrossbow, InventoryCarrier { - private static final DataWatcherObject DATA_BABY_ID = DataWatcher.defineId(EntityPiglin.class, DataWatcherRegistry.BOOLEAN); -@@ -79,6 +91,10 @@ - public boolean cannotHunt; + private static final DataWatcherObject DATA_BABY_ID = DataWatcher.defineId(EntityPiglin.class, DataWatcherRegistry.BOOLEAN); +@@ -81,6 +93,10 @@ + public boolean cannotHunt = false; protected static final ImmutableList>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.NEAREST_ITEMS, SensorType.HURT_BY, SensorType.PIGLIN_SPECIFIC_SENSOR); protected static final ImmutableList> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.DOORS_TO_CLOSE, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLINS, MemoryModuleType.NEARBY_ADULT_PIGLINS, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryModuleType.ITEM_PICKUP_COOLDOWN_TICKS, MemoryModuleType.HURT_BY, MemoryModuleType.HURT_BY_ENTITY, new MemoryModuleType[]{MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.INTERACTION_TARGET, MemoryModuleType.PATH, MemoryModuleType.ANGRY_AT, MemoryModuleType.UNIVERSAL_ANGER, MemoryModuleType.AVOID_TARGET, MemoryModuleType.ADMIRING_ITEM, MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM, MemoryModuleType.ADMIRING_DISABLED, MemoryModuleType.DISABLE_WALK_TO_ADMIRE_ITEM, MemoryModuleType.CELEBRATE_LOCATION, MemoryModuleType.DANCING, MemoryModuleType.HUNTED_RECENTLY, MemoryModuleType.NEAREST_VISIBLE_BABY_HOGLIN, MemoryModuleType.NEAREST_VISIBLE_NEMESIS, MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, MemoryModuleType.RIDE_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_HUNTABLE_HOGLIN, MemoryModuleType.NEAREST_TARGETABLE_PLAYER_NOT_WEARING_GOLD, MemoryModuleType.NEAREST_PLAYER_HOLDING_WANTED_ITEM, MemoryModuleType.ATE_RECENTLY, MemoryModuleType.NEAREST_REPELLENT}); + // CraftBukkit start - Custom bartering and interest list @@ -30,9 +30,9 @@ public EntityPiglin(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -97,6 +113,14 @@ - } - +@@ -93,6 +109,14 @@ + nbttagcompound.putBoolean("IsBaby", this.isBaby()); + nbttagcompound.putBoolean("CannotHunt", this.cannotHunt); this.writeInventoryToTag(nbttagcompound, this.registryAccess()); + // CraftBukkit start + NBTTagList barterList = new NBTTagList(); @@ -45,18 +45,18 @@ } @Override -@@ -105,6 +129,10 @@ - this.setBaby(nbttagcompound.getBoolean("IsBaby")); - this.setCannotHunt(nbttagcompound.getBoolean("CannotHunt")); +@@ -101,6 +125,10 @@ + this.setBaby(nbttagcompound.getBooleanOr("IsBaby", false)); + this.setCannotHunt(nbttagcompound.getBooleanOr("CannotHunt", false)); this.readInventoryFromTag(nbttagcompound, this.registryAccess()); + // CraftBukkit start -+ this.allowedBarterItems = nbttagcompound.getList("Bukkit.BarterList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(BuiltInRegistries.ITEM::getValue).collect(Collectors.toCollection(HashSet::new)); -+ this.interestItems = nbttagcompound.getList("Bukkit.InterestList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(BuiltInRegistries.ITEM::getValue).collect(Collectors.toCollection(HashSet::new)); ++ this.allowedBarterItems = nbttagcompound.getList("Bukkit.BarterList").stream().flatMap(item -> item.asString().stream()).map(MinecraftKey::tryParse).map(BuiltInRegistries.ITEM::getValue).collect(Collectors.toCollection(HashSet::new)); ++ this.interestItems = nbttagcompound.getList("Bukkit.InterestList").stream().flatMap(item -> item.asString().stream()).map(MinecraftKey::tryParse).map(BuiltInRegistries.ITEM::getValue).collect(Collectors.toCollection(HashSet::new)); + // CraftBukkit end } @VisibleForDebug -@@ -224,7 +252,7 @@ +@@ -220,7 +248,7 @@ @Override public BehaviorController getBrain() { @@ -65,7 +65,7 @@ } @Override -@@ -374,7 +402,7 @@ +@@ -371,7 +399,7 @@ } protected void holdInOffHand(ItemStack itemstack) { @@ -74,7 +74,7 @@ this.setItemSlot(EnumItemSlot.OFFHAND, itemstack); this.setGuaranteedDrop(EnumItemSlot.OFFHAND); } else { -@@ -401,8 +429,8 @@ +@@ -398,8 +426,8 @@ return false; } else { TagKey tagkey = this.getPreferredWeaponType(); @@ -85,8 +85,8 @@ return flag && !flag1 ? true : (!flag && flag1 ? false : super.canReplaceCurrentItem(itemstack, itemstack1, enumitemslot)); } -@@ -431,7 +459,7 @@ - +@@ -429,7 +457,7 @@ + @Nullable @Override protected SoundEffect getAmbientSound() { - return this.level().isClientSide ? null : (SoundEffect) PiglinAI.getSoundForCurrentActivity(this).orElse((Object) null); diff --git a/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.patch b/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.patch index 85d6ba91e..2b8de73e3 100644 --- a/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.patch +++ b/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.java +++ b/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.java -@@ -102,7 +102,7 @@ +@@ -105,7 +105,7 @@ protected void finishConversion(WorldServer worldserver) { this.convertTo(EntityTypes.ZOMBIFIED_PIGLIN, ConversionParams.single(this, true, true), (entitypigzombie) -> { - entitypigzombie.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0)); + entitypigzombie.addEffect(new MobEffect(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 } diff --git a/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch b/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch index 26aa77840..eea01f5ca 100644 --- a/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch +++ b/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/PiglinAI.java +++ b/net/minecraft/world/entity/monster/piglin/PiglinAI.java -@@ -72,6 +72,14 @@ +@@ -73,6 +73,14 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParameters; import net.minecraft.world.phys.Vec3D; @@ -15,7 +15,27 @@ public class PiglinAI { public static final int REPELLENT_DETECTION_RANGE_HORIZONTAL = 8; -@@ -166,7 +174,8 @@ +@@ -147,7 +155,8 @@ + private static void initFightActivity(EntityPiglin entitypiglin, BehaviorController behaviorcontroller) { + behaviorcontroller.addActivityAndRemoveMemoryWhenStopped(Activity.FIGHT, 10, ImmutableList.of(BehaviorAttackTargetForget.create((worldserver, entityliving) -> { + return !isNearestValidAttackTarget(worldserver, entitypiglin, entityliving); +- }), BehaviorBuilder.triggerIf(PiglinAI::hasCrossbow, BehaviorRetreat.create(5, 0.75F)), BehaviorWalkAwayOutOfRange.create(1.0F), BehaviorAttack.create(20), new BehaviorCrossbowAttack(), BehaviorRememberHuntedHoglin.create(), BehaviorRemoveMemory.create(PiglinAI::isNearZombified, MemoryModuleType.ATTACK_TARGET)), MemoryModuleType.ATTACK_TARGET); ++ // CraftBukkit - decompile error ++ }), BehaviorBuilder.triggerIf(PiglinAI::hasCrossbow, BehaviorRetreat.create(5, 0.75F)), BehaviorWalkAwayOutOfRange.create(1.0F), BehaviorAttack.create(20), new BehaviorCrossbowAttack<>(), BehaviorRememberHuntedHoglin.create(), BehaviorRemoveMemory.create(PiglinAI::isNearZombified, MemoryModuleType.ATTACK_TARGET)), MemoryModuleType.ATTACK_TARGET); + } + + private static void initCelebrateActivity(BehaviorController behaviorcontroller) { +@@ -155,7 +164,8 @@ + return entitypiglin.isAdult(); + }, PiglinAI::findNearestValidAttackTarget), BehaviorBuilder.triggerIf((entitypiglin) -> { + return !entitypiglin.isDancing(); +- }, GoToTargetLocation.create(MemoryModuleType.CELEBRATE_LOCATION, 2, 1.0F)), BehaviorBuilder.triggerIf(EntityPiglin::isDancing, GoToTargetLocation.create(MemoryModuleType.CELEBRATE_LOCATION, 4, 0.6F)), new BehaviorGateSingle(ImmutableList.of(Pair.of(BehaviorLookTarget.create(EntityTypes.PIGLIN, 8.0F), 1), Pair.of(BehaviorStrollRandomUnconstrained.stroll(0.6F, 2, 1), 1), Pair.of(new BehaviorNop(10, 20), 1)))), MemoryModuleType.CELEBRATE_LOCATION); ++ // CraftBukkit - decompile error ++ }, GoToTargetLocation.create(MemoryModuleType.CELEBRATE_LOCATION, 2, 1.0F)), BehaviorBuilder.triggerIf(EntityPiglin::isDancing, GoToTargetLocation.create(MemoryModuleType.CELEBRATE_LOCATION, 4, 0.6F)), new BehaviorGateSingle<>(ImmutableList.of(Pair.of(BehaviorLookTarget.create(EntityTypes.PIGLIN, 8.0F), 1), Pair.of(BehaviorStrollRandomUnconstrained.stroll(0.6F, 2, 1), 1), Pair.of(new BehaviorNop(10, 20), 1)))), MemoryModuleType.CELEBRATE_LOCATION); + } + + private static void initAdmireItemActivity(BehaviorController behaviorcontroller) { +@@ -167,7 +177,8 @@ } private static void initRideHoglinActivity(BehaviorController behaviorcontroller) { @@ -25,16 +45,16 @@ return true; }), 1)).build())), BehaviorStopRiding.create(8, PiglinAI::wantsToStopRiding)), MemoryModuleType.RIDE_TARGET); } -@@ -176,7 +185,7 @@ +@@ -177,7 +188,7 @@ } private static BehaviorGateSingle createIdleLookBehaviors() { -- return new BehaviorGateSingle<>(ImmutableList.builder().addAll(createLookBehaviors()).add(Pair.of(new BehaviorNop(30, 60), 1)).build()); -+ return new BehaviorGateSingle<>(ImmutableList., Integer>>builder().addAll(createLookBehaviors()).add(Pair.of(new BehaviorNop(30, 60), 1)).build()); // CraftBukkit - decompile error +- return new BehaviorGateSingle(ImmutableList.builder().addAll(createLookBehaviors()).add(Pair.of(new BehaviorNop(30, 60), 1)).build()); ++ return new BehaviorGateSingle(ImmutableList., Integer>>builder().addAll(createLookBehaviors()).add(Pair.of(new BehaviorNop(30, 60), 1)).build()); // CraftBukkit - decompile error } private static BehaviorGateSingle createIdleMovementBehaviors() { -@@ -197,13 +206,13 @@ +@@ -198,13 +209,13 @@ protected static void updateActivity(EntityPiglin entitypiglin) { BehaviorController behaviorcontroller = entitypiglin.getBrain(); @@ -51,7 +71,7 @@ Objects.requireNonNull(entitypiglin); optional.ifPresent(entitypiglin::makeSound); -@@ -235,23 +244,27 @@ +@@ -236,23 +247,27 @@ stopWalking(entitypiglin); ItemStack itemstack; @@ -84,7 +104,7 @@ if (!flag) { putInInventory(entitypiglin, itemstack); -@@ -272,7 +285,7 @@ +@@ -273,7 +288,7 @@ ItemStack itemstack1 = itemstack.split(1); if (itemstack.isEmpty()) { @@ -93,12 +113,13 @@ } else { entityitem.setItem(itemstack); } -@@ -287,9 +300,14 @@ - boolean flag1; +@@ -286,10 +301,15 @@ + entitypiglin.setItemInHand(EnumHand.OFF_HAND, ItemStack.EMPTY); if (entitypiglin.isAdult()) { -- flag1 = isBarterCurrency(itemstack); -+ flag1 = isBarterCurrency(itemstack, entitypiglin); // CraftBukkit - Changes to allow custom payment for bartering +- boolean flag1 = isBarterCurrency(itemstack); ++ boolean flag1 = isBarterCurrency(itemstack, entitypiglin); // CraftBukkit - Changes to allow custom payment for bartering + if (flag && flag1) { - throwItems(entitypiglin, getBarterResponseItems(entitypiglin)); + // CraftBukkit start @@ -110,8 +131,8 @@ } else if (!flag1) { boolean flag2 = !entitypiglin.equipItemIfPossible(worldserver, itemstack).isEmpty(); -@@ -302,7 +320,7 @@ - if (!flag1) { +@@ -303,7 +323,7 @@ + if (!flag3) { ItemStack itemstack1 = entitypiglin.getMainHandItem(); - if (isLovedItem(itemstack1)) { @@ -119,7 +140,7 @@ putInInventory(entitypiglin, itemstack1); } else { throwItems(entitypiglin, Collections.singletonList(itemstack1)); -@@ -379,7 +397,7 @@ +@@ -377,7 +397,7 @@ return false; } else if (isAdmiringDisabled(entitypiglin) && entitypiglin.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET)) { return false; @@ -128,7 +149,7 @@ return isNotHoldingLovedItemInOffHand(entitypiglin); } else { boolean flag = entitypiglin.canAddToInventory(itemstack); -@@ -388,6 +406,12 @@ +@@ -386,6 +406,12 @@ } } @@ -141,7 +162,7 @@ protected static boolean isLovedItem(ItemStack itemstack) { return itemstack.is(TagsItem.PIGLIN_LOVED); } -@@ -481,7 +505,7 @@ +@@ -479,7 +505,7 @@ } protected static boolean canAdmire(EntityPiglin entitypiglin, ItemStack itemstack) { @@ -150,7 +171,7 @@ } protected static void wasHurtBy(WorldServer worldserver, EntityPiglin entitypiglin, EntityLiving entityliving) { -@@ -735,6 +759,12 @@ +@@ -727,6 +753,12 @@ return entitypiglin.getBrain().hasMemoryValue(MemoryModuleType.ADMIRING_ITEM); } @@ -163,7 +184,7 @@ private static boolean isBarterCurrency(ItemStack itemstack) { return itemstack.is(PiglinAI.BARTERING_ITEM); } -@@ -772,7 +802,7 @@ +@@ -764,7 +796,7 @@ } private static boolean isNotHoldingLovedItemInOffHand(EntityPiglin entitypiglin) { diff --git a/nms-patches/net/minecraft/world/entity/monster/warden/Warden.patch b/nms-patches/net/minecraft/world/entity/monster/warden/Warden.patch index ca1bdf194..ec1c0c224 100644 --- a/nms-patches/net/minecraft/world/entity/monster/warden/Warden.patch +++ b/nms-patches/net/minecraft/world/entity/monster/warden/Warden.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/warden/Warden.java +++ b/net/minecraft/world/entity/monster/warden/Warden.java -@@ -375,7 +375,7 @@ +@@ -372,7 +372,7 @@ @Override public BehaviorController getBrain() { @@ -9,7 +9,7 @@ } @Override -@@ -412,7 +412,7 @@ +@@ -409,7 +409,7 @@ public static void applyDarknessAround(WorldServer worldserver, Vec3D vec3d, @Nullable Entity entity, int i) { MobEffect mobeffect = new MobEffect(MobEffects.DARKNESS, 260, 0, false, false); @@ -18,26 +18,3 @@ } @Override -@@ -547,7 +547,7 @@ - - public void setAttackTarget(EntityLiving entityliving) { - this.getBrain().eraseMemory(MemoryModuleType.ROAR_TARGET); -- this.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, (Object) entityliving); -+ this.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, entityliving); // CraftBukkit - decompile error - this.getBrain().eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); - SonicBoom.setCooldown(this, 200); - } -@@ -582,11 +582,11 @@ - - @Override - protected NavigationAbstract createNavigation(World world) { -- return new Navigation(this, this, world) { -+ return new Navigation(this, world) { // CraftBukkit - decompile error - @Override - protected Pathfinder createPathFinder(int i) { - this.nodeEvaluator = new PathfinderNormal(); -- return new Pathfinder(this, this.nodeEvaluator, i) { -+ return new Pathfinder(this.nodeEvaluator, i) { // CraftBukkit - decompile error - @Override - protected float distance(PathPoint pathpoint, PathPoint pathpoint1) { - return pathpoint.distanceToXZ(pathpoint1); diff --git a/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch b/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch index 88fdc69ad..d93187d93 100644 --- a/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch +++ b/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/EntityVillager.java +++ b/net/minecraft/world/entity/npc/EntityVillager.java -@@ -93,6 +93,15 @@ +@@ -92,6 +92,15 @@ import net.minecraft.world.phys.AxisAlignedBB; import org.slf4j.Logger; @@ -16,8 +16,21 @@ public class EntityVillager extends EntityVillagerAbstract implements ReputationHandler, VillagerDataHolder { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -133,6 +142,9 @@ - }, MemoryModuleType.MEETING_POINT, (entityvillager, holder) -> { +@@ -129,15 +138,18 @@ + private boolean assignProfessionWhenSpawned; + private static final ImmutableList> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.HOME, MemoryModuleType.JOB_SITE, MemoryModuleType.POTENTIAL_JOB_SITE, MemoryModuleType.MEETING_POINT, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.VISIBLE_VILLAGER_BABIES, MemoryModuleType.NEAREST_PLAYERS, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryModuleType.ITEM_PICKUP_COOLDOWN_TICKS, new MemoryModuleType[]{MemoryModuleType.WALK_TARGET, MemoryModuleType.LOOK_TARGET, MemoryModuleType.INTERACTION_TARGET, MemoryModuleType.BREED_TARGET, MemoryModuleType.PATH, MemoryModuleType.DOORS_TO_CLOSE, MemoryModuleType.NEAREST_BED, MemoryModuleType.HURT_BY, MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.NEAREST_HOSTILE, MemoryModuleType.SECONDARY_JOB_SITE, MemoryModuleType.HIDING_PLACE, MemoryModuleType.HEARD_BELL_TIME, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.LAST_SLEPT, MemoryModuleType.LAST_WOKEN, MemoryModuleType.LAST_WORKED_AT_POI, MemoryModuleType.GOLEM_DETECTED_RECENTLY}); + private static final ImmutableList>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.NEAREST_ITEMS, SensorType.NEAREST_BED, SensorType.HURT_BY, SensorType.VILLAGER_HOSTILES, SensorType.VILLAGER_BABIES, SensorType.SECONDARY_POIS, SensorType.GOLEM_DETECTED); +- public static final Map, BiPredicate>> POI_MEMORIES = ImmutableMap.of(MemoryModuleType.HOME, (BiPredicate) (entityvillager, holder) -> { ++ public static final Map, BiPredicate>> POI_MEMORIES = ImmutableMap.of(MemoryModuleType.HOME, (entityvillager, holder) -> { // CraftBukkit - decompile error + return holder.is(PoiTypes.HOME); +- }, MemoryModuleType.JOB_SITE, (BiPredicate) (entityvillager, holder) -> { ++ }, MemoryModuleType.JOB_SITE, (entityvillager, holder) -> { // CraftBukkit - decompile error + return ((VillagerProfession) entityvillager.getVillagerData().profession().value()).heldJobSite().test(holder); +- }, MemoryModuleType.POTENTIAL_JOB_SITE, (BiPredicate) (entityvillager, holder) -> { ++ }, MemoryModuleType.POTENTIAL_JOB_SITE, (entityvillager, holder) -> { // CraftBukkit - decompile error + return VillagerProfession.ALL_ACQUIRABLE_JOBS.test(holder); +- }, MemoryModuleType.MEETING_POINT, (BiPredicate) (entityvillager, holder) -> { ++ }, MemoryModuleType.MEETING_POINT, (entityvillager, holder) -> { // CraftBukkit - decompile error return holder.is(PoiTypes.MEETING); }); + // CraftBukkit start @@ -26,18 +39,18 @@ public EntityVillager(EntityTypes entitytypes, World world) { this(entitytypes, world, VillagerType.PLAINS); -@@ -140,7 +152,9 @@ - - public EntityVillager(EntityTypes entitytypes, World world, VillagerType villagertype) { +@@ -150,7 +162,9 @@ + public EntityVillager(EntityTypes entitytypes, World world, Holder holder) { super(entitytypes, world); + this.foodLevel = 0; - this.gossips = new Reputation(); + // CraftBukkit start - add constructor parameter in Reputation + this.gossips = new Reputation(this); + // CraftBukkit end - ((Navigation) this.getNavigation()).setCanOpenDoors(true); - this.getNavigation().setCanFloat(true); - this.getNavigation().setRequiredPathLength(48.0F); -@@ -150,7 +164,7 @@ + this.lastGossipDecayTime = 0L; + this.villagerXp = 0; + this.lastRestockGameTime = 0L; +@@ -165,7 +179,7 @@ @Override public BehaviorController getBrain() { @@ -46,7 +59,7 @@ } @Override -@@ -235,7 +249,7 @@ +@@ -250,7 +264,7 @@ this.increaseProfessionLevelOnUpdate = false; } @@ -55,10 +68,10 @@ } } -@@ -360,7 +374,13 @@ - while (iterator.hasNext()) { - MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next(); +@@ -368,7 +382,13 @@ + this.updateDemand(); + for (MerchantRecipe merchantrecipe : this.getOffers()) { - merchantrecipe.resetUses(); + // CraftBukkit start + VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit()); @@ -70,10 +83,10 @@ } this.resendOffersToTradingPlayer(); -@@ -429,7 +449,13 @@ - while (iterator.hasNext()) { - MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next(); +@@ -427,7 +447,13 @@ + if (i > 0) { + for (MerchantRecipe merchantrecipe : this.getOffers()) { - merchantrecipe.resetUses(); + // CraftBukkit start + VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit()); @@ -85,25 +98,16 @@ } } -@@ -489,7 +515,7 @@ - @Override - public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { - super.addAdditionalSaveData(nbttagcompound); -- DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); -+ DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); // CraftBukkit - decompile error - Logger logger = EntityVillager.LOGGER; +@@ -500,7 +526,7 @@ + this.entityData.set(EntityVillager.DATA_VILLAGER_DATA, (VillagerData) nbttagcompound.read("VillagerData", VillagerData.CODEC).orElseGet(EntityVillager::createDefaultVillagerData)); + this.foodLevel = nbttagcompound.getByteOr("FoodLevel", (byte) 0); + this.gossips.clear(); +- Optional optional = nbttagcompound.read("Gossips", Reputation.CODEC); ++ Optional optional = nbttagcompound.read("Gossips", Reputation.CODEC); // CraftBukkit - decompile error + Reputation reputation = this.gossips; - Objects.requireNonNull(logger); -@@ -512,7 +538,7 @@ - public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { - super.readAdditionalSaveData(nbttagcompound); - if (nbttagcompound.contains("VillagerData", 10)) { -- DataResult dataresult = VillagerData.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("VillagerData")); -+ DataResult dataresult = VillagerData.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("VillagerData"))); - Logger logger = EntityVillager.LOGGER; - - Objects.requireNonNull(logger); -@@ -808,7 +834,7 @@ + Objects.requireNonNull(this.gossips); +@@ -777,7 +803,7 @@ entitywitch1.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entitywitch1.blockPosition()), EntitySpawnReason.CONVERSION, (GroupDataEntity) null); entitywitch1.setPersistenceRequired(); this.releaseAllPois(); @@ -112,7 +116,16 @@ if (entitywitch == null) { super.thunderHit(worldserver, entitylightning); -@@ -891,7 +917,7 @@ +@@ -825,7 +851,7 @@ + @Override + protected void updateTrades() { + VillagerData villagerdata = this.getVillagerData(); +- ResourceKey resourcekey = (ResourceKey) villagerdata.profession().unwrapKey().orElse((Object) null); ++ ResourceKey resourcekey = (ResourceKey) villagerdata.profession().unwrapKey().orElse(null); // CraftBukkit - decompile error + + if (resourcekey != null) { + Int2ObjectMap int2objectmap; +@@ -864,7 +890,7 @@ if (this.lastGossipDecayTime == 0L) { this.lastGossipDecayTime = i; @@ -121,7 +134,7 @@ this.gossips.decay(); this.lastGossipDecayTime = i; } -@@ -906,7 +932,7 @@ +@@ -879,7 +905,7 @@ }).limit(5L).toList(); if (list1.size() >= j) { @@ -130,7 +143,7 @@ list.forEach(SensorGolemLastSeen::golemDetected); } } -@@ -919,15 +945,18 @@ +@@ -892,15 +918,18 @@ @Override public void onReputationEventFrom(ReputationEvent reputationevent, Entity entity) { @@ -154,21 +167,3 @@ } } -@@ -963,7 +992,7 @@ - @Override - public void startSleeping(BlockPosition blockposition) { - super.startSleeping(blockposition); -- this.brain.setMemory(MemoryModuleType.LAST_SLEPT, (Object) this.level().getGameTime()); -+ this.brain.setMemory(MemoryModuleType.LAST_SLEPT, this.level().getGameTime()); // CraftBukkit - decompile error - this.brain.eraseMemory(MemoryModuleType.WALK_TARGET); - this.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); - } -@@ -971,7 +1000,7 @@ - @Override - public void stopSleeping() { - super.stopSleeping(); -- this.brain.setMemory(MemoryModuleType.LAST_WOKEN, (Object) this.level().getGameTime()); -+ this.brain.setMemory(MemoryModuleType.LAST_WOKEN, this.level().getGameTime()); // CraftBukkit - decompile error - } - - private boolean golemSpawnConditionsMet(long i) { diff --git a/nms-patches/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch b/nms-patches/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch index dbdfbb05d..cc0d4c481 100644 --- a/nms-patches/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch +++ b/nms-patches/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/npc/EntityVillagerAbstract.java +++ b/net/minecraft/world/entity/npc/EntityVillagerAbstract.java -@@ -40,8 +40,22 @@ +@@ -34,8 +34,22 @@ + import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.Vec3D; - import org.slf4j.Logger; +// CraftBukkit start +import org.bukkit.Bukkit; @@ -20,10 +20,10 @@ + return (org.bukkit.craftbukkit.entity.CraftAbstractVillager) getBukkitEntity(); + } + // CraftBukkit end - private static final DataWatcherObject DATA_UNHAPPY_COUNTER = DataWatcher.defineId(EntityVillagerAbstract.class, DataWatcherRegistry.INT); - private static final Logger LOGGER = LogUtils.getLogger(); + private static final DataWatcherObject DATA_UNHAPPY_COUNTER = DataWatcher.defineId(EntityVillagerAbstract.class, DataWatcherRegistry.INT); public static final int VILLAGER_SLOT_OFFSET = 300; -@@ -50,7 +64,7 @@ + private static final int VILLAGER_INVENTORY_SIZE = 8; +@@ -43,7 +57,7 @@ private EntityHuman tradingPlayer; @Nullable protected MerchantRecipeList offers; @@ -32,16 +32,16 @@ public EntityVillagerAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -179,7 +193,7 @@ +@@ -171,7 +185,7 @@ + @Override public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { super.readAdditionalSaveData(nbttagcompound); - if (nbttagcompound.contains("Offers")) { -- DataResult dataresult = MerchantRecipeList.CODEC.parse(this.registryAccess().createSerializationContext(DynamicOpsNBT.INSTANCE), nbttagcompound.get("Offers")); -+ DataResult dataresult = MerchantRecipeList.CODEC.parse(this.registryAccess().createSerializationContext(DynamicOpsNBT.INSTANCE), nbttagcompound.get("Offers")); // CraftBukkit - decompile error - Logger logger = EntityVillagerAbstract.LOGGER; +- this.offers = (MerchantRecipeList) nbttagcompound.read("Offers", MerchantRecipeList.CODEC, this.registryAccess().createSerializationContext(DynamicOpsNBT.INSTANCE)).orElse((Object) null); ++ this.offers = (MerchantRecipeList) nbttagcompound.read("Offers", MerchantRecipeList.CODEC, this.registryAccess().createSerializationContext(DynamicOpsNBT.INSTANCE)).orElse(null); // CraftBukkit - decompile error + this.readInventoryFromTag(nbttagcompound, this.registryAccess()); + } - Objects.requireNonNull(logger); -@@ -246,7 +260,16 @@ +@@ -230,7 +244,16 @@ MerchantRecipe merchantrecipe = ((VillagerTrades.IMerchantRecipeOption) arraylist.remove(this.random.nextInt(arraylist.size()))).getOffer(this, this.random); if (merchantrecipe != null) { diff --git a/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch b/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch index 24ade5e53..163c6bca7 100644 --- a/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch +++ b/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/EntityVillagerTrader.java +++ b/net/minecraft/world/entity/npc/EntityVillagerTrader.java -@@ -48,6 +48,14 @@ +@@ -45,6 +45,14 @@ import net.minecraft.world.phys.Vec3D; import org.apache.commons.lang3.tuple.Pair; @@ -14,8 +14,8 @@ + public class EntityVillagerTrader extends EntityVillagerAbstract implements Consumable.b { - private static final int NUMBER_OF_TRADE_OFFERS = 5; -@@ -57,6 +65,7 @@ + private static final int DEFAULT_DESPAWN_DELAY = 0; +@@ -54,15 +62,16 @@ public EntityVillagerTrader(EntityTypes entitytypes, World world) { super(entitytypes, world); @@ -23,25 +23,27 @@ } @Override -@@ -137,7 +146,16 @@ - MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.getOffer(this, this.random); + protected void registerGoals() { + this.goalSelector.addGoal(0, new PathfinderGoalFloat(this)); +- this.goalSelector.addGoal(0, new PathfinderGoalUseItem(this, PotionContents.createItemStack(Items.POTION, Potions.INVISIBILITY), SoundEffects.WANDERING_TRADER_DISAPPEARED, (entityvillagertrader) -> { ++ this.goalSelector.addGoal(0, new PathfinderGoalUseItem<>(this, PotionContents.createItemStack(Items.POTION, Potions.INVISIBILITY), SoundEffects.WANDERING_TRADER_DISAPPEARED, (entityvillagertrader) -> { // CraftBukkit - decompile error + return this.level().isDarkOutside() && !entityvillagertrader.isInvisible(); + })); +- this.goalSelector.addGoal(0, new PathfinderGoalUseItem(this, new ItemStack(Items.MILK_BUCKET), SoundEffects.WANDERING_TRADER_REAPPEARED, (entityvillagertrader) -> { ++ this.goalSelector.addGoal(0, new PathfinderGoalUseItem<>(this, new ItemStack(Items.MILK_BUCKET), SoundEffects.WANDERING_TRADER_REAPPEARED, (entityvillagertrader) -> { // CraftBukkit - decompile error + return this.level().isBrightOutside() && entityvillagertrader.isInvisible(); + })); + this.goalSelector.addGoal(1, new PathfinderGoalTradeWithPlayer(this)); +@@ -140,7 +149,7 @@ + public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { + super.readAdditionalSaveData(nbttagcompound); + this.despawnDelay = nbttagcompound.getIntOr("DespawnDelay", 0); +- this.wanderTarget = (BlockPosition) nbttagcompound.read("wander_target", BlockPosition.CODEC).orElse((Object) null); ++ this.wanderTarget = (BlockPosition) nbttagcompound.read("wander_target", BlockPosition.CODEC).orElse(null); // CraftBukkit - decompile error + this.setAge(Math.max(0, this.getAge())); + } - if (merchantrecipe != null) { -- merchantrecipelist.add(merchantrecipe); -+ // CraftBukkit start -+ VillagerAcquireTradeEvent event = new VillagerAcquireTradeEvent((AbstractVillager) getBukkitEntity(), merchantrecipe.asBukkit()); -+ // Suppress during worldgen -+ if (this.valid) { -+ Bukkit.getPluginManager().callEvent(event); -+ } -+ if (!event.isCancelled()) { -+ merchantrecipelist.add(CraftMerchantRecipe.fromBukkit(event.getRecipe()).toMinecraft()); -+ } -+ // CraftBukkit end - } - - } -@@ -244,7 +262,7 @@ +@@ -208,7 +217,7 @@ private void maybeDespawn() { if (this.despawnDelay > 0 && !this.isTrading() && --this.despawnDelay == 0) { diff --git a/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch b/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch index e4987a51d..11d1a7fc0 100644 --- a/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch +++ b/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/npc/MobSpawnerTrader.java +++ b/net/minecraft/world/entity/npc/MobSpawnerTrader.java -@@ -110,7 +110,7 @@ +@@ -101,7 +101,7 @@ return false; } -- EntityVillagerTrader entityvillagertrader = (EntityVillagerTrader) EntityTypes.WANDERING_TRADER.spawn(worldserver, blockposition2, EntitySpawnReason.EVENT); -+ EntityVillagerTrader entityvillagertrader = (EntityVillagerTrader) EntityTypes.WANDERING_TRADER.spawn(worldserver, blockposition2, EntitySpawnReason.EVENT, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit +- EntityVillagerTrader entityvillagertrader = EntityTypes.WANDERING_TRADER.spawn(worldserver, blockposition2, EntitySpawnReason.EVENT); ++ EntityVillagerTrader entityvillagertrader = EntityTypes.WANDERING_TRADER.spawn(worldserver, blockposition2, EntitySpawnReason.EVENT, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit if (entityvillagertrader != null) { - for (int i = 0; i < 2; ++i) { -@@ -118,7 +118,7 @@ + for (int j = 0; j < 2; ++j) { +@@ -109,7 +109,7 @@ } this.serverLevelData.setWanderingTraderId(entityvillagertrader.getUUID()); @@ -18,12 +18,12 @@ entityvillagertrader.setWanderTarget(blockposition1); entityvillagertrader.restrictTo(blockposition1, 16); return true; -@@ -133,7 +133,7 @@ +@@ -124,7 +124,7 @@ BlockPosition blockposition = this.findSpawnPositionNear(worldserver, entityvillagertrader.blockPosition(), i); if (blockposition != null) { -- EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawn(worldserver, blockposition, EntitySpawnReason.EVENT); -+ EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawn(worldserver, blockposition, EntitySpawnReason.EVENT, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit +- EntityLlamaTrader entityllamatrader = EntityTypes.TRADER_LLAMA.spawn(worldserver, blockposition, EntitySpawnReason.EVENT); ++ EntityLlamaTrader entityllamatrader = EntityTypes.TRADER_LLAMA.spawn(worldserver, blockposition, EntitySpawnReason.EVENT, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit if (entityllamatrader != null) { entityllamatrader.setLeashedTo(entityvillagertrader, true); diff --git a/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch b/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch index 5827903e3..f6bd9baf7 100644 --- a/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch +++ b/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/player/EntityHuman.java +++ b/net/minecraft/world/entity/player/EntityHuman.java -@@ -119,6 +119,19 @@ +@@ -117,6 +117,19 @@ import net.minecraft.world.scores.ScoreboardTeam; - import org.slf4j.Logger; + import net.minecraft.world.scores.ScoreboardTeamBase; +// CraftBukkit start +import net.minecraft.nbt.NBTBase; @@ -19,27 +19,27 @@ + public abstract class EntityHuman extends EntityLiving { - private static final Logger LOGGER = LogUtils.getLogger(); -@@ -139,7 +152,8 @@ + public static final EnumMainHand DEFAULT_MAIN_HAND = EnumMainHand.RIGHT; +@@ -136,7 +149,8 @@ private static final int CURRENT_IMPULSE_CONTEXT_RESET_GRACE_TIME_TICKS = 40; public static final Vec3D DEFAULT_VEHICLE_ATTACHMENT = new Vec3D(0.0D, 0.6D, 0.0D); public static final EntitySize STANDING_DIMENSIONS = EntitySize.scalable(0.6F, 1.8F).withEyeHeight(1.62F).withAttachments(EntityAttachments.builder().attach(EntityAttachment.VEHICLE, EntityHuman.DEFAULT_VEHICLE_ATTACHMENT)); - private static final Map POSES = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.STANDING_DIMENSIONS).put(EntityPose.SLEEPING, EntityHuman.SLEEPING_DIMENSIONS).put(EntityPose.FALL_FLYING, EntitySize.scalable(0.6F, 0.6F).withEyeHeight(0.4F)).put(EntityPose.SWIMMING, EntitySize.scalable(0.6F, 0.6F).withEyeHeight(0.4F)).put(EntityPose.SPIN_ATTACK, EntitySize.scalable(0.6F, 0.6F).withEyeHeight(0.4F)).put(EntityPose.CROUCHING, EntitySize.scalable(0.6F, 1.5F).withEyeHeight(1.27F).withAttachments(EntityAttachments.builder().attach(EntityAttachment.VEHICLE, EntityHuman.DEFAULT_VEHICLE_ATTACHMENT))).put(EntityPose.DYING, EntitySize.fixed(0.2F, 0.2F).withEyeHeight(1.62F)).build(); + // CraftBukkit - decompile error + private static final Map POSES = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.STANDING_DIMENSIONS).put(EntityPose.SLEEPING, EntityHuman.SLEEPING_DIMENSIONS).put(EntityPose.FALL_FLYING, EntitySize.scalable(0.6F, 0.6F).withEyeHeight(0.4F)).put(EntityPose.SWIMMING, EntitySize.scalable(0.6F, 0.6F).withEyeHeight(0.4F)).put(EntityPose.SPIN_ATTACK, EntitySize.scalable(0.6F, 0.6F).withEyeHeight(0.4F)).put(EntityPose.CROUCHING, EntitySize.scalable(0.6F, 1.5F).withEyeHeight(1.27F).withAttachments(EntityAttachments.builder().attach(EntityAttachment.VEHICLE, EntityHuman.DEFAULT_VEHICLE_ATTACHMENT))).put(EntityPose.DYING, EntitySize.fixed(0.2F, 0.2F).withEyeHeight(1.62F)).build(); - private static final DataWatcherObject DATA_PLAYER_ABSORPTION_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.FLOAT); - private static final DataWatcherObject DATA_SCORE_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.INT); - protected static final DataWatcherObject DATA_PLAYER_MODE_CUSTOMISATION = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.BYTE); -@@ -149,7 +163,7 @@ - public static final int CLIENT_LOADED_TIMEOUT_TIME = 60; + private static final DataWatcherObject DATA_PLAYER_ABSORPTION_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.FLOAT); + private static final DataWatcherObject DATA_SCORE_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.INT); + protected static final DataWatcherObject DATA_PLAYER_MODE_CUSTOMISATION = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.BYTE); +@@ -155,7 +169,7 @@ + private static final int DEFAULT_CURRENT_IMPULSE_CONTEXT_RESET_GRACE_TIME = 0; private long timeEntitySatOnShoulder; - final PlayerInventory inventory = new PlayerInventory(this); + final PlayerInventory inventory; - protected InventoryEnderChest enderChestInventory = new InventoryEnderChest(); + protected InventoryEnderChest enderChestInventory = new InventoryEnderChest(this); // CraftBukkit - add "this" to constructor public final ContainerPlayer inventoryMenu; public Container containerMenu; protected FoodMetaData foodData = new FoodMetaData(); -@@ -189,6 +203,16 @@ +@@ -195,6 +209,16 @@ private boolean ignoreFallDamageFromCurrentImpulse; private int currentImpulseContextResetGraceTime; @@ -56,7 +56,7 @@ public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile) { super(EntityTypes.PLAYER, world); this.lastItemInMainHand = ItemStack.EMPTY; -@@ -353,7 +377,7 @@ +@@ -366,7 +390,7 @@ } private void turtleHelmetTick() { @@ -65,7 +65,7 @@ } private boolean isEquipped(Item item) { -@@ -523,8 +547,14 @@ +@@ -518,8 +542,14 @@ public void rideTick() { if (!this.level().isClientSide && this.wantsToStopRiding() && this.isPassenger()) { this.stopRiding(); @@ -82,48 +82,25 @@ super.rideTick(); this.oBob = this.bob; this.bob = 0.0F; -@@ -719,6 +749,13 @@ +@@ -590,7 +620,7 @@ + private void playShoulderEntityAmbientSound(NBTTagCompound nbttagcompound) { + if (!nbttagcompound.isEmpty() && !nbttagcompound.getBooleanOr("Silent", false)) { + if (this.level().random.nextInt(200) == 0) { +- EntityTypes entitytypes = (EntityTypes) nbttagcompound.read("id", EntityTypes.CODEC).orElse((Object) null); ++ EntityTypes entitytypes = (EntityTypes) nbttagcompound.read("id", EntityTypes.CODEC).orElse(null); // CraftBukkit - decompile error - @Nullable - public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1) { -+ // CraftBukkit start - SPIGOT-2942: Add boolean to call event -+ return drop(itemstack, flag, flag1, true); -+ } -+ -+ @Nullable -+ public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1, boolean callEvent) { -+ // CraftBukkit end - if (!itemstack.isEmpty() && this.level().isClientSide) { - this.swing(EnumHand.MAIN_HAND); - } -@@ -809,7 +846,7 @@ - } - - if (nbttagcompound.contains("LastDeathLocation", 10)) { -- DataResult dataresult = GlobalPos.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("LastDeathLocation")); -+ DataResult dataresult = GlobalPos.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("LastDeathLocation")); // CraftBukkit - decompile error - Logger logger = EntityHuman.LOGGER; - - Objects.requireNonNull(logger); -@@ -817,7 +854,7 @@ - } - - if (nbttagcompound.contains("current_explosion_impact_pos", 9)) { -- DataResult dataresult1 = Vec3D.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("current_explosion_impact_pos")); -+ DataResult dataresult1 = Vec3D.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("current_explosion_impact_pos")); // CraftBukkit - decompile error - Logger logger1 = EntityHuman.LOGGER; - - Objects.requireNonNull(logger1); -@@ -854,7 +891,7 @@ - } - - this.getLastDeathLocation().flatMap((globalpos) -> { -- DataResult dataresult = GlobalPos.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, globalpos); -+ DataResult dataresult = GlobalPos.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, globalpos); // CraftBukkit - decompile error - Logger logger = EntityHuman.LOGGER; - - Objects.requireNonNull(logger); -@@ -886,10 +923,10 @@ + if (entitytypes == EntityTypes.PARROT && !EntityParrot.imitateNearbyMobs(this.level(), this)) { + this.level().playSound((Entity) null, this.getX(), this.getY(), this.getZ(), EntityParrot.getAmbient(this.level(), this.level().random), this.getSoundSource(), 1.0F, EntityParrot.getPitch(this.level().random)); +@@ -777,7 +807,7 @@ + this.setShoulderEntityLeft(nbttagcompound.getCompoundOrEmpty("ShoulderEntityLeft")); + this.setShoulderEntityRight(nbttagcompound.getCompoundOrEmpty("ShoulderEntityRight")); + this.setLastDeathLocation(nbttagcompound.read("LastDeathLocation", GlobalPos.CODEC)); +- this.currentImpulseImpactPos = (Vec3D) nbttagcompound.read("current_explosion_impact_pos", Vec3D.CODEC).orElse((Object) null); ++ this.currentImpulseImpactPos = (Vec3D) nbttagcompound.read("current_explosion_impact_pos", Vec3D.CODEC).orElse(null); // CraftBukkit - decompile error + this.ignoreFallDamageFromCurrentImpulse = nbttagcompound.getBooleanOr("ignore_fall_damage_from_current_explosion", false); + this.currentImpulseContextResetGraceTime = nbttagcompound.getIntOr("current_impulse_context_reset_grace_time", 0); + } +@@ -829,10 +859,10 @@ if (this.isDeadOrDying()) { return false; } else { @@ -136,7 +113,7 @@ } if (worldserver.getDifficulty() == EnumDifficulty.EASY) { -@@ -901,7 +938,13 @@ +@@ -844,7 +874,13 @@ } } @@ -151,12 +128,12 @@ } } } -@@ -923,10 +966,29 @@ +@@ -868,10 +904,29 @@ } public boolean canHarmPlayer(EntityHuman entityhuman) { -- ScoreboardTeam scoreboardteam = this.getTeam(); -- ScoreboardTeam scoreboardteam1 = entityhuman.getTeam(); +- ScoreboardTeamBase scoreboardteambase = this.getTeam(); +- ScoreboardTeamBase scoreboardteambase1 = entityhuman.getTeam(); + // CraftBukkit start - Change to check OTHER player's scoreboard team according to API + // To summarize this method's logic, it's "Can parameter hurt this" + org.bukkit.scoreboard.Team team; @@ -175,7 +152,7 @@ + } + } -- return scoreboardteam == null ? true : (!scoreboardteam.isAlliedTo(scoreboardteam1) ? true : scoreboardteam.isAllowFriendlyFire()); +- return scoreboardteambase == null ? true : (!scoreboardteambase.isAlliedTo(scoreboardteambase1) ? true : scoreboardteambase.isAllowFriendlyFire()); + if (this instanceof EntityPlayer) { + return !team.hasPlayer(((EntityPlayer) this).getBukkitEntity()); + } @@ -184,13 +161,12 @@ } @Override -@@ -966,8 +1028,13 @@ - } +@@ -885,7 +940,12 @@ } -+ // CraftBukkit start @Override - protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) { ++ // CraftBukkit start + protected boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) { // void -> boolean + if (true) { + return super.actuallyHurt(worldserver, damagesource, f, event); @@ -199,7 +175,7 @@ if (!this.isInvulnerableTo(worldserver, damagesource)) { f = this.getDamageAfterArmorAbsorb(damagesource, f); f = this.getDamageAfterMagicAbsorb(damagesource, f); -@@ -982,7 +1049,7 @@ +@@ -900,7 +960,7 @@ } if (f != 0.0F) { @@ -208,7 +184,7 @@ this.getCombatTracker().recordDamage(damagesource, f); this.setHealth(this.getHealth() - f); if (f < 3.4028235E37F) { -@@ -992,6 +1059,7 @@ +@@ -910,6 +970,7 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE); } } @@ -216,7 +192,7 @@ } public boolean isTextFilteringEnabled() { -@@ -1144,10 +1212,15 @@ +@@ -1066,10 +1127,15 @@ f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; @@ -231,24 +207,9 @@ + } + // CraftBukkit end if (iprojectile.deflect(ProjectileDeflection.AIM_DEFLECT, this, this, true)) { - this.level().playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_ATTACK_NODAMAGE, this.getSoundSource()); + this.level().playSound((Entity) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_ATTACK_NODAMAGE, this.getSoundSource()); return; -@@ -1223,8 +1296,13 @@ - if (entityliving2 != this && entityliving2 != entity && !this.isAlliedTo((Entity) entityliving2) && (!(entityliving2 instanceof EntityArmorStand) || !((EntityArmorStand) entityliving2).isMarker()) && this.distanceToSqr((Entity) entityliving2) < 9.0D) { - float f7 = this.getEnchantedDamage(entityliving2, f6, damagesource) * f2; - -+ // CraftBukkit start - Only apply knockback if the damage hits -+ if (!entityliving2.hurtServer((WorldServer) this.level(), this.damageSources().playerAttack(this).sweep(), f7)) { -+ continue; -+ } -+ // CraftBukkit end - entityliving2.knockback(0.4000000059604645D, (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F))); -- entityliving2.hurt(damagesource, f7); -+ // entityliving2.hurt(damagesource, f7); // CraftBukkit - moved up - World world = this.level(); - - if (world instanceof WorldServer) { -@@ -1240,9 +1318,26 @@ +@@ -1167,9 +1233,26 @@ } if (entity instanceof EntityPlayer && entity.hurtMarked) { @@ -275,14 +236,14 @@ } if (flag2) { -@@ -1308,9 +1403,14 @@ +@@ -1236,9 +1319,14 @@ } } - this.causeFoodExhaustion(0.1F); + this.causeFoodExhaustion(0.1F, EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent } else { - this.level().playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); + this.level().playSound((Entity) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); + // CraftBukkit start - resync on cancelled event + if (this instanceof EntityPlayer) { + ((EntityPlayer) this).getBukkitEntity().updateInventory(); @@ -291,7 +252,7 @@ } } -@@ -1351,7 +1451,14 @@ +@@ -1273,7 +1361,14 @@ @Override public void remove(Entity.RemovalReason entity_removalreason) { @@ -307,7 +268,7 @@ this.inventoryMenu.removed(this); if (this.containerMenu != null && this.hasContainerOpen()) { this.doCloseContainer(); -@@ -1391,6 +1498,12 @@ +@@ -1337,6 +1432,12 @@ } public Either startSleepInBed(BlockPosition blockposition) { @@ -320,7 +281,7 @@ this.startSleeping(blockposition); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1545,12 +1658,24 @@ +@@ -1491,7 +1592,15 @@ } public void startFallFlying() { @@ -336,17 +297,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 -@@ -1665,10 +1790,21 @@ +@@ -1606,10 +1715,21 @@ return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2); } @@ -369,31 +321,7 @@ } } -@@ -1748,13 +1884,20 @@ - - @Override - public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { -+ // CraftBukkit start -+ setItemSlot(enumitemslot, itemstack, false); -+ } -+ -+ @Override -+ public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) { -+ // CraftBukkit end - this.verifyEquippedItem(itemstack); - if (enumitemslot == EnumItemSlot.MAINHAND) { -- this.onEquipItem(enumitemslot, (ItemStack) this.inventory.items.set(this.inventory.selected, itemstack), itemstack); -+ this.onEquipItem(enumitemslot, (ItemStack) this.inventory.items.set(this.inventory.selected, itemstack), itemstack, silent); // CraftBukkit - } else if (enumitemslot == EnumItemSlot.OFFHAND) { -- this.onEquipItem(enumitemslot, (ItemStack) this.inventory.offhand.set(0, itemstack), itemstack); -+ this.onEquipItem(enumitemslot, (ItemStack) this.inventory.offhand.set(0, itemstack), itemstack, silent); // CraftBukkit - } else if (enumitemslot.getType() == EnumItemSlot.Function.HUMANOID_ARMOR) { -- this.onEquipItem(enumitemslot, (ItemStack) this.inventory.armor.set(enumitemslot.getIndex(), itemstack), itemstack); -+ this.onEquipItem(enumitemslot, (ItemStack) this.inventory.armor.set(enumitemslot.getIndex(), itemstack), itemstack, silent); // CraftBukkit - } - - } -@@ -1798,26 +1941,31 @@ +@@ -1706,26 +1826,31 @@ protected void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { @@ -418,11 +346,11 @@ if (!this.level().isClientSide && !nbttagcompound.isEmpty()) { - EntityTypes.create(nbttagcompound, this.level(), EntitySpawnReason.LOAD).ifPresent((entity) -> { + return EntityTypes.create(nbttagcompound, this.level(), EntitySpawnReason.LOAD).map((entity) -> { // CraftBukkit - if (entity instanceof EntityTameableAnimal) { - ((EntityTameableAnimal) entity).setOwnerUUID(this.uuid); + if (entity instanceof EntityTameableAnimal entitytameableanimal) { + entitytameableanimal.setOwner(this); } - entity.setPos(this.getX(), this.getY() + 0.699999988079071D, this.getZ()); + entity.setPos(this.getX(), this.getY() + (double) 0.7F, this.getZ()); - ((WorldServer) this.level()).addWithUUID(entity); - }); + return ((WorldServer) this.level()).addWithUUID(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit @@ -432,4 +360,4 @@ + return true; // CraftBukkit } - @Override + @Nullable diff --git a/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch b/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch index 1746368ea..71b1daf89 100644 --- a/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch +++ b/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch @@ -1,11 +1,12 @@ --- a/net/minecraft/world/entity/player/PlayerInventory.java +++ b/net/minecraft/world/entity/player/PlayerInventory.java -@@ -24,6 +24,13 @@ +@@ -25,6 +25,14 @@ + import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; - import net.minecraft.world.level.block.state.IBlockData; +// CraftBukkit start +import java.util.ArrayList; ++import java.util.List; +import org.bukkit.Location; +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.entity.HumanEntity; @@ -14,39 +15,49 @@ public class PlayerInventory implements IInventory, INamableTileEntity { public static final int POP_TIME_DURATION = 5; -@@ -39,6 +46,54 @@ - public final EntityHuman player; +@@ -39,6 +47,65 @@ + private final EntityEquipment equipment; private int timesChanged; + // CraftBukkit start - add fields and methods -+ public List transaction = new java.util.ArrayList(); ++ public List transaction = new java.util.ArrayList<>(); + private int maxStack = MAX_STACK; + ++ @Override + public List getContents() { -+ List combined = new ArrayList(items.size() + armor.size() + offhand.size()); -+ for (List sub : this.compartments) { -+ combined.addAll(sub); ++ List combined = new ArrayList<>(getContainerSize()); ++ for (net.minecraft.world.item.ItemStack sub : this) { ++ combined.add(sub); + } + + return combined; + } + + public List getArmorContents() { -+ return this.armor; ++ List combined = new ArrayList<>(SLOT_OFFHAND - INVENTORY_SIZE); ++ for (int i = INVENTORY_SIZE; i < SLOT_OFFHAND; i++) { ++ combined.add(getItem(i)); ++ } ++ ++ return combined; + } + ++ @Override + public void onOpen(CraftHumanEntity who) { + transaction.add(who); + } + ++ @Override + public void onClose(CraftHumanEntity who) { + transaction.remove(who); + } + ++ @Override + public List getViewers() { + return transaction; + } + ++ @Override + public org.bukkit.inventory.InventoryHolder getOwner() { + return this.player.getBukkitEntity(); + } @@ -56,6 +67,7 @@ + return maxStack; + } + ++ @Override + public void setMaxStackSize(int size) { + maxStack = size; + } @@ -66,10 +78,10 @@ + } + // CraftBukkit end + - public PlayerInventory(EntityHuman entityhuman) { - this.items = NonNullList.withSize(36, ItemStack.EMPTY); - this.armor = NonNullList.withSize(4, ItemStack.EMPTY); -@@ -59,6 +114,28 @@ + public PlayerInventory(EntityHuman entityhuman, EntityEquipment entityequipment) { + this.items = NonNullList.withSize(36, ItemStack.EMPTY); + this.player = entityhuman; +@@ -77,6 +144,28 @@ return !itemstack.isEmpty() && ItemStack.isSameItemSameComponents(itemstack, itemstack1) && itemstack.isStackable() && itemstack.getCount() < this.getMaxStackSize(itemstack); } @@ -85,7 +97,7 @@ + } + if (remains <= 0) return itemstack.getCount(); + } -+ ItemStack offhandItemStack = this.getItem(this.items.size() + this.armor.size()); ++ ItemStack offhandItemStack = this.equipment.get(EnumItemSlot.OFFHAND); + if (this.hasRemainingSpaceForItem(offhandItemStack, itemstack)) { + remains -= (offhandItemStack.getMaxStackSize() < this.getMaxStackSize() ? offhandItemStack.getMaxStackSize() : this.getMaxStackSize()) - offhandItemStack.getCount(); + } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch index a63d42d3b..d598df8f9 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityArrow.java +++ b/net/minecraft/world/entity/projectile/EntityArrow.java -@@ -51,6 +51,13 @@ +@@ -50,6 +50,13 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.shapes.VoxelShape; @@ -14,7 +14,7 @@ public abstract class EntityArrow extends IProjectile { private static final double ARROW_BASE_DAMAGE = 2.0D; -@@ -88,7 +95,14 @@ +@@ -94,7 +101,14 @@ } protected EntityArrow(EntityTypes entitytypes, double d0, double d1, double d2, World world, ItemStack itemstack, @Nullable ItemStack itemstack1) { @@ -27,20 +27,20 @@ + this.setOwner(ownerEntity); + // CraftBukkit end this.pickupItemStack = itemstack.copy(); - this.setCustomName((IChatBaseComponent) itemstack.get(DataComponents.CUSTOM_NAME)); + this.applyComponentsFromItemStack(itemstack); Unit unit = (Unit) itemstack.remove(DataComponents.INTANGIBLE_PROJECTILE); -@@ -114,8 +128,8 @@ +@@ -120,8 +134,8 @@ } protected EntityArrow(EntityTypes entitytypes, EntityLiving entityliving, World world, ItemStack itemstack, @Nullable ItemStack itemstack1) { -- this(entitytypes, entityliving.getX(), entityliving.getEyeY() - 0.10000000149011612D, entityliving.getZ(), world, itemstack, itemstack1); +- this(entitytypes, entityliving.getX(), entityliving.getEyeY() - (double) 0.1F, entityliving.getZ(), world, itemstack, itemstack1); - this.setOwner(entityliving); -+ this(entitytypes, entityliving.getX(), entityliving.getEyeY() - 0.10000000149011612D, entityliving.getZ(), world, itemstack, itemstack1, entityliving); // CraftBukkit ++ this(entitytypes, entityliving.getX(), entityliving.getEyeY() - (double) 0.1F, entityliving.getZ(), world, itemstack, itemstack1, entityliving); // CraftBukkit + // this.setOwner(entityliving); // SPIGOT-7744 - Moved to the above constructor } public void setSoundEvent(SoundEffect soundeffect) { -@@ -282,7 +296,7 @@ +@@ -284,7 +298,7 @@ if (movingobjectpositionentity == null) { if (this.isAlive() && movingobjectpositionblock.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { @@ -49,7 +49,7 @@ this.hasImpulse = true; } } else { -@@ -290,7 +304,7 @@ +@@ -292,7 +306,7 @@ continue; } @@ -58,7 +58,7 @@ this.hasImpulse = true; if (this.getPierceLevel() > 0 && projectiledeflection == ProjectileDeflection.NONE) { -@@ -357,7 +371,7 @@ +@@ -364,7 +378,7 @@ protected void tickDespawn() { ++this.life; if (this.life >= 1200) { @@ -67,7 +67,7 @@ } } -@@ -423,7 +437,7 @@ +@@ -437,7 +451,7 @@ } if (this.piercingIgnoreEntityIds.size() >= this.getPierceLevel() + 1) { @@ -76,7 +76,7 @@ return; } -@@ -444,7 +458,13 @@ +@@ -458,7 +472,13 @@ int k = entity.getRemainingFireTicks(); if (this.isOnFire() && !flag) { @@ -91,7 +91,7 @@ } if (entity.hurtOrSimulate(damagesource, (float) i)) { -@@ -490,7 +510,7 @@ +@@ -508,7 +528,7 @@ this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); if (this.getPierceLevel() <= 0) { @@ -100,7 +100,7 @@ } } else { entity.setRemainingFireTicks(k); -@@ -506,7 +526,7 @@ +@@ -524,7 +544,7 @@ this.spawnAtLocation(worldserver2, this.getPickupItem(), 0.1F); } @@ -109,16 +109,25 @@ } } } -@@ -675,7 +695,7 @@ - } +@@ -667,7 +687,7 @@ + RegistryOps registryops = this.registryAccess().createSerializationContext(DynamicOpsNBT.INSTANCE); - if (nbttagcompound.contains("weapon", 10)) { -- this.firedFromWeapon = (ItemStack) ItemStack.parse(this.registryAccess(), nbttagcompound.getCompound("weapon")).orElse((Object) null); -+ this.firedFromWeapon = (ItemStack) ItemStack.parse(this.registryAccess(), nbttagcompound.getCompound("weapon")).orElse(null); // CraftBukkit - decompile error - } else { - this.firedFromWeapon = null; - } -@@ -688,34 +708,31 @@ + this.life = nbttagcompound.getShortOr("life", (short) 0); +- this.lastState = (IBlockData) nbttagcompound.read("inBlockState", IBlockData.CODEC, registryops).orElse((Object) null); ++ this.lastState = (IBlockData) nbttagcompound.read("inBlockState", IBlockData.CODEC, registryops).orElse(null); // CraftBukkit - decompile error + this.shakeTime = nbttagcompound.getByteOr("shake", (byte) 0) & 255; + this.setInGround(nbttagcompound.getBooleanOr("inGround", false)); + this.baseDamage = nbttagcompound.getDoubleOr("damage", 2.0D); +@@ -676,7 +696,7 @@ + this.setPierceLevel(nbttagcompound.getByteOr("PierceLevel", (byte) 0)); + this.soundEvent = (SoundEffect) nbttagcompound.read("SoundEvent", BuiltInRegistries.SOUND_EVENT.byNameCodec()).orElse(this.getDefaultHitGroundSoundEvent()); + this.setPickupItemStack((ItemStack) nbttagcompound.read("item", ItemStack.CODEC, registryops).orElse(this.getDefaultPickupItem())); +- this.firedFromWeapon = (ItemStack) nbttagcompound.read("weapon", ItemStack.CODEC, registryops).orElse((Object) null); ++ this.firedFromWeapon = (ItemStack) nbttagcompound.read("weapon", ItemStack.CODEC, registryops).orElse(null); // CraftBukkit - decompile error + } + + @Override +@@ -685,34 +705,31 @@ Entity entity1 = entity; byte b0 = 0; @@ -165,7 +174,7 @@ } this.pickup = entityarrow_pickupstatus; -@@ -724,9 +741,24 @@ +@@ -721,9 +738,24 @@ @Override public void playerTouch(EntityHuman entityhuman) { if (!this.level().isClientSide && (this.isInGround() || this.isNoPhysics()) && this.shakeTime <= 0) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityDragonFireball.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityDragonFireball.patch index 806f5d1e1..5d9c7e914 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityDragonFireball.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityDragonFireball.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityDragonFireball.java +++ b/net/minecraft/world/entity/projectile/EntityDragonFireball.java -@@ -15,6 +15,10 @@ +@@ -14,6 +14,10 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public class EntityDragonFireball extends EntityFireball { public static final float SPLASH_RANGE = 4.0F; -@@ -61,7 +65,7 @@ +@@ -58,7 +62,7 @@ this.level().levelEvent(2006, this.blockPosition(), this.isSilent() ? -1 : 1); this.level().addFreshEntity(entityareaeffectcloud); diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch index 025e842e5..346fbea4f 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch @@ -1,12 +1,14 @@ --- a/net/minecraft/world/entity/projectile/EntityEgg.java +++ b/net/minecraft/world/entity/projectile/EntityEgg.java -@@ -14,6 +14,16 @@ +@@ -18,6 +18,18 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.MovingObjectPositionEntity; +// CraftBukkit start ++import net.minecraft.core.Holder; +import net.minecraft.server.level.EntityPlayer; +import net.minecraft.world.entity.Entity; ++import net.minecraft.world.entity.animal.ChickenVariant; +import org.bukkit.entity.Ageable; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; @@ -17,7 +19,7 @@ public class EntityEgg extends EntityProjectileThrowable { private static final EntitySize ZERO_SIZED_DIMENSIONS = EntitySize.fixed(0.0F, 0.0F); -@@ -52,30 +62,58 @@ +@@ -56,36 +68,68 @@ protected void onHit(MovingObjectPosition movingobjectposition) { super.onHit(movingobjectposition); if (!this.level().isClientSide) { @@ -26,10 +28,10 @@ + boolean hatching = this.random.nextInt(8) == 0; + if (true) { + // CraftBukkit end - byte b0 = 1; + int i = 1; if (this.random.nextInt(32) == 0) { - b0 = 4; + i = 4; } + // CraftBukkit start @@ -37,24 +39,24 @@ + + Entity shooter = this.getOwner(); + if (!hatching) { -+ b0 = 0; ++ i = 0; + } + if (shooter instanceof EntityPlayer) { -+ PlayerEggThrowEvent event = new PlayerEggThrowEvent((Player) shooter.getBukkitEntity(), (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, b0, hatchingType); ++ PlayerEggThrowEvent event = new PlayerEggThrowEvent((Player) shooter.getBukkitEntity(), (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, (byte) i, hatchingType); + this.level().getCraftServer().getPluginManager().callEvent(event); + -+ b0 = event.getNumHatches(); ++ i = event.getNumHatches(); + hatching = event.isHatching(); + hatchingType = event.getHatchingType(); + // If hatching is set to false, ensure child count is 0 + if (!hatching) { -+ b0 = 0; ++ i = 0; + } + } + // CraftBukkit end + - for (int i = 0; i < b0; ++i) { -- EntityChicken entitychicken = (EntityChicken) EntityTypes.CHICKEN.create(this.level(), EntitySpawnReason.TRIGGERED); + for (int j = 0; j < i; ++j) { +- EntityChicken entitychicken = EntityTypes.CHICKEN.create(this.level(), EntitySpawnReason.TRIGGERED); + Entity entitychicken = this.level().getWorld().makeEntity(new org.bukkit.Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass()); // CraftBukkit if (entitychicken != null) { @@ -64,7 +66,19 @@ + ((Ageable) entitychicken.getBukkitEntity()).setBaby(); + } + // CraftBukkit end - entitychicken.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F); + entitychicken.snapTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F); +- Optional optional = Optional.ofNullable((EitherHolder) this.getItem().get(DataComponents.CHICKEN_VARIANT)).flatMap((eitherholder) -> { ++ Optional> optional = Optional.ofNullable((EitherHolder) this.getItem().get(DataComponents.CHICKEN_VARIANT)).flatMap((eitherholder) -> { // CraftBukkit - decompile error + return eitherholder.unwrap(this.registryAccess()); + }); + + Objects.requireNonNull(entitychicken); +- optional.ifPresent(entitychicken::setVariant); ++ // CraftBukkit start ++ if (entitychicken instanceof EntityChicken chicken) { ++ optional.ifPresent(chicken::setVariant); ++ } ++ // CraftBukkit end if (!entitychicken.fudgePositionAfterSizeChange(EntityEgg.ZERO_SIZED_DIMENSIONS)) { break; } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch index cebde2d24..58f882cdf 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityEnderPearl.java +++ b/net/minecraft/world/entity/projectile/EntityEnderPearl.java -@@ -29,6 +29,13 @@ +@@ -27,6 +27,13 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -14,7 +14,7 @@ public class EntityEnderPearl extends EntityProjectileThrowable { private long ticketTimer = 0L; -@@ -140,12 +147,19 @@ +@@ -130,12 +137,19 @@ EntityPlayer entityplayer = (EntityPlayer) entity; if (entityplayer.connection.isAcceptingMessages()) { @@ -26,16 +26,16 @@ + } + // CraftBukkit end if (this.random.nextFloat() < 0.05F && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { - EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(worldserver, EntitySpawnReason.TRIGGERED); + EntityEndermite entityendermite = EntityTypes.ENDERMITE.create(worldserver, EntitySpawnReason.TRIGGERED); if (entityendermite != null) { - entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); + entityendermite.snapTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); - worldserver.addFreshEntity(entityendermite); + worldserver.addFreshEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL); } } -@@ -153,12 +167,12 @@ +@@ -143,12 +157,12 @@ entity.setPortalCooldown(); } @@ -50,7 +50,7 @@ } this.playSound(worldserver, vec3d); -@@ -173,11 +187,11 @@ +@@ -163,11 +177,11 @@ this.playSound(worldserver, vec3d); } @@ -64,7 +64,7 @@ return; } } -@@ -210,7 +224,7 @@ +@@ -200,7 +214,7 @@ entity = this.getOwner(); if (entity instanceof EntityPlayer entityplayer) { if (!entity.isAlive() && entityplayer.serverLevel().getGameRules().getBoolean(GameRules.RULE_ENDER_PEARLS_VANISH_ON_DEATH)) { @@ -73,7 +73,7 @@ break label30; } } -@@ -248,7 +262,7 @@ +@@ -238,7 +252,7 @@ @Override public boolean canTeleport(World world, World world1) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityEnderSignal.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityEnderSignal.patch index 04ffd2f1b..c7fa32cb6 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityEnderSignal.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityEnderSignal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityEnderSignal.java +++ b/net/minecraft/world/entity/projectile/EntityEnderSignal.java -@@ -18,6 +18,10 @@ +@@ -21,6 +21,10 @@ import net.minecraft.world.level.World; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public class EntityEnderSignal extends Entity implements ItemSupplier { private static final float MIN_CAMERA_DISTANCE_SQUARED = 12.25F; -@@ -153,7 +157,7 @@ +@@ -156,7 +160,7 @@ ++this.life; if (this.life > 80 && !this.level().isClientSide) { this.playSound(SoundEffects.ENDER_EYE_DEATH, 1.0F, 1.0F); @@ -20,17 +20,3 @@ if (this.surviveAfterDeath) { this.level().addFreshEntity(new EntityItem(this.level(), this.getX(), this.getY(), this.getZ(), this.getItem())); } else { -@@ -174,7 +178,12 @@ - @Override - public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { - if (nbttagcompound.contains("Item", 10)) { -- this.setItem((ItemStack) ItemStack.parse(this.registryAccess(), nbttagcompound.getCompound("Item")).orElse(this.getDefaultItem())); -+ // CraftBukkit start - SPIGOT-6103 summon, see also SPIGOT-5474 -+ ItemStack itemstack = (ItemStack) ItemStack.parse(this.registryAccess(), nbttagcompound.getCompound("Item")).orElse(this.getDefaultItem()); -+ if (!itemstack.isEmpty()) { -+ this.setItem(itemstack); -+ } -+ // CraftBukkit end - } else { - this.setItem(this.getDefaultItem()); - } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch index fbf2bafb5..143e13503 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityEvokerFangs.java +++ b/net/minecraft/world/entity/projectile/EntityEvokerFangs.java -@@ -17,6 +17,10 @@ +@@ -16,6 +16,10 @@ import net.minecraft.world.item.enchantment.EnchantmentManager; import net.minecraft.world.level.World; @@ -11,7 +11,16 @@ public class EntityEvokerFangs extends Entity implements TraceableEntity { public static final int ATTACK_DURATION = 20; -@@ -121,7 +125,7 @@ +@@ -70,7 +74,7 @@ + @Override + protected void readAdditionalSaveData(NBTTagCompound nbttagcompound) { + this.warmupDelayTicks = nbttagcompound.getIntOr("Warmup", 0); +- this.ownerUUID = (UUID) nbttagcompound.read("Owner", UUIDUtil.CODEC).orElse((Object) null); ++ this.ownerUUID = (UUID) nbttagcompound.read("Owner", UUIDUtil.CODEC).orElse(null); // CraftBukkit - decompile error + } + + @Override +@@ -111,7 +115,7 @@ } if (--this.lifeTicks < 0) { @@ -20,7 +29,7 @@ } } -@@ -132,7 +136,7 @@ +@@ -122,7 +126,7 @@ if (entityliving.isAlive() && !entityliving.isInvulnerable() && entityliving != entityliving1) { if (entityliving1 == null) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch deleted file mode 100644 index 0c681a09f..000000000 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/world/entity/projectile/EntityFireballFireball.java -+++ b/net/minecraft/world/entity/projectile/EntityFireballFireball.java -@@ -61,7 +61,12 @@ - public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { - super.readAdditionalSaveData(nbttagcompound); - if (nbttagcompound.contains("Item", 10)) { -- this.setItem((ItemStack) ItemStack.parse(this.registryAccess(), nbttagcompound.getCompound("Item")).orElse(this.getDefaultItem())); -+ // CraftBukkit start - SPIGOT-5474 probably came from bugged earlier versions -+ ItemStack itemstack = (ItemStack) ItemStack.parse(this.registryAccess(), nbttagcompound.getCompound("Item")).orElse(this.getDefaultItem()); -+ if (!itemstack.isEmpty()) { -+ this.setItem(itemstack); -+ } -+ // CraftBukkit end - } else { - this.setItem(this.getDefaultItem()); - } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch index 82af90e23..0ef5630ea 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityFireworks.java +++ b/net/minecraft/world/entity/projectile/EntityFireworks.java -@@ -33,6 +33,10 @@ +@@ -35,6 +35,10 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -10,8 +10,8 @@ + public class EntityFireworks extends IProjectile implements ItemSupplier { - public static final DataWatcherObject DATA_ID_FIREWORKS_ITEM = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.ITEM_STACK); -@@ -152,7 +156,7 @@ + public static final DataWatcherObject DATA_ID_FIREWORKS_ITEM = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.ITEM_STACK); +@@ -163,7 +167,7 @@ } if (!this.noPhysics && this.isAlive() && movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { @@ -20,7 +20,7 @@ this.hasImpulse = true; } -@@ -172,7 +176,11 @@ +@@ -183,7 +187,11 @@ if (world instanceof WorldServer) { WorldServer worldserver = (WorldServer) world; @@ -33,7 +33,7 @@ } } -@@ -182,7 +190,7 @@ +@@ -193,7 +201,7 @@ worldserver.broadcastEntityEvent(this, (byte) 17); this.gameEvent(GameEvent.EXPLODE, this.getOwner()); this.dealExplosionDamage(worldserver); @@ -42,7 +42,7 @@ } @Override -@@ -191,7 +199,11 @@ +@@ -202,7 +210,11 @@ World world = this.level(); if (world instanceof WorldServer worldserver) { @@ -55,7 +55,7 @@ } } -@@ -205,7 +217,11 @@ +@@ -216,7 +228,11 @@ if (world instanceof WorldServer worldserver) { if (this.hasExplosion()) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch index 48be1a5e0..db331f7f3 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityFishingHook.java +++ b/net/minecraft/world/entity/projectile/EntityFishingHook.java -@@ -47,6 +47,13 @@ +@@ -46,6 +46,13 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -14,7 +14,7 @@ public class EntityFishingHook extends IProjectile { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -68,6 +75,18 @@ +@@ -67,6 +74,18 @@ private final int luck; private final int lureSpeed; @@ -33,7 +33,7 @@ private EntityFishingHook(EntityTypes entitytypes, World world, int i, int j) { super(entitytypes, world); this.syncronizedRandom = RandomSource.create(); -@@ -152,12 +171,12 @@ +@@ -148,12 +167,12 @@ EntityHuman entityhuman = this.getPlayerOwner(); if (entityhuman == null) { @@ -48,7 +48,7 @@ return; } } else { -@@ -259,7 +278,7 @@ +@@ -255,7 +274,7 @@ if (!entityhuman.isRemoved() && entityhuman.isAlive() && (flag || flag1) && this.distanceToSqr((Entity) entityhuman) <= 1024.0D) { return false; } else { @@ -57,7 +57,7 @@ return true; } } -@@ -267,7 +286,7 @@ +@@ -263,7 +282,7 @@ private void checkCollision() { MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity); @@ -66,7 +66,7 @@ } @Override -@@ -300,11 +319,11 @@ +@@ -296,11 +315,11 @@ int i = 1; BlockPosition blockposition1 = blockposition.above(); @@ -80,7 +80,7 @@ --i; } -@@ -314,6 +333,10 @@ +@@ -310,6 +329,10 @@ this.timeUntilLured = 0; this.timeUntilHooked = 0; this.getEntityData().set(EntityFishingHook.DATA_BITING, false); @@ -89,44 +89,44 @@ + this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent); + // CraftBukkit end } - } else { - float f; -@@ -347,6 +370,13 @@ - worldserver.sendParticles(Particles.FISHING, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D); - } - } else { -+ // CraftBukkit start -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.getPlayerOwner().getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.BITE); -+ this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent); -+ if (playerFishEvent.isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - this.playSound(SoundEffects.FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); - double d3 = this.getY() + 0.5D; - -@@ -379,12 +409,16 @@ - } - - if (this.timeUntilLured <= 0) { -- this.fishAngle = MathHelper.nextFloat(this.random, 0.0F, 360.0F); -- this.timeUntilHooked = MathHelper.nextInt(this.random, 20, 80); -+ // CraftBukkit start - logic to modify fishing wait time, lure time, and lure angle -+ this.fishAngle = MathHelper.nextFloat(this.random, this.minLureAngle, this.maxLureAngle); -+ this.timeUntilHooked = MathHelper.nextInt(this.random, this.minLureTime, this.maxLureTime); -+ // CraftBukkit end + } else if (this.timeUntilHooked > 0) { + this.timeUntilHooked -= i; +@@ -335,6 +358,13 @@ + worldserver.sendParticles(Particles.FISHING, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D); } } else { -- this.timeUntilLured = MathHelper.nextInt(this.random, 100, 600); -- this.timeUntilLured -= this.lureSpeed; -+ // CraftBukkit start - logic to modify fishing wait time -+ this.timeUntilLured = MathHelper.nextInt(this.random, this.minWaitTime, this.maxWaitTime); -+ this.timeUntilLured -= (this.applyLure) ? this.lureSpeed : 0; ++ // CraftBukkit start ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.getPlayerOwner().getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.BITE); ++ this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent); ++ if (playerFishEvent.isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + this.playSound(SoundEffects.FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); + double d3 = this.getY() + 0.5D; + +@@ -369,12 +399,16 @@ + } + + if (this.timeUntilLured <= 0) { +- this.fishAngle = MathHelper.nextFloat(this.random, 0.0F, 360.0F); +- this.timeUntilHooked = MathHelper.nextInt(this.random, 20, 80); ++ // CraftBukkit start - logic to modify fishing wait time, lure time, and lure angle ++ this.fishAngle = MathHelper.nextFloat(this.random, this.minLureAngle, this.maxLureAngle); ++ this.timeUntilHooked = MathHelper.nextInt(this.random, this.minLureTime, this.maxLureTime); + // CraftBukkit end } + } else { +- this.timeUntilLured = MathHelper.nextInt(this.random, 100, 600); +- this.timeUntilLured -= this.lureSpeed; ++ // CraftBukkit start - logic to modify fishing wait time ++ this.timeUntilLured = MathHelper.nextInt(this.random, this.minWaitTime, this.maxWaitTime); ++ this.timeUntilLured -= (this.applyLure) ? this.lureSpeed : 0; ++ // CraftBukkit end } -@@ -452,6 +486,14 @@ + } +@@ -441,6 +475,14 @@ int i = 0; if (this.hookedIn != null) { @@ -141,9 +141,9 @@ this.pullEntity(this.hookedIn); CriterionTriggers.FISHING_ROD_HOOKED.trigger((EntityPlayer) entityhuman, itemstack, this, Collections.emptyList()); this.level().broadcastEntityEvent(this, (byte) 31); -@@ -467,6 +509,15 @@ - while (iterator.hasNext()) { - ItemStack itemstack1 = (ItemStack) iterator.next(); +@@ -454,6 +496,15 @@ + + for (ItemStack itemstack1 : list) { EntityItem entityitem = new EntityItem(this.level(), this.getX(), this.getY(), this.getZ(), itemstack1); + // CraftBukkit start + PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), entityitem.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH); @@ -157,7 +157,7 @@ double d0 = entityhuman.getX() - this.getX(); double d1 = entityhuman.getY() - this.getY(); double d2 = entityhuman.getZ() - this.getZ(); -@@ -474,7 +525,11 @@ +@@ -461,7 +512,11 @@ entityitem.setDeltaMovement(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D); this.level().addFreshEntity(entityitem); @@ -170,7 +170,7 @@ if (itemstack1.is(TagsItem.FISHES)) { entityhuman.awardStat(StatisticList.FISH_CAUGHT, 1); } -@@ -484,10 +539,27 @@ +@@ -471,10 +526,27 @@ } if (this.onGround()) { @@ -199,7 +199,7 @@ return i; } else { return 0; -@@ -520,8 +592,15 @@ +@@ -515,8 +587,15 @@ @Override public void remove(Entity.RemovalReason entity_removalreason) { @@ -216,7 +216,7 @@ } @Override -@@ -575,7 +654,7 @@ +@@ -577,7 +656,7 @@ int i = packetplayoutspawnentity.getData(); EntityFishingHook.LOGGER.error("Failed to recreate fishing hook on client. {} (id: {}) is not a valid owner.", this.level().getEntity(i), i); diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch index abd100daf..a56405ded 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityLargeFireball.java +++ b/net/minecraft/world/entity/projectile/EntityLargeFireball.java -@@ -13,17 +13,24 @@ +@@ -13,6 +13,11 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,8 @@ + public class EntityLargeFireball extends EntityFireballFireball { - public int explosionPower = 1; + private static final byte DEFAULT_EXPLOSION_POWER = 1; +@@ -20,11 +25,13 @@ public EntityLargeFireball(EntityTypes entitytypes, World world) { super(entitytypes, world); @@ -25,7 +26,7 @@ } @Override -@@ -34,8 +41,16 @@ +@@ -35,8 +42,16 @@ if (world instanceof WorldServer worldserver) { boolean flag = worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); @@ -44,13 +45,12 @@ } } -@@ -65,7 +80,8 @@ +@@ -65,6 +80,7 @@ + @Override public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { super.readAdditionalSaveData(nbttagcompound); - if (nbttagcompound.contains("ExplosionPower", 99)) { -- this.explosionPower = nbttagcompound.getByte("ExplosionPower"); -+ // CraftBukkit - set bukkitYield when setting explosionpower -+ bukkitYield = this.explosionPower = nbttagcompound.getByte("ExplosionPower"); - } - +- this.explosionPower = nbttagcompound.getByteOr("ExplosionPower", (byte) 1); ++ // CraftBukkit - set bukkitYield when setting explosionpower ++ bukkitYield = this.explosionPower = nbttagcompound.getByteOr("ExplosionPower", (byte) 1); } + } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch index 17a9a2653..f3856935e 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch @@ -26,11 +26,11 @@ if (this.level().getBlockStates(this.getBoundingBox()).noneMatch(BlockBase.BlockData::isAir)) { - this.discard(); + this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause - } else if (this.isInWaterOrBubble()) { + } else if (this.isInWater()) { - this.discard(); + this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } else { - this.setDeltaMovement(vec3d.scale(0.9900000095367432D)); + this.setDeltaMovement(vec3d.scale((double) 0.99F)); this.applyGravity(); @@ -83,7 +87,7 @@ protected void onHitBlock(MovingObjectPositionBlock movingobjectpositionblock) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch index fce143ac0..6caa8fb39 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityPotion.java +++ b/net/minecraft/world/entity/projectile/EntityPotion.java -@@ -35,6 +35,18 @@ +@@ -28,6 +28,18 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.MovingObjectPositionEntity; @@ -16,22 +16,17 @@ +import org.bukkit.event.entity.EntityRemoveEvent; +// CraftBukkit end + - public class EntityPotion extends EntityProjectileThrowable { + public abstract class EntityPotion extends EntityProjectileThrowable { public static final double SPLASH_RANGE = 4.0D; -@@ -101,18 +113,18 @@ +@@ -86,14 +98,14 @@ if (potioncontents.is(Potions.WATER)) { - this.applyWater(worldserver); + this.onHitAsWater(worldserver); - } else if (potioncontents.hasEffects()) { +- this.onHitAsPotion(worldserver, itemstack, movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY ? ((MovingObjectPositionEntity) movingobjectposition).getEntity() : null); + } else if (true || potioncontents.hasEffects()) { // CraftBukkit - Call event even if no effects to apply - if (this.isLingering()) { -- this.makeAreaOfEffectCloud(potioncontents); -+ this.makeAreaOfEffectCloud(potioncontents, movingobjectposition); // CraftBukkit - Pass MovingObjectPosition - } else { -- this.applySplash(worldserver, potioncontents.getAllEffects(), movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY ? ((MovingObjectPositionEntity) movingobjectposition).getEntity() : null); -+ this.applySplash(worldserver, potioncontents.getAllEffects(), movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY ? ((MovingObjectPositionEntity) movingobjectposition).getEntity() : null, movingobjectposition); // CraftBukkit - Pass MovingObjectPosition - } ++ this.onHitAsPotion(worldserver, itemstack, movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY ? ((MovingObjectPositionEntity) movingobjectposition).getEntity() : null, movingobjectposition); // CraftBukkit - Pass MovingObjectPosition } int i = potioncontents.potion().isPresent() && ((PotionRegistry) ((Holder) potioncontents.potion().get()).value()).hasInstantEffects() ? 2007 : 2002; @@ -42,110 +37,14 @@ } } -@@ -147,9 +159,10 @@ +@@ -120,19 +132,31 @@ } -- private void applySplash(WorldServer worldserver, Iterable iterable, @Nullable Entity entity) { -+ private void applySplash(WorldServer worldserver, Iterable iterable, @Nullable Entity entity, MovingObjectPosition position) { // CraftBukkit - Pass MovingObjectPosition - AxisAlignedBB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D); - List list = worldserver.getEntitiesOfClass(EntityLiving.class, axisalignedbb); -+ Map affected = new HashMap(); // CraftBukkit +- protected abstract void onHitAsPotion(WorldServer worldserver, ItemStack itemstack, @Nullable Entity entity); ++ protected abstract void onHitAsPotion(WorldServer worldserver, ItemStack itemstack, @Nullable Entity entity, MovingObjectPosition position); // CraftBukkit - Pass MovingObjectPosition - if (!list.isEmpty()) { - Entity entity1 = this.getEffectSource(); -@@ -170,24 +183,50 @@ - d1 = 1.0D - Math.sqrt(d0) / 4.0D; - } - -- Iterator iterator1 = iterable.iterator(); -+ // CraftBukkit start -+ affected.put((LivingEntity) entityliving.getBukkitEntity(), d1); -+ } -+ } -+ } -+ } - -- while (iterator1.hasNext()) { -- MobEffect mobeffect = (MobEffect) iterator1.next(); -- Holder holder = mobeffect.getEffect(); -+ org.bukkit.event.entity.PotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPotionSplashEvent(this, position, affected); -+ if (!event.isCancelled() && list != null && !list.isEmpty()) { // do not process effects if there are no effects to process -+ Entity entity1 = this.getEffectSource(); -+ for (LivingEntity victim : event.getAffectedEntities()) { -+ if (!(victim instanceof CraftLivingEntity)) { -+ continue; -+ } - -- if (((MobEffectList) holder.value()).isInstantenous()) { -- ((MobEffectList) holder.value()).applyInstantenousEffect(worldserver, this, this.getOwner(), entityliving, mobeffect.getAmplifier(), d1); -- } else { -- int i = mobeffect.mapDuration((j) -> { -- return (int) (d1 * (double) j + 0.5D); -- }); -- MobEffect mobeffect1 = new MobEffect(holder, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible()); -+ EntityLiving entityliving = ((CraftLivingEntity) victim).getHandle(); -+ double d1 = event.getIntensity(victim); -+ // CraftBukkit end - -- if (!mobeffect1.endsWithin(20)) { -- entityliving.addEffect(mobeffect1, entity1); -- } -- } -+ Iterator iterator1 = iterable.iterator(); -+ -+ while (iterator1.hasNext()) { -+ MobEffect mobeffect = (MobEffect) iterator1.next(); -+ Holder holder = mobeffect.getEffect(); -+ // CraftBukkit start - Abide by PVP settings - for players only! -+ if (!this.level().pvpMode && this.getOwner() instanceof EntityPlayer && entityliving instanceof EntityPlayer && entityliving != this.getOwner()) { -+ MobEffectList mobeffectlist = (MobEffectList) holder.value(); -+ if (mobeffectlist == MobEffects.MOVEMENT_SLOWDOWN || mobeffectlist == MobEffects.DIG_SLOWDOWN || mobeffectlist == MobEffects.HARM || mobeffectlist == MobEffects.BLINDNESS -+ || mobeffectlist == MobEffects.HUNGER || mobeffectlist == MobEffects.WEAKNESS || mobeffectlist == MobEffects.POISON) { -+ continue; -+ } -+ } -+ // CraftBukkit end -+ -+ if (((MobEffectList) holder.value()).isInstantenous()) { -+ ((MobEffectList) holder.value()).applyInstantenousEffect(worldserver, this, this.getOwner(), entityliving, mobeffect.getAmplifier(), d1); -+ } else { -+ int i = mobeffect.mapDuration((j) -> { -+ return (int) (d1 * (double) j + 0.5D); -+ }); -+ MobEffect mobeffect1 = new MobEffect(holder, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible()); -+ -+ if (!mobeffect1.endsWithin(20)) { -+ entityliving.addEffect(mobeffect1, entity1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_SPLASH); // CraftBukkit - } - } - } -@@ -196,7 +235,7 @@ - - } - -- private void makeAreaOfEffectCloud(PotionContents potioncontents) { -+ private void makeAreaOfEffectCloud(PotionContents potioncontents, MovingObjectPosition position) { // CraftBukkit - Pass MovingObjectPosition - EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ()); - Entity entity = this.getOwner(); - -@@ -209,7 +248,14 @@ - entityareaeffectcloud.setWaitTime(10); - entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / (float) entityareaeffectcloud.getDuration()); - entityareaeffectcloud.setPotionContents(potioncontents); -- this.level().addFreshEntity(entityareaeffectcloud); -+ // CraftBukkit start -+ org.bukkit.event.entity.LingeringPotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callLingeringPotionSplashEvent(this, position, entityareaeffectcloud); -+ if (!(event.isCancelled() || entityareaeffectcloud.isRemoved())) { -+ this.level().addFreshEntity(entityareaeffectcloud); -+ } else { -+ entityareaeffectcloud.discard(null); // CraftBukkit - add Bukkit remove cause -+ } -+ // CraftBukkit end - } - - public boolean isLingering() { -@@ -220,13 +266,25 @@ + private void dowseFire(BlockPosition blockposition) { IBlockData iblockdata = this.level().getBlockState(blockposition); if (iblockdata.is(TagsBlock.FIRE)) { @@ -163,12 +62,12 @@ + } + // CraftBukkit end } else if (BlockCampfire.isLitCampfire(iblockdata)) { -- this.level().levelEvent((EntityHuman) null, 1009, blockposition, 0); +- this.level().levelEvent((Entity) null, 1009, blockposition, 0); - BlockCampfire.dowse(this.getOwner(), this.level(), blockposition, iblockdata); - this.level().setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(BlockCampfire.LIT, false)); + // CraftBukkit start + if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.setValue(BlockCampfire.LIT, false))) { -+ this.level().levelEvent((EntityHuman) null, 1009, blockposition, 0); ++ this.level().levelEvent((Entity) null, 1009, blockposition, 0); + BlockCampfire.dowse(this.getOwner(), this.level(), blockposition, iblockdata); + this.level().setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(BlockCampfire.LIT, false)); + } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityProjectileThrowable.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityProjectileThrowable.patch index 8ddb29fd1..6edc043cd 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityProjectileThrowable.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityProjectileThrowable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityProjectileThrowable.java +++ b/net/minecraft/world/entity/projectile/EntityProjectileThrowable.java -@@ -34,6 +34,12 @@ +@@ -37,6 +37,12 @@ protected abstract Item getDefaultItem(); diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch index a42348eab..8c7c30b03 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch @@ -11,7 +11,7 @@ public class EntityShulkerBullet extends IProjectile { private static final double SPEED = 0.15D; -@@ -60,8 +64,21 @@ +@@ -60,7 +64,20 @@ this.finalTarget = entity; this.currentMoveDirection = EnumDirection.UP; this.selectNextMoveDirection(enumdirection_enumaxis); @@ -21,19 +21,29 @@ + // CraftBukkit start + public Entity getTarget() { + return this.finalTarget; - } - ++ } ++ + public void setTarget(Entity e) { + this.finalTarget = e; + this.currentMoveDirection = EnumDirection.UP; + this.selectNextMoveDirection(EnumDirection.EnumAxis.X); -+ } + } + // CraftBukkit end -+ + @Override public SoundCategory getSoundSource() { - return SoundCategory.HOSTILE; -@@ -194,7 +211,7 @@ +@@ -88,8 +105,8 @@ + this.targetDeltaX = nbttagcompound.getDoubleOr("TXD", 0.0D); + this.targetDeltaY = nbttagcompound.getDoubleOr("TYD", 0.0D); + this.targetDeltaZ = nbttagcompound.getDoubleOr("TZD", 0.0D); +- this.currentMoveDirection = (EnumDirection) nbttagcompound.read("Dir", EnumDirection.LEGACY_ID_CODEC).orElse((Object) null); +- this.targetId = (UUID) nbttagcompound.read("Target", UUIDUtil.CODEC).orElse((Object) null); ++ this.currentMoveDirection = (EnumDirection) nbttagcompound.read("Dir", EnumDirection.LEGACY_ID_CODEC).orElse(null); // CraftBukkit - decompile error ++ this.targetId = (UUID) nbttagcompound.read("Target", UUIDUtil.CODEC).orElse(null); // CraftBukkit - decompile error + } + + @Override +@@ -185,7 +202,7 @@ @Override public void checkDespawn() { if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL) { @@ -42,7 +52,7 @@ } } -@@ -239,7 +256,7 @@ +@@ -231,7 +248,7 @@ } if (movingobjectposition != null && this.isAlive() && movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { @@ -51,7 +61,7 @@ } ProjectileHelper.rotateTowardsMovement(this, 0.5F); -@@ -312,7 +329,7 @@ +@@ -309,7 +326,7 @@ if (entity instanceof EntityLiving) { EntityLiving entityliving1 = (EntityLiving) entity; @@ -60,7 +70,7 @@ } } -@@ -326,14 +343,20 @@ +@@ -323,14 +340,20 @@ } private void destroy() { @@ -72,7 +82,7 @@ + private void destroy(EntityRemoveEvent.Cause cause) { + this.discard(cause); + // CraftBukkit end - this.level().gameEvent((Holder) GameEvent.ENTITY_DAMAGE, this.position(), GameEvent.a.of((Entity) this)); + this.level().gameEvent(GameEvent.ENTITY_DAMAGE, this.position(), GameEvent.a.of((Entity) this)); } @Override @@ -83,7 +93,7 @@ } @Override -@@ -348,9 +371,14 @@ +@@ -345,9 +368,14 @@ @Override public boolean hurtServer(WorldServer worldserver, DamageSource damagesource, float f) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntitySpectralArrow.patch b/nms-patches/net/minecraft/world/entity/projectile/EntitySpectralArrow.patch index 292ce8948..9081b13c3 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntitySpectralArrow.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntitySpectralArrow.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntitySpectralArrow.java +++ b/net/minecraft/world/entity/projectile/EntitySpectralArrow.java -@@ -41,7 +41,7 @@ +@@ -42,7 +42,7 @@ super.doPostHurtEffects(entityliving); MobEffect mobeffect = new MobEffect(MobEffects.GLOWING, this.duration, 0); diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch index 99263bbaa..a48e27fff 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch @@ -28,7 +28,7 @@ + } + // CraftBukkit end + - EntityExperienceOrb.award((WorldServer) this.level(), this.position(), i); + EntityExperienceOrb.award((WorldServer) this.level(), movingobjectposition.getLocation(), i); - this.discard(); + this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch index 15f4e7f0f..2bbf4ef82 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch @@ -10,8 +10,8 @@ + public class EntityThrownTrident extends EntityArrow { - private static final DataWatcherObject ID_LOYALTY = DataWatcher.defineId(EntityThrownTrident.class, DataWatcherRegistry.BYTE); -@@ -76,10 +80,10 @@ + private static final DataWatcherObject ID_LOYALTY = DataWatcher.defineId(EntityThrownTrident.class, DataWatcherRegistry.BYTE); +@@ -77,10 +81,10 @@ } } @@ -24,12 +24,3 @@ return; } -@@ -137,7 +141,7 @@ - - world = this.level(); - if (world instanceof WorldServer) { -- worldserver = (WorldServer) world; -+ WorldServer worldserver = (WorldServer) world; // CraftBukkit - decompile error - EnchantmentManager.doPostAttackEffectsWithItemSourceOnBreak(worldserver, entity, damagesource, this.getWeaponItem(), (item) -> { - this.kill(worldserver); - }); diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch index 49b008c6d..feec70615 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch @@ -1,20 +1,11 @@ --- a/net/minecraft/world/entity/projectile/EntityTippedArrow.java +++ b/net/minecraft/world/entity/projectile/EntityTippedArrow.java -@@ -119,7 +119,7 @@ - mobeffect = (MobEffect) iterator.next(); - entityliving.addEffect(new MobEffect(mobeffect.getEffect(), Math.max(mobeffect.mapDuration((i) -> { - return i / 8; -- }), 1), mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible()), entity); -+ }), 1), mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible()), entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit - } - } +@@ -113,7 +113,7 @@ + float f = this.getPotionDurationScale(); -@@ -127,7 +127,7 @@ - - while (iterator.hasNext()) { - mobeffect = (MobEffect) iterator.next(); + potioncontents.forEachEffect((mobeffect) -> { - entityliving.addEffect(mobeffect, entity); + entityliving.addEffect(mobeffect, entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit - } - + }, f); } + diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch index d03789ba0..9c3ecca67 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch @@ -11,8 +11,8 @@ + public class EntityWitherSkull extends EntityFireball { - private static final DataWatcherObject DATA_DANGEROUS = DataWatcher.defineId(EntityWitherSkull.class, DataWatcherRegistry.BOOLEAN); -@@ -69,7 +74,7 @@ + private static final DataWatcherObject DATA_DANGEROUS = DataWatcher.defineId(EntityWitherSkull.class, DataWatcherRegistry.BOOLEAN); +@@ -70,7 +75,7 @@ if (entity.isAlive()) { EnchantmentManager.doPostAttackEffects(worldserver, entity, damagesource); } else { @@ -21,16 +21,16 @@ } } } else { -@@ -86,7 +91,7 @@ +@@ -87,7 +92,7 @@ } - if (b0 > 0) { -- entityliving.addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1), this.getEffectSource()); -+ entityliving.addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1), this.getEffectSource(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit + if (i > 0) { +- entityliving1.addEffect(new MobEffect(MobEffects.WITHER, 20 * i, 1), this.getEffectSource()); ++ entityliving1.addEffect(new MobEffect(MobEffects.WITHER, 20 * i, 1), this.getEffectSource(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } } -@@ -97,8 +102,16 @@ +@@ -98,8 +103,16 @@ protected void onHit(MovingObjectPosition movingobjectposition) { super.onHit(movingobjectposition); if (!this.level().isClientSide) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch b/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch index b4c0be0b3..12bb9226f 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch @@ -10,8 +10,8 @@ + public abstract class IProjectile extends Entity implements TraceableEntity { - @Nullable -@@ -47,6 +51,10 @@ + private static final boolean DEFAULT_LEFT_OWNER = false; +@@ -49,6 +53,10 @@ @Nullable private Entity lastDeflectedBy; @@ -22,7 +22,7 @@ IProjectile(EntityTypes entitytypes, World world) { super(entitytypes, world); } -@@ -56,6 +64,7 @@ +@@ -58,6 +66,7 @@ this.ownerUUID = entity.getUUID(); this.cachedOwner = entity; } @@ -30,7 +30,16 @@ } -@@ -213,7 +222,7 @@ +@@ -105,7 +114,7 @@ + + @Override + protected void readAdditionalSaveData(NBTTagCompound nbttagcompound) { +- this.setOwnerThroughUUID((UUID) nbttagcompound.read("Owner", UUIDUtil.CODEC).orElse((Object) null)); ++ this.setOwnerThroughUUID((UUID) nbttagcompound.read("Owner", UUIDUtil.CODEC).orElse(null)); // CraftBukkit - decompile error + this.leftOwner = nbttagcompound.getBooleanOr("LeftOwner", false); + this.hasBeenShot = nbttagcompound.getBooleanOr("HasBeenShot", false); + } +@@ -225,7 +234,7 @@ public static T spawnProjectile(T t0, WorldServer worldserver, ItemStack itemstack, Consumer consumer) { consumer.accept(t0); @@ -39,7 +48,7 @@ t0.applyOnProjectileSpawned(worldserver, itemstack); return t0; } -@@ -232,6 +241,17 @@ +@@ -244,6 +253,17 @@ } @@ -57,7 +66,7 @@ protected ProjectileDeflection hitTargetOrDeflectSelf(MovingObjectPosition movingobjectposition) { if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY) { MovingObjectPositionEntity movingobjectpositionentity = (MovingObjectPositionEntity) movingobjectposition; -@@ -309,6 +329,11 @@ +@@ -321,6 +341,11 @@ protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) {} protected void onHitBlock(MovingObjectPositionBlock movingobjectpositionblock) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/ThrownLingeringPotion.patch b/nms-patches/net/minecraft/world/entity/projectile/ThrownLingeringPotion.patch new file mode 100644 index 000000000..4b65cf823 --- /dev/null +++ b/nms-patches/net/minecraft/world/entity/projectile/ThrownLingeringPotion.patch @@ -0,0 +1,37 @@ +--- a/net/minecraft/world/entity/projectile/ThrownLingeringPotion.java ++++ b/net/minecraft/world/entity/projectile/ThrownLingeringPotion.java +@@ -11,6 +11,10 @@ + import net.minecraft.world.item.Items; + import net.minecraft.world.level.World; + ++// CraftBukkit start ++import net.minecraft.world.phys.MovingObjectPosition; ++// CraftBukkit end ++ + public class ThrownLingeringPotion extends EntityPotion { + + public ThrownLingeringPotion(EntityTypes entitytypes, World world) { +@@ -31,7 +35,7 @@ + } + + @Override +- public void onHitAsPotion(WorldServer worldserver, ItemStack itemstack, @Nullable Entity entity) { ++ public void onHitAsPotion(WorldServer worldserver, ItemStack itemstack, @Nullable Entity entity, MovingObjectPosition position) { // CraftBukkit - Pass MovingObjectPosition + EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ()); + Entity entity1 = this.getOwner(); + +@@ -45,6 +49,13 @@ + entityareaeffectcloud.setWaitTime(10); + entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / (float) entityareaeffectcloud.getDuration()); + entityareaeffectcloud.applyComponentsFromItemStack(itemstack); +- worldserver.addFreshEntity(entityareaeffectcloud); ++ // CraftBukkit start ++ org.bukkit.event.entity.LingeringPotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callLingeringPotionSplashEvent(this, position, entityareaeffectcloud); ++ if (!(event.isCancelled() || entityareaeffectcloud.isRemoved())) { ++ this.level().addFreshEntity(entityareaeffectcloud); ++ } else { ++ entityareaeffectcloud.discard(null); // CraftBukkit - add Bukkit remove cause ++ } ++ // CraftBukkit end + } + } diff --git a/nms-patches/net/minecraft/world/entity/projectile/ThrownSplashPotion.patch b/nms-patches/net/minecraft/world/entity/projectile/ThrownSplashPotion.patch new file mode 100644 index 000000000..9ffc928e4 --- /dev/null +++ b/nms-patches/net/minecraft/world/entity/projectile/ThrownSplashPotion.patch @@ -0,0 +1,82 @@ +--- a/net/minecraft/world/entity/projectile/ThrownSplashPotion.java ++++ b/net/minecraft/world/entity/projectile/ThrownSplashPotion.java +@@ -17,6 +17,16 @@ + import net.minecraft.world.level.World; + import net.minecraft.world.phys.AxisAlignedBB; + ++// CraftBukkit start ++import java.util.HashMap; ++import java.util.Map; ++import net.minecraft.server.level.EntityPlayer; ++import net.minecraft.world.effect.MobEffects; ++import net.minecraft.world.phys.MovingObjectPosition; ++import org.bukkit.craftbukkit.entity.CraftLivingEntity; ++import org.bukkit.entity.LivingEntity; ++// CraftBukkit end ++ + public class ThrownSplashPotion extends EntityPotion { + + public ThrownSplashPotion(EntityTypes entitytypes, World world) { +@@ -37,12 +47,13 @@ + } + + @Override +- public void onHitAsPotion(WorldServer worldserver, ItemStack itemstack, @Nullable Entity entity) { ++ public void onHitAsPotion(WorldServer worldserver, ItemStack itemstack, @Nullable Entity entity, MovingObjectPosition position) { // CraftBukkit - Pass MovingObjectPosition + PotionContents potioncontents = (PotionContents) itemstack.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY); + float f = (Float) itemstack.getOrDefault(DataComponents.POTION_DURATION_SCALE, 1.0F); + Iterable iterable = potioncontents.getAllEffects(); + AxisAlignedBB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D); + List list = this.level().getEntitiesOfClass(EntityLiving.class, axisalignedbb); ++ Map affected = new HashMap(); // CraftBukkit + + if (!list.isEmpty()) { + Entity entity1 = this.getEffectSource(); +@@ -60,8 +71,38 @@ + d1 = 1.0D - Math.sqrt(d0) / 4.0D; + } + ++ // CraftBukkit start ++ affected.put((LivingEntity) entityliving.getBukkitEntity(), d1); ++ } ++ } ++ } ++ } ++ ++ { ++ { ++ org.bukkit.event.entity.PotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPotionSplashEvent(this, position, affected); ++ if (!event.isCancelled() && list != null && !list.isEmpty()) { // do not process effects if there are no effects to process ++ Entity entity1 = this.getEffectSource(); ++ for (LivingEntity victim : event.getAffectedEntities()) { ++ if (!(victim instanceof CraftLivingEntity)) { ++ continue; ++ } ++ ++ EntityLiving entityliving = ((CraftLivingEntity) victim).getHandle(); ++ double d1 = event.getIntensity(victim); ++ // CraftBukkit end ++ + for (MobEffect mobeffect : iterable) { + Holder holder = mobeffect.getEffect(); ++ // CraftBukkit start - Abide by PVP settings - for players only! ++ if (!this.level().pvpMode && this.getOwner() instanceof EntityPlayer && entityliving instanceof EntityPlayer && entityliving != this.getOwner()) { ++ MobEffectList mobeffectlist = (MobEffectList) holder.value(); ++ if (mobeffectlist == MobEffects.SLOWNESS || mobeffectlist == MobEffects.MINING_FATIGUE || mobeffectlist == MobEffects.INSTANT_DAMAGE || mobeffectlist == MobEffects.BLINDNESS ++ || mobeffectlist == MobEffects.HUNGER || mobeffectlist == MobEffects.WEAKNESS || mobeffectlist == MobEffects.POISON) { ++ continue; ++ } ++ } ++ // CraftBukkit end + + if (((MobEffectList) holder.value()).isInstantenous()) { + ((MobEffectList) holder.value()).applyInstantenousEffect(worldserver, this, this.getOwner(), entityliving, mobeffect.getAmplifier(), d1); +@@ -72,7 +113,7 @@ + MobEffect mobeffect1 = new MobEffect(holder, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible()); + + if (!mobeffect1.endsWithin(20)) { +- entityliving.addEffect(mobeffect1, entity1); ++ entityliving.addEffect(mobeffect1, entity1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_SPLASH); // CraftBukkit + } + } + } diff --git a/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch b/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch index d38532195..d4f3f45b7 100644 --- a/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch +++ b/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/EntityRaider.java +++ b/net/minecraft/world/entity/raid/EntityRaider.java -@@ -41,6 +41,10 @@ +@@ -40,6 +40,10 @@ import net.minecraft.world.level.pathfinder.PathEntity; import net.minecraft.world.phys.Vec3D; @@ -10,8 +10,8 @@ + public abstract class EntityRaider extends EntityMonsterPatrolling { - protected static final DataWatcherObject IS_CELEBRATING = DataWatcher.defineId(EntityRaider.class, DataWatcherRegistry.BOOLEAN); -@@ -236,7 +240,7 @@ + protected static final DataWatcherObject IS_CELEBRATING = DataWatcher.defineId(EntityRaider.class, DataWatcherRegistry.BOOLEAN); +@@ -253,7 +257,7 @@ this.onItemPickup(entityitem); this.setItemSlot(enumitemslot, itemstack); this.take(entityitem, itemstack.getCount()); @@ -20,7 +20,7 @@ this.getCurrentRaid().setLeader(this.getWave(), this); this.setPatrolLeader(true); } else { -@@ -290,7 +294,7 @@ +@@ -307,7 +311,7 @@ @Nullable private EntityItem pursuedBannerItemEntity; @@ -29,21 +29,21 @@ this.mob = entityraider; this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE)); } -@@ -547,7 +551,7 @@ - while (iterator.hasNext()) { - EntityRaider entityraider = (EntityRaider) iterator.next(); +@@ -451,7 +455,7 @@ + this.mob.getNavigation().stop(); + for (EntityRaider entityraider : getServerLevel((Entity) this.mob).getNearbyEntities(EntityRaider.class, this.shoutTargeting, this.mob, this.mob.getBoundingBox().inflate(8.0D, 8.0D, 8.0D))) { - entityraider.setTarget(this.mob.getTarget()); + entityraider.setTarget(this.mob.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit } } -@@ -564,7 +568,7 @@ - while (iterator.hasNext()) { - EntityRaider entityraider = (EntityRaider) iterator.next(); +@@ -463,7 +467,7 @@ + if (entityliving != null) { + for (EntityRaider entityraider : getServerLevel((Entity) this.mob).getNearbyEntities(EntityRaider.class, this.shoutTargeting, this.mob, this.mob.getBoundingBox().inflate(8.0D, 8.0D, 8.0D))) { - entityraider.setTarget(entityliving); -+ entityraider.setTarget(this.mob.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit ++ entityraider.setTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit entityraider.setAggressive(true); } diff --git a/nms-patches/net/minecraft/world/entity/raid/PersistentRaid.patch b/nms-patches/net/minecraft/world/entity/raid/PersistentRaid.patch index dc16854e7..d43532f9f 100644 --- a/nms-patches/net/minecraft/world/entity/raid/PersistentRaid.patch +++ b/nms-patches/net/minecraft/world/entity/raid/PersistentRaid.patch @@ -1,27 +1,27 @@ --- a/net/minecraft/world/entity/raid/PersistentRaid.java +++ b/net/minecraft/world/entity/raid/PersistentRaid.java -@@ -115,11 +115,23 @@ +@@ -151,11 +151,23 @@ - Raid raid = this.getOrCreateRaid(entityplayer.serverLevel(), blockposition2); + Raid raid = this.getOrCreateRaid(worldserver, blockposition2); -+ /* CraftBukkit - moved down - if (!raid.isStarted() && !this.raidMap.containsKey(raid.getId())) { - this.raidMap.put(raid.getId(), raid); - } -+ */ ++ /* CraftBukkit - moved down + if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { + this.raidMap.put(this.getUniqueId(), raid); + } ++ */ -- if (!raid.isStarted() || raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel()) { -+ 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, entityplayer)) { -+ entityplayer.removeEffect(net.minecraft.world.effect.MobEffects.RAID_OMEN); -+ return null; -+ } +- if (!raid.isStarted() || raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel()) { ++ 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, worldserver, entityplayer)) { ++ entityplayer.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(entityplayer); - } ++ if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { ++ this.raidMap.put(this.getUniqueId(), raid); ++ } ++ // CraftBukkit end + raid.absorbRaidOmen(entityplayer); + } diff --git a/nms-patches/net/minecraft/world/entity/raid/Raid.patch b/nms-patches/net/minecraft/world/entity/raid/Raid.patch index cff0acd8f..4fc53bdf8 100644 --- a/nms-patches/net/minecraft/world/entity/raid/Raid.patch +++ b/nms-patches/net/minecraft/world/entity/raid/Raid.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java -@@ -177,6 +177,12 @@ +@@ -186,6 +186,12 @@ return this.status == Raid.Status.LOSS; } @@ -13,48 +13,48 @@ public float getTotalHealth() { return this.totalHealth; } -@@ -281,6 +287,7 @@ +@@ -276,6 +282,7 @@ - this.active = this.level.hasChunkAt(this.center); - if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.PEACE); // CraftBukkit + this.active = worldserver.hasChunkAt(this.center); + if (worldserver.getDifficulty() == EnumDifficulty.PEACEFUL) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, worldserver, org.bukkit.event.raid.RaidStopEvent.Reason.PEACE); // CraftBukkit this.stop(); return; } -@@ -300,13 +307,16 @@ - if (!this.level.isVillage(this.center)) { +@@ -295,13 +302,16 @@ + if (!worldserver.isVillage(this.center)) { if (this.groupsSpawned > 0) { this.status = Raid.Status.LOSS; -+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(this, new java.util.ArrayList<>()); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(this, worldserver, 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(this, worldserver, 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(this, worldserver, org.bukkit.event.raid.RaidStopEvent.Reason.TIMEOUT); // CraftBukkit this.stop(); return; } -@@ -374,6 +384,7 @@ +@@ -368,6 +378,7 @@ } if (j > 5) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.UNSPAWNABLE); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, worldserver, org.bukkit.event.raid.RaidStopEvent.Reason.UNSPAWNABLE); // CraftBukkit this.stop(); break; } -@@ -386,6 +397,7 @@ +@@ -379,6 +390,7 @@ + } else { this.status = Raid.Status.VICTORY; - Iterator iterator = this.heroesOfTheVillage.iterator(); + List winners = new java.util.ArrayList<>(); // CraftBukkit - while (iterator.hasNext()) { - UUID uuid = (UUID) iterator.next(); - Entity entity = this.level.getEntity(uuid); -@@ -400,10 +412,12 @@ + for (UUID uuid : this.heroesOfTheVillage) { + Entity entity = worldserver.getEntity(uuid); + +@@ -392,10 +404,12 @@ entityplayer.awardStat(StatisticList.RAID_WIN); CriterionTriggers.RAID_WIN.trigger(entityplayer); @@ -63,67 +63,67 @@ } } } -+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(this, winners); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(this, worldserver, winners); // CraftBukkit } } -@@ -411,6 +425,7 @@ +@@ -403,6 +417,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(this, worldserver, org.bukkit.event.raid.RaidStopEvent.Reason.FINISHED); // CraftBukkit this.stop(); return; } -@@ -544,6 +559,10 @@ - int j = araid_wave.length; - int k = 0; +@@ -524,6 +539,10 @@ + DifficultyDamageScaler difficultydamagescaler = worldserver.getCurrentDifficultyAt(blockposition); + boolean flag1 = this.shouldSpawnBonusGroup(); + // CraftBukkit start + EntityRaider leader = null; + List raiders = new java.util.ArrayList<>(); + // CraftBukkit end - while (k < j) { - Raid.Wave raid_wave = araid_wave[k]; - int l = this.getDefaultNumSpawns(raid_wave, i, flag1) + this.getPotentialBonusSpawns(raid_wave, this.random, i, difficultydamagescaler, flag1); -@@ -559,9 +578,11 @@ + for (Raid.Wave raid_wave : Raid.Wave.VALUES) { + int j = this.getDefaultNumSpawns(raid_wave, i, flag1) + this.getPotentialBonusSpawns(raid_wave, this.random, i, difficultydamagescaler, flag1); + int k = 0; +@@ -538,9 +557,11 @@ entityraider.setPatrolLeader(true); this.setLeader(i, entityraider); flag = true; + leader = entityraider; // CraftBukkit } - this.joinRaid(i, entityraider, blockposition, false); + this.joinRaid(worldserver, i, entityraider, blockposition, false); + raiders.add(entityraider); // CraftBukkit if (raid_wave.entityType == EntityTypes.RAVAGER) { EntityRaider entityraider1 = null; -@@ -580,6 +601,7 @@ - this.joinRaid(i, entityraider1, blockposition, false); - entityraider1.moveTo(blockposition, 0.0F, 0.0F); +@@ -559,6 +580,7 @@ + this.joinRaid(worldserver, i, entityraider1, blockposition, false); + entityraider1.snapTo(blockposition, 0.0F, 0.0F); entityraider1.startRiding(entityraider); + raiders.add(entityraider); // CraftBukkit } } -@@ -597,6 +619,7 @@ +@@ -573,6 +595,7 @@ ++this.groupsSpawned; this.updateBossbar(); - this.setDirty(); -+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidSpawnWaveEvent(this, leader, raiders); // CraftBukkit + this.setDirty(worldserver); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidSpawnWaveEvent(this, worldserver, leader, raiders); // CraftBukkit } - public void joinRaid(int i, EntityRaider entityraider, @Nullable BlockPosition blockposition, boolean flag) { -@@ -612,7 +635,7 @@ - entityraider.finalizeSpawn(this.level, this.level.getCurrentDifficultyAt(blockposition), EntitySpawnReason.EVENT, (GroupDataEntity) null); - entityraider.applyRaidBuffs(this.level, i, false); + public void joinRaid(WorldServer worldserver, int i, EntityRaider entityraider, @Nullable BlockPosition blockposition, boolean flag) { +@@ -588,7 +611,7 @@ + entityraider.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(blockposition), EntitySpawnReason.EVENT, (GroupDataEntity) null); + entityraider.applyRaidBuffs(worldserver, i, false); entityraider.setOnGround(true); -- this.level.addFreshEntityWithPassengers(entityraider); -+ this.level.addFreshEntityWithPassengers(entityraider, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); // CraftBukkit +- worldserver.addFreshEntityWithPassengers(entityraider); ++ worldserver.addFreshEntityWithPassengers(entityraider, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); // CraftBukkit } } -@@ -865,6 +888,12 @@ +@@ -811,6 +834,12 @@ this.heroesOfTheVillage.add(entity.getUUID()); } @@ -133,6 +133,6 @@ + } + // CraftBukkit end + - private static enum Status { + private static enum Status implements INamable { - ONGOING, VICTORY, LOSS, STOPPED; + ONGOING("ongoing"), VICTORY("victory"), LOSS("loss"), STOPPED("stopped"); diff --git a/nms-patches/net/minecraft/world/entity/vehicle/AbstractBoat.patch b/nms-patches/net/minecraft/world/entity/vehicle/AbstractBoat.patch index bc5ef3553..83cfafca7 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/AbstractBoat.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/AbstractBoat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/AbstractBoat.java +++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java -@@ -48,6 +48,15 @@ +@@ -50,6 +50,15 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -15,8 +15,8 @@ + public abstract class AbstractBoat extends VehicleEntity implements Leashable { - private static final DataWatcherObject DATA_ID_PADDLE_LEFT = DataWatcher.defineId(AbstractBoat.class, DataWatcherRegistry.BOOLEAN); -@@ -87,6 +96,14 @@ + private static final DataWatcherObject DATA_ID_PADDLE_LEFT = DataWatcher.defineId(AbstractBoat.class, DataWatcherRegistry.BOOLEAN); +@@ -83,6 +92,14 @@ private Leashable.a leashData; private final Supplier dropItem; @@ -31,7 +31,7 @@ public AbstractBoat(EntityTypes entitytypes, World world, Supplier supplier) { super(entitytypes, world); this.dropItem = supplier; -@@ -182,9 +199,29 @@ +@@ -178,9 +195,29 @@ public void push(Entity entity) { if (entity instanceof AbstractBoat) { if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) { @@ -61,7 +61,7 @@ super.push(entity); } -@@ -247,6 +284,7 @@ +@@ -208,6 +245,7 @@ return this.getDirection().getClockWise(); } @@ -69,7 +69,7 @@ @Override public void tick() { this.oldStatus = this.status; -@@ -287,6 +325,21 @@ +@@ -248,6 +286,21 @@ this.setDeltaMovement(Vec3D.ZERO); } @@ -91,7 +91,7 @@ this.applyEffectsFromBlocks(); this.applyEffectsFromBlocks(); this.tickBubbleColumn(); -@@ -790,11 +843,18 @@ +@@ -733,11 +786,18 @@ @Override public void remove(Entity.RemovalReason entity_removalreason) { diff --git a/nms-patches/net/minecraft/world/entity/vehicle/AbstractChestBoat.patch b/nms-patches/net/minecraft/world/entity/vehicle/AbstractChestBoat.patch index 5b6e2c7ab..11fdf4604 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/AbstractChestBoat.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/AbstractChestBoat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/AbstractChestBoat.java +++ b/net/minecraft/world/entity/vehicle/AbstractChestBoat.java -@@ -27,6 +27,15 @@ +@@ -25,6 +25,15 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.storage.loot.LootTable; @@ -16,7 +16,7 @@ public abstract class AbstractChestBoat extends AbstractBoat implements HasCustomInventoryScreen, ContainerEntity { private static final int CONTAINER_SIZE = 27; -@@ -70,11 +79,18 @@ +@@ -68,11 +77,18 @@ @Override public void remove(Entity.RemovalReason entity_removalreason) { @@ -28,7 +28,7 @@ + public void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) { + // CraftBukkit end if (!this.level().isClientSide && entity_removalreason.shouldDestroy()) { - InventoryUtils.dropContents(this.level(), (Entity) this, (IInventory) this); + InventoryUtils.dropContents(this.level(), (Entity) this, this); } - super.remove(entity_removalreason); @@ -36,9 +36,9 @@ } @Override -@@ -212,4 +228,51 @@ +@@ -210,4 +226,51 @@ public void stopOpen(EntityHuman entityhuman) { - this.level().gameEvent((Holder) GameEvent.CONTAINER_CLOSE, this.position(), GameEvent.a.of((Entity) entityhuman)); + this.level().gameEvent(GameEvent.CONTAINER_CLOSE, this.position(), GameEvent.a.of((Entity) entityhuman)); } + + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch index 0401e0ece..dcddf1777 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java +++ b/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java -@@ -43,6 +43,14 @@ +@@ -45,6 +45,14 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -15,9 +15,9 @@ public abstract class EntityMinecartAbstract extends VehicleEntity { private static final Vec3D LOWERED_PASSENGER_ATTACHMENT = new Vec3D(0.0D, 0.0D, 0.0D); -@@ -76,6 +84,17 @@ - enummap.put(BlockPropertyTrackPosition.NORTH_EAST, Pair.of(baseblockposition2, baseblockposition1)); - }); +@@ -69,6 +77,17 @@ + return ImmutableMap.of(BlockPropertyTrackPosition.NORTH_SOUTH, Pair.of(baseblockposition2, baseblockposition3), BlockPropertyTrackPosition.EAST_WEST, Pair.of(baseblockposition, baseblockposition1), BlockPropertyTrackPosition.ASCENDING_EAST, Pair.of(baseblockposition4, baseblockposition1), BlockPropertyTrackPosition.ASCENDING_WEST, Pair.of(baseblockposition, baseblockposition5), BlockPropertyTrackPosition.ASCENDING_NORTH, Pair.of(baseblockposition2, baseblockposition7), BlockPropertyTrackPosition.ASCENDING_SOUTH, Pair.of(baseblockposition6, baseblockposition3), BlockPropertyTrackPosition.SOUTH_EAST, Pair.of(baseblockposition3, baseblockposition1), BlockPropertyTrackPosition.SOUTH_WEST, Pair.of(baseblockposition3, baseblockposition), BlockPropertyTrackPosition.NORTH_WEST, Pair.of(baseblockposition2, baseblockposition), BlockPropertyTrackPosition.NORTH_EAST, Pair.of(baseblockposition2, baseblockposition1)); + })); + // CraftBukkit start + public boolean slowWhenEmpty = true; @@ -32,17 +32,8 @@ + protected EntityMinecartAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); - this.blocksBuilding = true; -@@ -101,7 +120,7 @@ - - @Nullable - public static T createMinecart(World world, double d0, double d1, double d2, EntityTypes entitytypes, EntitySpawnReason entityspawnreason, ItemStack itemstack, @Nullable EntityHuman entityhuman) { -- T t0 = (EntityMinecartAbstract) entitytypes.create(world, entityspawnreason); -+ T t0 = (T) entitytypes.create(world, entityspawnreason); // CraftBukkit - decompile error - - if (t0 != null) { - t0.setInitialPos(d0, d1, d2); -@@ -262,6 +281,14 @@ + this.flipped = false; +@@ -251,6 +270,14 @@ @Override public void tick() { @@ -57,7 +48,7 @@ if (this.getHurtTime() > 0) { this.setHurtTime(this.getHurtTime() - 1); } -@@ -271,8 +298,20 @@ +@@ -260,8 +287,20 @@ } this.checkBelowWorld(); @@ -78,8 +69,8 @@ + // CraftBukkit end this.updateInWaterStateAndDoFluidPushing(); if (this.isInLava()) { - this.lavaHurt(); -@@ -385,12 +424,16 @@ + this.lavaIgnite(); +@@ -345,12 +384,16 @@ this.setDeltaMovement(MathHelper.clamp(vec3d.x, -d0, d0), vec3d.y, MathHelper.clamp(vec3d.z, -d0, d0)); if (this.onGround()) { @@ -98,7 +89,7 @@ } } -@@ -521,6 +564,14 @@ +@@ -485,6 +528,14 @@ if (!this.level().isClientSide) { if (!entity.noPhysics && !this.noPhysics) { if (!this.hasPassenger(entity)) { @@ -113,7 +104,7 @@ double d0 = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double d2 = d0 * d0 + d1 * d1; -@@ -645,4 +696,26 @@ +@@ -603,4 +654,26 @@ public boolean isFurnace() { return false; } diff --git a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartContainer.patch b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartContainer.patch index 4966dee1e..49de6f48a 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartContainer.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartContainer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/EntityMinecartContainer.java +++ b/net/minecraft/world/entity/vehicle/EntityMinecartContainer.java -@@ -21,6 +21,15 @@ +@@ -20,6 +20,15 @@ import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.phys.Vec3D; @@ -16,7 +16,7 @@ public abstract class EntityMinecartContainer extends EntityMinecartAbstract implements ContainerEntity { private NonNullList itemStacks; -@@ -28,9 +37,50 @@ +@@ -27,9 +36,50 @@ public ResourceKey lootTable; public long lootTableSeed; @@ -63,12 +63,12 @@ + protected EntityMinecartContainer(EntityTypes entitytypes, World world) { super(entitytypes, world); -- this.itemStacks = NonNullList.withSize(36, ItemStack.EMPTY); -+ this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513 +- this.itemStacks = NonNullList.withSize(36, ItemStack.EMPTY); ++ this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513 } @Override -@@ -74,11 +124,18 @@ +@@ -73,11 +123,18 @@ @Override public void remove(Entity.RemovalReason entity_removalreason) { @@ -80,7 +80,7 @@ + public void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) { + // CraftBukkit end if (!this.level().isClientSide && entity_removalreason.shouldDestroy()) { - InventoryUtils.dropContents(this.level(), (Entity) this, (IInventory) this); + InventoryUtils.dropContents(this.level(), (Entity) this, this); } - super.remove(entity_removalreason); diff --git a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartTNT.patch b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartTNT.patch index 0adf2b5f8..71da73f92 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartTNT.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartTNT.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/EntityMinecartTNT.java +++ b/net/minecraft/world/entity/vehicle/EntityMinecartTNT.java -@@ -26,6 +26,11 @@ +@@ -27,6 +27,11 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.material.Fluid; @@ -12,7 +12,7 @@ public class EntityMinecartTNT extends EntityMinecartAbstract { private static final byte EVENT_PRIME = 10; -@@ -37,6 +42,7 @@ +@@ -41,6 +46,7 @@ public int fuse = -1; public float explosionPowerBase = 4.0F; public float explosionSpeedFactor = 1.0F; @@ -20,22 +20,25 @@ public EntityMinecartTNT(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -117,8 +123,16 @@ - if (world instanceof WorldServer worldserver) { - double d1 = Math.min(Math.sqrt(d0), 5.0D); +@@ -122,10 +128,18 @@ + if (worldserver.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES)) { + double d1 = Math.min(Math.sqrt(d0), 5.0D); -- worldserver.explode(this, damagesource, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), (float) ((double) this.explosionPowerBase + (double) this.explosionSpeedFactor * this.random.nextDouble() * 1.5D * d1), false, World.a.TNT); -- this.discard(); -+ // CraftBukkit start -+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), (float) ((double) this.explosionPowerBase + (double) this.explosionSpeedFactor * this.random.nextDouble() * 1.5D * d1), this.isIncendiary); -+ worldserver.getCraftServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ fuse = -1; -+ return; -+ } -+ worldserver.explode(this, damagesource, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT); -+ // CraftBukkit end -+ this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause +- worldserver.explode(this, damagesource, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), (float) ((double) this.explosionPowerBase + (double) this.explosionSpeedFactor * this.random.nextDouble() * 1.5D * d1), false, World.a.TNT); +- this.discard(); ++ // CraftBukkit start ++ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), (float) ((double) this.explosionPowerBase + (double) this.explosionSpeedFactor * this.random.nextDouble() * 1.5D * d1), this.isIncendiary); ++ worldserver.getCraftServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ fuse = -1; ++ return; ++ } ++ worldserver.explode(this, damagesource, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT); ++ // CraftBukkit end ++ this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause + } else if (this.isPrimed()) { +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause + } } - } diff --git a/nms-patches/net/minecraft/world/entity/vehicle/NewMinecartBehavior.patch b/nms-patches/net/minecraft/world/entity/vehicle/NewMinecartBehavior.patch index c384676e8..69a5775ae 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/NewMinecartBehavior.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/NewMinecartBehavior.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java +++ b/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java -@@ -28,6 +28,11 @@ +@@ -27,6 +27,11 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -12,7 +12,7 @@ public class NewMinecartBehavior extends MinecartBehavior { public static final int POS_ROT_LERP_TICKS = 3; -@@ -516,6 +521,12 @@ +@@ -513,6 +518,12 @@ @Override public double getMaxSpeed(WorldServer worldserver) { @@ -25,7 +25,7 @@ return (double) worldserver.getGameRules().getInt(GameRules.RULE_MINECART_MAX_SPEED) * (this.minecart.isInWater() ? 0.5D : 1.0D) / 20.0D; } -@@ -544,7 +555,7 @@ +@@ -541,7 +552,7 @@ @Override public double getSlowdownFactor() { @@ -34,9 +34,9 @@ } @Override -@@ -571,6 +582,14 @@ - Entity entity = (Entity) iterator.next(); - +@@ -564,6 +575,14 @@ + if (!list.isEmpty()) { + for (Entity entity : list) { if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.minecart.isVehicle() && !entity.isPassenger()) { + // CraftBukkit start + VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.minecart.getBukkitEntity(), entity.getBukkitEntity()); @@ -49,9 +49,9 @@ boolean flag = entity.startRiding(this.minecart); if (flag) { -@@ -597,6 +616,16 @@ - Entity entity = (Entity) iterator.next(); - +@@ -586,6 +605,16 @@ + if (!list.isEmpty()) { + for (Entity entity : list) { if (entity instanceof EntityHuman || entity instanceof EntityIronGolem || entity instanceof EntityMinecartAbstract || this.minecart.isVehicle() || entity.isPassenger()) { + // CraftBukkit start + if (!this.minecart.isPassengerOfSameVehicle(entity)) { @@ -66,9 +66,9 @@ entity.push((Entity) this.minecart); flag = true; } -@@ -609,6 +638,14 @@ - Entity entity1 = (Entity) iterator1.next(); - +@@ -594,6 +623,14 @@ + } else { + for (Entity entity1 : this.level().getEntities(this.minecart, axisalignedbb)) { if (!this.minecart.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof EntityMinecartAbstract) { + // CraftBukkit start + VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.minecart.getBukkitEntity(), entity1.getBukkitEntity()); diff --git a/nms-patches/net/minecraft/world/entity/vehicle/OldMinecartBehavior.patch b/nms-patches/net/minecraft/world/entity/vehicle/OldMinecartBehavior.patch index e250c2792..2e5a52962 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/OldMinecartBehavior.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/OldMinecartBehavior.patch @@ -12,9 +12,9 @@ public class OldMinecartBehavior extends MinecartBehavior { private static final double MINECART_RIDABLE_THRESHOLD = 0.01D; -@@ -454,8 +459,26 @@ - Entity entity = (Entity) iterator.next(); - +@@ -412,8 +417,26 @@ + if (!list.isEmpty()) { + for (Entity entity : list) { if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.minecart.isVehicle() && !entity.isPassenger()) { + // CraftBukkit start + VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.minecart.getBukkitEntity(), entity.getBukkitEntity()); @@ -39,9 +39,9 @@ entity.push((Entity) this.minecart); } } -@@ -467,6 +490,14 @@ - Entity entity1 = (Entity) iterator1.next(); - +@@ -421,6 +444,14 @@ + } else { + for (Entity entity1 : this.level().getEntities(this.minecart, axisalignedbb)) { if (!this.minecart.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof EntityMinecartAbstract) { + // CraftBukkit start + VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.minecart.getBukkitEntity(), entity1.getBukkitEntity()); @@ -54,7 +54,7 @@ entity1.push((Entity) this.minecart); } } -@@ -487,11 +518,17 @@ +@@ -441,11 +472,17 @@ @Override public double getMaxSpeed(WorldServer worldserver) { diff --git a/nms-patches/net/minecraft/world/entity/vehicle/VehicleEntity.patch b/nms-patches/net/minecraft/world/entity/vehicle/VehicleEntity.patch index 7f20fdff3..adf14a943 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/VehicleEntity.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/VehicleEntity.patch @@ -13,7 +13,7 @@ + public abstract class VehicleEntity extends Entity { - protected static final DataWatcherObject DATA_ID_HURT = DataWatcher.defineId(VehicleEntity.class, DataWatcherRegistry.INT); + protected static final DataWatcherObject DATA_ID_HURT = DataWatcher.defineId(VehicleEntity.class, DataWatcherRegistry.INT); @@ -40,6 +47,18 @@ return false; } else { diff --git a/nms-patches/net/minecraft/world/food/FoodInfo.patch b/nms-patches/net/minecraft/world/food/FoodInfo.patch index 294900c93..6633c32c3 100644 --- a/nms-patches/net/minecraft/world/food/FoodInfo.patch +++ b/nms-patches/net/minecraft/world/food/FoodInfo.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/food/FoodInfo.java +++ b/net/minecraft/world/food/FoodInfo.java -@@ -18,6 +18,10 @@ +@@ -19,6 +19,10 @@ import net.minecraft.world.item.component.ConsumableListener; import net.minecraft.world.level.World; @@ -11,12 +11,12 @@ public record FoodInfo(int nutrition, float saturation, boolean canAlwaysEat) implements ConsumableListener { public static final Codec DIRECT_CODEC = RecordCodecBuilder.create((instance) -> { -@@ -31,7 +35,7 @@ +@@ -32,7 +36,7 @@ - world.playSound((EntityHuman) null, entityliving.getX(), entityliving.getY(), entityliving.getZ(), (SoundEffect) consumable.sound().value(), SoundCategory.NEUTRAL, 1.0F, randomsource.triangle(1.0F, 0.4F)); + world.playSound((Entity) null, entityliving.getX(), entityliving.getY(), entityliving.getZ(), (SoundEffect) consumable.sound().value(), SoundCategory.NEUTRAL, 1.0F, randomsource.triangle(1.0F, 0.4F)); if (entityliving instanceof EntityHuman entityhuman) { - entityhuman.getFoodData().eat(this); + entityhuman.getFoodData().eat(this, itemstack, (EntityPlayer) entityhuman); // CraftBukkit - world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, MathHelper.randomBetween(randomsource, 0.9F, 1.0F)); + world.playSound((Entity) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, MathHelper.randomBetween(randomsource, 0.9F, 1.0F)); } diff --git a/nms-patches/net/minecraft/world/food/FoodMetaData.patch b/nms-patches/net/minecraft/world/food/FoodMetaData.patch index dc73325ee..9aba95b13 100644 --- a/nms-patches/net/minecraft/world/food/FoodMetaData.patch +++ b/nms-patches/net/minecraft/world/food/FoodMetaData.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/food/FoodMetaData.java +++ b/net/minecraft/world/food/FoodMetaData.java -@@ -7,12 +7,22 @@ +@@ -7,6 +7,11 @@ import net.minecraft.world.EnumDifficulty; import net.minecraft.world.level.GameRules; @@ -11,7 +11,8 @@ + public class FoodMetaData { - public int foodLevel = 20; + private static final int DEFAULT_TICK_TIMER = 0; +@@ -15,6 +20,11 @@ public float saturationLevel = 5.0F; public float exhaustionLevel; private int tickTimer; @@ -23,7 +24,7 @@ public FoodMetaData() {} -@@ -29,6 +39,20 @@ +@@ -31,6 +41,20 @@ this.add(foodinfo.nutrition(), foodinfo.saturation()); } @@ -44,7 +45,7 @@ public void tick(EntityPlayer entityplayer) { WorldServer worldserver = entityplayer.serverLevel(); EnumDifficulty enumdifficulty = worldserver.getDifficulty(); -@@ -38,7 +62,15 @@ +@@ -40,7 +64,15 @@ if (this.saturationLevel > 0.0F) { this.saturationLevel = Math.max(this.saturationLevel - 1.0F, 0.0F); } else if (enumdifficulty != EnumDifficulty.PEACEFUL) { @@ -61,7 +62,7 @@ } } -@@ -46,23 +78,25 @@ +@@ -48,23 +80,25 @@ if (flag && this.saturationLevel > 0.0F && entityplayer.isHurt() && this.foodLevel >= 20) { ++this.tickTimer; diff --git a/nms-patches/net/minecraft/world/inventory/Container.patch b/nms-patches/net/minecraft/world/inventory/Container.patch index 808b2dbca..ae7193eb8 100644 --- a/nms-patches/net/minecraft/world/inventory/Container.patch +++ b/nms-patches/net/minecraft/world/inventory/Container.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/Container.java +++ b/net/minecraft/world/inventory/Container.java -@@ -35,6 +35,20 @@ +@@ -36,6 +36,20 @@ import net.minecraft.world.level.block.entity.TileEntity; import org.slf4j.Logger; @@ -21,7 +21,7 @@ public abstract class Container { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -67,6 +81,31 @@ +@@ -68,6 +82,31 @@ private ContainerSynchronizer synchronizer; private boolean suppressRemoteUpdates; @@ -52,16 +52,17 @@ + protected Container(@Nullable Containers containers, int i) { this.carried = ItemStack.EMPTY; - this.remoteSlots = NonNullList.create(); -@@ -192,6 +231,15 @@ + this.remoteSlots = NonNullList.create(); +@@ -201,6 +240,16 @@ } + // CraftBukkit start + public void broadcastCarriedItem() { -+ this.remoteCarried = this.getCarried().copy(); ++ ItemStack itemstack = this.getCarried().copy(); ++ this.remoteCarried.force(itemstack); + if (this.synchronizer != null) { -+ this.synchronizer.sendCarriedChange(this, this.remoteCarried); ++ this.synchronizer.sendCarriedChange(this, itemstack); + } + } + // CraftBukkit end @@ -69,39 +70,39 @@ public void removeSlotListener(ICrafting icrafting) { this.containerListeners.remove(icrafting); } -@@ -417,7 +465,7 @@ +@@ -408,7 +457,7 @@ } } else if (this.quickcraftStatus == 2) { if (!this.quickcraftSlots.isEmpty()) { - if (this.quickcraftSlots.size() == 1) { + if (false && this.quickcraftSlots.size() == 1) { // CraftBukkit - treat everything as a drag since we are unable to easily call InventoryClickEvent instead - k = ((Slot) this.quickcraftSlots.iterator().next()).index; - this.resetQuickCraft(); - this.doClick(k, this.quickcraftType, InventoryClickType.PICKUP, entityhuman); -@@ -433,6 +481,7 @@ - l = this.getCarried().getCount(); - Iterator iterator = this.quickcraftSlots.iterator(); + int l = ((Slot) this.quickcraftSlots.iterator().next()).index; + this.resetQuickCraft(); +@@ -424,6 +473,7 @@ + } + + int i1 = this.getCarried().getCount(); + Map draggedSlots = new HashMap(); // CraftBukkit - Store slots from drag in map (raw slot id -> new stack) - while (iterator.hasNext()) { - Slot slot1 = (Slot) iterator.next(); + + for (Slot slot1 : this.quickcraftSlots) { ItemStack itemstack2 = this.getCarried(); -@@ -443,12 +492,48 @@ +@@ -434,12 +484,48 @@ int l1 = Math.min(getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemstack1) + j1, k1); - l -= l1 - j1; + i1 -= l1 - j1; - slot1.setByPlayer(itemstack1.copyWithCount(l1)); + // slot1.setByPlayer(itemstack1.copyWithCount(l1)); + draggedSlots.put(slot1.index, itemstack1.copyWithCount(l1)); // CraftBukkit - Put in map instead of setting } } -- itemstack1.setCount(l); +- itemstack1.setCount(i1); - this.setCarried(itemstack1); + // CraftBukkit start - InventoryDragEvent + InventoryView view = getBukkitView(); + org.bukkit.inventory.ItemStack newcursor = CraftItemStack.asCraftMirror(itemstack1); -+ newcursor.setAmount(l); ++ newcursor.setAmount(i1); + Map eventmap = new HashMap(); + for (Map.Entry ditem : draggedSlots.entrySet()) { + eventmap.put(ditem.getKey(), CraftItemStack.asBukkitCopy(ditem.getValue())); @@ -138,49 +139,49 @@ } this.resetQuickCraft(); -@@ -466,8 +551,11 @@ - if (i == -999) { - if (!this.getCarried().isEmpty()) { - if (clickaction == ClickAction.PRIMARY) { -- entityhuman.drop(this.getCarried(), true); -+ // CraftBukkit start -+ ItemStack carried = this.getCarried(); - this.setCarried(ItemStack.EMPTY); -+ entityhuman.drop(carried, true); -+ // CraftBukkit start - } else { - entityhuman.drop(this.getCarried().split(1), true); - } -@@ -530,6 +618,15 @@ +@@ -454,8 +540,11 @@ + if (i == -999) { + if (!this.getCarried().isEmpty()) { + if (clickaction == ClickAction.PRIMARY) { +- entityhuman.drop(this.getCarried(), true); ++ // CraftBukkit start ++ ItemStack carried = this.getCarried(); + this.setCarried(ItemStack.EMPTY); ++ entityhuman.drop(carried, true); ++ // CraftBukkit start + } else { + entityhuman.drop(this.getCarried().split(1), true); + } +@@ -521,6 +610,15 @@ + } + + slot3.setChanged(); ++ // CraftBukkit start - Make sure the client has the right slot contents ++ if (entityhuman instanceof EntityPlayer && slot3.getMaxStackSize() != IInventory.MAX_STACK) { ++ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutSetSlot(this.containerId, this.incrementStateId(), slot3.index, slot3.getItem())); ++ // Updating a crafting inventory makes the client reset the result slot, have to send it again ++ if (this.getBukkitView().getType() == InventoryType.WORKBENCH || this.getBukkitView().getType() == InventoryType.CRAFTING) { ++ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutSetSlot(this.containerId, this.incrementStateId(), 0, this.getSlot(0).getItem())); ++ } ++ } ++ // CraftBukkit end + } + } else if (inventoryclicktype == InventoryClickType.SWAP && (j >= 0 && j < 9 || j == 40)) { + ItemStack itemstack6 = playerinventory.getItem(j); +@@ -589,7 +687,11 @@ } - slot.setChanged(); -+ // CraftBukkit start - Make sure the client has the right slot contents -+ if (entityhuman instanceof EntityPlayer && slot.getMaxStackSize() != IInventory.MAX_STACK) { -+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutSetSlot(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() == InventoryType.WORKBENCH || this.getBukkitView().getType() == InventoryType.CRAFTING) { -+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutSetSlot(this.containerId, this.incrementStateId(), 0, this.getSlot(0).getItem())); -+ } + itemstack9 = slot6.safeTake(j3, Integer.MAX_VALUE, entityhuman); +- entityhuman.drop(itemstack9, true); ++ // CraftBukkit start - SPIGOT-8010: break loop ++ if (entityhuman.drop(itemstack9, true) == null) { ++ break; + } + // CraftBukkit end + entityhuman.handleCreativeModeItemDrop(itemstack9); } - } else { - int j2; -@@ -598,7 +695,11 @@ - } - - itemstack = slot2.safeTake(k, Integer.MAX_VALUE, entityhuman); -- entityhuman.drop(itemstack, true); -+ // CraftBukkit start - SPIGOT-8010: break loop -+ if (entityhuman.drop(itemstack, true) == null) { -+ break; -+ } -+ // CraftBukkit end - entityhuman.handleCreativeModeItemDrop(itemstack); - } - } -@@ -662,8 +763,9 @@ + } +@@ -651,8 +753,9 @@ ItemStack itemstack = this.getCarried(); if (!itemstack.isEmpty()) { @@ -191,7 +192,7 @@ } } -@@ -893,6 +995,11 @@ +@@ -881,6 +984,11 @@ } public ItemStack getCarried() { diff --git a/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch b/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch index 9bf68e92e..1b942a174 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerAnvil.java +++ b/net/minecraft/world/inventory/ContainerAnvil.java -@@ -21,6 +21,10 @@ +@@ -20,6 +20,10 @@ import net.minecraft.world.level.block.state.IBlockData; import org.slf4j.Logger; @@ -11,7 +11,7 @@ public class ContainerAnvil extends ContainerAnvilAbstract { public static final int INPUT_SLOT = 0; -@@ -45,6 +49,11 @@ +@@ -44,6 +48,11 @@ private static final int ADDITIONAL_SLOT_X_PLACEMENT = 76; private static final int RESULT_SLOT_X_PLACEMENT = 134; private static final int SLOT_Y_PLACEMENT = 47; @@ -23,7 +23,7 @@ public ContainerAnvil(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); -@@ -72,7 +81,7 @@ +@@ -71,7 +80,7 @@ @Override protected boolean mayPickup(EntityHuman entityhuman, boolean flag) { @@ -32,7 +32,7 @@ } @Override -@@ -94,7 +103,7 @@ +@@ -93,7 +102,7 @@ this.inputSlots.setItem(1, ItemStack.EMPTY); } @@ -41,10 +41,10 @@ this.inputSlots.setItem(0, ItemStack.EMPTY); this.access.execute((world, blockposition) -> { IBlockData iblockdata = world.getBlockState(blockposition); -@@ -143,8 +152,8 @@ - if (itemstack1.isDamageableItem() && itemstack.isValidRepairItem(itemstack2)) { - k = Math.min(itemstack1.getDamageValue(), itemstack1.getMaxDamage() / 4); - if (k <= 0) { +@@ -139,8 +148,8 @@ + int l = Math.min(itemstack1.getDamageValue(), itemstack1.getMaxDamage() / 4); + + if (l <= 0) { - this.resultSlots.setItem(0, ItemStack.EMPTY); - this.cost.set(0); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit @@ -52,7 +52,7 @@ return; } -@@ -158,8 +167,8 @@ +@@ -157,8 +166,8 @@ this.repairItemCountCost = i1; } else { if (!flag && (!itemstack1.is(itemstack2.getItem()) || !itemstack1.isDamageableItem())) { @@ -63,7 +63,7 @@ return; } -@@ -233,8 +242,8 @@ +@@ -226,8 +235,8 @@ } if (flag2 && !flag1) { @@ -74,10 +74,10 @@ return; } } -@@ -260,14 +269,14 @@ +@@ -253,14 +262,14 @@ } - if (b0 == i && b0 > 0) { + if (k == i && k > 0) { - if (this.cost.get() >= 40) { - this.cost.set(39); + if (this.cost.get() >= maximumRepairCost) { // CraftBukkit @@ -87,12 +87,12 @@ this.onlyRenaming = true; } -- if (this.cost.get() >= 40 && !this.player.getAbilities().instabuild) { -+ if (this.cost.get() >= maximumRepairCost && !this.player.getAbilities().instabuild) { // CraftBukkit +- if (this.cost.get() >= 40 && !this.player.hasInfiniteMaterials()) { ++ if (this.cost.get() >= maximumRepairCost && !this.player.hasInfiniteMaterials()) { // CraftBukkit itemstack1 = ItemStack.EMPTY; } -@@ -285,12 +294,13 @@ +@@ -279,12 +288,13 @@ EnchantmentManager.setEnchantments(itemstack1, itemenchantments_a.toImmutable()); } @@ -109,7 +109,7 @@ } public static int calculateIncreasedRepairCost(int i) { -@@ -329,4 +339,19 @@ +@@ -323,4 +333,19 @@ public int getCost() { return this.cost.get(); } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch b/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch index 204c7d1c0..1e832c0a3 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerAnvilAbstract.java +++ b/net/minecraft/world/inventory/ContainerAnvilAbstract.java -@@ -50,7 +50,7 @@ - while (iterator.hasNext()) { - final ItemCombinerMenuSlotDefinition.b itemcombinermenuslotdefinition_b = (ItemCombinerMenuSlotDefinition.b) iterator.next(); - -- this.addSlot(new Slot(this, this.inputSlots, itemcombinermenuslotdefinition_b.slotIndex(), itemcombinermenuslotdefinition_b.x(), itemcombinermenuslotdefinition_b.y()) { -+ this.addSlot(new Slot(this.inputSlots, itemcombinermenuslotdefinition_b.slotIndex(), itemcombinermenuslotdefinition_b.x(), itemcombinermenuslotdefinition_b.y()) { // CraftBukkit - decompile error - @Override - public boolean mayPlace(ItemStack itemstack) { - return itemcombinermenuslotdefinition_b.mayPlace().test(itemstack); -@@ -110,6 +110,7 @@ +@@ -105,6 +105,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch b/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch index b15494388..881752118 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch @@ -23,16 +23,14 @@ public ContainerBeacon(int i, IInventory iinventory) { this(i, iinventory, new ContainerProperties(3), ContainerAccess.NULL); -@@ -34,7 +43,8 @@ +@@ -34,6 +43,7 @@ public ContainerBeacon(int i, IInventory iinventory, IContainerProperties icontainerproperties, ContainerAccess containeraccess) { super(Containers.BEACON, i); -- this.beacon = new InventorySubcontainer(this, 1) { + player = (PlayerInventory) iinventory; // CraftBukkit - TODO: check this -+ this.beacon = new InventorySubcontainer(1) { // CraftBukkit - decompile error + this.beacon = new InventorySubcontainer(1) { @Override public boolean canPlaceItem(int j, ItemStack itemstack) { - return itemstack.is(TagsItem.BEACON_PAYMENT_ITEMS); @@ -69,6 +79,7 @@ @Override diff --git a/nms-patches/net/minecraft/world/inventory/ContainerCartography.patch b/nms-patches/net/minecraft/world/inventory/ContainerCartography.patch index 3872eb8c6..c2f2258d0 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerCartography.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerCartography.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerCartography.java +++ b/net/minecraft/world/inventory/ContainerCartography.java -@@ -14,8 +14,30 @@ +@@ -15,8 +15,30 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.saveddata.maps.WorldMap; @@ -31,7 +31,7 @@ public static final int MAP_SLOT = 0; public static final int ADDITIONAL_SLOT = 1; public static final int RESULT_SLOT = 2; -@@ -40,6 +62,13 @@ +@@ -41,6 +63,13 @@ ContainerCartography.this.slotsChanged(this); super.setChanged(); } @@ -45,7 +45,7 @@ }; this.resultContainer = new InventoryCraftResult() { @Override -@@ -47,15 +76,22 @@ +@@ -48,6 +77,13 @@ ContainerCartography.this.slotsChanged(this); super.setChanged(); } @@ -58,19 +58,8 @@ + // CraftBukkit end }; this.access = containeraccess; -- this.addSlot(new Slot(this, this.container, 0, 15, 15) { -+ this.addSlot(new Slot(this.container, 0, 15, 15) { // CraftBukkit - decompile error - @Override - public boolean mayPlace(ItemStack itemstack) { - return itemstack.has(DataComponents.MAP_ID); - } - }); -- this.addSlot(new Slot(this, this.container, 1, 15, 52) { -+ this.addSlot(new Slot(this.container, 1, 15, 52) { // CraftBukkit - decompile error - @Override - public boolean mayPlace(ItemStack itemstack) { - return itemstack.is(Items.PAPER) || itemstack.is(Items.MAP) || itemstack.is(Items.GLASS_PANE); -@@ -85,10 +121,12 @@ + this.addSlot(new Slot(this.container, 0, 15, 15) { +@@ -86,10 +122,12 @@ } }); this.addStandardInventorySlots(playerinventory, 8, 84); diff --git a/nms-patches/net/minecraft/world/inventory/ContainerChest.patch b/nms-patches/net/minecraft/world/inventory/ContainerChest.patch index 71d40414a..aee9ee3fd 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerChest.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerChest.patch @@ -55,7 +55,7 @@ + // CraftBukkit start - Save player + this.player = playerinventory; + // CraftBukkit end - boolean flag = true; + int k = 18; this.addChestGrid(iinventory, 8, 18); @@ -72,6 +110,7 @@ diff --git a/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch b/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch index 1b0156011..d57d3a8e2 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch @@ -45,22 +45,6 @@ }; this.random = RandomSource.create(); this.enchantmentSeed = ContainerProperty.standalone(); -@@ -60,13 +84,13 @@ - this.enchantClue = new int[]{-1, -1, -1}; - this.levelClue = new int[]{-1, -1, -1}; - this.access = containeraccess; -- this.addSlot(new Slot(this, this.enchantSlots, 0, 15, 47) { -+ this.addSlot(new Slot(this.enchantSlots, 0, 15, 47) { // CraftBukkit - decompile error - @Override - public int getMaxStackSize() { - return 1; - } - }); -- this.addSlot(new Slot(this, this.enchantSlots, 1, 35, 47) { -+ this.addSlot(new Slot(this.enchantSlots, 1, 35, 47) { // CraftBukkit - decompile error - @Override - public boolean mayPlace(ItemStack itemstack) { - return itemstack.is(Items.LAPIS_LAZULI); @@ -88,6 +112,9 @@ this.addDataSlot(ContainerProperty.shared(this.levelClue, 0)); this.addDataSlot(ContainerProperty.shared(this.levelClue, 1)); @@ -80,14 +64,14 @@ this.access.execute((world, blockposition) -> { Registry> registry = world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); int i = 0; -@@ -135,6 +162,41 @@ +@@ -130,6 +157,41 @@ } } + // CraftBukkit start + CraftItemStack item = CraftItemStack.asCraftMirror(itemstack); + org.bukkit.enchantments.EnchantmentOffer[] offers = new EnchantmentOffer[3]; -+ for (j = 0; j < 3; ++j) { ++ for (int j = 0; j < 3; ++j) { + org.bukkit.enchantments.Enchantment enchantment = (this.enchantClue[j] >= 0) ? CraftEnchantment.minecraftHolderToBukkit(registry.byId(this.enchantClue[j])) : null; + offers[j] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.levelClue[j], this.costs[j]) : null; + } @@ -97,7 +81,7 @@ + world.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { -+ for (j = 0; j < 3; ++j) { ++ for (int j = 0; j < 3; ++j) { + this.costs[j] = 0; + this.enchantClue[j] = -1; + this.levelClue[j] = -1; @@ -105,7 +89,7 @@ + return; + } + -+ for (j = 0; j < 3; j++) { ++ for (int j = 0; j < 3; j++) { + EnchantmentOffer offer = event.getOffers()[j]; + if (offer != null) { + this.costs[j] = offer.getCost(); @@ -122,7 +106,7 @@ this.broadcastChanges(); }); } else { -@@ -162,21 +224,46 @@ +@@ -157,17 +219,46 @@ ItemStack itemstack2 = itemstack; List list = this.getEnchantmentList(world.registryAccess(), itemstack, i, this.costs[i]); @@ -134,7 +118,7 @@ + // entityhuman.onEnchantmentPerformed(itemstack, j); // Moved down + Map enchants = new java.util.HashMap(); + for (WeightedRandomEnchant instance : list) { -+ enchants.put(CraftEnchantment.minecraftHolderToBukkit(instance.enchantment), instance.level); ++ enchants.put(CraftEnchantment.minecraftHolderToBukkit(instance.enchantment()), instance.level()); + } + CraftItemStack item = CraftItemStack.asCraftMirror(itemstack2); + @@ -153,19 +137,16 @@ this.enchantSlots.setItem(0, itemstack2); } -- Iterator iterator = list.iterator(); -- -- while (iterator.hasNext()) { -- WeightedRandomEnchant weightedrandomenchant = (WeightedRandomEnchant) iterator.next(); +- for (WeightedRandomEnchant weightedrandomenchant : list) { + // CraftBukkit start + for (Map.Entry entry : event.getEnchantsToAdd().entrySet()) { + Holder nms = CraftEnchantment.bukkitToMinecraftHolder(entry.getKey()); + if (nms == null) { + continue; + } - ++ + WeightedRandomEnchant weightedrandomenchant = new WeightedRandomEnchant(nms, entry.getValue()); - itemstack2.enchant(weightedrandomenchant.enchantment, weightedrandomenchant.level); + itemstack2.enchant(weightedrandomenchant.enchantment(), weightedrandomenchant.level()); } + entityhuman.onEnchantmentPerformed(itemstack, j); @@ -175,7 +156,7 @@ itemstack1.consume(j, entityhuman); if (itemstack1.isEmpty()) { this.enchantSlots.setItem(1, ItemStack.EMPTY); -@@ -243,6 +330,7 @@ +@@ -234,6 +325,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { @@ -183,7 +164,7 @@ return stillValid(this.access, entityhuman, Blocks.ENCHANTING_TABLE); } -@@ -293,4 +381,17 @@ +@@ -284,4 +376,17 @@ return itemstack; } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch b/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch index 2ad13b214..cc01e45d0 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerGrindstone.java +++ b/net/minecraft/world/inventory/ContainerGrindstone.java -@@ -20,8 +20,30 @@ +@@ -19,8 +19,30 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.phys.Vec3D; @@ -31,7 +31,7 @@ public static final int MAX_NAME_LENGTH = 35; public static final int INPUT_SLOT = 0; public static final int ADDITIONAL_SLOT = 1; -@@ -47,15 +69,22 @@ +@@ -46,6 +68,13 @@ super.setChanged(); ContainerGrindstone.this.slotsChanged(this); } @@ -44,19 +44,8 @@ + // CraftBukkit end }; this.access = containeraccess; -- this.addSlot(new Slot(this, this.repairSlots, 0, 49, 19) { -+ this.addSlot(new Slot(this.repairSlots, 0, 49, 19) { // CraftBukkit - decompile error - @Override - public boolean mayPlace(ItemStack itemstack) { - return itemstack.isDamageableItem() || EnchantmentManager.hasAnyEnchantments(itemstack); - } - }); -- this.addSlot(new Slot(this, this.repairSlots, 1, 49, 40) { -+ this.addSlot(new Slot(this.repairSlots, 1, 49, 40) { // CraftBukkit - decompile error - @Override - public boolean mayPlace(ItemStack itemstack) { - return itemstack.isDamageableItem() || EnchantmentManager.hasAnyEnchantments(itemstack); -@@ -113,6 +142,7 @@ + this.addSlot(new Slot(this.repairSlots, 0, 49, 19) { +@@ -110,6 +139,7 @@ } }); this.addStandardInventorySlots(playerinventory, 8, 84); @@ -64,7 +53,7 @@ } @Override -@@ -125,7 +155,8 @@ +@@ -122,7 +152,8 @@ } private void createResult() { @@ -74,7 +63,7 @@ this.broadcastChanges(); } -@@ -227,6 +258,7 @@ +@@ -222,6 +253,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch b/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch index 9113652d4..89b2884be 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/ContainerHorse.java +++ b/net/minecraft/world/inventory/ContainerHorse.java @@ -11,6 +11,11 @@ + import net.minecraft.world.entity.player.PlayerInventory; import net.minecraft.world.item.ItemStack; - import net.minecraft.world.item.Items; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftInventoryView; @@ -11,8 +11,8 @@ + public class ContainerHorse extends Container { - static final MinecraftKey SADDLE_SLOT_SPRITE = MinecraftKey.withDefaultNamespace("container/slot/saddle"); -@@ -22,13 +27,28 @@ + private static final MinecraftKey SADDLE_SLOT_SPRITE = MinecraftKey.withDefaultNamespace("container/slot/saddle"); +@@ -22,8 +27,23 @@ private static final int SLOT_BODY_ARMOR = 1; private static final int SLOT_HORSE_INVENTORY_START = 2; @@ -34,20 +34,5 @@ + player = playerinventory; + // CraftBukkit end this.horseContainer = iinventory; - this.armorContainer = entityhorseabstract.getBodyArmorAccess(); this.horse = entityhorseabstract; iinventory.startOpen(playerinventory.player); -- this.addSlot(new Slot(this, iinventory, 0, 8, 18) { -+ this.addSlot(new Slot(iinventory, 0, 8, 18) { // CraftBukkit - decompile error - @Override - public boolean mayPlace(ItemStack itemstack) { - return itemstack.is(Items.SADDLE) && !this.hasItem() && entityhorseabstract.isSaddleable(); -@@ -46,7 +66,7 @@ - }); - MinecraftKey minecraftkey = entityhorseabstract instanceof EntityLlama ? ContainerHorse.LLAMA_ARMOR_SLOT_SPRITE : ContainerHorse.ARMOR_SLOT_SPRITE; - -- this.addSlot(new ArmorSlot(this, this.armorContainer, entityhorseabstract, EnumItemSlot.BODY, 0, 8, 36, minecraftkey) { -+ this.addSlot(new ArmorSlot(this.armorContainer, entityhorseabstract, EnumItemSlot.BODY, 0, 8, 36, minecraftkey) { // CraftBukkit - decompile error - @Override - public boolean mayPlace(ItemStack itemstack) { - return entityhorseabstract.isEquippableInSlot(itemstack, EnumItemSlot.BODY); diff --git a/nms-patches/net/minecraft/world/inventory/ContainerLectern.patch b/nms-patches/net/minecraft/world/inventory/ContainerLectern.patch index 5c2cf6b85..91f3247c4 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerLectern.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerLectern.patch @@ -59,7 +59,7 @@ } @Override -@@ -59,6 +87,13 @@ +@@ -60,6 +88,13 @@ return false; } @@ -73,7 +73,7 @@ ItemStack itemstack = this.lectern.removeItemNoUpdate(0); this.lectern.setChanged(); -@@ -86,6 +121,8 @@ +@@ -87,6 +122,8 @@ @Override public boolean stillValid(EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/inventory/ContainerLoom.patch b/nms-patches/net/minecraft/world/inventory/ContainerLoom.patch index ff61f6da0..cd661b9f1 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerLoom.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerLoom.patch @@ -45,7 +45,7 @@ }; this.outputContainer = new InventorySubcontainer(1) { @Override -@@ -67,21 +96,28 @@ +@@ -67,6 +96,13 @@ super.setChanged(); ContainerLoom.this.slotUpdateListener.run(); } @@ -58,25 +58,7 @@ + // CraftBukkit end }; this.access = containeraccess; -- this.bannerSlot = this.addSlot(new Slot(this, this.inputContainer, 0, 13, 26) { -+ this.bannerSlot = this.addSlot(new Slot(this.inputContainer, 0, 13, 26) { // CraftBukkit - decompile error - @Override - public boolean mayPlace(ItemStack itemstack) { - return itemstack.getItem() instanceof ItemBanner; - } - }); -- this.dyeSlot = this.addSlot(new Slot(this, this.inputContainer, 1, 33, 26) { -+ this.dyeSlot = this.addSlot(new Slot(this.inputContainer, 1, 33, 26) { // CraftBukkit - decompile error - @Override - public boolean mayPlace(ItemStack itemstack) { - return itemstack.getItem() instanceof ItemDye; - } - }); -- this.patternSlot = this.addSlot(new Slot(this, this.inputContainer, 2, 23, 45) { -+ this.patternSlot = this.addSlot(new Slot(this.inputContainer, 2, 23, 45) { // CraftBukkit - decompile error - @Override - public boolean mayPlace(ItemStack itemstack) { - return itemstack.getItem() instanceof ItemBannerPattern; + this.bannerSlot = this.addSlot(new Slot(this.inputContainer, 0, 13, 26) { @@ -116,10 +152,12 @@ this.addStandardInventorySlots(playerinventory, 8, 84); this.addDataSlot(this.selectedBannerPatternIndex); @@ -90,7 +72,7 @@ return stillValid(this.access, entityhuman, Blocks.LOOM); } -@@ -294,6 +332,11 @@ +@@ -288,6 +326,11 @@ EnumColor enumcolor = ((ItemDye) itemstack1.getItem()).getDyeColor(); itemstack2.update(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY, (bannerpatternlayers) -> { diff --git a/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch b/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch index 35cd2ec5b..d1aa31fd9 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch @@ -30,15 +30,6 @@ this.active = flag; this.owner = entityhuman; this.addResultSlot(entityhuman, 154, 28); -@@ -54,7 +66,7 @@ - } - - this.addStandardInventorySlots(playerinventory, 8, 84); -- this.addSlot(new Slot(this, playerinventory, 40, 77, 62) { -+ this.addSlot(new Slot(playerinventory, 40, 77, 62) { // CraftBukkit - decompile error - @Override - public void setByPlayer(ItemStack itemstack, ItemStack itemstack1) { - entityhuman.onEquipItem(EnumItemSlot.OFFHAND, itemstack1, itemstack); @@ -190,4 +202,17 @@ protected EntityHuman owner() { return this.owner; diff --git a/nms-patches/net/minecraft/world/inventory/ContainerShulkerBox.patch b/nms-patches/net/minecraft/world/inventory/ContainerShulkerBox.patch index ca5c50ae9..3890d6b09 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerShulkerBox.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerShulkerBox.patch @@ -43,8 +43,8 @@ - iinventory.startOpen(playerinventory.player); + this.player = playerinventory; // CraftBukkit - save player + // iinventory.startOpen(playerinventory.player); // CraftBukkit - don't startOpen until menu actually opens - boolean flag = true; - boolean flag1 = true; + int j = 3; + int k = 9; @@ -34,6 +60,7 @@ diff --git a/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch b/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch index 39be79fce..74dca3e39 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch @@ -19,15 +19,6 @@ public ContainerSmithing(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); -@@ -117,7 +122,7 @@ - public void createResult() { - SmithingRecipeInput smithingrecipeinput = this.createRecipeInput(); - World world = this.level; -- Optional optional; -+ Optional> optional; // CraftBukkit - decompile error - - if (world instanceof WorldServer worldserver) { - optional = worldserver.recipeAccess().getRecipeFor(Recipes.SMITHING, smithingrecipeinput, worldserver); @@ -129,7 +134,9 @@ ItemStack itemstack = ((SmithingRecipe) recipeholder.value()).assemble(smithingrecipeinput, this.level.registryAccess()); diff --git a/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch b/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch index 88d269485..5eff9cc31 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerStonecutter.java +++ b/net/minecraft/world/inventory/ContainerStonecutter.java -@@ -17,6 +17,13 @@ +@@ -18,6 +18,13 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.block.Blocks; @@ -14,7 +14,7 @@ public class ContainerStonecutter extends Container { public static final int INPUT_SLOT = 0; -@@ -36,6 +43,21 @@ +@@ -37,6 +44,21 @@ Runnable slotUpdateListener; public final IInventory container; final InventoryCraftResult resultContainer; @@ -36,7 +36,7 @@ public ContainerStonecutter(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); -@@ -55,6 +77,13 @@ +@@ -56,6 +78,13 @@ ContainerStonecutter.this.slotsChanged(this); ContainerStonecutter.this.slotUpdateListener.run(); } @@ -50,7 +50,7 @@ }; this.resultContainer = new InventoryCraftResult(); this.access = containeraccess; -@@ -94,6 +123,7 @@ +@@ -95,6 +124,7 @@ }); this.addStandardInventorySlots(playerinventory, 8, 84); this.addDataSlot(this.selectedRecipeIndex); @@ -58,7 +58,7 @@ } public int getSelectedRecipeIndex() { -@@ -114,6 +144,7 @@ +@@ -115,6 +145,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { @@ -66,12 +66,3 @@ return stillValid(this.access, entityhuman, Blocks.STONECUTTER); } -@@ -158,7 +189,7 @@ - } - - void setupResultSlot(int i) { -- Optional optional; -+ Optional> optional; // CraftBukkit - decompile error - - if (!this.recipesForInput.isEmpty() && this.isValidRecipeIndex(i)) { - SelectableRecipe.a selectablerecipe_a = (SelectableRecipe.a) this.recipesForInput.entries().get(i); diff --git a/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch b/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch index ccbef3da8..ba3938d18 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch @@ -54,7 +54,7 @@ return stillValid(this.access, entityhuman, Blocks.CRAFTING_TABLE); } -@@ -181,4 +192,17 @@ +@@ -179,4 +190,17 @@ protected EntityHuman owner() { return this.player; } diff --git a/nms-patches/net/minecraft/world/inventory/Containers.patch b/nms-patches/net/minecraft/world/inventory/Containers.patch index 0febcbd23..9d6e8324b 100644 --- a/nms-patches/net/minecraft/world/inventory/Containers.patch +++ b/nms-patches/net/minecraft/world/inventory/Containers.patch @@ -20,3 +20,17 @@ }); public static final Containers LOOM = register("loom", ContainerLoom::new); public static final Containers MERCHANT = register("merchant", ContainerMerchant::new); +@@ -41,11 +45,11 @@ + private final Containers.Supplier constructor; + + private static Containers register(String s, Containers.Supplier containers_supplier) { +- return (Containers) IRegistry.register(BuiltInRegistries.MENU, s, new Containers(containers_supplier, FeatureFlags.VANILLA_SET)); ++ return (Containers) IRegistry.register(BuiltInRegistries.MENU, s, new Containers<>(containers_supplier, FeatureFlags.VANILLA_SET)); // CraftBukkit - decompile error + } + + private static Containers register(String s, Containers.Supplier containers_supplier, FeatureFlag... afeatureflag) { +- return (Containers) IRegistry.register(BuiltInRegistries.MENU, s, new Containers(containers_supplier, FeatureFlags.REGISTRY.subset(afeatureflag))); ++ return (Containers) IRegistry.register(BuiltInRegistries.MENU, s, new Containers<>(containers_supplier, FeatureFlags.REGISTRY.subset(afeatureflag))); // CraftBukkit - decompile error + } + + private Containers(Containers.Supplier containers_supplier, FeatureFlagSet featureflagset) { diff --git a/nms-patches/net/minecraft/world/inventory/InventoryCraftResult.patch b/nms-patches/net/minecraft/world/inventory/InventoryCraftResult.patch index 8b0b0e954..f9efc22f1 100644 --- a/nms-patches/net/minecraft/world/inventory/InventoryCraftResult.patch +++ b/nms-patches/net/minecraft/world/inventory/InventoryCraftResult.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/InventoryCraftResult.java +++ b/net/minecraft/world/inventory/InventoryCraftResult.java -@@ -9,12 +9,51 @@ +@@ -8,12 +8,51 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeHolder; @@ -50,5 +50,5 @@ + // CraftBukkit end + public InventoryCraftResult() { - this.itemStacks = NonNullList.withSize(1, ItemStack.EMPTY); + this.itemStacks = NonNullList.withSize(1, ItemStack.EMPTY); } diff --git a/nms-patches/net/minecraft/world/inventory/InventoryMerchant.patch b/nms-patches/net/minecraft/world/inventory/InventoryMerchant.patch index a2dec8965..d836d7e47 100644 --- a/nms-patches/net/minecraft/world/inventory/InventoryMerchant.patch +++ b/nms-patches/net/minecraft/world/inventory/InventoryMerchant.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/InventoryMerchant.java +++ b/net/minecraft/world/inventory/InventoryMerchant.java -@@ -11,6 +11,16 @@ +@@ -10,6 +10,16 @@ import net.minecraft.world.item.trading.MerchantRecipe; import net.minecraft.world.item.trading.MerchantRecipeList; @@ -17,7 +17,7 @@ public class InventoryMerchant implements IInventory { private final IMerchant merchant; -@@ -20,6 +30,46 @@ +@@ -19,6 +29,46 @@ public int selectionHint; private int futureXp; @@ -62,5 +62,5 @@ + // CraftBukkit end + public InventoryMerchant(IMerchant imerchant) { - this.itemStacks = NonNullList.withSize(3, ItemStack.EMPTY); + this.itemStacks = NonNullList.withSize(3, ItemStack.EMPTY); this.merchant = imerchant; diff --git a/nms-patches/net/minecraft/world/inventory/TransientCraftingContainer.patch b/nms-patches/net/minecraft/world/inventory/TransientCraftingContainer.patch index 7c539ac59..c6735a826 100644 --- a/nms-patches/net/minecraft/world/inventory/TransientCraftingContainer.patch +++ b/nms-patches/net/minecraft/world/inventory/TransientCraftingContainer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/TransientCraftingContainer.java +++ b/net/minecraft/world/inventory/TransientCraftingContainer.java -@@ -8,6 +8,16 @@ +@@ -7,6 +7,16 @@ import net.minecraft.world.entity.player.StackedItemContents; import net.minecraft.world.item.ItemStack; @@ -17,7 +17,7 @@ public class TransientCraftingContainer implements InventoryCrafting { private final NonNullList items; -@@ -15,6 +25,68 @@ +@@ -14,6 +24,68 @@ private final int height; private final Container menu; diff --git a/nms-patches/net/minecraft/world/item/ItemArmorStand.patch b/nms-patches/net/minecraft/world/item/ItemArmorStand.patch index 6069029c1..66d8ea906 100644 --- a/nms-patches/net/minecraft/world/item/ItemArmorStand.patch +++ b/nms-patches/net/minecraft/world/item/ItemArmorStand.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/item/ItemArmorStand.java +++ b/net/minecraft/world/item/ItemArmorStand.java -@@ -53,6 +53,11 @@ +@@ -52,6 +52,11 @@ float f = (float) MathHelper.floor((MathHelper.wrapDegrees(itemactioncontext.getRotation() - 180.0F) + 22.5F) / 45.0F) * 45.0F; - entityarmorstand.moveTo(entityarmorstand.getX(), entityarmorstand.getY(), entityarmorstand.getZ(), f, 0.0F); + entityarmorstand.snapTo(entityarmorstand.getX(), entityarmorstand.getY(), entityarmorstand.getZ(), f, 0.0F); + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(itemactioncontext, entityarmorstand).isCancelled()) { + return EnumInteractionResult.FAIL; + } + // CraftBukkit end worldserver.addFreshEntityWithPassengers(entityarmorstand); - world.playSound((EntityHuman) null, entityarmorstand.getX(), entityarmorstand.getY(), entityarmorstand.getZ(), SoundEffects.ARMOR_STAND_PLACE, SoundCategory.BLOCKS, 0.75F, 0.8F); + world.playSound((Entity) null, entityarmorstand.getX(), entityarmorstand.getY(), entityarmorstand.getZ(), SoundEffects.ARMOR_STAND_PLACE, SoundCategory.BLOCKS, 0.75F, 0.8F); entityarmorstand.gameEvent(GameEvent.ENTITY_PLACE, itemactioncontext.getPlayer()); diff --git a/nms-patches/net/minecraft/world/item/ItemBlock.patch b/nms-patches/net/minecraft/world/item/ItemBlock.patch index 966952394..4cff38c01 100644 --- a/nms-patches/net/minecraft/world/item/ItemBlock.patch +++ b/nms-patches/net/minecraft/world/item/ItemBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemBlock.java +++ b/net/minecraft/world/item/ItemBlock.java -@@ -32,6 +32,13 @@ +@@ -29,6 +29,13 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -14,7 +14,7 @@ public class ItemBlock extends Item { /** @deprecated */ -@@ -62,6 +69,12 @@ +@@ -59,6 +66,12 @@ return EnumInteractionResult.FAIL; } else { IBlockData iblockdata = this.getPlacementState(blockactioncontext1); @@ -27,7 +27,7 @@ if (iblockdata == null) { return EnumInteractionResult.FAIL; -@@ -79,6 +92,19 @@ +@@ -76,6 +89,19 @@ this.updateCustomBlockEntityTag(blockposition, world, entityhuman, itemstack, iblockdata1); updateBlockEntityComponents(world, blockposition, itemstack); iblockdata1.getBlock().setPlacedBy(world, blockposition, iblockdata1, entityhuman, itemstack); @@ -47,24 +47,24 @@ if (entityhuman instanceof EntityPlayer) { CriterionTriggers.PLACED_BLOCK.trigger((EntityPlayer) entityhuman, blockposition, itemstack); } -@@ -86,7 +112,7 @@ +@@ -83,7 +109,7 @@ SoundEffectType soundeffecttype = iblockdata1.getSoundType(); - world.playSound(entityhuman, blockposition, this.getPlaceSound(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); + // world.playSound(entityhuman, blockposition, this.getPlaceSound(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); - world.gameEvent((Holder) GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(entityhuman, iblockdata1)); + world.gameEvent(GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(entityhuman, iblockdata1)); itemstack.consume(1, entityhuman); return EnumInteractionResult.SUCCESS; -@@ -144,8 +170,15 @@ +@@ -141,7 +167,15 @@ protected boolean canPlace(BlockActionContext blockactioncontext, IBlockData iblockdata) { EntityHuman entityhuman = blockactioncontext.getPlayer(); - VoxelShapeCollision voxelshapecollision = entityhuman == null ? VoxelShapeCollision.empty() : VoxelShapeCollision.of(entityhuman); -+ // CraftBukkit start - store default return -+ boolean defaultReturn = (!this.mustSurvive() || iblockdata.canSurvive(blockactioncontext.getLevel(), blockactioncontext.getClickedPos())) && blockactioncontext.getLevel().isUnobstructed(iblockdata, blockactioncontext.getClickedPos(), voxelshapecollision); -+ org.bukkit.entity.Player player = (blockactioncontext.getPlayer() instanceof EntityPlayer) ? (org.bukkit.entity.Player) blockactioncontext.getPlayer().getBukkitEntity() : null; -- return (!this.mustSurvive() || iblockdata.canSurvive(blockactioncontext.getLevel(), blockactioncontext.getClickedPos())) && blockactioncontext.getLevel().isUnobstructed(iblockdata, blockactioncontext.getClickedPos(), voxelshapecollision); +- return (!this.mustSurvive() || iblockdata.canSurvive(blockactioncontext.getLevel(), blockactioncontext.getClickedPos())) && blockactioncontext.getLevel().isUnobstructed(iblockdata, blockactioncontext.getClickedPos(), VoxelShapeCollision.placementContext(entityhuman)); ++ // CraftBukkit start - store default return ++ boolean defaultReturn = (!this.mustSurvive() || iblockdata.canSurvive(blockactioncontext.getLevel(), blockactioncontext.getClickedPos())) && blockactioncontext.getLevel().isUnobstructed(iblockdata, blockactioncontext.getClickedPos(), VoxelShapeCollision.placementContext(entityhuman)); ++ org.bukkit.entity.Player player = (blockactioncontext.getPlayer() instanceof EntityPlayer) ? (org.bukkit.entity.Player) blockactioncontext.getPlayer().getBukkitEntity() : null; ++ + BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(blockactioncontext.getLevel(), blockactioncontext.getClickedPos()), player, CraftBlockData.fromData(iblockdata), defaultReturn); + blockactioncontext.getLevel().getCraftServer().getPluginManager().callEvent(event); + diff --git a/nms-patches/net/minecraft/world/item/ItemBlockWallable.patch b/nms-patches/net/minecraft/world/item/ItemBlockWallable.patch index f1eec8067..70d6046cf 100644 --- a/nms-patches/net/minecraft/world/item/ItemBlockWallable.patch +++ b/nms-patches/net/minecraft/world/item/ItemBlockWallable.patch @@ -1,29 +1,30 @@ --- a/net/minecraft/world/item/ItemBlockWallable.java +++ b/net/minecraft/world/item/ItemBlockWallable.java -@@ -10,6 +10,12 @@ - import net.minecraft.world.level.block.Block; +@@ -10,6 +10,13 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.shapes.VoxelShapeCollision; + +// CraftBukkit start +import net.minecraft.server.level.EntityPlayer; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.event.block.BlockCanBuildEvent; +// CraftBukkit end - ++ public class ItemBlockWallable extends ItemBlock { -@@ -49,7 +55,19 @@ + public final Block wallBlock; +@@ -44,7 +51,19 @@ } } -- return iblockdata1 != null && world.isUnobstructed(iblockdata1, blockposition, VoxelShapeCollision.empty()) ? iblockdata1 : null; +- return iblockdata1 != null && iworldreader.isUnobstructed(iblockdata1, blockposition, VoxelShapeCollision.empty()) ? iblockdata1 : null; + // CraftBukkit start + if (iblockdata1 != null) { -+ boolean defaultReturn = world.isUnobstructed(iblockdata1, blockposition, VoxelShapeCollision.empty()); ++ boolean defaultReturn = iworldreader.isUnobstructed(iblockdata1, blockposition, VoxelShapeCollision.empty()); + org.bukkit.entity.Player player = (blockactioncontext.getPlayer() instanceof EntityPlayer) ? (org.bukkit.entity.Player) blockactioncontext.getPlayer().getBukkitEntity() : null; + -+ BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(world, blockposition), player, CraftBlockData.fromData(iblockdata1), defaultReturn); ++ BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(blockactioncontext.getLevel(), blockposition), player, CraftBlockData.fromData(iblockdata1), defaultReturn); + blockactioncontext.getLevel().getCraftServer().getPluginManager().callEvent(event); + + return (event.isBuildable()) ? iblockdata1 : null; diff --git a/nms-patches/net/minecraft/world/item/ItemBoat.patch b/nms-patches/net/minecraft/world/item/ItemBoat.patch index 5ab0387a0..2d84d15dc 100644 --- a/nms-patches/net/minecraft/world/item/ItemBoat.patch +++ b/nms-patches/net/minecraft/world/item/ItemBoat.patch @@ -1,26 +1,46 @@ --- a/net/minecraft/world/item/ItemBoat.java +++ b/net/minecraft/world/item/ItemBoat.java -@@ -58,6 +58,13 @@ +@@ -20,6 +20,10 @@ + import net.minecraft.world.phys.MovingObjectPosition; + import net.minecraft.world.phys.Vec3D; + ++// CraftBukkit start ++import net.minecraft.world.phys.MovingObjectPositionBlock; ++// CraftBukkit end ++ + public class ItemBoat extends Item { + + private final EntityTypes entityType; +@@ -32,7 +36,7 @@ + @Override + public EnumInteractionResult use(World world, EntityHuman entityhuman, EnumHand enumhand) { + ItemStack itemstack = entityhuman.getItemInHand(enumhand); +- MovingObjectPosition movingobjectposition = getPlayerPOVHitResult(world, entityhuman, RayTrace.FluidCollisionOption.ANY); ++ MovingObjectPositionBlock movingobjectposition = getPlayerPOVHitResult(world, entityhuman, RayTrace.FluidCollisionOption.ANY); // CraftBukkit + + if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.MISS) { + return EnumInteractionResult.PASS; +@@ -54,6 +58,13 @@ } - if (movingobjectpositionblock.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) { + if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) { + // CraftBukkit start - Boat placement -+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(entityhuman, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), itemstack, false, enumhand, movingobjectpositionblock.getLocation()); ++ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(entityhuman, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, movingobjectposition.getBlockPos(), movingobjectposition.getDirection(), itemstack, false, enumhand, movingobjectposition.getLocation()); + + if (event.isCancelled()) { + return EnumInteractionResult.PASS; + } + // CraftBukkit end - AbstractBoat abstractboat = this.getBoat(world, movingobjectpositionblock, itemstack, entityhuman); + AbstractBoat abstractboat = this.getBoat(world, movingobjectposition, itemstack, entityhuman); if (abstractboat == null) { -@@ -68,7 +75,15 @@ +@@ -64,7 +75,15 @@ return EnumInteractionResult.FAIL; } else { if (!world.isClientSide) { - world.addFreshEntity(abstractboat); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(world, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), entityhuman, abstractboat, enumhand).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(world, movingobjectposition.getBlockPos(), movingobjectposition.getDirection(), entityhuman, abstractboat, enumhand).isCancelled()) { + return EnumInteractionResult.FAIL; + } + @@ -28,6 +48,6 @@ + return EnumInteractionResult.PASS; + } + // CraftBukkit end - world.gameEvent((Entity) entityhuman, (Holder) GameEvent.ENTITY_PLACE, movingobjectpositionblock.getLocation()); + world.gameEvent(entityhuman, (Holder) GameEvent.ENTITY_PLACE, movingobjectposition.getLocation()); itemstack.consume(1, entityhuman); } diff --git a/nms-patches/net/minecraft/world/item/ItemBucket.patch b/nms-patches/net/minecraft/world/item/ItemBucket.patch index 63994725b..ef98bb208 100644 --- a/nms-patches/net/minecraft/world/item/ItemBucket.patch +++ b/nms-patches/net/minecraft/world/item/ItemBucket.patch @@ -17,7 +17,7 @@ public class ItemBucket extends Item implements DispensibleContainerItem { public final FluidType content; -@@ -63,6 +73,17 @@ +@@ -60,6 +70,17 @@ if (block instanceof IFluidSource) { IFluidSource ifluidsource = (IFluidSource) block; @@ -32,57 +32,63 @@ + return EnumInteractionResult.FAIL; + } + // CraftBukkit end + ItemStack itemstack1 = ifluidsource.pickupBlock(entityhuman, world, blockposition, iblockdata); - itemstack1 = ifluidsource.pickupBlock(entityhuman, world, blockposition, iblockdata); if (!itemstack1.isEmpty()) { -@@ -71,7 +92,7 @@ +@@ -68,7 +89,7 @@ entityhuman.playSound(soundeffect, 1.0F, 1.0F); }); - world.gameEvent((Entity) entityhuman, (Holder) GameEvent.FLUID_PICKUP, blockposition); + world.gameEvent(entityhuman, (Holder) GameEvent.FLUID_PICKUP, blockposition); - ItemStack itemstack2 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1); + ItemStack itemstack2 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit if (!world.isClientSide) { CriterionTriggers.FILLED_BUCKET.trigger((EntityPlayer) entityhuman, itemstack1); -@@ -86,7 +107,7 @@ - iblockdata = world.getBlockState(blockposition); - BlockPosition blockposition2 = iblockdata.getBlock() instanceof IFluidContainer && this.content == FluidTypes.WATER ? blockposition : blockposition1; +@@ -83,7 +104,7 @@ + IBlockData iblockdata1 = world.getBlockState(blockposition); + BlockPosition blockposition2 = iblockdata1.getBlock() instanceof IFluidContainer && this.content == FluidTypes.WATER ? blockposition : blockposition1; - if (this.emptyContents(entityhuman, world, blockposition2, movingobjectpositionblock)) { + if (this.emptyContents(entityhuman, world, blockposition2, movingobjectpositionblock, movingobjectpositionblock.getDirection(), blockposition, itemstack, enumhand)) { // CraftBukkit this.checkExtraContent(entityhuman, world, itemstack, blockposition2); if (entityhuman instanceof EntityPlayer) { CriterionTriggers.PLACED_BLOCK.trigger((EntityPlayer) entityhuman, blockposition2, itemstack); -@@ -114,6 +135,12 @@ +@@ -112,11 +133,18 @@ @Override - public boolean emptyContents(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock) { + public boolean emptyContents(@Nullable EntityLiving entityliving, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock) { + // CraftBukkit start -+ return emptyContents(entityhuman, world, blockposition, movingobjectpositionblock, null, null, null, EnumHand.MAIN_HAND); ++ return emptyContents(entityliving, world, blockposition, movingobjectpositionblock, null, null, null, EnumHand.MAIN_HAND); + } + -+ public boolean emptyContents(EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock, EnumDirection enumdirection, BlockPosition clicked, ItemStack itemstack, EnumHand enumhand) { ++ public boolean emptyContents(@Nullable EntityLiving entityliving, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock, EnumDirection enumdirection, BlockPosition clicked, ItemStack itemstack, EnumHand enumhand) { + // CraftBukkit end FluidType fluidtype = this.content; if (!(fluidtype instanceof FluidTypeFlowing fluidtypeflowing)) { -@@ -149,8 +176,18 @@ + return false; + } else { ++ IBlockData iblockdata; // CraftBukkit - decompile error + Block block; + boolean flag; + boolean flag1; +@@ -146,8 +174,18 @@ boolean flag2 = flag1; + // CraftBukkit start -+ if (flag2 && entityhuman != null) { -+ PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent((WorldServer) world, entityhuman, blockposition, clicked, enumdirection, itemstack, enumhand); ++ if (flag2 && entityliving instanceof EntityPlayer entityplayer) { ++ PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent((WorldServer) world, entityplayer, blockposition, clicked, enumdirection, itemstack, enumhand); + if (event.isCancelled()) { -+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-4238: needed when looking through entity -+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541 ++ entityplayer.connection.send(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-4238: needed when looking through entity ++ entityplayer.getBukkitEntity().updateInventory(); // SPIGOT-4541 + return false; + } + } + // CraftBukkit end if (!flag2) { -- return movingobjectpositionblock != null && this.emptyContents(entityhuman, world, movingobjectpositionblock.getBlockPos().relative(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null); -+ return movingobjectpositionblock != null && this.emptyContents(entityhuman, world, movingobjectpositionblock.getBlockPos().relative(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null, enumdirection, clicked, itemstack, enumhand); // CraftBukkit +- return movingobjectpositionblock != null && this.emptyContents(entityliving, world, movingobjectpositionblock.getBlockPos().relative(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null); ++ return movingobjectpositionblock != null && this.emptyContents(entityliving, world, movingobjectpositionblock.getBlockPos().relative(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null, enumdirection, clicked, itemstack, enumhand); // CraftBukkit } else if (world.dimensionType().ultraWarm() && this.content.is(TagsFluid.WATER)) { int i = blockposition.getX(); int j = blockposition.getY(); diff --git a/nms-patches/net/minecraft/world/item/ItemEgg.patch b/nms-patches/net/minecraft/world/item/ItemEgg.patch index 29a269378..46c458ffd 100644 --- a/nms-patches/net/minecraft/world/item/ItemEgg.patch +++ b/nms-patches/net/minecraft/world/item/ItemEgg.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/item/ItemEgg.java +++ b/net/minecraft/world/item/ItemEgg.java -@@ -25,10 +25,18 @@ +@@ -26,10 +26,18 @@ public EnumInteractionResult use(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.getItemInHand(enumhand); -- world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); -+ // world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down +- world.playSound((Entity) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); ++ // world.playSound((Entity) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down if (world instanceof WorldServer worldserver) { -- IProjectile.spawnProjectileFromRotation(EntityEgg::new, worldserver, itemstack, entityhuman, 0.0F, ItemEgg.PROJECTILE_SHOOT_POWER, 1.0F); +- IProjectile.spawnProjectileFromRotation(EntityEgg::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F); + // CraftBukkit start -+ if (IProjectile.spawnProjectileFromRotation(EntityEgg::new, worldserver, itemstack, entityhuman, 0.0F, ItemEgg.PROJECTILE_SHOOT_POWER, 1.0F).isRemoved()) { ++ if (IProjectile.spawnProjectileFromRotation(EntityEgg::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F).isRemoved()) { + if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { + ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); + } @@ -17,7 +17,7 @@ + } + // CraftBukkit end } -+ world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); ++ world.playSound((Entity) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); entityhuman.awardStat(StatisticList.ITEM_USED.get(this)); itemstack.consume(1, entityhuman); diff --git a/nms-patches/net/minecraft/world/item/ItemEndCrystal.patch b/nms-patches/net/minecraft/world/item/ItemEndCrystal.patch index 0981092fb..149faa090 100644 --- a/nms-patches/net/minecraft/world/item/ItemEndCrystal.patch +++ b/nms-patches/net/minecraft/world/item/ItemEndCrystal.patch @@ -10,5 +10,5 @@ + } + // CraftBukkit end world.addFreshEntity(entityendercrystal); - world.gameEvent((Entity) itemactioncontext.getPlayer(), (Holder) GameEvent.ENTITY_PLACE, blockposition1); + world.gameEvent(itemactioncontext.getPlayer(), (Holder) GameEvent.ENTITY_PLACE, blockposition1); EnderDragonBattle enderdragonbattle = ((WorldServer) world).getDragonFight(); diff --git a/nms-patches/net/minecraft/world/item/ItemEnderEye.patch b/nms-patches/net/minecraft/world/item/ItemEnderEye.patch index 7549f8170..a6e7452ca 100644 --- a/nms-patches/net/minecraft/world/item/ItemEnderEye.patch +++ b/nms-patches/net/minecraft/world/item/ItemEnderEye.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/item/ItemEnderEye.java +++ b/net/minecraft/world/item/ItemEnderEye.java -@@ -99,7 +99,11 @@ +@@ -101,7 +101,11 @@ entityendersignal.setItem(itemstack); entityendersignal.signalTo(blockposition); - world.gameEvent((Holder) GameEvent.PROJECTILE_SHOOT, entityendersignal.position(), GameEvent.a.of((Entity) entityhuman)); + world.gameEvent(GameEvent.PROJECTILE_SHOOT, entityendersignal.position(), GameEvent.a.of((Entity) entityhuman)); - world.addFreshEntity(entityendersignal); + // CraftBukkit start + if (!world.addFreshEntity(entityendersignal)) { diff --git a/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch b/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch index 32f38cf3c..3ddc4435e 100644 --- a/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch +++ b/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/item/ItemEnderPearl.java +++ b/net/minecraft/world/item/ItemEnderPearl.java -@@ -23,10 +23,17 @@ +@@ -24,10 +24,17 @@ public EnumInteractionResult use(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.getItemInHand(enumhand); -- world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); +- world.playSound((Entity) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); if (world instanceof WorldServer worldserver) { - IProjectile.spawnProjectileFromRotation(EntityEnderPearl::new, worldserver, itemstack, entityhuman, 0.0F, ItemEnderPearl.PROJECTILE_SHOOT_POWER, 1.0F); + // CraftBukkit start @@ -15,7 +15,7 @@ + return EnumInteractionResult.FAIL; + } } -+ world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); ++ world.playSound((Entity) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); + // CraftBukkit end entityhuman.awardStat(StatisticList.ITEM_USED.get(this)); diff --git a/nms-patches/net/minecraft/world/item/ItemFireball.patch b/nms-patches/net/minecraft/world/item/ItemFireball.patch index 524413702..8f041afd1 100644 --- a/nms-patches/net/minecraft/world/item/ItemFireball.patch +++ b/nms-patches/net/minecraft/world/item/ItemFireball.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemFireball.java +++ b/net/minecraft/world/item/ItemFireball.java -@@ -40,12 +40,28 @@ +@@ -39,12 +39,28 @@ if (!BlockCampfire.canLight(iblockdata) && !CandleBlock.canLight(iblockdata) && !CandleCakeBlock.canLight(iblockdata)) { blockposition = blockposition.relative(itemactioncontext.getClickedFace()); if (BlockFireAbstract.canBePlacedAt(world, blockposition, itemactioncontext.getHorizontalDirection())) { @@ -14,7 +14,7 @@ + // CraftBukkit end this.playSound(world, blockposition); world.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(world, blockposition)); - world.gameEvent((Entity) itemactioncontext.getPlayer(), (Holder) GameEvent.BLOCK_PLACE, blockposition); + world.gameEvent(itemactioncontext.getPlayer(), (Holder) GameEvent.BLOCK_PLACE, blockposition); flag = true; } } else { @@ -28,4 +28,4 @@ + // CraftBukkit end this.playSound(world, blockposition); world.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(BlockProperties.LIT, true)); - world.gameEvent((Entity) itemactioncontext.getPlayer(), (Holder) GameEvent.BLOCK_CHANGE, blockposition); + world.gameEvent(itemactioncontext.getPlayer(), (Holder) GameEvent.BLOCK_CHANGE, blockposition); diff --git a/nms-patches/net/minecraft/world/item/ItemFishingRod.patch b/nms-patches/net/minecraft/world/item/ItemFishingRod.patch index e75d434c7..306f14ee8 100644 --- a/nms-patches/net/minecraft/world/item/ItemFishingRod.patch +++ b/nms-patches/net/minecraft/world/item/ItemFishingRod.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemFishingRod.java +++ b/net/minecraft/world/item/ItemFishingRod.java -@@ -14,6 +14,11 @@ +@@ -15,6 +15,11 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.gameevent.GameEvent; @@ -12,12 +12,12 @@ public class ItemFishingRod extends Item { public ItemFishingRod(Item.Info item_info) { -@@ -34,13 +39,24 @@ - world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); +@@ -35,13 +40,24 @@ + world.playSound((Entity) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); entityhuman.gameEvent(GameEvent.ITEM_INTERACT_FINISH); } else { -- world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); -+ // world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); +- world.playSound((Entity) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); ++ // world.playSound((Entity) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); if (world instanceof WorldServer) { WorldServer worldserver = (WorldServer) world; int j = (int) (EnchantmentManager.getFishingTimeReduction(worldserver, itemstack, entityhuman) * 20.0F); @@ -33,7 +33,7 @@ + entityhuman.fishing = null; + return EnumInteractionResult.PASS; + } -+ world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); ++ world.playSound((Entity) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); + IProjectile.spawnProjectile(entityfishinghook, worldserver, itemstack); + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/item/ItemFlintAndSteel.patch b/nms-patches/net/minecraft/world/item/ItemFlintAndSteel.patch index 2c7069365..807e16362 100644 --- a/nms-patches/net/minecraft/world/item/ItemFlintAndSteel.patch +++ b/nms-patches/net/minecraft/world/item/ItemFlintAndSteel.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemFlintAndSteel.java +++ b/net/minecraft/world/item/ItemFlintAndSteel.java -@@ -37,6 +37,12 @@ +@@ -36,6 +36,12 @@ BlockPosition blockposition1 = blockposition.relative(itemactioncontext.getClickedFace()); if (BlockFireAbstract.canBePlacedAt(world, blockposition1, itemactioncontext.getHorizontalDirection())) { @@ -13,7 +13,7 @@ world.playSound(entityhuman, blockposition1, SoundEffects.FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, world.getRandom().nextFloat() * 0.4F + 0.8F); IBlockData iblockdata1 = BlockFireAbstract.getState(world, blockposition1); -@@ -54,6 +60,12 @@ +@@ -53,6 +59,12 @@ return EnumInteractionResult.FAIL; } } else { @@ -25,4 +25,4 @@ + // CraftBukkit end world.playSound(entityhuman, blockposition, SoundEffects.FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, world.getRandom().nextFloat() * 0.4F + 0.8F); world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockProperties.LIT, true), 11); - world.gameEvent((Entity) entityhuman, (Holder) GameEvent.BLOCK_CHANGE, blockposition); + world.gameEvent(entityhuman, (Holder) GameEvent.BLOCK_CHANGE, blockposition); diff --git a/nms-patches/net/minecraft/world/item/ItemHanging.patch b/nms-patches/net/minecraft/world/item/ItemHanging.patch index 5dcb4a284..55c691674 100644 --- a/nms-patches/net/minecraft/world/item/ItemHanging.patch +++ b/nms-patches/net/minecraft/world/item/ItemHanging.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemHanging.java +++ b/net/minecraft/world/item/ItemHanging.java -@@ -25,6 +25,11 @@ +@@ -21,6 +21,11 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.gameevent.GameEvent; @@ -12,9 +12,9 @@ public class ItemHanging extends Item { private static final IChatBaseComponent TOOLTIP_RANDOM_VARIANT = IChatBaseComponent.translatable("painting.random").withStyle(EnumChatFormat.GRAY); -@@ -75,6 +80,19 @@ - - if (((EntityHanging) object).survives()) { +@@ -66,6 +71,19 @@ + EntityTypes.createDefaultStackConfig(world, itemstack, entityhuman).accept(entityhanging); + if (entityhanging.survives()) { if (!world.isClientSide) { + // CraftBukkit start - fire HangingPlaceEvent + Player who = (itemactioncontext.getPlayer() == null) ? null : (Player) itemactioncontext.getPlayer().getBukkitEntity(); @@ -22,22 +22,13 @@ + org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection); + org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(itemactioncontext.getHand()); + -+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) ((EntityHanging) object).getBukkitEntity(), who, blockClicked, blockFace, hand, org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); ++ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityhanging.getBukkitEntity(), who, blockClicked, blockFace, hand, org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); + world.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return EnumInteractionResult.FAIL; + } + // CraftBukkit end - ((EntityHanging) object).playPlacementSound(); - world.gameEvent((Entity) entityhuman, (Holder) GameEvent.ENTITY_PLACE, ((EntityHanging) object).position()); - world.addFreshEntity((Entity) object); -@@ -102,7 +120,7 @@ - - if (!customdata.isEmpty()) { - customdata.read(holderlookup_a.createSerializationContext(DynamicOpsNBT.INSTANCE), EntityPainting.VARIANT_MAP_CODEC).result().ifPresentOrElse((holder) -> { -- Optional optional = ((PaintingVariant) holder.value()).title(); -+ Optional optional = ((PaintingVariant) holder.value()).title(); // CraftBukkit - decompile error - - Objects.requireNonNull(list); - optional.ifPresent(list::add); + entityhanging.playPlacementSound(); + world.gameEvent(entityhuman, (Holder) GameEvent.ENTITY_PLACE, entityhanging.position()); + world.addFreshEntity(entityhanging); diff --git a/nms-patches/net/minecraft/world/item/ItemLeash.patch b/nms-patches/net/minecraft/world/item/ItemLeash.patch index 38caf51bf..32144b43d 100644 --- a/nms-patches/net/minecraft/world/item/ItemLeash.patch +++ b/nms-patches/net/minecraft/world/item/ItemLeash.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/world/item/ItemLeash.java +++ b/net/minecraft/world/item/ItemLeash.java -@@ -19,6 +19,12 @@ +@@ -17,6 +17,13 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AxisAlignedBB; +// CraftBukkit start ++import java.util.Iterator; +import org.bukkit.craftbukkit.CraftEquipmentSlot; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.event.hanging.HangingPlaceEvent; @@ -13,7 +14,7 @@ public class ItemLeash extends Item { public ItemLeash(Item.Info item_info) { -@@ -35,14 +41,14 @@ +@@ -33,25 +40,46 @@ EntityHuman entityhuman = itemactioncontext.getPlayer(); if (!world.isClientSide && entityhuman != null) { @@ -30,13 +31,11 @@ EntityLeash entityleash = null; List list = leashableInArea(world, blockposition, (leashable) -> { return leashable.getLeashHolder() == entityhuman; -@@ -50,22 +56,55 @@ + }); - Leashable leashable; - -- for (Iterator iterator = list.iterator(); iterator.hasNext(); leashable.setLeashedTo(entityleash, true)) { +- for (Leashable leashable : list) { + for (Iterator iterator = list.iterator(); iterator.hasNext();) { // CraftBukkit - handle setLeashedTo at end of loop - leashable = (Leashable) iterator.next(); ++ Leashable leashable = (Leashable) iterator.next(); if (entityleash == null) { entityleash = EntityLeash.getOrCreateKnot(world, blockposition); + @@ -52,7 +51,7 @@ + // CraftBukkit end entityleash.playPlacementSound(); } -+ + + // CraftBukkit start + if (leashable instanceof Entity leashed) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(leashed, entityleash, entityhuman, enumhand).isCancelled()) { @@ -60,13 +59,13 @@ + continue; + } + } -+ -+ leashable.setLeashedTo(entityleash, true); + // CraftBukkit end ++ + leashable.setLeashedTo(entityleash, true); } - if (!list.isEmpty()) { - world.gameEvent((Holder) GameEvent.BLOCK_ATTACH, blockposition, GameEvent.a.of((Entity) entityhuman)); +@@ -59,10 +87,21 @@ + world.gameEvent(GameEvent.BLOCK_ATTACH, blockposition, GameEvent.a.of((Entity) entityhuman)); return EnumInteractionResult.SUCCESS_SERVER; } else { + // CraftBukkit start- remove leash if we do not leash any entity because of the cancelled event diff --git a/nms-patches/net/minecraft/world/item/ItemMinecart.patch b/nms-patches/net/minecraft/world/item/ItemMinecart.patch index f5a66c7ae..aa43ed361 100644 --- a/nms-patches/net/minecraft/world/item/ItemMinecart.patch +++ b/nms-patches/net/minecraft/world/item/ItemMinecart.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemMinecart.java +++ b/net/minecraft/world/item/ItemMinecart.java -@@ -67,7 +67,12 @@ +@@ -59,7 +59,12 @@ if (world instanceof WorldServer) { WorldServer worldserver = (WorldServer) world; @@ -11,6 +11,6 @@ + } + // CraftBukkit end + if (!worldserver.addFreshEntity(entityminecartabstract)) return EnumInteractionResult.PASS; // CraftBukkit - worldserver.gameEvent((Holder) GameEvent.ENTITY_PLACE, blockposition, GameEvent.a.of(itemactioncontext.getPlayer(), worldserver.getBlockState(blockposition.below()))); + worldserver.gameEvent(GameEvent.ENTITY_PLACE, blockposition, GameEvent.a.of(itemactioncontext.getPlayer(), worldserver.getBlockState(blockposition.below()))); } diff --git a/nms-patches/net/minecraft/world/item/ItemMonsterEgg.patch b/nms-patches/net/minecraft/world/item/ItemMonsterEgg.patch index c76355cfd..0ece6ee9b 100644 --- a/nms-patches/net/minecraft/world/item/ItemMonsterEgg.patch +++ b/nms-patches/net/minecraft/world/item/ItemMonsterEgg.patch @@ -1,15 +1,11 @@ --- a/net/minecraft/world/item/ItemMonsterEgg.java +++ b/net/minecraft/world/item/ItemMonsterEgg.java -@@ -176,10 +176,10 @@ - return Optional.empty(); +@@ -176,7 +176,7 @@ } else { - ((EntityInsentient) object).moveTo(vec3d.x(), vec3d.y(), vec3d.z(), 0.0F, 0.0F); -- worldserver.addFreshEntityWithPassengers((Entity) object); -+ worldserver.addFreshEntityWithPassengers((Entity) object, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit - ((EntityInsentient) object).setCustomName((IChatBaseComponent) itemstack.get(DataComponents.CUSTOM_NAME)); + entityinsentient1.snapTo(vec3d.x(), vec3d.y(), vec3d.z(), 0.0F, 0.0F); + entityinsentient1.applyComponentsFromItemStack(itemstack); +- worldserver.addFreshEntityWithPassengers(entityinsentient1); ++ worldserver.addFreshEntityWithPassengers(entityinsentient1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit itemstack.consume(1, entityhuman); -- return Optional.of(object); -+ return Optional.of((EntityInsentient) object); // CraftBukkit - decompile error + return Optional.of(entityinsentient1); } - } - } diff --git a/nms-patches/net/minecraft/world/item/ItemSnowball.patch b/nms-patches/net/minecraft/world/item/ItemSnowball.patch index 1bbc3503d..1777f8b27 100644 --- a/nms-patches/net/minecraft/world/item/ItemSnowball.patch +++ b/nms-patches/net/minecraft/world/item/ItemSnowball.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/item/ItemSnowball.java +++ b/net/minecraft/world/item/ItemSnowball.java -@@ -25,13 +25,21 @@ +@@ -26,13 +26,21 @@ public EnumInteractionResult use(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.getItemInHand(enumhand); -- world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); +- world.playSound((Entity) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); + // CraftBukkit start - moved down -+ // world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); ++ // world.playSound((Entity) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); if (world instanceof WorldServer worldserver) { - IProjectile.spawnProjectileFromRotation(EntitySnowball::new, worldserver, itemstack, entityhuman, 0.0F, ItemSnowball.PROJECTILE_SHOOT_POWER, 1.0F); + if (IProjectile.spawnProjectileFromRotation(EntitySnowball::new, worldserver, itemstack, entityhuman, 0.0F, ItemSnowball.PROJECTILE_SHOOT_POWER, 1.0F).isAlive()) { + itemstack.consume(1, entityhuman); + -+ world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); ++ world.playSound((Entity) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); + } else if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { + ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); + } diff --git a/nms-patches/net/minecraft/world/item/ItemStack.patch b/nms-patches/net/minecraft/world/item/ItemStack.patch index 5cb394abf..1a1c9f2f2 100644 --- a/nms-patches/net/minecraft/world/item/ItemStack.patch +++ b/nms-patches/net/minecraft/world/item/ItemStack.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -96,18 +96,52 @@ +@@ -97,6 +97,40 @@ import org.apache.commons.lang3.mutable.MutableBoolean; import org.slf4j.Logger; @@ -41,51 +41,7 @@ public final class ItemStack implements DataComponentHolder { private static final List OP_NBT_WARNING = List.of(IChatBaseComponent.translatable("item.op_warning.line1").withStyle(EnumChatFormat.RED, EnumChatFormat.BOLD), IChatBaseComponent.translatable("item.op_warning.line2").withStyle(EnumChatFormat.RED), IChatBaseComponent.translatable("item.op_warning.line3").withStyle(EnumChatFormat.RED)); - public static final Codec CODEC = Codec.lazyInitialized(() -> { -- return RecordCodecBuilder.create((instance) -> { -+ return RecordCodecBuilder.create((instance) -> { // CraftBukkit - decompile error - return instance.group(Item.CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder), ExtraCodecs.intRange(1, 99).fieldOf("count").orElse(1).forGetter(ItemStack::getCount), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> { - return itemstack.components.asPatch(); - })).apply(instance, ItemStack::new); - }); - }); - public static final Codec SINGLE_ITEM_CODEC = Codec.lazyInitialized(() -> { -- return RecordCodecBuilder.create((instance) -> { -+ return RecordCodecBuilder.create((instance) -> { // CraftBukkit - decompile error - return instance.group(Item.CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> { - return itemstack.components.asPatch(); - })).apply(instance, (holder, datacomponentpatch) -> { -@@ -132,19 +166,25 @@ - if (i <= 0) { - return ItemStack.EMPTY; - } else { -- Holder holder = (Holder) null.ITEM_STREAM_CODEC.decode(registryfriendlybytebuf); -+ Holder holder = (Holder) ITEM_STREAM_CODEC.decode(registryfriendlybytebuf); // CraftBukkit - decompile error - DataComponentPatch datacomponentpatch = (DataComponentPatch) DataComponentPatch.STREAM_CODEC.decode(registryfriendlybytebuf); - -- return new ItemStack(holder, i, datacomponentpatch); -+ // CraftBukkit start -+ ItemStack itemstack = new ItemStack(holder, i, datacomponentpatch); -+ if (!datacomponentpatch.isEmpty()) { -+ CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); -+ } -+ return itemstack; -+ // CraftBukkit end - } - } - - public void encode(RegistryFriendlyByteBuf registryfriendlybytebuf, ItemStack itemstack) { -- if (itemstack.isEmpty()) { -+ if (itemstack.isEmpty() || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem() - registryfriendlybytebuf.writeVarInt(0); - } else { - registryfriendlybytebuf.writeVarInt(itemstack.getCount()); -- null.ITEM_STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.getItemHolder()); -+ ITEM_STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.getItemHolder()); // CraftBukkit - decompile error - DataComponentPatch.STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.components.asPatch()); - } - } -@@ -187,7 +227,7 @@ +@@ -136,7 +170,7 @@ return dataresult.isError() ? dataresult.map((unit) -> { return itemstack; @@ -94,18 +50,28 @@ int i = itemstack.getCount(); return "Item stack with stack size of " + i + " was larger than maximum: " + itemstack.getMaxStackSize(); -@@ -294,8 +334,9 @@ - j = itemstack.getMaxStackSize(); - } while (i <= j); +@@ -154,12 +188,18 @@ + Holder holder = (Holder) Item.STREAM_CODEC.decode(registryfriendlybytebuf); + DataComponentPatch datacomponentpatch = (DataComponentPatch) streamcodec.decode(registryfriendlybytebuf); -+ int finalI = i, finalJ = j; // CraftBukkit - decompile error - return DataResult.error(() -> { -- return "Item stack with count of " + i + " was larger than maximum: " + j; -+ return "Item stack with count of " + finalI + " was larger than maximum: " + finalJ; // CraftBukkit - decompile error - }); - } - } -@@ -377,15 +418,173 @@ +- return new ItemStack(holder, i, datacomponentpatch); ++ // CraftBukkit start ++ ItemStack itemstack = new ItemStack(holder, i, datacomponentpatch); ++ if (!datacomponentpatch.isEmpty()) { ++ CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); ++ } ++ return itemstack; ++ // CraftBukkit end + } + } + + public void encode(RegistryFriendlyByteBuf registryfriendlybytebuf, ItemStack itemstack) { +- if (itemstack.isEmpty()) { ++ if (itemstack.isEmpty() || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem() + registryfriendlybytebuf.writeVarInt(0); + } else { + registryfriendlybytebuf.writeVarInt(itemstack.getCount()); +@@ -343,15 +383,173 @@ return EnumInteractionResult.PASS; } else { Item item = this.getItem(); @@ -260,7 +226,7 @@ + IBlockData blockData = world.getBlockState(position); + + if (blockData.getBlock() instanceof BlockBed) { -+ world.blockUpdated(position, Blocks.AIR); ++ world.updateNeighborsAt(position, Blocks.AIR); + blockData.updateNeighbourShapes(world, position, 3); + } + } @@ -281,7 +247,7 @@ return enuminteractionresult; } -@@ -492,6 +691,21 @@ +@@ -454,6 +652,21 @@ public void hurtAndBreak(int i, WorldServer worldserver, @Nullable EntityPlayer entityplayer, Consumer consumer) { int j = this.processDurabilityChange(i, worldserver, entityplayer); @@ -303,7 +269,7 @@ if (j != 0) { this.applyDamage(this.getDamageValue() + j, entityplayer, consumer); -@@ -511,6 +725,11 @@ +@@ -473,6 +686,11 @@ this.setDamageValue(i); if (this.isBroken()) { Item item = this.getItem(); @@ -315,7 +281,7 @@ this.shrink(1); consumer.accept(item); -@@ -770,6 +989,12 @@ +@@ -747,6 +965,12 @@ return this.getItem().useOnRelease(this); } @@ -326,18 +292,9 @@ + // CraftBukkit end + @Nullable - public T set(DataComponentType datacomponenttype, @Nullable T t0) { - return this.components.set(datacomponenttype, t0); -@@ -858,7 +1083,7 @@ - } - - private void addToTooltip(DataComponentType datacomponenttype, Item.b item_b, Consumer consumer, TooltipFlag tooltipflag) { -- T t0 = (TooltipProvider) this.get(datacomponenttype); -+ T t0 = (T) this.get(datacomponenttype); // CraftBukkit - decompile error - - if (t0 != null) { - t0.addToTooltip(item_b, consumer, tooltipflag); -@@ -1091,6 +1316,13 @@ + public T set(DataComponentType datacomponenttype, @Nullable T t0) { + return (T) this.components.set(datacomponenttype, t0); +@@ -1084,6 +1308,13 @@ EnchantmentManager.forEachModifier(this, enumitemslot, biconsumer); } @@ -351,7 +308,7 @@ public IChatBaseComponent getDisplayName() { IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.empty().append(this.getHoverName()); -@@ -1153,7 +1385,7 @@ +@@ -1146,7 +1377,7 @@ } public void consume(int i, @Nullable EntityLiving entityliving) { diff --git a/nms-patches/net/minecraft/world/item/ItemTrident.patch b/nms-patches/net/minecraft/world/item/ItemTrident.patch index ec20c66e6..96043200d 100644 --- a/nms-patches/net/minecraft/world/item/ItemTrident.patch +++ b/nms-patches/net/minecraft/world/item/ItemTrident.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/item/ItemTrident.java +++ b/net/minecraft/world/item/ItemTrident.java -@@ -86,9 +86,19 @@ +@@ -78,10 +78,20 @@ if (world instanceof WorldServer) { WorldServer worldserver = (WorldServer) world; - itemstack.hurtWithoutBreaking(1, entityhuman); + // itemstack.hurtWithoutBreaking(1, entityhuman); // CraftBukkit - moved down if (f == 0.0F) { - EntityThrownTrident entitythrowntrident = (EntityThrownTrident) IProjectile.spawnProjectileFromRotation(EntityThrownTrident::new, worldserver, itemstack, entityhuman, 0.0F, 2.5F, 1.0F); + // CraftBukkit start ++ EntityThrownTrident entitythrowntrident = (EntityThrownTrident) IProjectile.spawnProjectileFromRotation(EntityThrownTrident::new, worldserver, itemstack, entityhuman, 0.0F, 2.5F, 1.0F); + if (entitythrowntrident.isRemoved()) { + if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { + ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); @@ -16,14 +16,16 @@ + return false; + } + itemstack.hurtWithoutBreaking(1, entityhuman); -+ entitythrowntrident.pickupItemStack = itemstack.copy(); // SPIGOT-4511 update since damage call moved + ItemStack itemstack1 = itemstack.consumeAndReturn(1, entityhuman); +- EntityThrownTrident entitythrowntrident = (EntityThrownTrident) IProjectile.spawnProjectileFromRotation(EntityThrownTrident::new, worldserver, itemstack1, entityhuman, 0.0F, 2.5F, 1.0F); ++ entitythrowntrident.pickupItemStack = itemstack1.copy(); // SPIGOT-4511 update since damage call moved + // CraftBukkit end if (entityhuman.hasInfiniteMaterials()) { entitythrowntrident.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY; -@@ -98,6 +108,10 @@ +@@ -89,6 +99,10 @@ - world.playSound((EntityHuman) null, (Entity) entitythrowntrident, (SoundEffect) holder.value(), SoundCategory.PLAYERS, 1.0F, 1.0F); + world.playSound((Entity) null, (Entity) entitythrowntrident, holder.value(), SoundCategory.PLAYERS, 1.0F, 1.0F); return true; + // CraftBukkit start - SPIGOT-5458 also need in this branch :( + } else { @@ -32,7 +34,7 @@ } } -@@ -112,6 +126,7 @@ +@@ -103,6 +117,7 @@ f3 *= f / f6; f4 *= f / f6; f5 *= f / f6; diff --git a/nms-patches/net/minecraft/world/item/MaceItem.patch b/nms-patches/net/minecraft/world/item/MaceItem.patch index 63df5a7ac..4cbdc92eb 100644 --- a/nms-patches/net/minecraft/world/item/MaceItem.patch +++ b/nms-patches/net/minecraft/world/item/MaceItem.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/MaceItem.java +++ b/net/minecraft/world/item/MaceItem.java -@@ -27,6 +27,10 @@ - import net.minecraft.world.level.block.state.IBlockData; +@@ -23,6 +23,10 @@ + import net.minecraft.world.level.World; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start @@ -11,14 +11,14 @@ public class MaceItem extends Item { private static final int DEFAULT_ATTACK_DAMAGE = 5; -@@ -144,7 +148,15 @@ +@@ -133,7 +137,15 @@ Vec3D vec3d1 = vec3d.normalize().scale(d0); if (d0 > 0.0D) { -- entityliving.push(vec3d1.x, 0.699999988079071D, vec3d1.z); -+ // entityliving.push(vec3d1.x, 0.699999988079071D, vec3d1.z); // CraftBukkit - moved below +- entityliving.push(vec3d1.x, (double) 0.7F, vec3d1.z); ++ // entityliving.push(vec3d1.x, 0.7F, vec3d1.z); // CraftBukkit - moved below + // CraftBukkit start - EntityKnockbackEvent -+ Vec3D vec3dPush = new Vec3D(vec3d1.x, 0.699999988079071D, vec3d1.z); ++ Vec3D vec3dPush = new Vec3D(vec3d1.x, 0.7F, vec3d1.z); + Vec3D result = entity.getDeltaMovement().add(vec3dPush); + org.bukkit.event.entity.EntityKnockbackEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entityliving.getBukkitEntity(), entity, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK, d0, result, vec3dPush.x, vec3dPush.y, vec3dPush.z); + if (!event.isCancelled()) { diff --git a/nms-patches/net/minecraft/world/item/MobBucketItem.patch b/nms-patches/net/minecraft/world/item/MobBucketItem.patch index ef0cdb5ce..b7dd4604d 100644 --- a/nms-patches/net/minecraft/world/item/MobBucketItem.patch +++ b/nms-patches/net/minecraft/world/item/MobBucketItem.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/MobBucketItem.java +++ b/net/minecraft/world/item/MobBucketItem.java -@@ -26,6 +26,10 @@ +@@ -18,6 +18,10 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.material.FluidType; @@ -10,8 +10,8 @@ + public class MobBucketItem extends ItemBucket { - private static final MapCodec VARIANT_FIELD_CODEC = EntityTropicalFish.d.CODEC.fieldOf("BucketVariantTag"); -@@ -63,7 +67,7 @@ + private final EntityTypes type; +@@ -54,7 +58,7 @@ } if (entityinsentient != null) { diff --git a/nms-patches/net/minecraft/world/item/alchemy/PotionContents.patch b/nms-patches/net/minecraft/world/item/alchemy/PotionContents.patch index 63fdb46f4..9fcc2a8da 100644 --- a/nms-patches/net/minecraft/world/item/alchemy/PotionContents.patch +++ b/nms-patches/net/minecraft/world/item/alchemy/PotionContents.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/world/item/alchemy/PotionContents.java +++ b/net/minecraft/world/item/alchemy/PotionContents.java -@@ -93,7 +93,7 @@ - } - - public PotionContents withEffectAdded(MobEffect mobeffect) { -- return new PotionContents(this.potion, this.customColor, SystemUtils.copyAndAdd(this.customEffects, (Object) mobeffect), this.customName); -+ return new PotionContents(this.potion, this.customColor, SystemUtils.copyAndAdd(this.customEffects, mobeffect), this.customName); // CraftBukkit - decompile error - } - - public int getColor() { -@@ -172,7 +172,7 @@ +@@ -158,7 +158,7 @@ if (((MobEffectList) mobeffect.getEffect().value()).isInstantenous()) { ((MobEffectList) mobeffect.getEffect().value()).applyInstantenousEffect(worldserver, entityhuman2, entityhuman2, entityliving, mobeffect.getAmplifier(), 1.0D); } else { @@ -17,4 +8,4 @@ + entityliving.addEffect(mobeffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_DRINK); // CraftBukkit } - }); + }, f); diff --git a/nms-patches/net/minecraft/world/item/component/DeathProtection.patch b/nms-patches/net/minecraft/world/item/component/DeathProtection.patch index 14197c4bd..2fd977092 100644 --- a/nms-patches/net/minecraft/world/item/component/DeathProtection.patch +++ b/nms-patches/net/minecraft/world/item/component/DeathProtection.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/component/DeathProtection.java +++ b/net/minecraft/world/item/component/DeathProtection.java -@@ -15,6 +15,10 @@ +@@ -14,6 +14,10 @@ import net.minecraft.world.item.consume_effects.ClearAllStatusEffectsConsumeEffect; import net.minecraft.world.item.consume_effects.ConsumeEffect; @@ -11,10 +11,10 @@ public record DeathProtection(List deathEffects) { public static final Codec CODEC = RecordCodecBuilder.create((instance) -> { -@@ -29,7 +33,7 @@ - while (iterator.hasNext()) { - ConsumeEffect consumeeffect = (ConsumeEffect) iterator.next(); +@@ -24,7 +28,7 @@ + public void applyEffects(ItemStack itemstack, EntityLiving entityliving) { + for (ConsumeEffect consumeeffect : this.deathEffects) { - consumeeffect.apply(entityliving.level(), itemstack, entityliving); + consumeeffect.apply(entityliving.level(), itemstack, entityliving, EntityPotionEffectEvent.Cause.TOTEM); // CraftBukkit } diff --git a/nms-patches/net/minecraft/world/item/component/SuspiciousStewEffects.patch b/nms-patches/net/minecraft/world/item/component/SuspiciousStewEffects.patch index b8ba7b7f0..1d4ca3881 100644 --- a/nms-patches/net/minecraft/world/item/component/SuspiciousStewEffects.patch +++ b/nms-patches/net/minecraft/world/item/component/SuspiciousStewEffects.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/world/item/component/SuspiciousStewEffects.java +++ b/net/minecraft/world/item/component/SuspiciousStewEffects.java -@@ -29,7 +29,7 @@ - public static final StreamCodec STREAM_CODEC = SuspiciousStewEffects.a.STREAM_CODEC.apply(ByteBufCodecs.list()).map(SuspiciousStewEffects::new, SuspiciousStewEffects::effects); - - public SuspiciousStewEffects withEffectAdded(SuspiciousStewEffects.a suspicioussteweffects_a) { -- return new SuspiciousStewEffects(SystemUtils.copyAndAdd(this.effects, (Object) suspicioussteweffects_a)); -+ return new SuspiciousStewEffects(SystemUtils.copyAndAdd(this.effects, suspicioussteweffects_a)); // CraftBukkit - decompile error - } - - @Override -@@ -44,6 +44,15 @@ +@@ -40,6 +40,15 @@ } @@ -23,5 +14,5 @@ + // CraftBukkit end + @Override - public void addToTooltip(Item.b item_b, Consumer consumer, TooltipFlag tooltipflag) { + public void addToTooltip(Item.b item_b, Consumer consumer, TooltipFlag tooltipflag, DataComponentGetter datacomponentgetter) { if (tooltipflag.isCreative()) { diff --git a/nms-patches/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.patch b/nms-patches/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.patch index 2b3e14470..b46893a79 100644 --- a/nms-patches/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.patch +++ b/nms-patches/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java +++ b/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java -@@ -13,6 +13,10 @@ +@@ -12,6 +12,10 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.World; @@ -11,7 +11,7 @@ public record ApplyStatusEffectsConsumeEffect(List effects, float probability) implements ConsumeEffect { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -38,7 +42,7 @@ +@@ -37,14 +41,14 @@ } @Override @@ -20,10 +20,9 @@ if (entityliving.getRandom().nextFloat() >= this.probability) { return false; } else { -@@ -48,7 +52,7 @@ - while (iterator.hasNext()) { - MobEffect mobeffect = (MobEffect) iterator.next(); + boolean flag = false; + for (MobEffect mobeffect : this.effects) { - if (entityliving.addEffect(new MobEffect(mobeffect))) { + if (entityliving.addEffect(new MobEffect(mobeffect), cause)) { // CraftBukkit flag = true; diff --git a/nms-patches/net/minecraft/world/item/consume_effects/ConsumeEffect.patch b/nms-patches/net/minecraft/world/item/consume_effects/ConsumeEffect.patch index d85f91059..d71bb6b97 100644 --- a/nms-patches/net/minecraft/world/item/consume_effects/ConsumeEffect.patch +++ b/nms-patches/net/minecraft/world/item/consume_effects/ConsumeEffect.patch @@ -28,3 +28,12 @@ public static record a(MapCodec codec, StreamCodec streamCodec) { +@@ -30,7 +42,7 @@ + public static final ConsumeEffect.a PLAY_SOUND = register("play_sound", PlaySoundConsumeEffect.CODEC, PlaySoundConsumeEffect.STREAM_CODEC); + + private static ConsumeEffect.a register(String s, MapCodec mapcodec, StreamCodec streamcodec) { +- return (ConsumeEffect.a) IRegistry.register(BuiltInRegistries.CONSUME_EFFECT_TYPE, s, new ConsumeEffect.a(mapcodec, streamcodec)); ++ return (ConsumeEffect.a) IRegistry.register(BuiltInRegistries.CONSUME_EFFECT_TYPE, s, new ConsumeEffect.a<>(mapcodec, streamcodec)); // CraftBukkit - decompile error + } + } + } diff --git a/nms-patches/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.patch b/nms-patches/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.patch index 4e7586f72..ef1037211 100644 --- a/nms-patches/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.patch +++ b/nms-patches/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java +++ b/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java -@@ -15,6 +15,10 @@ +@@ -14,6 +14,10 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.World; @@ -11,18 +11,15 @@ public record RemoveStatusEffectsConsumeEffect(HolderSet effects) implements ConsumeEffect { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -32,14 +36,14 @@ +@@ -31,11 +35,11 @@ } @Override - public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving) { + public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving, EntityPotionEffectEvent.Cause cause) { // CraftBukkit boolean flag = false; - Iterator iterator = this.effects.iterator(); - - while (iterator.hasNext()) { - Holder holder = (Holder) iterator.next(); + for (Holder holder : this.effects) { - if (entityliving.removeEffect(holder)) { + if (entityliving.removeEffect(holder, cause)) { // CraftBukkit flag = true; diff --git a/nms-patches/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.patch b/nms-patches/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.patch index b8af6a41f..ee8664060 100644 --- a/nms-patches/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.patch +++ b/nms-patches/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java +++ b/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java -@@ -53,7 +53,16 @@ +@@ -52,7 +52,16 @@ Vec3D vec3d = entityliving.position(); @@ -15,6 +15,6 @@ + + if (status.get()) { + // CraftBukkit end - world.gameEvent((Holder) GameEvent.TELEPORT, vec3d, GameEvent.a.of((Entity) entityliving)); - SoundEffect soundeffect; + world.gameEvent(GameEvent.TELEPORT, vec3d, GameEvent.a.of((Entity) entityliving)); SoundCategory soundcategory; + SoundEffect soundeffect; diff --git a/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch b/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch index 82f29fa19..4e7a712a7 100644 --- a/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch +++ b/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/CraftingManager.java +++ b/net/minecraft/world/item/crafting/CraftingManager.java -@@ -39,6 +39,11 @@ +@@ -38,6 +38,11 @@ import net.minecraft.world.level.World; import org.slf4j.Logger; @@ -12,7 +12,7 @@ public class CraftingManager extends ResourceDataAbstract implements RecipeAccess { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -111,7 +116,25 @@ +@@ -110,7 +115,25 @@ CraftingManager.LOGGER.info("Loaded {} recipes", recipemap.values().size()); } @@ -38,16 +38,7 @@ List> list = new ArrayList(); List list1 = CraftingManager.RECIPE_PROPERTY_SETS.entrySet().stream().map((entry) -> { return new CraftingManager.b((ResourceKey) entry.getKey(), (CraftingManager.c) entry.getValue()); -@@ -130,7 +153,7 @@ - RecipeStonecutting recipestonecutting = (RecipeStonecutting) irecipe; - - if (isIngredientEnabled(featureflagset, recipestonecutting.input()) && recipestonecutting.resultDisplay().isEnabled(featureflagset)) { -- list.add(new SelectableRecipe.a<>(recipestonecutting.input(), new SelectableRecipe<>(recipestonecutting.resultDisplay(), Optional.of(recipeholder)))); -+ list.add(new SelectableRecipe.a(recipestonecutting.input(), new SelectableRecipe<>(recipestonecutting.resultDisplay(), Optional.of((RecipeHolder) recipeholder)))); // CraftBukkit - decompile error - } - } - -@@ -172,7 +195,10 @@ +@@ -171,7 +194,10 @@ } public > Optional> getRecipeFor(Recipes recipes, I i0, World world) { @@ -59,7 +50,7 @@ } public Optional> byKey(ResourceKey> resourcekey) { -@@ -183,7 +209,7 @@ +@@ -182,7 +208,7 @@ private > RecipeHolder byKeyTyped(Recipes recipes, ResourceKey> resourcekey) { RecipeHolder recipeholder = this.recipes.byKey(resourcekey); @@ -68,8 +59,8 @@ } public Map, RecipePropertySet> getSynchronizedItemProperties() { -@@ -231,6 +257,22 @@ - return new RecipeHolder<>(resourcekey, irecipe); +@@ -230,6 +256,22 @@ + return new RecipeHolder(resourcekey, irecipe); } + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch b/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch index 4d92b7060..3f908b0ff 100644 --- a/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch +++ b/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/IRecipe.java +++ b/net/minecraft/world/item/crafting/IRecipe.java -@@ -44,4 +44,6 @@ +@@ -46,4 +46,6 @@ } RecipeBookCategory recipeBookCategory(); diff --git a/nms-patches/net/minecraft/world/item/crafting/RecipeMap.patch b/nms-patches/net/minecraft/world/item/crafting/RecipeMap.patch index 86f181878..32f653f86 100644 --- a/nms-patches/net/minecraft/world/item/crafting/RecipeMap.patch +++ b/nms-patches/net/minecraft/world/item/crafting/RecipeMap.patch @@ -1,12 +1,13 @@ --- a/net/minecraft/world/item/crafting/RecipeMap.java +++ b/net/minecraft/world/item/crafting/RecipeMap.java -@@ -12,13 +12,21 @@ +@@ -10,13 +10,22 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.World; +// CraftBukkit start +import com.google.common.collect.LinkedHashMultimap; +import com.google.common.collect.Maps; ++import java.util.Iterator; +import java.util.LinkedHashMap; +// CraftBukkit end + @@ -25,15 +26,15 @@ this.byType = multimap; this.byKey = map; } -@@ -35,11 +43,39 @@ - com_google_common_collect_immutablemap_builder.put(recipeholder.id(), recipeholder); +@@ -30,11 +39,39 @@ + immutablemap_builder.put(recipeholder.id(), recipeholder); } -- return new RecipeMap(builder.build(), com_google_common_collect_immutablemap_builder.build()); +- return new RecipeMap(immutablemultimap_builder.build(), immutablemap_builder.build()); + // CraftBukkit start - mutable, ordered -+ return new RecipeMap(LinkedHashMultimap.create(builder.build()), Maps.newLinkedHashMap(com_google_common_collect_immutablemap_builder.build())); -+ } -+ ++ return new RecipeMap(LinkedHashMultimap.create(immutablemultimap_builder.build()), Maps.newLinkedHashMap(immutablemap_builder.build())); + } + + public void addRecipe(RecipeHolder irecipe) { + Collection> map = this.byType.get(irecipe.value().getType()); + @@ -43,8 +44,8 @@ + map.add(irecipe); + byKey.putFirst(irecipe.id(), irecipe); // CraftBukkit - ordered + } - } - ++ } ++ + public boolean removeRecipe(ResourceKey> mcKey) { + boolean removed = false; + Iterator> iter = byType.values().iterator(); diff --git a/nms-patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.patch b/nms-patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.patch index 5594867ed..9df2f946a 100644 --- a/nms-patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.patch +++ b/nms-patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.patch @@ -1,12 +1,11 @@ --- a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java +++ b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java -@@ -14,6 +14,14 @@ +@@ -14,6 +14,13 @@ import net.minecraft.world.item.crafting.display.SlotDisplay; import net.minecraft.world.item.crafting.display.SmithingRecipeDisplay; +// CraftBukkit start +import org.bukkit.NamespacedKey; -+import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.inventory.CraftRecipe; +import org.bukkit.craftbukkit.inventory.CraftSmithingTransformRecipe; +import org.bukkit.inventory.Recipe; @@ -15,14 +14,14 @@ public class SmithingTransformRecipe implements SmithingRecipe { final Optional template; -@@ -71,6 +79,17 @@ - return List.of(new SmithingRecipeDisplay(RecipeItemStack.optionalIngredientToDisplay(this.template), RecipeItemStack.optionalIngredientToDisplay(this.base), RecipeItemStack.optionalIngredientToDisplay(this.addition), new SlotDisplay.f(this.result), new SlotDisplay.d(Items.SMITHING_TABLE))); +@@ -68,6 +75,17 @@ + return List.of(new SmithingRecipeDisplay(RecipeItemStack.optionalIngredientToDisplay(this.template), this.base.display(), RecipeItemStack.optionalIngredientToDisplay(this.addition), this.result.display(), new SlotDisplay.d(Items.SMITHING_TABLE))); } + // CraftBukkit start + @Override + public Recipe toBukkitRecipe(NamespacedKey id) { -+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result); ++ org.bukkit.inventory.ItemStack result = CraftRecipe.toBukkit(this.result); + + CraftSmithingTransformRecipe recipe = new CraftSmithingTransformRecipe(id, result, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition)); + diff --git a/nms-patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.patch b/nms-patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.patch index 3b2a1c61e..8473fb526 100644 --- a/nms-patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.patch +++ b/nms-patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.patch @@ -1,27 +1,28 @@ --- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java +++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -@@ -21,6 +21,13 @@ +@@ -21,6 +21,14 @@ + import net.minecraft.world.item.equipment.trim.TrimMaterials; import net.minecraft.world.item.equipment.trim.TrimPattern; - import net.minecraft.world.item.equipment.trim.TrimPatterns; +// CraftBukkit start +import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.inventory.CraftRecipe; +import org.bukkit.craftbukkit.inventory.CraftSmithingTrimRecipe; ++import org.bukkit.craftbukkit.inventory.trim.CraftTrimPattern; +import org.bukkit.inventory.Recipe; +// CraftBukkit end + public class SmithingTrimRecipe implements SmithingRecipe { - final Optional template; -@@ -97,6 +104,13 @@ - return List.of(new SmithingRecipeDisplay(slotdisplay2, slotdisplay, slotdisplay1, new SlotDisplay.g(slotdisplay, slotdisplay1, slotdisplay2), new SlotDisplay.d(Items.SMITHING_TABLE))); + final RecipeItemStack template; +@@ -99,6 +107,13 @@ + return List.of(new SmithingRecipeDisplay(slotdisplay2, slotdisplay, slotdisplay1, new SlotDisplay.g(slotdisplay, slotdisplay1, this.pattern), new SlotDisplay.d(Items.SMITHING_TABLE))); } + // CraftBukkit start + @Override + public Recipe toBukkitRecipe(NamespacedKey id) { -+ return new CraftSmithingTrimRecipe(id, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition)); ++ return new CraftSmithingTrimRecipe(id, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition), CraftTrimPattern.minecraftHolderToBukkit(this.pattern)); + } + // CraftBukkit end + diff --git a/nms-patches/net/minecraft/world/item/crafting/TransmuteRecipe.patch b/nms-patches/net/minecraft/world/item/crafting/TransmuteRecipe.patch index b650fe619..a2ed4de41 100644 --- a/nms-patches/net/minecraft/world/item/crafting/TransmuteRecipe.patch +++ b/nms-patches/net/minecraft/world/item/crafting/TransmuteRecipe.patch @@ -1,12 +1,11 @@ --- a/net/minecraft/world/item/crafting/TransmuteRecipe.java +++ b/net/minecraft/world/item/crafting/TransmuteRecipe.java -@@ -20,6 +20,14 @@ - import net.minecraft.world.level.IMaterial; +@@ -16,6 +16,13 @@ + import net.minecraft.world.item.crafting.display.SlotDisplay; import net.minecraft.world.level.World; +// CraftBukkit start +import org.bukkit.NamespacedKey; -+import org.bukkit.craftbukkit.inventory.CraftItemType; +import org.bukkit.craftbukkit.inventory.CraftRecipe; +import org.bukkit.craftbukkit.inventory.CraftTransmuteRecipe; +import org.bukkit.inventory.Recipe; @@ -15,14 +14,14 @@ public class TransmuteRecipe implements RecipeCrafting { final String group; -@@ -84,6 +92,13 @@ - return List.of(new ShapelessCraftingRecipeDisplay(List.of(this.input.display(), this.material.display()), new SlotDisplay.d(this.result), new SlotDisplay.d(Items.CRAFTING_TABLE))); +@@ -82,6 +89,13 @@ + return List.of(new ShapelessCraftingRecipeDisplay(List.of(this.input.display(), this.material.display()), this.result.display(), new SlotDisplay.d(Items.CRAFTING_TABLE))); } + // CraftBukkit start + @Override + public Recipe toBukkitRecipe(NamespacedKey id) { -+ return new CraftTransmuteRecipe(id, CraftItemType.minecraftToBukkit(this.result.value()), CraftRecipe.toBukkit(this.input), CraftRecipe.toBukkit(this.material)); ++ return new CraftTransmuteRecipe(id, CraftRecipe.toBukkit(this.result), CraftRecipe.toBukkit(this.input), CraftRecipe.toBukkit(this.material)); + } + // CraftBukkit end + diff --git a/nms-patches/net/minecraft/world/item/enchantment/effects/ReplaceDisk.patch b/nms-patches/net/minecraft/world/item/enchantment/effects/ReplaceDisk.patch index 350911b20..1785d9c6d 100644 --- a/nms-patches/net/minecraft/world/item/enchantment/effects/ReplaceDisk.patch +++ b/nms-patches/net/minecraft/world/item/enchantment/effects/ReplaceDisk.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java +++ b/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java -@@ -37,7 +37,7 @@ - +@@ -33,7 +33,7 @@ + for (BlockPosition blockposition1 : BlockPosition.betweenClosed(blockposition.offset(-j, 0, -j), blockposition.offset(j, Math.min(k - 1, 0), j))) { if (blockposition1.distToCenterSqr(vec3d.x(), (double) blockposition1.getY() + 0.5D, vec3d.z()) < (double) MathHelper.square(j) && (Boolean) this.predicate.map((blockpredicate) -> { return blockpredicate.test(worldserver, blockposition1); - }).orElse(true) && worldserver.setBlockAndUpdate(blockposition1, this.blockState.getState(randomsource, blockposition1))) { diff --git a/nms-patches/net/minecraft/world/level/CommandBlockListenerAbstract.patch b/nms-patches/net/minecraft/world/level/CommandBlockListenerAbstract.patch index f3c4982ba..0021ed9f4 100644 --- a/nms-patches/net/minecraft/world/level/CommandBlockListenerAbstract.patch +++ b/nms-patches/net/minecraft/world/level/CommandBlockListenerAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/CommandBlockListenerAbstract.java +++ b/net/minecraft/world/level/CommandBlockListenerAbstract.java -@@ -33,6 +33,10 @@ +@@ -38,6 +38,10 @@ private String command = ""; @Nullable private IChatBaseComponent customName; @@ -11,7 +11,7 @@ public CommandBlockListenerAbstract() {} -@@ -132,7 +136,7 @@ +@@ -121,7 +125,7 @@ }); diff --git a/nms-patches/net/minecraft/world/level/GameRules.patch b/nms-patches/net/minecraft/world/level/GameRules.patch index c23988392..966b13475 100644 --- a/nms-patches/net/minecraft/world/level/GameRules.patch +++ b/nms-patches/net/minecraft/world/level/GameRules.patch @@ -1,33 +1,33 @@ --- a/net/minecraft/world/level/GameRules.java +++ b/net/minecraft/world/level/GameRules.java -@@ -58,7 +58,7 @@ - public static final GameRules.GameRuleKey RULE_SENDCOMMANDFEEDBACK = register("sendCommandFeedback", GameRules.GameRuleCategory.CHAT, GameRules.GameRuleBoolean.create(true)); +@@ -60,7 +60,7 @@ public static final GameRules.GameRuleKey RULE_REDUCEDDEBUGINFO = register("reducedDebugInfo", GameRules.GameRuleCategory.MISC, GameRules.GameRuleBoolean.create(false, (minecraftserver, gamerules_gameruleboolean) -> { - int i = gamerules_gameruleboolean.get() ? 22 : 23; -- Iterator iterator = minecraftserver.getPlayerList().getPlayers().iterator(); -+ Iterator iterator = minecraftserver.players().iterator(); // CraftBukkit - per-world + byte b0 = (byte) (gamerules_gameruleboolean.get() ? 22 : 23); - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -74,7 +74,7 @@ +- for (EntityPlayer entityplayer : minecraftserver.getPlayerList().getPlayers()) { ++ for (EntityPlayer entityplayer : minecraftserver.players()) { // CraftBukkit - per-world + entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0)); + } + +@@ -72,7 +72,7 @@ public static final GameRules.GameRuleKey RULE_MAX_ENTITY_CRAMMING = register("maxEntityCramming", GameRules.GameRuleCategory.MOBS, GameRules.GameRuleInt.create(24)); public static final GameRules.GameRuleKey RULE_WEATHER_CYCLE = register("doWeatherCycle", GameRules.GameRuleCategory.UPDATES, GameRules.GameRuleBoolean.create(true)); public static final GameRules.GameRuleKey RULE_LIMITED_CRAFTING = register("doLimitedCrafting", GameRules.GameRuleCategory.PLAYER, GameRules.GameRuleBoolean.create(false, (minecraftserver, gamerules_gameruleboolean) -> { -- Iterator iterator = minecraftserver.getPlayerList().getPlayers().iterator(); -+ Iterator iterator = minecraftserver.players().iterator(); // CraftBukkit - per-world +- for (EntityPlayer entityplayer : minecraftserver.getPlayerList().getPlayers()) { ++ for (EntityPlayer entityplayer : minecraftserver.players()) { // CraftBukkit - per-world + entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.LIMITED_CRAFTING, gamerules_gameruleboolean.get() ? 1.0F : 0.0F)); + } - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -90,7 +90,7 @@ +@@ -84,7 +84,7 @@ public static final GameRules.GameRuleKey RULE_DISABLE_RAIDS = register("disableRaids", GameRules.GameRuleCategory.MOBS, GameRules.GameRuleBoolean.create(false)); public static final GameRules.GameRuleKey RULE_DOINSOMNIA = register("doInsomnia", GameRules.GameRuleCategory.SPAWNING, GameRules.GameRuleBoolean.create(true)); public static final GameRules.GameRuleKey RULE_DO_IMMEDIATE_RESPAWN = register("doImmediateRespawn", GameRules.GameRuleCategory.PLAYER, GameRules.GameRuleBoolean.create(false, (minecraftserver, gamerules_gameruleboolean) -> { -- Iterator iterator = minecraftserver.getPlayerList().getPlayers().iterator(); -+ Iterator iterator = minecraftserver.players().iterator(); // CraftBukkit - per-world +- for (EntityPlayer entityplayer : minecraftserver.getPlayerList().getPlayers()) { ++ for (EntityPlayer entityplayer : minecraftserver.players()) { // CraftBukkit - per-world + entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.IMMEDIATE_RESPAWN, gamerules_gameruleboolean.get() ? 1.0F : 0.0F)); + } - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -123,7 +123,7 @@ +@@ -113,7 +113,7 @@ public static final GameRules.GameRuleKey RULE_MINECART_MAX_SPEED = register("minecartMaxSpeed", GameRules.GameRuleCategory.MISC, GameRules.GameRuleInt.create(8, 1, 1000, FeatureFlagSet.of(FeatureFlags.MINECART_IMPROVEMENTS), (minecraftserver, gamerules_gameruleint) -> { })); public static final GameRules.GameRuleKey RULE_SPAWN_CHUNK_RADIUS = register("spawnChunkRadius", GameRules.GameRuleCategory.MISC, GameRules.GameRuleInt.create(2, 0, 32, FeatureFlagSet.of(), (minecraftserver, gamerules_gameruleint) -> { @@ -36,16 +36,22 @@ worldserver.setDefaultSpawnPos(worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle()); })); -@@ -164,7 +164,7 @@ - } +@@ -127,12 +127,12 @@ - public > T getRule(GameRules.GameRuleKey gamerules_gamerulekey) { -- T t0 = (GameRules.GameRuleValue) this.rules.get(gamerules_gamerulekey); -+ T t0 = (T) this.rules.get(gamerules_gamerulekey); // CraftBukkit - decompile error - - if (t0 == null) { - throw new IllegalArgumentException("Tried to access invalid game rule"); -@@ -184,7 +184,7 @@ + public static > Codec> keyCodec(Class oclass) { + return Codec.STRING.comapFlatMap((s) -> { +- return (DataResult) GameRules.GAME_RULE_TYPES.entrySet().stream().filter((entry) -> { ++ return GameRules.GAME_RULE_TYPES.entrySet().stream().filter((entry) -> { // CraftBukkit - decompile error + return ((GameRules.GameRuleDefinition) entry.getValue()).valueClass == oclass; + }).map(Entry::getKey).filter((gamerules_gamerulekey) -> { + return gamerules_gamerulekey.getId().equals(s); + }).map((gamerules_gamerulekey) -> { +- return gamerules_gamerulekey; ++ return (GameRules.GameRuleKey) gamerules_gamerulekey; // CraftBukkit - decompile error + }).findFirst().map(DataResult::success).orElseGet(() -> { + return DataResult.error(() -> { + return "Invalid game rule ID for type: " + s; +@@ -195,7 +195,7 @@ private void loadFromTag(DynamicLike dynamiclike) { this.rules.forEach((gamerules_gamerulekey, gamerules_gamerulevalue) -> { @@ -54,7 +60,7 @@ Objects.requireNonNull(gamerules_gamerulevalue); dataresult.ifSuccess(gamerules_gamerulevalue::deserialize); -@@ -205,19 +205,19 @@ +@@ -216,19 +216,19 @@ private > void callVisitorCap(GameRules.GameRuleVisitor gamerules_gamerulevisitor, GameRules.GameRuleKey gamerules_gamerulekey, GameRules.GameRuleDefinition gamerules_gameruledefinition) { if (gamerules_gameruledefinition.requiredFeatures.isSubsetOf(this.enabledFeatures)) { @@ -78,30 +84,22 @@ T t0 = gamerules.getRule(gamerules_gamerulekey); this.getRule(gamerules_gamerulekey).setFrom(t0, minecraftserver); -@@ -285,11 +285,11 @@ +@@ -305,12 +305,12 @@ final Supplier> argument; private final Function, T> constructor; - final BiConsumer callback; + final BiConsumer callback; // CraftBukkit - per-world private final GameRules.h visitorCaller; + final Class valueClass; final FeatureFlagSet requiredFeatures; -- GameRuleDefinition(Supplier> supplier, Function, T> function, BiConsumer biconsumer, GameRules.h gamerules_h, FeatureFlagSet featureflagset) { -+ GameRuleDefinition(Supplier> supplier, Function, T> function, BiConsumer biconsumer, GameRules.h gamerules_h, FeatureFlagSet featureflagset) { // CraftBukkit - per-world +- GameRuleDefinition(Supplier> supplier, Function, T> function, BiConsumer biconsumer, GameRules.h gamerules_h, Class oclass, FeatureFlagSet featureflagset) { ++ GameRuleDefinition(Supplier> supplier, Function, T> function, BiConsumer biconsumer, GameRules.h gamerules_h, Class oclass, FeatureFlagSet featureflagset) { // CraftBukkit - per-world this.argument = supplier; this.constructor = function; this.callback = biconsumer; -@@ -302,7 +302,7 @@ - } - - public T createRule() { -- return (GameRules.GameRuleValue) this.constructor.apply(this); -+ return this.constructor.apply(this); // CraftBukkit - decompile error - } - - public void callVisitor(GameRules.GameRuleVisitor gamerules_gamerulevisitor, GameRules.GameRuleKey gamerules_gamerulekey) { -@@ -326,17 +326,17 @@ +@@ -348,17 +348,17 @@ public void setFromArgument(CommandContext commandcontext, String s) { this.updateFromArgument(commandcontext, s); @@ -122,7 +120,7 @@ public abstract String serialize(); -@@ -350,7 +350,7 @@ +@@ -372,20 +372,20 @@ protected abstract T copy(); @@ -130,60 +128,23 @@ + public abstract void setFrom(T t0, @Nullable WorldServer minecraftserver); // CraftBukkit - per-world } - public interface GameRuleVisitor { -@@ -366,7 +366,7 @@ - - private boolean value; - -- static GameRules.GameRuleDefinition create(boolean flag, BiConsumer biconsumer) { -+ static GameRules.GameRuleDefinition create(boolean flag, BiConsumer biconsumer) { // CraftBukkit - per-world - return new GameRules.GameRuleDefinition<>(BoolArgumentType::bool, (gamerules_gameruledefinition) -> { - return new GameRules.GameRuleBoolean(gamerules_gameruledefinition, flag); - }, biconsumer, GameRules.GameRuleVisitor::visitBoolean, FeatureFlagSet.of()); -@@ -391,7 +391,7 @@ - return this.value; - } - -- public void set(boolean flag, @Nullable MinecraftServer minecraftserver) { -+ public void set(boolean flag, @Nullable WorldServer minecraftserver) { // CraftBukkit - per-world - this.value = flag; - this.onChanged(minecraftserver); - } -@@ -402,7 +402,7 @@ - } - - @Override -- protected void deserialize(String s) { -+ public void deserialize(String s) { // PAIL - protected->public - this.value = Boolean.parseBoolean(s); - } - -@@ -421,7 +421,7 @@ - return new GameRules.GameRuleBoolean(this.type, this.value); - } - -- public void setFrom(GameRules.GameRuleBoolean gamerules_gameruleboolean, @Nullable MinecraftServer minecraftserver) { -+ public void setFrom(GameRules.GameRuleBoolean gamerules_gameruleboolean, @Nullable WorldServer minecraftserver) { // CraftBukkit - per-world - this.value = gamerules_gameruleboolean.value; - this.onChanged(minecraftserver); - } -@@ -431,13 +431,13 @@ + public static class GameRuleInt extends GameRules.GameRuleValue { private int value; - private static GameRules.GameRuleDefinition create(int i, BiConsumer biconsumer) { + private static GameRules.GameRuleDefinition create(int i, BiConsumer biconsumer) { // CraftBukkit - per-world - return new GameRules.GameRuleDefinition<>(IntegerArgumentType::integer, (gamerules_gameruledefinition) -> { + return new GameRules.GameRuleDefinition(IntegerArgumentType::integer, (gamerules_gameruledefinition) -> { return new GameRules.GameRuleInt(gamerules_gameruledefinition, i); - }, biconsumer, GameRules.GameRuleVisitor::visitInteger, FeatureFlagSet.of()); + }, biconsumer, GameRules.GameRuleVisitor::visitInteger, GameRules.GameRuleInt.class, FeatureFlagSet.of()); } - static GameRules.GameRuleDefinition create(int i, int j, int k, FeatureFlagSet featureflagset, BiConsumer biconsumer) { + static GameRules.GameRuleDefinition create(int i, int j, int k, FeatureFlagSet featureflagset, BiConsumer biconsumer) { // CraftBukkit - per-world - return new GameRules.GameRuleDefinition<>(() -> { + return new GameRules.GameRuleDefinition(() -> { return IntegerArgumentType.integer(j, k); }, (gamerules_gameruledefinition) -> { -@@ -464,7 +464,7 @@ +@@ -412,7 +412,7 @@ return this.value; } @@ -192,7 +153,7 @@ this.value = i; this.onChanged(minecraftserver); } -@@ -475,7 +475,7 @@ +@@ -423,7 +423,7 @@ } @Override @@ -201,7 +162,7 @@ this.value = safeParse(s); } -@@ -517,7 +517,7 @@ +@@ -465,7 +465,7 @@ return new GameRules.GameRuleInt(this.type, this.value); } @@ -210,3 +171,39 @@ this.value = gamerules_gameruleint.value; this.onChanged(minecraftserver); } +@@ -475,7 +475,7 @@ + + private boolean value; + +- static GameRules.GameRuleDefinition create(boolean flag, BiConsumer biconsumer) { ++ static GameRules.GameRuleDefinition create(boolean flag, BiConsumer biconsumer) { // CraftBukkit - per-world + return new GameRules.GameRuleDefinition(BoolArgumentType::bool, (gamerules_gameruledefinition) -> { + return new GameRules.GameRuleBoolean(gamerules_gameruledefinition, flag); + }, biconsumer, GameRules.GameRuleVisitor::visitBoolean, GameRules.GameRuleBoolean.class, FeatureFlagSet.of()); +@@ -500,7 +500,7 @@ + return this.value; + } + +- public void set(boolean flag, @Nullable MinecraftServer minecraftserver) { ++ public void set(boolean flag, @Nullable WorldServer minecraftserver) { // CraftBukkit - per-world + this.value = flag; + this.onChanged(minecraftserver); + } +@@ -511,7 +511,7 @@ + } + + @Override +- protected void deserialize(String s) { ++ public void deserialize(String s) { // PAIL - protected->public + this.value = Boolean.parseBoolean(s); + } + +@@ -530,7 +530,7 @@ + return new GameRules.GameRuleBoolean(this.type, this.value); + } + +- public void setFrom(GameRules.GameRuleBoolean gamerules_gameruleboolean, @Nullable MinecraftServer minecraftserver) { ++ public void setFrom(GameRules.GameRuleBoolean gamerules_gameruleboolean, @Nullable WorldServer minecraftserver) { // CraftBukkit - per-world + this.value = gamerules_gameruleboolean.value; + this.onChanged(minecraftserver); + } diff --git a/nms-patches/net/minecraft/world/level/GeneratorAccess.patch b/nms-patches/net/minecraft/world/level/GeneratorAccess.patch index ff57d08fb..3c63126e2 100644 --- a/nms-patches/net/minecraft/world/level/GeneratorAccess.patch +++ b/nms-patches/net/minecraft/world/level/GeneratorAccess.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/GeneratorAccess.java +++ b/net/minecraft/world/level/GeneratorAccess.java -@@ -101,4 +101,6 @@ +@@ -100,4 +100,6 @@ default void gameEvent(ResourceKey resourcekey, BlockPosition blockposition, GameEvent.a gameevent_a) { - this.gameEvent((Holder) this.registryAccess().lookupOrThrow(Registries.GAME_EVENT).getOrThrow(resourcekey), blockposition, gameevent_a); + this.gameEvent(this.registryAccess().lookupOrThrow(Registries.GAME_EVENT).getOrThrow(resourcekey), blockposition, gameevent_a); } + + net.minecraft.server.level.WorldServer getMinecraftWorld(); // CraftBukkit diff --git a/nms-patches/net/minecraft/world/level/IBlockAccess.patch b/nms-patches/net/minecraft/world/level/IBlockAccess.patch index 0e30f8b40..fcdd4d43e 100644 --- a/nms-patches/net/minecraft/world/level/IBlockAccess.patch +++ b/nms-patches/net/minecraft/world/level/IBlockAccess.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/IBlockAccess.java +++ b/net/minecraft/world/level/IBlockAccess.java -@@ -31,7 +31,7 @@ +@@ -30,7 +30,7 @@ default Optional getBlockEntity(BlockPosition blockposition, TileEntityTypes tileentitytypes) { TileEntity tileentity = this.getBlockEntity(blockposition); @@ -9,7 +9,7 @@ } IBlockData getBlockState(BlockPosition blockposition); -@@ -59,8 +59,8 @@ +@@ -58,8 +58,8 @@ }); } @@ -20,7 +20,7 @@ IBlockData iblockdata = this.getBlockState(blockposition); Fluid fluid = this.getFluidState(blockposition); Vec3D vec3d = raytrace1.getFrom(); -@@ -73,6 +73,12 @@ +@@ -72,6 +72,12 @@ double d1 = movingobjectpositionblock1 == null ? Double.MAX_VALUE : raytrace1.getFrom().distanceToSqr(movingobjectpositionblock1.getLocation()); return d0 <= d1 ? movingobjectpositionblock : movingobjectpositionblock1; @@ -33,12 +33,3 @@ }, (raytrace1) -> { Vec3D vec3d = raytrace1.getFrom().subtract(raytrace1.getTo()); -@@ -145,7 +151,7 @@ - double d13 = d10 * (i1 > 0 ? 1.0D - MathHelper.frac(d4) : MathHelper.frac(d4)); - double d14 = d11 * (j1 > 0 ? 1.0D - MathHelper.frac(d5) : MathHelper.frac(d5)); - -- Object object; -+ T object; // CraftBukkit - decompile error - - do { - if (d12 > 1.0D && d13 > 1.0D && d14 > 1.0D) { diff --git a/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch b/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch index 7e6badc7e..bee8a7f79 100644 --- a/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch +++ b/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/MobSpawnerAbstract.java +++ b/net/minecraft/world/level/MobSpawnerAbstract.java -@@ -54,6 +54,7 @@ +@@ -55,6 +55,7 @@ public void setEntityId(EntityTypes entitytypes, @Nullable World world, RandomSource randomsource, BlockPosition blockposition) { this.getOrCreateNextSpawnData(world, randomsource, blockposition).getEntityToSpawn().putString("id", BuiltInRegistries.ENTITY_TYPE.getKey(entitytypes).toString()); -+ this.spawnPotentials = SimpleWeightedRandomList.empty(); // CraftBukkit - SPIGOT-3496, MC-92282 ++ this.spawnPotentials = WeightedList.of(); // CraftBukkit - SPIGOT-3496, MC-92282 } private boolean isNearPlayer(World world, BlockPosition blockposition) { -@@ -157,13 +158,18 @@ +@@ -156,13 +157,18 @@ ((EntityInsentient) entity).finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.SPAWNER, (GroupDataEntity) null); } diff --git a/nms-patches/net/minecraft/world/level/ServerExplosion.patch b/nms-patches/net/minecraft/world/level/ServerExplosion.patch index d118a865e..6f42c63f3 100644 --- a/nms-patches/net/minecraft/world/level/ServerExplosion.patch +++ b/nms-patches/net/minecraft/world/level/ServerExplosion.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -35,6 +35,13 @@ +@@ -34,6 +34,13 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.Vec3D; @@ -14,7 +14,7 @@ public class ServerExplosion implements Explosion { private static final ExplosionDamageCalculator EXPLOSION_DAMAGE_CALCULATOR = new ExplosionDamageCalculator(); -@@ -50,16 +57,21 @@ +@@ -49,16 +56,21 @@ private final DamageSource damageSource; private final ExplosionDamageCalculator damageCalculator; private final Map hitPlayers = new HashMap(); @@ -37,7 +37,19 @@ } private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) { -@@ -195,7 +207,35 @@ +@@ -171,7 +183,10 @@ + int i1 = MathHelper.floor(this.center.z - (double) f - 1.0D); + int j1 = MathHelper.floor(this.center.z + (double) f + 1.0D); + +- for (Entity entity : this.level.getEntities(this.source, new AxisAlignedBB((double) i, (double) k, (double) i1, (double) j, (double) l, (double) j1))) { ++ // CraftBukkit start ++ List list = this.level.getEntities(this.source, new AxisAlignedBB((double) i, (double) k, (double) i1, (double) j, (double) l, (double) j1)); ++ for (Entity entity :list) { ++ // CraftBukkit end + if (!entity.ignoreExplosion(this)) { + double d0 = Math.sqrt(entity.distanceToSqr(this.center)) / (double) f; + +@@ -190,7 +205,35 @@ float f2 = !flag && f1 == 0.0F ? 0.0F : getSeenPercent(this.center, entity); if (flag) { @@ -74,7 +86,7 @@ } double d5 = (1.0D - d0) * (double) f2 * (double) f1; -@@ -214,6 +254,17 @@ +@@ -209,6 +252,17 @@ d3 *= d6; Vec3D vec3d = new Vec3D(d1, d2, d3); @@ -92,7 +104,7 @@ entity.push(vec3d); if (entity instanceof EntityHuman) { EntityHuman entityhuman = (EntityHuman) entity; -@@ -235,10 +286,31 @@ +@@ -230,8 +284,30 @@ List list1 = new ArrayList(); SystemUtils.shuffle(list, this.level.random); @@ -106,10 +118,8 @@ + return; + } + // CraftBukkit end - Iterator iterator = list.iterator(); - while (iterator.hasNext()) { - BlockPosition blockposition = (BlockPosition) iterator.next(); + for (BlockPosition blockposition : list) { + // CraftBukkit start - TNTPrimeEvent + IBlockData iblockdata = this.level.getBlockState(blockposition); + Block block = iblockdata.getBlock(); @@ -121,12 +131,13 @@ + } + } + // CraftBukkit end - ++ this.level.getBlockState(blockposition).onExplosionHit(this.level, blockposition, this, (itemstack, blockposition1) -> { addOrAppendStack(list1, itemstack, blockposition1); -@@ -262,13 +334,22 @@ - BlockPosition blockposition = (BlockPosition) iterator.next(); - + }); +@@ -246,13 +322,22 @@ + private void createFire(List list) { + for (BlockPosition blockposition : list) { if (this.level.random.nextInt(3) == 0 && this.level.getBlockState(blockposition).isAir() && this.level.getBlockState(blockposition.below()).isSolidRender()) { - this.level.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(this.level, blockposition)); + // CraftBukkit start - Ignition by explosion @@ -148,7 +159,7 @@ this.level.gameEvent(this.source, (Holder) GameEvent.EXPLODE, this.center); List list = this.calculateExplodedPositions(); -@@ -279,7 +360,15 @@ +@@ -263,7 +348,15 @@ gameprofilerfiller.push("explosion_blocks"); this.interactWithBlocks(list); gameprofilerfiller.pop(); @@ -164,11 +175,11 @@ if (this.fire) { this.createFire(list); -@@ -288,6 +377,7 @@ +@@ -272,6 +365,7 @@ } private static void addOrAppendStack(List list, ItemStack itemstack, BlockPosition blockposition) { + if (itemstack.isEmpty()) return; // CraftBukkit - SPIGOT-5425 - Iterator iterator = list.iterator(); - - do { + for (ServerExplosion.a serverexplosion_a : list) { + serverexplosion_a.tryMerge(itemstack); + if (itemstack.isEmpty()) { diff --git a/nms-patches/net/minecraft/world/level/SpawnerCreature.patch b/nms-patches/net/minecraft/world/level/SpawnerCreature.patch index d2b2e265e..c11115930 100644 --- a/nms-patches/net/minecraft/world/level/SpawnerCreature.patch +++ b/nms-patches/net/minecraft/world/level/SpawnerCreature.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/SpawnerCreature.java +++ b/net/minecraft/world/level/SpawnerCreature.java -@@ -50,6 +50,13 @@ +@@ -49,6 +49,13 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -14,7 +14,7 @@ public final class SpawnerCreature { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -107,15 +114,31 @@ +@@ -104,11 +111,28 @@ return (BiomeBase) ichunkaccess.getNoiseBiome(QuartPos.fromBlock(blockposition.getX()), QuartPos.fromBlock(blockposition.getY()), QuartPos.fromBlock(blockposition.getZ())).value(); } @@ -24,11 +24,9 @@ + WorldData worlddata = worldserver.getLevelData(); // CraftBukkit - Other mob type spawn tick rate + // CraftBukkit end List list = new ArrayList(SpawnerCreature.SPAWNING_CATEGORIES.length); - EnumCreatureType[] aenumcreaturetype = SpawnerCreature.SPAWNING_CATEGORIES; - int i = aenumcreaturetype.length; - for (int j = 0; j < i; ++j) { - EnumCreatureType enumcreaturetype = aenumcreaturetype[j]; + for (EnumCreatureType enumcreaturetype : SpawnerCreature.SPAWNING_CATEGORIES) { +- if ((flag || !enumcreaturetype.isFriendly()) && (flag1 || enumcreaturetype.isFriendly()) && (flag2 || !enumcreaturetype.isPersistent()) && spawnercreature_d.canSpawnForCategoryGlobal(enumcreaturetype)) { + // CraftBukkit start - Use per-world spawn limits + boolean spawnThisTick = true; + int limit = enumcreaturetype.getMaxInstancesPerChunk(); @@ -37,8 +35,7 @@ + spawnThisTick = worldserver.ticksPerSpawnCategory.getLong(spawnCategory) != 0 && worlddata.getGameTime() % worldserver.ticksPerSpawnCategory.getLong(spawnCategory) == 0; + limit = worldserver.getWorld().getSpawnLimit(spawnCategory); + } - -- if ((flag || !enumcreaturetype.isFriendly()) && (flag1 || enumcreaturetype.isFriendly()) && (flag2 || !enumcreaturetype.isPersistent()) && spawnercreature_d.canSpawnForCategoryGlobal(enumcreaturetype)) { ++ + if (!spawnThisTick || limit == 0) { + continue; + } @@ -48,27 +45,27 @@ list.add(enumcreaturetype); } } -@@ -217,10 +240,15 @@ - entityinsentient.moveTo(d0, (double) i, d1, worldserver.random.nextFloat() * 360.0F, 0.0F); - if (isValidPositionForMob(worldserver, entityinsentient, d2)) { - groupdataentity = entityinsentient.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityinsentient.blockPosition()), EntitySpawnReason.NATURAL, groupdataentity); -- ++j; -- ++k1; -- worldserver.addFreshEntityWithPassengers(entityinsentient); -- spawnercreature_a.run(entityinsentient, ichunkaccess); -+ // 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. -+ worldserver.addFreshEntityWithPassengers(entityinsentient, (entityinsentient instanceof net.minecraft.world.entity.animal.EntityOcelot && !((org.bukkit.entity.Ageable) entityinsentient.getBukkitEntity()).isAdult()) ? SpawnReason.OCELOT_BABY : SpawnReason.NATURAL); -+ if (!entityinsentient.isRemoved()) { -+ ++j; -+ ++k1; -+ spawnercreature_a.run(entityinsentient, ichunkaccess); -+ } -+ // CraftBukkit end - if (j >= entityinsentient.getMaxSpawnClusterSize()) { - return; - } -@@ -369,7 +397,7 @@ +@@ -202,10 +226,15 @@ + entityinsentient.snapTo(d0, (double) i, d1, worldserver.random.nextFloat() * 360.0F, 0.0F); + if (isValidPositionForMob(worldserver, entityinsentient, d2)) { + groupdataentity = entityinsentient.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityinsentient.blockPosition()), EntitySpawnReason.NATURAL, groupdataentity); +- ++j; +- ++l1; +- worldserver.addFreshEntityWithPassengers(entityinsentient); +- spawnercreature_a.run(entityinsentient, ichunkaccess); ++ // 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. ++ worldserver.addFreshEntityWithPassengers(entityinsentient, (entityinsentient instanceof net.minecraft.world.entity.animal.EntityOcelot && !((org.bukkit.entity.Ageable) entityinsentient.getBukkitEntity()).isAdult()) ? SpawnReason.OCELOT_BABY : SpawnReason.NATURAL); ++ if (!entityinsentient.isRemoved()) { ++ ++j; ++ ++l1; ++ spawnercreature_a.run(entityinsentient, ichunkaccess); ++ } ++ // CraftBukkit end + if (j >= entityinsentient.getMaxSpawnClusterSize()) { + return; + } +@@ -354,7 +383,7 @@ if (entityinsentient.checkSpawnRules(worldaccess, EntitySpawnReason.CHUNK_GENERATION) && entityinsentient.checkSpawnObstruction(worldaccess)) { groupdataentity = entityinsentient.finalizeSpawn(worldaccess, worldaccess.getCurrentDifficultyAt(entityinsentient.blockPosition()), EntitySpawnReason.CHUNK_GENERATION, groupdataentity); @@ -77,7 +74,7 @@ flag = true; } } -@@ -482,8 +510,10 @@ +@@ -461,8 +490,10 @@ return this.unmodifiableMobCategoryCounts; } diff --git a/nms-patches/net/minecraft/world/level/TicketStorage.patch b/nms-patches/net/minecraft/world/level/TicketStorage.patch new file mode 100644 index 000000000..8f869deb8 --- /dev/null +++ b/nms-patches/net/minecraft/world/level/TicketStorage.patch @@ -0,0 +1,58 @@ +--- a/net/minecraft/world/level/TicketStorage.java ++++ b/net/minecraft/world/level/TicketStorage.java +@@ -28,6 +28,10 @@ + import net.minecraft.world.level.saveddata.SavedDataType; + import org.slf4j.Logger; + ++// CraftBukkit start ++import java.util.Objects; ++// CraftBukkit end ++ + public class TicketStorage extends PersistentBase { + + private static final int INITIAL_TICKET_LIST_CAPACITY = 4; +@@ -95,7 +99,7 @@ + Long2ObjectMap.Entry> long2objectmap_entry = (Entry) objectiterator.next(); + ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(long2objectmap_entry.getLongKey()); + +- for (Ticket ticket : (List) long2objectmap_entry.getValue()) { ++ for (Ticket ticket : long2objectmap_entry.getValue()) { // CraftBukkit - decompile error + biconsumer.accept(chunkcoordintpair, ticket); + } + } +@@ -108,7 +112,7 @@ + while (objectiterator.hasNext()) { + Long2ObjectMap.Entry> long2objectmap_entry = (Entry) objectiterator.next(); + +- for (Ticket ticket : (List) long2objectmap_entry.getValue()) { ++ for (Ticket ticket : long2objectmap_entry.getValue()) { // CraftBukkit - decompile error + this.addTicket(long2objectmap_entry.getLongKey(), ticket); + } + } +@@ -180,7 +184,7 @@ + } + + private static boolean isTicketSameTypeAndLevel(Ticket ticket, Ticket ticket1) { +- return ticket1.getType() == ticket.getType() && ticket1.getTicketLevel() == ticket.getTicketLevel(); ++ return ticket1.getType() == ticket.getType() && ticket1.getTicketLevel() == ticket.getTicketLevel() && Objects.equals(ticket.key, ticket1.key); // CraftBukkit + } + + public int getTicketLevelAt(long i, boolean flag) { +@@ -361,7 +365,7 @@ + while (objectiterator.hasNext()) { + Long2ObjectMap.Entry> long2objectmap_entry = (Entry) objectiterator.next(); + +- for (Ticket ticket : (List) long2objectmap_entry.getValue()) { ++ for (Ticket ticket : long2objectmap_entry.getValue()) { // CraftBukkit - decompile error + if (ticket.getType() == tickettype) { + list.add(Pair.of(ticket, long2objectmap_entry.getLongKey())); + } +@@ -397,7 +401,7 @@ + while (objectiterator.hasNext()) { + Long2ObjectMap.Entry> long2objectmap_entry = (Entry) objectiterator.next(); + +- for (Ticket ticket : (List) long2objectmap_entry.getValue()) { ++ for (Ticket ticket : long2objectmap_entry.getValue()) { // CraftBukkit - decompile error + if (predicate.test(ticket)) { + longopenhashset.add(long2objectmap_entry.getLongKey()); + break; diff --git a/nms-patches/net/minecraft/world/level/World.patch b/nms-patches/net/minecraft/world/level/World.patch index 37e1193dd..cdc3c3d3f 100644 --- a/nms-patches/net/minecraft/world/level/World.patch +++ b/nms-patches/net/minecraft/world/level/World.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/World.java +++ b/net/minecraft/world/level/World.java -@@ -81,6 +81,28 @@ +@@ -85,6 +85,28 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.scores.Scoreboard; @@ -26,10 +26,10 @@ +import org.bukkit.event.block.BlockPhysicsEvent; +// CraftBukkit end + - public abstract class World implements GeneratorAccess, AutoCloseable { + public abstract class World implements GeneratorAccess, UUIDLookup, AutoCloseable { public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); -@@ -121,7 +143,42 @@ +@@ -125,7 +147,42 @@ private final DamageSources damageSources; private long subTickCount; @@ -72,13 +72,9 @@ + // CraftBukkit end this.levelData = worlddatamutable; this.dimensionTypeRegistration = holder; - final DimensionManager dimensionmanager = (DimensionManager) holder.value(); -@@ -129,15 +186,15 @@ - this.dimension = resourcekey; - this.isClientSide = flag; - if (dimensionmanager.coordinateScale() != 1.0D) { -- this.worldBorder = new WorldBorder(this) { -+ this.worldBorder = new WorldBorder() { // CraftBukkit - decompile error + final DimensionManager dimensionmanager = holder.value(); +@@ -136,12 +193,12 @@ + this.worldBorder = new WorldBorder() { @Override public double getCenterX() { - return super.getCenterX() / dimensionmanager.coordinateScale(); @@ -92,7 +88,7 @@ } }; } else { -@@ -150,6 +207,42 @@ +@@ -154,6 +211,42 @@ this.neighborUpdater = new CollectingNeighborUpdater(this, j); this.registryAccess = iregistrycustom; this.damageSources = new DamageSources(iregistrycustom); @@ -135,7 +131,7 @@ } @Override -@@ -207,6 +300,18 @@ +@@ -211,6 +304,18 @@ @Override public boolean setBlock(BlockPosition blockposition, IBlockData iblockdata, int i, int j) { @@ -154,11 +150,10 @@ if (this.isOutsideBuildHeight(blockposition)) { return false; } else if (!this.isClientSide && this.isDebug()) { -@@ -214,13 +319,29 @@ +@@ -218,13 +323,29 @@ } else { Chunk chunk = this.getChunkAt(blockposition); Block block = iblockdata.getBlock(); -- IBlockData iblockdata1 = chunk.setBlockState(blockposition, iblockdata, (i & 64) != 0); + + // CraftBukkit start - capture blockstates + boolean captured = false; @@ -169,7 +164,7 @@ + } + // CraftBukkit end + -+ IBlockData iblockdata1 = chunk.setBlockState(blockposition, iblockdata, (i & 64) != 0, (i & 1024) == 0); // CraftBukkit custom NO_PLACE flag + IBlockData iblockdata1 = chunk.setBlockState(blockposition, iblockdata, i); if (iblockdata1 == null) { + // CraftBukkit start - remove blockstate if failed (or the same) @@ -185,9 +180,9 @@ if (iblockdata2 == iblockdata) { if (iblockdata1 != iblockdata2) { this.setBlocksDirty(blockposition, iblockdata1, iblockdata2); -@@ -247,12 +368,69 @@ +@@ -251,12 +372,69 @@ - this.onBlockStateChange(blockposition, iblockdata1, iblockdata2); + this.updatePOIOnBlockStateChange(blockposition, iblockdata1, iblockdata2); } + */ + @@ -218,9 +213,9 @@ + } + + if ((i & 1) != 0) { -+ this.blockUpdated(blockposition, iblockdata1.getBlock()); ++ this.updateNeighborsAt(blockposition, iblockdata1.getBlock()); + if (!this.isClientSide && iblockdata.hasAnalogOutputSignal()) { -+ this.updateNeighbourForOutputSignal(blockposition, newBlock.getBlock()); ++ this.updateNeighborsAt(blockposition, newBlock.getBlock()); + } + } + @@ -245,17 +240,17 @@ + + // CraftBukkit start - SPIGOT-5710 + if (!preventPoiUpdated) { -+ this.onBlockStateChange(blockposition, iblockdata1, iblockdata2); ++ this.updatePOIOnBlockStateChange(blockposition, iblockdata1, iblockdata2); + } + // CraftBukkit end + } + } + // CraftBukkit end + - public void onBlockStateChange(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {} + public void updatePOIOnBlockStateChange(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {} @Override -@@ -340,6 +518,14 @@ +@@ -342,6 +520,14 @@ @Override public IBlockData getBlockState(BlockPosition blockposition) { @@ -270,7 +265,7 @@ if (this.isOutsideBuildHeight(blockposition)) { return Blocks.VOID_AIR.defaultBlockState(); } else { -@@ -510,6 +696,16 @@ +@@ -512,6 +698,16 @@ @Nullable @Override public TileEntity getBlockEntity(BlockPosition blockposition) { @@ -287,7 +282,7 @@ return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, Chunk.EnumTileEntityState.IMMEDIATE)); } -@@ -517,6 +713,12 @@ +@@ -519,6 +715,12 @@ BlockPosition blockposition = tileentity.getBlockPos(); if (!this.isOutsideBuildHeight(blockposition)) { @@ -300,21 +295,12 @@ this.getChunkAt(blockposition).addAndRegisterBlockEntity(tileentity); } } -@@ -643,7 +845,7 @@ - - for (int k = 0; k < j; ++k) { - EntityComplexPart entitycomplexpart = aentitycomplexpart[k]; -- T t0 = (Entity) entitytypetest.tryCast(entitycomplexpart); -+ T t0 = entitytypetest.tryCast(entitycomplexpart); // CraftBukkit - decompile error - - if (t0 != null && predicate.test(t0)) { - list.add(t0); -@@ -912,7 +1114,7 @@ +@@ -915,7 +1117,7 @@ public static enum a implements INamable { - NONE("none"), BLOCK("block"), MOB("mob"), TNT("tnt"), TRIGGER("trigger"); + NONE("none"), BLOCK("block"), MOB("mob"), TNT("tnt"), TRIGGER("trigger"), STANDARD("standard"); // CraftBukkit - Add STANDARD which will always use Explosion.Effect.DESTROY - public static final Codec CODEC = INamable.fromEnum(World.a::values); + public static final Codec CODEC = INamable.fromEnum(World.a::values); private final String id; diff --git a/nms-patches/net/minecraft/world/level/block/BigDripleafBlock.patch b/nms-patches/net/minecraft/world/level/block/BigDripleafBlock.patch index 791bcfe2c..b6294faf4 100644 --- a/nms-patches/net/minecraft/world/level/block/BigDripleafBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/BigDripleafBlock.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/world/level/block/BigDripleafBlock.java +++ b/net/minecraft/world/level/block/BigDripleafBlock.java -@@ -45,6 +45,11 @@ +@@ -46,6 +46,12 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; +// CraftBukkit start ++import net.minecraft.world.entity.player.EntityHuman; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.EntityInteractEvent; +// CraftBukkit end @@ -12,7 +13,7 @@ public class BigDripleafBlock extends BlockFacingHorizontal implements IBlockFragilePlantElement, IBlockWaterlogged { public static final MapCodec CODEC = simpleCodec(BigDripleafBlock::new); -@@ -119,7 +124,7 @@ +@@ -121,7 +127,7 @@ @Override protected void onProjectileHit(World world, IBlockData iblockdata, MovingObjectPositionBlock movingobjectpositionblock, IProjectile iprojectile) { @@ -21,8 +22,8 @@ } @Override -@@ -178,7 +183,20 @@ - protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { +@@ -180,7 +186,20 @@ + protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity, InsideBlockEffectApplier insideblockeffectapplier) { if (!world.isClientSide) { if (iblockdata.getValue(BigDripleafBlock.TILT) == Tilt.NONE && canEntityTilt(blockposition, entity) && !world.hasNeighborSignal(blockposition)) { - this.setTiltAndScheduleTick(iblockdata, world, blockposition, Tilt.UNSTABLE, (SoundEffect) null); @@ -43,7 +44,7 @@ } } -@@ -192,9 +210,9 @@ +@@ -194,9 +213,9 @@ Tilt tilt = (Tilt) iblockdata.getValue(BigDripleafBlock.TILT); if (tilt == Tilt.UNSTABLE) { @@ -55,7 +56,7 @@ } else if (tilt == Tilt.FULL) { resetTilt(iblockdata, worldserver, blockposition); } -@@ -220,8 +238,10 @@ +@@ -222,8 +241,10 @@ return entity.onGround() && entity.position().y > (double) ((float) blockposition.getY() + 0.6875F); } @@ -68,7 +69,7 @@ if (soundeffect != null) { playTiltSound(world, blockposition, soundeffect); } -@@ -235,14 +255,21 @@ +@@ -237,14 +258,21 @@ } private static void resetTilt(IBlockData iblockdata, World world, BlockPosition blockposition) { @@ -92,7 +93,7 @@ Tilt tilt1 = (Tilt) iblockdata.getValue(BigDripleafBlock.TILT); world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BigDripleafBlock.TILT, tilt), 2); -@@ -250,6 +277,7 @@ +@@ -252,6 +280,7 @@ world.gameEvent((Entity) null, (Holder) GameEvent.BLOCK_CHANGE, blockposition); } diff --git a/nms-patches/net/minecraft/world/level/block/Block.patch b/nms-patches/net/minecraft/world/level/block/Block.patch index 883f50836..19469e203 100644 --- a/nms-patches/net/minecraft/world/level/block/Block.patch +++ b/nms-patches/net/minecraft/world/level/block/Block.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -340,7 +340,13 @@ +@@ -384,7 +384,13 @@ EntityItem entityitem = (EntityItem) supplier.get(); entityitem.setDefaultPickUpDelay(); @@ -15,7 +15,7 @@ return; } } -@@ -369,7 +375,7 @@ +@@ -413,7 +419,7 @@ public void playerDestroy(World world, EntityHuman entityhuman, BlockPosition blockposition, IBlockData iblockdata, @Nullable TileEntity tileentity, ItemStack itemstack) { entityhuman.awardStat(StatisticList.BLOCK_MINED.get(this)); @@ -24,7 +24,16 @@ dropResources(iblockdata, world, blockposition, tileentity, entityhuman, itemstack); } -@@ -490,15 +496,23 @@ +@@ -520,7 +526,7 @@ + } + + protected Function getShapeForEachState(Function function) { +- ImmutableMap immutablemap = (ImmutableMap) this.stateDefinition.getPossibleStates().stream().collect(ImmutableMap.toImmutableMap(Function.identity(), function)); ++ ImmutableMap immutablemap = (ImmutableMap) this.stateDefinition.getPossibleStates().stream().collect(ImmutableMap.toImmutableMap(Function.identity(), function)); // CraftBukkit - decompile error + + Objects.requireNonNull(immutablemap); + return immutablemap::get; +@@ -557,14 +563,22 @@ return this.builtInRegistryHolder; } @@ -40,13 +49,12 @@ } + return 0; - } - ++ } ++ + public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) { + return 0; -+ } + } + // CraftBukkit end -+ + private static record a(VoxelShape first, VoxelShape second) { - public boolean equals(Object object) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch b/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch index b18e8d371..4f6c2e6d6 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockBamboo.java +++ b/net/minecraft/world/level/block/BlockBamboo.java -@@ -183,7 +183,7 @@ +@@ -174,7 +174,7 @@ BlockPosition blockposition1 = blockposition.above(i); IBlockData iblockdata1 = worldserver.getBlockState(blockposition1); @@ -9,7 +9,7 @@ return; } -@@ -204,14 +204,18 @@ +@@ -190,14 +190,18 @@ BlockPosition blockposition1 = blockposition.below(2); IBlockData iblockdata2 = world.getBlockState(blockposition1); BlockPropertyBambooSize blockpropertybamboosize = BlockPropertyBambooSize.NONE; @@ -30,7 +30,7 @@ } } } else { -@@ -222,7 +226,14 @@ +@@ -208,7 +212,14 @@ int j = (Integer) iblockdata.getValue(BlockBamboo.AGE) != 1 && !iblockdata2.is(Blocks.BAMBOO) ? 0 : 1; int k = (i < 11 || randomsource.nextFloat() >= 0.25F) && i != 15 ? 0 : 1; diff --git a/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch b/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch index 9bfc7a5cb..c49225191 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockBambooSapling.java +++ b/net/minecraft/world/level/block/BlockBambooSapling.java -@@ -87,6 +87,6 @@ +@@ -76,6 +76,6 @@ } protected void growBamboo(World world, BlockPosition blockposition) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockBed.patch b/nms-patches/net/minecraft/world/level/block/BlockBed.patch index cbeb65ab0..3f540830b 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockBed.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockBed.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockBed.java +++ b/net/minecraft/world/level/block/BlockBed.java -@@ -95,7 +95,8 @@ +@@ -94,7 +94,8 @@ } } @@ -10,7 +10,7 @@ world.removeBlock(blockposition, false); BlockPosition blockposition1 = blockposition.relative(((EnumDirection) iblockdata.getValue(BlockBed.FACING)).getOpposite()); -@@ -114,7 +115,16 @@ +@@ -113,7 +114,16 @@ return EnumInteractionResult.SUCCESS_SERVER; } else { @@ -27,7 +27,7 @@ if (entityhuman_enumbedresult.getMessage() != null) { entityhuman.displayClientMessage(entityhuman_enumbedresult.getMessage(), true); } -@@ -125,8 +135,30 @@ +@@ -124,8 +134,30 @@ } } @@ -59,7 +59,7 @@ } private boolean kickVillagerOutOfBed(World world, BlockPosition blockposition) { -@@ -320,6 +352,11 @@ +@@ -304,6 +336,11 @@ BlockPosition blockposition1 = blockposition.relative((EnumDirection) iblockdata.getValue(BlockBed.FACING)); world.setBlock(blockposition1, (IBlockData) iblockdata.setValue(BlockBed.PART, BlockPropertyBedPart.HEAD), 3); @@ -68,6 +68,6 @@ + return; + } + // CraftBukkit end - world.blockUpdated(blockposition, Blocks.AIR); + world.updateNeighborsAt(blockposition, Blocks.AIR); iblockdata.updateNeighbourShapes(world, blockposition, 3); } diff --git a/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch b/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch index 181c4a870..91af61512 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockBeehive.java +++ b/net/minecraft/world/level/block/BlockBeehive.java -@@ -133,7 +133,7 @@ +@@ -125,7 +125,7 @@ if (entitybee.getTarget() == null) { EntityHuman entityhuman = (EntityHuman) SystemUtils.getRandom(list1, world.random); @@ -9,21 +9,3 @@ } } } -@@ -297,7 +297,7 @@ - ItemStack itemstack = new ItemStack(this); - - itemstack.applyComponents(tileentitybeehive.collectComponents()); -- itemstack.set(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY.with(BlockBeehive.HONEY_LEVEL, (Comparable) i)); -+ itemstack.set(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY.with(BlockBeehive.HONEY_LEVEL, i)); // CraftBukkit - decompile error - EntityItem entityitem = new EntityItem(world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack); - - entityitem.setDefaultPickUpDelay(); -@@ -332,7 +332,7 @@ - ItemStack itemstack = super.getCloneItemStack(iworldreader, blockposition, iblockdata, flag); - - if (flag) { -- itemstack.set(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY.with(BlockBeehive.HONEY_LEVEL, (Comparable) ((Integer) iblockdata.getValue(BlockBeehive.HONEY_LEVEL)))); -+ itemstack.set(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY.with(BlockBeehive.HONEY_LEVEL, ((Integer) iblockdata.getValue(BlockBeehive.HONEY_LEVEL)))); // CraftBukkit - decompile error - } - - return itemstack; diff --git a/nms-patches/net/minecraft/world/level/block/BlockBell.patch b/nms-patches/net/minecraft/world/level/block/BlockBell.patch index cdf7e1e8b..7730a75d4 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockBell.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockBell.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockBell.java +++ b/net/minecraft/world/level/block/BlockBell.java -@@ -148,6 +148,11 @@ +@@ -150,6 +150,11 @@ if (enumdirection == null) { enumdirection = (EnumDirection) world.getBlockState(blockposition).getValue(BlockBell.FACING); } @@ -11,4 +11,4 @@ + // CraftBukkit end ((TileEntityBell) tileentity).onHit(enumdirection); - world.playSound((EntityHuman) null, blockposition, SoundEffects.BELL_BLOCK, SoundCategory.BLOCKS, 2.0F, 1.0F); + world.playSound((Entity) null, blockposition, SoundEffects.BELL_BLOCK, SoundCategory.BLOCKS, 2.0F, 1.0F); diff --git a/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch b/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch index 5000b862d..5b5cfc6a7 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/BlockButtonAbstract.java +++ b/net/minecraft/world/level/block/BlockButtonAbstract.java -@@ -35,6 +35,11 @@ - import net.minecraft.world.phys.shapes.VoxelShape; +@@ -40,6 +40,11 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; + import net.minecraft.world.phys.shapes.VoxelShapes; +// CraftBukkit start +import org.bukkit.event.block.BlockRedstoneEvent; @@ -12,7 +12,7 @@ public class BlockButtonAbstract extends BlockAttachable { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -126,6 +131,19 @@ +@@ -87,6 +92,19 @@ if ((Boolean) iblockdata.getValue(BlockButtonAbstract.POWERED)) { return EnumInteractionResult.CONSUME; } else { @@ -32,7 +32,7 @@ this.press(iblockdata, world, blockposition, entityhuman); return EnumInteractionResult.SUCCESS; } -@@ -197,11 +215,36 @@ +@@ -155,11 +173,36 @@ } protected void checkPressed(IBlockData iblockdata, World world, BlockPosition blockposition) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockCactus.patch b/nms-patches/net/minecraft/world/level/block/BlockCactus.patch index b7357ae0e..0878a78ab 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCactus.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCactus.patch @@ -9,19 +9,23 @@ public class BlockCactus extends Block { public static final MapCodec CODEC = simpleCodec(BlockCactus::new); -@@ -65,7 +67,7 @@ - int j = (Integer) iblockdata.getValue(BlockCactus.AGE); +@@ -72,10 +74,10 @@ + double d0 = i >= 3 ? 0.25D : 0.1D; - if (j == 15) { -- worldserver.setBlockAndUpdate(blockposition1, this.defaultBlockState()); -+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, this.defaultBlockState()); // CraftBukkit - IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockCactus.AGE, 0); + if (randomsource.nextDouble() <= d0) { +- worldserver.setBlockAndUpdate(blockposition1, Blocks.CACTUS_FLOWER.defaultBlockState()); ++ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, Blocks.CACTUS_FLOWER.defaultBlockState()); // CraftBukkit + } + } else if (j == 15 && i < 3) { +- worldserver.setBlockAndUpdate(blockposition1, this.defaultBlockState()); ++ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, this.defaultBlockState()); // CraftBukkit + IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockCactus.AGE, 0); - worldserver.setBlock(blockposition, iblockdata1, 4); -@@ -120,7 +122,7 @@ + worldserver.setBlock(blockposition, iblockdata1, 260); +@@ -125,7 +127,7 @@ @Override - protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity, InsideBlockEffectApplier insideblockeffectapplier) { - entity.hurt(world.damageSources().cactus(), 1.0F); + entity.hurt(world.damageSources().cactus().directBlock(world, blockposition), 1.0F); // CraftBukkit } diff --git a/nms-patches/net/minecraft/world/level/block/BlockCake.patch b/nms-patches/net/minecraft/world/level/block/BlockCake.patch index 85c051155..bca7eedd8 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCake.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCake.patch @@ -19,4 +19,4 @@ + // CraftBukkit end int i = (Integer) iblockdata.getValue(BlockCake.BITES); - generatoraccess.gameEvent((Entity) entityhuman, (Holder) GameEvent.EAT, blockposition); + generatoraccess.gameEvent(entityhuman, (Holder) GameEvent.EAT, blockposition); diff --git a/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch b/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch index b1895f817..e3e27c8b7 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch @@ -2,14 +2,14 @@ +++ b/net/minecraft/world/level/block/BlockCampfire.java @@ -113,7 +113,7 @@ @Override - protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity, InsideBlockEffectApplier insideblockeffectapplier) { if ((Boolean) iblockdata.getValue(BlockCampfire.LIT) && entity instanceof EntityLiving) { - entity.hurt(world.damageSources().campfire(), (float) this.fireDamage); + entity.hurt(world.damageSources().campfire().directBlock(world, blockposition), (float) this.fireDamage); // CraftBukkit } - super.entityInside(iblockdata, world, blockposition, entity); -@@ -219,6 +219,11 @@ + super.entityInside(iblockdata, world, blockposition, entity, insideblockeffectapplier); +@@ -200,6 +200,11 @@ if (world instanceof WorldServer worldserver) { if (iprojectile.isOnFire() && iprojectile.mayInteract(worldserver, blockposition) && !(Boolean) iblockdata.getValue(BlockCampfire.LIT) && !(Boolean) iblockdata.getValue(BlockCampfire.WATERLOGGED)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockCauldron.patch b/nms-patches/net/minecraft/world/level/block/BlockCauldron.patch index 37c8b5f25..2c29c9dbf 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCauldron.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCauldron.patch @@ -11,19 +11,20 @@ public class BlockCauldron extends AbstractCauldronBlock { public static final MapCodec CODEC = simpleCodec(BlockCauldron::new); -@@ -62,13 +66,11 @@ - +@@ -61,14 +65,12 @@ if (fluidtype == FluidTypes.WATER) { - iblockdata1 = Blocks.WATER_CAULDRON.defaultBlockState(); + IBlockData iblockdata1 = Blocks.WATER_CAULDRON.defaultBlockState(); + - world.setBlockAndUpdate(blockposition, iblockdata1); -- world.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1)); +- world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1)); + LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata1, null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit world.levelEvent(1047, blockposition, 0); } else if (fluidtype == FluidTypes.LAVA) { - iblockdata1 = Blocks.LAVA_CAULDRON.defaultBlockState(); -- world.setBlockAndUpdate(blockposition, iblockdata1); -- world.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1)); -+ LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata1, null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit + IBlockData iblockdata2 = Blocks.LAVA_CAULDRON.defaultBlockState(); + +- world.setBlockAndUpdate(blockposition, iblockdata2); +- world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata2)); ++ LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata2, null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit world.levelEvent(1046, blockposition, 0); } diff --git a/nms-patches/net/minecraft/world/level/block/BlockChest.patch b/nms-patches/net/minecraft/world/level/block/BlockChest.patch index 01c475972..0b8a1d209 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockChest.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockChest.patch @@ -1,37 +1,38 @@ --- a/net/minecraft/world/level/block/BlockChest.java +++ b/net/minecraft/world/level/block/BlockChest.java -@@ -87,28 +87,11 @@ +@@ -83,28 +83,11 @@ return Optional.empty(); } }; - private static final DoubleBlockFinder.Combiner> MENU_PROVIDER_COMBINER = new DoubleBlockFinder.Combiner>() { + public static final DoubleBlockFinder.Combiner> MENU_PROVIDER_COMBINER = new DoubleBlockFinder.Combiner>() { // PAIL private -> public public Optional acceptDouble(final TileEntityChest tileentitychest, final TileEntityChest tileentitychest1) { - final InventoryLargeChest inventorylargechest = new InventoryLargeChest(tileentitychest, tileentitychest1); - -- return Optional.of(new ITileInventory(this) { +- final IInventory iinventory = new InventoryLargeChest(tileentitychest, tileentitychest1); +- +- return Optional.of(new ITileInventory() { - @Nullable - @Override - public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) { - if (tileentitychest.canOpen(entityhuman) && tileentitychest1.canOpen(entityhuman)) { - tileentitychest.unpackLootTable(playerinventory.player); - tileentitychest1.unpackLootTable(playerinventory.player); -- return ContainerChest.sixRows(i, playerinventory, inventorylargechest); +- return ContainerChest.sixRows(i, playerinventory, iinventory); - } else { - return null; - } - } -- ++ final InventoryLargeChest iinventory = new InventoryLargeChest(tileentitychest, tileentitychest1); // CraftBukkit + - @Override - public IChatBaseComponent getDisplayName() { - return (IChatBaseComponent) (tileentitychest.hasCustomName() ? tileentitychest.getDisplayName() : (tileentitychest1.hasCustomName() ? tileentitychest1.getDisplayName() : IChatBaseComponent.translatable("container.chestDouble"))); - } - }); -+ return Optional.of(new DoubleInventory(tileentitychest, tileentitychest1, inventorylargechest)); // CraftBukkit // CraftBukkit - decompile error ++ return Optional.of(new DoubleInventory(tileentitychest, tileentitychest1, iinventory)); // CraftBukkit } public Optional acceptSingle(TileEntityChest tileentitychest) { -@@ -121,6 +104,38 @@ +@@ -117,6 +100,38 @@ } }; @@ -70,16 +71,7 @@ @Override public MapCodec codec() { return BlockChest.CODEC; -@@ -257,7 +272,7 @@ - - @Override - public DoubleBlockFinder.Result combine(IBlockData iblockdata, World world, BlockPosition blockposition, boolean flag) { -- BiPredicate bipredicate; -+ BiPredicate bipredicate; // CraftBukkit - decompile error - - if (flag) { - bipredicate = (generatoraccess, blockposition1) -> { -@@ -273,7 +288,14 @@ +@@ -268,7 +283,14 @@ @Nullable @Override protected ITileInventory getMenuProvider(IBlockData iblockdata, World world, BlockPosition blockposition) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockChorusFlower.patch b/nms-patches/net/minecraft/world/level/block/BlockChorusFlower.patch index 04cac1d35..3f239ada3 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockChorusFlower.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockChorusFlower.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockChorusFlower.java +++ b/net/minecraft/world/level/block/BlockChorusFlower.java -@@ -23,6 +23,8 @@ +@@ -22,6 +22,8 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.shapes.VoxelShape; @@ -9,7 +9,7 @@ public class BlockChorusFlower extends Block { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -103,8 +105,12 @@ +@@ -101,8 +103,12 @@ } if (flag && allNeighborsEmpty(worldserver, blockposition1, (EnumDirection) null) && worldserver.isEmptyBlock(blockposition.above(2))) { @@ -22,9 +22,9 @@ + } + // CraftBukkit end } else if (i < 4) { - j = randomsource.nextInt(4); - if (flag1) { -@@ -118,18 +124,30 @@ + int l = randomsource.nextInt(4); + +@@ -117,18 +123,30 @@ BlockPosition blockposition2 = blockposition.relative(enumdirection); if (worldserver.isEmptyBlock(blockposition2) && worldserver.isEmptyBlock(blockposition2.below()) && allNeighborsEmpty(worldserver, blockposition2, enumdirection.getOpposite())) { @@ -59,7 +59,7 @@ } } -@@ -267,6 +285,11 @@ +@@ -258,6 +276,11 @@ if (world instanceof WorldServer worldserver) { if (iprojectile.mayInteract(worldserver, blockposition) && iprojectile.mayBreak(worldserver)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockCocoa.patch b/nms-patches/net/minecraft/world/level/block/BlockCocoa.patch index 3e8d91fa1..a354d42e4 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCocoa.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCocoa.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/BlockCocoa.java +++ b/net/minecraft/world/level/block/BlockCocoa.java -@@ -21,6 +21,8 @@ - import net.minecraft.world.phys.shapes.VoxelShape; +@@ -25,6 +25,8 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; + import net.minecraft.world.phys.shapes.VoxelShapes; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + public class BlockCocoa extends BlockFacingHorizontal implements IBlockFragilePlantElement { public static final MapCodec CODEC = simpleCodec(BlockCocoa::new); -@@ -61,7 +63,7 @@ +@@ -55,7 +57,7 @@ int i = (Integer) iblockdata.getValue(BlockCocoa.AGE); if (i < 2) { @@ -18,7 +18,7 @@ } } -@@ -131,7 +133,7 @@ +@@ -109,7 +111,7 @@ @Override public void performBonemeal(WorldServer worldserver, RandomSource randomsource, BlockPosition blockposition, IBlockData iblockdata) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockComposter.patch b/nms-patches/net/minecraft/world/level/block/BlockComposter.patch index c6903bbe8..9c3832388 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockComposter.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockComposter.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockComposter.java +++ b/net/minecraft/world/level/block/BlockComposter.java -@@ -42,6 +42,11 @@ +@@ -41,6 +41,11 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -12,7 +12,7 @@ public class BlockComposter extends Block implements IInventoryHolder { public static final MapCodec CODEC = simpleCodec(BlockComposter::new); -@@ -269,7 +274,14 @@ +@@ -276,7 +281,14 @@ int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL); if (i < 7 && BlockComposter.COMPOSTABLES.containsKey(itemstack.getItem())) { @@ -28,7 +28,7 @@ itemstack.shrink(1); return iblockdata1; -@@ -279,6 +291,14 @@ +@@ -286,6 +298,14 @@ } public static IBlockData extractProduce(Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) { @@ -43,7 +43,7 @@ if (!world.isClientSide) { Vec3D vec3d = Vec3D.atLowerCornerWithOffset(blockposition, 0.5D, 1.01D, 0.5D).offsetRandom(world.random, 0.7F); EntityItem entityitem = new EntityItem(world, vec3d.x(), vec3d.y(), vec3d.z(), new ItemStack(Items.BONE_MEAL)); -@@ -302,10 +322,16 @@ +@@ -309,10 +329,16 @@ } static IBlockData addItem(@Nullable Entity entity, IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) { @@ -61,7 +61,7 @@ return iblockdata; } else { int j = i + 1; -@@ -354,7 +380,8 @@ +@@ -361,13 +387,15 @@ public IWorldInventory getContainer(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL); @@ -70,8 +70,16 @@ + return (IWorldInventory) (i == 8 ? new BlockComposter.ContainerOutput(iblockdata, generatoraccess, blockposition, new ItemStack(Items.BONE_MEAL)) : (i < 7 ? new BlockComposter.ContainerInput(iblockdata, generatoraccess, blockposition) : new BlockComposter.ContainerEmpty(generatoraccess, blockposition))); } - public static class ContainerOutput extends InventorySubcontainer implements IWorldInventory { -@@ -369,6 +396,7 @@ + public static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory { + +- public ContainerEmpty() { ++ public ContainerEmpty(GeneratorAccess generatoraccess, BlockPosition blockposition) { // CraftBukkit + super(0); ++ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit + } + + @Override +@@ -398,6 +426,7 @@ this.state = iblockdata; this.level = generatoraccess; this.pos = blockposition; @@ -79,7 +87,7 @@ } @Override -@@ -393,8 +421,15 @@ +@@ -422,8 +451,15 @@ @Override public void setChanged() { @@ -95,7 +103,7 @@ } } -@@ -407,6 +442,7 @@ +@@ -436,6 +472,7 @@ public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { super(1); @@ -103,14 +111,3 @@ this.state = iblockdata; this.level = generatoraccess; this.pos = blockposition; -@@ -449,8 +485,9 @@ - - public static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory { - -- public ContainerEmpty() { -+ public ContainerEmpty(GeneratorAccess generatoraccess, BlockPosition blockposition) { // CraftBukkit - super(0); -+ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit - } - - @Override diff --git a/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch b/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch index f828b830d..7270dd3d2 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch @@ -24,20 +24,20 @@ } @@ -49,7 +55,24 @@ BlockPosition blockposition = blockactioncontext.getClickedPos(); - IBlockData iblockdata = world.getBlockState(blockposition); + IBlockData iblockdata = iblockaccess.getBlockState(blockposition); -- return shouldSolidify(world, blockposition, iblockdata) ? this.concrete.defaultBlockState() : super.getStateForPlacement(blockactioncontext); +- return shouldSolidify(iblockaccess, blockposition, iblockdata) ? this.concrete.defaultBlockState() : super.getStateForPlacement(blockactioncontext); + // CraftBukkit start -+ if (!shouldSolidify(world, blockposition, iblockdata)) { ++ if (!shouldSolidify(iblockaccess, blockposition, iblockdata)) { + return super.getStateForPlacement(blockactioncontext); + } + + // TODO: An event factory call for methods like this -+ CraftBlockState blockState = CraftBlockStates.getBlockState(world, blockposition); ++ CraftBlockState blockState = CraftBlockStates.getBlockState(blockactioncontext.getLevel(), blockposition); + blockState.setData(this.concrete.defaultBlockState()); + + BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState); -+ world.getServer().server.getPluginManager().callEvent(event); ++ blockactioncontext.getLevel().getServer().server.getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + return blockState.getHandle(); @@ -48,7 +48,7 @@ } private static boolean shouldSolidify(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) { -@@ -85,7 +108,25 @@ +@@ -82,7 +105,25 @@ @Override protected IBlockData updateShape(IBlockData iblockdata, IWorldReader iworldreader, ScheduledTickAccess scheduledtickaccess, BlockPosition blockposition, EnumDirection enumdirection, BlockPosition blockposition1, IBlockData iblockdata1, RandomSource randomsource) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockCoralPlant.patch b/nms-patches/net/minecraft/world/level/block/BlockCoralPlant.patch index 44e06a249..3eedfdef8 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCoralPlant.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCoralPlant.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCoralPlant.java +++ b/net/minecraft/world/level/block/BlockCoralPlant.java -@@ -46,6 +46,11 @@ +@@ -45,6 +45,11 @@ @Override protected void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, RandomSource randomsource) { if (!scanForWater(iblockdata, worldserver, blockposition)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockCrops.patch b/nms-patches/net/minecraft/world/level/block/BlockCrops.patch index bf16556b8..3d43f5ddf 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCrops.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCrops.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/BlockCrops.java +++ b/net/minecraft/world/level/block/BlockCrops.java -@@ -22,6 +22,8 @@ +@@ -23,6 +23,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + - public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement { + public class BlockCrops extends VegetationBlock implements IBlockFragilePlantElement { public static final MapCodec CODEC = simpleCodec(BlockCrops::new); -@@ -83,7 +85,7 @@ +@@ -86,7 +88,7 @@ float f = getGrowthSpeed(this, worldserver, blockposition); if (randomsource.nextInt((int) (25.0F / f) + 1) == 0) { @@ -18,18 +18,18 @@ } } } -@@ -98,7 +100,7 @@ - i = j; - } +@@ -96,7 +98,7 @@ + public void growCrops(World world, BlockPosition blockposition, IBlockData iblockdata) { + int i = Math.min(this.getMaxAge(), this.getAge(iblockdata) + this.getBonemealAgeIncrease(world)); - world.setBlock(blockposition, this.getStateForAge(i), 2); + CraftEventFactory.handleBlockGrowEvent(world, blockposition, this.getStateForAge(i), 2); // CraftBukkit } protected int getBonemealAgeIncrease(World world) { -@@ -161,7 +163,7 @@ +@@ -159,7 +161,7 @@ @Override - protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity, InsideBlockEffectApplier insideblockeffectapplier) { if (world instanceof WorldServer worldserver) { - if (entity instanceof EntityRavager && worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (entity instanceof EntityRavager && CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.defaultBlockState(), !worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit diff --git a/nms-patches/net/minecraft/world/level/block/BlockDaylightDetector.patch b/nms-patches/net/minecraft/world/level/block/BlockDaylightDetector.patch index f15f2f15f..fc6ef55d3 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockDaylightDetector.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockDaylightDetector.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockDaylightDetector.java +++ b/net/minecraft/world/level/block/BlockDaylightDetector.java -@@ -74,6 +74,7 @@ +@@ -73,6 +73,7 @@ i = MathHelper.clamp(i, 0, 15); if ((Integer) iblockdata.getValue(BlockDaylightDetector.POWER) != i) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockDiodeAbstract.patch b/nms-patches/net/minecraft/world/level/block/BlockDiodeAbstract.patch index 1b54785c3..6020b2bc7 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockDiodeAbstract.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockDiodeAbstract.patch @@ -8,7 +8,7 @@ + public abstract class BlockDiodeAbstract extends BlockFacingHorizontal { - protected static final VoxelShape SHAPE = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D); + public static final BlockStateBoolean POWERED = BlockProperties.POWERED; @@ -59,8 +61,18 @@ boolean flag1 = this.shouldTurnOn(worldserver, blockposition, iblockdata); diff --git a/nms-patches/net/minecraft/world/level/block/BlockDispenser.patch b/nms-patches/net/minecraft/world/level/block/BlockDispenser.patch index 8b0139e08..c5dff2b1c 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockDispenser.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockDispenser.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockDispenser.java +++ b/net/minecraft/world/level/block/BlockDispenser.java -@@ -52,6 +52,7 @@ +@@ -51,6 +51,7 @@ private static final DispenseBehaviorItem DEFAULT_BEHAVIOR = new DispenseBehaviorItem(); public static final Map DISPENSER_REGISTRY = new IdentityHashMap(); private static final int TRIGGER_DURATION = 4; @@ -8,7 +8,7 @@ @Override public MapCodec codec() { -@@ -88,7 +89,7 @@ +@@ -87,7 +88,7 @@ } public void dispenseFrom(WorldServer worldserver, IBlockData iblockdata, BlockPosition blockposition) { @@ -17,7 +17,7 @@ if (tileentitydispenser == null) { BlockDispenser.LOGGER.warn("Ignoring dispensing attempt for Dispenser without matching block entity at {}", blockposition); -@@ -104,6 +105,7 @@ +@@ -103,6 +104,7 @@ IDispenseBehavior idispensebehavior = this.getDispenseMethod(worldserver, itemstack); if (idispensebehavior != IDispenseBehavior.NOOP) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockDoor.patch b/nms-patches/net/minecraft/world/level/block/BlockDoor.patch index d62163d03..b08ca6689 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockDoor.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockDoor.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/BlockDoor.java +++ b/net/minecraft/world/level/block/BlockDoor.java -@@ -39,6 +39,8 @@ - import net.minecraft.world.phys.shapes.VoxelShape; +@@ -41,6 +41,8 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; + import net.minecraft.world.phys.shapes.VoxelShapes; +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit + public class BlockDoor extends Block { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -222,9 +224,24 @@ +@@ -204,9 +206,24 @@ @Override protected void neighborChanged(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, @Nullable Orientation orientation, boolean flag) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockEndGateway.patch b/nms-patches/net/minecraft/world/level/block/BlockEndGateway.patch index d4318f235..04f6f6529 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockEndGateway.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockEndGateway.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockEndGateway.java +++ b/net/minecraft/world/level/block/BlockEndGateway.java -@@ -23,6 +23,10 @@ +@@ -24,6 +24,10 @@ import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public class BlockEndGateway extends BlockTileEntity implements Portal { public static final MapCodec CODEC = simpleCodec(BlockEndGateway::new); -@@ -112,7 +116,7 @@ +@@ -113,7 +117,7 @@ if (tileentity instanceof TileEntityEndGateway tileentityendgateway) { Vec3D vec3d = tileentityendgateway.getPortalPosition(worldserver, blockposition); diff --git a/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch b/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch index 85f651ffb..a2dac5ccf 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockEnderPortal.java +++ b/net/minecraft/world/level/block/BlockEnderPortal.java -@@ -26,6 +26,19 @@ +@@ -27,6 +27,19 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -20,9 +20,9 @@ public class BlockEnderPortal extends BlockTileEntity implements Portal { public static final MapCodec CODEC = simpleCodec(BlockEnderPortal::new); -@@ -58,6 +71,10 @@ +@@ -59,6 +72,10 @@ @Override - protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity, InsideBlockEffectApplier insideblockeffectapplier) { if (entity.canUsePortal(false)) { + // CraftBukkit start - Entity in portal + EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ())); @@ -31,7 +31,7 @@ if (!world.isClientSide && world.dimension() == World.END && entity instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) entity; -@@ -74,11 +91,11 @@ +@@ -75,11 +92,11 @@ @Override public TeleportTransition getPortalDestination(WorldServer worldserver, Entity entity, BlockPosition blockposition) { @@ -45,8 +45,8 @@ } else { boolean flag = resourcekey == World.END; BlockPosition blockposition1 = flag ? WorldServer.END_SPAWN_POINT : worldserver1.getSharedSpawnPos(); -@@ -87,7 +104,7 @@ - Set set; +@@ -88,7 +105,7 @@ + Set set; if (flag) { - EndPlatformFeature.createEndPlatform(worldserver1, BlockPosition.containing(vec3d).below(), true); @@ -54,7 +54,7 @@ f = EnumDirection.WEST.toYRot(); set = Relative.union(Relative.DELTA, Set.of(Relative.X_ROT)); if (entity instanceof EntityPlayer) { -@@ -99,13 +116,21 @@ +@@ -100,13 +117,21 @@ if (entity instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) entity; diff --git a/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch b/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch index 9665e2b12..7e73d54b9 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockFenceGate.java +++ b/net/minecraft/world/level/block/BlockFenceGate.java -@@ -173,6 +173,17 @@ +@@ -183,6 +183,17 @@ protected void neighborChanged(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, @Nullable Orientation orientation, boolean flag) { if (!world.isClientSide) { boolean flag1 = world.hasNeighborSignal(blockposition); diff --git a/nms-patches/net/minecraft/world/level/block/BlockFire.patch b/nms-patches/net/minecraft/world/level/block/BlockFire.patch index beab20b97..8e7d87315 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockFire.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockFire.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockFire.java +++ b/net/minecraft/world/level/block/BlockFire.java -@@ -29,6 +29,15 @@ +@@ -28,6 +28,15 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -16,7 +16,7 @@ public class BlockFire extends BlockFireAbstract { public static final MapCodec CODEC = simpleCodec(BlockFire::new); -@@ -100,7 +109,24 @@ +@@ -82,7 +91,24 @@ @Override protected IBlockData updateShape(IBlockData iblockdata, IWorldReader iworldreader, ScheduledTickAccess scheduledtickaccess, BlockPosition blockposition, EnumDirection enumdirection, BlockPosition blockposition1, IBlockData iblockdata1, RandomSource randomsource) { @@ -42,85 +42,85 @@ } @Override -@@ -149,7 +175,7 @@ - worldserver.scheduleTick(blockposition, (Block) this, getFireTickDelay(worldserver.random)); +@@ -129,7 +155,7 @@ if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { - if (!iblockdata.canSurvive(worldserver, blockposition)) { -- worldserver.removeBlock(blockposition, false); -+ fireExtinguished(worldserver, blockposition); // CraftBukkit - invalid place location - } + if (worldserver.getGameRules().getBoolean(GameRules.RULE_ALLOWFIRETICKAWAYFROMPLAYERS) || worldserver.anyPlayerCloseEnoughForSpawning(blockposition)) { + if (!iblockdata.canSurvive(worldserver, blockposition)) { +- worldserver.removeBlock(blockposition, false); ++ fireExtinguished(worldserver, blockposition); // CraftBukkit - invalid place location + } - IBlockData iblockdata1 = worldserver.getBlockState(blockposition.below()); -@@ -157,7 +183,7 @@ - int i = (Integer) iblockdata.getValue(BlockFire.AGE); + IBlockData iblockdata1 = worldserver.getBlockState(blockposition.below()); +@@ -137,7 +163,7 @@ + int i = (Integer) iblockdata.getValue(BlockFire.AGE); - if (!flag && worldserver.isRaining() && this.isNearRain(worldserver, blockposition) && randomsource.nextFloat() < 0.2F + (float) i * 0.03F) { -- worldserver.removeBlock(blockposition, false); -+ fireExtinguished(worldserver, blockposition); // CraftBukkit - extinguished by rain - } else { - int j = Math.min(15, i + randomsource.nextInt(3) / 2); + if (!flag && worldserver.isRaining() && this.isNearRain(worldserver, blockposition) && randomsource.nextFloat() < 0.2F + (float) i * 0.03F) { +- worldserver.removeBlock(blockposition, false); ++ fireExtinguished(worldserver, blockposition); // CraftBukkit - extinguished by rain + } else { + int j = Math.min(15, i + randomsource.nextInt(3) / 2); -@@ -171,14 +197,14 @@ - BlockPosition blockposition1 = blockposition.below(); +@@ -151,14 +177,14 @@ + BlockPosition blockposition1 = blockposition.below(); - if (!worldserver.getBlockState(blockposition1).isFaceSturdy(worldserver, blockposition1, EnumDirection.UP) || i > 3) { -- worldserver.removeBlock(blockposition, false); -+ fireExtinguished(worldserver, blockposition); // CraftBukkit + if (!worldserver.getBlockState(blockposition1).isFaceSturdy(worldserver, blockposition1, EnumDirection.UP) || i > 3) { +- worldserver.removeBlock(blockposition, false); ++ fireExtinguished(worldserver, blockposition); // CraftBukkit + } + + return; } - return; + if (i == 15 && randomsource.nextInt(4) == 0 && !this.canBurn(worldserver.getBlockState(blockposition.below()))) { +- worldserver.removeBlock(blockposition, false); ++ fireExtinguished(worldserver, blockposition); // CraftBukkit + return; + } } +@@ -166,12 +192,14 @@ + boolean flag1 = worldserver.getBiome(blockposition).is(BiomeTags.INCREASED_FIRE_BURNOUT); + int k = flag1 ? -50 : 0; - if (i == 15 && randomsource.nextInt(4) == 0 && !this.canBurn(worldserver.getBlockState(blockposition.below()))) { -- worldserver.removeBlock(blockposition, false); -+ fireExtinguished(worldserver, blockposition); // CraftBukkit - return; - } - } -@@ -186,12 +212,14 @@ - boolean flag1 = worldserver.getBiome(blockposition).is(BiomeTags.INCREASED_FIRE_BURNOUT); - int k = flag1 ? -50 : 0; +- this.checkBurnOut(worldserver, blockposition.east(), 300 + k, randomsource, i); +- this.checkBurnOut(worldserver, blockposition.west(), 300 + k, randomsource, i); +- this.checkBurnOut(worldserver, blockposition.below(), 250 + k, randomsource, i); +- this.checkBurnOut(worldserver, blockposition.above(), 250 + k, randomsource, i); +- this.checkBurnOut(worldserver, blockposition.north(), 300 + k, randomsource, i); +- this.checkBurnOut(worldserver, blockposition.south(), 300 + k, randomsource, i); ++ // CraftBukkit start - add source blockposition to burn calls ++ this.checkBurnOut(worldserver, blockposition.east(), 300 + k, randomsource, i, blockposition); ++ this.checkBurnOut(worldserver, blockposition.west(), 300 + k, randomsource, i, blockposition); ++ this.checkBurnOut(worldserver, blockposition.below(), 250 + k, randomsource, i, blockposition); ++ this.checkBurnOut(worldserver, blockposition.above(), 250 + k, randomsource, i, blockposition); ++ this.checkBurnOut(worldserver, blockposition.north(), 300 + k, randomsource, i, blockposition); ++ this.checkBurnOut(worldserver, blockposition.south(), 300 + k, randomsource, i, blockposition); ++ // CraftBukkit end + BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition(); -- this.checkBurnOut(worldserver, blockposition.east(), 300 + k, randomsource, i); -- this.checkBurnOut(worldserver, blockposition.west(), 300 + k, randomsource, i); -- this.checkBurnOut(worldserver, blockposition.below(), 250 + k, randomsource, i); -- this.checkBurnOut(worldserver, blockposition.above(), 250 + k, randomsource, i); -- this.checkBurnOut(worldserver, blockposition.north(), 300 + k, randomsource, i); -- this.checkBurnOut(worldserver, blockposition.south(), 300 + k, randomsource, i); -+ // CraftBukkit start - add source blockposition to burn calls -+ this.trySpread(worldserver, blockposition.east(), 300 + k, randomsource, i, blockposition); -+ this.trySpread(worldserver, blockposition.west(), 300 + k, randomsource, i, blockposition); -+ this.trySpread(worldserver, blockposition.below(), 250 + k, randomsource, i, blockposition); -+ this.trySpread(worldserver, blockposition.above(), 250 + k, randomsource, i, blockposition); -+ this.trySpread(worldserver, blockposition.north(), 300 + k, randomsource, i, blockposition); -+ this.trySpread(worldserver, blockposition.south(), 300 + k, randomsource, i, blockposition); -+ // CraftBukkit end - BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition(); + for (int l = -1; l <= 1; ++l) { +@@ -197,7 +225,15 @@ + if (i2 > 0 && randomsource.nextInt(k1) <= i2 && (!worldserver.isRaining() || !this.isNearRain(worldserver, blockposition_mutableblockposition))) { + int j2 = Math.min(15, i + randomsource.nextInt(5) / 4); - for (int l = -1; l <= 1; ++l) { -@@ -217,7 +245,15 @@ - if (i2 > 0 && randomsource.nextInt(k1) <= i2 && (!worldserver.isRaining() || !this.isNearRain(worldserver, blockposition_mutableblockposition))) { - int j2 = Math.min(15, i + randomsource.nextInt(5) / 4); - -- worldserver.setBlock(blockposition_mutableblockposition, this.getStateWithAge(worldserver, blockposition_mutableblockposition, j2), 3); -+ // CraftBukkit start - Call to stop spread of fire -+ if (worldserver.getBlockState(blockposition_mutableblockposition).getBlock() != Blocks.FIRE) { -+ if (CraftEventFactory.callBlockIgniteEvent(worldserver, blockposition_mutableblockposition, blockposition).isCancelled()) { -+ continue; -+ } +- worldserver.setBlock(blockposition_mutableblockposition, this.getStateWithAge(worldserver, blockposition_mutableblockposition, j2), 3); ++ // CraftBukkit start - Call to stop spread of fire ++ if (worldserver.getBlockState(blockposition_mutableblockposition).getBlock() != Blocks.FIRE) { ++ if (CraftEventFactory.callBlockIgniteEvent(worldserver, blockposition_mutableblockposition, blockposition).isCancelled()) { ++ continue; ++ } + -+ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition_mutableblockposition, this.getStateWithAge(worldserver, blockposition_mutableblockposition, j2), 3); // CraftBukkit -+ } -+ // CraftBukkit end ++ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition_mutableblockposition, this.getStateWithAge(worldserver, blockposition_mutableblockposition, j2), 3); // CraftBukkit ++ } ++ // CraftBukkit end + } } } - } -@@ -241,12 +277,28 @@ +@@ -222,12 +258,28 @@ return iblockdata.hasProperty(BlockProperties.WATERLOGGED) && (Boolean) iblockdata.getValue(BlockProperties.WATERLOGGED) ? 0 : this.igniteOdds.getInt(iblockdata.getBlock()); } - private void checkBurnOut(World world, BlockPosition blockposition, int i, RandomSource randomsource, int j) { -+ private void trySpread(World world, BlockPosition blockposition, int i, RandomSource randomsource, int j, BlockPosition sourceposition) { // CraftBukkit add sourceposition ++ private void checkBurnOut(World world, BlockPosition blockposition, int i, RandomSource randomsource, int j, BlockPosition sourceposition) { // CraftBukkit add sourceposition int k = this.getBurnOdds(world.getBlockState(blockposition)); if (randomsource.nextInt(i) < k) { @@ -145,7 +145,7 @@ if (randomsource.nextInt(j + 10) < 5 && !world.isRainingAt(blockposition)) { int l = Math.min(j + randomsource.nextInt(5) / 4, 15); -@@ -310,8 +362,10 @@ +@@ -283,8 +335,10 @@ } @Override diff --git a/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch b/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch index 639176c45..3209d58ce 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockFireAbstract.java +++ b/net/minecraft/world/level/block/BlockFireAbstract.java -@@ -20,6 +20,10 @@ +@@ -22,6 +22,10 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -11,14 +11,14 @@ public abstract class BlockFireAbstract extends Block { private static final int SECONDS_ON_FIRE = 8; -@@ -137,7 +141,14 @@ +@@ -147,33 +151,40 @@ } 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(world, blockposition), entity.getBukkitEntity(), 8.0F); -+ world.getCraftServer().getPluginManager().callEvent(event); ++ org.bukkit.event.entity.EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustByBlockEvent(entity.getBukkitEntity().getLocation().getBlock(), entity.getBukkitEntity(), 8.0F); // PAIL - TODO ++ entity.level().getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + entity.igniteForSeconds(event.getDuration(), false); @@ -27,7 +27,6 @@ } } -@@ -146,26 +157,26 @@ } @Override @@ -58,7 +57,7 @@ } @Override -@@ -213,4 +224,12 @@ +@@ -217,4 +228,12 @@ } } } diff --git a/nms-patches/net/minecraft/world/level/block/BlockFlowerPot.patch b/nms-patches/net/minecraft/world/level/block/BlockFlowerPot.patch index d0d5059eb..308c95898 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockFlowerPot.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockFlowerPot.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockFlowerPot.java +++ b/net/minecraft/world/level/block/BlockFlowerPot.java -@@ -137,11 +137,14 @@ +@@ -136,11 +136,14 @@ boolean flag1 = CreakingHeartBlock.isNaturalNight(worldserver); if (flag != flag1) { @@ -11,9 +11,9 @@ + EyeblossomBlock.a eyeblossomblock_a = EyeblossomBlock.a.fromBoolean(flag).transform(); - eyeblossomblock_a.spawnTransformParticle(worldserver, blockposition, randomsource); -- worldserver.playSound((EntityHuman) null, blockposition, eyeblossomblock_a.longSwitchSound(), SoundCategory.BLOCKS, 1.0F, 1.0F); +- worldserver.playSound((Entity) null, blockposition, eyeblossomblock_a.longSwitchSound(), SoundCategory.BLOCKS, 1.0F, 1.0F); + eyeblossomblock_a.spawnTransformParticle(worldserver, blockposition, randomsource); -+ worldserver.playSound((EntityHuman) null, blockposition, eyeblossomblock_a.longSwitchSound(), SoundCategory.BLOCKS, 1.0F, 1.0F); ++ worldserver.playSound((Entity) null, blockposition, eyeblossomblock_a.longSwitchSound(), SoundCategory.BLOCKS, 1.0F, 1.0F); + } + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch b/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch index 31ae1d489..2a6ac6c91 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch @@ -6,10 +6,10 @@ +import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit + - public class BlockLeaves extends Block implements IBlockWaterlogged { + public abstract class BlockLeaves extends Block implements IBlockWaterlogged { - public static final MapCodec CODEC = simpleCodec(BlockLeaves::new); -@@ -59,6 +61,14 @@ + public static final int DECAY_DISTANCE = 7; +@@ -58,6 +60,14 @@ @Override protected void randomTick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, RandomSource randomsource) { if (this.decaying(iblockdata)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockLectern.patch b/nms-patches/net/minecraft/world/level/block/BlockLectern.patch deleted file mode 100644 index 0ca61f9a6..000000000 --- a/nms-patches/net/minecraft/world/level/block/BlockLectern.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/world/level/block/BlockLectern.java -+++ b/net/minecraft/world/level/block/BlockLectern.java -@@ -206,11 +206,12 @@ - } - - private void popBook(IBlockData iblockdata, World world, BlockPosition blockposition) { -- TileEntity tileentity = world.getBlockEntity(blockposition); -+ TileEntity tileentity = world.getBlockEntity(blockposition, false); // CraftBukkit - don't validate, type may be changed already - - if (tileentity instanceof TileEntityLectern tileentitylectern) { - EnumDirection enumdirection = (EnumDirection) iblockdata.getValue(BlockLectern.FACING); - ItemStack itemstack = tileentitylectern.getBook().copy(); -+ if (itemstack.isEmpty()) return; // CraftBukkit - SPIGOT-5500 - float f = 0.25F * (float) enumdirection.getStepX(); - float f1 = 0.25F * (float) enumdirection.getStepZ(); - EntityItem entityitem = new EntityItem(world, (double) blockposition.getX() + 0.5D + (double) f, (double) (blockposition.getY() + 1), (double) blockposition.getZ() + 0.5D + (double) f1, itemstack); diff --git a/nms-patches/net/minecraft/world/level/block/BlockLever.patch b/nms-patches/net/minecraft/world/level/block/BlockLever.patch index 32219f939..047c2e855 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockLever.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockLever.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/BlockLever.java +++ b/net/minecraft/world/level/block/BlockLever.java -@@ -32,6 +32,8 @@ - import net.minecraft.world.phys.shapes.VoxelShape; +@@ -35,6 +35,8 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; + import net.minecraft.world.phys.shapes.VoxelShapes; +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit + public class BlockLever extends BlockAttachable { public static final MapCodec CODEC = simpleCodec(BlockLever::new); -@@ -102,6 +104,20 @@ +@@ -74,6 +76,20 @@ makeParticle(iblockdata1, world, blockposition, 1.0F); } } else { diff --git a/nms-patches/net/minecraft/world/level/block/BlockMinecartDetector.patch b/nms-patches/net/minecraft/world/level/block/BlockMinecartDetector.patch index 0029fbfc6..78053bc2e 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockMinecartDetector.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockMinecartDetector.patch @@ -9,10 +9,10 @@ public class BlockMinecartDetector extends BlockMinecartTrackAbstract { public static final MapCodec CODEC = simpleCodec(BlockMinecartDetector::new); -@@ -88,6 +90,16 @@ +@@ -87,6 +89,17 @@ + flag1 = true; } - IBlockData iblockdata1; + // CraftBukkit start + if (flag != flag1) { + org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); @@ -23,6 +23,7 @@ + flag1 = eventRedstone.getNewCurrent() > 0; + } + // CraftBukkit end - ++ if (flag1 && !flag) { - iblockdata1 = (IBlockData) iblockdata.setValue(BlockMinecartDetector.POWERED, true); + IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockMinecartDetector.POWERED, true); + diff --git a/nms-patches/net/minecraft/world/level/block/BlockMobSpawner.patch b/nms-patches/net/minecraft/world/level/block/BlockMobSpawner.patch index 99b013b05..5177d1454 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockMobSpawner.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockMobSpawner.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockMobSpawner.java +++ b/net/minecraft/world/level/block/BlockMobSpawner.java -@@ -45,12 +45,20 @@ +@@ -40,11 +40,19 @@ @Override protected void spawnAfterBreak(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) { super.spawnAfterBreak(iblockdata, worldserver, blockposition, itemstack, flag); @@ -20,5 +20,4 @@ + return 0; + // CraftBukkit end } - - @Override + } diff --git a/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch b/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch index 894857ded..832f81498 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockMonsterEggs.java +++ b/net/minecraft/world/level/block/BlockMonsterEggs.java -@@ -20,6 +20,8 @@ +@@ -19,6 +19,8 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.block.state.properties.IBlockState; @@ -9,10 +9,10 @@ public class BlockMonsterEggs extends Block { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -54,7 +56,7 @@ +@@ -53,7 +55,7 @@ if (entitysilverfish != null) { - entitysilverfish.moveTo((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F); + entitysilverfish.snapTo((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F); - worldserver.addFreshEntity(entitysilverfish); + worldserver.addFreshEntity(entitysilverfish, SpawnReason.SILVERFISH_BLOCK); // CraftBukkit - add SpawnReason entitysilverfish.spawnAnim(); diff --git a/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch b/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch index fc6d23338..dd0a8f643 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockMushroom.java +++ b/net/minecraft/world/level/block/BlockMushroom.java -@@ -20,6 +20,10 @@ +@@ -19,6 +19,10 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -8,10 +8,10 @@ +import org.bukkit.TreeType; +// CraftBukkit end + - public class BlockMushroom extends BlockPlant implements IBlockFragilePlantElement { + public class BlockMushroom extends VegetationBlock implements IBlockFragilePlantElement { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -75,7 +79,7 @@ +@@ -70,7 +74,7 @@ } if (worldserver.isEmptyBlock(blockposition2) && iblockdata.canSurvive(worldserver, blockposition2)) { @@ -20,7 +20,7 @@ } } -@@ -101,6 +105,7 @@ +@@ -96,6 +100,7 @@ return false; } else { worldserver.removeBlock(blockposition, false); diff --git a/nms-patches/net/minecraft/world/level/block/BlockNetherWart.patch b/nms-patches/net/minecraft/world/level/block/BlockNetherWart.patch index 3e9f116ef..bc556791d 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockNetherWart.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockNetherWart.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockNetherWart.java +++ b/net/minecraft/world/level/block/BlockNetherWart.java -@@ -54,7 +54,7 @@ +@@ -56,7 +56,7 @@ if (i < 3 && randomsource.nextInt(10) == 0) { iblockdata = (IBlockData) iblockdata.setValue(BlockNetherWart.AGE, i + 1); diff --git a/nms-patches/net/minecraft/world/level/block/BlockPortal.patch b/nms-patches/net/minecraft/world/level/block/BlockPortal.patch index 70f5f61d9..1b0b57e7b 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockPortal.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockPortal.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/BlockPortal.java +++ b/net/minecraft/world/level/block/BlockPortal.java -@@ -39,6 +39,15 @@ - import net.minecraft.world.phys.shapes.VoxelShapeCollision; +@@ -42,6 +42,15 @@ + import net.minecraft.world.phys.shapes.VoxelShapes; import org.slf4j.Logger; +// CraftBukkit start @@ -15,7 +15,7 @@ + public class BlockPortal extends Block implements Portal { - public static final MapCodec CODEC = simpleCodec(BlockPortal::new); + private static final Logger LOGGER = LogUtils.getLogger(); @@ -77,7 +86,8 @@ } @@ -28,7 +28,7 @@ entity.setPortalCooldown(); @@ -104,6 +114,10 @@ @Override - protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity, InsideBlockEffectApplier insideblockeffectapplier) { if (entity.canUsePortal(false)) { + // CraftBukkit start - Entity in portal + EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ())); diff --git a/nms-patches/net/minecraft/world/level/block/BlockPressurePlateAbstract.patch b/nms-patches/net/minecraft/world/level/block/BlockPressurePlateAbstract.patch index e429e95a7..23346d05d 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockPressurePlateAbstract.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockPressurePlateAbstract.patch @@ -8,7 +8,7 @@ + public abstract class BlockPressurePlateAbstract extends Block { - protected static final VoxelShape PRESSED_AABB = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 0.5D, 15.0D); + private static final VoxelShape SHAPE_PRESSED = Block.column(14.0D, 0.0D, 0.5D); @@ -91,6 +93,19 @@ boolean flag = i > 0; boolean flag1 = j > 0; @@ -29,7 +29,7 @@ if (i != j) { IBlockData iblockdata1 = this.setSignalForState(iblockdata, j); -@@ -145,9 +160,15 @@ +@@ -142,9 +157,15 @@ } protected static int getEntityCount(World world, AxisAlignedBB axisalignedbb, Class oclass) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch b/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch index c7033e7a1..b7a698c69 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockPumpkinCarved.java +++ b/net/minecraft/world/level/block/BlockPumpkinCarved.java -@@ -25,6 +25,10 @@ +@@ -24,6 +24,10 @@ import net.minecraft.world.level.block.state.predicate.BlockStatePredicate; import net.minecraft.world.level.block.state.properties.BlockStateEnum; @@ -11,13 +11,13 @@ public class BlockPumpkinCarved extends BlockFacingHorizontal { public static final MapCodec CODEC = simpleCodec(BlockPumpkinCarved::new); -@@ -87,9 +91,14 @@ +@@ -86,9 +90,14 @@ } private static void spawnGolemInWorld(World world, ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection, Entity entity, BlockPosition blockposition) { - clearPatternBlocks(world, shapedetector_shapedetectorcollection); + // clearPatternBlocks(world, shapedetector_shapedetectorcollection); // CraftBukkit - moved down - entity.moveTo((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.05D, (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F); + entity.snapTo((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.05D, (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F); - world.addFreshEntity(entity); + // CraftBukkit start + if (!world.addFreshEntity(entity, (entity.getType() == EntityTypes.SNOW_GOLEM) ? SpawnReason.BUILD_SNOWMAN : SpawnReason.BUILD_IRONGOLEM)) { @@ -25,6 +25,6 @@ + } + clearPatternBlocks(world, shapedetector_shapedetectorcollection); // CraftBukkit - from above + // CraftBukkit end - Iterator iterator = world.getEntitiesOfClass(EntityPlayer.class, entity.getBoundingBox().inflate(5.0D)).iterator(); - while (iterator.hasNext()) { + for (EntityPlayer entityplayer : world.getEntitiesOfClass(EntityPlayer.class, entity.getBoundingBox().inflate(5.0D))) { + CriterionTriggers.SUMMONED_ENTITY.trigger(entityplayer, entity); diff --git a/nms-patches/net/minecraft/world/level/block/BlockRedstoneComparator.patch b/nms-patches/net/minecraft/world/level/block/BlockRedstoneComparator.patch index dc9826b6d..f73f2c7cf 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockRedstoneComparator.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockRedstoneComparator.patch @@ -9,17 +9,7 @@ public class BlockRedstoneComparator extends BlockDiodeAbstract implements ITileEntity { public static final MapCodec CODEC = simpleCodec(BlockRedstoneComparator::new); -@@ -110,7 +112,8 @@ - - @Nullable - private EntityItemFrame getItemFrame(World world, EnumDirection enumdirection, BlockPosition blockposition) { -- List list = world.getEntitiesOfClass(EntityItemFrame.class, new AxisAlignedBB((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), (double) (blockposition.getX() + 1), (double) (blockposition.getY() + 1), (double) (blockposition.getZ() + 1)), (entityitemframe) -> { -+ // CraftBukkit - decompile error -+ List list = world.getEntitiesOfClass(EntityItemFrame.class, new AxisAlignedBB((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), (double) (blockposition.getX() + 1), (double) (blockposition.getY() + 1), (double) (blockposition.getZ() + 1)), (java.util.function.Predicate) (entityitemframe) -> { - return entityitemframe != null && entityitemframe.getDirection() == enumdirection; - }); - -@@ -163,8 +166,18 @@ +@@ -163,8 +165,18 @@ boolean flag1 = (Boolean) iblockdata.getValue(BlockRedstoneComparator.POWERED); if (flag1 && !flag) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockRedstoneTorch.patch b/nms-patches/net/minecraft/world/level/block/BlockRedstoneTorch.patch index 8d82d1033..f0f588416 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockRedstoneTorch.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockRedstoneTorch.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockRedstoneTorch.java +++ b/net/minecraft/world/level/block/BlockRedstoneTorch.java -@@ -22,6 +22,8 @@ +@@ -21,6 +21,8 @@ import net.minecraft.world.level.redstone.ExperimentalRedstoneUtils; import net.minecraft.world.level.redstone.Orientation; @@ -9,7 +9,7 @@ public class BlockRedstoneTorch extends BaseTorchBlock { public static final MapCodec CODEC = simpleCodec(BlockRedstoneTorch::new); -@@ -85,8 +87,24 @@ +@@ -81,8 +83,24 @@ list.remove(0); } @@ -34,7 +34,7 @@ worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockRedstoneTorch.LIT, false), 3); if (isToggledTooFrequently(worldserver, blockposition, true)) { worldserver.levelEvent(1502, blockposition, 0); -@@ -94,6 +112,15 @@ +@@ -90,6 +108,15 @@ } } } else if (!flag && !isToggledTooFrequently(worldserver, blockposition, false)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockReed.patch b/nms-patches/net/minecraft/world/level/block/BlockReed.patch index 332579a6d..a8b5613f6 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockReed.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockReed.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/BlockReed.java +++ b/net/minecraft/world/level/block/BlockReed.java -@@ -63,7 +63,7 @@ +@@ -61,7 +61,7 @@ int j = (Integer) iblockdata.getValue(BlockReed.AGE); if (j == 15) { - worldserver.setBlockAndUpdate(blockposition.above(), this.defaultBlockState()); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition.above(), this.defaultBlockState()); // CraftBukkit - worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockReed.AGE, 0), 4); + worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockReed.AGE, 0), 260); } else { - worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockReed.AGE, j + 1), 4); + worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockReed.AGE, j + 1), 260); diff --git a/nms-patches/net/minecraft/world/level/block/BlockRespawnAnchor.patch b/nms-patches/net/minecraft/world/level/block/BlockRespawnAnchor.patch index 3dc1bbb4f..f490ee24f 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockRespawnAnchor.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockRespawnAnchor.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/BlockRespawnAnchor.java +++ b/net/minecraft/world/level/block/BlockRespawnAnchor.java -@@ -88,7 +88,7 @@ - EntityPlayer entityplayer = (EntityPlayer) entityhuman; +@@ -89,7 +89,7 @@ + EntityPlayer.RespawnConfig entityplayer_respawnconfig1 = new EntityPlayer.RespawnConfig(world.dimension(), blockposition, 0.0F, false); - if (entityplayer.getRespawnDimension() != world.dimension() || !blockposition.equals(entityplayer.getRespawnPosition())) { -- entityplayer.setRespawnPosition(world.dimension(), blockposition, 0.0F, false, true); -+ entityplayer.setRespawnPosition(world.dimension(), blockposition, 0.0F, false, true, org.bukkit.event.player.PlayerSpawnChangeEvent.Cause.RESPAWN_ANCHOR); // CraftBukkit - world.playSound((EntityHuman) null, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, SoundEffects.RESPAWN_ANCHOR_SET_SPAWN, SoundCategory.BLOCKS, 1.0F, 1.0F); + if (entityplayer_respawnconfig == null || !entityplayer_respawnconfig.isSamePosition(entityplayer_respawnconfig1)) { +- entityplayer.setRespawnPosition(entityplayer_respawnconfig1, true); ++ entityplayer.setRespawnPosition(entityplayer_respawnconfig1, true, org.bukkit.event.player.PlayerSpawnChangeEvent.Cause.RESPAWN_ANCHOR); // CraftBukkit + world.playSound((Entity) null, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, SoundEffects.RESPAWN_ANCHOR_SET_SPAWN, SoundCategory.BLOCKS, 1.0F, 1.0F); return EnumInteractionResult.SUCCESS_SERVER; } -@@ -127,15 +127,16 @@ +@@ -128,8 +128,9 @@ } private void explode(IBlockData iblockdata, World world, final BlockPosition blockposition) { @@ -20,15 +20,7 @@ Objects.requireNonNull(blockposition); boolean flag = stream.map(blockposition::relative).anyMatch((blockposition1) -> { - return isWaterThatWouldFlow(blockposition1, world); - }); - final boolean flag1 = flag || world.getFluidState(blockposition.above()).is(TagsFluid.WATER); -- ExplosionDamageCalculator explosiondamagecalculator = new ExplosionDamageCalculator(this) { -+ ExplosionDamageCalculator explosiondamagecalculator = new ExplosionDamageCalculator() { // CraftBukkit - decompile error - @Override - public Optional getBlockExplosionResistance(Explosion explosion, IBlockAccess iblockaccess, BlockPosition blockposition1, IBlockData iblockdata1, Fluid fluid) { - return blockposition1.equals(blockposition) && flag1 ? Optional.of(Blocks.WATER.getExplosionResistance()) : super.getBlockExplosionResistance(explosion, iblockaccess, blockposition1, iblockdata1, fluid); -@@ -143,7 +144,7 @@ +@@ -144,7 +145,7 @@ }; Vec3D vec3d = blockposition.getCenter(); diff --git a/nms-patches/net/minecraft/world/level/block/BlockSapling.patch b/nms-patches/net/minecraft/world/level/block/BlockSapling.patch index c31af8eb7..c89e7fc63 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockSapling.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockSapling.patch @@ -13,20 +13,20 @@ +import org.bukkit.event.world.StructureGrowEvent; +// CraftBukkit end + - public class BlockSapling extends BlockPlant implements IBlockFragilePlantElement { + public class BlockSapling extends VegetationBlock implements IBlockFragilePlantElement { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -28,6 +37,7 @@ - protected static final float AABB_OFFSET = 6.0F; - protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D); +@@ -27,6 +36,7 @@ + public static final BlockStateInteger STAGE = BlockProperties.STAGE; + private static final VoxelShape SHAPE = Block.column(12.0D, 0.0D, 12.0D); protected final WorldGenTreeProvider treeGrower; + public static TreeType treeType; // CraftBukkit @Override public MapCodec codec() { -@@ -57,7 +67,32 @@ +@@ -56,7 +66,32 @@ if ((Integer) iblockdata.getValue(BlockSapling.STAGE) == 0) { - worldserver.setBlock(blockposition, (IBlockData) iblockdata.cycle(BlockSapling.STAGE), 4); + worldserver.setBlock(blockposition, (IBlockData) iblockdata.cycle(BlockSapling.STAGE), 260); } else { - this.treeGrower.growTree(worldserver, worldserver.getChunkSource().getGenerator(), blockposition, iblockdata, randomsource); + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/level/block/BlockScaffolding.patch b/nms-patches/net/minecraft/world/level/block/BlockScaffolding.patch index d151507de..96a87d6bb 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockScaffolding.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockScaffolding.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockScaffolding.java +++ b/net/minecraft/world/level/block/BlockScaffolding.java -@@ -103,7 +103,7 @@ +@@ -102,7 +102,7 @@ int i = getDistance(worldserver, blockposition); IBlockData iblockdata1 = (IBlockData) ((IBlockData) iblockdata.setValue(BlockScaffolding.DISTANCE, i)).setValue(BlockScaffolding.BOTTOM, this.isBottom(worldserver, blockposition, i)); diff --git a/nms-patches/net/minecraft/world/level/block/BlockSign.patch b/nms-patches/net/minecraft/world/level/block/BlockSign.patch index 677b87be0..da96698e5 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockSign.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockSign.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockSign.java +++ b/net/minecraft/world/level/block/BlockSign.java -@@ -140,7 +140,7 @@ +@@ -139,7 +139,7 @@ } else if (flag1) { return EnumInteractionResult.SUCCESS_SERVER; } else if (!this.otherPlayerIsEditingSign(entityhuman, tileentitysign) && entityhuman.mayBuild() && this.hasEditableText(entityhuman, tileentitysign, flag)) { @@ -9,7 +9,7 @@ return EnumInteractionResult.SUCCESS_SERVER; } else { return EnumInteractionResult.PASS; -@@ -186,6 +186,15 @@ +@@ -185,6 +185,15 @@ } public void openTextEdit(EntityHuman entityhuman, TileEntitySign tileentitysign, boolean flag) { @@ -25,7 +25,7 @@ tileentitysign.setAllowedPlayerEditor(entityhuman.getUUID()); entityhuman.openTextEdit(tileentitysign, flag); } -@@ -199,6 +208,6 @@ +@@ -198,6 +207,6 @@ @Nullable @Override public BlockEntityTicker getTicker(World world, IBlockData iblockdata, TileEntityTypes tileentitytypes) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockSnow.patch b/nms-patches/net/minecraft/world/level/block/BlockSnow.patch index 17758fccc..4c9cc63d6 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockSnow.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockSnow.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockSnow.java +++ b/net/minecraft/world/level/block/BlockSnow.java -@@ -99,6 +99,11 @@ +@@ -91,6 +91,11 @@ @Override protected void randomTick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, RandomSource randomsource) { if (worldserver.getBrightness(EnumSkyBlock.BLOCK, blockposition) > 11) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockSoil.patch b/nms-patches/net/minecraft/world/level/block/BlockSoil.patch index 4f6c91e2d..d6bf67c19 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockSoil.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockSoil.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockSoil.java +++ b/net/minecraft/world/level/block/BlockSoil.java -@@ -30,6 +30,11 @@ +@@ -28,6 +28,11 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -12,7 +12,7 @@ public class BlockSoil extends Block { public static final MapCodec CODEC = simpleCodec(BlockSoil::new); -@@ -92,28 +97,51 @@ +@@ -90,28 +95,51 @@ if (!isNearWater(worldserver, blockposition) && !worldserver.isRainingAt(blockposition.above())) { if (i > 0) { @@ -29,10 +29,10 @@ } @Override - public void fallOn(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, float f) { -+ super.fallOn(world, iblockdata, blockposition, entity, f); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage. + public void fallOn(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, double d0) { ++ super.fallOn(world, iblockdata, blockposition, entity, d0); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage. if (world instanceof WorldServer worldserver) { - if (world.random.nextFloat() < f - 0.5F && entity instanceof EntityLiving && (entity instanceof EntityHuman || worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) && entity.getBbWidth() * entity.getBbWidth() * entity.getBbHeight() > 0.512F) { + if ((double) world.random.nextFloat() < d0 - 0.5D && entity instanceof EntityLiving && (entity instanceof EntityHuman || worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) && entity.getBbWidth() * entity.getBbWidth() * entity.getBbHeight() > 0.512F) { + // CraftBukkit start - Interact soil + org.bukkit.event.Cancellable cancellable; + if (entity instanceof EntityHuman) { @@ -54,8 +54,8 @@ } } -- super.fallOn(world, iblockdata, blockposition, entity, f); -+ // super.fallOn(world, iblockdata, blockposition, entity, f); // CraftBukkit - moved up +- super.fallOn(world, iblockdata, blockposition, entity, d0); ++ // super.fallOn(world, iblockdata, blockposition, entity, d0); // CraftBukkit - moved up } public static void turnToDirt(@Nullable Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockSponge.patch b/nms-patches/net/minecraft/world/level/block/BlockSponge.patch index 485c39764..6fccbc269 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockSponge.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockSponge.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockSponge.java +++ b/net/minecraft/world/level/block/BlockSponge.java -@@ -15,6 +15,13 @@ +@@ -16,6 +16,13 @@ import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.redstone.Orientation; @@ -14,17 +14,17 @@ public class BlockSponge extends Block { public static final MapCodec CODEC = simpleCodec(BlockSponge::new); -@@ -53,7 +60,8 @@ +@@ -54,7 +61,8 @@ } private boolean removeWaterBreadthFirstSearch(World world, BlockPosition blockposition) { - return BlockPosition.breadthFirstTraversal(blockposition, 6, 65, (blockposition1, consumer) -> { + BlockStateListPopulator blockList = new BlockStateListPopulator(world); // CraftBukkit - Use BlockStateListPopulator + BlockPosition.breadthFirstTraversal(blockposition, 6, 65, (blockposition1, consumer) -> { - EnumDirection[] aenumdirection = BlockSponge.ALL_DIRECTIONS; - int i = aenumdirection.length; - -@@ -67,8 +75,10 @@ + for (EnumDirection enumdirection : BlockSponge.ALL_DIRECTIONS) { + consumer.accept(blockposition1.relative(enumdirection)); + } +@@ -63,8 +71,10 @@ if (blockposition1.equals(blockposition)) { return BlockPosition.b.ACCEPT; } else { @@ -37,12 +37,12 @@ if (!fluid.is(TagsFluid.WATER)) { return BlockPosition.b.SKIP; -@@ -78,27 +88,64 @@ +@@ -74,27 +84,64 @@ if (block instanceof IFluidSource) { IFluidSource ifluidsource = (IFluidSource) block; -- if (!ifluidsource.pickupBlock((EntityHuman) null, world, blockposition1, iblockdata).isEmpty()) { -+ if (!ifluidsource.pickupBlock((EntityHuman) null, blockList, blockposition1, iblockdata).isEmpty()) { // CraftBukkit +- if (!ifluidsource.pickupBlock((EntityLiving) null, world, blockposition1, iblockdata).isEmpty()) { ++ if (!ifluidsource.pickupBlock((EntityLiving) null, blockList, blockposition1, iblockdata).isEmpty()) { // CraftBukkit return BlockPosition.b.ACCEPT; } } @@ -89,7 +89,7 @@ + Fluid fluid = world.getFluidState(blockposition1); + + if (fluid.is(TagsFluid.WATER)) { -+ if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).pickupBlock((EntityHuman) null, blockList, blockposition1, iblockdata).isEmpty()) { ++ if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).pickupBlock((EntityLiving) null, blockList, blockposition1, iblockdata).isEmpty()) { + // NOP + } else if (iblockdata.getBlock() instanceof BlockFluids) { + // NOP diff --git a/nms-patches/net/minecraft/world/level/block/BlockStem.patch b/nms-patches/net/minecraft/world/level/block/BlockStem.patch index d1f2af041..306711677 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockStem.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockStem.patch @@ -6,10 +6,10 @@ +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + - public class BlockStem extends BlockPlant implements IBlockFragilePlantElement { + public class BlockStem extends VegetationBlock implements IBlockFragilePlantElement { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -79,7 +81,7 @@ +@@ -80,7 +82,7 @@ if (i < 7) { iblockdata = (IBlockData) iblockdata.setValue(BlockStem.AGE, i + 1); @@ -18,7 +18,7 @@ } else { EnumDirection enumdirection = EnumDirection.EnumDirectionLimit.HORIZONTAL.getRandomDirection(randomsource); BlockPosition blockposition1 = blockposition.relative(enumdirection); -@@ -91,7 +93,11 @@ +@@ -92,7 +94,11 @@ Optional optional1 = iregistry.getOptional(this.attachedStem); if (optional.isPresent() && optional1.isPresent()) { @@ -31,7 +31,7 @@ worldserver.setBlockAndUpdate(blockposition, (IBlockData) ((Block) optional1.get()).defaultBlockState().setValue(BlockFacingHorizontal.FACING, enumdirection)); } } -@@ -121,7 +127,7 @@ +@@ -122,7 +128,7 @@ int i = Math.min(7, (Integer) iblockdata.getValue(BlockStem.AGE) + MathHelper.nextInt(worldserver.random, 2, 5)); IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockStem.AGE, i); diff --git a/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch b/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch index a2a2f3145..6e13f2034 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/BlockSweetBerryBush.java +++ b/net/minecraft/world/level/block/BlockSweetBerryBush.java -@@ -29,6 +29,13 @@ - import net.minecraft.world.phys.shapes.VoxelShape; +@@ -30,6 +30,13 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; + import net.minecraft.world.phys.shapes.VoxelShapes; +// CraftBukkit start +import java.util.Collections; @@ -11,28 +11,28 @@ +import org.bukkit.event.player.PlayerHarvestBlockEvent; +// CraftBukkit end + - public class BlockSweetBerryBush extends BlockPlant implements IBlockFragilePlantElement { + public class BlockSweetBerryBush extends VegetationBlock implements IBlockFragilePlantElement { public static final MapCodec CODEC = simpleCodec(BlockSweetBerryBush::new); -@@ -70,7 +77,7 @@ +@@ -84,7 +91,7 @@ if (i < 3 && randomsource.nextInt(5) == 0 && worldserver.getRawBrightness(blockposition.above(), 0) >= 9) { IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSweetBerryBush.AGE, i + 1); - worldserver.setBlock(blockposition, iblockdata1, 2); + if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata1, 2)) return; // CraftBukkit - worldserver.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1)); + worldserver.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1)); } -@@ -91,7 +98,7 @@ +@@ -105,7 +112,7 @@ double d1 = Math.abs(vec3d.z()); - if (d0 >= 0.003000000026077032D || d1 >= 0.003000000026077032D) { + if (d0 >= (double) 0.003F || d1 >= (double) 0.003F) { - entity.hurtServer(worldserver, world.damageSources().sweetBerryBush(), 1.0F); + entity.hurtServer(worldserver, world.damageSources().sweetBerryBush().directBlock(world, blockposition), 1.0F); // CraftBukkit } } -@@ -118,7 +125,15 @@ +@@ -132,7 +139,15 @@ if (i > 1) { int j = 1 + world.random.nextInt(2); @@ -46,6 +46,6 @@ + popResource(world, blockposition, CraftItemStack.asNMSCopy(itemStack)); + } + // CraftBukkit end - world.playSound((EntityHuman) null, blockposition, SoundEffects.SWEET_BERRY_BUSH_PICK_BERRIES, SoundCategory.BLOCKS, 1.0F, 0.8F + world.random.nextFloat() * 0.4F); + world.playSound((Entity) null, blockposition, SoundEffects.SWEET_BERRY_BUSH_PICK_BERRIES, SoundCategory.BLOCKS, 1.0F, 0.8F + world.random.nextFloat() * 0.4F); IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSweetBerryBush.AGE, 1); diff --git a/nms-patches/net/minecraft/world/level/block/BlockTNT.patch b/nms-patches/net/minecraft/world/level/block/BlockTNT.patch index 9c7445727..5fb21bf3f 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTNT.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockTNT.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockTNT.java +++ b/net/minecraft/world/level/block/BlockTNT.java -@@ -29,6 +29,11 @@ +@@ -31,6 +31,11 @@ import net.minecraft.world.level.redstone.Orientation; import net.minecraft.world.phys.MovingObjectPositionBlock; @@ -12,34 +12,34 @@ public class BlockTNT extends Block { public static final MapCodec CODEC = simpleCodec(BlockTNT::new); -@@ -47,7 +52,7 @@ +@@ -49,7 +54,7 @@ @Override protected void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) { if (!iblockdata1.is(iblockdata.getBlock())) { -- if (world.hasNeighborSignal(blockposition)) { -+ if (world.hasNeighborSignal(blockposition) && CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent - explode(world, blockposition); +- if (world.hasNeighborSignal(blockposition) && prime(world, blockposition)) { ++ if (world.hasNeighborSignal(blockposition) && CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.REDSTONE, null, null) && prime(world, blockposition)) { // CraftBukkit - TNTPrimeEvent world.removeBlock(blockposition, false); } -@@ -57,7 +62,7 @@ + +@@ -58,7 +63,7 @@ @Override protected void neighborChanged(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, @Nullable Orientation orientation, boolean flag) { -- if (world.hasNeighborSignal(blockposition)) { -+ if (world.hasNeighborSignal(blockposition) && CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent - explode(world, blockposition); +- if (world.hasNeighborSignal(blockposition) && prime(world, blockposition)) { ++ if (world.hasNeighborSignal(blockposition) && CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.REDSTONE, null, null) && prime(world, blockposition)) { // CraftBukkit - TNTPrimeEvent world.removeBlock(blockposition, false); } + @@ -66,7 +71,7 @@ @Override public IBlockData playerWillDestroy(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) { -- if (!world.isClientSide() && !entityhuman.isCreative() && (Boolean) iblockdata.getValue(BlockTNT.UNSTABLE)) { -+ if (!world.isClientSide() && !entityhuman.isCreative() && (Boolean) iblockdata.getValue(BlockTNT.UNSTABLE) && CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.BLOCK_BREAK, entityhuman, null)) { // CraftBukkit - TNTPrimeEvent - explode(world, blockposition); +- if (!world.isClientSide() && !entityhuman.getAbilities().instabuild && (Boolean) iblockdata.getValue(BlockTNT.UNSTABLE)) { ++ if (!world.isClientSide() && !entityhuman.getAbilities().instabuild && (Boolean) iblockdata.getValue(BlockTNT.UNSTABLE) && CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.BLOCK_BREAK, entityhuman, null)) { // CraftBukkit - TNTPrimeEvent + prime(world, blockposition); } -@@ -101,6 +106,11 @@ +@@ -108,6 +113,11 @@ if (!itemstack.is(Items.FLINT_AND_STEEL) && !itemstack.is(Items.FIRE_CHARGE)) { return super.useItemOn(itemstack, iblockdata, world, blockposition, entityhuman, enumhand, movingobjectpositionblock); } else { @@ -48,18 +48,16 @@ + return EnumInteractionResult.CONSUME; + } + // CraftBukkit end - explode(world, blockposition, entityhuman); - world.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 11); - Item item = itemstack.getItem(); -@@ -123,6 +133,11 @@ + if (prime(world, blockposition, entityhuman)) { + world.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 11); + Item item = itemstack.getItem(); +@@ -138,7 +148,8 @@ + BlockPosition blockposition = movingobjectpositionblock.getBlockPos(); Entity entity = iprojectile.getOwner(); - if (iprojectile.isOnFire() && iprojectile.mayInteract(worldserver, blockposition)) { -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState()) || !CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.PROJECTILE, iprojectile, null)) { -+ return; -+ } -+ // CraftBukkit end - explode(world, blockposition, entity instanceof EntityLiving ? (EntityLiving) entity : null); +- if (iprojectile.isOnFire() && iprojectile.mayInteract(worldserver, blockposition) && prime(world, blockposition, entity instanceof EntityLiving ? (EntityLiving) entity : null)) { ++ // CraftBukkit - TNTPrimeEvent ++ if (iprojectile.isOnFire() && iprojectile.mayInteract(worldserver, blockposition) && org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState()) && CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.PROJECTILE, iprojectile, null) && prime(world, blockposition, entity instanceof EntityLiving ? (EntityLiving) entity : null)) { world.removeBlock(blockposition, false); } + } diff --git a/nms-patches/net/minecraft/world/level/block/BlockTallPlant.patch b/nms-patches/net/minecraft/world/level/block/BlockTallPlant.patch index af55991d8..fccc784ea 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTallPlant.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockTallPlant.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockTallPlant.java +++ b/net/minecraft/world/level/block/BlockTallPlant.java -@@ -103,6 +103,11 @@ +@@ -102,6 +102,11 @@ } protected static void preventDropFromBottomPart(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch b/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch index f9c7facd1..f93556e14 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/BlockTrapdoor.java +++ b/net/minecraft/world/level/block/BlockTrapdoor.java -@@ -38,6 +38,8 @@ - import net.minecraft.world.phys.shapes.VoxelShape; +@@ -39,6 +39,8 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; + import net.minecraft.world.phys.shapes.VoxelShapes; +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit + public class BlockTrapdoor extends BlockFacingHorizontal implements IBlockWaterlogged { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -143,6 +145,19 @@ +@@ -124,6 +126,19 @@ boolean flag1 = world.hasNeighborSignal(blockposition); if (flag1 != (Boolean) iblockdata.getValue(BlockTrapdoor.POWERED)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockTripwire.patch b/nms-patches/net/minecraft/world/level/block/BlockTripwire.patch index bc230018b..5ec01b650 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTripwire.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockTripwire.patch @@ -9,7 +9,32 @@ public class BlockTripwire extends Block { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -179,6 +181,40 @@ +@@ -107,7 +109,7 @@ + for (EnumDirection enumdirection : new EnumDirection[]{EnumDirection.SOUTH, EnumDirection.WEST}) { + int i = 1; + +- while (true) { ++ for (; i < 42; i++) { // CraftBukkit - decompile error + if (i < 42) { + BlockPosition blockposition1 = blockposition.relative(enumdirection, i); + IBlockData iblockdata1 = world.getBlockState(blockposition1); +@@ -116,9 +118,12 @@ + if (iblockdata1.getValue(BlockTripwireHook.FACING) == enumdirection.getOpposite()) { + BlockTripwireHook.calculateState(world, blockposition1, iblockdata1, false, true, i, iblockdata); + } +- } else if (iblockdata1.is(this)) { +- ++i; +- continue; ++ // CraftBukkit start - decompile error ++ break; ++ } ++ if (!iblockdata1.is(this)) { ++ break; ++ // CraftBukkit end + } + } + } +@@ -168,6 +173,40 @@ } } diff --git a/nms-patches/net/minecraft/world/level/block/BlockTripwireHook.patch b/nms-patches/net/minecraft/world/level/block/BlockTripwireHook.patch index 01475895a..8d6c74d00 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTripwireHook.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockTripwireHook.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/BlockTripwireHook.java +++ b/net/minecraft/world/level/block/BlockTripwireHook.java -@@ -32,6 +32,11 @@ - import net.minecraft.world.phys.shapes.VoxelShape; +@@ -33,6 +33,11 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; + import net.minecraft.world.phys.shapes.VoxelShapes; +// CraftBukkit start +import org.bukkit.craftbukkit.block.CraftBlock; @@ -12,8 +12,8 @@ public class BlockTripwireHook extends Block { public static final MapCodec CODEC = simpleCodec(BlockTripwireHook::new); -@@ -176,6 +181,15 @@ - emitState(world, blockposition1, flag4, flag5, flag2, flag3); +@@ -157,6 +162,15 @@ + emitState(world, blockposition2, flag4, flag5, flag2, flag3); } + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch b/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch index f9aedfa84..4871b5869 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockTurtleEgg.java +++ b/net/minecraft/world/level/block/BlockTurtleEgg.java -@@ -32,6 +32,12 @@ +@@ -31,6 +31,12 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -13,7 +13,7 @@ public class BlockTurtleEgg extends Block { public static final MapCodec CODEC = simpleCodec(BlockTurtleEgg::new); -@@ -74,6 +80,19 @@ +@@ -73,6 +79,19 @@ private void destroyEgg(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, int i) { if (iblockdata.is(Blocks.TURTLE_EGG) && world instanceof WorldServer worldserver) { if (this.canDestroyEgg(worldserver, entity) && world.random.nextInt(i) == 0) { @@ -33,7 +33,7 @@ this.decreaseEggs(worldserver, blockposition, iblockdata); } } -@@ -100,10 +119,20 @@ +@@ -99,10 +118,20 @@ int i = (Integer) iblockdata.getValue(BlockTurtleEgg.HATCH); if (i < 2) { @@ -42,23 +42,23 @@ + return; + } + // CraftBukkit end - worldserver.playSound((EntityHuman) null, blockposition, SoundEffects.TURTLE_EGG_CRACK, SoundCategory.BLOCKS, 0.7F, 0.9F + randomsource.nextFloat() * 0.2F); + worldserver.playSound((Entity) null, blockposition, SoundEffects.TURTLE_EGG_CRACK, SoundCategory.BLOCKS, 0.7F, 0.9F + randomsource.nextFloat() * 0.2F); - worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockTurtleEgg.HATCH, i + 1), 2); + // worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockTurtleEgg.HATCH, i + 1), 2); // CraftBukkit - handled above - worldserver.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata)); + worldserver.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata)); } else { + // CraftBukkit start - Call BlockFadeEvent + if (CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - worldserver.playSound((EntityHuman) null, blockposition, SoundEffects.TURTLE_EGG_HATCH, SoundCategory.BLOCKS, 0.7F, 0.9F + randomsource.nextFloat() * 0.2F); + worldserver.playSound((Entity) null, blockposition, SoundEffects.TURTLE_EGG_HATCH, SoundCategory.BLOCKS, 0.7F, 0.9F + randomsource.nextFloat() * 0.2F); worldserver.removeBlock(blockposition, false); - worldserver.gameEvent((Holder) GameEvent.BLOCK_DESTROY, blockposition, GameEvent.a.of(iblockdata)); -@@ -116,7 +145,7 @@ + worldserver.gameEvent(GameEvent.BLOCK_DESTROY, blockposition, GameEvent.a.of(iblockdata)); +@@ -115,7 +144,7 @@ entityturtle.setAge(-24000); entityturtle.setHomePos(blockposition); - entityturtle.moveTo((double) blockposition.getX() + 0.3D + (double) j * 0.2D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.3D, 0.0F, 0.0F); + entityturtle.snapTo((double) blockposition.getX() + 0.3D + (double) j * 0.2D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.3D, 0.0F, 0.0F); - worldserver.addFreshEntity(entityturtle); + worldserver.addFreshEntity(entityturtle, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); // CraftBukkit } diff --git a/nms-patches/net/minecraft/world/level/block/BlockVine.patch b/nms-patches/net/minecraft/world/level/block/BlockVine.patch index 7ebaef3b4..3f8c0d5ca 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockVine.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockVine.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockVine.java +++ b/net/minecraft/world/level/block/BlockVine.java -@@ -25,6 +25,8 @@ +@@ -23,6 +23,8 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -9,7 +9,7 @@ public class BlockVine extends Block { public static final MapCodec CODEC = simpleCodec(BlockVine::new); -@@ -203,30 +205,34 @@ +@@ -178,30 +180,34 @@ BlockPosition blockposition3 = blockposition2.relative(enumdirection1); BlockPosition blockposition4 = blockposition2.relative(enumdirection2); @@ -51,7 +51,7 @@ return; } -@@ -246,7 +252,7 @@ +@@ -219,7 +225,7 @@ } if (this.hasHorizontalConnection(iblockdata2)) { @@ -60,12 +60,12 @@ } return; -@@ -261,7 +267,7 @@ - IBlockData iblockdata4 = this.copyRandomFaces(iblockdata, iblockdata3, randomsource); +@@ -235,7 +241,7 @@ + IBlockData iblockdata5 = this.copyRandomFaces(iblockdata, iblockdata4, randomsource); - if (iblockdata3 != iblockdata4 && this.hasHorizontalConnection(iblockdata4)) { -- worldserver.setBlock(blockposition2, iblockdata4, 2); -+ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition2, iblockdata4, 2); // CraftBukkit + if (iblockdata4 != iblockdata5 && this.hasHorizontalConnection(iblockdata5)) { +- worldserver.setBlock(blockposition5, iblockdata5, 2); ++ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition5, iblockdata5, 2); // CraftBukkit } } } diff --git a/nms-patches/net/minecraft/world/level/block/BlockWaterLily.patch b/nms-patches/net/minecraft/world/level/block/BlockWaterLily.patch index 6423b8bbd..4ef621aac 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockWaterLily.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockWaterLily.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockWaterLily.java +++ b/net/minecraft/world/level/block/BlockWaterLily.java -@@ -14,6 +14,10 @@ +@@ -15,6 +15,10 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -8,12 +8,12 @@ +import org.bukkit.craftbukkit.event.CraftEventFactory; +// CraftBukkit end + - public class BlockWaterLily extends BlockPlant { + public class BlockWaterLily extends VegetationBlock { public static final MapCodec CODEC = simpleCodec(BlockWaterLily::new); -@@ -32,6 +36,11 @@ - protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { - super.entityInside(iblockdata, world, blockposition, entity); +@@ -33,6 +37,11 @@ + protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity, InsideBlockEffectApplier insideblockeffectapplier) { + super.entityInside(iblockdata, world, blockposition, entity, insideblockeffectapplier); if (world instanceof WorldServer && entity instanceof AbstractBoat) { + // CraftBukkit start + if (!CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.defaultBlockState())) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch b/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch index cfe307b6d..8a1b511c0 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockWitherRose.java +++ b/net/minecraft/world/level/block/BlockWitherRose.java -@@ -66,7 +66,7 @@ +@@ -67,7 +67,7 @@ if (world instanceof WorldServer worldserver) { if (world.getDifficulty() != EnumDifficulty.PEACEFUL && entity instanceof EntityLiving entityliving) { if (!entityliving.isInvulnerableTo(worldserver, world.damageSources().wither())) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch b/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch index 099a259f2..50037fe3f 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockWitherSkull.java +++ b/net/minecraft/world/level/block/BlockWitherSkull.java -@@ -26,6 +26,10 @@ +@@ -24,6 +24,10 @@ import net.minecraft.world.level.block.state.pattern.ShapeDetectorBuilder; import net.minecraft.world.level.block.state.predicate.BlockStatePredicate; @@ -11,7 +11,7 @@ public class BlockWitherSkull extends BlockSkull { public static final MapCodec CODEC = simpleCodec(BlockWitherSkull::new); -@@ -58,6 +62,7 @@ +@@ -56,6 +60,7 @@ } public static void checkSpawn(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) { @@ -19,15 +19,15 @@ if (!world.isClientSide) { IBlockData iblockdata = tileentityskull.getBlockState(); boolean flag = iblockdata.is(Blocks.WITHER_SKELETON_SKULL) || iblockdata.is(Blocks.WITHER_SKELETON_WALL_SKULL); -@@ -69,12 +74,18 @@ - EntityWither entitywither = (EntityWither) EntityTypes.WITHER.create(world, EntitySpawnReason.TRIGGERED); +@@ -67,18 +72,24 @@ + EntityWither entitywither = EntityTypes.WITHER.create(world, EntitySpawnReason.TRIGGERED); if (entitywither != null) { - BlockPumpkinCarved.clearPatternBlocks(world, shapedetector_shapedetectorcollection); + // BlockPumpkinCarved.clearPatternBlocks(world, shapedetector_shapedetectorcollection); // CraftBukkit - move down BlockPosition blockposition1 = shapedetector_shapedetectorcollection.getBlock(1, 2, 0).getPos(); - entitywither.moveTo((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.55D, (double) blockposition1.getZ() + 0.5D, shapedetector_shapedetectorcollection.getForwards().getAxis() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F); + entitywither.snapTo((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.55D, (double) blockposition1.getZ() + 0.5D, shapedetector_shapedetectorcollection.getForwards().getAxis() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F); entitywither.yBodyRot = shapedetector_shapedetectorcollection.getForwards().getAxis() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F; entitywither.makeInvulnerable(); + // CraftBukkit start @@ -36,11 +36,9 @@ + } + BlockPumpkinCarved.clearPatternBlocks(world, shapedetector_shapedetectorcollection); // CraftBukkit - from above + // CraftBukkit end - Iterator iterator = world.getEntitiesOfClass(EntityPlayer.class, entitywither.getBoundingBox().inflate(50.0D)).iterator(); - while (iterator.hasNext()) { -@@ -83,7 +94,7 @@ - CriterionTriggers.SUMMONED_ENTITY.trigger(entityplayer, (Entity) entitywither); + for (EntityPlayer entityplayer : world.getEntitiesOfClass(EntityPlayer.class, entitywither.getBoundingBox().inflate(50.0D))) { + CriterionTriggers.SUMMONED_ENTITY.trigger(entityplayer, entitywither); } - world.addFreshEntity(entitywither); diff --git a/nms-patches/net/minecraft/world/level/block/CaveVines.patch b/nms-patches/net/minecraft/world/level/block/CaveVines.patch index 1184f18f9..dbed56925 100644 --- a/nms-patches/net/minecraft/world/level/block/CaveVines.patch +++ b/nms-patches/net/minecraft/world/level/block/CaveVines.patch @@ -1,11 +1,12 @@ --- a/net/minecraft/world/level/block/CaveVines.java +++ b/net/minecraft/world/level/block/CaveVines.java -@@ -19,6 +19,13 @@ +@@ -17,6 +17,14 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.shapes.VoxelShape; +// CraftBukkit start +import java.util.Collections; ++import net.minecraft.world.entity.player.EntityHuman; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.event.player.PlayerHarvestBlockEvent; @@ -13,8 +14,8 @@ + public interface CaveVines { - VoxelShape SHAPE = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D); -@@ -26,7 +33,24 @@ + VoxelShape SHAPE = Block.column(14.0D, 0.0D, 16.0D); +@@ -24,7 +32,24 @@ static EnumInteractionResult use(@Nullable Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) { if ((Boolean) iblockdata.getValue(CaveVines.BERRIES)) { @@ -39,4 +40,4 @@ + float f = MathHelper.randomBetween(world.random, 0.8F, 1.2F); - world.playSound((EntityHuman) null, blockposition, SoundEffects.CAVE_VINES_PICK_BERRIES, SoundCategory.BLOCKS, 1.0F, f); + world.playSound((Entity) null, blockposition, SoundEffects.CAVE_VINES_PICK_BERRIES, SoundCategory.BLOCKS, 1.0F, f); diff --git a/nms-patches/net/minecraft/world/level/block/ChangeOverTimeBlock.patch b/nms-patches/net/minecraft/world/level/block/ChangeOverTimeBlock.patch index cb2cffd6c..4997b7145 100644 --- a/nms-patches/net/minecraft/world/level/block/ChangeOverTimeBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/ChangeOverTimeBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ChangeOverTimeBlock.java +++ b/net/minecraft/world/level/block/ChangeOverTimeBlock.java -@@ -20,7 +20,7 @@ +@@ -19,7 +19,7 @@ if (randomsource.nextFloat() < 0.05688889F) { this.getNextState(iblockdata, worldserver, blockposition, randomsource).ifPresent((iblockdata1) -> { diff --git a/nms-patches/net/minecraft/world/level/block/CrafterBlock.patch b/nms-patches/net/minecraft/world/level/block/CrafterBlock.patch index 10808668b..4f13147a8 100644 --- a/nms-patches/net/minecraft/world/level/block/CrafterBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/CrafterBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CrafterBlock.java +++ b/net/minecraft/world/level/block/CrafterBlock.java -@@ -40,6 +40,15 @@ +@@ -39,6 +39,15 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.Vec3D; @@ -16,9 +16,9 @@ public class CrafterBlock extends BlockTileEntity { public static final MapCodec CODEC = simpleCodec(CrafterBlock::new); -@@ -189,6 +198,13 @@ +@@ -187,6 +196,13 @@ RecipeHolder recipeholder = (RecipeHolder) optional.get(); - ItemStack itemstack = ((RecipeCrafting) recipeholder.value()).assemble(craftinginput, worldserver.registryAccess()); + ItemStack itemstack = (recipeholder.value()).assemble(craftinginput, worldserver.registryAccess()); + // CraftBukkit start + CrafterCraftEvent event = CraftEventFactory.callCrafterCraftEvent(blockposition, worldserver, crafterblockentity, itemstack, recipeholder.value().getRemainingItems(craftinginput), recipeholder); @@ -30,16 +30,16 @@ if (itemstack.isEmpty()) { worldserver.levelEvent(1050, blockposition, 0); } else { -@@ -196,7 +212,7 @@ - worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(CrafterBlock.CRAFTING, true), 2); +@@ -195,7 +211,7 @@ itemstack.onCraftedBySystem(worldserver); this.dispenseItem(worldserver, blockposition, crafterblockentity, itemstack, iblockdata, recipeholder); -- Iterator iterator = ((RecipeCrafting) recipeholder.value()).getRemainingItems(craftinginput).iterator(); -+ Iterator iterator = event.getRemainingItems().stream().map(CraftItemStack::asNMSCopy).iterator(); // CraftBukkit - while (iterator.hasNext()) { - ItemStack itemstack1 = (ItemStack) iterator.next(); -@@ -227,7 +243,25 @@ +- for (ItemStack itemstack1 : (recipeholder.value()).getRemainingItems(craftinginput)) { ++ for (ItemStack itemstack1 : event.getRemainingItems().stream().map(CraftItemStack::asNMSCopy).toList()) { // CraftBukkit + if (!itemstack1.isEmpty()) { + this.dispenseItem(worldserver, blockposition, crafterblockentity, itemstack1, iblockdata, recipeholder); + } +@@ -222,7 +238,25 @@ ItemStack itemstack1 = itemstack.copy(); if (iinventory != null && (iinventory instanceof CrafterBlockEntity || itemstack.getCount() > iinventory.getMaxStackSize(itemstack))) { @@ -65,7 +65,7 @@ ItemStack itemstack2 = itemstack1.copyWithCount(1); ItemStack itemstack3 = TileEntityHopper.addItem(crafterblockentity, iinventory, itemstack2, enumdirection.getOpposite()); -@@ -238,7 +272,25 @@ +@@ -233,7 +267,25 @@ itemstack1.shrink(1); } } else if (iinventory != null) { diff --git a/nms-patches/net/minecraft/world/level/block/DecoratedPotBlock.patch b/nms-patches/net/minecraft/world/level/block/DecoratedPotBlock.patch index a10aad16d..abad5f016 100644 --- a/nms-patches/net/minecraft/world/level/block/DecoratedPotBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/DecoratedPotBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DecoratedPotBlock.java +++ b/net/minecraft/world/level/block/DecoratedPotBlock.java -@@ -240,6 +240,11 @@ +@@ -213,6 +213,11 @@ if (world instanceof WorldServer worldserver) { if (iprojectile.mayInteract(worldserver, blockposition) && iprojectile.mayBreak(worldserver)) { @@ -9,6 +9,6 @@ + return; + } + // CraftBukkit end - world.setBlock(blockposition, (IBlockData) iblockdata.setValue(DecoratedPotBlock.CRACKED, true), 4); + world.setBlock(blockposition, (IBlockData) iblockdata.setValue(DecoratedPotBlock.CRACKED, true), 260); world.destroyBlock(blockposition, true, iprojectile); } diff --git a/nms-patches/net/minecraft/world/level/block/EyeblossomBlock.patch b/nms-patches/net/minecraft/world/level/block/EyeblossomBlock.patch index 8c4d639f1..be1d5ea17 100644 --- a/nms-patches/net/minecraft/world/level/block/EyeblossomBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/EyeblossomBlock.patch @@ -10,6 +10,6 @@ + return false; + } + // CraftBukkit end - worldserver.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata)); + worldserver.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata)); eyeblossomblock_a.spawnTransformParticle(worldserver, blockposition, randomsource); BlockPosition.betweenClosed(blockposition.offset(-3, -2, -3), blockposition.offset(3, 2, 3)).forEach((blockposition1) -> { diff --git a/nms-patches/net/minecraft/world/level/block/LayeredCauldronBlock.patch b/nms-patches/net/minecraft/world/level/block/LayeredCauldronBlock.patch index f2eebd060..606d151aa 100644 --- a/nms-patches/net/minecraft/world/level/block/LayeredCauldronBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/LayeredCauldronBlock.patch @@ -14,7 +14,7 @@ public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { @@ -64,39 +70,67 @@ - protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity, InsideBlockEffectApplier insideblockeffectapplier) { if (world instanceof WorldServer worldserver) { if (entity.isOnFire() && this.isEntityInsideContent(iblockdata, blockposition, entity)) { - entity.clearFire(); @@ -56,7 +56,7 @@ IBlockData iblockdata1 = i == 0 ? Blocks.CAULDRON.defaultBlockState() : (IBlockData) iblockdata.setValue(LayeredCauldronBlock.LEVEL, i); - world.setBlockAndUpdate(blockposition, iblockdata1); -- world.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1)); +- world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1)); + return changeLevel(iblockdata, world, blockposition, iblockdata1, entity, reason); } @@ -74,7 +74,7 @@ + return false; + } + newState.update(true); -+ world.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(newBlock)); ++ world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(newBlock)); + return true; + } + // CraftBukkit end @@ -85,7 +85,7 @@ IBlockData iblockdata1 = (IBlockData) iblockdata.cycle(LayeredCauldronBlock.LEVEL); - world.setBlockAndUpdate(blockposition, iblockdata1); -- world.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1)); +- world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1)); + changeLevel(iblockdata, world, blockposition, iblockdata1, null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit } } @@ -95,7 +95,7 @@ IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(LayeredCauldronBlock.LEVEL, (Integer) iblockdata.getValue(LayeredCauldronBlock.LEVEL) + 1); - world.setBlockAndUpdate(blockposition, iblockdata1); -- world.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1)); +- world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1)); + // CraftBukkit start + if (!changeLevel(iblockdata, world, blockposition, iblockdata1, null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) { + return; diff --git a/nms-patches/net/minecraft/world/level/block/MultifaceSpreader.patch b/nms-patches/net/minecraft/world/level/block/MultifaceSpreader.patch index 216e14a22..d4dd70e00 100644 --- a/nms-patches/net/minecraft/world/level/block/MultifaceSpreader.patch +++ b/nms-patches/net/minecraft/world/level/block/MultifaceSpreader.patch @@ -1,6 +1,15 @@ --- a/net/minecraft/world/level/block/MultifaceSpreader.java +++ b/net/minecraft/world/level/block/MultifaceSpreader.java -@@ -156,7 +156,7 @@ +@@ -95,7 +95,7 @@ + return this.config.placeBlock(generatoraccess, multifacespreader_c, iblockdata, flag) ? Optional.of(multifacespreader_c) : Optional.empty(); + } + +- public static record c(BlockPosition pos, EnumDirection face) { ++ public static record c(BlockPosition pos, EnumDirection face, BlockPosition source) { // CraftBukkit + + } + +@@ -130,7 +130,7 @@ generatoraccess.getChunk(multifacespreader_c.pos()).markPosForPostprocessing(multifacespreader_c.pos()); } @@ -9,7 +18,7 @@ } else { return false; } -@@ -174,19 +174,19 @@ +@@ -168,19 +168,19 @@ SAME_POSITION { @Override public MultifaceSpreader.c getSpreadPos(BlockPosition blockposition, EnumDirection enumdirection, EnumDirection enumdirection1) { @@ -32,12 +41,3 @@ } }; -@@ -195,7 +195,7 @@ - public abstract MultifaceSpreader.c getSpreadPos(BlockPosition blockposition, EnumDirection enumdirection, EnumDirection enumdirection1); - } - -- public static record c(BlockPosition pos, EnumDirection face) { -+ public static record c(BlockPosition pos, EnumDirection face, BlockPosition source) { // CraftBukkit - - } - } diff --git a/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch b/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch index 0ce0a1738..8fb3a4859 100644 --- a/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/PointedDripstoneBlock.java +++ b/net/minecraft/world/level/block/PointedDripstoneBlock.java -@@ -136,6 +136,11 @@ +@@ -135,6 +135,11 @@ WorldServer worldserver = (WorldServer) world; if (iprojectile.mayInteract(worldserver, blockposition) && iprojectile.mayBreak(worldserver) && iprojectile instanceof EntityThrownTrident && iprojectile.getDeltaMovement().length() > 0.6D) { @@ -12,16 +12,16 @@ world.destroyBlock(blockposition, true); } } -@@ -146,7 +151,7 @@ +@@ -145,7 +150,7 @@ @Override - public void fallOn(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, float f) { + public void fallOn(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, double d0) { if (iblockdata.getValue(PointedDripstoneBlock.TIP_DIRECTION) == EnumDirection.UP && iblockdata.getValue(PointedDripstoneBlock.THICKNESS) == DripstoneThickness.TIP) { -- entity.causeFallDamage(f + 2.0F, 2.0F, world.damageSources().stalagmite()); -+ entity.causeFallDamage(f + 2.0F, 2.0F, world.damageSources().stalagmite().directBlock(world, blockposition)); // CraftBukkit +- entity.causeFallDamage(d0 + 2.5D, 2.0F, world.damageSources().stalagmite()); ++ entity.causeFallDamage(d0 + 2.5D, 2.0F, world.damageSources().stalagmite().directBlock(world, blockposition)); // CraftBukkit } else { - super.fallOn(world, iblockdata, blockposition, entity, f); + super.fallOn(world, iblockdata, blockposition, entity, d0); } -@@ -391,15 +396,15 @@ +@@ -393,15 +398,15 @@ if (isUnmergedTipWithDirection(iblockdata, enumdirection.getOpposite())) { createMergedTips(iblockdata, worldserver, blockposition1); } else if (iblockdata.isAir() || iblockdata.is(Blocks.WATER)) { @@ -40,18 +40,18 @@ } private static void createMergedTips(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { -@@ -414,8 +419,8 @@ - blockposition1 = blockposition.below(); +@@ -416,8 +421,8 @@ + blockposition2 = blockposition.below(); } -- createDripstone(generatoraccess, blockposition2, EnumDirection.DOWN, DripstoneThickness.TIP_MERGE); -- createDripstone(generatoraccess, blockposition1, EnumDirection.UP, DripstoneThickness.TIP_MERGE); -+ createDripstone(generatoraccess, blockposition2, EnumDirection.DOWN, DripstoneThickness.TIP_MERGE, blockposition); // CraftBukkit -+ createDripstone(generatoraccess, blockposition1, EnumDirection.UP, DripstoneThickness.TIP_MERGE, blockposition); // CraftBukkit +- createDripstone(generatoraccess, blockposition1, EnumDirection.DOWN, DripstoneThickness.TIP_MERGE); +- createDripstone(generatoraccess, blockposition2, EnumDirection.UP, DripstoneThickness.TIP_MERGE); ++ createDripstone(generatoraccess, blockposition1, EnumDirection.DOWN, DripstoneThickness.TIP_MERGE, blockposition); // CraftBukkit ++ createDripstone(generatoraccess, blockposition2, EnumDirection.UP, DripstoneThickness.TIP_MERGE, blockposition); // CraftBukkit } public static void spawnDripParticle(World world, BlockPosition blockposition, IBlockData iblockdata) { -@@ -448,7 +453,7 @@ +@@ -450,7 +455,7 @@ return (BlockPosition) findBlockVertical(generatoraccess, blockposition, enumdirection.getAxisDirection(), bipredicate, (iblockdata1) -> { return isTip(iblockdata1, flag); @@ -60,7 +60,7 @@ } } -@@ -564,7 +569,7 @@ +@@ -566,7 +571,7 @@ return canDripThrough(world, blockposition1, iblockdata); }; @@ -69,7 +69,7 @@ } @Nullable -@@ -573,7 +578,7 @@ +@@ -575,7 +580,7 @@ return canDripThrough(world, blockposition1, iblockdata); }; diff --git a/nms-patches/net/minecraft/world/level/block/PowderSnowBlock.patch b/nms-patches/net/minecraft/world/level/block/PowderSnowBlock.patch index 54416b368..d331885dc 100644 --- a/nms-patches/net/minecraft/world/level/block/PowderSnowBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/PowderSnowBlock.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/level/block/PowderSnowBlock.java +++ b/net/minecraft/world/level/block/PowderSnowBlock.java -@@ -73,7 +73,12 @@ +@@ -77,7 +77,12 @@ - entity.setIsInPowderSnow(true); - if (world instanceof WorldServer worldserver) { -- if (entity.isOnFire() && (worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity instanceof EntityHuman) && entity.mayInteract(worldserver, blockposition)) { -+ // CraftBukkit start -+ if (entity.isOnFire() && entity.mayInteract(worldserver, blockposition)) { -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.defaultBlockState(), !(worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity instanceof EntityHuman))) { -+ return; -+ } -+ // CraftBukkit end - world.destroyBlock(blockposition, false); + insideblockeffectapplier.runBefore(InsideBlockEffectType.EXTINGUISH, (entity1) -> { + if (world instanceof WorldServer worldserver) { +- if (entity1.isOnFire() && (worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity1 instanceof EntityHuman) && entity1.mayInteract(worldserver, blockposition1)) { ++ // CraftBukkit start ++ if (entity1.isOnFire() && entity1.mayInteract(worldserver, blockposition1)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity1, blockposition1, Blocks.AIR.defaultBlockState(), !(worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity1 instanceof EntityHuman))) { ++ return; ++ } ++ // CraftBukkit end + world.destroyBlock(blockposition1, false); + } } - diff --git a/nms-patches/net/minecraft/world/level/block/SculkBlock.patch b/nms-patches/net/minecraft/world/level/block/SculkBlock.patch index e6fd17eed..89df595fc 100644 --- a/nms-patches/net/minecraft/world/level/block/SculkBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/SculkBlock.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/SculkBlock.java +++ b/net/minecraft/world/level/block/SculkBlock.java -@@ -43,8 +43,11 @@ +@@ -41,8 +41,11 @@ BlockPosition blockposition2 = blockposition1.above(); IBlockData iblockdata = this.getRandomGrowthState(generatoraccess, blockposition2, randomsource, sculkspreader.isWorldGeneration()); - generatoraccess.setBlock(blockposition2, iblockdata, 3); -- generatoraccess.playSound((EntityHuman) null, blockposition1, iblockdata.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, 1.0F, 1.0F); +- generatoraccess.playSound((Entity) null, blockposition1, iblockdata.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, 1.0F, 1.0F); + // CraftBukkit start - Call BlockSpreadEvent + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(generatoraccess, blockposition, blockposition2, iblockdata, 3)) { -+ generatoraccess.playSound((EntityHuman) null, blockposition1, iblockdata.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, 1.0F, 1.0F); ++ generatoraccess.playSound((Entity) null, blockposition1, iblockdata.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, 1.0F, 1.0F); + } + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch b/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch index 7621da01e..37e8e72b7 100644 --- a/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/world/level/block/SculkSensorBlock.java +++ b/net/minecraft/world/level/block/SculkSensorBlock.java -@@ -44,6 +44,11 @@ +@@ -43,6 +43,12 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; +// CraftBukkit start ++import net.minecraft.world.entity.player.EntityHuman; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.event.block.BlockRedstoneEvent; +// CraftBukkit end @@ -12,7 +13,7 @@ public class SculkSensorBlock extends BlockTileEntity implements IBlockWaterlogged { public static final MapCodec CODEC = simpleCodec(SculkSensorBlock::new); -@@ -104,6 +109,18 @@ +@@ -103,6 +109,18 @@ @Override public void stepOn(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { if (!world.isClientSide() && canActivate(iblockdata) && entity.getType() != EntityTypes.WARDEN) { @@ -31,7 +32,7 @@ TileEntity tileentity = world.getBlockEntity(blockposition); if (tileentity instanceof SculkSensorBlockEntity) { -@@ -202,6 +219,15 @@ +@@ -198,6 +216,15 @@ } public static void deactivate(World world, BlockPosition blockposition, IBlockData iblockdata) { @@ -47,7 +48,7 @@ world.setBlock(blockposition, (IBlockData) ((IBlockData) iblockdata.setValue(SculkSensorBlock.PHASE, SculkSensorPhase.COOLDOWN)).setValue(SculkSensorBlock.POWER, 0), 3); world.scheduleTick(blockposition, iblockdata.getBlock(), 10); updateNeighbours(world, blockposition, iblockdata); -@@ -213,6 +239,15 @@ +@@ -209,6 +236,15 @@ } public void activate(@Nullable Entity entity, World world, BlockPosition blockposition, IBlockData iblockdata, int i, int j) { @@ -63,7 +64,7 @@ world.setBlock(blockposition, (IBlockData) ((IBlockData) iblockdata.setValue(SculkSensorBlock.PHASE, SculkSensorPhase.ACTIVE)).setValue(SculkSensorBlock.POWER, i), 3); world.scheduleTick(blockposition, iblockdata.getBlock(), this.getActiveTicks()); updateNeighbours(world, blockposition, iblockdata); -@@ -293,9 +328,16 @@ +@@ -285,9 +321,16 @@ @Override protected void spawnAfterBreak(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) { super.spawnAfterBreak(iblockdata, worldserver, blockposition, itemstack, flag); diff --git a/nms-patches/net/minecraft/world/level/block/SculkShriekerBlock.patch b/nms-patches/net/minecraft/world/level/block/SculkShriekerBlock.patch index 57ab98856..196f8f65c 100644 --- a/nms-patches/net/minecraft/world/level/block/SculkShriekerBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/SculkShriekerBlock.patch @@ -8,7 +8,7 @@ worldserver.getBlockEntity(blockposition, TileEntityTypes.SCULK_SHRIEKER).ifPresent((sculkshriekerblockentity) -> { sculkshriekerblockentity.tryShriek(worldserver, entityplayer); }); -@@ -140,10 +141,17 @@ +@@ -127,10 +128,17 @@ @Override protected void spawnAfterBreak(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) { super.spawnAfterBreak(iblockdata, worldserver, blockposition, itemstack, flag); diff --git a/nms-patches/net/minecraft/world/level/block/SculkSpreader.patch b/nms-patches/net/minecraft/world/level/block/SculkSpreader.patch index 0a02154d4..9e4cca46c 100644 --- a/nms-patches/net/minecraft/world/level/block/SculkSpreader.patch +++ b/nms-patches/net/minecraft/world/level/block/SculkSpreader.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/SculkSpreader.java +++ b/net/minecraft/world/level/block/SculkSpreader.java -@@ -41,6 +41,14 @@ +@@ -35,6 +35,14 @@ + import net.minecraft.world.level.GeneratorAccess; import net.minecraft.world.level.block.state.IBlockData; - import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.nbt.NBTBase; @@ -15,33 +15,24 @@ public class SculkSpreader { public static final int MAX_GROWTH_RATE_RADIUS = 24; -@@ -57,6 +65,7 @@ +@@ -50,6 +58,7 @@ + private final int chargeDecayRate; private final int additionalDecayRate; private List cursors = new ArrayList(); - private static final Logger LOGGER = LogUtils.getLogger(); + public World level; // CraftBukkit public SculkSpreader(boolean flag, TagKey tagkey, int i, int j, int k, int l) { this.isWorldGeneration = flag; -@@ -111,7 +120,7 @@ - public void load(NBTTagCompound nbttagcompound) { - if (nbttagcompound.contains("cursors", 9)) { - this.cursors.clear(); -- DataResult dataresult = SculkSpreader.a.CODEC.listOf().parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getList("cursors", 10))); -+ DataResult> dataresult = SculkSpreader.a.CODEC.listOf().parse(new Dynamic<>(DynamicOpsNBT.INSTANCE, nbttagcompound.getList("cursors", 10))); // CraftBukkit - decompile error - Logger logger = SculkSpreader.LOGGER; +@@ -103,7 +112,7 @@ - Objects.requireNonNull(logger); -@@ -126,7 +135,7 @@ + public void load(NBTTagCompound nbttagcompound) { + this.cursors.clear(); +- ((List) nbttagcompound.read("cursors", SculkSpreader.a.CODEC.sizeLimitedListOf(32)).orElse(List.of())).forEach(this::addCursor); ++ (nbttagcompound.read("cursors", SculkSpreader.a.CODEC.sizeLimitedListOf(32)).orElse(List.of())).forEach(this::addCursor); // CraftBukkit - decompile error } public void save(NBTTagCompound nbttagcompound) { -- DataResult dataresult = SculkSpreader.a.CODEC.listOf().encodeStart(DynamicOpsNBT.INSTANCE, this.cursors); -+ DataResult dataresult = SculkSpreader.a.CODEC.listOf().encodeStart(DynamicOpsNBT.INSTANCE, this.cursors); // CraftBukkit - decompile error - Logger logger = SculkSpreader.LOGGER; - - Objects.requireNonNull(logger); -@@ -147,6 +156,19 @@ +@@ -122,6 +131,19 @@ private void addCursor(SculkSpreader.a sculkspreader_a) { if (this.cursors.size() < 32) { @@ -61,7 +52,7 @@ this.cursors.add(sculkspreader_a); } } -@@ -244,7 +266,7 @@ +@@ -214,7 +236,7 @@ this.charge = i; this.decayDelay = j; this.updateDelay = k; diff --git a/nms-patches/net/minecraft/world/level/block/SculkVeinBlock.patch b/nms-patches/net/minecraft/world/level/block/SculkVeinBlock.patch index 768898a5e..51561c76d 100644 --- a/nms-patches/net/minecraft/world/level/block/SculkVeinBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/SculkVeinBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkVeinBlock.java +++ b/net/minecraft/world/level/block/SculkVeinBlock.java -@@ -101,10 +101,11 @@ +@@ -92,10 +92,11 @@ @Override public int attemptUseCharge(SculkSpreader.a sculkspreader_a, GeneratorAccess generatoraccess, BlockPosition blockposition, RandomSource randomsource, SculkSpreader sculkspreader, boolean flag) { @@ -13,8 +13,8 @@ + private boolean attemptPlaceSculk(SculkSpreader sculkspreader, GeneratorAccess generatoraccess, BlockPosition blockposition, RandomSource randomsource, BlockPosition sourceBlock) { // CraftBukkit IBlockData iblockdata = generatoraccess.getBlockState(blockposition); TagKey tagkey = sculkspreader.replaceableBlocks(); - Iterator iterator = EnumDirection.allShuffled(randomsource).iterator(); -@@ -119,7 +120,11 @@ + +@@ -107,7 +108,11 @@ if (iblockdata1.is(tagkey)) { IBlockData iblockdata2 = Blocks.SCULK.defaultBlockState(); @@ -25,5 +25,5 @@ + } + // CraftBukkit end Block.pushEntitiesUp(iblockdata1, iblockdata2, generatoraccess, blockposition1); - generatoraccess.playSound((EntityHuman) null, blockposition1, SoundEffects.SCULK_BLOCK_SPREAD, SoundCategory.BLOCKS, 1.0F, 1.0F); + generatoraccess.playSound((Entity) null, blockposition1, SoundEffects.SCULK_BLOCK_SPREAD, SoundCategory.BLOCKS, 1.0F, 1.0F); this.veinSpreader.spreadAll(iblockdata2, generatoraccess, blockposition1, sculkspreader.isWorldGeneration()); diff --git a/nms-patches/net/minecraft/world/level/block/BlockPlant.patch b/nms-patches/net/minecraft/world/level/block/VegetationBlock.patch similarity index 85% rename from nms-patches/net/minecraft/world/level/block/BlockPlant.patch rename to nms-patches/net/minecraft/world/level/block/VegetationBlock.patch index 274403a39..2fb4e1b74 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockPlant.patch +++ b/nms-patches/net/minecraft/world/level/block/VegetationBlock.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/level/block/BlockPlant.java -+++ b/net/minecraft/world/level/block/BlockPlant.java +--- a/net/minecraft/world/level/block/VegetationBlock.java ++++ b/net/minecraft/world/level/block/VegetationBlock.java @@ -12,6 +12,10 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.pathfinder.PathMode; @@ -8,9 +8,9 @@ +import net.minecraft.world.level.World; +// CraftBukkit end + - public abstract class BlockPlant extends Block { + public abstract class VegetationBlock extends Block { - protected BlockPlant(BlockBase.Info blockbase_info) { + protected VegetationBlock(BlockBase.Info blockbase_info) { @@ -27,7 +31,15 @@ @Override diff --git a/nms-patches/net/minecraft/world/level/block/WallHangingSignBlock.patch b/nms-patches/net/minecraft/world/level/block/WallHangingSignBlock.patch index 4fad718c2..a4a18aedc 100644 --- a/nms-patches/net/minecraft/world/level/block/WallHangingSignBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/WallHangingSignBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/WallHangingSignBlock.java +++ b/net/minecraft/world/level/block/WallHangingSignBlock.java -@@ -179,6 +179,6 @@ +@@ -164,6 +164,6 @@ @Nullable @Override public BlockEntityTicker getTicker(World world, IBlockData iblockdata, TileEntityTypes tileentitytypes) { diff --git a/nms-patches/net/minecraft/world/level/block/entity/BrushableBlockEntity.patch b/nms-patches/net/minecraft/world/level/block/entity/BrushableBlockEntity.patch index e023ec99f..cf43c7c70 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/BrushableBlockEntity.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/BrushableBlockEntity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BrushableBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BrushableBlockEntity.java -@@ -31,6 +31,13 @@ +@@ -32,6 +32,13 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -14,13 +14,13 @@ public class BrushableBlockEntity extends TileEntity { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -80,7 +87,12 @@ +@@ -81,7 +88,12 @@ IBlockData iblockdata = this.getBlockState(); IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockProperties.DUSTED, k); - worldserver.setBlock(this.getBlockPos(), iblockdata1, 3); + // CraftBukkit start -+ BlockBrushEvent event = CraftEventFactory.callBlockBrushEvent(worldserver, this.getBlockPos(), iblockdata1, 3, entityhuman); ++ BlockBrushEvent event = CraftEventFactory.callBlockBrushEvent(worldserver, this.getBlockPos(), iblockdata1, 3, (EntityPlayer) entityliving); + if (!event.isCancelled()) { + event.getNewState().update(true); + } @@ -28,12 +28,12 @@ } return false; -@@ -121,10 +133,10 @@ +@@ -122,10 +134,10 @@ } - private void brushingCompleted(WorldServer worldserver, EntityHuman entityhuman, ItemStack itemstack) { -- this.dropContent(worldserver, entityhuman, itemstack); -+ // this.dropContent(worldserver, entityhuman, itemstack); // CraftBukkit - moved down + private void brushingCompleted(WorldServer worldserver, EntityLiving entityliving, ItemStack itemstack) { +- this.dropContent(worldserver, entityliving, itemstack); ++ // this.dropContent(worldserver, entityliving, itemstack); // CraftBukkit - moved down IBlockData iblockdata = this.getBlockState(); - worldserver.levelEvent(3008, this.getBlockPos(), Block.getId(iblockdata)); @@ -41,15 +41,15 @@ Block block = this.getBlockState().getBlock(); Block block1; -@@ -134,7 +146,15 @@ +@@ -135,7 +147,15 @@ block1 = Blocks.AIR; } - worldserver.setBlock(this.worldPosition, block1.defaultBlockState(), 3); + // CraftBukkit start -+ BlockBrushEvent event = CraftEventFactory.callBlockBrushEvent(worldserver, this.worldPosition, block1.defaultBlockState(), 3, entityhuman); ++ BlockBrushEvent event = CraftEventFactory.callBlockBrushEvent(worldserver, this.worldPosition, block1.defaultBlockState(), 3, (EntityPlayer) entityliving); + if (!event.isCancelled()) { -+ this.dropContent(worldserver, entityhuman, itemstack); // CraftBukkit - from above ++ this.dropContent(worldserver, entityliving, itemstack); // CraftBukkit - from above + worldserver.levelEvent(3008, this.getBlockPos(), Block.getId(iblockdata)); // CraftBukkit - from above + + event.getNewState().update(true); @@ -57,16 +57,36 @@ + // CraftBukkit end } - private void dropContent(WorldServer worldserver, EntityHuman entityhuman, ItemStack itemstack) { -@@ -151,7 +171,10 @@ + private void dropContent(WorldServer worldserver, EntityLiving entityliving, ItemStack itemstack) { +@@ -152,7 +172,12 @@ EntityItem entityitem = new EntityItem(worldserver, d3, d4, d5, this.item.split(worldserver.random.nextInt(21) + 10)); entityitem.setDeltaMovement(Vec3D.ZERO); - worldserver.addFreshEntity(entityitem); + // CraftBukkit start -+ org.bukkit.block.Block bblock = CraftBlock.at(this.level, this.worldPosition); -+ CraftEventFactory.handleBlockDropItemEvent(bblock, bblock.getState(), (EntityPlayer) entityhuman, Arrays.asList(entityitem)); ++ if (entityliving instanceof EntityPlayer entityplayer) { ++ org.bukkit.block.Block bblock = CraftBlock.at(this.level, this.worldPosition); ++ CraftEventFactory.handleBlockDropItemEvent(bblock, bblock.getState(), entityplayer, Arrays.asList(entityitem)); ++ } + // CraftBukkit end this.item = ItemStack.EMPTY; } +@@ -185,7 +210,7 @@ + } + + private boolean tryLoadLootTable(NBTTagCompound nbttagcompound) { +- this.lootTable = (ResourceKey) nbttagcompound.read("LootTable", LootTable.KEY_CODEC).orElse((Object) null); ++ this.lootTable = (ResourceKey) nbttagcompound.read("LootTable", LootTable.KEY_CODEC).orElse(null); // CraftBukkit - decompile error + this.lootTableSeed = nbttagcompound.getLongOr("LootTableSeed", 0L); + return this.lootTable != null; + } +@@ -233,7 +258,7 @@ + this.item = ItemStack.EMPTY; + } + +- this.hitDirection = (EnumDirection) nbttagcompound.read("hit_direction", EnumDirection.LEGACY_ID_CODEC).orElse((Object) null); ++ this.hitDirection = (EnumDirection) nbttagcompound.read("hit_direction", EnumDirection.LEGACY_ID_CODEC).orElse(null); // CraftBukkit - decompile error + } + + @Override diff --git a/nms-patches/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.patch b/nms-patches/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.patch index 449bad12a..c07b78b26 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java -@@ -23,12 +23,54 @@ +@@ -23,6 +23,13 @@ import net.minecraft.world.level.gameevent.GameEvent; import org.slf4j.Logger; @@ -14,7 +14,8 @@ public class ChiseledBookShelfBlockEntity extends TileEntity implements IInventory { public static final int MAX_BOOKS_IN_STORAGE = 6; - private static final Logger LOGGER = LogUtils.getLogger(); +@@ -30,6 +37,41 @@ + private static final int DEFAULT_LAST_INTERACTED_SLOT = -1; private final NonNullList items; public int lastInteractedSlot; + // CraftBukkit start - add fields and methods @@ -55,7 +56,7 @@ public ChiseledBookShelfBlockEntity(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.CHISELED_BOOKSHELF, blockposition, iblockdata); -@@ -100,7 +142,7 @@ +@@ -101,7 +143,7 @@ this.items.set(i, ItemStack.EMPTY); if (!itemstack.isEmpty()) { @@ -64,7 +65,7 @@ } return itemstack; -@@ -115,7 +157,7 @@ +@@ -116,7 +158,7 @@ public void setItem(int i, ItemStack itemstack) { if (itemstack.is(TagsItem.BOOKSHELF_BOOKS)) { this.items.set(i, itemstack); @@ -73,7 +74,7 @@ } else if (itemstack.isEmpty()) { this.removeItem(i, 1); } -@@ -131,7 +173,7 @@ +@@ -132,7 +174,7 @@ @Override public int getMaxStackSize() { diff --git a/nms-patches/net/minecraft/world/level/block/entity/ContainerOpenersCounter.patch b/nms-patches/net/minecraft/world/level/block/entity/ContainerOpenersCounter.patch index 87d8f1a72..fa022bb81 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/ContainerOpenersCounter.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/ContainerOpenersCounter.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ContainerOpenersCounter.java +++ b/net/minecraft/world/level/block/entity/ContainerOpenersCounter.java -@@ -17,6 +17,7 @@ +@@ -16,6 +16,7 @@ private static final int CHECK_TICK_DELAY = 5; private int openCount; private double maxInteractionRange; @@ -8,7 +8,7 @@ public ContainerOpenersCounter() {} -@@ -26,11 +27,36 @@ +@@ -25,11 +26,36 @@ protected abstract void openerCountChanged(World world, BlockPosition blockposition, IBlockData iblockdata, int i, int j); @@ -44,8 +44,8 @@ + if (i == 0) { this.onOpen(world, blockposition, iblockdata); - world.gameEvent((Entity) entityhuman, (Holder) GameEvent.CONTAINER_OPEN, blockposition); -@@ -42,8 +68,19 @@ + world.gameEvent(entityhuman, (Holder) GameEvent.CONTAINER_OPEN, blockposition); +@@ -41,8 +67,19 @@ } public void decrementOpeners(EntityHuman entityhuman, World world, BlockPosition blockposition, IBlockData iblockdata) { @@ -64,8 +64,8 @@ + if (this.openCount == 0) { this.onClose(world, blockposition, iblockdata); - world.gameEvent((Entity) entityhuman, (Holder) GameEvent.CONTAINER_CLOSE, blockposition); -@@ -72,6 +109,7 @@ + world.gameEvent(entityhuman, (Holder) GameEvent.CONTAINER_CLOSE, blockposition); +@@ -69,6 +106,7 @@ } int i = list.size(); diff --git a/nms-patches/net/minecraft/world/level/block/entity/CrafterBlockEntity.patch b/nms-patches/net/minecraft/world/level/block/entity/CrafterBlockEntity.patch index 90eb9c7d0..52f664247 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/CrafterBlockEntity.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/CrafterBlockEntity.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/world/level/block/entity/CrafterBlockEntity.java +++ b/net/minecraft/world/level/block/entity/CrafterBlockEntity.java -@@ -23,6 +23,12 @@ +@@ -22,6 +22,13 @@ import net.minecraft.world.level.block.CrafterBlock; import net.minecraft.world.level.block.state.IBlockData; +// CraftBukkit start ++import java.util.List; +import org.bukkit.Location; +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.entity.HumanEntity; @@ -13,7 +14,7 @@ public class CrafterBlockEntity extends TileEntityLootable implements InventoryCrafting { public static final int CONTAINER_WIDTH = 3; -@@ -35,12 +41,52 @@ +@@ -36,6 +43,46 @@ private NonNullList items; public int craftingTicksRemaining; protected final IContainerProperties containerData; @@ -60,10 +61,3 @@ public CrafterBlockEntity(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.CRAFTER, blockposition, iblockdata); - this.items = NonNullList.withSize(9, ItemStack.EMPTY); - this.craftingTicksRemaining = 0; -- this.containerData = new IContainerProperties(this) { -+ this.containerData = new IContainerProperties() { // CraftBukkit - decompile error - private final int[] slotStates = new int[9]; - private int triggered = 0; - diff --git a/nms-patches/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.patch b/nms-patches/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.patch index 6fdb53410..22b2e103d 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java +++ b/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java -@@ -20,8 +20,59 @@ +@@ -24,8 +24,59 @@ import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.ticks.ContainerSingleItem; diff --git a/nms-patches/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.patch b/nms-patches/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.patch index 5186a7c53..006893032 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java -@@ -35,10 +35,13 @@ +@@ -34,10 +34,13 @@ public SculkCatalystBlockEntity(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.SCULK_CATALYST, blockposition, iblockdata); this.catalystListener = new SculkCatalystBlockEntity.CatalystListener(iblockdata, new BlockPositionSource(blockposition)); @@ -14,7 +14,7 @@ } @Override -@@ -64,11 +67,13 @@ +@@ -63,11 +66,13 @@ final SculkSpreader sculkSpreader; private final IBlockData blockState; private final PositionSource positionSource; diff --git a/nms-patches/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.patch b/nms-patches/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.patch new file mode 100644 index 000000000..62f6e6444 --- /dev/null +++ b/nms-patches/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.patch @@ -0,0 +1,26 @@ +--- a/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java +@@ -105,12 +105,12 @@ + + public IChatBaseComponent getTestName() { + return (IChatBaseComponent) this.test().map((resourcekey) -> { +- return IChatBaseComponent.literal(resourcekey.location().toString()); ++ return (IChatBaseComponent) IChatBaseComponent.literal(resourcekey.location().toString()); // CraftBukkit - decompile error + }).orElse(TestInstanceBlockEntity.INVALID_TEST_NAME); + } + + private Optional> getTestHolder() { +- Optional optional = this.test(); ++ Optional> optional = this.test(); // CraftBukkit - decompile error + IRegistryCustom iregistrycustom = this.level.registryAccess(); + + Objects.requireNonNull(iregistrycustom); +@@ -368,7 +368,7 @@ + private void removeEntities() { + this.level.getEntities((Entity) null, this.getStructureBounds()).stream().filter((entity) -> { + return !(entity instanceof EntityHuman); +- }).forEach(Entity::discard); ++ }).forEach((entity) -> entity.discard(null)); // CraftBukkit - add Bukkit remove cause + } + + private void forceLoadChunks() { diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch index acd81b25b..aa6286916 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntity.java +++ b/net/minecraft/world/level/block/entity/TileEntity.java -@@ -26,8 +26,18 @@ +@@ -33,8 +33,18 @@ import net.minecraft.world.level.block.state.IBlockData; import org.slf4j.Logger; @@ -16,10 +16,19 @@ + private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry(); + public CraftPersistentDataContainer persistentDataContainer; + // CraftBukkit end + private static final Codec> TYPE_CODEC = BuiltInRegistries.BLOCK_ENTITY_TYPE.byNameCodec(); private static final Logger LOGGER = LogUtils.getLogger(); private final TileEntityTypes type; - @Nullable -@@ -74,7 +84,16 @@ +@@ -72,7 +82,7 @@ + int l = SectionPosition.blockToSectionCoord(i); + int i1 = SectionPosition.blockToSectionCoord(k); + +- if (l != chunkcoordintpair.x || i1 != chunkcoordintpair.z) { ++ if (chunkcoordintpair != null && (l != chunkcoordintpair.x || i1 != chunkcoordintpair.z)) { // CraftBukkit - allow null + TileEntity.LOGGER.warn("Block entity {} found in a wrong chunk, expected position from chunk {}", nbttagcompound, chunkcoordintpair); + i = chunkcoordintpair.getBlockX(SectionPosition.sectionRelative(i)); + k = chunkcoordintpair.getBlockZ(SectionPosition.sectionRelative(k)); +@@ -94,7 +104,16 @@ return this.level != null; } @@ -37,10 +46,10 @@ public final void loadWithComponents(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) { this.loadAdditional(nbttagcompound, holderlookup_a); -@@ -114,6 +133,11 @@ - }).ifPresent((nbtbase) -> { - nbttagcompound.merge((NBTTagCompound) nbtbase); - }); +@@ -126,6 +145,11 @@ + + this.saveAdditional(nbttagcompound, holderlookup_a); + nbttagcompound.store(TileEntity.a.COMPONENTS_CODEC, holderlookup_a.createSerializationContext(DynamicOpsNBT.INSTANCE), this.components); + // CraftBukkit start - store container + if (this.persistentDataContainer != null && !this.persistentDataContainer.isEmpty()) { + nbttagcompound.put("PublicBukkitValues", this.persistentDataContainer.toTagCompound()); @@ -49,7 +58,16 @@ return nbttagcompound; } -@@ -263,13 +287,19 @@ +@@ -160,7 +184,7 @@ + + @Nullable + public static TileEntity loadStatic(BlockPosition blockposition, IBlockData iblockdata, NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) { +- TileEntityTypes tileentitytypes = (TileEntityTypes) nbttagcompound.read("id", TileEntity.TYPE_CODEC).orElse((Object) null); ++ TileEntityTypes tileentitytypes = (TileEntityTypes) nbttagcompound.read("id", TileEntity.TYPE_CODEC).orElse(null); // CraftBukkit - decompile error + + if (tileentitytypes == null) { + TileEntity.LOGGER.error("Skipping block entity with invalid type: {}", nbttagcompound.get("id")); +@@ -285,6 +309,12 @@ } public final void applyComponents(DataComponentMap datacomponentmap, DataComponentPatch datacomponentpatch) { @@ -62,15 +80,7 @@ final Set> set = new HashSet(); set.add(DataComponents.BLOCK_ENTITY_DATA); - set.add(DataComponents.BLOCK_STATE); - final PatchedDataComponentMap patcheddatacomponentmap = PatchedDataComponentMap.fromPatch(datacomponentmap, datacomponentpatch); - -- this.applyImplicitComponents(new TileEntity.b(this) { -+ this.applyImplicitComponents(new TileEntity.b() { // CraftBukkit - decompile error - @Nullable - @Override - public T get(DataComponentType datacomponenttype) { -@@ -287,6 +317,11 @@ +@@ -309,6 +339,11 @@ DataComponentPatch datacomponentpatch1 = datacomponentpatch.forget(set::contains); this.components = datacomponentpatch1.split().added(); @@ -82,8 +92,12 @@ } protected void collectImplicitComponents(DataComponentMap.a datacomponentmap_a) {} -@@ -321,6 +356,15 @@ - } +@@ -337,9 +372,18 @@ + public static IChatBaseComponent parseCustomNameSafe(@Nullable NBTBase nbtbase, HolderLookup.a holderlookup_a) { + return nbtbase == null ? null : (IChatBaseComponent) ComponentSerialization.CODEC.parse(holderlookup_a.createSerializationContext(DynamicOpsNBT.INSTANCE), nbtbase).resultOrPartial((s) -> { + TileEntity.LOGGER.warn("Failed to parse custom name, discarding: {}", s); +- }).orElse((Object) null); ++ }).orElse(null); // CraftBukkit - decompile error } + // CraftBukkit start - add method @@ -97,4 +111,4 @@ + private static class a { - 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/nms-patches/net/minecraft/world/level/block/entity/TileEntityBanner.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBanner.patch index ab67e1893..38d8edac4 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBanner.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBanner.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/entity/TileEntityBanner.java +++ b/net/minecraft/world/level/block/entity/TileEntityBanner.java -@@ -19,6 +19,10 @@ +@@ -20,6 +20,10 @@ + import net.minecraft.world.level.block.BlockBannerAbstract; import net.minecraft.world.level.block.state.IBlockData; - import org.slf4j.Logger; +// CraftBukkit start +import java.util.List; @@ -10,26 +10,26 @@ + public class TileEntityBanner extends TileEntity implements INamableTileEntity { - private static final Logger LOGGER = LogUtils.getLogger(); -@@ -74,7 +78,7 @@ - BannerPatternLayers.CODEC.parse(holderlookup_a.createSerializationContext(DynamicOpsNBT.INSTANCE), nbttagcompound.get("patterns")).resultOrPartial((s) -> { - TileEntityBanner.LOGGER.error("Failed to parse banner patterns: '{}'", s); - }).ifPresent((bannerpatternlayers) -> { -- this.patterns = bannerpatternlayers; -+ this.setPatterns(bannerpatternlayers); // CraftBukkit - apply limits - }); - } + public static final int MAX_PATTERNS = 6; +@@ -68,7 +72,7 @@ + this.name = parseCustomNameSafe(nbttagcompound.get("CustomName"), holderlookup_a); + RegistryOps registryops = holderlookup_a.createSerializationContext(DynamicOpsNBT.INSTANCE); -@@ -108,7 +112,7 @@ - @Override - protected void applyImplicitComponents(TileEntity.b tileentity_b) { - super.applyImplicitComponents(tileentity_b); -- this.patterns = (BannerPatternLayers) tileentity_b.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY); -+ this.setPatterns((BannerPatternLayers) tileentity_b.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY)); // CraftBukkit - apply limits - this.name = (IChatBaseComponent) tileentity_b.get(DataComponents.CUSTOM_NAME); +- this.patterns = (BannerPatternLayers) nbttagcompound.read("patterns", BannerPatternLayers.CODEC, registryops).orElse(BannerPatternLayers.EMPTY); ++ this.setPatterns((BannerPatternLayers) nbttagcompound.read("patterns", BannerPatternLayers.CODEC, registryops).orElse(BannerPatternLayers.EMPTY)); // CraftBukkit - apply limits } -@@ -124,4 +128,13 @@ + @Override +@@ -99,7 +103,7 @@ + @Override + protected void applyImplicitComponents(DataComponentGetter datacomponentgetter) { + super.applyImplicitComponents(datacomponentgetter); +- this.patterns = (BannerPatternLayers) datacomponentgetter.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY); ++ this.setPatterns((BannerPatternLayers) datacomponentgetter.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY)); // CraftBukkit - apply limits + this.name = (IChatBaseComponent) datacomponentgetter.get(DataComponents.CUSTOM_NAME); + } + +@@ -115,4 +119,13 @@ nbttagcompound.remove("patterns"); nbttagcompound.remove("CustomName"); } diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBarrel.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBarrel.patch index 0d9290ca4..06d67e58f 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBarrel.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBarrel.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityBarrel.java +++ b/net/minecraft/world/level/block/entity/TileEntityBarrel.java -@@ -21,8 +21,49 @@ +@@ -22,8 +22,49 @@ import net.minecraft.world.level.block.BlockBarrel; import net.minecraft.world.level.block.state.IBlockData; diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch index fa7669c3f..c097a470a 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityBeacon.java +++ b/net/minecraft/world/level/block/entity/TileEntityBeacon.java -@@ -46,6 +46,11 @@ +@@ -50,6 +50,11 @@ import net.minecraft.world.level.levelgen.HeightMap; import net.minecraft.world.phys.AxisAlignedBB; @@ -9,10 +9,10 @@ +import org.bukkit.potion.PotionEffect; +// CraftBukkit end + - public class TileEntityBeacon extends TileEntity implements ITileInventory, INamableTileEntity { + public class TileEntityBeacon extends TileEntity implements ITileInventory, INamableTileEntity, BeaconBeamOwner { private static final int MAX_LEVELS = 4; -@@ -71,6 +76,15 @@ +@@ -75,6 +80,15 @@ public IChatBaseComponent name; public ChestLock lockKey; private final IContainerProperties dataAccess; @@ -28,7 +28,7 @@ @Nullable static Holder filterEffect(@Nullable Holder holder) { -@@ -251,38 +265,77 @@ +@@ -251,32 +265,72 @@ super.setRemoved(); } @@ -36,22 +36,22 @@ - if (!world.isClientSide && holder != null) { - double d0 = (double) (i * 10 + 10); + // CraftBukkit start - split into components -+ private static byte getAmplification(int i, @Nullable Holder holder, @Nullable Holder holder1) { ++ private static int getAmplification(int i, @Nullable Holder holder, @Nullable Holder holder1) { + { - byte b0 = 0; + int j = 0; if (i >= 4 && Objects.equals(holder, holder1)) { - b0 = 1; + j = 1; } -+ return b0; ++ return j; + } + } + + private static int getLevel(int i) { + { - int j = (9 + i * 2) * 20; -+ return j; + int k = (9 + i * 2) * 20; ++ return k; + } + } + @@ -60,22 +60,17 @@ + double d0 = (double) (i * 10 + 10); + AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition)).inflate(d0).expandTowards(0.0D, (double) world.getHeight(), 0.0D); - List list = world.getEntitiesOfClass(EntityHuman.class, axisalignedbb); -+ + List list = world.getEntitiesOfClass(EntityHuman.class, axisalignedbb); + + return list; + } + } + -+ private static void applyEffect(List list, @Nullable Holder holder, int j, int b0) { ++ private static void applyEffect(List list, @Nullable Holder holder, int k, int j) { + { - Iterator iterator = list.iterator(); - - EntityHuman entityhuman; - - while (iterator.hasNext()) { - entityhuman = (EntityHuman) iterator.next(); -- entityhuman.addEffect(new MobEffect(holder, j, b0, true, true)); -+ entityhuman.addEffect(new MobEffect(holder, j, b0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON); + for (EntityHuman entityhuman : list) { +- entityhuman.addEffect(new MobEffect(holder, k, j, true, true)); ++ entityhuman.addEffect(new MobEffect(holder, k, j, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON); } + } + } @@ -83,53 +78,50 @@ + private static boolean hasSecondaryEffect(int i, @Nullable Holder holder, @Nullable Holder holder1) { + { if (i >= 4 && !Objects.equals(holder, holder1) && holder1 != null) { -- iterator = list.iterator(); -- -- while (iterator.hasNext()) { -- entityhuman = (EntityHuman) iterator.next(); -- entityhuman.addEffect(new MobEffect(holder1, j, 0, true, true)); +- for (EntityHuman entityhuman1 : list) { +- entityhuman1.addEffect(new MobEffect(holder1, k, 0, true, true)); - } + return true; } + return false; -+ } -+ } -+ + } + } + + private static void applyEffects(World world, BlockPosition blockposition, int i, @Nullable Holder holder, @Nullable Holder holder1) { + if (!world.isClientSide && holder != null) { -+ double d0 = (double) (i * 10 + 10); -+ byte b0 = getAmplification(i, holder, holder1); ++ int j = getAmplification(i, holder, holder1); + -+ int j = getLevel(i); ++ int k = getLevel(i); + List list = getHumansInRange(world, blockposition, i); + -+ applyEffect(list, holder, j, b0); ++ applyEffect(list, holder, k, j); + + if (hasSecondaryEffect(i, holder, holder1)) { -+ applyEffect(list, holder1, j, 0); ++ applyEffect(list, holder1, k, 0); + } - } ++ } + - } ++ } + // CraftBukkit end - ++ public static void playSound(World world, BlockPosition blockposition, SoundEffect soundeffect) { - world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); -@@ -316,7 +369,7 @@ - if (nbttagcompound.contains(s, 8)) { - MinecraftKey minecraftkey = MinecraftKey.tryParse(nbttagcompound.getString(s)); + world.playSound((Entity) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); + } +@@ -311,7 +365,7 @@ + Set set = TileEntityBeacon.VALID_EFFECTS; -- return minecraftkey == null ? null : (Holder) BuiltInRegistries.MOB_EFFECT.get(minecraftkey).map(TileEntityBeacon::filterEffect).orElse((Object) null); -+ return minecraftkey == null ? null : (Holder) BuiltInRegistries.MOB_EFFECT.get(minecraftkey).orElse(null); // CraftBukkit - persist manually set non-default beacon effects (SPIGOT-3598) - } else { - return null; - } -@@ -327,6 +380,7 @@ + Objects.requireNonNull(set); +- return (Holder) optional.filter(set::contains).orElse((Object) null); ++ return (Holder) optional.orElse((Object) null); // CraftBukkit - persist manually set non-default beacon effects (SPIGOT-3598) + } + + @Override +@@ -319,6 +373,7 @@ super.loadAdditional(nbttagcompound, holderlookup_a); this.primaryPower = loadEffect(nbttagcompound, "primary_effect"); this.secondaryPower = loadEffect(nbttagcompound, "secondary_effect"); -+ this.levels = nbttagcompound.getInt("Levels"); // CraftBukkit - SPIGOT-5053, use where available - if (nbttagcompound.contains("CustomName", 8)) { - this.name = parseCustomNameSafe(nbttagcompound.getString("CustomName"), holderlookup_a); - } ++ this.levels = nbttagcompound.getIntOr("Levels", this.levels); // CraftBukkit - SPIGOT-5053, use where available + this.name = parseCustomNameSafe(nbttagcompound.get("CustomName"), holderlookup_a); + this.lockKey = ChestLock.fromTag(nbttagcompound, holderlookup_a); + } diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch index 28593a6d4..cff299630 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/entity/TileEntityBeehive.java +++ b/net/minecraft/world/level/block/entity/TileEntityBeehive.java -@@ -43,6 +43,10 @@ +@@ -39,6 +39,10 @@ + import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.gameevent.GameEvent; - import org.slf4j.Logger; +// CraftBukkit start +import org.bukkit.event.entity.EntityRemoveEvent; @@ -10,8 +10,8 @@ + public class TileEntityBeehive extends TileEntity { - private static final Logger LOGGER = LogUtils.getLogger(); -@@ -56,6 +60,7 @@ + private static final String TAG_FLOWER_POS = "flower_pos"; +@@ -51,6 +55,7 @@ private List stored = Lists.newArrayList(); @Nullable public BlockPosition savedFlowerPos; @@ -19,7 +19,7 @@ public TileEntityBeehive(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.BEEHIVE, blockposition, iblockdata); -@@ -95,7 +100,7 @@ +@@ -84,7 +89,7 @@ } public boolean isFull() { @@ -28,7 +28,7 @@ } public void emptyAllLivingFromHive(@Nullable EntityHuman entityhuman, IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { -@@ -112,7 +117,7 @@ +@@ -97,7 +102,7 @@ if (entityhuman.position().distanceToSqr(entity.position()) <= 16.0D) { if (!this.isSedated()) { @@ -37,7 +37,7 @@ } else { entitybee.setStayOutOfHiveCountdown(400); } -@@ -124,10 +129,16 @@ +@@ -109,10 +114,16 @@ } private List releaseAllOccupants(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { @@ -55,7 +55,7 @@ }); if (!list.isEmpty()) { super.setChanged(); -@@ -151,7 +162,17 @@ +@@ -136,7 +147,17 @@ } public void addOccupant(EntityBee entitybee) { @@ -74,8 +74,8 @@ entitybee.stopRiding(); entitybee.ejectPassengers(); entitybee.dropLeash(); -@@ -167,7 +188,7 @@ - this.level.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entitybee, this.getBlockState())); +@@ -152,7 +173,7 @@ + this.level.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entitybee, this.getBlockState())); } - entitybee.discard(); @@ -83,7 +83,7 @@ super.setChanged(); } } -@@ -177,7 +198,13 @@ +@@ -162,7 +183,13 @@ } private static boolean releaseOccupant(World world, BlockPosition blockposition, IBlockData iblockdata, TileEntityBeehive.c tileentitybeehive_c, @Nullable List list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, @Nullable BlockPosition blockposition1) { @@ -98,7 +98,7 @@ return false; } else { EnumDirection enumdirection = (EnumDirection) iblockdata.getValue(BlockBeehive.FACING); -@@ -190,6 +217,18 @@ +@@ -175,6 +202,18 @@ Entity entity = tileentitybeehive_c.createEntity(world, blockposition); if (entity != null) { @@ -110,14 +110,14 @@ + double d2 = (double) blockposition.getY() + 0.5D - (double) (entity.getBbHeight() / 2.0F); + double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getStepZ(); + -+ entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot()); ++ entity.snapTo(d1, d2, d3, entity.getYRot(), entity.getXRot()); + } + if (!world.addFreshEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BEEHIVE)) return false; // CraftBukkit - SpawnReason, moved from below + // CraftBukkit end if (entity instanceof EntityBee) { EntityBee entitybee = (EntityBee) entity; -@@ -220,6 +259,7 @@ +@@ -205,6 +244,7 @@ list.add(entitybee); } @@ -125,21 +125,21 @@ float f = entity.getBbWidth(); double d0 = flag ? 0.0D : 0.55D + (double) (f / 2.0F); double d1 = (double) blockposition.getX() + 0.5D + d0 * (double) enumdirection.getStepX(); -@@ -227,11 +267,12 @@ +@@ -212,11 +252,12 @@ double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getStepZ(); - entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot()); + entity.snapTo(d1, d2, d3, entity.getYRot(), entity.getXRot()); + */ // CraftBukkit end } - world.playSound((EntityHuman) null, blockposition, SoundEffects.BEEHIVE_EXIT, SoundCategory.BLOCKS, 1.0F, 1.0F); - world.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entity, world.getBlockState(blockposition))); + world.playSound((Entity) null, blockposition, SoundEffects.BEEHIVE_EXIT, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entity, world.getBlockState(blockposition))); - return world.addFreshEntity(entity); + return true; // return this.world.addFreshEntity(entity); // CraftBukkit - moved up } else { return false; } -@@ -256,6 +297,10 @@ +@@ -241,6 +282,10 @@ if (releaseOccupant(world, blockposition, iblockdata, tileentitybeehive_hivebee.toOccupant(), (List) null, tileentitybeehive_releasestatus, blockposition1)) { flag = true; iterator.remove(); @@ -150,46 +150,38 @@ } } } -@@ -282,7 +327,7 @@ +@@ -267,9 +312,12 @@ @Override protected void loadAdditional(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) { super.loadAdditional(nbttagcompound, holderlookup_a); - this.stored.clear(); +- ((List) nbttagcompound.read("bees", TileEntityBeehive.c.LIST_CODEC).orElse(List.of())).forEach(this::storeBee); +- this.savedFlowerPos = (BlockPosition) nbttagcompound.read("flower_pos", BlockPosition.CODEC).orElse((Object) null); + this.stored = Lists.newArrayList(); // CraftBukkit - SPIGOT-7790: create new copy (may be modified in physics event triggered by honey change) - if (nbttagcompound.contains("bees")) { - TileEntityBeehive.c.LIST_CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("bees")).resultOrPartial((s) -> { - TileEntityBeehive.LOGGER.error("Failed to parse bees: '{}'", s); -@@ -291,7 +336,12 @@ - }); - } - -- this.savedFlowerPos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "flower_pos").orElse((Object) null); -+ this.savedFlowerPos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "flower_pos").orElse(null); // CraftBukkit - decompile error ++ (nbttagcompound.read("bees", TileEntityBeehive.c.LIST_CODEC).orElse(List.of())).forEach(this::storeBee); // CraftBukkit - decompile error ++ this.savedFlowerPos = (BlockPosition) nbttagcompound.read("flower_pos", BlockPosition.CODEC).orElse(null); // CraftBukkit - decompile error + // CraftBukkit start -+ if (nbttagcompound.contains("Bukkit.MaxEntities")) { -+ this.maxBees = nbttagcompound.getInt("Bukkit.MaxEntities"); -+ } ++ this.maxBees = nbttagcompound.getIntOr("Bukkit.MaxEntities", this.maxBees); + // CraftBukkit end } @Override -@@ -301,13 +351,14 @@ - if (this.hasSavedFlowerPos()) { - nbttagcompound.put("flower_pos", GameProfileSerializer.writeBlockPos(this.savedFlowerPos)); - } +@@ -277,12 +325,13 @@ + super.saveAdditional(nbttagcompound, holderlookup_a); + nbttagcompound.store("bees", TileEntityBeehive.c.LIST_CODEC, this.getBees()); + nbttagcompound.storeNullable("flower_pos", BlockPosition.CODEC, this.savedFlowerPos); + nbttagcompound.putInt("Bukkit.MaxEntities", this.maxBees); // CraftBukkit - } @Override - protected void applyImplicitComponents(TileEntity.b tileentity_b) { - super.applyImplicitComponents(tileentity_b); + protected void applyImplicitComponents(DataComponentGetter datacomponentgetter) { + super.applyImplicitComponents(datacomponentgetter); - 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 = (List) tileentity_b.getOrDefault(DataComponents.BEES, List.of()); + List list = ((Bees) datacomponentgetter.getOrDefault(DataComponents.BEES, Bees.EMPTY)).bees(); list.forEach(this::storeBee); -@@ -348,7 +399,7 @@ +@@ -346,7 +395,7 @@ NBTTagCompound nbttagcompound = new NBTTagCompound(); entity.save(nbttagcompound); @@ -198,7 +190,7 @@ Objects.requireNonNull(nbttagcompound); list.forEach(nbttagcompound::remove); -@@ -367,7 +418,7 @@ +@@ -365,7 +414,7 @@ @Nullable public Entity createEntity(World world, BlockPosition blockposition) { NBTTagCompound nbttagcompound = this.entityData.copyTag(); diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBell.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBell.patch index c54d843b6..3a2120501 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBell.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBell.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityBell.java +++ b/net/minecraft/world/level/block/entity/TileEntityBell.java -@@ -120,7 +120,7 @@ - EntityLiving entityliving = (EntityLiving) iterator.next(); - - if (entityliving.isAlive() && !entityliving.isRemoved() && blockposition.closerToCenterThan(entityliving.position(), 32.0D)) { -- entityliving.getBrain().setMemory(MemoryModuleType.HEARD_BELL_TIME, (Object) this.level.getGameTime()); -+ entityliving.getBrain().setMemory(MemoryModuleType.HEARD_BELL_TIME, this.level.getGameTime()); // CraftBukkit - decompile error - } - } - } -@@ -144,9 +144,13 @@ +@@ -133,9 +133,13 @@ } private static void makeRaidersGlow(World world, BlockPosition blockposition, List list) { diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch index 002abf340..01f1f20b9 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch @@ -21,7 +21,7 @@ public class TileEntityBrewingStand extends TileEntityContainer implements IWorldInventory { private static final int INGREDIENT_SLOT = 3; -@@ -41,6 +55,36 @@ +@@ -43,6 +57,36 @@ private Item ingredient; public int fuel; protected final IContainerProperties dataAccess; @@ -58,8 +58,8 @@ public TileEntityBrewingStand(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.BREWING_STAND, blockposition, iblockdata); -@@ -107,8 +151,19 @@ - ItemStack itemstack = (ItemStack) tileentitybrewingstand.items.get(4); +@@ -109,8 +153,19 @@ + ItemStack itemstack = tileentitybrewingstand.items.get(4); if (tileentitybrewingstand.fuel <= 0 && itemstack.is(TagsItem.BREWING_FUEL)) { - tileentitybrewingstand.fuel = 20; @@ -80,9 +80,9 @@ setChanged(world, blockposition, iblockdata); } -@@ -116,12 +171,17 @@ +@@ -118,12 +173,17 @@ boolean flag1 = tileentitybrewingstand.brewTime > 0; - ItemStack itemstack1 = (ItemStack) tileentitybrewingstand.items.get(3); + ItemStack itemstack1 = tileentitybrewingstand.items.get(3); + // CraftBukkit start - Use wall time instead of ticks for brewing + int elapsedTicks = MinecraftServer.currentTick - tileentitybrewingstand.lastTick; @@ -101,7 +101,7 @@ } else if (!flag || !itemstack1.is(tileentitybrewingstand.ingredient)) { tileentitybrewingstand.brewTime = 0; } -@@ -129,7 +189,11 @@ +@@ -131,7 +191,11 @@ setChanged(world, blockposition, iblockdata); } else if (flag && tileentitybrewingstand.fuel > 0) { --tileentitybrewingstand.fuel; @@ -114,21 +114,21 @@ tileentitybrewingstand.ingredient = itemstack1.getItem(); setChanged(world, blockposition, iblockdata); } -@@ -185,12 +249,34 @@ +@@ -187,12 +251,34 @@ } } - private static void doBrew(World world, BlockPosition blockposition, NonNullList nonnulllist) { + private static void doBrew(World world, BlockPosition blockposition, NonNullList nonnulllist, TileEntityBrewingStand tileentitybrewingstand) { // CraftBukkit - ItemStack itemstack = (ItemStack) nonnulllist.get(3); + ItemStack itemstack = nonnulllist.get(3); PotionBrewer potionbrewer = world.potionBrewing(); + // CraftBukkit start + InventoryHolder owner = tileentitybrewingstand.getOwner(); + List brewResults = new ArrayList<>(3); for (int i = 0; i < 3; ++i) { -- nonnulllist.set(i, potionbrewer.mix(itemstack, (ItemStack) nonnulllist.get(i))); -+ brewResults.add(i, CraftItemStack.asCraftMirror(potionbrewer.mix(itemstack, (ItemStack) nonnulllist.get(i)))); +- nonnulllist.set(i, potionbrewer.mix(itemstack, nonnulllist.get(i))); ++ brewResults.add(i, CraftItemStack.asCraftMirror(potionbrewer.mix(itemstack, nonnulllist.get(i)))); + } + + if (owner != null) { diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch index ec68f7a9b..6386dc70e 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityCampfire.java +++ b/net/minecraft/world/level/block/entity/TileEntityCampfire.java -@@ -31,6 +31,14 @@ +@@ -32,6 +32,14 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.gameevent.GameEvent; @@ -15,7 +15,7 @@ public class TileEntityCampfire extends TileEntity implements Clearable { private static final int BURN_COOL_SPEED = 2; -@@ -63,6 +71,20 @@ +@@ -64,6 +72,20 @@ }).orElse(itemstack); if (itemstack1.isItemEnabled(worldserver.enabledFeatures())) { @@ -36,7 +36,7 @@ InventoryUtils.dropItemStack(worldserver, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1); tileentitycampfire.items.set(i, ItemStack.EMPTY); worldserver.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3); -@@ -177,7 +199,11 @@ +@@ -175,7 +197,11 @@ return false; } @@ -48,4 +48,4 @@ + // CraftBukkit end this.cookingProgress[i] = 0; this.items.set(i, itemstack.consumeAndReturn(1, entityliving)); - worldserver.gameEvent((Holder) GameEvent.BLOCK_CHANGE, this.getBlockPos(), GameEvent.a.of(entityliving, this.getBlockState())); + worldserver.gameEvent(GameEvent.BLOCK_CHANGE, this.getBlockPos(), GameEvent.a.of(entityliving, this.getBlockState())); diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityChest.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityChest.patch index fe85c696a..f0082f2c5 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityChest.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityChest.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityChest.java +++ b/net/minecraft/world/level/block/entity/TileEntityChest.java -@@ -24,6 +24,12 @@ +@@ -25,6 +25,12 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.block.state.properties.BlockPropertyChestType; @@ -13,7 +13,7 @@ public class TileEntityChest extends TileEntityLootable implements LidBlockEntity { private static final int EVENT_SET_OPEN_COUNT = 1; -@@ -31,6 +37,36 @@ +@@ -32,6 +38,36 @@ public final ContainerOpenersCounter openersCounter; private final ChestLidController chestLidController; @@ -49,4 +49,4 @@ + protected TileEntityChest(TileEntityTypes tileentitytypes, BlockPosition blockposition, IBlockData iblockdata) { super(tileentitytypes, blockposition, iblockdata); - this.items = NonNullList.withSize(27, ItemStack.EMPTY); + this.items = NonNullList.withSize(27, ItemStack.EMPTY); diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityCommand.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityCommand.patch index e664a2759..20618ccb8 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityCommand.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityCommand.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/entity/TileEntityCommand.java +++ b/net/minecraft/world/level/block/entity/TileEntityCommand.java -@@ -24,6 +24,13 @@ - private boolean auto; - private boolean conditionMet; +@@ -28,6 +28,13 @@ + private boolean auto = false; + private boolean conditionMet = false; private final CommandBlockListenerAbstract commandBlock = new CommandBlockListenerAbstract() { + // CraftBukkit start + @Override diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch index 033b3ba2d..cc74658e2 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch @@ -11,7 +11,16 @@ public class TileEntityConduit extends TileEntity { private static final int BLOCK_REFRESH_RATE = 2; -@@ -187,8 +191,20 @@ +@@ -55,7 +59,7 @@ + @Override + protected void loadAdditional(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) { + super.loadAdditional(nbttagcompound, holderlookup_a); +- this.destroyTargetUUID = (UUID) nbttagcompound.read("Target", UUIDUtil.CODEC).orElse((Object) null); ++ this.destroyTargetUUID = (UUID) nbttagcompound.read("Target", UUIDUtil.CODEC).orElse(null); // CraftBukkit - decompile error + } + + @Override +@@ -174,8 +178,20 @@ } private static void applyEffects(World world, BlockPosition blockposition, List list) { @@ -32,16 +41,16 @@ int k = blockposition.getX(); int l = blockposition.getY(); int i1 = blockposition.getZ(); -@@ -202,7 +218,7 @@ - EntityHuman entityhuman = (EntityHuman) iterator.next(); - +@@ -185,7 +201,7 @@ + if (!list1.isEmpty()) { + for (EntityHuman entityhuman : list1) { if (blockposition.closerThan(entityhuman.blockPosition(), (double) j) && entityhuman.isInWaterOrRain()) { - entityhuman.addEffect(new MobEffect(MobEffects.CONDUIT_POWER, 260, 0, true, true)); + entityhuman.addEffect(new MobEffect(MobEffects.CONDUIT_POWER, 260, 0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONDUIT); // CraftBukkit } } -@@ -210,6 +226,12 @@ +@@ -193,6 +209,12 @@ } private static void updateDestroyTarget(World world, BlockPosition blockposition, IBlockData iblockdata, List list, TileEntityConduit tileentityconduit) { @@ -54,17 +63,17 @@ EntityLiving entityliving = tileentityconduit.destroyTarget; int i = list.size(); -@@ -230,9 +252,12 @@ +@@ -213,9 +235,12 @@ tileentityconduit.destroyTarget = null; } - if (tileentityconduit.destroyTarget != null) { -- world.playSound((EntityHuman) null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F); +- world.playSound((Entity) null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F); - tileentityconduit.destroyTarget.hurt(world.damageSources().magic(), 4.0F); + // CraftBukkit start + if (damageTarget && tileentityconduit.destroyTarget != null) { + if (tileentityconduit.destroyTarget.hurtServer((WorldServer) world, world.damageSources().magic().directBlock(world, blockposition), 4.0F)) { -+ world.playSound(null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F); ++ world.playSound((Entity) null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F); + } + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityContainer.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityContainer.patch index cf27b3539..8b6cecc54 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityContainer.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityContainer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityContainer.java +++ b/net/minecraft/world/level/block/entity/TileEntityContainer.java -@@ -178,4 +178,12 @@ +@@ -172,4 +172,12 @@ nbttagcompound.remove("lock"); nbttagcompound.remove("Items"); } diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityDispenser.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityDispenser.patch index 1fae288d6..1ecd16533 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityDispenser.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityDispenser.patch @@ -47,4 +47,4 @@ + protected TileEntityDispenser(TileEntityTypes tileentitytypes, BlockPosition blockposition, IBlockData iblockdata) { super(tileentitytypes, blockposition, iblockdata); - this.items = NonNullList.withSize(9, ItemStack.EMPTY); + this.items = NonNullList.withSize(9, ItemStack.EMPTY); diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch index e6456e8fc..cecb1636c 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityEndGateway.java +++ b/net/minecraft/world/level/block/entity/TileEntityEndGateway.java -@@ -27,6 +27,10 @@ +@@ -25,6 +25,10 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -11,12 +11,21 @@ public class TileEntityEndGateway extends TileEntityEnderPortal { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -143,7 +147,7 @@ - public Vec3D getPortalPosition(WorldServer worldserver, BlockPosition blockposition) { - BlockPosition blockposition1; +@@ -60,7 +64,7 @@ + protected void loadAdditional(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) { + super.loadAdditional(nbttagcompound, holderlookup_a); + this.age = nbttagcompound.getLongOr("Age", 0L); +- this.exitPortal = (BlockPosition) nbttagcompound.read("exit_portal", BlockPosition.CODEC).filter(World::isInSpawnableBounds).orElse((Object) null); ++ this.exitPortal = (BlockPosition) nbttagcompound.read("exit_portal", BlockPosition.CODEC).filter(World::isInSpawnableBounds).orElse(null); // CraftBukkit - decompile error + this.exactTeleport = nbttagcompound.getBooleanOr("ExactTeleport", false); + } +@@ -136,7 +140,7 @@ + + @Nullable + public Vec3D getPortalPosition(WorldServer worldserver, BlockPosition blockposition) { - if (this.exitPortal == null && worldserver.dimension() == World.END) { + if (this.exitPortal == null && worldserver.getTypeKey() == WorldDimension.END) { // CraftBukkit - work in alternate worlds - blockposition1 = findOrCreateValidTeleportPos(worldserver, blockposition); + BlockPosition blockposition1 = findOrCreateValidTeleportPos(worldserver, blockposition); + blockposition1 = blockposition1.above(10); - TileEntityEndGateway.LOGGER.debug("Creating portal at {}", blockposition1); diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch index f70c7ce40..6ecd4c6bf 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch @@ -22,12 +22,12 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeCraftingHolder, AutoRecipeOutput { protected static final int SLOT_INPUT = 0; -@@ -110,9 +125,39 @@ +@@ -115,9 +130,39 @@ } }; this.recipesUsed = new Reference2IntOpenHashMap(); -- this.quickCheck = CraftingManager.createCheck(recipes); -+ this.quickCheck = CraftingManager.createCheck((Recipes) recipes); // CraftBukkit - decompile error // Eclipse fail +- this.quickCheck = CraftingManager.createCheck(recipes); ++ this.quickCheck = CraftingManager.createCheck((Recipes) recipes); // CraftBukkit - decompile error + } + + // CraftBukkit start - add fields and methods @@ -63,8 +63,8 @@ private boolean isLit() { return this.litTimeRemaining > 0; } -@@ -175,7 +220,7 @@ - RecipeHolder recipeholder; +@@ -168,7 +213,7 @@ + RecipeHolder recipeholder; if (flag2) { - recipeholder = (RecipeHolder) tileentityfurnace.quickCheck.getRecipeFor(singlerecipeinput, worldserver).orElse((Object) null); @@ -72,7 +72,7 @@ } else { recipeholder = null; } -@@ -183,9 +228,20 @@ +@@ -176,9 +221,20 @@ int i = tileentityfurnace.getMaxStackSize(); if (!tileentityfurnace.isLit() && canBurn(worldserver.registryAccess(), recipeholder, singlerecipeinput, tileentityfurnace.items, i)) { @@ -95,7 +95,7 @@ flag1 = true; if (flag3) { Item item = itemstack.getItem(); -@@ -199,11 +255,23 @@ +@@ -192,11 +248,23 @@ } if (tileentityfurnace.isLit() && canBurn(worldserver.registryAccess(), recipeholder, singlerecipeinput, tileentityfurnace.items, i)) { @@ -120,16 +120,16 @@ tileentityfurnace.setRecipeUsed(recipeholder); } -@@ -242,17 +310,44 @@ +@@ -235,17 +303,44 @@ } } - private static boolean burn(IRegistryCustom iregistrycustom, @Nullable RecipeHolder recipeholder, SingleRecipeInput singlerecipeinput, NonNullList nonnulllist, int i) { + private static boolean burn(World world, BlockPosition blockposition, IRegistryCustom iregistrycustom, @Nullable RecipeHolder recipeholder, SingleRecipeInput singlerecipeinput, NonNullList nonnulllist, int i) { // CraftBukkit if (recipeholder != null && canBurn(iregistrycustom, recipeholder, singlerecipeinput, nonnulllist, i)) { - ItemStack itemstack = (ItemStack) nonnulllist.get(0); + ItemStack itemstack = nonnulllist.get(0); ItemStack itemstack1 = ((RecipeCooking) recipeholder.value()).assemble(singlerecipeinput, iregistrycustom); - ItemStack itemstack2 = (ItemStack) nonnulllist.get(2); + ItemStack itemstack2 = nonnulllist.get(2); + // CraftBukkit start - fire FurnaceSmeltEvent + CraftItemStack source = CraftItemStack.asCraftMirror(itemstack); @@ -166,7 +166,7 @@ if (itemstack.is(Blocks.WET_SPONGE.asItem()) && !((ItemStack) nonnulllist.get(1)).isEmpty() && ((ItemStack) nonnulllist.get(1)).is(Items.BUCKET)) { nonnulllist.set(1, new ItemStack(Items.WATER_BUCKET)); -@@ -270,6 +365,7 @@ +@@ -263,6 +358,7 @@ } private static int getTotalCookTime(WorldServer worldserver, TileEntityFurnace tileentityfurnace) { @@ -174,7 +174,7 @@ SingleRecipeInput singlerecipeinput = new SingleRecipeInput(tileentityfurnace.getItem(0)); return (Integer) tileentityfurnace.quickCheck.getRecipeFor(singlerecipeinput, worldserver).map((recipeholder) -> { -@@ -360,8 +456,8 @@ +@@ -353,8 +449,8 @@ @Override public void awardUsedRecipes(EntityHuman entityhuman, List list) {} @@ -184,8 +184,8 @@ + List> list = this.getRecipesToAwardAndPopExperience(entityplayer.serverLevel(), entityplayer.position(), this.worldPosition, entityplayer, itemstack, amount); // CraftBukkit entityplayer.awardRecipes(list); - Iterator iterator = list.iterator(); -@@ -378,22 +474,28 @@ + +@@ -368,22 +464,28 @@ } public List> getRecipesToAwardAndPopExperience(WorldServer worldserver, Vec3D vec3d) { @@ -199,13 +199,13 @@ ObjectIterator objectiterator = this.recipesUsed.reference2IntEntrySet().iterator(); while (objectiterator.hasNext()) { - Entry>> entry = (Entry) objectiterator.next(); + Reference2IntMap.Entry>> reference2intmap_entry = (Entry) objectiterator.next(); -- worldserver.recipeAccess().byKey((ResourceKey) entry.getKey()).ifPresent((recipeholder) -> { -+ worldserver.recipeAccess().byKey(entry.getKey()).ifPresent((recipeholder) -> { // CraftBukkit - decompile error +- worldserver.recipeAccess().byKey((ResourceKey) reference2intmap_entry.getKey()).ifPresent((recipeholder) -> { ++ worldserver.recipeAccess().byKey(reference2intmap_entry.getKey()).ifPresent((recipeholder) -> {// CraftBukkit - decompile error list.add(recipeholder); -- createExperience(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) recipeholder.value()).experience()); -+ createExperience(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) recipeholder.value()).experience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit +- createExperience(worldserver, vec3d, reference2intmap_entry.getIntValue(), ((RecipeCooking) recipeholder.value()).experience()); ++ createExperience(worldserver, vec3d, reference2intmap_entry.getIntValue(), ((RecipeCooking) recipeholder.value()).experience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit }); } @@ -217,7 +217,7 @@ int j = MathHelper.floor((float) i * f); float f1 = MathHelper.frac((float) i * f); -@@ -401,6 +503,17 @@ +@@ -391,6 +493,17 @@ ++j; } diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityHopper.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityHopper.patch index c54c3dbe2..7ce9d5bbb 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityHopper.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityHopper.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityHopper.java +++ b/net/minecraft/world/level/block/entity/TileEntityHopper.java -@@ -30,6 +30,22 @@ +@@ -29,6 +29,22 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.AxisAlignedBB; @@ -59,8 +59,8 @@ + public TileEntityHopper(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.HOPPER, blockposition, iblockdata); - this.items = NonNullList.withSize(5, ItemStack.EMPTY); -@@ -167,7 +213,29 @@ + this.items = NonNullList.withSize(5, ItemStack.EMPTY); +@@ -161,7 +207,29 @@ if (!itemstack.isEmpty()) { int j = itemstack.getCount(); @@ -91,7 +91,7 @@ if (itemstack1.isEmpty()) { iinventory.setChanged(); -@@ -279,7 +347,34 @@ +@@ -262,7 +330,34 @@ if (!itemstack.isEmpty() && canTakeItemFromContainer(ihopper, iinventory, itemstack, i, enumdirection)) { int j = itemstack.getCount(); @@ -127,7 +127,7 @@ if (itemstack1.isEmpty()) { iinventory.setChanged(); -@@ -297,13 +392,20 @@ +@@ -280,13 +375,20 @@ public static boolean addItem(IInventory iinventory, EntityItem entityitem) { boolean flag = false; @@ -149,7 +149,7 @@ } else { entityitem.setItem(itemstack1); } -@@ -421,14 +523,38 @@ +@@ -402,14 +504,38 @@ return itemstack; } diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityJukeBox.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityJukeBox.patch index d86298736..7cd631790 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityJukeBox.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityJukeBox.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityJukeBox.java +++ b/net/minecraft/world/level/block/entity/TileEntityJukeBox.java -@@ -19,12 +19,56 @@ +@@ -22,12 +22,56 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.ticks.ContainerSingleItem; @@ -57,7 +57,7 @@ public TileEntityJukeBox(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.JUKEBOX, blockposition, iblockdata); -@@ -137,7 +181,7 @@ +@@ -139,7 +183,7 @@ @Override public int getMaxStackSize() { @@ -66,7 +66,7 @@ } @Override -@@ -156,12 +200,17 @@ +@@ -163,12 +207,17 @@ } @VisibleForTesting diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch index cd0506113..ab7e97353 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityLectern.java +++ b/net/minecraft/world/level/block/entity/TileEntityLectern.java -@@ -29,13 +29,72 @@ +@@ -33,13 +33,72 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; @@ -74,7 +74,7 @@ @Override public int getContainerSize() { return 1; -@@ -80,11 +139,20 @@ +@@ -84,11 +143,20 @@ } @Override @@ -97,7 +97,7 @@ } @Override -@@ -164,7 +232,7 @@ +@@ -168,7 +236,7 @@ if (j != this.page) { this.page = j; this.setChanged(); @@ -106,7 +106,7 @@ } } -@@ -189,6 +257,35 @@ +@@ -193,6 +261,35 @@ return itemstack; } @@ -141,18 +141,26 @@ + private CommandListenerWrapper createCommandSourceStack(@Nullable EntityHuman entityhuman, WorldServer worldserver) { String s; - Object object; -@@ -203,7 +300,8 @@ + IChatBaseComponent ichatbasecomponent; +@@ -207,7 +304,8 @@ Vec3D vec3d = Vec3D.atCenterOf(this.worldPosition); -- return new CommandListenerWrapper(ICommandListener.NULL, vec3d, Vec2F.ZERO, worldserver, 2, s, (IChatBaseComponent) object, worldserver.getServer(), entityhuman); +- return new CommandListenerWrapper(ICommandListener.NULL, vec3d, Vec2F.ZERO, worldserver, 2, s, ichatbasecomponent, worldserver.getServer(), entityhuman); + // CraftBukkit - commandSource -+ return new CommandListenerWrapper(commandSource, vec3d, Vec2F.ZERO, worldserver, 2, s, (IChatBaseComponent) object, worldserver.getServer(), entityhuman); ++ return new CommandListenerWrapper(commandSource, vec3d, Vec2F.ZERO, worldserver, 2, s, ichatbasecomponent, worldserver.getServer(), entityhuman); } @Override -@@ -236,7 +334,7 @@ +@@ -244,6 +342,7 @@ + if ((Boolean) iblockdata.getValue(BlockLectern.HAS_BOOK) && this.level != null) { + EnumDirection enumdirection = (EnumDirection) iblockdata.getValue(BlockLectern.FACING); + ItemStack itemstack = this.getBook().copy(); ++ if (itemstack.isEmpty()) return; // CraftBukkit - SPIGOT-5500 + float f = 0.25F * (float) enumdirection.getStepX(); + float f1 = 0.25F * (float) enumdirection.getStepZ(); + EntityItem entityitem = new EntityItem(this.level, (double) blockposition.getX() + 0.5D + (double) f, (double) (blockposition.getY() + 1), (double) blockposition.getZ() + 0.5D + (double) f1, itemstack); +@@ -256,7 +355,7 @@ @Override public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch index 7b3f170d3..34153d283 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityShulkerBox.java +++ b/net/minecraft/world/level/block/entity/TileEntityShulkerBox.java -@@ -34,6 +34,11 @@ +@@ -33,6 +33,11 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -12,7 +12,7 @@ public class TileEntityShulkerBox extends TileEntityLootable implements IWorldInventory { public static final int COLUMNS = 9; -@@ -52,6 +57,37 @@ +@@ -51,6 +56,37 @@ @Nullable private final EnumColor color; @@ -49,20 +49,20 @@ + public TileEntityShulkerBox(@Nullable EnumColor enumcolor, BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.SHULKER_BOX, blockposition, iblockdata); - this.itemStacks = NonNullList.withSize(27, ItemStack.EMPTY); -@@ -184,6 +220,7 @@ + this.itemStacks = NonNullList.withSize(27, ItemStack.EMPTY); +@@ -182,6 +218,7 @@ } ++this.openCount; + if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call. this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount); if (this.openCount == 1) { - this.level.gameEvent((Entity) entityhuman, (Holder) GameEvent.CONTAINER_OPEN, this.worldPosition); -@@ -197,6 +234,7 @@ + this.level.gameEvent(entityhuman, (Holder) GameEvent.CONTAINER_OPEN, this.worldPosition); +@@ -195,6 +232,7 @@ public void stopOpen(EntityHuman entityhuman) { if (!this.remove && !entityhuman.isSpectator()) { --this.openCount; + if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call. this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount); if (this.openCount <= 0) { - this.level.gameEvent((Entity) entityhuman, (Holder) GameEvent.CONTAINER_CLOSE, this.worldPosition); + this.level.gameEvent(entityhuman, (Holder) GameEvent.CONTAINER_CLOSE, this.worldPosition); diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch index 8c27e83ce..d8f73e4bf 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/world/level/block/entity/TileEntitySign.java +++ b/net/minecraft/world/level/block/entity/TileEntitySign.java -@@ -36,6 +36,16 @@ +@@ -34,6 +34,17 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; +// CraftBukkit start ++import java.util.Objects; +import net.minecraft.nbt.NBTBase; +import net.minecraft.server.level.EntityPlayer; +import org.bukkit.block.sign.Side; @@ -17,25 +18,7 @@ public class TileEntitySign extends TileEntity { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -101,7 +111,7 @@ - protected void saveAdditional(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) { - super.saveAdditional(nbttagcompound, holderlookup_a); - DynamicOps dynamicops = holderlookup_a.createSerializationContext(DynamicOpsNBT.INSTANCE); -- DataResult dataresult = SignText.DIRECT_CODEC.encodeStart(dynamicops, this.frontText); -+ DataResult dataresult = SignText.DIRECT_CODEC.encodeStart(dynamicops, this.frontText); // CraftBukkit - decompile error - Logger logger = TileEntitySign.LOGGER; - - Objects.requireNonNull(logger); -@@ -121,7 +131,7 @@ - protected void loadAdditional(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) { - super.loadAdditional(nbttagcompound, holderlookup_a); - DynamicOps dynamicops = holderlookup_a.createSerializationContext(DynamicOpsNBT.INSTANCE); -- DataResult dataresult; -+ DataResult dataresult; // CraftBukkit - decompile error - Logger logger; - - if (nbttagcompound.contains("front_text")) { -@@ -173,12 +183,13 @@ +@@ -145,12 +156,13 @@ public void updateSignText(EntityHuman entityhuman, boolean flag, List list) { if (!this.isWaxed() && entityhuman.getUUID().equals(this.getPlayerWhoMayEdit()) && this.level != null) { this.updateText((signtext) -> { @@ -50,7 +33,7 @@ } } -@@ -188,7 +199,8 @@ +@@ -160,7 +172,8 @@ return this.setText((SignText) unaryoperator.apply(signtext), flag); } @@ -60,7 +43,7 @@ for (int i = 0; i < list.size(); ++i) { FilteredText filteredtext = (FilteredText) list.get(i); ChatModifier chatmodifier = signtext.getMessage(i, entityhuman.isTextFilteringEnabled()).getStyle(); -@@ -200,6 +212,29 @@ +@@ -172,6 +185,29 @@ } } @@ -90,7 +73,15 @@ return signtext; } -@@ -250,11 +285,40 @@ +@@ -213,6 +249,7 @@ + if (chatclickable instanceof ChatClickable.RunCommand chatclickable_runcommand) { + ChatClickable.RunCommand chatclickable_runcommand1 = chatclickable_runcommand; + ++ String s; // CraftBukkit - decompile error + try { + s = chatclickable_runcommand1.command(); + } catch (Throwable throwable) { +@@ -229,11 +266,40 @@ return flag1; } @@ -125,15 +116,15 @@ + private CommandListenerWrapper createCommandSourceStack(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition) { + // CraftBukkit end String s = entityhuman == null ? "Sign" : entityhuman.getName().getString(); - Object object = entityhuman == null ? IChatBaseComponent.literal("Sign") : entityhuman.getDisplayName(); + IChatBaseComponent ichatbasecomponent = (IChatBaseComponent) (entityhuman == null ? IChatBaseComponent.literal("Sign") : entityhuman.getDisplayName()); -- return new CommandListenerWrapper(ICommandListener.NULL, Vec3D.atCenterOf(blockposition), Vec2F.ZERO, (WorldServer) world, 2, s, (IChatBaseComponent) object, world.getServer(), entityhuman); +- return new CommandListenerWrapper(ICommandListener.NULL, Vec3D.atCenterOf(blockposition), Vec2F.ZERO, (WorldServer) world, 2, s, ichatbasecomponent, world.getServer(), entityhuman); + // CraftBukkit - commandSource -+ return new CommandListenerWrapper(commandSource, Vec3D.atCenterOf(blockposition), Vec2F.ZERO, (WorldServer) world, 2, s, (IChatBaseComponent) object, world.getServer(), entityhuman); ++ return new CommandListenerWrapper(commandSource, Vec3D.atCenterOf(blockposition), Vec2F.ZERO, (WorldServer) world, 2, s, ichatbasecomponent, world.getServer(), entityhuman); } @Override -@@ -273,12 +337,17 @@ +@@ -252,12 +318,17 @@ @Nullable public UUID getPlayerWhoMayEdit() { diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityTypes.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityTypes.patch index 89d94c46d..fd6276ea8 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityTypes.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityTypes.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/level/block/entity/TileEntityTypes.java +++ b/net/minecraft/world/level/block/entity/TileEntityTypes.java -@@ -66,7 +66,7 @@ - public static final TileEntityTypes CRAFTER = register("crafter", CrafterBlockEntity::new, Blocks.CRAFTER); - public static final TileEntityTypes TRIAL_SPAWNER = register("trial_spawner", TrialSpawnerBlockEntity::new, Blocks.TRIAL_SPAWNER); +@@ -68,7 +68,7 @@ public static final TileEntityTypes VAULT = register("vault", VaultBlockEntity::new, Blocks.VAULT); + public static final TileEntityTypes TEST_BLOCK = register("test_block", TestBlockEntity::new, Blocks.TEST_BLOCK); + public static final TileEntityTypes TEST_INSTANCE_BLOCK = register("test_instance_block", TestInstanceBlockEntity::new, Blocks.TEST_INSTANCE_BLOCK); - private static final Set> OP_ONLY_CUSTOM_DATA = Set.of(TileEntityTypes.COMMAND_BLOCK, TileEntityTypes.LECTERN, TileEntityTypes.SIGN, TileEntityTypes.HANGING_SIGN, TileEntityTypes.MOB_SPAWNER, TileEntityTypes.TRIAL_SPAWNER); + private static final Set> OP_ONLY_CUSTOM_DATA = Set.of(TileEntityTypes.COMMAND_BLOCK, TileEntityTypes.LECTERN, TileEntityTypes.SIGN, TileEntityTypes.HANGING_SIGN, TileEntityTypes.MOB_SPAWNER, TileEntityTypes.TRIAL_SPAWNER, TileEntityTypes.CHEST); // CraftBukkit private final TileEntityTypes.a factory; private final Set validBlocks; private final Holder.c> builtInRegistryHolder; -@@ -110,7 +110,7 @@ - public T getBlockEntity(IBlockAccess iblockaccess, BlockPosition blockposition) { - TileEntity tileentity = iblockaccess.getBlockEntity(blockposition); +@@ -84,7 +84,7 @@ + } -- return tileentity != null && tileentity.getType() == this ? tileentity : null; -+ return tileentity != null && tileentity.getType() == this ? (T) tileentity : null; // CraftBukkit - decompile error + SystemUtils.fetchChoiceType(DataConverterTypes.BLOCK_ENTITY, s); +- return (TileEntityTypes) IRegistry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, s, new TileEntityTypes(tileentitytypes_a, Set.of(ablock))); ++ return (TileEntityTypes) IRegistry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, s, new TileEntityTypes<>(tileentitytypes_a, Set.of(ablock))); // CraftBukkit - decompile error } - public boolean onlyOpCanSetNbt() { + private TileEntityTypes(TileEntityTypes.a tileentitytypes_a, Set set) { diff --git a/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.patch b/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.patch index 51a8d8e13..bc4ac99b3 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.patch @@ -13,28 +13,28 @@ public final class TrialSpawner { public static final String NORMAL_CONFIG_TAG_NAME = "normal_config"; -@@ -219,13 +225,18 @@ - } - - entityinsentient.setPersistenceRequired(); -- Optional optional1 = mobspawnerdata.getEquipment(); -+ Optional optional1 = mobspawnerdata.getEquipment(); // CraftBukkit - decompile error - - Objects.requireNonNull(entityinsentient); - optional1.ifPresent(entityinsentient::equip); +@@ -214,13 +220,18 @@ } -- if (!worldserver.tryAddFreshEntityWithPassengers(entity)) { -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callTrialSpawnerSpawnEvent(entity, blockposition).isCancelled()) { -+ return Optional.empty(); -+ } -+ if (!worldserver.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRIAL_SPAWNER)) { -+ // CraftBukkit end - return Optional.empty(); - } else { - TrialSpawner.a trialspawner_a = this.isOminous ? TrialSpawner.a.OMINOUS : TrialSpawner.a.NORMAL; -@@ -248,6 +259,15 @@ + entityinsentient.setPersistenceRequired(); +- Optional optional1 = mobspawnerdata.getEquipment(); ++ Optional optional1 = mobspawnerdata.getEquipment(); // CraftBukkit - decompile error + + Objects.requireNonNull(entityinsentient); + optional1.ifPresent(entityinsentient::equip); + } + +- if (!worldserver.tryAddFreshEntityWithPassengers(entity)) { ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callTrialSpawnerSpawnEvent(entity, blockposition).isCancelled()) { ++ return Optional.empty(); ++ } ++ if (!worldserver.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRIAL_SPAWNER)) { ++ // CraftBukkit end + return Optional.empty(); + } else { + TrialSpawner.a trialspawner_a = this.isOminous ? TrialSpawner.a.OMINOUS : TrialSpawner.a.NORMAL; +@@ -242,6 +253,15 @@ ObjectArrayList objectarraylist = loottable.getRandomItems(lootparams); if (!objectarraylist.isEmpty()) { diff --git a/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.patch b/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.patch index e69745a45..ef3eba737 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.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 -@@ -210,7 +210,7 @@ +@@ -203,7 +203,7 @@ } public void resetAfterBecomingOminous(TrialSpawner trialspawner, WorldServer worldserver) { @@ -9,7 +9,7 @@ Objects.requireNonNull(worldserver); stream.map(worldserver::getEntity).forEach((entity) -> { -@@ -222,7 +222,7 @@ +@@ -215,7 +215,7 @@ entityinsentient.dropPreservedEquipment(worldserver); } diff --git a/nms-patches/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.patch b/nms-patches/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.patch index a44d02ca0..aab44884c 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java +++ b/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java -@@ -46,6 +46,13 @@ +@@ -43,6 +43,13 @@ + import net.minecraft.world.level.storage.loot.parameters.LootContextParameters; import net.minecraft.world.phys.Vec3D; - import org.slf4j.Logger; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -13,44 +13,24 @@ + public class VaultBlockEntity extends TileEntity { - private static final Logger LOGGER = LogUtils.getLogger(); -@@ -96,18 +103,18 @@ - dataresult = VaultServerData.CODEC.parse(dynamicops, nbttagcompound.get("server_data")); - logger = VaultBlockEntity.LOGGER; - Objects.requireNonNull(logger); -- optional = dataresult.resultOrPartial(logger::error); -+ optional = ((DataResult) dataresult).resultOrPartial(logger::error); // CraftBukkit - decompile error - VaultServerData vaultserverdata = this.serverData; + private final VaultServerData serverData = new VaultServerData(); +@@ -86,13 +93,13 @@ + VaultServerData vaultserverdata = this.serverData; - Objects.requireNonNull(this.serverData); -- optional.ifPresent(vaultserverdata::set); -+ ((Optional) optional).ifPresent(vaultserverdata::set); // CraftBukkit - decompile error - } - - if (nbttagcompound.contains("config")) { - dataresult = VaultConfig.CODEC.parse(dynamicops, nbttagcompound.get("config")); - logger = VaultBlockEntity.LOGGER; - Objects.requireNonNull(logger); -- dataresult.resultOrPartial(logger::error).ifPresent((vaultconfig) -> { -+ ((DataResult) dataresult).resultOrPartial(logger::error).ifPresent((vaultconfig) -> { // CraftBukkit - decompile error - this.config = vaultconfig; - }); - } -@@ -116,11 +123,11 @@ - dataresult = VaultSharedData.CODEC.parse(dynamicops, nbttagcompound.get("shared_data")); - logger = VaultBlockEntity.LOGGER; - Objects.requireNonNull(logger); -- optional = dataresult.resultOrPartial(logger::error); -+ optional = ((DataResult) dataresult).resultOrPartial(logger::error); // CraftBukkit - decompile error - VaultSharedData vaultshareddata = this.sharedData; - - Objects.requireNonNull(this.sharedData); -- optional.ifPresent(vaultshareddata::set); -+ ((Optional) optional).ifPresent(vaultshareddata::set); // CraftBukkit - decompile error - } + Objects.requireNonNull(this.serverData); +- optional.ifPresent(vaultserverdata::set); ++ ((Optional) optional).ifPresent(vaultserverdata::set); // CraftBukkit - decompile error + this.config = (VaultConfig) nbttagcompound.read("config", VaultConfig.CODEC, dynamicops).orElse(VaultConfig.DEFAULT); + optional = nbttagcompound.read("shared_data", VaultSharedData.CODEC, dynamicops); + VaultSharedData vaultshareddata = this.sharedData; + Objects.requireNonNull(this.sharedData); +- optional.ifPresent(vaultshareddata::set); ++ ((Optional) optional).ifPresent(vaultshareddata::set); // CraftBukkit - decompile error } -@@ -320,6 +327,14 @@ + + @Nullable +@@ -167,6 +174,14 @@ if (!list.isEmpty()) { entityhuman.awardStat(StatisticList.ITEM_USED.get(itemstack.getItem())); itemstack.consume(vaultconfig.keyItem().getCount(), entityhuman); @@ -65,7 +45,7 @@ unlock(worldserver, iblockdata, blockposition, vaultconfig, vaultserverdata, vaultshareddata, list); vaultserverdata.addToRewardedPlayers(entityhuman); vaultshareddata.updateConnectedPlayersWithinRange(worldserver, blockposition, vaultserverdata, vaultconfig, vaultconfig.deactivationRange()); -@@ -341,6 +356,14 @@ +@@ -188,6 +203,14 @@ vaultshareddata.setDisplayItem(ItemStack.EMPTY); } else { ItemStack itemstack = getRandomDisplayItemFromLootTable(worldserver, blockposition, (ResourceKey) vaultconfig.overrideLootTableToDisplay().orElse(vaultconfig.lootTable())); diff --git a/nms-patches/net/minecraft/world/level/block/entity/vault/VaultServerData.patch b/nms-patches/net/minecraft/world/level/block/entity/vault/VaultServerData.patch deleted file mode 100644 index e66793cb3..000000000 --- a/nms-patches/net/minecraft/world/level/block/entity/vault/VaultServerData.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/block/entity/vault/VaultServerData.java -+++ b/net/minecraft/world/level/block/entity/vault/VaultServerData.java -@@ -54,7 +54,7 @@ - return this.lastInsertFailTimestamp; - } - -- Set getRewardedPlayers() { -+ public Set getRewardedPlayers() { // PAIL package private -> public - return this.rewardedPlayers; - } - diff --git a/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch b/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch index f5710a773..02db3f0ce 100644 --- a/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch +++ b/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/grower/WorldGenTreeProvider.java +++ b/net/minecraft/world/level/block/grower/WorldGenTreeProvider.java -@@ -24,6 +24,12 @@ +@@ -23,6 +23,12 @@ import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.levelgen.feature.WorldGenFeatureConfigured; @@ -13,7 +13,7 @@ public final class WorldGenTreeProvider { private static final Map GROWERS = new Object2ObjectArrayMap(); -@@ -75,21 +81,22 @@ +@@ -74,21 +80,22 @@ } } @@ -39,7 +39,7 @@ for (int i = 0; i >= -1; --i) { for (int j = 0; j >= -1; --j) { if (isTwoByTwoSapling(iblockdata, worldserver, blockposition, i, j)) { -@@ -120,11 +127,12 @@ +@@ -119,11 +126,12 @@ if (resourcekey1 == null) { return false; } else { @@ -50,11 +50,11 @@ return false; } else { + setTreeType(holder1); // CraftBukkit - WorldGenFeatureConfigured worldgenfeatureconfigured1 = (WorldGenFeatureConfigured) holder1.value(); + WorldGenFeatureConfigured worldgenfeatureconfigured1 = holder1.value(); IBlockData iblockdata2 = worldserver.getFluidState(blockposition).createLegacyBlock(); -@@ -165,11 +173,66 @@ - return true; +@@ -158,11 +166,66 @@ + return false; } + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch b/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch index 7b2160e5e..bd9c31cf5 100644 --- a/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch +++ b/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/piston/BlockPiston.java +++ b/net/minecraft/world/level/block/piston/BlockPiston.java -@@ -45,6 +45,14 @@ +@@ -42,6 +42,14 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -15,7 +15,7 @@ public class BlockPiston extends BlockDirectional { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -155,6 +163,18 @@ +@@ -129,6 +137,18 @@ } } @@ -31,10 +31,10 @@ + } + // PAIL: checkME - what happened to setTypeAndData? + // CraftBukkit end - world.blockEvent(blockposition, this, b0, enumdirection.get3DDataValue()); + world.blockEvent(blockposition, this, i, enumdirection.get3DDataValue()); } -@@ -335,6 +355,48 @@ +@@ -295,6 +315,48 @@ IBlockData[] aiblockdata = new IBlockData[list.size() + list2.size()]; EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.getOpposite(); int i = 0; @@ -81,5 +81,5 @@ + } + // CraftBukkit end - BlockPosition blockposition3; - int j; + for (int j = list2.size() - 1; j >= 0; --j) { + BlockPosition blockposition3 = (BlockPosition) list2.get(j); diff --git a/nms-patches/net/minecraft/world/level/block/state/BlockBase.patch b/nms-patches/net/minecraft/world/level/block/state/BlockBase.patch index 55d783e12..84701ea65 100644 --- a/nms-patches/net/minecraft/world/level/block/state/BlockBase.patch +++ b/nms-patches/net/minecraft/world/level/block/state/BlockBase.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/state/BlockBase.java +++ b/net/minecraft/world/level/block/state/BlockBase.java -@@ -84,6 +84,11 @@ +@@ -85,6 +85,11 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -12,7 +12,7 @@ public abstract class BlockBase implements FeatureElement { protected static final EnumDirection[] UPDATE_SHAPE_ORDER = new EnumDirection[]{EnumDirection.WEST, EnumDirection.EAST, EnumDirection.NORTH, EnumDirection.SOUTH, EnumDirection.DOWN, EnumDirection.UP}; -@@ -158,6 +163,12 @@ +@@ -159,6 +164,12 @@ protected void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) {} @@ -22,10 +22,10 @@ + } + // CraftBukkit end + - protected void onRemove(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) { - if (iblockdata.hasBlockEntity() && !iblockdata.is(iblockdata1.getBlock())) { - world.removeBlockEntity(blockposition); -@@ -174,8 +185,10 @@ + protected void affectNeighborsAfterRemoval(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, boolean flag) {} + + protected void onExplosionHit(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Explosion explosion, BiConsumer biconsumer) { +@@ -170,8 +181,10 @@ TileEntity tileentity = iblockdata.hasBlockEntity() ? worldserver.getBlockEntity(blockposition) : null; LootParams.a lootparams_a = (new LootParams.a(worldserver)).withParameter(LootContextParameters.ORIGIN, Vec3D.atCenterOf(blockposition)).withParameter(LootContextParameters.TOOL, ItemStack.EMPTY).withOptionalParameter(LootContextParameters.BLOCK_ENTITY, tileentity).withOptionalParameter(LootContextParameters.THIS_ENTITY, explosion.getDirectSourceEntity()); @@ -38,7 +38,7 @@ } iblockdata.spawnAfterBreak(worldserver, blockposition, ItemStack.EMPTY, flag); -@@ -1125,7 +1138,13 @@ +@@ -1106,7 +1119,13 @@ } public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata, boolean flag) { @@ -52,4 +52,4 @@ + // CraftBukkit end } - public void onRemove(World world, BlockPosition blockposition, IBlockData iblockdata, boolean flag) { + public void affectNeighborsAfterRemoval(WorldServer worldserver, BlockPosition blockposition, boolean flag) { diff --git a/nms-patches/net/minecraft/world/level/border/WorldBorder.patch b/nms-patches/net/minecraft/world/level/border/WorldBorder.patch index 732d68c4d..82aefd265 100644 --- a/nms-patches/net/minecraft/world/level/border/WorldBorder.patch +++ b/nms-patches/net/minecraft/world/level/border/WorldBorder.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/border/WorldBorder.java +++ b/net/minecraft/world/level/border/WorldBorder.java -@@ -30,6 +30,7 @@ +@@ -32,6 +32,7 @@ int absoluteMaxSize = 29999984; - private WorldBorder.a extent = new WorldBorder.d(5.9999968E7D); - public static final WorldBorder.c DEFAULT_SETTINGS = new WorldBorder.c(0.0D, 0.0D, 0.2D, 5.0D, 5, 15, 5.9999968E7D, 0L, 0.0D); + private WorldBorder.a extent = new WorldBorder.e((double) 5.999997E7F); + public static final WorldBorder.d DEFAULT_SETTINGS = new WorldBorder.d(0.0D, 0.0D, 0.2D, 5.0D, 5, 15, (double) 5.999997E7F, 0L, 0.0D); + public net.minecraft.server.level.WorldServer world; // CraftBukkit public WorldBorder() {} -@@ -189,6 +190,7 @@ +@@ -190,6 +191,7 @@ } public void addListener(IWorldBorderListener iworldborderlistener) { diff --git a/nms-patches/net/minecraft/world/level/chunk/Chunk.patch b/nms-patches/net/minecraft/world/level/chunk/Chunk.patch index 4937f5fc7..36bed9506 100644 --- a/nms-patches/net/minecraft/world/level/chunk/Chunk.patch +++ b/nms-patches/net/minecraft/world/level/chunk/Chunk.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/Chunk.java +++ b/net/minecraft/world/level/chunk/Chunk.java -@@ -79,7 +79,7 @@ +@@ -78,7 +78,7 @@ }; private final Map tickersInLevel; public boolean loaded; @@ -9,16 +9,16 @@ @Nullable private Supplier fullStatus; @Nullable -@@ -98,7 +98,7 @@ +@@ -97,7 +97,7 @@ this.tickersInLevel = Maps.newHashMap(); this.unsavedListener = (chunkcoordintpair1) -> { }; - this.level = world; + this.level = (WorldServer) world; // CraftBukkit - type this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap(); - HeightMap.Type[] aheightmap_type = HeightMap.Type.values(); - int j = aheightmap_type.length; -@@ -116,6 +116,11 @@ + + for (HeightMap.Type heightmap_type : HeightMap.Type.values()) { +@@ -111,6 +111,11 @@ this.fluidTicks = levelchunkticks1; } @@ -30,7 +30,7 @@ public Chunk(WorldServer worldserver, ProtoChunk protochunk, @Nullable Chunk.c chunk_c) { this(worldserver, protochunk.getPos(), protochunk.getUpgradeData(), protochunk.unpackBlockTicks(), protochunk.unpackFluidTicks(), protochunk.getInhabitedTime(), protochunk.getSections(), chunk_c, protochunk.getBlendingData()); if (!Collections.disjoint(protochunk.pendingBlockEntities.keySet(), protochunk.blockEntities.keySet())) { -@@ -151,6 +156,10 @@ +@@ -139,6 +144,10 @@ this.skyLightSources = protochunk.skyLightSources; this.setLightCorrect(protochunk.isLightCorrect()); this.markUnsaved(); @@ -41,34 +41,17 @@ } public void setUnsavedListener(Chunk.e chunk_e) { -@@ -272,9 +281,16 @@ - } - } - -+ // CraftBukkit start - @Nullable - @Override - public IBlockData setBlockState(BlockPosition blockposition, IBlockData iblockdata, boolean flag) { -+ return this.setBlockState(blockposition, iblockdata, flag, true); -+ } -+ -+ @Nullable -+ public IBlockData setBlockState(BlockPosition blockposition, IBlockData iblockdata, boolean flag, boolean doPlace) { -+ // CraftBukkit end - int i = blockposition.getY(); - ChunkSection chunksection = this.getSection(this.getSectionIndex(i)); - boolean flag1 = chunksection.hasOnlyAir(); -@@ -324,7 +340,8 @@ - if (!chunksection.getBlockState(j, k, l).is(block)) { +@@ -332,7 +341,8 @@ + if (!chunksection.getBlockState(k, l, i1).is(block)) { return null; } else { -- if (!this.level.isClientSide) { +- if (!this.level.isClientSide && (i & 512) == 0) { + // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled. -+ if (!this.level.isClientSide && doPlace && (!this.level.captureBlockStates || block instanceof net.minecraft.world.level.block.BlockTileEntity)) { - iblockdata.onPlace(this.level, blockposition, iblockdata1, flag); ++ if (!this.level.isClientSide && (i & 512) == 0 && (!this.level.captureBlockStates || block instanceof net.minecraft.world.level.block.BlockTileEntity)) { + iblockdata.onPlace(this.level, blockposition, iblockdata1, flag3); } -@@ -375,7 +392,12 @@ +@@ -383,7 +393,12 @@ @Nullable public TileEntity getBlockEntity(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) { @@ -82,7 +65,7 @@ if (tileentity == null) { NBTTagCompound nbttagcompound = (NBTTagCompound) this.pendingBlockEntities.remove(blockposition); -@@ -447,6 +469,7 @@ +@@ -455,6 +470,7 @@ if (!iblockdata.hasBlockEntity()) { Chunk.LOGGER.warn("Trying to set block entity {} at position {}, but state {} does not allow it", new Object[]{tileentity, blockposition, iblockdata}); @@ -90,7 +73,7 @@ } else { IBlockData iblockdata1 = tileentity.getBlockState(); -@@ -500,6 +523,12 @@ +@@ -509,6 +525,12 @@ if (this.isInLevel()) { TileEntity tileentity = (TileEntity) this.blockEntities.remove(blockposition); @@ -103,7 +86,7 @@ if (tileentity != null) { World world = this.level; -@@ -553,6 +582,57 @@ +@@ -562,6 +584,57 @@ } @@ -161,16 +144,16 @@ public boolean isEmpty() { return false; } -@@ -750,7 +830,7 @@ +@@ -736,7 +809,7 @@ private void updateBlockEntityTicker(T t0) { IBlockData iblockdata = t0.getBlockState(); -- BlockEntityTicker blockentityticker = iblockdata.getTicker(this.level, t0.getType()); -+ BlockEntityTicker blockentityticker = iblockdata.getTicker(this.level, (TileEntityTypes) t0.getType()); // CraftBukkit - decompile error +- BlockEntityTicker blockentityticker = iblockdata.getTicker(this.level, ((TileEntity) t0).getType()); ++ BlockEntityTicker blockentityticker = iblockdata.getTicker(this.level, (TileEntityTypes) ((TileEntity) t0).getType()); // CraftBukkit - decompile error if (blockentityticker == null) { this.removeBlockEntityTicker(t0.getBlockPos()); -@@ -841,7 +921,7 @@ +@@ -778,7 +851,7 @@ private boolean loggedInvalidBlockState; a(final TileEntity tileentity, final BlockEntityTicker blockentityticker) { diff --git a/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch b/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch index 1d0aecddd..30ac4cd48 100644 --- a/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch +++ b/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/net/minecraft/world/level/chunk/ChunkGenerator.java -@@ -312,7 +312,7 @@ +@@ -286,7 +286,7 @@ } } @@ -9,16 +9,25 @@ ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos(); if (!SharedConstants.debugVoidTerrain(chunkcoordintpair)) { -@@ -334,7 +334,7 @@ +@@ -305,7 +305,7 @@ + IChunkAccess ichunkaccess1 = generatoraccessseed.getChunk(chunkcoordintpair1.x, chunkcoordintpair1.z); - for (int k = 0; k < j; ++k) { - ChunkSection chunksection = achunksection[k]; + for (ChunkSection chunksection : ichunkaccess1.getSections()) { - PalettedContainerRO palettedcontainerro = chunksection.getBiomes(); + PalettedContainerRO> palettedcontainerro = chunksection.getBiomes(); // CraftBukkit - decompile error Objects.requireNonNull(set); palettedcontainerro.getAll(set::add); -@@ -445,6 +445,33 @@ +@@ -323,7 +323,7 @@ + int i1 = 0; + + if (structuremanager.shouldGenerateStructures()) { +- for (Structure structure : (List) map.getOrDefault(l, Collections.emptyList())) { ++ for (Structure structure : map.getOrDefault(l, Collections.emptyList())) { // CraftBukkit - decompile error + seededrandom.setFeatureSeed(i, i1, l); + Supplier supplier = () -> { + Optional optional = iregistry.getResourceKey(structure).map(Object::toString); +@@ -409,6 +409,33 @@ } } @@ -52,7 +61,7 @@ private static StructureBoundingBox getWritableArea(IChunkAccess ichunkaccess) { ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos(); int i = chunkcoordintpair.getMinBlockX(); -@@ -582,6 +609,14 @@ +@@ -540,6 +567,14 @@ StructureStart structurestart = structure.generate(structureset_a.structure(), resourcekey, iregistrycustom, this, this.biomeSource, randomstate, structuretemplatemanager, i, chunkcoordintpair, j, ichunkaccess, predicate); if (structurestart.isValid()) { diff --git a/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch b/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch index 72784c4b5..287af43d1 100644 --- a/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch +++ b/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch @@ -19,7 +19,7 @@ this.biomes = palettedcontainerro; this.recalcBlockCounts(); @@ -196,6 +196,12 @@ - return (Holder) this.biomes.get(i, j, k); + return this.biomes.get(i, j, k); } + // CraftBukkit start @@ -30,4 +30,4 @@ + public void fillBiomesFromNoise(BiomeResolver biomeresolver, Climate.Sampler climate_sampler, int i, int j, int k) { DataPaletteBlock> datapaletteblock = this.biomes.recreate(); - boolean flag = true; + int l = 4; diff --git a/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch b/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch index 427607fb1..136933c84 100644 --- a/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch +++ b/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/IChunkAccess.java +++ b/net/minecraft/world/level/chunk/IChunkAccess.java -@@ -85,6 +85,11 @@ +@@ -84,6 +84,11 @@ protected final LevelHeightAccessor levelHeightAccessor; protected final ChunkSection[] sections; @@ -12,7 +12,7 @@ public IChunkAccess(ChunkCoordIntPair chunkcoordintpair, ChunkConverter chunkconverter, LevelHeightAccessor levelheightaccessor, IRegistry iregistry, long i, @Nullable ChunkSection[] achunksection, @Nullable BlendingData blendingdata) { this.chunkPos = chunkcoordintpair; this.upgradeData = chunkconverter; -@@ -103,7 +108,11 @@ +@@ -102,7 +107,11 @@ } replaceMissingSections(iregistry, this.sections); @@ -24,7 +24,7 @@ private static void replaceMissingSections(IRegistry iregistry, ChunkSection[] achunksection) { for (int i = 0; i < achunksection.length; ++i) { -@@ -275,6 +284,7 @@ +@@ -279,6 +288,7 @@ public boolean tryMarkSaved() { if (this.unsaved) { this.unsaved = false; @@ -32,7 +32,7 @@ return true; } else { return false; -@@ -282,7 +292,7 @@ +@@ -286,7 +296,7 @@ } public boolean isUnsaved() { @@ -41,7 +41,7 @@ } public abstract ChunkStatus getPersistedStatus(); -@@ -463,6 +473,27 @@ +@@ -467,6 +477,27 @@ } } diff --git a/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch b/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch index ad8619c4f..e3e088e77 100644 --- a/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch +++ b/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch @@ -37,12 +37,12 @@ + throw new RuntimeException(ex); + } + if (nbt != null) { -+ NBTTagCompound level = nbt.getCompound("Level"); -+ if (level.getBoolean("TerrainPopulated")) { ++ NBTTagCompound level = nbt.getCompoundOrEmpty("Level"); ++ if (level.getBooleanOr("TerrainPopulated", false)) { + return true; + } + -+ ChunkStatus status = ChunkStatus.byName(level.getString("Status")); ++ ChunkStatus status = ChunkStatus.byName(level.getStringOr("Status", "")); + if (status != null && status.isOrAfter(ChunkStatus.FEATURES)) { + return true; + } @@ -61,8 +61,8 @@ try { + // CraftBukkit start + if (i < 1466) { -+ NBTTagCompound level = nbttagcompound.getCompound("Level"); -+ if (level.getBoolean("TerrainPopulated") && !level.getBoolean("LightPopulated")) { ++ NBTTagCompound level = nbttagcompound.getCompoundOrEmpty("Level"); ++ if (level.getBooleanOr("TerrainPopulated", false) && !level.getBooleanOr("LightPopulated", false)) { + ChunkProviderServer cps = (generatoraccess == null) ? null : ((WorldServer) generatoraccess).getChunkSource(); + if (check(cps, pos.x - 1, pos.z) && check(cps, pos.x - 1, pos.z - 1) && check(cps, pos.x, pos.z - 1)) { + level.putBoolean("LightPopulated", true); @@ -73,8 +73,8 @@ + if (i < 1493) { nbttagcompound = DataFixTypes.CHUNK.update(this.fixerUpper, nbttagcompound, i, 1493); - if (nbttagcompound.getCompound("Level").getBoolean("hasLegacyStructureData")) { -@@ -70,7 +122,7 @@ + if ((Boolean) nbttagcompound.getCompound("Level").flatMap((nbttagcompound1) -> { +@@ -72,7 +124,7 @@ } } @@ -83,7 +83,7 @@ PersistentStructureLegacy persistentstructurelegacy = this.legacyStructureHandler; if (persistentstructurelegacy == null) { -@@ -85,7 +137,7 @@ +@@ -87,7 +139,7 @@ return persistentstructurelegacy; } diff --git a/nms-patches/net/minecraft/world/level/chunk/storage/RegionFile.patch b/nms-patches/net/minecraft/world/level/chunk/storage/RegionFile.patch index ec081d2e9..a13785879 100644 --- a/nms-patches/net/minecraft/world/level/chunk/storage/RegionFile.patch +++ b/nms-patches/net/minecraft/world/level/chunk/storage/RegionFile.patch @@ -52,16 +52,16 @@ return bytebuffer; } -@@ -358,7 +359,7 @@ - FileChannel filechannel = FileChannel.open(path1, StandardOpenOption.CREATE, StandardOpenOption.WRITE); +@@ -357,7 +358,7 @@ + Path path1 = Files.createTempFile(this.externalFileDir, "tmp", (String) null); - try { + try (FileChannel filechannel = FileChannel.open(path1, StandardOpenOption.CREATE, StandardOpenOption.WRITE)) { - bytebuffer.position(5); + ((java.nio.Buffer) bytebuffer).position(5); // CraftBukkit - decompile error filechannel.write(bytebuffer); - } catch (Throwable throwable) { - if (filechannel != null) { -@@ -382,7 +383,7 @@ + } + +@@ -367,7 +368,7 @@ } private void writeHeader() throws IOException { @@ -70,7 +70,7 @@ this.file.write(this.header, 0L); } -@@ -418,7 +419,7 @@ +@@ -403,7 +404,7 @@ if (i != j) { ByteBuffer bytebuffer = RegionFile.PADDING_BUFFER.duplicate(); diff --git a/nms-patches/net/minecraft/world/level/chunk/storage/RegionFileCache.patch b/nms-patches/net/minecraft/world/level/chunk/storage/RegionFileCache.patch index 888c3ee20..695afb67a 100644 --- a/nms-patches/net/minecraft/world/level/chunk/storage/RegionFileCache.patch +++ b/nms-patches/net/minecraft/world/level/chunk/storage/RegionFileCache.patch @@ -28,10 +28,10 @@ + return null; + } + // CraftBukkit end - DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkcoordintpair); - NBTTagCompound nbttagcompound; -@@ -96,7 +102,12 @@ + try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkcoordintpair)) { + if (datainputstream == null) { +@@ -68,7 +74,12 @@ } public void scanChunk(ChunkCoordIntPair chunkcoordintpair, StreamTagVisitor streamtagvisitor) throws IOException { @@ -42,10 +42,10 @@ + return; + } + // CraftBukkit end - DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkcoordintpair); - try { -@@ -122,7 +133,7 @@ + try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkcoordintpair)) { + if (datainputstream != null) { +@@ -79,7 +90,7 @@ } protected void write(ChunkCoordIntPair chunkcoordintpair, @Nullable NBTTagCompound nbttagcompound) throws IOException { diff --git a/nms-patches/net/minecraft/world/level/chunk/storage/SerializableChunkData.patch b/nms-patches/net/minecraft/world/level/chunk/storage/SerializableChunkData.patch index ccd848a8e..c6ba7470e 100644 --- a/nms-patches/net/minecraft/world/level/chunk/storage/SerializableChunkData.patch +++ b/nms-patches/net/minecraft/world/level/chunk/storage/SerializableChunkData.patch @@ -1,87 +1,85 @@ --- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -@@ -76,7 +76,8 @@ +@@ -71,7 +71,12 @@ import net.minecraft.world.ticks.TickListChunk; import org.slf4j.Logger; -public record SerializableChunkData(IRegistry biomeRegistry, ChunkCoordIntPair chunkPos, int minSectionY, long lastUpdateTime, long inhabitedTime, ChunkStatus chunkStatus, @Nullable BlendingData.d blendingData, @Nullable BelowZeroRetrogen belowZeroRetrogen, ChunkConverter upgradeData, @Nullable long[] carvingMask, Map heightmaps, IChunkAccess.a packedTicks, ShortList[] postProcessingSections, boolean lightCorrect, List sectionData, List entities, List blockEntities, NBTTagCompound structureData) { ++// CraftBukkit start ++import net.minecraft.nbt.NBTBase; ++// CraftBukkit end ++ +// CraftBukkit - persistentDataContainer +public record SerializableChunkData(IRegistry biomeRegistry, ChunkCoordIntPair chunkPos, int minSectionY, long lastUpdateTime, long inhabitedTime, ChunkStatus chunkStatus, @Nullable BlendingData.d blendingData, @Nullable BelowZeroRetrogen belowZeroRetrogen, ChunkConverter upgradeData, @Nullable long[] carvingMask, Map heightmaps, IChunkAccess.a packedTicks, ShortList[] postProcessingSections, boolean lightCorrect, List sectionData, List entities, List blockEntities, NBTTagCompound structureData, @Nullable NBTBase persistentDataContainer) { public static final Codec> BLOCK_STATE_CODEC = DataPaletteBlock.codecRW(Block.BLOCK_STATE_REGISTRY, IBlockData.CODEC, DataPaletteBlock.d.SECTION_STATES, Blocks.AIR.defaultBlockState()); - private static final Logger LOGGER = LogUtils.getLogger(); -@@ -110,7 +111,7 @@ - dataresult = BlendingData.d.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("blending_data")); - logger = SerializableChunkData.LOGGER; - Objects.requireNonNull(logger); -- blendingdata_d = (BlendingData.d) dataresult.resultOrPartial(logger::error).orElse((Object) null); -+ blendingdata_d = (BlendingData.d) ((DataResult) dataresult).resultOrPartial(logger::error).orElse(null); // CraftBukkit - decompile error - } else { - blendingdata_d = null; - } -@@ -121,7 +122,7 @@ - dataresult = BelowZeroRetrogen.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("below_zero_retrogen")); - logger = SerializableChunkData.LOGGER; - Objects.requireNonNull(logger); -- belowzeroretrogen = (BelowZeroRetrogen) dataresult.resultOrPartial(logger::error).orElse((Object) null); -+ belowzeroretrogen = (BelowZeroRetrogen) ((DataResult) dataresult).resultOrPartial(logger::error).orElse(null); // CraftBukkit - decompile error - } else { - belowzeroretrogen = null; - } -@@ -178,7 +179,7 @@ - NBTTagList nbttaglist2 = nbttagcompound.getList("sections", 10); + private static final Codec>> BLOCK_TICKS_CODEC = TickListChunk.codec(BuiltInRegistries.BLOCK.byNameCodec()).listOf(); +@@ -101,9 +106,9 @@ + return new ChunkConverter(nbttagcompound1, levelheightaccessor); + }).orElse(ChunkConverter.EMPTY); + boolean flag = nbttagcompound.getBooleanOr("isLightOn", false); +- BlendingData.d blendingdata_d = (BlendingData.d) nbttagcompound.read("blending_data", BlendingData.d.CODEC).orElse((Object) null); +- BelowZeroRetrogen belowzeroretrogen = (BelowZeroRetrogen) nbttagcompound.read("below_zero_retrogen", BelowZeroRetrogen.CODEC).orElse((Object) null); +- long[] along = (long[]) nbttagcompound.getLongArray("carving_mask").orElse((Object) null); ++ BlendingData.d blendingdata_d = (BlendingData.d) nbttagcompound.read("blending_data", BlendingData.d.CODEC).orElse(null); // CraftBukkit - decompile error ++ BelowZeroRetrogen belowzeroretrogen = (BelowZeroRetrogen) nbttagcompound.read("below_zero_retrogen", BelowZeroRetrogen.CODEC).orElse(null); // CraftBukkit - decompile error ++ long[] along = (long[]) nbttagcompound.getLongArray("carving_mask").orElse(null); // CraftBukkit - decompile error + Map map = new EnumMap(HeightMap.Type.class); + + nbttagcompound.getCompound("Heightmaps").ifPresent((nbttagcompound1) -> { +@@ -137,7 +142,7 @@ + NBTTagList nbttaglist2 = nbttagcompound.getListOrEmpty("sections"); List list4 = new ArrayList(nbttaglist2.size()); IRegistry iregistry = iregistrycustom.lookupOrThrow(Registries.BIOME); - Codec>> codec = makeBiomeCodec(iregistry); + Codec>> codec = makeBiomeCodecRW(iregistry); // CraftBukkit - read/write for (int i1 = 0; i1 < nbttaglist2.size(); ++i1) { - NBTTagCompound nbttagcompound3 = nbttaglist2.getCompound(i1); -@@ -196,17 +197,17 @@ - datapaletteblock = new DataPaletteBlock<>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), DataPaletteBlock.d.SECTION_STATES); + Optional optional = nbttaglist2.getCompound(i1); +@@ -155,8 +160,8 @@ + }).orElseGet(() -> { + return new DataPaletteBlock(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), DataPaletteBlock.d.SECTION_STATES); + }); +- PalettedContainerRO> palettedcontainerro = (PalettedContainerRO) nbttagcompound2.getCompound("biomes").map((nbttagcompound3) -> { +- return (PalettedContainerRO) codec.parse(DynamicOpsNBT.INSTANCE, nbttagcompound3).promotePartial((s) -> { ++ DataPaletteBlock> palettedcontainerro = nbttagcompound2.getCompound("biomes").map((nbttagcompound3) -> { // CraftBukkit - read/write ++ return codec.parse(DynamicOpsNBT.INSTANCE, nbttagcompound3).promotePartial((s) -> { // CraftBukkit - read/write + logErrors(chunkcoordintpair, j1, s); + }).getOrThrow(SerializableChunkData.a::new); + }).orElseGet(() -> { +@@ -168,14 +173,15 @@ + chunksection = null; } -- Object object; -+ DataPaletteBlock object; // CraftBukkit - read/write +- NibbleArray nibblearray = (NibbleArray) nbttagcompound2.getByteArray("BlockLight").map(NibbleArray::new).orElse((Object) null); +- NibbleArray nibblearray1 = (NibbleArray) nbttagcompound2.getByteArray("SkyLight").map(NibbleArray::new).orElse((Object) null); ++ NibbleArray nibblearray = (NibbleArray) nbttagcompound2.getByteArray("BlockLight").map(NibbleArray::new).orElse(null); // CraftBukkit - decompile error ++ NibbleArray nibblearray1 = (NibbleArray) nbttagcompound2.getByteArray("SkyLight").map(NibbleArray::new).orElse(null); // CraftBukkit - decompile error - if (nbttagcompound3.contains("biomes", 10)) { -- object = (PalettedContainerRO) codec.parse(DynamicOpsNBT.INSTANCE, nbttagcompound3.getCompound("biomes")).promotePartial((s1) -> { -+ object = codec.parse(DynamicOpsNBT.INSTANCE, nbttagcompound3.getCompound("biomes")).promotePartial((s1) -> { // CraftBukkit - read/write - logErrors(chunkcoordintpair, b0, s1); - }).getOrThrow(SerializableChunkData.a::new); - } else { - object = new DataPaletteBlock<>(iregistry.asHolderIdMap(), iregistry.getOrThrow(Biomes.PLAINS), DataPaletteBlock.d.SECTION_BIOMES); - } - -- chunksection = new ChunkSection(datapaletteblock, (PalettedContainerRO) object); -+ chunksection = new ChunkSection(datapaletteblock, (DataPaletteBlock) object); // CraftBukkit - read/write - } else { - chunksection = null; + list4.add(new SerializableChunkData.b(j1, chunksection, nibblearray, nibblearray1)); } -@@ -217,7 +218,8 @@ - list4.add(new SerializableChunkData.b(b0, chunksection, nibblearray, nibblearray1)); } -- return new SerializableChunkData(iregistry, chunkcoordintpair, levelheightaccessor.getMinSectionY(), i, j, chunkstatus, blendingdata_d, belowzeroretrogen, chunkconverter, along, map, ichunkaccess_a, ashortlist, flag, list4, list2, list3, nbttagcompound2); +- return new SerializableChunkData(iregistry, chunkcoordintpair, levelheightaccessor.getMinSectionY(), i, j, chunkstatus, blendingdata_d, belowzeroretrogen, chunkconverter, along, map, ichunkaccess_a, ashortlist, flag, list4, list2, list3, nbttagcompound1); + // CraftBukkit - ChunkBukkitValues -+ return new SerializableChunkData(iregistry, chunkcoordintpair, levelheightaccessor.getMinSectionY(), i, j, chunkstatus, blendingdata_d, belowzeroretrogen, chunkconverter, along, map, ichunkaccess_a, ashortlist, flag, list4, list2, list3, nbttagcompound2, nbttagcompound.get("ChunkBukkitValues")); ++ return new SerializableChunkData(iregistry, chunkcoordintpair, levelheightaccessor.getMinSectionY(), i, j, chunkstatus, blendingdata_d, belowzeroretrogen, chunkconverter, along, map, ichunkaccess_a, ashortlist, flag, list4, list2, list3, nbttagcompound1, nbttagcompound.get("ChunkBukkitValues")); } } -@@ -289,6 +291,12 @@ +@@ -245,6 +251,12 @@ } } + // CraftBukkit start - load chunk persistent data from nbt - SPIGOT-6814: Already load PDC here to account for 1.17 to 1.18 chunk upgrading. + if (persistentDataContainer instanceof NBTTagCompound) { -+ ((IChunkAccess) object).persistentDataContainer.putAll((NBTTagCompound) persistentDataContainer); ++ ichunkaccess.persistentDataContainer.putAll((NBTTagCompound) persistentDataContainer); + } + // CraftBukkit end + - ((IChunkAccess) object).setLightCorrect(this.lightCorrect); + ichunkaccess.setLightCorrect(this.lightCorrect); EnumSet enumset = EnumSet.noneOf(HeightMap.Type.class); - Iterator iterator1 = ((IChunkAccess) object).getPersistedStatus().heightmapsAfter().iterator(); -@@ -348,6 +356,12 @@ + +@@ -295,6 +307,12 @@ return DataPaletteBlock.codecRO(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getOrThrow(Biomes.PLAINS)); } @@ -94,7 +92,7 @@ public static SerializableChunkData copyOf(WorldServer worldserver, IChunkAccess ichunkaccess) { if (!ichunkaccess.canBeSerialized()) { throw new IllegalArgumentException("Chunk can't be serialized: " + String.valueOf(ichunkaccess)); -@@ -419,7 +433,14 @@ +@@ -361,7 +379,14 @@ }); NBTTagCompound nbttagcompound1 = packStructureData(StructurePieceSerializationContext.fromLevel(worldserver), chunkcoordintpair, ichunkaccess.getAllStarts(), ichunkaccess.getAllReferences()); @@ -110,16 +108,7 @@ } } -@@ -432,7 +453,7 @@ - nbttagcompound.putLong("LastUpdate", this.lastUpdateTime); - nbttagcompound.putLong("InhabitedTime", this.inhabitedTime); - nbttagcompound.putString("Status", BuiltInRegistries.CHUNK_STATUS.getKey(this.chunkStatus).toString()); -- DataResult dataresult; -+ DataResult dataresult; // CraftBukkit - decompile error - Logger logger; - - if (this.blendingData != null) { -@@ -513,6 +534,11 @@ +@@ -434,6 +459,11 @@ }); nbttagcompound.put("Heightmaps", nbttagcompound2); nbttagcompound.put("structures", this.structureData); @@ -131,12 +120,12 @@ return nbttagcompound; } -@@ -623,6 +649,12 @@ - StructureStart structurestart = StructureStart.loadStaticStart(structurepieceserializationcontext, nbttagcompound1.getCompound(s), i); +@@ -512,6 +542,12 @@ + StructureStart structurestart = StructureStart.loadStaticStart(structurepieceserializationcontext, nbttagcompound1.getCompoundOrEmpty(s), i); if (structurestart != null) { + // CraftBukkit start - load persistent data for structure start -+ net.minecraft.nbt.NBTBase persistentBase = nbttagcompound1.getCompound(s).get("StructureBukkitValues"); ++ net.minecraft.nbt.NBTBase persistentBase = nbttagcompound1.getCompoundOrEmpty(s).get("StructureBukkitValues"); + if (persistentBase instanceof NBTTagCompound) { + structurestart.persistentDataContainer.putAll((NBTTagCompound) persistentBase); + } diff --git a/nms-patches/net/minecraft/world/level/dimension/end/EnderDragonBattle.patch b/nms-patches/net/minecraft/world/level/dimension/end/EnderDragonBattle.patch index ad62a4bf2..3b9e34f7a 100644 --- a/nms-patches/net/minecraft/world/level/dimension/end/EnderDragonBattle.patch +++ b/nms-patches/net/minecraft/world/level/dimension/end/EnderDragonBattle.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/dimension/end/EnderDragonBattle.java +++ b/net/minecraft/world/level/dimension/end/EnderDragonBattle.java -@@ -111,14 +111,14 @@ +@@ -109,14 +109,14 @@ this.origin = blockposition; this.validPlayer = IEntitySelector.ENTITY_STILL_ALIVE.and(IEntitySelector.withinDistance((double) blockposition.getX(), (double) (128 + blockposition.getY()), (double) blockposition.getZ(), 192.0D)); this.needsStateScanning = enderdragonbattle_a.needsStateScanning; @@ -17,7 +17,7 @@ this.gateways.addAll((Collection) enderdragonbattle_a.gateways.orElseGet(() -> { ObjectArrayList objectarraylist = new ObjectArrayList(ContiguousSet.create(Range.closedOpen(0, 20), DiscreteDomain.integers())); -@@ -208,7 +208,7 @@ +@@ -206,7 +206,7 @@ this.dragonKilled = false; if (!flag) { EnderDragonBattle.LOGGER.info("But we didn't have a portal, let's remove it."); @@ -26,7 +26,7 @@ this.dragonUUID = null; } } -@@ -513,7 +513,7 @@ +@@ -484,7 +484,7 @@ return this.previouslyKilled; } @@ -35,8 +35,8 @@ if (this.dragonKilled && this.respawnStage == null) { BlockPosition blockposition = this.portalLocation; -@@ -540,19 +540,19 @@ - List list1 = this.level.getEntitiesOfClass(EntityEnderCrystal.class, new AxisAlignedBB(blockposition1.relative(enumdirection, 2))); +@@ -509,19 +509,19 @@ + List list1 = this.level.getEntitiesOfClass(EntityEnderCrystal.class, new AxisAlignedBB(blockposition1.relative(enumdirection, 2))); if (list1.isEmpty()) { - return; @@ -59,7 +59,7 @@ if (this.dragonKilled && this.respawnStage == null) { for (ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = this.findExitPortal(); shapedetector_shapedetectorcollection != null; shapedetector_shapedetectorcollection = this.findExitPortal()) { for (int i = 0; i < this.exitPortalPattern.getWidth(); ++i) { -@@ -572,8 +572,9 @@ +@@ -541,8 +541,9 @@ this.respawnTime = 0; this.spawnExitPortal(false); this.respawnCrystals = list; diff --git a/nms-patches/net/minecraft/world/level/dimension/end/EnumDragonRespawn.patch b/nms-patches/net/minecraft/world/level/dimension/end/EnumDragonRespawn.patch index 7ffc939cd..3a40b978b 100644 --- a/nms-patches/net/minecraft/world/level/dimension/end/EnumDragonRespawn.patch +++ b/nms-patches/net/minecraft/world/level/dimension/end/EnumDragonRespawn.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/dimension/end/EnumDragonRespawn.java +++ b/net/minecraft/world/level/dimension/end/EnumDragonRespawn.java -@@ -13,6 +13,10 @@ +@@ -12,6 +12,10 @@ import net.minecraft.world.level.levelgen.feature.WorldGenerator; import net.minecraft.world.level.levelgen.feature.configurations.WorldGenFeatureEndSpikeConfiguration; @@ -11,7 +11,7 @@ public enum EnumDragonRespawn { START { -@@ -27,7 +31,7 @@ +@@ -23,7 +27,7 @@ entityendercrystal.setBeamTarget(blockposition1); } @@ -20,7 +20,7 @@ } }, PREPARING_TO_SUMMON_PILLARS { -@@ -38,7 +42,7 @@ +@@ -34,7 +38,7 @@ worldserver.levelEvent(3001, new BlockPosition(0, 128, 0), 0); } } else { @@ -29,26 +29,24 @@ } } -@@ -81,7 +85,7 @@ +@@ -70,7 +74,7 @@ WorldGenerator.END_SPIKE.place(worldgenfeatureendspikeconfiguration, worldserver, worldserver.getChunkSource().getGenerator(), RandomSource.create(), new BlockPosition(worldgenender_spike.getCenterX(), 45, worldgenender_spike.getCenterZ())); } - } else if (flag1) { + } else if (flag) { - enderdragonbattle.setRespawnStage(null.SUMMONING_DRAGON); + enderdragonbattle.setRespawnStage(SUMMONING_DRAGON); // CraftBukkit - decompile error } } -@@ -94,7 +98,7 @@ - EntityEnderCrystal entityendercrystal; - +@@ -80,13 +84,13 @@ + @Override + public void tick(WorldServer worldserver, EnderDragonBattle enderdragonbattle, List list, int i, BlockPosition blockposition) { if (i >= 100) { - enderdragonbattle.setRespawnStage(null.END); + enderdragonbattle.setRespawnStage(END); // CraftBukkit - decompile error enderdragonbattle.resetSpikeCrystals(); - iterator = list.iterator(); -@@ -102,7 +106,7 @@ - entityendercrystal = (EntityEnderCrystal) iterator.next(); + for (EntityEnderCrystal entityendercrystal : list) { entityendercrystal.setBeamTarget((BlockPosition) null); worldserver.explode(entityendercrystal, entityendercrystal.getX(), entityendercrystal.getY(), entityendercrystal.getZ(), 6.0F, World.a.NONE); - entityendercrystal.discard(); diff --git a/nms-patches/net/minecraft/world/level/entity/EntityAccess.patch b/nms-patches/net/minecraft/world/level/entity/EntityAccess.patch index 55f2fd8d6..289066608 100644 --- a/nms-patches/net/minecraft/world/level/entity/EntityAccess.patch +++ b/nms-patches/net/minecraft/world/level/entity/EntityAccess.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/entity/EntityAccess.java +++ b/net/minecraft/world/level/entity/EntityAccess.java -@@ -6,6 +6,10 @@ +@@ -5,6 +5,10 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.phys.AxisAlignedBB; @@ -8,10 +8,10 @@ +import org.bukkit.event.entity.EntityRemoveEvent; +// CraftBukkit end + - public interface EntityAccess { + public interface EntityAccess extends UniquelyIdentifyable { int getId(); -@@ -24,6 +28,12 @@ +@@ -21,6 +25,12 @@ void setRemoved(Entity.RemovalReason entity_removalreason); diff --git a/nms-patches/net/minecraft/world/level/entity/PersistentEntitySectionManager.patch b/nms-patches/net/minecraft/world/level/entity/PersistentEntitySectionManager.patch index b92034629..98c7a2086 100644 --- a/nms-patches/net/minecraft/world/level/entity/PersistentEntitySectionManager.patch +++ b/nms-patches/net/minecraft/world/level/entity/PersistentEntitySectionManager.patch @@ -14,7 +14,7 @@ static final Logger LOGGER = LogUtils.getLogger(); @@ -55,6 +61,16 @@ - this.entityGetter = new LevelEntityGetterAdapter<>(this.visibleEntityStorage, this.sectionStorage); + this.entityGetter = new LevelEntityGetterAdapter(this.visibleEntityStorage, this.sectionStorage); } + // CraftBukkit start - add method to get all entities in chunk @@ -30,7 +30,7 @@ void removeSectionIfEmpty(long i, EntitySection entitysection) { if (entitysection.isEmpty()) { this.sectionStorage.remove(i); -@@ -196,6 +212,12 @@ +@@ -200,6 +216,12 @@ } private boolean storeChunkSections(long i, Consumer consumer) { @@ -43,23 +43,23 @@ PersistentEntitySectionManager.b persistententitysectionmanager_b = (PersistentEntitySectionManager.b) this.chunkLoadStatuses.get(i); if (persistententitysectionmanager_b == PersistentEntitySectionManager.b.PENDING) { -@@ -207,6 +229,7 @@ +@@ -211,6 +233,7 @@ if (list.isEmpty()) { if (persistententitysectionmanager_b == PersistentEntitySectionManager.b.LOADED) { + if (callEvent) CraftEventFactory.callEntitiesUnloadEvent(((EntityStorage) permanentStorage).level, new ChunkCoordIntPair(i), ImmutableList.of()); // CraftBukkit - this.permanentStorage.storeEntities(new ChunkEntities<>(new ChunkCoordIntPair(i), ImmutableList.of())); + this.permanentStorage.storeEntities(new ChunkEntities(new ChunkCoordIntPair(i), ImmutableList.of())); } -@@ -215,6 +238,7 @@ +@@ -219,6 +242,7 @@ this.requestChunkLoad(i); return false; } else { + if (callEvent) CraftEventFactory.callEntitiesUnloadEvent(((EntityStorage) permanentStorage).level, new ChunkCoordIntPair(i), list.stream().map(entity -> (Entity) entity).collect(Collectors.toList())); // CraftBukkit - this.permanentStorage.storeEntities(new ChunkEntities<>(new ChunkCoordIntPair(i), list)); + this.permanentStorage.storeEntities(new ChunkEntities(new ChunkCoordIntPair(i), list)); list.forEach(consumer); return true; -@@ -238,7 +262,7 @@ +@@ -242,7 +266,7 @@ private boolean processChunkUnload(long i) { boolean flag = this.storeChunkSections(i, (entityaccess) -> { entityaccess.getPassengersAndSelf().forEach(this::unloadEntity); @@ -68,7 +68,7 @@ if (!flag) { return false; -@@ -249,24 +273,28 @@ +@@ -253,12 +277,12 @@ } private void unloadEntity(EntityAccess entityaccess) { @@ -83,13 +83,7 @@ return this.chunkVisibility.get(i) != Visibility.HIDDEN ? true : this.processChunkUnload(i); }); } - - private void processPendingLoads() { -- ChunkEntities chunkentities; -+ ChunkEntities chunkentities; // CraftBukkit - decompile error - - while ((chunkentities = (ChunkEntities) this.loadingInbox.poll()) != null) { - chunkentities.getEntities().forEach((entityaccess) -> { +@@ -271,6 +295,10 @@ this.addEntity(entityaccess, true); }); this.chunkLoadStatuses.put(chunkentities.getPos().toLong(), PersistentEntitySectionManager.b.LOADED); @@ -100,7 +94,7 @@ } } -@@ -292,7 +320,7 @@ +@@ -296,7 +324,7 @@ } public void autoSave() { @@ -109,7 +103,7 @@ boolean flag = this.chunkVisibility.get(i) == Visibility.HIDDEN; if (flag) { -@@ -311,7 +339,7 @@ +@@ -315,7 +343,7 @@ while (!longset.isEmpty()) { this.permanentStorage.flush(false); this.processPendingLoads(); @@ -118,7 +112,7 @@ boolean flag = this.chunkVisibility.get(i) == Visibility.HIDDEN; return flag ? this.processChunkUnload(i) : this.storeChunkSections(i, (entityaccess) -> { -@@ -323,7 +351,15 @@ +@@ -327,7 +355,15 @@ } public void close() throws IOException { @@ -135,7 +129,7 @@ this.permanentStorage.close(); } -@@ -350,7 +386,7 @@ +@@ -354,7 +390,7 @@ public void dumpSections(Writer writer) throws IOException { CSVWriter csvwriter = CSVWriter.builder().addColumn("x").addColumn("y").addColumn("z").addColumn("visibility").addColumn("load_status").addColumn("entity_count").build(writer); @@ -144,7 +138,7 @@ PersistentEntitySectionManager.b persistententitysectionmanager_b = (PersistentEntitySectionManager.b) this.chunkLoadStatuses.get(i); this.sectionStorage.getExistingSectionPositionsInChunk(i).forEach((j) -> { -@@ -394,7 +430,7 @@ +@@ -398,7 +434,7 @@ private EntitySection currentSection; a(final EntityAccess entityaccess, final long i, final EntitySection entitysection) { diff --git a/nms-patches/net/minecraft/world/level/gameevent/GameEventDispatcher.patch b/nms-patches/net/minecraft/world/level/gameevent/GameEventDispatcher.patch index d3e07b318..aa5fd1000 100644 --- a/nms-patches/net/minecraft/world/level/gameevent/GameEventDispatcher.patch +++ b/nms-patches/net/minecraft/world/level/gameevent/GameEventDispatcher.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/gameevent/GameEventDispatcher.java +++ b/net/minecraft/world/level/gameevent/GameEventDispatcher.java -@@ -12,6 +12,13 @@ - import net.minecraft.world.level.chunk.Chunk; +@@ -11,6 +11,13 @@ + import net.minecraft.world.level.chunk.IChunkAccess; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start @@ -14,7 +14,7 @@ public class GameEventDispatcher { private final WorldServer level; -@@ -23,6 +30,14 @@ +@@ -22,6 +29,14 @@ public void post(Holder holder, Vec3D vec3d, GameEvent.a gameevent_a) { int i = ((GameEvent) holder.value()).notificationRadius(); BlockPosition blockposition = BlockPosition.containing(vec3d); diff --git a/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.patch b/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.patch index 0b7640d2c..a809ed149 100644 --- a/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.patch +++ b/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.patch @@ -13,21 +13,19 @@ public interface VibrationSystem { List> RESONANCE_EVENTS = List.of(GameEvent.RESONATE_1.key(), GameEvent.RESONATE_2.key(), GameEvent.RESONATE_3.key(), GameEvent.RESONATE_4.key(), GameEvent.RESONATE_5.key(), GameEvent.RESONATE_6.key(), GameEvent.RESONATE_7.key(), GameEvent.RESONATE_8.key(), GameEvent.RESONATE_9.key(), GameEvent.RESONATE_10.key(), GameEvent.RESONATE_11.key(), GameEvent.RESONATE_12.key(), GameEvent.RESONATE_13.key(), GameEvent.RESONATE_14.key(), GameEvent.RESONATE_15.key()); -@@ -233,7 +239,8 @@ - if (vibrationsystem_d.requiresAdjacentChunksToBeTicking() && !areAdjacentChunksTicking(worldserver, blockposition1)) { - return false; - } else { -- vibrationsystem_d.onReceiveVibration(worldserver, blockposition, vibrationinfo.gameEvent(), (Entity) vibrationinfo.getEntity(worldserver).orElse((Object) null), (Entity) vibrationinfo.getProjectileOwner(worldserver).orElse((Object) null), VibrationSystem.b.distanceBetweenInBlocks(blockposition, blockposition1)); -+ // CraftBukkit - decompile error -+ vibrationsystem_d.onReceiveVibration(worldserver, blockposition, vibrationinfo.gameEvent(), (Entity) vibrationinfo.getEntity(worldserver).orElse(null), (Entity) vibrationinfo.getProjectileOwner(worldserver).orElse(null), VibrationSystem.b.distanceBetweenInBlocks(blockposition, blockposition1)); - vibrationsystem_a.setCurrentVibration((VibrationInfo) null); - return true; - } -@@ -288,8 +295,14 @@ - return false; +@@ -112,7 +118,7 @@ + return instance.group(VibrationInfo.CODEC.lenientOptionalFieldOf("event").forGetter((vibrationsystem_a) -> { + return Optional.ofNullable(vibrationsystem_a.currentVibration); + }), VibrationSelector.CODEC.fieldOf("selector").forGetter(VibrationSystem.a::getSelectionStrategy), ExtraCodecs.NON_NEGATIVE_INT.fieldOf("event_delay").orElse(0).forGetter(VibrationSystem.a::getTravelTimeInTicks)).apply(instance, (optional, vibrationselector, integer) -> { +- return new VibrationSystem.a((VibrationInfo) optional.orElse((Object) null), vibrationselector, integer, true); ++ return new VibrationSystem.a((VibrationInfo) optional.orElse(null), vibrationselector, integer, true); // CraftBukkit- decompile error + }); + }); + public static final String NBT_TAG_KEY = "listener"; +@@ -202,7 +208,14 @@ } else { Vec3D vec3d1 = (Vec3D) optional.get(); -- + - if (!vibrationsystem_d.canReceiveVibration(worldserver, BlockPosition.containing(vec3d), holder, gameevent_a)) { + // CraftBukkit start + boolean defaultCancel = !vibrationsystem_d.canReceiveVibration(worldserver, BlockPosition.containing(vec3d), holder, gameevent_a); @@ -40,12 +38,13 @@ return false; } else if (isOccluded(worldserver, vec3d, vec3d1)) { return false; -@@ -342,7 +355,7 @@ - return instance.group(VibrationInfo.CODEC.lenientOptionalFieldOf("event").forGetter((vibrationsystem_a) -> { - return Optional.ofNullable(vibrationsystem_a.currentVibration); - }), VibrationSelector.CODEC.fieldOf("selector").forGetter(VibrationSystem.a::getSelectionStrategy), ExtraCodecs.NON_NEGATIVE_INT.fieldOf("event_delay").orElse(0).forGetter(VibrationSystem.a::getTravelTimeInTicks)).apply(instance, (optional, vibrationselector, integer) -> { -- return new VibrationSystem.a((VibrationInfo) optional.orElse((Object) null), vibrationselector, integer, true); -+ return new VibrationSystem.a((VibrationInfo) optional.orElse(null), vibrationselector, integer, true); // CraftBukkit - decompile error - }); - }); - public static final String NBT_TAG_KEY = "listener"; +@@ -314,7 +327,8 @@ + if (vibrationsystem_d.requiresAdjacentChunksToBeTicking() && !areAdjacentChunksTicking(worldserver, blockposition1)) { + return false; + } else { +- vibrationsystem_d.onReceiveVibration(worldserver, blockposition, vibrationinfo.gameEvent(), (Entity) vibrationinfo.getEntity(worldserver).orElse((Object) null), (Entity) vibrationinfo.getProjectileOwner(worldserver).orElse((Object) null), VibrationSystem.b.distanceBetweenInBlocks(blockposition, blockposition1)); ++ // CraftBukkit - decompile error ++ vibrationsystem_d.onReceiveVibration(worldserver, blockposition, vibrationinfo.gameEvent(), (Entity) vibrationinfo.getEntity(worldserver).orElse(null), (Entity) vibrationinfo.getProjectileOwner(worldserver).orElse(null), VibrationSystem.b.distanceBetweenInBlocks(blockposition, blockposition1)); + vibrationsystem_a.setCurrentVibration((VibrationInfo) null); + return true; + } diff --git a/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch b/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch index c2787a531..a3884945a 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/MobSpawnerPatrol.java +++ b/net/minecraft/world/level/levelgen/MobSpawnerPatrol.java -@@ -116,7 +116,7 @@ +@@ -97,7 +97,7 @@ entitymonsterpatrolling.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); entitymonsterpatrolling.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(blockposition), EntitySpawnReason.PATROL, (GroupDataEntity) null); diff --git a/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPhantom.patch b/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPhantom.patch index 35c075ea1..52d62f758 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPhantom.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPhantom.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/levelgen/MobSpawnerPhantom.java +++ b/net/minecraft/world/level/levelgen/MobSpawnerPhantom.java -@@ -74,7 +74,7 @@ - if (entityphantom != null) { - entityphantom.moveTo(blockposition1, 0.0F, 0.0F); - groupdataentity = entityphantom.finalizeSpawn(worldserver, difficultydamagescaler, EntitySpawnReason.NATURAL, groupdataentity); -- worldserver.addFreshEntityWithPassengers(entityphantom); -+ worldserver.addFreshEntityWithPassengers(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit - ++i; +@@ -61,7 +61,7 @@ + if (entityphantom != null) { + entityphantom.snapTo(blockposition1, 0.0F, 0.0F); + groupdataentity = entityphantom.finalizeSpawn(worldserver, difficultydamagescaler, EntitySpawnReason.NATURAL, groupdataentity); +- worldserver.addFreshEntityWithPassengers(entityphantom); ++ worldserver.addFreshEntityWithPassengers(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit + } } } diff --git a/nms-patches/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.patch b/nms-patches/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.patch index f8a04e34b..3868f3989 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.patch @@ -28,19 +28,19 @@ for (int i = -2; i <= 2; ++i) { @@ -29,16 +42,36 @@ - BlockPosition.MutableBlockPosition blockposition_mutableblockposition1 = blockposition_mutableblockposition.set(blockposition).move(j, k, i); + BlockPosition blockposition1 = blockposition_mutableblockposition.set(blockposition).move(j, k, i); Block block = k == -1 ? Blocks.OBSIDIAN : Blocks.AIR; -- if (!worldaccess.getBlockState(blockposition_mutableblockposition1).is(block)) { +- if (!worldaccess.getBlockState(blockposition1).is(block)) { + // CraftBukkit start -+ if (!blockList.getBlockState(blockposition_mutableblockposition1).is(block)) { ++ if (!blockList.getBlockState(blockposition1).is(block)) { if (flag) { -- worldaccess.destroyBlock(blockposition_mutableblockposition1, true, (Entity) null); -+ blockList.destroyBlock(blockposition_mutableblockposition1, true, (Entity) null); +- worldaccess.destroyBlock(blockposition1, true, (Entity) null); ++ blockList.destroyBlock(blockposition1, true, (Entity) null); } -- worldaccess.setBlock(blockposition_mutableblockposition1, block.defaultBlockState(), 3); -+ blockList.setBlock(blockposition_mutableblockposition1, block.defaultBlockState(), 3); +- worldaccess.setBlock(blockposition1, block.defaultBlockState(), 3); ++ blockList.setBlock(blockposition1, block.defaultBlockState(), 3); + // CraftBukkit end } } diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch index a8d3bc86d..fe55fa6fc 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.java +++ b/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.java -@@ -21,6 +21,10 @@ +@@ -23,6 +23,10 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.storage.WorldPersistentData; @@ -11,7 +11,16 @@ public class PersistentStructureLegacy { private static final Map CURRENT_TO_LEGACY_MAP = (Map) SystemUtils.make(Maps.newHashMap(), (hashmap) -> { -@@ -233,16 +237,16 @@ +@@ -179,7 +183,7 @@ + Optional optional = nbttaglist.getCompound(0).flatMap((nbttagcompound2) -> { + return nbttagcompound2.getString("id"); + }); +- Map map = PersistentStructureLegacy.LEGACY_TO_CURRENT_MAP; ++ Map map = PersistentStructureLegacy.LEGACY_TO_CURRENT_MAP; // CraftBukkit - decompile error + + Objects.requireNonNull(map); + optional.map(map::get).ifPresent((s2) -> { +@@ -215,14 +219,14 @@ } } @@ -20,15 +29,13 @@ + public static PersistentStructureLegacy getLegacyStructureHandler(ResourceKey resourcekey, @Nullable WorldPersistentData worldpersistentdata) { // CraftBukkit + if (resourcekey == WorldDimension.OVERWORLD) { // CraftBukkit return new PersistentStructureLegacy(worldpersistentdata, ImmutableList.of("Monument", "Stronghold", "Village", "Mineshaft", "Temple", "Mansion"), ImmutableList.of("Village", "Mineshaft", "Mansion", "Igloo", "Desert_Pyramid", "Jungle_Pyramid", "Swamp_Hut", "Stronghold", "Monument")); - } else { - ImmutableList immutablelist; +- } else if (resourcekey == World.NETHER) { ++ } else if (resourcekey == WorldDimension.NETHER) { // CraftBukkit + List list = ImmutableList.of("Fortress"); -- if (resourcekey == World.NETHER) { -+ if (resourcekey == WorldDimension.NETHER) { // CraftBukkit - immutablelist = ImmutableList.of("Fortress"); - return new PersistentStructureLegacy(worldpersistentdata, immutablelist, immutablelist); -- } else if (resourcekey == World.END) { -+ } else if (resourcekey == WorldDimension.END) { // CraftBukkit - immutablelist = ImmutableList.of("EndCity"); - return new PersistentStructureLegacy(worldpersistentdata, immutablelist, immutablelist); - } else { + return new PersistentStructureLegacy(worldpersistentdata, list, list); +- } else if (resourcekey == World.END) { ++ } else if (resourcekey == WorldDimension.END) { // CraftBukkit + List list1 = ImmutableList.of("EndCity"); + + return new PersistentStructureLegacy(worldpersistentdata, list1, list1); diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/StructurePiece.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/StructurePiece.patch index e9a124002..55f60fa06 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/StructurePiece.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/StructurePiece.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/StructurePiece.java +++ b/net/minecraft/world/level/levelgen/structure/StructurePiece.java -@@ -51,7 +51,7 @@ +@@ -45,7 +45,7 @@ private EnumBlockRotation rotation; protected int genDepth; private final WorldGenFeatureStructurePieceType type; @@ -9,37 +9,19 @@ protected StructurePiece(WorldGenFeatureStructurePieceType worldgenfeaturestructurepiecetype, int i, StructureBoundingBox structureboundingbox) { this.type = worldgenfeaturestructurepiecetype; -@@ -80,13 +80,11 @@ - NBTTagCompound nbttagcompound = new NBTTagCompound(); - - nbttagcompound.putString("id", BuiltInRegistries.STRUCTURE_PIECE.getKey(this.getType()).toString()); -- DataResult dataresult = StructureBoundingBox.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.boundingBox); -- Logger logger = StructurePiece.LOGGER; -- -- Objects.requireNonNull(logger); -- dataresult.resultOrPartial(logger::error).ifPresent((nbtbase) -> { -- nbttagcompound.put("BB", nbtbase); -+ // CraftBukkit start - decompile error -+ StructureBoundingBox.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.boundingBox).resultOrPartial(Objects.requireNonNull(StructurePiece.LOGGER)::error).ifPresent((nbtbase) -> { -+ nbttagcompound.put("BB", nbtbase); - }); -+ // CraftBukkit end - EnumDirection enumdirection = this.getOrientation(); - - nbttagcompound.putInt("O", enumdirection == null ? -1 : enumdirection.get2DDataValue()); -@@ -186,6 +184,11 @@ +@@ -172,6 +172,11 @@ } - generatoraccessseed.setBlock(blockposition_mutableblockposition, iblockdata, 2); + generatoraccessseed.setBlock(blockposition, iblockdata, 2); + // CraftBukkit start - fluid handling is already done if we have a transformer generator access + if (generatoraccessseed instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess) { + return; + } + // CraftBukkit end - Fluid fluid = generatoraccessseed.getFluidState(blockposition_mutableblockposition); + Fluid fluid = generatoraccessseed.getFluidState(blockposition); if (!fluid.isEmpty()) { -@@ -200,6 +203,38 @@ +@@ -186,6 +191,38 @@ } } @@ -78,7 +60,7 @@ protected boolean canBeReplaced(IWorldReader iworldreader, int i, int j, int k, StructureBoundingBox structureboundingbox) { return true; } -@@ -393,12 +428,20 @@ +@@ -377,12 +414,20 @@ iblockdata = reorient(worldaccess, blockposition, Blocks.CHEST.defaultBlockState()); } @@ -99,14 +81,14 @@ return true; } else { -@@ -410,12 +453,31 @@ - BlockPosition.MutableBlockPosition blockposition_mutableblockposition = this.getWorldPos(i, j, k); +@@ -394,12 +439,31 @@ + BlockPosition blockposition = this.getWorldPos(i, j, k); - if (structureboundingbox.isInside(blockposition_mutableblockposition) && !generatoraccessseed.getBlockState(blockposition_mutableblockposition).is(Blocks.DISPENSER)) { + if (structureboundingbox.isInside(blockposition) && !generatoraccessseed.getBlockState(blockposition).is(Blocks.DISPENSER)) { + // CraftBukkit start + /* this.placeBlock(generatoraccessseed, (IBlockData) Blocks.DISPENSER.defaultBlockState().setValue(BlockDispenser.FACING, enumdirection), i, j, k, structureboundingbox); - TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition_mutableblockposition); + TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition); if (tileentity instanceof TileEntityDispenser) { ((TileEntityDispenser) tileentity).setLootTable(resourcekey, randomsource.nextLong()); @@ -123,15 +105,15 @@ + iblockdata = iblockdata.rotate(this.rotation); + } + -+ org.bukkit.craftbukkit.block.CraftDispenser dispenserState = (org.bukkit.craftbukkit.block.CraftDispenser) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(generatoraccessseed, blockposition_mutableblockposition, iblockdata, null); ++ org.bukkit.craftbukkit.block.CraftDispenser dispenserState = (org.bukkit.craftbukkit.block.CraftDispenser) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(generatoraccessseed, blockposition, iblockdata, null); + dispenserState.setLootTable(org.bukkit.craftbukkit.CraftLootTable.minecraftToBukkit(resourcekey)); + dispenserState.setSeed(randomsource.nextLong()); -+ placeCraftBlockEntity(generatoraccessseed, blockposition_mutableblockposition, dispenserState, 2); ++ placeCraftBlockEntity(generatoraccessseed, blockposition, dispenserState, 2); + // CraftBukkit end return true; } else { -@@ -428,7 +490,7 @@ +@@ -412,7 +476,7 @@ } public static StructureBoundingBox createBoundingBox(Stream stream) { diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/StructureStart.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/StructureStart.patch index cf6f6199a..b15007ca1 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/StructureStart.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/StructureStart.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/StructureStart.java +++ b/net/minecraft/world/level/levelgen/structure/StructureStart.java -@@ -32,6 +32,12 @@ +@@ -31,6 +31,12 @@ @Nullable private volatile StructureBoundingBox cachedBoundingBox; @@ -13,16 +13,14 @@ public StructureStart(Structure structure, ChunkCoordIntPair chunkcoordintpair, int i, PiecesContainer piecescontainer) { this.structure = structure; this.chunkPos = chunkcoordintpair; -@@ -91,6 +97,8 @@ - StructureBoundingBox structureboundingbox1 = ((StructurePiece) list.get(0)).boundingBox; +@@ -91,11 +97,25 @@ BlockPosition blockposition = structureboundingbox1.getCenter(); BlockPosition blockposition1 = new BlockPosition(blockposition.getX(), structureboundingbox1.minY(), blockposition.getZ()); + + // CraftBukkit start + /* - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { -@@ -100,6 +108,18 @@ + for (StructurePiece structurepiece : list) { + if (structurepiece.getBoundingBox().intersects(structureboundingbox)) { structurepiece.postProcess(generatoraccessseed, structuremanager, chunkgenerator, randomsource, structureboundingbox, chunkcoordintpair, blockposition1); } } @@ -41,7 +39,7 @@ this.structure.afterPlace(generatoraccessseed, structuremanager, chunkgenerator, randomsource, structureboundingbox, chunkcoordintpair, this.pieceContainer); } -@@ -107,6 +127,11 @@ +@@ -103,6 +123,11 @@ public NBTTagCompound createTag(StructurePieceSerializationContext structurepieceserializationcontext, ChunkCoordIntPair chunkcoordintpair) { NBTTagCompound nbttagcompound = new NBTTagCompound(); diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.patch index 8da3c9070..9a37cd7ab 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java +++ b/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java -@@ -68,6 +68,15 @@ +@@ -64,6 +64,15 @@ private static void placeSuspiciousSand(StructureBoundingBox structureboundingbox, GeneratorAccessSeed generatoraccessseed, BlockPosition blockposition) { if (structureboundingbox.isInside(blockposition)) { diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.patch index 9aea52419..b99c51b19 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.java -@@ -285,7 +285,12 @@ +@@ -274,7 +274,12 @@ BlockPosition blockposition1 = blockposition.below(); if (structureboundingbox.isInside(blockposition1)) { diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.patch index 086c189cf..dd64cabd2 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java -@@ -44,6 +44,10 @@ +@@ -38,6 +38,10 @@ + import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.LootTables; - import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.nbt.NBTBase; @@ -10,46 +10,23 @@ + public class MineshaftPieces { - static final Logger LOGGER = LogUtils.getLogger(); -@@ -520,6 +524,8 @@ + private static final int DEFAULT_SHAFT_WIDTH = 3; +@@ -517,6 +521,8 @@ - if (structureboundingbox.isInside(blockposition_mutableblockposition) && this.isInterior(generatoraccessseed, 1, 0, l, structureboundingbox)) { + if (structureboundingbox.isInside(blockposition1) && this.isInterior(generatoraccessseed, 1, 0, i2, structureboundingbox)) { this.hasPlacedSpider = true; + // CraftBukkit start + /* - generatoraccessseed.setBlock(blockposition_mutableblockposition, Blocks.SPAWNER.defaultBlockState(), 2); - TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition_mutableblockposition); + generatoraccessseed.setBlock(blockposition1, Blocks.SPAWNER.defaultBlockState(), 2); + TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition1); -@@ -528,6 +534,9 @@ +@@ -525,6 +531,9 @@ tileentitymobspawner.setEntityId(EntityTypes.CAVE_SPIDER, randomsource); } + */ -+ placeCraftSpawner(generatoraccessseed, blockposition_mutableblockposition, org.bukkit.entity.EntityType.CAVE_SPIDER, 2); ++ placeCraftSpawner(generatoraccessseed, blockposition1, org.bukkit.entity.EntityType.CAVE_SPIDER, 2); + // CraftBukkit end } } } -@@ -819,11 +828,11 @@ - - public d(NBTTagCompound nbttagcompound) { - super(WorldGenFeatureStructurePieceType.MINE_SHAFT_ROOM, nbttagcompound); -- DataResult dataresult = StructureBoundingBox.CODEC.listOf().parse(DynamicOpsNBT.INSTANCE, nbttagcompound.getList("Entrances", 11)); -+ DataResult> dataresult = StructureBoundingBox.CODEC.listOf().parse(DynamicOpsNBT.INSTANCE, nbttagcompound.getList("Entrances", 11)); // CraftBukkit - decompile error - Logger logger = MineshaftPieces.LOGGER; - - Objects.requireNonNull(logger); -- Optional optional = dataresult.resultOrPartial(logger::error); -+ Optional> optional = dataresult.resultOrPartial(logger::error); // CraftBukkit - decompile error - List list = this.childEntranceBoxes; - - Objects.requireNonNull(this.childEntranceBoxes); -@@ -929,7 +938,7 @@ - @Override - protected void addAdditionalSaveData(StructurePieceSerializationContext structurepieceserializationcontext, NBTTagCompound nbttagcompound) { - super.addAdditionalSaveData(structurepieceserializationcontext, nbttagcompound); -- DataResult dataresult = StructureBoundingBox.CODEC.listOf().encodeStart(DynamicOpsNBT.INSTANCE, this.childEntranceBoxes); -+ DataResult dataresult = StructureBoundingBox.CODEC.listOf().encodeStart(DynamicOpsNBT.INSTANCE, this.childEntranceBoxes); // CraftBukkit - decompile error - Logger logger = MineshaftPieces.LOGGER; - - Objects.requireNonNull(logger); diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.patch index ab12d63ae..9f7e25abb 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java -@@ -428,6 +428,8 @@ +@@ -667,6 +667,8 @@ - if (structureboundingbox.isInside(blockposition_mutableblockposition)) { + if (structureboundingbox.isInside(blockposition1)) { this.hasPlacedSpawner = true; + // CraftBukkit start + /* - generatoraccessseed.setBlock(blockposition_mutableblockposition, Blocks.SPAWNER.defaultBlockState(), 2); - TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition_mutableblockposition); + generatoraccessseed.setBlock(blockposition1, Blocks.SPAWNER.defaultBlockState(), 2); + TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition1); -@@ -436,6 +438,9 @@ +@@ -675,6 +677,9 @@ tileentitymobspawner.setEntityId(EntityTypes.BLAZE, randomsource); } + */ -+ placeCraftSpawner(generatoraccessseed, blockposition_mutableblockposition, org.bukkit.entity.EntityType.BLAZE, 2); ++ placeCraftSpawner(generatoraccessseed, blockposition1, org.bukkit.entity.EntityType.BLAZE, 2); + // CraftBukkit end } } diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.patch index bfb61781f..d0d7dd8a4 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java -@@ -200,12 +200,20 @@ +@@ -199,12 +199,20 @@ @Override protected void handleDataMarker(String s, BlockPosition blockposition, WorldAccess worldaccess, RandomSource randomsource, StructureBoundingBox structureboundingbox) { if ("chest".equals(s)) { @@ -19,5 +19,5 @@ + placeCraftBlockEntity(worldaccess, blockposition, craftChest, 2); + // CraftBukkit end } else if ("drowned".equals(s)) { - EntityDrowned entitydrowned = (EntityDrowned) EntityTypes.DROWNED.create(worldaccess.getLevel(), EntitySpawnReason.STRUCTURE); + EntityDrowned entitydrowned = EntityTypes.DROWNED.create(worldaccess.getLevel(), EntitySpawnReason.STRUCTURE); diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/ShipwreckPieces.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/ShipwreckPieces.patch index 259fce4db..7da851a48 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/ShipwreckPieces.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/ShipwreckPieces.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 -@@ -79,7 +79,12 @@ +@@ -78,7 +78,12 @@ ResourceKey resourcekey = (ResourceKey) ShipwreckPieces.MARKERS_TO_LOOT.get(s); if (resourcekey != null) { diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.patch index b1409167e..d7a1efd59 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.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 -@@ -53,7 +53,7 @@ +@@ -54,7 +54,7 @@ public boolean doPlace(int i) { return super.doPlace(i) && i > 5; } @@ -9,21 +9,21 @@ private static List currentPieces; static Class imposedPiece; private static int totalWeight; -@@ -1136,6 +1136,8 @@ +@@ -1384,6 +1384,8 @@ - if (structureboundingbox.isInside(blockposition_mutableblockposition)) { + if (structureboundingbox.isInside(blockposition1)) { this.hasPlacedSpawner = true; + // CraftBukkit start + /* - generatoraccessseed.setBlock(blockposition_mutableblockposition, Blocks.SPAWNER.defaultBlockState(), 2); - TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition_mutableblockposition); + generatoraccessseed.setBlock(blockposition1, Blocks.SPAWNER.defaultBlockState(), 2); + TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition1); -@@ -1144,6 +1146,9 @@ +@@ -1392,6 +1394,9 @@ tileentitymobspawner.setEntityId(EntityTypes.SILVERFISH, randomsource); } + */ -+ placeCraftSpawner(generatoraccessseed, blockposition_mutableblockposition, org.bukkit.entity.EntityType.SILVERFISH, 2); ++ placeCraftSpawner(generatoraccessseed, blockposition1, org.bukkit.entity.EntityType.SILVERFISH, 2); + // CraftBukkit end } } diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/SwampHutPiece.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/SwampHutPiece.patch index d46ee7578..88f16ab4b 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/SwampHutPiece.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/SwampHutPiece.patch @@ -2,8 +2,8 @@ +++ b/net/minecraft/world/level/levelgen/structure/structures/SwampHutPiece.java @@ -100,7 +100,7 @@ entitywitch.setPersistenceRequired(); - entitywitch.moveTo((double) blockposition_mutableblockposition.getX() + 0.5D, (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + 0.5D, 0.0F, 0.0F); - entitywitch.finalizeSpawn(generatoraccessseed, generatoraccessseed.getCurrentDifficultyAt(blockposition_mutableblockposition), EntitySpawnReason.STRUCTURE, (GroupDataEntity) null); + entitywitch.snapTo((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D, 0.0F, 0.0F); + entitywitch.finalizeSpawn(generatoraccessseed, generatoraccessseed.getCurrentDifficultyAt(blockposition1), EntitySpawnReason.STRUCTURE, (GroupDataEntity) null); - generatoraccessseed.addFreshEntityWithPassengers(entitywitch); + generatoraccessseed.addFreshEntityWithPassengers(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason } @@ -11,8 +11,8 @@ } @@ -121,7 +121,7 @@ entitycat.setPersistenceRequired(); - entitycat.moveTo((double) blockposition_mutableblockposition.getX() + 0.5D, (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + 0.5D, 0.0F, 0.0F); - entitycat.finalizeSpawn(worldaccess, worldaccess.getCurrentDifficultyAt(blockposition_mutableblockposition), EntitySpawnReason.STRUCTURE, (GroupDataEntity) null); + entitycat.snapTo((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F); + entitycat.finalizeSpawn(worldaccess, worldaccess.getCurrentDifficultyAt(blockposition), EntitySpawnReason.STRUCTURE, (GroupDataEntity) null); - worldaccess.addFreshEntityWithPassengers(entitycat); + worldaccess.addFreshEntityWithPassengers(entitycat, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason } diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch index f8027cf9f..5a32ebd34 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java -@@ -56,6 +56,12 @@ +@@ -58,6 +58,12 @@ import net.minecraft.world.phys.shapes.VoxelShapeBitSet; import net.minecraft.world.phys.shapes.VoxelShapeDiscrete; @@ -13,7 +13,7 @@ public class DefinedStructure { public static final String PALETTE_TAG = "palette"; -@@ -74,6 +80,11 @@ +@@ -76,6 +82,11 @@ private BaseBlockPosition size; private String author; @@ -34,7 +34,7 @@ return definedstructure_blockinfo.pos.getY(); }).thenComparingInt((definedstructure_blockinfo) -> { return definedstructure_blockinfo.pos.getX(); -@@ -253,6 +264,19 @@ +@@ -247,6 +258,19 @@ if (this.palettes.isEmpty()) { return false; } else { @@ -54,9 +54,9 @@ List list = definedstructureinfo.getRandomPalette(this.palettes, blockposition).blocks(); if ((!list.isEmpty() || !definedstructureinfo.isIgnoreEntities() && !this.entityInfoList.isEmpty()) && this.size.getX() >= 1 && this.size.getY() >= 1 && this.size.getZ() >= 1) { -@@ -284,6 +308,20 @@ - Clearable.tryClear(tileentity); - worldaccess.setBlock(blockposition2, Blocks.BARRIER.defaultBlockState(), 20); +@@ -271,6 +295,20 @@ + if (definedstructure_blockinfo.nbt != null) { + worldaccess.setBlock(blockposition2, Blocks.BARRIER.defaultBlockState(), 820); } + // CraftBukkit start + if (structureTransformer != null) { @@ -75,16 +75,16 @@ if (worldaccess.setBlock(blockposition2, iblockdata, i)) { j = Math.min(j, blockposition2.getX()); -@@ -296,7 +334,7 @@ - if (definedstructure_blockinfo.nbt != null) { - tileentity = worldaccess.getBlockEntity(blockposition2); +@@ -284,7 +322,7 @@ + TileEntity tileentity = worldaccess.getBlockEntity(blockposition2); + if (tileentity != null) { - if (tileentity instanceof RandomizableContainer) { + if (structureTransformer == null && tileentity instanceof RandomizableContainer) { // CraftBukkit - only process if don't have a transformer access (Was already set above) - SPIGOT-7520: Use structureTransformer as check, so that it is the same as above definedstructure_blockinfo.nbt.putLong("LootTableSeed", randomsource.nextLong()); } -@@ -401,7 +439,7 @@ +@@ -380,7 +418,7 @@ } if (!definedstructureinfo.isIgnoreEntities()) { @@ -93,7 +93,7 @@ } return true; -@@ -503,11 +541,13 @@ +@@ -475,11 +513,13 @@ } private static Optional createEntityIgnoreException(WorldAccess worldaccess, NBTTagCompound nbttagcompound) { @@ -111,9 +111,9 @@ } public BaseBlockPosition getSize(EnumBlockRotation enumblockrotation) { -@@ -721,6 +761,11 @@ +@@ -681,6 +721,11 @@ - nbttagcompound.put("entities", nbttaglist3); + nbttagcompound.put("entities", nbttaglist4); nbttagcompound.put("size", this.newIntegerList(this.size.getX(), this.size.getY(), this.size.getZ())); + // CraftBukkit start - PDC + if (!this.persistentDataContainer.isEmpty()) { @@ -123,10 +123,10 @@ return GameProfileSerializer.addCurrentDataVersion(nbttagcompound); } -@@ -760,6 +805,12 @@ - } - } - +@@ -711,6 +756,12 @@ + this.entityInfoList.add(new DefinedStructure.EntityInfo(vec3d, blockposition, nbttagcompound2)); + }); + }); + // CraftBukkit start - PDC + NBTBase base = nbttagcompound.get("BukkitValues"); + if (base instanceof NBTTagCompound) { @@ -136,7 +136,16 @@ } private void loadPalette(HolderGetter holdergetter, NBTTagList nbttaglist, NBTTagList nbttaglist1) { -@@ -924,7 +975,7 @@ +@@ -728,7 +779,7 @@ + NBTTagList nbttaglist2 = nbttagcompound.getListOrEmpty("pos"); + BlockPosition blockposition = new BlockPosition(nbttaglist2.getIntOr(0, 0), nbttaglist2.getIntOr(1, 0), nbttaglist2.getIntOr(2, 0)); + IBlockData iblockdata = definedstructure_c.stateFor(nbttagcompound.getIntOr("state", 0)); +- NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttagcompound.getCompound("nbt").orElse((Object) null); ++ NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttagcompound.getCompound("nbt").orElse(null); // CraftBukkit - decompile error + DefinedStructure.BlockInfo definedstructure_blockinfo = new DefinedStructure.BlockInfo(blockposition, iblockdata, nbttagcompound1); + + addToLists(definedstructure_blockinfo, list, list1, list2); +@@ -791,7 +842,7 @@ public IBlockData stateFor(int i) { IBlockData iblockdata = (IBlockData) this.ids.byId(i); diff --git a/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch b/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch index 0cff368d6..2f86809b9 100644 --- a/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch +++ b/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/material/FluidTypeFlowing.java +++ b/net/minecraft/world/level/material/FluidTypeFlowing.java -@@ -32,6 +32,15 @@ +@@ -30,6 +30,15 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -16,7 +16,7 @@ public abstract class FluidTypeFlowing extends FluidType { public static final BlockStateBoolean FALLING = BlockProperties.FALLING; -@@ -135,6 +144,15 @@ +@@ -126,6 +135,15 @@ FluidType fluidtype = fluid2.getType(); if (fluid1.canBeReplacedWith(worldserver, blockposition1, fluidtype, EnumDirection.DOWN) && canHoldSpecificFluid(worldserver, blockposition1, iblockdata1, fluidtype)) { @@ -32,8 +32,8 @@ this.spreadTo(worldserver, blockposition1, iblockdata1, EnumDirection.DOWN, fluid2); if (this.sourceNeighborCount(worldserver, blockposition) >= 3) { this.spreadToSides(worldserver, blockposition, fluid, iblockdata); -@@ -168,6 +186,15 @@ - Fluid fluid1 = (Fluid) entry.getValue(); +@@ -157,6 +175,15 @@ + Fluid fluid1 = (Fluid) map_entry.getValue(); BlockPosition blockposition1 = blockposition.relative(enumdirection); + // CraftBukkit start @@ -48,7 +48,7 @@ this.spreadTo(worldserver, blockposition1, worldserver.getBlockState(blockposition1), enumdirection, fluid1); } -@@ -444,10 +471,24 @@ +@@ -424,10 +451,24 @@ if (fluid1.isEmpty()) { fluid = fluid1; iblockdata = Blocks.AIR.defaultBlockState(); @@ -60,7 +60,7 @@ + iblockdata = ((CraftBlockData) event.getNewData()).getState(); + // CraftBukkit end worldserver.setBlock(blockposition, iblockdata, 3); - } else if (!fluid1.equals(fluid)) { + } else if (fluid1 != fluid) { fluid = fluid1; iblockdata = fluid1.createLegacyBlock(); + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch b/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch index b77cab1de..8439586d4 100644 --- a/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch +++ b/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch @@ -1,35 +1,35 @@ --- a/net/minecraft/world/level/material/FluidTypeLava.java +++ b/net/minecraft/world/level/material/FluidTypeLava.java -@@ -85,6 +85,13 @@ +@@ -89,6 +89,13 @@ - if (iblockdata.isAir()) { - if (this.hasFlammableNeighbours(worldserver, blockposition1)) { + if (iblockdata.isAir()) { + if (this.hasFlammableNeighbours(worldserver, blockposition1)) { ++ // CraftBukkit start - Prevent lava putting something on fire ++ if (worldserver.getBlockState(blockposition1).getBlock() != Blocks.FIRE) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(worldserver, blockposition1, blockposition).isCancelled()) { ++ continue; ++ } ++ } ++ // CraftBukkit end + worldserver.setBlockAndUpdate(blockposition1, BlockFireAbstract.getState(worldserver, blockposition1)); + return; + } +@@ -105,6 +112,14 @@ + } + + if (worldserver.isEmptyBlock(blockposition2.above()) && this.isFlammable(worldserver, blockposition2)) { + // CraftBukkit start - Prevent lava putting something on fire -+ if (worldserver.getBlockState(blockposition1).getBlock() != Blocks.FIRE) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(worldserver, blockposition1, blockposition).isCancelled()) { ++ BlockPosition up = blockposition2.above(); ++ if (worldserver.getBlockState(up).getBlock() != Blocks.FIRE) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(worldserver, up, blockposition).isCancelled()) { + continue; + } + } + // CraftBukkit end - worldserver.setBlockAndUpdate(blockposition1, BlockFireAbstract.getState(worldserver, blockposition1)); - return; + worldserver.setBlockAndUpdate(blockposition2.above(), BlockFireAbstract.getState(worldserver, blockposition2)); } -@@ -101,6 +108,14 @@ } - - if (worldserver.isEmptyBlock(blockposition2.above()) && this.isFlammable(worldserver, blockposition2)) { -+ // CraftBukkit start - Prevent lava putting something on fire -+ BlockPosition up = blockposition2.above(); -+ if (worldserver.getBlockState(up).getBlock() != Blocks.FIRE) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(worldserver, up, blockposition).isCancelled()) { -+ continue; -+ } -+ } -+ // CraftBukkit end - worldserver.setBlockAndUpdate(blockposition2.above(), BlockFireAbstract.getState(worldserver, blockposition2)); - } - } -@@ -196,7 +211,11 @@ +@@ -202,7 +217,11 @@ if (this.is(TagsFluid.LAVA) && fluid1.is(TagsFluid.WATER)) { if (iblockdata.getBlock() instanceof BlockFluids) { diff --git a/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch b/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch index 0f5b050ab..f8aae9ba6 100644 --- a/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch +++ b/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/portal/PortalTravelAgent.java +++ b/net/minecraft/world/level/portal/PortalTravelAgent.java -@@ -43,23 +43,35 @@ +@@ -42,23 +42,35 @@ } public Optional findClosestPortalPosition(BlockPosition blockposition, boolean flag, WorldBorder worldborder) { @@ -40,44 +40,44 @@ double d0 = -1.0D; BlockPosition blockposition1 = null; @@ -69,7 +81,7 @@ - int i = Math.min(this.level.getMaxY(), this.level.getMinY() + this.level.getLogicalHeight() - 1); - boolean flag = true; + int j = 1; BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable(); -- Iterator iterator = BlockPosition.spiralAround(blockposition, 16, EnumDirection.EAST, EnumDirection.SOUTH).iterator(); -+ Iterator iterator = BlockPosition.spiralAround(blockposition, createRadius, EnumDirection.EAST, EnumDirection.SOUTH).iterator(); // CraftBukkit - int j; - int k; -@@ -122,6 +134,7 @@ - int j1; - int k1; +- for (BlockPosition.MutableBlockPosition blockposition_mutableblockposition1 : BlockPosition.spiralAround(blockposition, 16, EnumDirection.EAST, EnumDirection.SOUTH)) { ++ for (BlockPosition.MutableBlockPosition blockposition_mutableblockposition1 : BlockPosition.spiralAround(blockposition, createRadius, EnumDirection.EAST, EnumDirection.SOUTH)) { // CraftBukkit + int k = Math.min(i, this.level.getHeight(HeightMap.Type.MOTION_BLOCKING, blockposition_mutableblockposition1.getX(), blockposition_mutableblockposition1.getZ())); + + if (worldborder.isWithinBounds((BlockPosition) blockposition_mutableblockposition1) && worldborder.isWithinBounds((BlockPosition) blockposition_mutableblockposition1.move(enumdirection, 1))) { +@@ -114,6 +126,7 @@ + d0 = d1; + } + org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(this.level); // CraftBukkit - Use BlockStateListPopulator if (d0 == -1.0D) { - j1 = Math.max(this.level.getMinY() - -1, 70); - k1 = i - 9; -@@ -139,7 +152,7 @@ - IBlockData iblockdata = i1 < 0 ? Blocks.OBSIDIAN.defaultBlockState() : Blocks.AIR.defaultBlockState(); + int k1 = Math.max(this.level.getMinY() - -1, 70); + int l1 = i - 9; +@@ -132,7 +145,7 @@ + IBlockData iblockdata = k2 < 0 ? Blocks.OBSIDIAN.defaultBlockState() : Blocks.AIR.defaultBlockState(); - blockposition_mutableblockposition.setWithOffset(blockposition1, l * enumdirection.getStepX() + k * enumdirection1.getStepX(), i1, l * enumdirection.getStepZ() + k * enumdirection1.getStepZ()); + blockposition_mutableblockposition.setWithOffset(blockposition1, j2 * enumdirection.getStepX() + i2 * enumdirection1.getStepX(), k2, j2 * enumdirection.getStepZ() + i2 * enumdirection1.getStepZ()); - this.level.setBlockAndUpdate(blockposition_mutableblockposition, iblockdata); + blockList.setBlock(blockposition_mutableblockposition, iblockdata, 3); // CraftBukkit } } } -@@ -149,7 +162,7 @@ - for (k1 = -1; k1 < 4; ++k1) { - if (j1 == -1 || j1 == 2 || k1 == -1 || k1 == 3) { - blockposition_mutableblockposition.setWithOffset(blockposition1, j1 * enumdirection.getStepX(), k1, j1 * enumdirection.getStepZ()); +@@ -142,7 +155,7 @@ + for (int i3 = -1; i3 < 4; ++i3) { + if (l2 == -1 || l2 == 2 || i3 == -1 || i3 == 3) { + blockposition_mutableblockposition.setWithOffset(blockposition1, l2 * enumdirection.getStepX(), i3, l2 * enumdirection.getStepZ()); - this.level.setBlock(blockposition_mutableblockposition, Blocks.OBSIDIAN.defaultBlockState(), 3); + blockList.setBlock(blockposition_mutableblockposition, Blocks.OBSIDIAN.defaultBlockState(), 3); // CraftBukkit } } } -@@ -159,10 +172,20 @@ - for (k1 = 0; k1 < 2; ++k1) { - for (j = 0; j < 3; ++j) { - blockposition_mutableblockposition.setWithOffset(blockposition1, k1 * enumdirection.getStepX(), j, k1 * enumdirection.getStepZ()); +@@ -152,10 +165,20 @@ + for (int j3 = 0; j3 < 2; ++j3) { + for (int k3 = 0; k3 < 3; ++k3) { + blockposition_mutableblockposition.setWithOffset(blockposition1, j3 * enumdirection.getStepX(), k3, j3 * enumdirection.getStepZ()); - this.level.setBlock(blockposition_mutableblockposition, iblockdata1, 18); + blockList.setBlock(blockposition_mutableblockposition, iblockdata1, 18); // CraftBukkit } diff --git a/nms-patches/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.patch b/nms-patches/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.patch index c98450b07..4dca3c17c 100644 --- a/nms-patches/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.patch +++ b/nms-patches/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java +++ b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java -@@ -10,6 +10,11 @@ +@@ -9,6 +9,11 @@ import net.minecraft.world.level.block.BlockRedstoneWire; import net.minecraft.world.level.block.state.IBlockData; @@ -12,7 +12,7 @@ public class DefaultRedstoneWireEvaluator extends RedstoneWireEvaluator { public DefaultRedstoneWireEvaluator(BlockRedstoneWire blockredstonewire) { -@@ -20,7 +25,16 @@ +@@ -19,7 +24,16 @@ public void updatePowerStrength(World world, BlockPosition blockposition, IBlockData iblockdata, @Nullable Orientation orientation, boolean flag) { int i = this.calculateTargetStrength(world, blockposition); diff --git a/nms-patches/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.patch b/nms-patches/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.patch index 163997076..8e8d1e843 100644 --- a/nms-patches/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.patch +++ b/nms-patches/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.java +++ b/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.java -@@ -17,6 +17,11 @@ +@@ -15,6 +15,11 @@ import net.minecraft.world.level.block.state.properties.BlockPropertyRedstoneSide; import net.minecraft.world.level.block.state.properties.BlockStateEnum; @@ -12,11 +12,11 @@ public class ExperimentalRedstoneWireEvaluator extends RedstoneWireEvaluator { private final Deque wiresToTurnOff = new ArrayDeque(); -@@ -41,7 +46,16 @@ +@@ -39,7 +44,16 @@ int j = unpackPower(i); IBlockData iblockdata1 = world.getBlockState(blockposition1); -- if (iblockdata1.is((Block) this.wireBlock) && !((Integer) iblockdata1.getValue(BlockRedstoneWire.POWER)).equals(j)) { +- if (iblockdata1.is(this.wireBlock) && !((Integer) iblockdata1.getValue(BlockRedstoneWire.POWER)).equals(j)) { + // CraftBukkit start + int oldPower = iblockdata.getValue(BlockRedstoneWire.POWER); + if (oldPower != j) { @@ -25,8 +25,16 @@ + + j = event.getNewCurrent(); + } -+ if (iblockdata1.is((Block) this.wireBlock) && oldPower != j) { ++ if (iblockdata1.is(this.wireBlock) && oldPower != j) { + // CraftBukkit end int k = 2; if (!flag || !flag1) { +@@ -140,6 +154,7 @@ + } + + int k1; ++ Orientation orientation2; // CraftBukkit - decompile error + + for (; !this.wiresToTurnOn.isEmpty(); this.propagateChangeToNeighbors(world, blockposition1, k1, orientation2, false)) { + blockposition1 = (BlockPosition) this.wiresToTurnOn.removeFirst(); diff --git a/nms-patches/net/minecraft/world/level/redstone/NeighborUpdater.patch b/nms-patches/net/minecraft/world/level/redstone/NeighborUpdater.patch index 3d8cac6f4..825c13a3b 100644 --- a/nms-patches/net/minecraft/world/level/redstone/NeighborUpdater.patch +++ b/nms-patches/net/minecraft/world/level/redstone/NeighborUpdater.patch @@ -14,11 +14,16 @@ public interface NeighborUpdater { -@@ -50,6 +57,17 @@ +@@ -45,6 +52,22 @@ static void executeUpdate(World world, IBlockData iblockdata, BlockPosition blockposition, Block block, @Nullable Orientation orientation, boolean flag) { try { + // CraftBukkit start ++ // BUKKIT-4923: Ignore Block Physics in Chunk population. ++ if (world.populating) { ++ return; ++ } ++ + CraftWorld cworld = ((WorldServer) world).getWorld(); + if (cworld != null) { + BlockPhysicsEvent event = new BlockPhysicsEvent(CraftBlock.at(world, blockposition), CraftBlockData.fromData(iblockdata)); diff --git a/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch b/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch index 88ce770f5..3eb020565 100644 --- a/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch +++ b/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch @@ -1,14 +1,13 @@ --- a/net/minecraft/world/level/saveddata/maps/WorldMap.java +++ b/net/minecraft/world/level/saveddata/maps/WorldMap.java -@@ -47,6 +47,17 @@ - import net.minecraft.world.level.saveddata.PersistentBase; +@@ -41,6 +41,16 @@ + import net.minecraft.world.level.saveddata.SavedDataType; import org.slf4j.Logger; +// CraftBukkit start +import java.util.UUID; -+import net.minecraft.nbt.NBTBase; ++import net.minecraft.server.MinecraftServer; +import org.bukkit.Bukkit; -+import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.map.CraftMapCursor; +import org.bukkit.craftbukkit.map.CraftMapView; @@ -18,119 +17,103 @@ public class WorldMap extends PersistentBase { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -70,6 +81,13 @@ - private final Map frameMarkers = Maps.newHashMap(); +@@ -70,6 +80,14 @@ + return List.copyOf(worldmap.bannerMarkers.values()); + }), WorldMapFrame.CODEC.listOf().optionalFieldOf("frames", List.of()).forGetter((worldmap) -> { + return List.copyOf(worldmap.frameMarkers.values()); ++ // CraftBukkit start ++ }), Codec.LONG.optionalFieldOf("UUIDLeast", 0L).forGetter((worldmap) -> { ++ UUID uuid = worldmap.updateUUID(); ++ return (uuid != null) ? uuid.getLeastSignificantBits() : 0L; ++ }), Codec.LONG.optionalFieldOf("UUIDMost", 0L).forGetter((worldmap) -> { ++ UUID uuid = worldmap.updateUUID(); ++ return (uuid != null) ? uuid.getMostSignificantBits() : 0L; ++ // CraftBukkit end + })).apply(instance, WorldMap::new); + }); + public int centerX; +@@ -87,6 +105,46 @@ + private final Map frameMarkers; private int trackedDecorationCount; + // CraftBukkit start + public final CraftMapView mapView; -+ private CraftServer server; + public UUID uniqueId = null; + public MapId id; ++ ++ private static ResourceKey getWorldKey(ResourceKey resourcekey, long uuidLeast, long uuidMost) { ++ World lookup = MinecraftServer.getServer().getLevel(resourcekey); ++ if (lookup != null) { ++ return resourcekey; ++ } ++ ++ if (uuidLeast != 0L && uuidMost != 0L) { ++ UUID uniqueId = new UUID(uuidMost, uuidLeast); ++ ++ CraftWorld world = (CraftWorld) 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: " + resourcekey); ++ } ++ ++ @Nullable ++ private UUID updateUUID() { ++ if (this.uniqueId == null) { ++ World world = MinecraftServer.getServer().getLevel(this.dimension); ++ if (world != null) { ++ this.uniqueId = world.getWorld().getUID(); ++ } ++ } ++ ++ return this.uniqueId; ++ } + // CraftBukkit end + - public static PersistentBase.a factory() { - return new PersistentBase.a<>(() -> { + public static SavedDataType type(MapId mapid) { + return new SavedDataType(mapid.key(), () -> { throw new IllegalStateException("Should never create an empty map saved data"); -@@ -84,6 +102,10 @@ +@@ -107,17 +165,21 @@ this.trackingPosition = flag; this.unlimitedTracking = flag1; this.locked = flag2; + // CraftBukkit start ++ updateUUID(); + mapView = new CraftMapView(this); -+ server = (CraftServer) org.bukkit.Bukkit.getServer(); + } + +- private WorldMap(ResourceKey resourcekey, int i, int j, byte b0, ByteBuffer bytebuffer, boolean flag, boolean flag1, boolean flag2, List list, List list1) { +- this(i, j, (byte) MathHelper.clamp(b0, 0, 4), flag, flag1, flag2, resourcekey); ++ private WorldMap(ResourceKey resourcekey, int i, int j, byte b0, ByteBuffer bytebuffer, boolean flag, boolean flag1, boolean flag2, List list, List list1, long uuidLeast, long uuidMost) { ++ this(i, j, (byte) MathHelper.clamp(b0, 0, 4), flag, flag1, flag2, getWorldKey(resourcekey, uuidLeast, uuidMost)); + // CraftBukkit end - } - - public static WorldMap createFresh(double d0, double d1, byte b0, boolean flag, boolean flag1, ResourceKey resourcekey) { -@@ -101,12 +123,30 @@ - } - - public static WorldMap load(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) { -- DataResult dataresult = DimensionManager.parseLegacy(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("dimension"))); -+ DataResult> dataresult = DimensionManager.parseLegacy(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("dimension"))); // CraftBukkit - decompile error - Logger logger = WorldMap.LOGGER; - - Objects.requireNonNull(logger); -- ResourceKey resourcekey = (ResourceKey) dataresult.resultOrPartial(logger::error).orElseThrow(() -> { -- return new IllegalArgumentException("Invalid map dimension: " + String.valueOf(nbttagcompound.get("dimension"))); -+ // CraftBukkit start -+ ResourceKey resourcekey = (ResourceKey) dataresult.resultOrPartial(logger::error).orElseGet(() -> { -+ long least = nbttagcompound.getLong("UUIDLeast"); -+ long most = nbttagcompound.getLong("UUIDMost"); -+ -+ if (least != 0L && most != 0L) { -+ UUID uniqueId = new UUID(most, least); -+ -+ CraftWorld world = (CraftWorld) 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(nbttagcompound.get("dimension"))); -+ // CraftBukkit end - }); - int i = nbttagcompound.getInt("xCenter"); - int j = nbttagcompound.getInt("zCenter"); -@@ -131,7 +171,8 @@ - MapIconBanner mapiconbanner = (MapIconBanner) iterator.next(); - - worldmap.bannerMarkers.put(mapiconbanner.getId(), mapiconbanner); -- worldmap.addDecoration(mapiconbanner.getDecoration(), (GeneratorAccess) null, mapiconbanner.getId(), (double) mapiconbanner.pos().getX(), (double) mapiconbanner.pos().getZ(), 180.0D, (IChatBaseComponent) mapiconbanner.name().orElse((Object) null)); -+ // CraftBukkit - decompile error -+ worldmap.addDecoration(mapiconbanner.getDecoration(), (GeneratorAccess) null, mapiconbanner.getId(), (double) mapiconbanner.pos().getX(), (double) mapiconbanner.pos().getZ(), 180.0D, (IChatBaseComponent) mapiconbanner.name().orElse(null)); + if (bytebuffer.array().length == 16384) { + this.colors = bytebuffer.array(); } - NBTTagList nbttaglist = nbttagcompound.getList("frames", 10); -@@ -150,13 +191,32 @@ + for (MapIconBanner mapiconbanner : list) { + this.bannerMarkers.put(mapiconbanner.getId(), mapiconbanner); +- this.addDecoration(mapiconbanner.getDecoration(), (GeneratorAccess) null, mapiconbanner.getId(), (double) mapiconbanner.pos().getX(), (double) mapiconbanner.pos().getZ(), 180.0D, (IChatBaseComponent) mapiconbanner.name().orElse((Object) null)); ++ this.addDecoration(mapiconbanner.getDecoration(), (GeneratorAccess) null, mapiconbanner.getId(), (double) mapiconbanner.pos().getX(), (double) mapiconbanner.pos().getZ(), 180.0D, (IChatBaseComponent) mapiconbanner.name().orElse(null)); // CraftBukkit - decompile error + } - @Override - public NBTTagCompound save(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) { -- DataResult dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.dimension.location()); -+ DataResult dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.dimension.location()); // CraftBukkit - decompile error - Logger logger = WorldMap.LOGGER; - - Objects.requireNonNull(logger); - dataresult.resultOrPartial(logger::error).ifPresent((nbtbase) -> { - nbttagcompound.put("dimension", nbtbase); - }); -+ // CraftBukkit start -+ if (true) { -+ if (this.uniqueId == null) { -+ for (org.bukkit.World world : server.getWorlds()) { -+ CraftWorld cWorld = (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) { -+ nbttagcompound.putLong("UUIDLeast", this.uniqueId.getLeastSignificantBits()); -+ nbttagcompound.putLong("UUIDMost", this.uniqueId.getMostSignificantBits()); -+ } -+ } -+ // CraftBukkit end - nbttagcompound.putInt("xCenter", this.centerX); - nbttagcompound.putInt("zCenter", this.centerZ); - nbttagcompound.putByte("scale", this.scale); -@@ -443,7 +503,7 @@ + for (WorldMapFrame worldmapframe : list1) { +@@ -400,7 +462,7 @@ if (!this.isTrackedCountOverLimit(256)) { this.bannerMarkers.put(mapiconbanner.getId(), mapiconbanner); - this.addDecoration(mapiconbanner.getDecoration(), generatoraccess, mapiconbanner.getId(), d0, d1, 180.0D, (IChatBaseComponent) mapiconbanner.name().orElse((Object) null)); + this.addDecoration(mapiconbanner.getDecoration(), generatoraccess, mapiconbanner.getId(), d0, d1, 180.0D, (IChatBaseComponent) mapiconbanner.name().orElse(null)); // CraftBukkit - decompile error + this.setDirty(); return true; } - } -@@ -554,7 +614,7 @@ +@@ -551,7 +613,7 @@ this.player = entityhuman; } @@ -139,7 +122,7 @@ int i = this.minDirtyX; int j = this.minDirtyY; int k = this.maxDirtyX + 1 - this.minDirtyX; -@@ -563,7 +623,7 @@ +@@ -560,7 +622,7 @@ for (int i1 = 0; i1 < k; ++i1) { for (int j1 = 0; j1 < l; ++j1) { @@ -148,7 +131,7 @@ } } -@@ -573,19 +633,29 @@ +@@ -570,19 +632,29 @@ @Nullable Packet nextUpdatePacket(MapId mapid) { WorldMap.c worldmap_c; @@ -162,7 +145,7 @@ worldmap_c = null; } - Collection collection; + Collection collection; - if (this.dirtyDecorations && this.tick++ % 5 == 0) { + if ((true || this.dirtyDecorations) && this.tick++ % 5 == 0) { // CraftBukkit - custom maps don't update this yet diff --git a/nms-patches/net/minecraft/world/level/storage/Convertable.patch b/nms-patches/net/minecraft/world/level/storage/Convertable.patch index c2b813148..f4327e617 100644 --- a/nms-patches/net/minecraft/world/level/storage/Convertable.patch +++ b/nms-patches/net/minecraft/world/level/storage/Convertable.patch @@ -11,7 +11,7 @@ public class Convertable { static final Logger LOGGER = LogUtils.getLogger(); -@@ -149,7 +153,7 @@ +@@ -127,7 +131,7 @@ } public static WorldDataConfiguration readDataConfig(Dynamic dynamic) { @@ -20,7 +20,7 @@ Logger logger = Convertable.LOGGER; Objects.requireNonNull(logger); -@@ -168,6 +172,7 @@ +@@ -146,6 +150,7 @@ WorldDimensions.b worlddimensions_b = generatorsettings.dimensions().bake(iregistry); Lifecycle lifecycle = worlddimensions_b.lifecycle().add(holderlookup_a.allRegistriesLifecycle()); WorldDataServer worlddataserver = WorldDataServer.parse(dynamic1, worldsettings, worlddimensions_b.specialWorldProperty(), generatorsettings.options(), lifecycle); @@ -28,7 +28,7 @@ return new LevelDataAndDimensions(worlddataserver, worlddimensions_b); } -@@ -409,27 +414,41 @@ +@@ -362,35 +367,53 @@ return this.backupDir; } @@ -71,10 +71,9 @@ + } + // CraftBukkit end + - public static record a(List levels) implements Iterable { + public class ConversionSession implements AutoCloseable { - public boolean isEmpty() { -@@ -488,8 +507,12 @@ + final SessionLock lock; public final Convertable.b levelDirectory; private final String levelId; private final Map resources = Maps.newHashMap(); @@ -88,7 +87,7 @@ this.levelId = s; this.levelDirectory = new Convertable.b(path); this.lock = SessionLock.create(path); -@@ -529,7 +552,7 @@ +@@ -430,7 +453,7 @@ } public Path getLevelPath(SavedFile savedfile) { @@ -97,7 +96,7 @@ Convertable.b convertable_b = this.levelDirectory; Objects.requireNonNull(this.levelDirectory); -@@ -537,7 +560,7 @@ +@@ -438,7 +461,7 @@ } public Path getDimensionPath(ResourceKey resourcekey) { diff --git a/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch b/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch index cf2dffac9..d0d946cc9 100644 --- a/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch +++ b/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch @@ -39,7 +39,7 @@ + } + // CraftBukkit end - private WorldDataServer(@Nullable NBTTagCompound nbttagcompound, boolean flag, BlockPosition blockposition, float f, long i, long j, int k, int l, int i1, boolean flag1, int j1, boolean flag2, boolean flag3, boolean flag4, WorldBorder.c worldborder_c, int k1, int l1, @Nullable UUID uuid, Set set, Set set1, CustomFunctionCallbackTimerQueue customfunctioncallbacktimerqueue, @Nullable NBTTagCompound nbttagcompound1, EnderDragonBattle.a enderdragonbattle_a, WorldSettings worldsettings, WorldOptions worldoptions, WorldDataServer.a worlddataserver_a, Lifecycle lifecycle) { + private WorldDataServer(@Nullable NBTTagCompound nbttagcompound, boolean flag, BlockPosition blockposition, float f, long i, long j, int k, int l, int i1, boolean flag1, int j1, boolean flag2, boolean flag3, boolean flag4, WorldBorder.d worldborder_d, int k1, int l1, @Nullable UUID uuid, Set set, Set set1, CustomFunctionCallbackTimerQueue customfunctioncallbacktimerqueue, @Nullable NBTTagCompound nbttagcompound1, EnderDragonBattle.a enderdragonbattle_a, WorldSettings worldsettings, WorldOptions worldoptions, WorldDataServer.a worlddataserver_a, Lifecycle lifecycle) { this.wasModded = flag; @@ -116,7 +143,7 @@ @@ -51,7 +51,7 @@ Objects.requireNonNull(codec); @@ -136,7 +163,7 @@ - WorldBorder.c worldborder_c = WorldBorder.c.read(dynamic, WorldBorder.DEFAULT_SETTINGS); + WorldBorder.d worldborder_d = WorldBorder.d.read(dynamic, WorldBorder.DEFAULT_SETTINGS); int k1 = dynamic.get("WanderingTraderSpawnDelay").asInt(0); int l1 = dynamic.get("WanderingTraderSpawnChance").asInt(0); - UUID uuid = (UUID) dynamic.get("WanderingTraderId").read(UUIDUtil.CODEC).result().orElse((Object) null); @@ -61,7 +61,7 @@ }).collect(Collectors.toCollection(Sets::newLinkedHashSet)); @@ -145,7 +172,7 @@ }).collect(Collectors.toSet()); - CustomFunctionCallbackTimerQueue customfunctioncallbacktimerqueue = new CustomFunctionCallbackTimerQueue<>(CustomFunctionCallbackTimers.SERVER_CALLBACKS, dynamic.get("ScheduledEvents").asStream()); + CustomFunctionCallbackTimerQueue customfunctioncallbacktimerqueue = new CustomFunctionCallbackTimerQueue(CustomFunctionCallbackTimers.SERVER_CALLBACKS, dynamic.get("ScheduledEvents").asStream()); NBTTagCompound nbttagcompound1 = (NBTTagCompound) dynamic.get("CustomBossEvents").orElseEmptyMap().getValue(); - DataResult dataresult = dynamic.get("DragonFight").read(EnderDragonBattle.a.CODEC); + DataResult dataresult = dynamic.get("DragonFight").read(EnderDragonBattle.a.CODEC); // CraftBukkit - decompile error @@ -71,16 +71,16 @@ @@ -180,7 +207,7 @@ nbttagcompound.put("Version", nbttagcompound2); GameProfileSerializer.addCurrentDataVersion(nbttagcompound); - DynamicOps dynamicops = iregistrycustom.createSerializationContext(DynamicOpsNBT.INSTANCE); + DynamicOps dynamicops = iregistrycustom.createSerializationContext(DynamicOpsNBT.INSTANCE); - DataResult dataresult = GeneratorSettings.encode(dynamicops, this.worldOptions, iregistrycustom); + DataResult dataresult = GeneratorSettings.encode(dynamicops, this.worldOptions, new WorldDimensions(this.customDimensions != null ? this.customDimensions : iregistrycustom.lookupOrThrow(Registries.LEVEL_STEM))); // CraftBukkit Logger logger = WorldDataServer.LOGGER; Objects.requireNonNull(logger); -@@ -230,11 +257,13 @@ - nbttagcompound.putUUID("WanderingTraderId", this.wanderingTraderId); - } - +@@ -223,11 +250,13 @@ + nbttagcompound.putInt("WanderingTraderSpawnDelay", this.wanderingTraderSpawnDelay); + nbttagcompound.putInt("WanderingTraderSpawnChance", this.wanderingTraderSpawnChance); + nbttagcompound.storeNullable("WanderingTraderId", UUIDUtil.CODEC, this.wanderingTraderId); + nbttagcompound.putString("Bukkit.Version", Bukkit.getName() + "/" + Bukkit.getVersion() + "/" + Bukkit.getBukkitVersion()); // CraftBukkit + world.getWorld().storeBukkitValues(nbttagcompound); // CraftBukkit - add pdc } @@ -92,7 +92,7 @@ Objects.requireNonNull(nbttaglist); stream.forEach(nbttaglist::add); -@@ -310,6 +339,20 @@ +@@ -303,6 +332,20 @@ @Override public void setThundering(boolean flag) { @@ -113,7 +113,7 @@ this.thundering = flag; } -@@ -330,6 +373,20 @@ +@@ -323,6 +366,20 @@ @Override public void setRaining(boolean flag) { @@ -134,7 +134,7 @@ this.raining = flag; } -@@ -396,6 +453,12 @@ +@@ -389,6 +446,12 @@ @Override public void setDifficulty(EnumDifficulty enumdifficulty) { this.settings = this.settings.withDifficulty(enumdifficulty); @@ -147,7 +147,7 @@ } @Override -@@ -532,6 +595,14 @@ +@@ -525,6 +588,14 @@ return this.settings.copy(); } diff --git a/nms-patches/net/minecraft/world/level/storage/loot/LootDataType.patch b/nms-patches/net/minecraft/world/level/storage/loot/LootDataType.patch index 86e7c6ff3..462c7948f 100644 --- a/nms-patches/net/minecraft/world/level/storage/loot/LootDataType.patch +++ b/nms-patches/net/minecraft/world/level/storage/loot/LootDataType.patch @@ -11,7 +11,7 @@ + public record LootDataType(ResourceKey> registryKey, Codec codec, LootDataType.a validator) { - public static final LootDataType PREDICATE = new LootDataType<>(Registries.PREDICATE, LootItemCondition.DIRECT_CODEC, createSimpleValidator()); + public static final LootDataType PREDICATE = new LootDataType(Registries.PREDICATE, LootItemCondition.DIRECT_CODEC, createSimpleValidator()); @@ -32,6 +37,7 @@ private static LootDataType.a createLootTableValidator() { return (lootcollector, resourcekey, loottable) -> { diff --git a/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch b/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch index 827b4ca44..144c51d26 100644 --- a/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch +++ b/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch @@ -14,7 +14,15 @@ public class LootTable { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -54,6 +61,7 @@ +@@ -50,13 +57,14 @@ + })).apply(instance, LootTable::new); + }); + }); +- public static final Codec> CODEC = RegistryFileCodec.>create(Registries.LOOT_TABLE, LootTable.DIRECT_CODEC); ++ public static final Codec> CODEC = RegistryFileCodec.create(Registries.LOOT_TABLE, LootTable.DIRECT_CODEC); // CraftBukkit - decompile error + public static final LootTable EMPTY = new LootTable(LootContextParameterSets.EMPTY, Optional.empty(), List.of(), List.of()); + private final ContextKeySet paramSet; + private final Optional randomSequence; private final List pools; private final List functions; private final BiFunction compositeFunction; @@ -22,7 +30,7 @@ LootTable(ContextKeySet contextkeyset, Optional optional, List list, List list1) { this.paramSet = contextkeyset; -@@ -157,9 +165,22 @@ +@@ -155,9 +163,22 @@ } public void fill(IInventory iinventory, LootParams lootparams, long i) { diff --git a/pom.xml b/pom.xml index 1c988e083..a6030381e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.bukkit craftbukkit jar - 1.21.4-R0.1-SNAPSHOT + 1.21.5-R0.1-SNAPSHOT CraftBukkit https://www.spigotmc.org/ @@ -14,7 +14,7 @@ UTF-8 unknown git - 1_21_R3 + 1_21_R4 21 @@ -97,7 +97,7 @@ com.mojang authlib - 6.0.57 + 6.0.58 compile @@ -157,63 +157,63 @@ io.netty netty-buffer - 4.1.115.Final + 4.1.118.Final compile io.netty netty-codec - 4.1.115.Final + 4.1.118.Final compile io.netty netty-common - 4.1.115.Final + 4.1.118.Final compile io.netty netty-handler - 4.1.115.Final + 4.1.118.Final compile io.netty netty-resolver - 4.1.115.Final + 4.1.118.Final compile io.netty netty-transport - 4.1.115.Final + 4.1.118.Final compile io.netty netty-transport-classes-epoll - 4.1.115.Final + 4.1.118.Final compile io.netty netty-transport-native-epoll - 4.1.115.Final + 4.1.118.Final linux-x86_64 compile io.netty netty-transport-native-epoll - 4.1.115.Final + 4.1.118.Final linux-aarch_64 compile io.netty netty-transport-native-unix-common - 4.1.115.Final + 4.1.118.Final compile @@ -312,13 +312,13 @@ org.xerial sqlite-jdbc - 3.47.0.0 + 3.49.1.0 runtime com.mysql mysql-connector-j - 9.1.0 + 9.2.0 runtime @@ -369,7 +369,7 @@ org.mockito mockito-core - 5.16.0 + 5.14.1 test diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index b786d5aef..854c76bf1 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -317,7 +317,7 @@ public class CraftChunk implements Chunk { NBTTagCompound data = new NBTTagCompound(); data.put("block_states", SerializableChunkData.BLOCK_STATE_CODEC.encodeStart(DynamicOpsNBT.INSTANCE, cs[i].getStates()).getOrThrow()); - sectionBlockIDs[i] = SerializableChunkData.BLOCK_STATE_CODEC.parse(DynamicOpsNBT.INSTANCE, data.getCompound("block_states")).getOrThrow(SerializableChunkData.a::new); + sectionBlockIDs[i] = SerializableChunkData.BLOCK_STATE_CODEC.parse(DynamicOpsNBT.INSTANCE, data.getCompoundOrEmpty("block_states")).getOrThrow(SerializableChunkData.a::new); sectionEmpty[i] = cs[i].hasOnlyAir(); LevelLightEngine lightengine = worldServer.getLightEngine(); @@ -338,7 +338,7 @@ public class CraftChunk implements Chunk { if (biome != null) { data.put("biomes", biomeCodec.encodeStart(DynamicOpsNBT.INSTANCE, cs[i].getBiomes()).getOrThrow()); - biome[i] = biomeCodec.parse(DynamicOpsNBT.INSTANCE, data.getCompound("biomes")).getOrThrow(SerializableChunkData.a::new); + biome[i] = biomeCodec.parse(DynamicOpsNBT.INSTANCE, data.getCompoundOrEmpty("biomes")).getOrThrow(SerializableChunkData.a::new); } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java b/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java index e379616d9..83818462c 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java @@ -19,6 +19,7 @@ public class CraftEquipmentSlot { set(EquipmentSlot.CHEST, EnumItemSlot.CHEST); set(EquipmentSlot.HEAD, EnumItemSlot.HEAD); set(EquipmentSlot.BODY, EnumItemSlot.BODY); + set(EquipmentSlot.SADDLE, EnumItemSlot.SADDLE); } private static void set(EquipmentSlot type, EnumItemSlot value) { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java index a00765395..9068f0337 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java @@ -13,6 +13,8 @@ import net.minecraft.core.GlobalPos; import net.minecraft.nbt.DynamicOpsNBT; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import net.minecraft.server.level.EntityPlayer; +import net.minecraft.server.level.WorldServer; import net.minecraft.server.players.WhiteListEntry; import net.minecraft.stats.ServerStatisticManager; import net.minecraft.world.level.storage.WorldNBTStorage; @@ -29,6 +31,7 @@ import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.SerializableAs; import org.bukkit.craftbukkit.entity.memory.CraftMemoryMapper; import org.bukkit.craftbukkit.profile.CraftPlayerProfile; +import org.bukkit.craftbukkit.util.CraftLocation; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.metadata.MetadataValue; @@ -69,7 +72,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa if (data != null) { if (data.contains("lastKnownName")) { - return data.getString("lastKnownName"); + return data.getStringOr("lastKnownName", ""); } } @@ -209,7 +212,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa if (!result.contains("bukkit")) { result.put("bukkit", new NBTTagCompound()); } - result = result.getCompound("bukkit"); + result = result.getCompoundOrEmpty("bukkit"); } return result; @@ -228,7 +231,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa if (data != null) { if (data.contains("firstPlayed")) { - return data.getLong("firstPlayed"); + return data.getLongOr("firstPlayed", 0); } else { File file = getDataFile(); return file.lastModified(); @@ -247,7 +250,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa if (data != null) { if (data.contains("lastPlayed")) { - return data.getLong("lastPlayed"); + return data.getLongOr("lastPlayed", 0); } else { File file = getDataFile(); return file.lastModified(); @@ -264,7 +267,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa @Override public Location getLastDeathLocation() { - if (getData().contains("LastDeathLocation", 10)) { + if (getData().contains("LastDeathLocation")) { return GlobalPos.CODEC.parse(DynamicOpsNBT.INSTANCE, getData().get("LastDeathLocation")).result().map(CraftMemoryMapper::fromNms).orElse(null); } return null; @@ -281,14 +284,14 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa NBTTagList position = (NBTTagList) data.get("Pos"); NBTTagList rotation = (NBTTagList) data.get("Rotation"); - UUID uuid = new UUID(data.getLong("WorldUUIDMost"), data.getLong("WorldUUIDLeast")); + UUID uuid = new UUID(data.getLongOr("WorldUUIDMost", 0), data.getLongOr("WorldUUIDLeast", 0)); return new Location(server.getWorld(uuid), - position.getDouble(0), - position.getDouble(1), - position.getDouble(2), - rotation.getFloat(0), - rotation.getFloat(1) + position.getDoubleOr(0, 0), + position.getDoubleOr(1, 0), + position.getDoubleOr(2, 0), + rotation.getFloatOr(0, 0), + rotation.getFloatOr(1, 0) ); } @@ -305,12 +308,22 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa NBTTagCompound data = getData(); if (data == null) return null; + EntityPlayer.RespawnConfig respawn = data.read("respawn", EntityPlayer.RespawnConfig.CODEC).orElse(null); + if (respawn != null) { + WorldServer world = server.getServer().getLevel(respawn.dimension()); + if (world == null) { + world = server.getServer().overworld(); + } + + return CraftLocation.toBukkit(respawn.pos(), world.getWorld(), respawn.angle(), 0.0F); + } + if (data.contains("SpawnX") && data.contains("SpawnY") && data.contains("SpawnZ")) { - String spawnWorld = data.getString("SpawnWorld"); + String spawnWorld = data.getStringOr("SpawnWorld", ""); if (spawnWorld.equals("")) { spawnWorld = server.getWorlds().get(0).getName(); } - return new Location(server.getWorld(spawnWorld), data.getInt("SpawnX"), data.getInt("SpawnY"), data.getInt("SpawnZ")); + return new Location(server.getWorld(spawnWorld), data.getIntOr("SpawnX", 0), data.getIntOr("SpawnY", 0), data.getIntOr("SpawnZ", 0)); } return null; } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftParticle.java b/src/main/java/org/bukkit/craftbukkit/CraftParticle.java index ae7618e04..23fed0601 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftParticle.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftParticle.java @@ -208,6 +208,7 @@ public abstract class CraftParticle implements Keyed { add("shriek", integerFunction); add("block_marker", blockDataFunction); add("entity_effect", colorFunction); + add("tinted_leaves", colorFunction); add("dust_pillar", blockDataFunction); add("block_crumble", blockDataFunction); add("trail", trailFunction); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRaid.java b/src/main/java/org/bukkit/craftbukkit/CraftRaid.java index 575b44d06..cdf078bc8 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftRaid.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftRaid.java @@ -19,9 +19,11 @@ import org.bukkit.entity.Raider; public final class CraftRaid implements Raid { private final net.minecraft.world.entity.raid.Raid handle; + private final World world; - public CraftRaid(net.minecraft.world.entity.raid.Raid handle) { + public CraftRaid(net.minecraft.world.entity.raid.Raid handle, World world) { this.handle = handle; + this.world = world; } @Override @@ -49,7 +51,6 @@ public final class CraftRaid implements Raid { @Override public Location getLocation() { BlockPosition pos = handle.getCenter(); - World world = handle.getLevel(); return CraftLocation.toBukkit(pos, world.getWorld()); } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java index 737ff6307..d4d04d798 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java @@ -16,7 +16,6 @@ import net.minecraft.util.RandomSource; import net.minecraft.world.entity.EntityInsentient; import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.entity.GroupDataEntity; -import net.minecraft.world.entity.projectile.EntityPotion; import net.minecraft.world.level.GeneratorAccessSeed; import net.minecraft.world.level.biome.BiomeBase; import net.minecraft.world.level.block.BlockChorusFlower; @@ -38,28 +37,25 @@ import org.bukkit.craftbukkit.block.CraftBlockType; import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftEntityTypes; -import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.util.BlockStateListPopulator; import org.bukkit.craftbukkit.util.CraftLocation; import org.bukkit.craftbukkit.util.RandomSourceWrapper; import org.bukkit.entity.AbstractArrow; +import org.bukkit.entity.AbstractCow; import org.bukkit.entity.AbstractHorse; import org.bukkit.entity.Arrow; +import org.bukkit.entity.Cow; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Fireball; import org.bukkit.entity.Horse; import org.bukkit.entity.LargeFireball; -import org.bukkit.entity.LingeringPotion; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Minecart; import org.bukkit.entity.SizedFireball; -import org.bukkit.entity.SplashPotion; -import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.TippedArrow; import org.bukkit.entity.minecart.RideableMinecart; import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionType; public abstract class CraftRegionAccessor implements RegionAccessor { @@ -477,17 +473,14 @@ public abstract class CraftRegionAccessor implements RegionAccessor { clazz = Arrow.class; } else if (clazz == AbstractHorse.class) { clazz = Horse.class; + } else if (clazz == AbstractCow.class) { + clazz = Cow.class; } else if (clazz == Fireball.class) { clazz = LargeFireball.class; - } else if (clazz == LingeringPotion.class) { - clazz = ThrownPotion.class; - runOld = other -> ((EntityPotion) other).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1))); } else if (clazz == Minecart.class) { clazz = RideableMinecart.class; } else if (clazz == SizedFireball.class) { clazz = LargeFireball.class; - } else if (clazz == SplashPotion.class) { - clazz = ThrownPotion.class; } else if (clazz == TippedArrow.class) { clazz = Arrow.class; runOld = other -> ((Arrow) other.getBukkitEntity()).setBasePotionType(PotionType.WATER); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java index acd81b404..68fe14f13 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java @@ -32,7 +32,10 @@ import org.bukkit.craftbukkit.block.banner.CraftPatternType; import org.bukkit.craftbukkit.damage.CraftDamageType; import org.bukkit.craftbukkit.enchantments.CraftEnchantment; import org.bukkit.craftbukkit.entity.CraftCat; +import org.bukkit.craftbukkit.entity.CraftChicken; +import org.bukkit.craftbukkit.entity.CraftCow; import org.bukkit.craftbukkit.entity.CraftFrog; +import org.bukkit.craftbukkit.entity.CraftPig; import org.bukkit.craftbukkit.entity.CraftVillager; import org.bukkit.craftbukkit.entity.CraftWolf; import org.bukkit.craftbukkit.generator.structure.CraftStructure; @@ -50,8 +53,11 @@ import org.bukkit.craftbukkit.util.Handleable; 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.generator.structure.Structure; @@ -209,6 +215,15 @@ public class CraftRegistry implements Registry { if (bukkitClass == Cat.Type.class) { return new CraftRegistry<>(Cat.Type.class, registryHolder.lookupOrThrow(Registries.CAT_VARIANT), CraftCat.CraftType::new, FieldRename.NONE); } + if (bukkitClass == Pig.Variant.class) { + return new CraftRegistry<>(Pig.Variant.class, registryHolder.lookupOrThrow(Registries.PIG_VARIANT), CraftPig.CraftVariant::new, FieldRename.NONE); + } + if (bukkitClass == Cow.Variant.class) { + return new CraftRegistry<>(Cow.Variant.class, registryHolder.lookupOrThrow(Registries.COW_VARIANT), CraftCow.CraftVariant::new, FieldRename.NONE); + } + if (bukkitClass == Chicken.Variant.class) { + return new CraftRegistry<>(Chicken.Variant.class, registryHolder.lookupOrThrow(Registries.CHICKEN_VARIANT), CraftChicken.CraftVariant::new, FieldRename.NONE); + } if (bukkitClass == MapCursor.Type.class) { return new CraftRegistry<>(MapCursor.Type.class, registryHolder.lookupOrThrow(Registries.MAP_DECORATION_TYPE), CraftMapCursor.CraftType::new, FieldRename.NONE); } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 15aadc35e..01de36d0b 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -381,7 +381,7 @@ public final class CraftServer implements Server { overrideSpawnLimits(); console.autosavePeriod = configuration.getInt("ticks-per.autosave"); warningState = WarningState.value(configuration.getString("settings.deprecated-verbose")); - TicketType.PLUGIN.timeout = configuration.getInt("chunk-gc.period-in-ticks"); + TicketType.pluginTimeout = configuration.getInt("chunk-gc.period-in-ticks"); minimumAPI = ApiVersion.getOrCreateVersion(configuration.getString("settings.minimum-api")); loadIcon(); loadCompatibilities(); @@ -927,7 +927,7 @@ public final class CraftServer implements Server { console.setMotd(config.motd); overrideSpawnLimits(); warningState = WarningState.value(configuration.getString("settings.deprecated-verbose")); - TicketType.PLUGIN.timeout = configuration.getInt("chunk-gc.period-in-ticks"); + TicketType.pluginTimeout = configuration.getInt("chunk-gc.period-in-ticks"); minimumAPI = ApiVersion.getOrCreateVersion(configuration.getString("settings.minimum-api")); printSaveWarning = false; console.autosavePeriod = configuration.getInt("ticks-per.autosave"); @@ -1199,7 +1199,7 @@ public final class CraftServer implements Server { worlddata.setModdedInfo(console.getServerModName(), console.getModdedStatus().shouldReportAsModified()); if (console.options.has("forceUpgrade")) { - net.minecraft.server.Main.forceUpgrade(worldSession, DataConverterRegistry.getDataFixer(), console.options.has("eraseCache"), () -> true, iregistrycustom_dimension, console.options.has("recreateRegionFiles")); + net.minecraft.server.Main.forceUpgrade(worldSession, worlddata, DataConverterRegistry.getDataFixer(), console.options.has("eraseCache"), () -> true, iregistrycustom_dimension, console.options.has("recreateRegionFiles")); } long j = BiomeManager.obfuscateSeed(creator.seed()); @@ -1740,7 +1740,7 @@ public final class CraftServer implements Server { public CraftMapView createMap(World world) { Preconditions.checkArgument(world != null, "World cannot be null"); - net.minecraft.world.level.World minecraftWorld = ((CraftWorld) world).getHandle(); + WorldServer minecraftWorld = ((CraftWorld) world).getHandle(); // creates a new map at world spawn with the scale of 3, with out tracking position and unlimited tracking BlockPosition spawn = minecraftWorld.getLevelData().getSpawnPos(); MapId newId = ItemWorldMap.createNewSavedData(minecraftWorld, spawn.getX(), spawn.getZ(), 3, false, false, minecraftWorld.dimension()); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index e734fd6e2..285acb1c5 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -38,7 +38,6 @@ import net.minecraft.network.protocol.game.PacketPlayOutNamedSoundEffect; import net.minecraft.network.protocol.game.PacketPlayOutUpdateTime; import net.minecraft.network.protocol.game.PacketPlayOutWorldEvent; import net.minecraft.resources.MinecraftKey; -import net.minecraft.server.level.ChunkMapDistance; import net.minecraft.server.level.EntityPlayer; import net.minecraft.server.level.PlayerChunk; import net.minecraft.server.level.PlayerChunkMap; @@ -48,9 +47,7 @@ import net.minecraft.server.level.WorldServer; import net.minecraft.sounds.SoundCategory; import net.minecraft.sounds.SoundEffect; import net.minecraft.sounds.SoundEffects; -import net.minecraft.util.ArraySetSorted; import net.minecraft.util.MathHelper; -import net.minecraft.util.Unit; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.entity.EntityLightning; import net.minecraft.world.entity.EntitySpawnReason; @@ -64,6 +61,7 @@ import net.minecraft.world.level.ChunkCoordIntPair; import net.minecraft.world.level.Explosion; import net.minecraft.world.level.GameRules; import net.minecraft.world.level.RayTrace; +import net.minecraft.world.level.TicketStorage; import net.minecraft.world.level.biome.BiomeBase; import net.minecraft.world.level.biome.Climate; import net.minecraft.world.level.chunk.IChunkAccess; @@ -289,7 +287,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean unloadChunkRequest(int x, int z) { if (isChunkLoaded(x, z)) { - world.getChunkSource().removeRegionTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 1, Unit.INSTANCE); + world.getChunkSource().removeTicketWithRadius(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 1); } return true; @@ -398,7 +396,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { } if (chunk instanceof net.minecraft.world.level.chunk.Chunk) { - world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 1, Unit.INSTANCE); + world.getChunkSource().addTicketWithRadius(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 1); return true; } @@ -424,9 +422,9 @@ public class CraftWorld extends CraftRegionAccessor implements World { Preconditions.checkArgument(plugin != null, "null plugin"); Preconditions.checkArgument(plugin.isEnabled(), "plugin is not enabled"); - ChunkMapDistance chunkDistanceManager = this.world.getChunkSource().chunkMap.distanceManager; + TicketStorage chunkDistanceManager = this.world.getChunkSource().ticketStorage; - if (chunkDistanceManager.addRegionTicketAtDistance(TicketType.PLUGIN_TICKET, new ChunkCoordIntPair(x, z), 2, plugin)) { // keep in-line with force loading, add at level 31 + if (chunkDistanceManager.addTicket(ChunkCoordIntPair.asLong(x, z), Ticket.of(TicketType.PLUGIN_TICKET, PlayerChunkMap.FORCED_TICKET_LEVEL, plugin))) { // keep in-line with force loading, add at level 31 this.getChunkAt(x, z); // ensure loaded return true; } @@ -438,29 +436,29 @@ public class CraftWorld extends CraftRegionAccessor implements World { public boolean removePluginChunkTicket(int x, int z, Plugin plugin) { Preconditions.checkNotNull(plugin, "null plugin"); - ChunkMapDistance chunkDistanceManager = this.world.getChunkSource().chunkMap.distanceManager; - return chunkDistanceManager.removeRegionTicketAtDistance(TicketType.PLUGIN_TICKET, new ChunkCoordIntPair(x, z), 2, plugin); // keep in-line with force loading, remove at level 31 + TicketStorage chunkDistanceManager = this.world.getChunkSource().ticketStorage; + return chunkDistanceManager.removeTicket(ChunkCoordIntPair.asLong(x, z), Ticket.of(TicketType.PLUGIN_TICKET, PlayerChunkMap.FORCED_TICKET_LEVEL, plugin)); // keep in-line with force loading, remove at level 31 } @Override public void removePluginChunkTickets(Plugin plugin) { Preconditions.checkNotNull(plugin, "null plugin"); - ChunkMapDistance chunkDistanceManager = this.world.getChunkSource().chunkMap.distanceManager; - chunkDistanceManager.removeAllTicketsFor(TicketType.PLUGIN_TICKET, 31, plugin); // keep in-line with force loading, remove at level 31 + TicketStorage chunkDistanceManager = this.world.getChunkSource().ticketStorage; + chunkDistanceManager.removeTicketIf((ticket) -> ticket.getType() == TicketType.PLUGIN_TICKET && Objects.equals(ticket.key, plugin), null); } @Override public Collection getPluginChunkTickets(int x, int z) { - ChunkMapDistance chunkDistanceManager = this.world.getChunkSource().chunkMap.distanceManager; - ArraySetSorted> tickets = chunkDistanceManager.tickets.get(ChunkCoordIntPair.asLong(x, z)); + TicketStorage chunkDistanceManager = this.world.getChunkSource().ticketStorage; + List tickets = chunkDistanceManager.getTickets(ChunkCoordIntPair.asLong(x, z)); if (tickets == null) { return Collections.emptyList(); } ImmutableList.Builder ret = ImmutableList.builder(); - for (Ticket ticket : tickets) { + for (Ticket ticket : tickets) { if (ticket.getType() == TicketType.PLUGIN_TICKET) { ret.add((Plugin) ticket.key); } @@ -472,14 +470,14 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public Map> getPluginChunkTickets() { Map> ret = new HashMap<>(); - ChunkMapDistance chunkDistanceManager = this.world.getChunkSource().chunkMap.distanceManager; + TicketStorage chunkDistanceManager = this.world.getChunkSource().ticketStorage; - for (Long2ObjectMap.Entry>> chunkTickets : chunkDistanceManager.tickets.long2ObjectEntrySet()) { + for (Long2ObjectMap.Entry> chunkTickets : chunkDistanceManager.tickets.long2ObjectEntrySet()) { long chunkKey = chunkTickets.getLongKey(); - ArraySetSorted> tickets = chunkTickets.getValue(); + List tickets = chunkTickets.getValue(); Chunk chunk = null; - for (Ticket ticket : tickets) { + for (Ticket ticket : tickets) { if (ticket.getType() != TicketType.PLUGIN_TICKET) { continue; } @@ -516,7 +514,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean isChunkForceLoaded(int x, int z) { - return getHandle().getForcedChunks().contains(ChunkCoordIntPair.asLong(x, z)); + return getHandle().getForceLoadedChunks().contains(ChunkCoordIntPair.asLong(x, z)); } @Override @@ -528,7 +526,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { public Collection getForceLoadedChunks() { Set chunks = new HashSet<>(); - for (long coord : getHandle().getForcedChunks()) { + for (long coord : getHandle().getForceLoadedChunks()) { chunks.add(getChunkAt(ChunkCoordIntPair.getX(coord), ChunkCoordIntPair.getZ(coord))); } @@ -599,7 +597,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { arrow = EntityTypes.ARROW.create(world, EntitySpawnReason.COMMAND); } - arrow.moveTo(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); + arrow.snapTo(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); arrow.shoot(velocity.getX(), velocity.getY(), velocity.getZ(), speed, spread); world.addFreshEntity(arrow); return (T) arrow.getBukkitEntity(); @@ -619,7 +617,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { Preconditions.checkArgument(loc != null, "Location cannot be null"); EntityLightning lightning = EntityTypes.LIGHTNING_BOLT.create(world, EntitySpawnReason.COMMAND); - lightning.moveTo(loc.getX(), loc.getY(), loc.getZ()); + lightning.snapTo(loc.getX(), loc.getY(), loc.getZ()); lightning.setVisualOnly(isVisual); world.strikeLightning(lightning, LightningStrikeEvent.Cause.CUSTOM); return (LightningStrike) lightning.getBukkitEntity(); @@ -2029,13 +2027,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { PersistentRaid persistentRaid = world.getRaids(); net.minecraft.world.entity.raid.Raid raid = persistentRaid.getNearbyRaid(CraftLocation.toBlockPosition(location), radius * radius); - return (raid == null) ? null : new CraftRaid(raid); + return (raid == null) ? null : new CraftRaid(raid, world); } @Override public List getRaids() { PersistentRaid persistentRaid = world.getRaids(); - return persistentRaid.raidMap.values().stream().map(CraftRaid::new).collect(Collectors.toList()); + return persistentRaid.raidMap.values().stream().map((raid) -> new CraftRaid(raid, world)).collect(Collectors.toList()); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java index 9f00f709c..c2c4126b3 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -162,8 +162,8 @@ public class Main { } float javaVersion = Float.parseFloat(System.getProperty("java.class.version")); - if (javaVersion > 68.0) { - System.err.println("Unsupported Java detected (" + javaVersion + "). Only up to Java 24 is supported."); + if (javaVersion > 67.0) { + System.err.println("Unsupported Java detected (" + javaVersion + "). Only up to Java 23 is supported."); return; } @@ -190,11 +190,11 @@ public class Main { useConsole = false; } - if (false && Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { + if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { Date buildDate = new Date(Integer.parseInt(Main.class.getPackage().getImplementationVendor()) * 1000L); Calendar deadline = Calendar.getInstance(); - deadline.add(Calendar.DAY_OF_YEAR, -21); + deadline.add(Calendar.DAY_OF_YEAR, -2); if (buildDate.before(deadline.getTime())) { System.err.println("*** Error, this build is outdated ***"); System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***"); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java index e6bc7d5d0..73dfb33c8 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java @@ -6,7 +6,8 @@ import java.util.Collections; import java.util.Optional; import net.minecraft.advancements.critereon.CriterionConditionItem; import net.minecraft.advancements.critereon.CriterionConditionValue; -import net.minecraft.core.component.DataComponentPredicate; +import net.minecraft.advancements.critereon.DataComponentMatchers; +import net.minecraft.core.component.DataComponentExactPredicate; import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.IChatBaseComponent; import net.minecraft.world.ChestLock; @@ -99,7 +100,7 @@ public class CraftBeacon extends CraftBlockEntityState impleme @Override public String getLock() { - Optional customName = this.getSnapshot().lockKey.predicate().components().asPatch().get(DataComponents.CUSTOM_NAME); + Optional customName = this.getSnapshot().lockKey.predicate().components().exact().asPatch().get(DataComponents.CUSTOM_NAME); return (customName != null) ? customName.map(CraftChatMessage::fromComponent).orElse("") : ""; } @@ -109,8 +110,8 @@ public class CraftBeacon extends CraftBlockEntityState impleme if (key == null) { this.getSnapshot().lockKey = ChestLock.NO_LOCK; } else { - DataComponentPredicate predicate = DataComponentPredicate.builder().expect(DataComponents.CUSTOM_NAME, CraftChatMessage.fromStringOrNull(key)).build(); - this.getSnapshot().lockKey = new ChestLock(new CriterionConditionItem(Optional.empty(), CriterionConditionValue.IntegerRange.ANY, predicate, Collections.emptyMap())); + DataComponentExactPredicate predicate = DataComponentExactPredicate.builder().expect(DataComponents.CUSTOM_NAME, CraftChatMessage.fromStringOrNull(key)).build(); + this.getSnapshot().lockKey = new ChestLock(new CriterionConditionItem(Optional.empty(), CriterionConditionValue.IntegerRange.ANY, new DataComponentMatchers(predicate, Collections.emptyMap()))); } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 6ac71753f..df139dd4e 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -204,9 +204,9 @@ public class CraftBlock implements Block { } if (applyPhysics) { - return world.setBlock(position, blockData, 3); + return world.setBlock(position, blockData, net.minecraft.world.level.block.Block.UPDATE_NEIGHBORS | net.minecraft.world.level.block.Block.UPDATE_CLIENTS); } else { - boolean success = world.setBlock(position, blockData, 2 | 16 | 1024); // NOTIFY | NO_OBSERVER | NO_PLACE (custom) + boolean success = world.setBlock(position, blockData, net.minecraft.world.level.block.Block.UPDATE_CLIENTS | net.minecraft.world.level.block.Block.UPDATE_KNOWN_SHAPE | net.minecraft.world.level.block.Block.UPDATE_SKIP_ON_PLACE); // NOTIFY | NO_OBSERVER | NO_PLACE (custom) if (success && world instanceof net.minecraft.world.level.World) { world.getMinecraftWorld().sendBlockUpdated( position, diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java index c683a8305..2cf4b5cce 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java @@ -24,6 +24,8 @@ import net.minecraft.world.level.block.entity.HangingSignBlockEntity; import net.minecraft.world.level.block.entity.SculkCatalystBlockEntity; import net.minecraft.world.level.block.entity.SculkSensorBlockEntity; import net.minecraft.world.level.block.entity.SculkShriekerBlockEntity; +import net.minecraft.world.level.block.entity.TestBlockEntity; +import net.minecraft.world.level.block.entity.TestInstanceBlockEntity; import net.minecraft.world.level.block.entity.TileEntity; import net.minecraft.world.level.block.entity.TileEntityBanner; import net.minecraft.world.level.block.entity.TileEntityBarrel; @@ -347,6 +349,8 @@ public final class CraftBlockStates { register(Material.CRAFTER, CraftCrafter.class, CraftCrafter::new, CrafterBlockEntity::new); register(Material.TRIAL_SPAWNER, CraftTrialSpawner.class, CraftTrialSpawner::new, TrialSpawnerBlockEntity::new); register(Material.VAULT, CraftVault.class, CraftVault::new, VaultBlockEntity::new); + register(Material.TEST_BLOCK, CraftTestBlock.class, CraftTestBlock::new, TestBlockEntity::new); + register(Material.TEST_INSTANCE_BLOCK, CraftTestInstance.class, CraftTestInstance::new, TestInstanceBlockEntity::new); } private static void register(Material blockType, BlockStateFactory factory) { diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java index 75212d999..f7e169c89 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java @@ -4,7 +4,8 @@ import java.util.Collections; import java.util.Optional; import net.minecraft.advancements.critereon.CriterionConditionItem; import net.minecraft.advancements.critereon.CriterionConditionValue; -import net.minecraft.core.component.DataComponentPredicate; +import net.minecraft.advancements.critereon.DataComponentMatchers; +import net.minecraft.core.component.DataComponentExactPredicate; import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.IChatBaseComponent; import net.minecraft.world.ChestLock; @@ -33,7 +34,7 @@ public abstract class CraftContainer extends Craf @Override public String getLock() { - Optional customName = this.getSnapshot().lockKey.predicate().components().asPatch().get(DataComponents.CUSTOM_NAME); + Optional customName = this.getSnapshot().lockKey.predicate().components().exact().asPatch().get(DataComponents.CUSTOM_NAME); return (customName != null) ? customName.map(CraftChatMessage::fromComponent).orElse("") : ""; } @@ -43,8 +44,8 @@ public abstract class CraftContainer extends Craf if (key == null) { this.getSnapshot().lockKey = ChestLock.NO_LOCK; } else { - DataComponentPredicate predicate = DataComponentPredicate.builder().expect(DataComponents.CUSTOM_NAME, CraftChatMessage.fromStringOrNull(key)).build(); - this.getSnapshot().lockKey = new ChestLock(new CriterionConditionItem(Optional.empty(), CriterionConditionValue.IntegerRange.ANY, predicate, Collections.emptyMap())); + DataComponentExactPredicate predicate = DataComponentExactPredicate.builder().expect(DataComponents.CUSTOM_NAME, CraftChatMessage.fromStringOrNull(key)).build(); + this.getSnapshot().lockKey = new ChestLock(new CriterionConditionItem(Optional.empty(), CriterionConditionValue.IntegerRange.ANY, new DataComponentMatchers(predicate, Collections.emptyMap()))); } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java index 334f27ca1..6bda67c2f 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java @@ -11,8 +11,8 @@ import java.util.stream.Collectors; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.InclusiveRange; import net.minecraft.util.RandomSource; -import net.minecraft.util.random.SimpleWeightedRandomList; -import net.minecraft.util.random.WeightedEntry.b; +import net.minecraft.util.random.Weighted; +import net.minecraft.util.random.WeightedList; import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.entity.EquipmentTable; import net.minecraft.world.level.MobSpawnerAbstract; @@ -54,7 +54,7 @@ public class CraftCreatureSpawner extends CraftBlockEntityState builder = SimpleWeightedRandomList.builder(); // PAIL rename Builder - spawner.spawnPotentials.unwrap().forEach(entry -> builder.add(entry.data(), entry.getWeight().asInt())); + WeightedList.a builder = WeightedList.builder(); // PAIL rename Builder + spawner.spawnPotentials.unwrap().forEach(entry -> builder.add(entry.value(), entry.weight())); builder.add(new MobSpawnerData(compoundTag, Optional.ofNullable(toMinecraftRule(spawnRule)), getEquipment(equipment)), weight); spawner.spawnPotentials = builder.build(); } @@ -129,7 +129,7 @@ public class CraftCreatureSpawner extends CraftBlockEntityState entries) { Preconditions.checkArgument(entries != null, "Entries cannot be null"); - SimpleWeightedRandomList.a builder = SimpleWeightedRandomList.builder(); + WeightedList.a builder = WeightedList.builder(); for (SpawnerEntry spawnerEntry : entries) { NBTTagCompound compoundTag = ((CraftEntitySnapshot) spawnerEntry.getSnapshot()).getData(); builder.add(new MobSpawnerData(compoundTag, Optional.ofNullable(toMinecraftRule(spawnerEntry.getSpawnRule())), getEquipment(spawnerEntry.getEquipment())), spawnerEntry.getSpawnWeight()); @@ -145,12 +145,12 @@ public class CraftCreatureSpawner extends CraftBlockEntityState getPotentialSpawns(MobSpawnerAbstract spawner) { List entries = new ArrayList<>(); - for (b entry : spawner.spawnPotentials.unwrap()) { // PAIL rename Wrapper - CraftEntitySnapshot snapshot = CraftEntitySnapshot.create(entry.data().getEntityToSpawn()); + for (Weighted entry : spawner.spawnPotentials.unwrap()) { + CraftEntitySnapshot snapshot = CraftEntitySnapshot.create(entry.value().getEntityToSpawn()); if (snapshot != null) { - SpawnRule rule = entry.data().customSpawnRules().map(CraftCreatureSpawner::fromMinecraftRule).orElse(null); - entries.add(new SpawnerEntry(snapshot, entry.getWeight().asInt(), rule, getEquipment(entry.data().equipment()))); + SpawnRule rule = entry.value().customSpawnRules().map(CraftCreatureSpawner::fromMinecraftRule).orElse(null); + entries.add(new SpawnerEntry(snapshot, entry.weight(), rule, getEquipment(entry.value().equipment()))); } } return entries; diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftTestBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftTestBlock.java new file mode 100644 index 000000000..b0c1ed37d --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftTestBlock.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block; + +import net.minecraft.world.level.block.entity.TestBlockEntity; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.TestBlock; + +public class CraftTestBlock extends CraftBlockEntityState implements TestBlock { + + public CraftTestBlock(World world, TestBlockEntity tileEntity) { + super(world, tileEntity); + } + + protected CraftTestBlock(CraftTestBlock state, Location location) { + super(state, location); + } + + @Override + public CraftTestBlock copy() { + return new CraftTestBlock(this, null); + } + + @Override + public CraftTestBlock copy(Location location) { + return new CraftTestBlock(this, location); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftTestInstance.java b/src/main/java/org/bukkit/craftbukkit/block/CraftTestInstance.java new file mode 100644 index 000000000..3f54a4e94 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftTestInstance.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block; + +import net.minecraft.world.level.block.entity.TestInstanceBlockEntity; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.TestInstance; + +public class CraftTestInstance extends CraftBlockEntityState implements TestInstance { + + public CraftTestInstance(World world, TestInstanceBlockEntity tileEntity) { + super(world, tileEntity); + } + + protected CraftTestInstance(CraftTestInstance state, Location location) { + super(state, location); + } + + @Override + public CraftTestInstance copy() { + return new CraftTestInstance(this, null); + } + + @Override + public CraftTestInstance copy(Location location) { + return new CraftTestInstance(this, location); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftTrialSpawnerConfiguration.java b/src/main/java/org/bukkit/craftbukkit/block/CraftTrialSpawnerConfiguration.java index 0062664cf..b121b4e93 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftTrialSpawnerConfiguration.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftTrialSpawnerConfiguration.java @@ -10,8 +10,8 @@ import java.util.Optional; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.resources.ResourceKey; -import net.minecraft.util.random.SimpleWeightedRandomList; -import net.minecraft.util.random.WeightedEntry.b; +import net.minecraft.util.random.Weighted; +import net.minecraft.util.random.WeightedList; import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.level.MobSpawnerData; import net.minecraft.world.level.block.entity.TrialSpawnerBlockEntity; @@ -36,8 +36,8 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration private float totalMobsAddedPerPlayer; private float simultaneousMobsAddedPerPlayer; private int ticksBetweenSpawn; - private SimpleWeightedRandomList spawnPotentialsDefinition; - private SimpleWeightedRandomList> lootTablesToEject; + private WeightedList spawnPotentialsDefinition; + private WeightedList> lootTablesToEject; private ResourceKey itemsToDropWhenOminous; public CraftTrialSpawnerConfiguration(TrialSpawnerConfig minecraft, TrialSpawnerBlockEntity snapshot) { @@ -60,7 +60,7 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration return null; } - Optional> type = EntityTypes.by(spawnPotentialsDefinition.unwrap().get(0).data().getEntityToSpawn()); + Optional> type = EntityTypes.by(spawnPotentialsDefinition.unwrap().get(0).value().getEntityToSpawn()); return type.map(CraftEntityType::minecraftToBukkit).orElse(null); } @@ -68,7 +68,7 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration public void setSpawnedType(EntityType entityType) { if (entityType == null) { getTrialData().nextSpawnData = Optional.empty(); - spawnPotentialsDefinition = SimpleWeightedRandomList.empty(); // need clear the spawnPotentials to avoid nextSpawnData being replaced later + spawnPotentialsDefinition = WeightedList.of(); // need clear the spawnPotentials to avoid nextSpawnData being replaced later return; } Preconditions.checkArgument(entityType != EntityType.UNKNOWN, "Can't spawn EntityType %s from mob spawners!", entityType); @@ -76,7 +76,7 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration MobSpawnerData data = new MobSpawnerData(); data.getEntityToSpawn().putString("id", BuiltInRegistries.ENTITY_TYPE.getKey(CraftEntityType.bukkitToMinecraft(entityType)).toString()); getTrialData().nextSpawnData = Optional.of(data); - spawnPotentialsDefinition = SimpleWeightedRandomList.single(data); + spawnPotentialsDefinition = WeightedList.of(data); } @Override @@ -143,12 +143,12 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration @Override public EntitySnapshot getSpawnedEntity() { - SimpleWeightedRandomList potentials = spawnPotentialsDefinition; + WeightedList potentials = spawnPotentialsDefinition; if (potentials.isEmpty()) { return null; } - return CraftEntitySnapshot.create(potentials.unwrap().get(0).data().getEntityToSpawn()); + return CraftEntitySnapshot.create(potentials.unwrap().get(0).value().getEntityToSpawn()); } @Override @@ -166,7 +166,7 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration private void setSpawnedEntity(EntitySnapshot snapshot, SpawnRule spawnRule, SpawnerEntry.Equipment equipment) { if (snapshot == null) { getTrialData().nextSpawnData = Optional.empty(); - spawnPotentialsDefinition = SimpleWeightedRandomList.empty(); // need clear the spawnPotentials to avoid nextSpawnData being replaced later + spawnPotentialsDefinition = WeightedList.of(); // need clear the spawnPotentials to avoid nextSpawnData being replaced later return; } @@ -174,7 +174,7 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration MobSpawnerData data = new MobSpawnerData(compoundTag, Optional.ofNullable(CraftCreatureSpawner.toMinecraftRule(spawnRule)), CraftCreatureSpawner.getEquipment(equipment)); getTrialData().nextSpawnData = Optional.of(data); - spawnPotentialsDefinition = SimpleWeightedRandomList.single(data); + spawnPotentialsDefinition = WeightedList.of(data); } @Override @@ -187,8 +187,8 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration NBTTagCompound compoundTag = ((CraftEntitySnapshot) snapshot).getData(); - SimpleWeightedRandomList.a builder = SimpleWeightedRandomList.builder(); // PAIL rename Builder - spawnPotentialsDefinition.unwrap().forEach(entry -> builder.add(entry.data(), entry.getWeight().asInt())); + WeightedList.a builder = WeightedList.builder(); // PAIL rename Builder + spawnPotentialsDefinition.unwrap().forEach(entry -> builder.add(entry.value(), entry.weight())); builder.add(new MobSpawnerData(compoundTag, Optional.ofNullable(CraftCreatureSpawner.toMinecraftRule(spawnRule)), CraftCreatureSpawner.getEquipment(equipment)), weight); spawnPotentialsDefinition = builder.build(); } @@ -204,7 +204,7 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration public void setPotentialSpawns(Collection entries) { Preconditions.checkArgument(entries != null, "Entries cannot be null"); - SimpleWeightedRandomList.a builder = SimpleWeightedRandomList.builder(); + WeightedList.a builder = WeightedList.builder(); for (SpawnerEntry spawnerEntry : entries) { NBTTagCompound compoundTag = ((CraftEntitySnapshot) spawnerEntry.getSnapshot()).getData(); builder.add(new MobSpawnerData(compoundTag, Optional.ofNullable(CraftCreatureSpawner.toMinecraftRule(spawnerEntry.getSpawnRule())), CraftCreatureSpawner.getEquipment(spawnerEntry.getEquipment())), spawnerEntry.getSpawnWeight()); @@ -216,12 +216,12 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration public List getPotentialSpawns() { List entries = new ArrayList<>(); - for (b entry : spawnPotentialsDefinition.unwrap()) { // PAIL rename Wrapper - CraftEntitySnapshot snapshot = CraftEntitySnapshot.create(entry.data().getEntityToSpawn()); + for (Weighted entry : spawnPotentialsDefinition.unwrap()) { + CraftEntitySnapshot snapshot = CraftEntitySnapshot.create(entry.value().getEntityToSpawn()); if (snapshot != null) { - SpawnRule rule = entry.data().customSpawnRules().map(CraftCreatureSpawner::fromMinecraftRule).orElse(null); - entries.add(new SpawnerEntry(snapshot, entry.getWeight().asInt(), rule)); + SpawnRule rule = entry.value().customSpawnRules().map(CraftCreatureSpawner::fromMinecraftRule).orElse(null); + entries.add(new SpawnerEntry(snapshot, entry.weight(), rule)); } } return entries; @@ -231,10 +231,10 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration public Map getPossibleRewards() { Map tables = new HashMap<>(); - for (b> entry : lootTablesToEject.unwrap()) { - LootTable table = CraftLootTable.minecraftToBukkit(entry.data()); + for (Weighted> entry : lootTablesToEject.unwrap()) { + LootTable table = CraftLootTable.minecraftToBukkit(entry.value()); if (table != null) { - tables.put(table, entry.getWeight().asInt()); + tables.put(table, entry.weight()); } } @@ -246,8 +246,8 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration Preconditions.checkArgument(table != null, "Table cannot be null"); Preconditions.checkArgument(weight >= 1, "Weight must be at least 1"); - SimpleWeightedRandomList.a> builder = SimpleWeightedRandomList.builder(); - lootTablesToEject.unwrap().forEach(entry -> builder.add(entry.data(), entry.getWeight().asInt())); + WeightedList.a> builder = WeightedList.builder(); + lootTablesToEject.unwrap().forEach(entry -> builder.add(entry.value(), entry.weight())); builder.add(CraftLootTable.bukkitToMinecraft(table), weight); lootTablesToEject = builder.build(); } @@ -257,11 +257,11 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration Preconditions.checkArgument(table != null, "Key cannot be null"); ResourceKey minecraftKey = CraftLootTable.bukkitToMinecraft(table); - SimpleWeightedRandomList.a> builder = SimpleWeightedRandomList.builder(); + WeightedList.a> builder = WeightedList.builder(); - for (b> entry : lootTablesToEject.unwrap()) { - if (!entry.data().equals(minecraftKey)) { - builder.add(entry.data(), entry.getWeight().asInt()); + for (Weighted> entry : lootTablesToEject.unwrap()) { + if (!entry.value().equals(minecraftKey)) { + builder.add(entry.value(), entry.weight()); } } lootTablesToEject = builder.build(); @@ -270,11 +270,11 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration @Override public void setPossibleRewards(Map rewards) { if (rewards == null || rewards.isEmpty()) { - lootTablesToEject = SimpleWeightedRandomList.empty(); + lootTablesToEject = WeightedList.of(); return; } - SimpleWeightedRandomList.a> builder = SimpleWeightedRandomList.builder(); + WeightedList.a> builder = WeightedList.builder(); rewards.forEach((table, weight) -> { Preconditions.checkArgument(table != null, "Table cannot be null"); Preconditions.checkArgument(weight >= 1, "Weight must be at least 1"); diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java index 1177b36af..e4ab3e682 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java +++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java @@ -432,7 +432,6 @@ public class CraftBlockData implements BlockData { register(net.minecraft.world.level.block.BlockKelp.class, org.bukkit.craftbukkit.block.impl.CraftKelp::new); register(net.minecraft.world.level.block.BlockLadder.class, org.bukkit.craftbukkit.block.impl.CraftLadder::new); register(net.minecraft.world.level.block.BlockLantern.class, org.bukkit.craftbukkit.block.impl.CraftLantern::new); - register(net.minecraft.world.level.block.BlockLeaves.class, org.bukkit.craftbukkit.block.impl.CraftLeaves::new); register(net.minecraft.world.level.block.BlockLectern.class, org.bukkit.craftbukkit.block.impl.CraftLectern::new); register(net.minecraft.world.level.block.BlockLever.class, org.bukkit.craftbukkit.block.impl.CraftLever::new); register(net.minecraft.world.level.block.BlockLoom.class, org.bukkit.craftbukkit.block.impl.CraftLoom::new); @@ -504,12 +503,14 @@ public class CraftBlockData implements BlockData { register(net.minecraft.world.level.block.CrafterBlock.class, org.bukkit.craftbukkit.block.impl.CraftCrafter::new); register(net.minecraft.world.level.block.CreakingHeartBlock.class, org.bukkit.craftbukkit.block.impl.CraftCreakingHeart::new); register(net.minecraft.world.level.block.DecoratedPotBlock.class, org.bukkit.craftbukkit.block.impl.CraftDecoratedPot::new); + register(net.minecraft.world.level.block.FlowerBedBlock.class, org.bukkit.craftbukkit.block.impl.CraftFlowerBed::new); register(net.minecraft.world.level.block.GlowLichenBlock.class, org.bukkit.craftbukkit.block.impl.CraftGlowLichen::new); register(net.minecraft.world.level.block.HangingMossBlock.class, org.bukkit.craftbukkit.block.impl.CraftHangingMoss::new); register(net.minecraft.world.level.block.HangingRootsBlock.class, org.bukkit.craftbukkit.block.impl.CraftHangingRoots::new); register(net.minecraft.world.level.block.HeavyCoreBlock.class, org.bukkit.craftbukkit.block.impl.CraftHeavyCore::new); register(net.minecraft.world.level.block.InfestedRotatedPillarBlock.class, org.bukkit.craftbukkit.block.impl.CraftInfestedRotatedPillar::new); register(net.minecraft.world.level.block.LayeredCauldronBlock.class, org.bukkit.craftbukkit.block.impl.CraftLayeredCauldron::new); + register(net.minecraft.world.level.block.LeafLitterBlock.class, org.bukkit.craftbukkit.block.impl.CraftLeafLitter::new); register(net.minecraft.world.level.block.LightBlock.class, org.bukkit.craftbukkit.block.impl.CraftLight::new); register(net.minecraft.world.level.block.LightningRodBlock.class, org.bukkit.craftbukkit.block.impl.CraftLightningRod::new); register(net.minecraft.world.level.block.MangroveLeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangroveLeaves::new); @@ -517,9 +518,7 @@ public class CraftBlockData implements BlockData { register(net.minecraft.world.level.block.MangroveRootsBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangroveRoots::new); register(net.minecraft.world.level.block.MossyCarpetBlock.class, org.bukkit.craftbukkit.block.impl.CraftMossyCarpet::new); register(net.minecraft.world.level.block.MultifaceBlock.class, org.bukkit.craftbukkit.block.impl.CraftMultiface::new); - register(net.minecraft.world.level.block.ParticleLeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftParticleLeaves::new); register(net.minecraft.world.level.block.PiglinWallSkullBlock.class, org.bukkit.craftbukkit.block.impl.CraftPiglinWallSkull::new); - register(net.minecraft.world.level.block.PinkPetalsBlock.class, org.bukkit.craftbukkit.block.impl.CraftPinkPetals::new); register(net.minecraft.world.level.block.PitcherCropBlock.class, org.bukkit.craftbukkit.block.impl.CraftPitcherCrop::new); register(net.minecraft.world.level.block.PointedDripstoneBlock.class, org.bukkit.craftbukkit.block.impl.CraftPointedDripstone::new); register(net.minecraft.world.level.block.SculkCatalystBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkCatalyst::new); @@ -529,8 +528,11 @@ public class CraftBlockData implements BlockData { register(net.minecraft.world.level.block.SmallDripleafBlock.class, org.bukkit.craftbukkit.block.impl.CraftSmallDripleaf::new); register(net.minecraft.world.level.block.SnifferEggBlock.class, org.bukkit.craftbukkit.block.impl.CraftSnifferEgg::new); register(net.minecraft.world.level.block.TallSeagrassBlock.class, org.bukkit.craftbukkit.block.impl.CraftTallSeagrass::new); + register(net.minecraft.world.level.block.TestBlock.class, org.bukkit.craftbukkit.block.impl.CraftTest::new); + register(net.minecraft.world.level.block.TintedParticleLeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftTintedParticleLeaves::new); register(net.minecraft.world.level.block.TorchflowerCropBlock.class, org.bukkit.craftbukkit.block.impl.CraftTorchflowerCrop::new); register(net.minecraft.world.level.block.TrialSpawnerBlock.class, org.bukkit.craftbukkit.block.impl.CraftTrialSpawner::new); + register(net.minecraft.world.level.block.UntintedParticleLeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftUntintedParticleLeaves::new); register(net.minecraft.world.level.block.VaultBlock.class, org.bukkit.craftbukkit.block.impl.CraftVault::new); register(net.minecraft.world.level.block.WallHangingSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftWallHangingSign::new); register(net.minecraft.world.level.block.WaterloggedTransparentBlock.class, org.bukkit.craftbukkit.block.impl.CraftWaterloggedTransparent::new); diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCreakingHeart.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCreakingHeart.java index 1dd3689f2..d51b983a5 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCreakingHeart.java +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCreakingHeart.java @@ -5,17 +5,17 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData; public abstract class CraftCreakingHeart extends CraftBlockData implements CreakingHeart { - private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean ACTIVE = getBoolean("active"); + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum CREAKING_HEART_STATE = getEnum("creaking_heart_state"); private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean NATURAL = getBoolean("natural"); @Override public boolean isActive() { - return get(ACTIVE); + return getCreakingHeartState() == State.AWAKE; } @Override public void setActive(boolean active) { - set(ACTIVE, active); + setCreakingHeartState(State.AWAKE); } @Override @@ -27,4 +27,14 @@ public abstract class CraftCreakingHeart extends CraftBlockData implements Creak public void setNatural(boolean natural) { set(NATURAL, natural); } + + @Override + public org.bukkit.block.data.type.CreakingHeart.State getCreakingHeartState() { + return get(CREAKING_HEART_STATE, org.bukkit.block.data.type.CreakingHeart.State.class); + } + + @Override + public void setCreakingHeartState(org.bukkit.block.data.type.CreakingHeart.State state) { + set(CREAKING_HEART_STATE, state); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPinkPetals.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftFlowerBed.java similarity index 80% rename from src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPinkPetals.java rename to src/main/java/org/bukkit/craftbukkit/block/data/type/CraftFlowerBed.java index cbf3f5cb9..a2fd14450 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPinkPetals.java +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftFlowerBed.java @@ -1,9 +1,9 @@ package org.bukkit.craftbukkit.block.data.type; -import org.bukkit.block.data.type.PinkPetals; +import org.bukkit.block.data.type.FlowerBed; import org.bukkit.craftbukkit.block.data.CraftBlockData; -public abstract class CraftPinkPetals extends CraftBlockData implements PinkPetals { +public abstract class CraftFlowerBed extends CraftBlockData implements FlowerBed { private static final net.minecraft.world.level.block.state.properties.BlockStateInteger FLOWER_AMOUNT = getInteger("flower_amount"); diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftLeafLitter.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftLeafLitter.java new file mode 100644 index 000000000..f834348ef --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftLeafLitter.java @@ -0,0 +1,24 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.LeafLitter; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftLeafLitter extends CraftBlockData implements LeafLitter { + + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger SEGMENT_AMOUNT = getInteger("segment_amount"); + + @Override + public int getSegmentAmount() { + return get(SEGMENT_AMOUNT); + } + + @Override + public void setSegmentAmount(int segment_amount) { + set(SEGMENT_AMOUNT, segment_amount); + } + + @Override + public int getMaximumSegmentAmount() { + return getMax(SEGMENT_AMOUNT); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTestBlock.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTestBlock.java new file mode 100644 index 000000000..5ef377d36 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTestBlock.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.TestBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftTestBlock extends CraftBlockData implements TestBlock { + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum MODE = getEnum("mode"); + + @Override + public org.bukkit.block.data.type.TestBlock.Mode getMode() { + return get(MODE, org.bukkit.block.data.type.TestBlock.Mode.class); + } + + @Override + public void setMode(org.bukkit.block.data.type.TestBlock.Mode mode) { + set(MODE, mode); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCreakingHeart.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCreakingHeart.java index 11f73f3de..faff36c10 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCreakingHeart.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCreakingHeart.java @@ -15,17 +15,17 @@ public final class CraftCreakingHeart extends org.bukkit.craftbukkit.block.data. // org.bukkit.craftbukkit.block.data.type.CraftCreakingHeart - private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean ACTIVE = getBoolean(net.minecraft.world.level.block.CreakingHeartBlock.class, "active"); + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum CREAKING_HEART_STATE = getEnum(net.minecraft.world.level.block.CreakingHeartBlock.class, "creaking_heart_state"); private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean NATURAL = getBoolean(net.minecraft.world.level.block.CreakingHeartBlock.class, "natural"); @Override public boolean isActive() { - return get(ACTIVE); + return getCreakingHeartState() == State.AWAKE; } @Override public void setActive(boolean active) { - set(ACTIVE, active); + setCreakingHeartState(State.AWAKE); } @Override @@ -38,6 +38,16 @@ public final class CraftCreakingHeart extends org.bukkit.craftbukkit.block.data. set(NATURAL, natural); } + @Override + public org.bukkit.block.data.type.CreakingHeart.State getCreakingHeartState() { + return get(CREAKING_HEART_STATE, org.bukkit.block.data.type.CreakingHeart.State.class); + } + + @Override + public void setCreakingHeartState(org.bukkit.block.data.type.CreakingHeart.State state) { + set(CREAKING_HEART_STATE, state); + } + // org.bukkit.craftbukkit.block.data.CraftOrientable private static final net.minecraft.world.level.block.state.properties.BlockStateEnum AXIS = getEnum(net.minecraft.world.level.block.CreakingHeartBlock.class, "axis"); diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPinkPetals.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFlowerBed.java similarity index 70% rename from src/main/java/org/bukkit/craftbukkit/block/impl/CraftPinkPetals.java rename to src/main/java/org/bukkit/craftbukkit/block/impl/CraftFlowerBed.java index 7d3bc82e7..55f5075b1 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPinkPetals.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFlowerBed.java @@ -3,19 +3,19 @@ */ package org.bukkit.craftbukkit.block.impl; -public final class CraftPinkPetals extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.PinkPetals, org.bukkit.block.data.Directional { +public final class CraftFlowerBed extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.PinkPetals, org.bukkit.block.data.type.FlowerBed, org.bukkit.block.data.Directional { - public CraftPinkPetals() { + public CraftFlowerBed() { super(); } - public CraftPinkPetals(net.minecraft.world.level.block.state.IBlockData state) { + public CraftFlowerBed(net.minecraft.world.level.block.state.IBlockData state) { super(state); } - // org.bukkit.craftbukkit.block.data.type.CraftPinkPetals + // org.bukkit.craftbukkit.block.data.type.CraftFlowerBed - private static final net.minecraft.world.level.block.state.properties.BlockStateInteger FLOWER_AMOUNT = getInteger(net.minecraft.world.level.block.PinkPetalsBlock.class, "flower_amount"); + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger FLOWER_AMOUNT = getInteger(net.minecraft.world.level.block.FlowerBedBlock.class, "flower_amount"); @Override public int getFlowerAmount() { @@ -34,7 +34,7 @@ public final class CraftPinkPetals extends org.bukkit.craftbukkit.block.data.Cra // org.bukkit.craftbukkit.block.data.CraftDirectional - private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACING = getEnum(net.minecraft.world.level.block.PinkPetalsBlock.class, "facing"); + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACING = getEnum(net.minecraft.world.level.block.FlowerBedBlock.class, "facing"); @Override public org.bukkit.block.BlockFace getFacing() { diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLeafLitter.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLeafLitter.java new file mode 100644 index 000000000..36c480d77 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLeafLitter.java @@ -0,0 +1,53 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftLeafLitter extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.LeafLitter, org.bukkit.block.data.Directional { + + public CraftLeafLitter() { + super(); + } + + public CraftLeafLitter(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftLeafLitter + + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger SEGMENT_AMOUNT = getInteger(net.minecraft.world.level.block.LeafLitterBlock.class, "segment_amount"); + + @Override + public int getSegmentAmount() { + return get(SEGMENT_AMOUNT); + } + + @Override + public void setSegmentAmount(int segment_amount) { + set(SEGMENT_AMOUNT, segment_amount); + } + + @Override + public int getMaximumSegmentAmount() { + return getMax(SEGMENT_AMOUNT); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACING = getEnum(net.minecraft.world.level.block.LeafLitterBlock.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTest.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTest.java new file mode 100644 index 000000000..f6200b62d --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTest.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftTest extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.TestBlock { + + public CraftTest() { + super(); + } + + public CraftTest(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftTestBlock + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum MODE = getEnum(net.minecraft.world.level.block.TestBlock.class, "mode"); + + @Override + public org.bukkit.block.data.type.TestBlock.Mode getMode() { + return get(MODE, org.bukkit.block.data.type.TestBlock.Mode.class); + } + + @Override + public void setMode(org.bukkit.block.data.type.TestBlock.Mode mode) { + set(MODE, mode); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftParticleLeaves.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTintedParticleLeaves.java similarity index 70% rename from src/main/java/org/bukkit/craftbukkit/block/impl/CraftParticleLeaves.java rename to src/main/java/org/bukkit/craftbukkit/block/impl/CraftTintedParticleLeaves.java index 5d0822c46..02f08175c 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftParticleLeaves.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTintedParticleLeaves.java @@ -3,20 +3,20 @@ */ package org.bukkit.craftbukkit.block.impl; -public final class CraftParticleLeaves extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Leaves, org.bukkit.block.data.Waterlogged { +public final class CraftTintedParticleLeaves extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Leaves, org.bukkit.block.data.Waterlogged { - public CraftParticleLeaves() { + public CraftTintedParticleLeaves() { super(); } - public CraftParticleLeaves(net.minecraft.world.level.block.state.IBlockData state) { + public CraftTintedParticleLeaves(net.minecraft.world.level.block.state.IBlockData state) { super(state); } // org.bukkit.craftbukkit.block.data.type.CraftLeaves - private static final net.minecraft.world.level.block.state.properties.BlockStateInteger DISTANCE = getInteger(net.minecraft.world.level.block.ParticleLeavesBlock.class, "distance"); - private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean PERSISTENT = getBoolean(net.minecraft.world.level.block.ParticleLeavesBlock.class, "persistent"); + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger DISTANCE = getInteger(net.minecraft.world.level.block.TintedParticleLeavesBlock.class, "distance"); + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean PERSISTENT = getBoolean(net.minecraft.world.level.block.TintedParticleLeavesBlock.class, "persistent"); @Override public boolean isPersistent() { @@ -40,7 +40,7 @@ public final class CraftParticleLeaves extends org.bukkit.craftbukkit.block.data // org.bukkit.craftbukkit.block.data.CraftWaterlogged - private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.ParticleLeavesBlock.class, "waterlogged"); + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.TintedParticleLeavesBlock.class, "waterlogged"); @Override public boolean isWaterlogged() { diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftUntintedParticleLeaves.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftUntintedParticleLeaves.java new file mode 100644 index 000000000..aaba21795 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftUntintedParticleLeaves.java @@ -0,0 +1,54 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftUntintedParticleLeaves extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Leaves, org.bukkit.block.data.Waterlogged { + + public CraftUntintedParticleLeaves() { + super(); + } + + public CraftUntintedParticleLeaves(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftLeaves + + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger DISTANCE = getInteger(net.minecraft.world.level.block.UntintedParticleLeavesBlock.class, "distance"); + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean PERSISTENT = getBoolean(net.minecraft.world.level.block.UntintedParticleLeavesBlock.class, "persistent"); + + @Override + public boolean isPersistent() { + return get(PERSISTENT); + } + + @Override + public void setPersistent(boolean persistent) { + set(PERSISTENT, persistent); + } + + @Override + public int getDistance() { + return get(DISTANCE); + } + + @Override + public void setDistance(int distance) { + set(DISTANCE, distance); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.UntintedParticleLeavesBlock.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java index 7bf1fa554..8e8e1b0ad 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java @@ -29,7 +29,7 @@ public class CraftAbstractArrow extends CraftProjectile implements AbstractArrow @Override public double getDamage() { - return getHandle().getBaseDamage(); + return getHandle().baseDamage; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractCow.java new file mode 100644 index 000000000..bf55aafbf --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractCow.java @@ -0,0 +1,11 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.world.entity.animal.AbstractCow; +import org.bukkit.craftbukkit.CraftServer; + +public abstract class CraftAbstractCow extends CraftAnimals { + + public CraftAbstractCow(CraftServer server, AbstractCow entity) { + super(server, entity); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java index 830e84f3b..58f9f27fd 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java @@ -2,6 +2,8 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; import java.util.UUID; +import net.minecraft.world.entity.EntityLiving; +import net.minecraft.world.entity.EntityReference; import net.minecraft.world.entity.ai.attributes.GenericAttributes; import net.minecraft.world.entity.animal.horse.EntityHorseAbstract; import org.bukkit.craftbukkit.CraftServer; @@ -89,11 +91,12 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac } public UUID getOwnerUUID() { - return getHandle().getOwnerUUID(); + EntityReference owner = getHandle().getOwnerReference(); + return (owner != null) ? owner.getUUID() : null; } public void setOwnerUUID(UUID uuid) { - getHandle().setOwnerUUID(uuid); + getHandle().owner = (uuid != null) ? new EntityReference<>(uuid) : null; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java index 33f8cd2c8..e8c1f3e56 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java @@ -185,9 +185,9 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand { private static EulerAngle fromNMS(Vector3f old) { return new EulerAngle( - Math.toRadians(old.getX()), - Math.toRadians(old.getY()), - Math.toRadians(old.getZ()) + Math.toRadians(old.x()), + Math.toRadians(old.y()), + Math.toRadians(old.z()) ); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java index 0cd521678..0f69d4a34 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java @@ -1,7 +1,15 @@ package org.bukkit.craftbukkit.entity; +import com.google.common.base.Preconditions; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.entity.animal.ChickenVariant; import net.minecraft.world.entity.animal.EntityChicken; +import org.bukkit.NamespacedKey; +import org.bukkit.Registry; +import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.registry.CraftRegistryItem; import org.bukkit.entity.Chicken; public class CraftChicken extends CraftAnimals implements Chicken { @@ -19,4 +27,44 @@ public class CraftChicken extends CraftAnimals implements Chicken { public String toString() { return "CraftChicken"; } + + @Override + public Chicken.Variant getVariant() { + return CraftChicken.CraftVariant.minecraftHolderToBukkit(getHandle().getVariant()); + } + + @Override + public void setVariant(Chicken.Variant variant) { + Preconditions.checkArgument(variant != null, "variant"); + + getHandle().setVariant(CraftChicken.CraftVariant.bukkitToMinecraftHolder(variant)); + } + + public static class CraftVariant extends CraftRegistryItem implements Chicken.Variant { + + public static Chicken.Variant minecraftToBukkit(ChickenVariant minecraft) { + return CraftRegistry.minecraftToBukkit(minecraft, Registries.CHICKEN_VARIANT, Registry.CHICKEN_VARIANT); + } + + public static Chicken.Variant minecraftHolderToBukkit(Holder minecraft) { + return minecraftToBukkit(minecraft.value()); + } + + public static ChickenVariant bukkitToMinecraft(Chicken.Variant bukkit) { + return CraftRegistry.bukkitToMinecraft(bukkit); + } + + public static Holder bukkitToMinecraftHolder(Chicken.Variant bukkit) { + return CraftRegistry.bukkitToMinecraftHolder(bukkit, Registries.CHICKEN_VARIANT); + } + + public CraftVariant(NamespacedKey key, Holder handle) { + super(key, handle); + } + + @Override + public NamespacedKey getKey() { + return getKeyOrThrow(); + } + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java index ac0143a69..7b5979897 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java @@ -1,10 +1,18 @@ package org.bukkit.craftbukkit.entity; +import com.google.common.base.Preconditions; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.entity.animal.CowVariant; import net.minecraft.world.entity.animal.EntityCow; +import org.bukkit.NamespacedKey; +import org.bukkit.Registry; +import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.registry.CraftRegistryItem; import org.bukkit.entity.Cow; -public class CraftCow extends CraftAnimals implements Cow { +public class CraftCow extends CraftAbstractCow implements Cow { public CraftCow(CraftServer server, EntityCow entity) { super(server, entity); @@ -19,4 +27,44 @@ public class CraftCow extends CraftAnimals implements Cow { public String toString() { return "CraftCow"; } + + @Override + public Cow.Variant getVariant() { + return CraftVariant.minecraftHolderToBukkit(getHandle().getVariant()); + } + + @Override + public void setVariant(Cow.Variant variant) { + Preconditions.checkArgument(variant != null, "variant"); + + getHandle().setVariant(CraftVariant.bukkitToMinecraftHolder(variant)); + } + + public static class CraftVariant extends CraftRegistryItem implements Cow.Variant { + + public static Cow.Variant minecraftToBukkit(CowVariant minecraft) { + return CraftRegistry.minecraftToBukkit(minecraft, Registries.COW_VARIANT, Registry.COW_VARIANT); + } + + public static Cow.Variant minecraftHolderToBukkit(Holder minecraft) { + return minecraftToBukkit(minecraft.value()); + } + + public static CowVariant bukkitToMinecraft(Cow.Variant bukkit) { + return CraftRegistry.bukkitToMinecraft(bukkit); + } + + public static Holder bukkitToMinecraftHolder(Cow.Variant bukkit) { + return CraftRegistry.bukkitToMinecraftHolder(bukkit, Registries.COW_VARIANT); + } + + public CraftVariant(NamespacedKey key, Holder handle) { + super(key, handle); + } + + @Override + public NamespacedKey getKey() { + return getKeyOrThrow(); + } + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 1ffd11527..209753f0b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -210,7 +210,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } // entity.setLocation() throws no event, and so cannot be cancelled - entity.absMoveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + entity.absSnapTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); // SPIGOT-619: Force sync head rotation also entity.setYHeadRot(location.getYaw()); @@ -385,7 +385,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public float getFallDistance() { - return getHandle().fallDistance; + return (float) getHandle().fallDistance; } @Override @@ -790,7 +790,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return null; } - return tag.getAsString(); + return tag.toString(); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityFactory.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityFactory.java index caa492d9b..76c53b750 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityFactory.java @@ -25,7 +25,7 @@ public class CraftEntityFactory implements EntityFactory { NBTTagCompound tag; try { - tag = MojangsonParser.parseTag(input); + tag = MojangsonParser.parseCompoundFully(input); } catch (CommandSyntaxException e) { throw new IllegalArgumentException("Could not parse Entity: " + input, e); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntitySnapshot.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntitySnapshot.java index b3409ee18..21eddb41d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntitySnapshot.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntitySnapshot.java @@ -45,7 +45,7 @@ public class CraftEntitySnapshot implements EntitySnapshot { @Override public String getAsString() { - return data.getAsString(); + return data.toString(); } private net.minecraft.world.entity.Entity createInternal(World world) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java index 77e1c6da7..5a51b4d44 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java @@ -29,6 +29,8 @@ import net.minecraft.world.entity.projectile.EntityFireball; import net.minecraft.world.entity.projectile.EntityFireworks; import net.minecraft.world.entity.projectile.EntityPotion; import net.minecraft.world.entity.projectile.EntitySnowball; +import net.minecraft.world.entity.projectile.ThrownLingeringPotion; +import net.minecraft.world.entity.projectile.ThrownSplashPotion; import net.minecraft.world.entity.vehicle.EntityMinecartAbstract; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -125,6 +127,7 @@ import org.bukkit.entity.ItemFrame; import org.bukkit.entity.LargeFireball; import org.bukkit.entity.LeashHitch; import org.bukkit.entity.LightningStrike; +import org.bukkit.entity.LingeringPotion; import org.bukkit.entity.Llama; import org.bukkit.entity.LlamaSpit; import org.bukkit.entity.MagmaCube; @@ -161,6 +164,7 @@ import org.bukkit.entity.Snowball; import org.bukkit.entity.Snowman; import org.bukkit.entity.SpectralArrow; import org.bukkit.entity.Spider; +import org.bukkit.entity.SplashPotion; import org.bukkit.entity.Squid; import org.bukkit.entity.Stray; import org.bukkit.entity.Strider; @@ -168,7 +172,6 @@ import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.Tadpole; import org.bukkit.entity.TextDisplay; import org.bukkit.entity.ThrownExpBottle; -import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.TraderLlama; import org.bukkit.entity.Trident; import org.bukkit.entity.TropicalFish; @@ -253,11 +256,11 @@ public final class CraftEntityTypes { private static final BiConsumer POS = (spawnData, entity) -> entity.setPos(spawnData.x(), spawnData.y(), spawnData.z()); private static final BiConsumer ABS_MOVE = (spawnData, entity) -> { - entity.absMoveTo(spawnData.x(), spawnData.y(), spawnData.z(), spawnData.yaw(), spawnData.pitch()); + entity.absSnapTo(spawnData.x(), spawnData.y(), spawnData.z(), spawnData.yaw(), spawnData.pitch()); entity.setYHeadRot(spawnData.yaw()); // SPIGOT-3587 }; - private static final BiConsumer MOVE = (spawnData, entity) -> entity.moveTo(spawnData.x(), spawnData.y(), spawnData.z(), spawnData.yaw(), spawnData.pitch()); - private static final BiConsumer MOVE_EMPTY_ROT = (spawnData, entity) -> entity.moveTo(spawnData.x(), spawnData.y(), spawnData.z(), 0, 0); + private static final BiConsumer MOVE = (spawnData, entity) -> entity.snapTo(spawnData.x(), spawnData.y(), spawnData.z(), spawnData.yaw(), spawnData.pitch()); + private static final BiConsumer MOVE_EMPTY_ROT = (spawnData, entity) -> entity.snapTo(spawnData.x(), spawnData.y(), spawnData.z(), 0, 0); private static final BiConsumer DIRECTION = (spawnData, entity) -> { Vector direction = spawnData.location().getDirection(); entity.assignDirectionalMovement(new Vec3D(direction.getX(), direction.getY(), direction.getZ()), 1.0); @@ -371,7 +374,7 @@ public final class CraftEntityTypes { return EntityPainting.create(spawnData.minecraftWorld(), hangingData.position(), hangingData.direction()).orElse(null); } else { EntityPainting entity = new EntityPainting(EntityTypes.PAINTING, spawnData.minecraftWorld()); - entity.absMoveTo(spawnData.x(), spawnData.y(), spawnData.z(), spawnData.yaw(), spawnData.pitch()); + entity.absSnapTo(spawnData.x(), spawnData.y(), spawnData.z(), spawnData.yaw(), spawnData.pitch()); entity.setDirection(hangingData.direction()); return entity; } @@ -440,8 +443,12 @@ public final class CraftEntityTypes { register(new EntityTypeData<>(EntityType.LEASH_KNOT, LeashHitch.class, CraftLeash::new, spawnData -> new EntityLeash(spawnData.minecraftWorld(), BlockPosition.containing(spawnData.x(), spawnData.y(), spawnData.z())))); // SPIGOT-5732: LeashHitch has no direction and is always centered at a block register(new EntityTypeData<>(EntityType.SNOWBALL, Snowball.class, CraftSnowball::new, spawnData -> new EntitySnowball(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), new net.minecraft.world.item.ItemStack(Items.SNOWBALL)))); register(new EntityTypeData<>(EntityType.EYE_OF_ENDER, EnderSignal.class, CraftEnderSignal::new, spawnData -> new EntityEnderSignal(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z()))); - register(new EntityTypeData<>(EntityType.POTION, ThrownPotion.class, CraftThrownPotion::new, spawnData -> { - EntityPotion entity = new EntityPotion(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), new net.minecraft.world.item.ItemStack(Items.SPLASH_POTION)); + register(new EntityTypeData<>(EntityType.SPLASH_POTION, SplashPotion.class, CraftSplashPotion::new, spawnData -> { + EntityPotion entity = new ThrownSplashPotion(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), new net.minecraft.world.item.ItemStack(Items.SPLASH_POTION)); + return entity; + })); + register(new EntityTypeData<>(EntityType.LINGERING_POTION, LingeringPotion.class, CraftLingeringPotion::new, spawnData -> { + EntityPotion entity = new ThrownLingeringPotion(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), new net.minecraft.world.item.ItemStack(Items.LINGERING_POTION)); return entity; })); register(new EntityTypeData<>(EntityType.TNT, TNTPrimed.class, CraftTNTPrimed::new, spawnData -> new EntityTNTPrimed(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), null))); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java index c3524a3bc..bf17270a7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java @@ -11,12 +11,12 @@ public class CraftExperienceOrb extends CraftEntity implements ExperienceOrb { @Override public int getExperience() { - return getHandle().value; + return getHandle().getValue(); } @Override public void setExperience(int value) { - getHandle().value = value; + getHandle().setValue(value); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java index efcb213ea..a7f072728 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java @@ -3,6 +3,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; import java.util.Optional; import java.util.UUID; +import net.minecraft.world.entity.EntityReference; import net.minecraft.world.entity.animal.EntityFox; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.AnimalTamer; @@ -64,7 +65,7 @@ public class CraftFox extends CraftAnimals implements Fox { @Override public AnimalTamer getFirstTrustedPlayer() { - UUID uuid = getHandle().getEntityData().get(EntityFox.DATA_TRUSTED_ID_0).orElse(null); + UUID uuid = getHandle().getEntityData().get(EntityFox.DATA_TRUSTED_ID_0).map(EntityReference::getUUID).orElse(null); if (uuid == null) { return null; } @@ -83,12 +84,12 @@ public class CraftFox extends CraftAnimals implements Fox { Preconditions.checkState(getHandle().getEntityData().get(EntityFox.DATA_TRUSTED_ID_1).isEmpty(), "Must remove second trusted player first"); } - getHandle().getEntityData().set(EntityFox.DATA_TRUSTED_ID_0, player == null ? Optional.empty() : Optional.of(player.getUniqueId())); + getHandle().getEntityData().set(EntityFox.DATA_TRUSTED_ID_0, player == null ? Optional.empty() : Optional.of(new EntityReference<>(player.getUniqueId()))); } @Override public AnimalTamer getSecondTrustedPlayer() { - UUID uuid = getHandle().getEntityData().get(EntityFox.DATA_TRUSTED_ID_1).orElse(null); + UUID uuid = getHandle().getEntityData().get(EntityFox.DATA_TRUSTED_ID_1).map(EntityReference::getUUID).orElse(null); if (uuid == null) { return null; } @@ -107,7 +108,7 @@ public class CraftFox extends CraftAnimals implements Fox { Preconditions.checkState(getHandle().getEntityData().get(EntityFox.DATA_TRUSTED_ID_0).isPresent(), "Must add first trusted player first"); } - getHandle().getEntityData().set(EntityFox.DATA_TRUSTED_ID_1, player == null ? Optional.empty() : Optional.of(player.getUniqueId())); + getHandle().getEntityData().set(EntityFox.DATA_TRUSTED_ID_1, player == null ? Optional.empty() : Optional.of(new EntityReference<>(player.getUniqueId()))); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java index 10677e92c..4a699d343 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java @@ -3,8 +3,8 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; -import net.minecraft.world.entity.animal.FrogVariant; import net.minecraft.world.entity.animal.frog.Frog; +import net.minecraft.world.entity.animal.frog.FrogVariant; import org.bukkit.NamespacedKey; import org.bukkit.Registry; import org.bukkit.craftbukkit.CraftRegistry; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java index 61f1fef5b..cbe461cd9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; +import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.animal.horse.EntityHorse; import net.minecraft.world.entity.animal.horse.HorseColor; import net.minecraft.world.entity.animal.horse.HorseStyle; @@ -59,7 +60,7 @@ public class CraftHorse extends CraftAbstractHorse implements Horse { @Override public HorseInventory getInventory() { - return new CraftInventoryHorse(getHandle().inventory, getHandle().getBodyArmorAccess()); + return new CraftInventoryHorse(getHandle().inventory, getHandle().createEquipmentSlotContainer(EnumItemSlot.BODY)); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index e9c3b40e6..5d1dcd5bc 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -441,7 +441,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { mcMerchant = ((CraftAbstractVillager) merchant).getHandle(); name = ((CraftAbstractVillager) merchant).getHandle().getDisplayName(); if (merchant instanceof CraftVillager) { - level = ((CraftVillager) merchant).getHandle().getVillagerData().getLevel(); + level = ((CraftVillager) merchant).getHandle().getVillagerData().level(); } } else if (merchant instanceof CraftMerchantCustom) { mcMerchant = ((CraftMerchantCustom) merchant).getMerchant(); @@ -534,7 +534,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { } ItemCooldown.Info cooldown = getHandle().getCooldowns().cooldowns.get(group); - return (cooldown == null) ? 0 : Math.max(0, cooldown.endTime - getHandle().getCooldowns().tickCount); + return (cooldown == null) ? 0 : Math.max(0, cooldown.endTime() - getHandle().getCooldowns().tickCount); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLingeringPotion.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLingeringPotion.java new file mode 100644 index 000000000..df3ad9efa --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLingeringPotion.java @@ -0,0 +1,12 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.world.entity.projectile.EntityPotion; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.LingeringPotion; + +public class CraftLingeringPotion extends CraftThrownPotion implements LingeringPotion { + + public CraftLingeringPotion(CraftServer server, EntityPotion entity) { + super(server, entity); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 0d5d34ecd..a2d965ddd 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -33,7 +33,6 @@ import net.minecraft.world.entity.projectile.EntityFireworks; import net.minecraft.world.entity.projectile.EntityFishingHook; import net.minecraft.world.entity.projectile.EntityLargeFireball; import net.minecraft.world.entity.projectile.EntityLlamaSpit; -import net.minecraft.world.entity.projectile.EntityPotion; import net.minecraft.world.entity.projectile.EntityProjectile; import net.minecraft.world.entity.projectile.EntityShulkerBullet; import net.minecraft.world.entity.projectile.EntitySmallFireball; @@ -43,6 +42,8 @@ import net.minecraft.world.entity.projectile.EntityThrownExpBottle; import net.minecraft.world.entity.projectile.EntityThrownTrident; import net.minecraft.world.entity.projectile.EntityTippedArrow; import net.minecraft.world.entity.projectile.EntityWitherSkull; +import net.minecraft.world.entity.projectile.ThrownLingeringPotion; +import net.minecraft.world.entity.projectile.ThrownSplashPotion; import net.minecraft.world.item.Items; import net.minecraft.world.item.component.Consumable; import net.minecraft.world.phys.Vec3D; @@ -402,7 +403,8 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public Player getKiller() { - return getHandle().lastHurtByPlayer == null ? null : (Player) getHandle().lastHurtByPlayer.getBukkitEntity(); + EntityHuman lastHurtByPlayer = getHandle().getLastHurtByPlayer(); + return lastHurtByPlayer == null ? null : (Player) lastHurtByPlayer.getBukkitEntity(); } @Override @@ -486,9 +488,9 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { ((EntityArrow) launch).shootFromRotation(getHandle(), getHandle().getXRot(), getHandle().getYRot(), 0.0F, 3.0F, 1.0F); // ItemBow } else if (ThrownPotion.class.isAssignableFrom(projectile)) { if (LingeringPotion.class.isAssignableFrom(projectile)) { - launch = new EntityPotion(world, getHandle(), new net.minecraft.world.item.ItemStack(Items.LINGERING_POTION)); + launch = new ThrownLingeringPotion(world, getHandle(), new net.minecraft.world.item.ItemStack(Items.LINGERING_POTION)); } else { - launch = new EntityPotion(world, getHandle(), new net.minecraft.world.item.ItemStack(Items.SPLASH_POTION)); + launch = new ThrownSplashPotion(world, getHandle(), new net.minecraft.world.item.ItemStack(Items.SPLASH_POTION)); } ((EntityProjectile) launch).shootFromRotation(getHandle(), getHandle().getXRot(), getHandle().getYRot(), -20.0F, 0.5F, 1.0F); // ItemSplashPotion } else if (ThrownExpBottle.class.isAssignableFrom(projectile)) { @@ -521,7 +523,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } ((EntityFireball) launch).projectileSource = this; - launch.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + launch.snapTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); } else if (LlamaSpit.class.isAssignableFrom(projectile)) { Location location = getEyeLocation(); Vector direction = location.getDirection(); @@ -530,17 +532,17 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { ((EntityLlamaSpit) launch).setOwner(getHandle()); ((EntityLlamaSpit) launch).shoot(direction.getX(), direction.getY(), direction.getZ(), 1.5F, 10.0F); // EntityLlama - launch.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + launch.snapTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); } else if (ShulkerBullet.class.isAssignableFrom(projectile)) { Location location = getEyeLocation(); launch = new EntityShulkerBullet(world, getHandle(), null, null); - launch.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + launch.snapTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); } else if (Firework.class.isAssignableFrom(projectile)) { Location location = getEyeLocation(); launch = new EntityFireworks(world, net.minecraft.world.item.ItemStack.EMPTY, getHandle()); - launch.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + launch.snapTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); } Preconditions.checkArgument(launch != null, "Projectile (%s) not supported", projectile.getName()); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java index 9082667bc..b9953f55a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; +import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.animal.horse.EntityLlama; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftInventoryLlama; @@ -34,7 +35,7 @@ public class CraftLlama extends CraftChestedHorse implements Llama { @Override public LlamaInventory getInventory() { - return new CraftInventoryLlama(getHandle().inventory, getHandle().getBodyArmorAccess()); + return new CraftInventoryLlama(getHandle().inventory, getHandle().createEquipmentSlotContainer(EnumItemSlot.BODY)); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java index 8b45c0ee5..439b06205 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java @@ -1,8 +1,8 @@ package org.bukkit.craftbukkit.entity; +import java.util.Optional; import net.minecraft.server.level.WorldServer; import net.minecraft.world.entity.vehicle.EntityMinecartAbstract; -import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.CraftServer; @@ -78,11 +78,10 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart { public void setDisplayBlock(MaterialData material) { if (material != null) { IBlockData block = CraftMagicNumbers.getBlock(material); - this.getHandle().setDisplayBlockState(block); + this.getHandle().setCustomDisplayBlockState(Optional.of(block)); } else { // Set block to air (default) and set the flag to not have a display block. - this.getHandle().setDisplayBlockState(Blocks.AIR.defaultBlockState()); - this.getHandle().setCustomDisplay(false); + this.getHandle().setCustomDisplayBlockState(Optional.empty()); } } @@ -90,11 +89,10 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart { public void setDisplayBlockData(BlockData blockData) { if (blockData != null) { IBlockData block = ((CraftBlockData) blockData).getState(); - this.getHandle().setDisplayBlockState(block); + this.getHandle().setCustomDisplayBlockState(Optional.of(block)); } else { // Set block to air (default) and set the flag to not have a display block. - this.getHandle().setDisplayBlockState(Blocks.AIR.defaultBlockState()); - this.getHandle().setCustomDisplay(false); + this.getHandle().setCustomDisplayBlockState(Optional.empty()); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java index 546472fda..929b1942b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java @@ -5,7 +5,7 @@ import java.util.Collection; import java.util.List; import java.util.Optional; import net.minecraft.util.RandomSource; -import net.minecraft.util.random.SimpleWeightedRandomList; +import net.minecraft.util.random.WeightedList; import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.entity.vehicle.EntityMinecartMobSpawner; import net.minecraft.world.level.MobSpawnerData; @@ -36,7 +36,7 @@ final class CraftMinecartMobSpawner extends CraftMinecart implements SpawnerMine @Override public void setSpawnedType(EntityType entityType) { if (entityType == null) { - getHandle().getSpawner().spawnPotentials = SimpleWeightedRandomList.empty(); // need clear the spawnPotentials to avoid nextSpawnData being replaced later + getHandle().getSpawner().spawnPotentials = WeightedList.of(); // need clear the spawnPotentials to avoid nextSpawnData being replaced later getHandle().getSpawner().nextSpawnData = new MobSpawnerData(); return; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java index 31da5d03e..85294ac78 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java @@ -52,7 +52,7 @@ public final class CraftMinecartTNT extends CraftMinecart implements ExplosiveMi @Override public void ignite() { - getHandle().primeFuse(); + getHandle().primeFuse(null); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java index 2dff42289..0de95270b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java @@ -15,7 +15,7 @@ import org.bukkit.entity.MushroomCow; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -public class CraftMushroomCow extends CraftCow implements MushroomCow { +public class CraftMushroomCow extends CraftAbstractCow implements MushroomCow { public CraftMushroomCow(CraftServer server, EntityMushroomCow entity) { super(server, entity); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java index e18445804..3c4df310d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java @@ -1,9 +1,19 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.animal.EntityPig; +import net.minecraft.world.entity.animal.PigVariant; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.Registry; +import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.registry.CraftRegistryItem; import org.bukkit.entity.Pig; public class CraftPig extends CraftAnimals implements Pig { @@ -19,7 +29,7 @@ public class CraftPig extends CraftAnimals implements Pig { @Override public void setSaddle(boolean saddled) { - getHandle().steering.setSaddle(saddled); + getHandle().setItemSlot(EnumItemSlot.SADDLE, new ItemStack(Items.SADDLE)); } @Override @@ -56,6 +66,46 @@ public class CraftPig extends CraftAnimals implements Pig { return Material.CARROT_ON_A_STICK; } + @Override + public Pig.Variant getVariant() { + return CraftVariant.minecraftHolderToBukkit(getHandle().getVariant()); + } + + @Override + public void setVariant(Pig.Variant variant) { + Preconditions.checkArgument(variant != null, "variant"); + + getHandle().setVariant(CraftVariant.bukkitToMinecraftHolder(variant)); + } + + public static class CraftVariant extends CraftRegistryItem implements Pig.Variant { + + public static Pig.Variant minecraftToBukkit(PigVariant minecraft) { + return CraftRegistry.minecraftToBukkit(minecraft, Registries.PIG_VARIANT, Registry.PIG_VARIANT); + } + + public static Pig.Variant minecraftHolderToBukkit(Holder minecraft) { + return minecraftToBukkit(minecraft.value()); + } + + public static PigVariant bukkitToMinecraft(Pig.Variant bukkit) { + return CraftRegistry.bukkitToMinecraft(bukkit); + } + + public static Holder bukkitToMinecraftHolder(Pig.Variant bukkit) { + return CraftRegistry.bukkitToMinecraftHolder(bukkit, Registries.PIG_VARIANT); + } + + public CraftVariant(NamespacedKey key, Holder handle) { + super(key, handle); + } + + @Override + public NamespacedKey getKey() { + return getKeyOrThrow(); + } + } + @Override public EntityPig getHandle() { return (EntityPig) entity; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index e968385f4..ebd52ca0e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1153,11 +1153,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public Location getRespawnLocation() { - WorldServer world = getHandle().server.getLevel(getHandle().getRespawnDimension()); - BlockPosition bed = getHandle().getRespawnPosition(); + EntityPlayer.RespawnConfig respawnConfig = getHandle().getRespawnConfig(); + if (respawnConfig == null) { + return null; + } + + WorldServer world = getHandle().server.getLevel(respawnConfig.dimension()); + BlockPosition bed = respawnConfig.pos(); if (world != null && bed != null) { - Optional spawnLoc = EntityPlayer.findRespawnAndUseSpawnBlock(world, bed, getHandle().getRespawnAngle(), getHandle().isRespawnForced(), true); + Optional spawnLoc = EntityPlayer.findRespawnAndUseSpawnBlock(world, respawnConfig, true); if (spawnLoc.isPresent()) { EntityPlayer.RespawnPosAngle vec = spawnLoc.get(); return CraftLocation.toBukkit(vec.position(), world.getWorld(), vec.yaw(), 0); @@ -1184,9 +1189,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void setRespawnLocation(Location location, boolean override) { if (location == null) { - getHandle().setRespawnPosition(null, null, 0.0F, override, false, PlayerSpawnChangeEvent.Cause.PLUGIN); + getHandle().setRespawnPosition(new EntityPlayer.RespawnConfig(null, null, 0.0F, false), override, PlayerSpawnChangeEvent.Cause.PLUGIN); } else { - getHandle().setRespawnPosition(((CraftWorld) location.getWorld()).getHandle().dimension(), CraftLocation.toBlockPosition(location), location.getYaw(), override, false, PlayerSpawnChangeEvent.Cause.PLUGIN); + getHandle().setRespawnPosition(new EntityPlayer.RespawnConfig(((CraftWorld) location.getWorld()).getHandle().dimension(), CraftLocation.toBlockPosition(location), location.getYaw(), false), override, PlayerSpawnChangeEvent.Cause.PLUGIN); } } @@ -1202,10 +1207,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public Location getBedLocation() { - Preconditions.checkState(isSleeping(), "Not sleeping"); + Optional bed = getHandle().getSleepingPos(); + Preconditions.checkState(bed.isPresent(), "Not sleeping"); - BlockPosition bed = getHandle().getRespawnPosition(); - return CraftLocation.toBukkit(bed, getWorld()); + return CraftLocation.toBukkit(bed.get(), getWorld()); } @Override @@ -1761,20 +1766,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void readExtraData(NBTTagCompound nbttagcompound) { hasPlayedBefore = true; if (nbttagcompound.contains("bukkit")) { - NBTTagCompound data = nbttagcompound.getCompound("bukkit"); + NBTTagCompound data = nbttagcompound.getCompoundOrEmpty("bukkit"); if (data.contains("firstPlayed")) { - firstPlayed = data.getLong("firstPlayed"); - lastPlayed = data.getLong("lastPlayed"); + firstPlayed = data.getLongOr("firstPlayed", firstPlayed); + lastPlayed = data.getLongOr("lastPlayed", lastPlayed); } if (data.contains("newExp")) { EntityPlayer handle = getHandle(); - handle.newExp = data.getInt("newExp"); - handle.newTotalExp = data.getInt("newTotalExp"); - handle.newLevel = data.getInt("newLevel"); - handle.expToDrop = data.getInt("expToDrop"); - handle.keepLevel = data.getBoolean("keepLevel"); + handle.newExp = data.getIntOr("newExp", handle.newExp); + handle.newTotalExp = data.getIntOr("newTotalExp", handle.newTotalExp); + handle.newLevel = data.getIntOr("newLevel", handle.newLevel); + handle.expToDrop = data.getIntOr("expToDrop", handle.expToDrop); + handle.keepLevel = data.getBooleanOr("keepLevel", handle.keepLevel); } } } @@ -1784,7 +1789,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { nbttagcompound.put("bukkit", new NBTTagCompound()); } - NBTTagCompound data = nbttagcompound.getCompound("bukkit"); + NBTTagCompound data = nbttagcompound.getCompoundOrEmpty("bukkit"); EntityPlayer handle = getHandle(); data.putInt("newExp", handle.newExp); data.putInt("newTotalExp", handle.newTotalExp); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java index 2deb3c1ee..0219a473a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java @@ -34,7 +34,7 @@ public abstract class CraftRaider extends CraftMonster implements Raider { @Override public Raid getRaid() { - return getHandle().getCurrentRaid() == null ? null : new CraftRaid(getHandle().getCurrentRaid()); + return getHandle().getCurrentRaid() == null ? null : new CraftRaid(getHandle().getCurrentRaid(), getHandle().level()); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java index 171691e15..68cb75611 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java @@ -30,6 +30,6 @@ public class CraftSalmon extends CraftFish implements Salmon { public void setVariant(Variant variant) { Preconditions.checkArgument(variant != null, "variant"); - getHandle().setVariant(EntitySalmon.a.values()[variant.ordinal()]); + getHandle().setVariant(EntitySalmon.Variant.values()[variant.ordinal()]); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java index a498b9c69..d8fe89862 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.animal.EntitySheep; +import net.minecraft.world.entity.animal.sheep.EntitySheep; import net.minecraft.world.item.EnumColor; import org.bukkit.DyeColor; import org.bukkit.craftbukkit.CraftServer; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSplashPotion.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSplashPotion.java new file mode 100644 index 000000000..ed6ab1938 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSplashPotion.java @@ -0,0 +1,12 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.world.entity.projectile.EntityPotion; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.SplashPotion; + +public class CraftSplashPotion extends CraftThrownPotion implements SplashPotion { + + public CraftSplashPotion(CraftServer server, EntityPotion entity) { + super(server, entity); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java index d57b6a975..2d95c8156 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java @@ -1,7 +1,10 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; +import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.monster.EntityStrider; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import org.bukkit.Material; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Strider; @@ -29,7 +32,7 @@ public class CraftStrider extends CraftAnimals implements Strider { @Override public void setSaddle(boolean saddled) { - getHandle().steering.setSaddle(saddled); + getHandle().setItemSlot(EnumItemSlot.SADDLE, new ItemStack(Items.SADDLE)); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java index dc4466f39..d6b19bedd 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java @@ -1,6 +1,8 @@ package org.bukkit.craftbukkit.entity; import java.util.UUID; +import net.minecraft.world.entity.EntityLiving; +import net.minecraft.world.entity.EntityReference; import net.minecraft.world.entity.EntityTameableAnimal; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.AnimalTamer; @@ -18,15 +20,12 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat } public UUID getOwnerUUID() { - try { - return getHandle().getOwnerUUID(); - } catch (IllegalArgumentException ex) { - return null; - } + EntityReference owner = getHandle().getOwnerReference(); + return (owner != null) ? owner.getUUID() : null; } public void setOwnerUUID(UUID uuid) { - getHandle().setOwnerUUID(uuid); + getHandle().setOwnerReference(new EntityReference<>(uuid)); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java index 868b3de94..13e2d003a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java @@ -15,7 +15,7 @@ import org.bukkit.entity.ThrownPotion; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; -public class CraftThrownPotion extends CraftThrowableProjectile implements ThrownPotion { +public abstract class CraftThrownPotion extends CraftThrowableProjectile implements ThrownPotion { public CraftThrownPotion(CraftServer server, EntityPotion entity) { super(server, entity); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java index d00a341c2..4caf5014c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -9,6 +9,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import net.minecraft.core.BlockPosition; import net.minecraft.core.Holder; +import net.minecraft.core.IRegistry; import net.minecraft.core.registries.Registries; import net.minecraft.world.entity.ai.gossip.ReputationType; import net.minecraft.world.entity.monster.EntityZombie; @@ -56,36 +57,36 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { @Override public Profession getProfession() { - return CraftProfession.minecraftToBukkit(getHandle().getVillagerData().getProfession()); + return CraftProfession.minecraftHolderToBukkit(getHandle().getVillagerData().profession()); } @Override public void setProfession(Profession profession) { Preconditions.checkArgument(profession != null, "Profession cannot be null"); - getHandle().setVillagerData(getHandle().getVillagerData().setProfession(CraftProfession.bukkitToMinecraft(profession))); + getHandle().setVillagerData(getHandle().getVillagerData().withProfession(CraftProfession.bukkitToMinecraftHolder(profession))); } @Override public Type getVillagerType() { - return CraftType.minecraftToBukkit(getHandle().getVillagerData().getType()); + return CraftType.minecraftHolderToBukkit(getHandle().getVillagerData().type()); } @Override public void setVillagerType(Type type) { Preconditions.checkArgument(type != null, "Type cannot be null"); - getHandle().setVillagerData(getHandle().getVillagerData().setType(CraftType.bukkitToMinecraft(type))); + getHandle().setVillagerData(getHandle().getVillagerData().withType(CraftType.bukkitToMinecraftHolder(type))); } @Override public int getVillagerLevel() { - return getHandle().getVillagerData().getLevel(); + return getHandle().getVillagerData().level(); } @Override public void setVillagerLevel(int level) { Preconditions.checkArgument(1 <= level && level <= 5, "level (%s) must be between [1, 5]", level); - getHandle().setVillagerData(getHandle().getVillagerData().setLevel(level)); + getHandle().setVillagerData(getHandle().getVillagerData().withLevel(level)); } @Override @@ -216,10 +217,27 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { return CraftRegistry.minecraftToBukkit(minecraft, Registries.VILLAGER_TYPE, Registry.VILLAGER_TYPE); } + public static Type minecraftHolderToBukkit(Holder minecraft) { + return minecraftToBukkit(minecraft.value()); + } + public static VillagerType bukkitToMinecraft(Type bukkit) { return CraftRegistry.bukkitToMinecraft(bukkit); } + public static Holder bukkitToMinecraftHolder(Type bukkit) { + Preconditions.checkArgument(bukkit != null); + + IRegistry registry = CraftRegistry.getMinecraftRegistry(Registries.VILLAGER_TYPE); + + if (registry.wrapAsHolder(bukkitToMinecraft(bukkit)) instanceof Holder.c holder) { + return holder; + } + + throw new IllegalArgumentException("No Reference holder found for " + bukkit + + ", this can happen if a plugin creates its own villager type without properly registering it."); + } + public CraftType(NamespacedKey key, Holder handle) { super(key, handle, count++); } @@ -237,10 +255,27 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { return CraftRegistry.minecraftToBukkit(minecraft, Registries.VILLAGER_PROFESSION, Registry.VILLAGER_PROFESSION); } + public static Profession minecraftHolderToBukkit(Holder minecraft) { + return minecraftToBukkit(minecraft.value()); + } + public static VillagerProfession bukkitToMinecraft(Profession bukkit) { return CraftRegistry.bukkitToMinecraft(bukkit); } + public static Holder bukkitToMinecraftHolder(Profession bukkit) { + Preconditions.checkArgument(bukkit != null); + + IRegistry registry = CraftRegistry.getMinecraftRegistry(Registries.VILLAGER_PROFESSION); + + if (registry.wrapAsHolder(bukkitToMinecraft(bukkit)) instanceof Holder.c holder) { + return holder; + } + + throw new IllegalArgumentException("No Reference holder found for " + bukkit + + ", this can happen if a plugin creates its own villager profession without properly registering it."); + } + public CraftProfession(NamespacedKey key, Holder handle) { super(key, handle, count++); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java index ccdd0fd82..ec565c0c1 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java @@ -27,24 +27,24 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager { @Override public Villager.Profession getVillagerProfession() { - return CraftVillager.CraftProfession.minecraftToBukkit(getHandle().getVillagerData().getProfession()); + return CraftVillager.CraftProfession.minecraftHolderToBukkit(getHandle().getVillagerData().profession()); } @Override public void setVillagerProfession(Villager.Profession profession) { Preconditions.checkArgument(profession != null, "Villager.Profession cannot be null"); - getHandle().setVillagerData(getHandle().getVillagerData().setProfession(CraftVillager.CraftProfession.bukkitToMinecraft(profession))); + getHandle().setVillagerData(getHandle().getVillagerData().withProfession(CraftVillager.CraftProfession.bukkitToMinecraftHolder(profession))); } @Override public Villager.Type getVillagerType() { - return CraftVillager.CraftType.minecraftToBukkit(getHandle().getVillagerData().getType()); + return CraftVillager.CraftType.minecraftHolderToBukkit(getHandle().getVillagerData().type()); } @Override public void setVillagerType(Villager.Type type) { Preconditions.checkArgument(type != null, "Villager.Type cannot be null"); - getHandle().setVillagerData(getHandle().getVillagerData().setType(CraftVillager.CraftType.bukkitToMinecraft(type))); + getHandle().setVillagerData(getHandle().getVillagerData().withType(CraftVillager.CraftType.bukkitToMinecraftHolder(type))); } @Override @@ -65,7 +65,7 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager { getHandle().villagerConversionTime = -1; getHandle().getEntityData().set(EntityZombieVillager.DATA_CONVERTING_ID, false); getHandle().conversionStarter = null; - getHandle().removeEffect(MobEffects.DAMAGE_BOOST, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); + getHandle().removeEffect(MobEffects.STRENGTH, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); } else { getHandle().startConverting(null, time); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java index c303309ef..8abd0c4aa 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java @@ -4,8 +4,8 @@ import com.google.common.base.Preconditions; import net.minecraft.core.Holder; import net.minecraft.core.IRegistry; import net.minecraft.core.registries.Registries; -import net.minecraft.world.entity.animal.EntityWolf; -import net.minecraft.world.entity.animal.WolfVariant; +import net.minecraft.world.entity.animal.wolf.EntityWolf; +import net.minecraft.world.entity.animal.wolf.WolfVariant; import net.minecraft.world.item.EnumColor; import org.bukkit.DyeColor; import org.bukkit.NamespacedKey; diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index b87944a25..1f47a53b0 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -281,7 +281,7 @@ import org.bukkit.util.Vector; public class CraftEventFactory { // helper methods - private static boolean canBuild(WorldServer world, Player player, int x, int z) { + private static boolean canBuild(World world, Player player, int x, int z) { int spawnSize = Bukkit.getServer().getSpawnRadius(); if (world.dimension() != World.OVERWORLD) return true; @@ -502,15 +502,15 @@ public class CraftEventFactory { /** * Bucket methods */ - public static PlayerBucketEmptyEvent callPlayerBucketEmptyEvent(WorldServer world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemInHand, EnumHand enumhand) { + public static PlayerBucketEmptyEvent callPlayerBucketEmptyEvent(World world, EntityPlayer who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemInHand, EnumHand enumhand) { return (PlayerBucketEmptyEvent) getPlayerBucketEvent(false, world, who, changed, clicked, clickedFace, itemInHand, Items.BUCKET, enumhand); } - public static PlayerBucketFillEvent callPlayerBucketFillEvent(WorldServer world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemInHand, net.minecraft.world.item.Item bucket, EnumHand enumhand) { + public static PlayerBucketFillEvent callPlayerBucketFillEvent(World world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemInHand, net.minecraft.world.item.Item bucket, EnumHand enumhand) { return (PlayerBucketFillEvent) getPlayerBucketEvent(true, world, who, clicked, changed, clickedFace, itemInHand, bucket, enumhand); } - private static PlayerEvent getPlayerBucketEvent(boolean isFilling, WorldServer world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemstack, net.minecraft.world.item.Item item, EnumHand enumhand) { + private static PlayerEvent getPlayerBucketEvent(boolean isFilling, World world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemstack, net.minecraft.world.item.Item item, EnumHand enumhand) { Player player = (Player) who.getBukkitEntity(); CraftItemStack itemInHand = CraftItemStack.asNewCraftStack(item); Material bucket = CraftItemType.minecraftToBukkit(itemstack.getItem()); @@ -1775,29 +1775,29 @@ public class CraftEventFactory { /** * Raid events */ - public static boolean callRaidTriggerEvent(Raid raid, EntityPlayer player) { - RaidTriggerEvent event = new RaidTriggerEvent(new CraftRaid(raid), raid.getLevel().getWorld(), player.getBukkitEntity()); + public static boolean callRaidTriggerEvent(Raid raid, World world, EntityPlayer player) { + RaidTriggerEvent event = new RaidTriggerEvent(new CraftRaid(raid, world), world.getWorld(), player.getBukkitEntity()); Bukkit.getPluginManager().callEvent(event); return !event.isCancelled(); } - public static void callRaidFinishEvent(Raid raid, List players) { - RaidFinishEvent event = new RaidFinishEvent(new CraftRaid(raid), raid.getLevel().getWorld(), players); + public static void callRaidFinishEvent(Raid raid, World world, List players) { + RaidFinishEvent event = new RaidFinishEvent(new CraftRaid(raid, world), world.getWorld(), players); Bukkit.getPluginManager().callEvent(event); } - public static void callRaidStopEvent(Raid raid, RaidStopEvent.Reason reason) { - RaidStopEvent event = new RaidStopEvent(new CraftRaid(raid), raid.getLevel().getWorld(), reason); + public static void callRaidStopEvent(Raid raid, World world, RaidStopEvent.Reason reason) { + RaidStopEvent event = new RaidStopEvent(new CraftRaid(raid, world), world.getWorld(), reason); Bukkit.getPluginManager().callEvent(event); } - public static void callRaidSpawnWaveEvent(Raid raid, EntityRaider leader, List raiders) { + public static void callRaidSpawnWaveEvent(Raid raid, World world, EntityRaider leader, List raiders) { Raider craftLeader = (CraftRaider) leader.getBukkitEntity(); List craftRaiders = new ArrayList<>(); for (EntityRaider entityRaider : raiders) { craftRaiders.add((Raider) entityRaider.getBukkitEntity()); } - RaidSpawnWaveEvent event = new RaidSpawnWaveEvent(new CraftRaid(raid), raid.getLevel().getWorld(), craftLeader, craftRaiders); + RaidSpawnWaveEvent event = new RaidSpawnWaveEvent(new CraftRaid(raid, world), world.getWorld(), craftLeader, craftRaiders); Bukkit.getPluginManager().callEvent(event); } diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java index 00fe52cf4..fc3c12533 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java @@ -3,6 +3,7 @@ package org.bukkit.craftbukkit.generator; import com.google.common.base.Preconditions; import java.lang.ref.WeakReference; import net.minecraft.core.BlockPosition; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.ITileEntity; import net.minecraft.world.level.block.entity.TileEntity; @@ -165,7 +166,7 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData { IChunkAccess access = getHandle(); BlockPosition blockPosition = new BlockPosition(access.getPos().getMinBlockX() + x, y, access.getPos().getMinBlockZ() + z); - IBlockData oldBlockData = access.setBlockState(blockPosition, type, false); + IBlockData oldBlockData = access.setBlockState(blockPosition, type, Block.UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS); if (type.hasBlockEntity()) { TileEntity tileEntity = ((ITileEntity) type.getBlock()).newBlockEntity(blockPosition, type); diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java index ef1f476fe..530df3542 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java @@ -6,22 +6,17 @@ import java.util.List; import java.util.Random; import java.util.concurrent.CompletableFuture; import net.minecraft.core.BlockPosition; -import net.minecraft.core.Holder; import net.minecraft.core.IRegistryCustom; import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.RegionLimitedWorldAccess; import net.minecraft.server.level.WorldServer; import net.minecraft.util.MathHelper; -import net.minecraft.util.random.WeightedRandomList; -import net.minecraft.world.entity.EnumCreatureType; import net.minecraft.world.level.BlockColumn; import net.minecraft.world.level.GeneratorAccessSeed; import net.minecraft.world.level.LevelHeightAccessor; import net.minecraft.world.level.StructureManager; import net.minecraft.world.level.World; -import net.minecraft.world.level.biome.BiomeBase; import net.minecraft.world.level.biome.BiomeManager; -import net.minecraft.world.level.biome.BiomeSettingsMobs; import net.minecraft.world.level.biome.WorldChunkManager; import net.minecraft.world.level.block.ITileEntity; import net.minecraft.world.level.block.entity.TileEntity; @@ -286,11 +281,6 @@ public class CustomChunkGenerator extends InternalChunkGenerator { return delegate.getBaseHeight(i, j, heightmap_type, levelheightaccessor, randomstate); } - @Override - public WeightedRandomList getMobsAt(Holder holder, StructureManager structuremanager, EnumCreatureType enumcreaturetype, BlockPosition blockposition) { - return delegate.getMobsAt(holder, structuremanager, enumcreaturetype, blockposition); - } - @Override public void applyBiomeDecoration(GeneratorAccessSeed generatoraccessseed, IChunkAccess ichunkaccess, StructureManager structuremanager) { SeededRandom random = getSeededRandom(); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java index dc4cb10f2..70333d5e2 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java @@ -249,11 +249,7 @@ public class CraftEntityEquipment implements EntityEquipment { private void setDropChance(EnumItemSlot slot, float chance) { Preconditions.checkArgument(entity.getHandle() instanceof EntityInsentient, "Cannot set drop chance for non-Mob entity"); - if (slot == EnumItemSlot.MAINHAND || slot == EnumItemSlot.OFFHAND) { - ((EntityInsentient) entity.getHandle()).handDropChances[slot.getIndex()] = chance; - } else { - ((EntityInsentient) entity.getHandle()).armorDropChances[slot.getIndex()] = chance; - } + ((EntityInsentient) entity.getHandle()).setDropChance(slot, chance); } private float getDropChance(EnumItemSlot slot) { @@ -261,10 +257,6 @@ public class CraftEntityEquipment implements EntityEquipment { return 1; } - if (slot == EnumItemSlot.MAINHAND || slot == EnumItemSlot.OFFHAND) { - return ((EntityInsentient) entity.getHandle()).handDropChances[slot.getIndex()]; - } else { - return ((EntityInsentient) entity.getHandle()).armorDropChances[slot.getIndex()]; - } + return ((EntityInsentient) entity.getHandle()).getDropChances().byEquipment(slot); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java index 88327c35a..0bb0d4925 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java @@ -23,12 +23,12 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i @Override public ItemStack[] getStorageContents() { - return asCraftMirror(getInventory().items); + return asCraftMirror(getInventory().getNonEquipmentItems()); } @Override public ItemStack getItemInMainHand() { - return CraftItemStack.asCraftMirror(getInventory().getSelected()); + return CraftItemStack.asCraftMirror(getInventory().getSelectedItem()); } @Override @@ -43,7 +43,7 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i @Override public ItemStack getItemInOffHand() { - return CraftItemStack.asCraftMirror(getInventory().offhand.get(0)); + return CraftItemStack.asCraftMirror(getInventory().getItem(PlayerInventory.SLOT_OFFHAND)); } @Override @@ -169,13 +169,13 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i @Override public int getHeldItemSlot() { - return getInventory().selected; + return getInventory().getSelectedSlot(); } @Override public void setHeldItemSlot(int slot) { Preconditions.checkArgument(slot >= 0 && slot < PlayerInventory.getSelectionSize(), "Slot (%s) is not between 0 and %s inclusive", slot, PlayerInventory.getSelectionSize() - 1); - this.getInventory().selected = slot; + this.getInventory().setSelectedSlot(slot); ((CraftPlayer) this.getHolder()).getHandle().connection.send(new PacketPlayOutHeldItemSlot(slot)); } @@ -241,7 +241,7 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i @Override public ItemStack[] getArmorContents() { - return asCraftMirror(getInventory().armor); + return asCraftMirror(getInventory().getArmorContents()); } private void setSlots(ItemStack[] items, int baseSlot, int length) { @@ -261,22 +261,22 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i @Override public void setStorageContents(ItemStack[] items) throws IllegalArgumentException { - setSlots(items, 0, getInventory().items.size()); + setSlots(items, 0, PlayerInventory.INVENTORY_SIZE); } @Override public void setArmorContents(ItemStack[] items) { - setSlots(items, getInventory().items.size(), getInventory().armor.size()); + setSlots(items, PlayerInventory.INVENTORY_SIZE, PlayerInventory.SLOT_OFFHAND - PlayerInventory.INVENTORY_SIZE); } @Override public ItemStack[] getExtraContents() { - return asCraftMirror(getInventory().offhand); + return new ItemStack[]{getItemInOffHand()}; } @Override public void setExtraContents(ItemStack[] items) { - setSlots(items, getInventory().items.size() + getInventory().armor.size(), getInventory().offhand.size()); + setSlots(items, PlayerInventory.SLOT_OFFHAND, 1); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java index 9ee162973..8518e6352 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -25,12 +25,14 @@ import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftEntityType; +import org.bukkit.craftbukkit.inventory.components.CraftBlocksAttacksComponent; import org.bukkit.craftbukkit.inventory.components.CraftCustomModelDataComponent; import org.bukkit.craftbukkit.inventory.components.CraftEquippableComponent; import org.bukkit.craftbukkit.inventory.components.CraftFoodComponent; import org.bukkit.craftbukkit.inventory.components.CraftJukeboxComponent; import org.bukkit.craftbukkit.inventory.components.CraftToolComponent; import org.bukkit.craftbukkit.inventory.components.CraftUseCooldownComponent; +import org.bukkit.craftbukkit.inventory.components.CraftWeaponComponent; import org.bukkit.craftbukkit.util.CraftLegacy; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -47,12 +49,15 @@ public final class CraftItemFactory implements ItemFactory { instance = new CraftItemFactory(); ConfigurationSerialization.registerClass(SerializableMeta.class); ConfigurationSerialization.registerClass(CraftCustomModelDataComponent.class); + ConfigurationSerialization.registerClass(CraftBlocksAttacksComponent.class); + ConfigurationSerialization.registerClass(CraftBlocksAttacksComponent.CraftDamageReduction.class); ConfigurationSerialization.registerClass(CraftEquippableComponent.class); ConfigurationSerialization.registerClass(CraftFoodComponent.class); ConfigurationSerialization.registerClass(CraftToolComponent.class); ConfigurationSerialization.registerClass(CraftToolComponent.CraftToolRule.class); ConfigurationSerialization.registerClass(CraftJukeboxComponent.class); ConfigurationSerialization.registerClass(CraftUseCooldownComponent.class); + ConfigurationSerialization.registerClass(CraftWeaponComponent.class); } private CraftItemFactory() { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFlag.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFlag.java index 902fb5f22..b5ee4043d 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFlag.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFlag.java @@ -1,12 +1,74 @@ package org.bukkit.craftbukkit.inventory; import com.google.common.base.Preconditions; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import java.util.Arrays; +import java.util.Collection; +import java.util.Locale; +import net.minecraft.core.component.DataComponentType; +import net.minecraft.core.component.DataComponents; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.MinecraftKey; +import org.bukkit.NamespacedKey; import org.bukkit.craftbukkit.legacy.FieldRename; import org.bukkit.craftbukkit.util.ApiVersion; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.inventory.ItemFlag; public class CraftItemFlag { + private static final BiMap> BUKKIT_TO_NMS = HashBiMap.create(); + private static final Collection> HIDE_ADDITIONAL_TOOLTIP = Arrays.asList( + DataComponents.POTION_CONTENTS, DataComponents.WRITABLE_BOOK_CONTENT, DataComponents.WRITTEN_BOOK_CONTENT, + DataComponents.FIREWORKS, DataComponents.FIREWORK_EXPLOSION, + DataComponents.MAP_COLOR, DataComponents.MAP_DECORATIONS, DataComponents.MAP_ID, DataComponents.MAP_POST_PROCESSING, + DataComponents.BANNER_PATTERNS, + DataComponents.STORED_ENCHANTMENTS + ); + + static { + BUKKIT_TO_NMS.put(ItemFlag.HIDE_ARMOR_TRIM, DataComponents.TRIM); + BUKKIT_TO_NMS.put(ItemFlag.HIDE_ATTRIBUTES, DataComponents.ATTRIBUTE_MODIFIERS); + BUKKIT_TO_NMS.put(ItemFlag.HIDE_DESTROYS, DataComponents.CAN_BREAK); + BUKKIT_TO_NMS.put(ItemFlag.HIDE_DYE, DataComponents.DYED_COLOR); + BUKKIT_TO_NMS.put(ItemFlag.HIDE_ENCHANTS, DataComponents.ENCHANTMENTS); + BUKKIT_TO_NMS.put(ItemFlag.HIDE_PLACED_ON, DataComponents.CAN_PLACE_ON); + BUKKIT_TO_NMS.put(ItemFlag.HIDE_UNBREAKABLE, DataComponents.UNBREAKABLE); + } + + public static Collection> bukkitToNMS(ItemFlag bukkit) { + if (bukkit == ItemFlag.HIDE_ADDITIONAL_TOOLTIP) { + return HIDE_ADDITIONAL_TOOLTIP; + } + + DataComponentType type = BUKKIT_TO_NMS.get(bukkit); + if (type == null) { + NamespacedKey key = bukkit.getComponent(); + Preconditions.checkArgument(key != null, "Unknown flag %s must have component key", bukkit); + + type = BuiltInRegistries.DATA_COMPONENT_TYPE.getValue(CraftNamespacedKey.toMinecraft(key)); + } + + Preconditions.checkArgument(type != null, "Unknown flag %s", bukkit); + return Arrays.asList(type); + } + + public static ItemFlag nmsToBukkit(DataComponentType nms) { + ItemFlag inverse = BUKKIT_TO_NMS.inverse().get(nms); + + if (inverse == null) { + MinecraftKey key = BuiltInRegistries.DATA_COMPONENT_TYPE.getKey(nms); + if (key == null) { + throw new IllegalArgumentException("Unregistered component " + nms); + } + + inverse = ItemFlag.valueOf("HIDE_" + key.getPath().toUpperCase(Locale.ROOT).replace('/', '_')); + } + + return inverse; + } + public static String bukkitToString(ItemFlag bukkit) { Preconditions.checkArgument(bukkit != null); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java index ca8009cb1..76468918f 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java @@ -246,7 +246,7 @@ public final class CraftItemMetas { || itemType == ItemType.DECORATED_POT || itemType == ItemType.SUSPICIOUS_SAND || itemType == ItemType.SUSPICIOUS_GRAVEL || itemType == ItemType.CRAFTER || itemType == ItemType.TRIAL_SPAWNER || itemType == ItemType.VAULT - || itemType == ItemType.CREAKING_HEART) { + || itemType == ItemType.CREAKING_HEART || itemType == ItemType.TEST_BLOCK || itemType == ItemType.TEST_INSTANCE_BLOCK) { return asType(BLOCK_STATE_META_DATA); } if (itemType == ItemType.SHIELD) { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index 83653c1f3..9c503f23a 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -7,11 +7,12 @@ import java.util.Map; import java.util.Optional; import net.minecraft.advancements.critereon.CriterionConditionItem; import net.minecraft.advancements.critereon.CriterionConditionValue; +import net.minecraft.advancements.critereon.DataComponentMatchers; import net.minecraft.core.Holder; import net.minecraft.core.HolderSet; +import net.minecraft.core.component.DataComponentExactPredicate; import net.minecraft.core.component.DataComponentMap; import net.minecraft.core.component.DataComponentPatch; -import net.minecraft.core.component.DataComponentPredicate; import net.minecraft.core.component.DataComponents; import net.minecraft.core.component.PatchedDataComponentMap; import net.minecraft.world.item.Item; @@ -95,9 +96,9 @@ public final class CraftItemStack extends ItemStack { public static CriterionConditionItem asCriterionConditionItem(ItemStack original) { net.minecraft.world.item.ItemStack nms = CraftItemStack.asNMSCopy(original); - DataComponentPredicate predicate = DataComponentPredicate.allOf(PatchedDataComponentMap.fromPatch(DataComponentMap.EMPTY, nms.getComponentsPatch())); + DataComponentExactPredicate predicate = DataComponentExactPredicate.allOf(PatchedDataComponentMap.fromPatch(DataComponentMap.EMPTY, nms.getComponentsPatch())); - return new CriterionConditionItem(Optional.of(HolderSet.direct(nms.getItemHolder())), CriterionConditionValue.IntegerRange.ANY, predicate, Collections.emptyMap()); + return new CriterionConditionItem(Optional.of(HolderSet.direct(nms.getItemHolder())), CriterionConditionValue.IntegerRange.ANY, new DataComponentMatchers(predicate, Collections.emptyMap())); } net.minecraft.world.item.ItemStack handle; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java index 6030c5625..d10b0d01c 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java @@ -3,8 +3,8 @@ package org.bukkit.craftbukkit.inventory; import com.google.common.base.Preconditions; import java.util.List; import java.util.Optional; +import net.minecraft.core.component.DataComponentExactPredicate; import net.minecraft.core.component.DataComponentMap; -import net.minecraft.core.component.DataComponentPredicate; import net.minecraft.core.component.PatchedDataComponentMap; import net.minecraft.world.item.Items; import net.minecraft.world.item.trading.ItemCost; @@ -118,11 +118,11 @@ public class CraftMerchantRecipe extends MerchantRecipe { List ingredients = getIngredients(); Preconditions.checkState(!ingredients.isEmpty(), "No offered ingredients"); net.minecraft.world.item.ItemStack baseCostA = CraftItemStack.asNMSCopy(ingredients.get(0)); - DataComponentPredicate baseCostAPredicate = DataComponentPredicate.allOf(PatchedDataComponentMap.fromPatch(DataComponentMap.EMPTY, baseCostA.getComponentsPatch())); + DataComponentExactPredicate baseCostAPredicate = DataComponentExactPredicate.allOf(PatchedDataComponentMap.fromPatch(DataComponentMap.EMPTY, baseCostA.getComponentsPatch())); handle.baseCostA = new ItemCost(baseCostA.getItemHolder(), baseCostA.getCount(), baseCostAPredicate, baseCostA); if (ingredients.size() > 1) { net.minecraft.world.item.ItemStack costB = CraftItemStack.asNMSCopy(ingredients.get(1)); - DataComponentPredicate costBPredicate = DataComponentPredicate.allOf(PatchedDataComponentMap.fromPatch(DataComponentMap.EMPTY, costB.getComponentsPatch())); + DataComponentExactPredicate costBPredicate = DataComponentExactPredicate.allOf(PatchedDataComponentMap.fromPatch(DataComponentMap.EMPTY, costB.getComponentsPatch())); handle.costB = Optional.of(new ItemCost(costB.getItemHolder(), costB.getCount(), costBPredicate, costB)); } else { handle.costB = Optional.empty(); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java index a1c65d946..174d27f02 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java @@ -11,7 +11,6 @@ import org.bukkit.Registry; import org.bukkit.configuration.serialization.DelegateDeserialization; import org.bukkit.craftbukkit.inventory.trim.CraftTrimMaterial; import org.bukkit.craftbukkit.inventory.trim.CraftTrimPattern; -import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.meta.ArmorMeta; import org.bukkit.inventory.meta.trim.ArmorTrim; import org.bukkit.inventory.meta.trim.TrimMaterial; @@ -42,10 +41,6 @@ public class CraftMetaArmor extends CraftMetaItem implements ArmorMeta { TrimPattern trimPattern = CraftTrimPattern.minecraftHolderToBukkit(trimCompound.pattern()); this.trim = new ArmorTrim(trimMaterial, trimPattern); - - if (!trimCompound.showInTooltip()) { - addItemFlags(ItemFlag.HIDE_ARMOR_TRIM); - } }); } @@ -78,7 +73,7 @@ public class CraftMetaArmor extends CraftMetaItem implements ArmorMeta { super.applyToItem(itemTag); if (hasTrim()) { - itemTag.put(TRIM, new net.minecraft.world.item.equipment.trim.ArmorTrim(CraftTrimMaterial.bukkitToMinecraftHolder(trim.getMaterial()), CraftTrimPattern.bukkitToMinecraftHolder(trim.getPattern()), !hasItemFlag(ItemFlag.HIDE_ARMOR_TRIM))); + itemTag.put(TRIM, new net.minecraft.world.item.equipment.trim.ArmorTrim(CraftTrimMaterial.bukkitToMinecraftHolder(trim.getMaterial()), CraftTrimPattern.bukkitToMinecraftHolder(trim.getPattern()))); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java index 7d02f8eca..26c92d415 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java @@ -43,9 +43,7 @@ public class CraftMetaArmorStand extends CraftMetaItem { void deserializeInternal(NBTTagCompound tag, Object context) { super.deserializeInternal(tag, context); - if (tag.contains(ENTITY_TAG.NBT)) { - entityTag = tag.getCompound(ENTITY_TAG.NBT); - } + entityTag = tag.getCompound(ENTITY_TAG.NBT).orElse(entityTag); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaAxolotlBucket.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaAxolotlBucket.java index e43e68c3f..8c167dce7 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaAxolotlBucket.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaAxolotlBucket.java @@ -8,7 +8,6 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.item.component.CustomData; import org.bukkit.configuration.serialization.DelegateDeserialization; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.entity.Axolotl; import org.bukkit.inventory.meta.AxolotlBucketMeta; @@ -42,16 +41,16 @@ public class CraftMetaAxolotlBucket extends CraftMetaItem implements AxolotlBuck getOrEmpty(tag, ENTITY_TAG).ifPresent((nbt) -> { entityTag = nbt.copyTag(); - if (entityTag.contains(VARIANT.NBT, CraftMagicNumbers.NBT.TAG_INT)) { - this.variant = entityTag.getInt(VARIANT.NBT); - } + entityTag.getInt(VARIANT.NBT).ifPresent((variant) -> { + this.variant = variant; + }); }); getOrEmpty(tag, BUCKET_ENTITY_TAG).ifPresent((nbt) -> { bucketEntityTag = nbt.copyTag(); - if (bucketEntityTag.contains(VARIANT.NBT, CraftMagicNumbers.NBT.TAG_INT)) { - this.variant = bucketEntityTag.getInt(VARIANT.NBT); - } + bucketEntityTag.getInt(VARIANT.NBT).ifPresent((variant) -> { + this.variant = variant; + }); }); } @@ -68,12 +67,8 @@ public class CraftMetaAxolotlBucket extends CraftMetaItem implements AxolotlBuck void deserializeInternal(NBTTagCompound tag, Object context) { super.deserializeInternal(tag, context); - if (tag.contains(ENTITY_TAG.NBT)) { - entityTag = tag.getCompound(ENTITY_TAG.NBT); - } - if (tag.contains(BUCKET_ENTITY_TAG.NBT)) { - bucketEntityTag = tag.getCompound(BUCKET_ENTITY_TAG.NBT); - } + entityTag = tag.getCompound(ENTITY_TAG.NBT).orElse(entityTag); + bucketEntityTag = tag.getCompound(BUCKET_ENTITY_TAG.NBT).orElse(bucketEntityTag); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java index 487d07b83..c15faa0a0 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java @@ -24,7 +24,6 @@ import org.bukkit.block.BlockState; import org.bukkit.configuration.serialization.DelegateDeserialization; import org.bukkit.craftbukkit.block.CraftBlockEntityState; import org.bukkit.craftbukkit.block.CraftBlockStates; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.inventory.meta.BlockStateMeta; import org.bukkit.util.BlockVector; @@ -82,8 +81,8 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta NBTTagCompound nbt = blockTag.copyTag(); blockEntityTag = getBlockState(material, nbt); - if (nbt.contains("x", CraftMagicNumbers.NBT.TAG_ANY_NUMBER) && nbt.contains("y", CraftMagicNumbers.NBT.TAG_ANY_NUMBER) && nbt.contains("z", CraftMagicNumbers.NBT.TAG_ANY_NUMBER)) { - position = new BlockVector(nbt.getInt("x"), nbt.getInt("y"), nbt.getInt("z")); + if (nbt.contains("x") && nbt.contains("y") && nbt.contains("z")) { + position = new BlockVector(nbt.getIntOr("x", 0), nbt.getIntOr("y", 0), nbt.getIntOr("z", 0)); } }); @@ -161,9 +160,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta void deserializeInternal(NBTTagCompound tag, Object context) { super.deserializeInternal(tag, context); - if (tag.contains(BLOCK_ENTITY_TAG.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { - internalTag = tag.getCompound(BLOCK_ENTITY_TAG.NBT); - } + this.internalTag = tag.getCompound(BLOCK_ENTITY_TAG.NBT).orElse(this.internalTag); } @Override @@ -257,7 +254,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta blockEntityTag.putString("id", "minecraft:shulker_box"); } - pos = TileEntity.getPosFromTag(blockEntityTag); + pos = TileEntity.getPosFromTag(null, blockEntityTag); } // This is expected to always return a CraftBlockEntityState for the passed material: @@ -277,14 +274,11 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta private static Material shieldToBannerHack(NBTTagCompound tag) { if (tag != null) { - if (tag.contains("components", CraftMagicNumbers.NBT.TAG_COMPOUND)) { - NBTTagCompound components = tag.getCompound("components"); - if (components.contains("minecraft:base_color", CraftMagicNumbers.NBT.TAG_STRING)) { - DyeColor color = DyeColor.getByWoolData((byte) EnumColor.byName(components.getString("minecraft:base_color"), EnumColor.WHITE).getId()); + tag.getCompound("components").flatMap((components) -> components.getString("minecraft:base_color").map((baseColor) -> { + DyeColor color = DyeColor.getByWoolData((byte) EnumColor.byName(baseColor, EnumColor.WHITE).getId()); - return CraftMetaShield.shieldToBannerHack(color); - } - } + return CraftMetaShield.shieldToBannerHack(color); + })).orElse(Material.WHITE_BANNER); } return Material.WHITE_BANNER; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEnchantedBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEnchantedBook.java index ad1ab6ad0..1303b58d6 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEnchantedBook.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEnchantedBook.java @@ -37,9 +37,6 @@ class CraftMetaEnchantedBook extends CraftMetaItem implements EnchantmentStorage getOrEmpty(tag, STORED_ENCHANTMENTS).ifPresent((itemEnchantments) -> { enchantments = buildEnchantments(itemEnchantments); - if (!itemEnchantments.showInTooltip) { - addItemFlags(ItemFlag.HIDE_ADDITIONAL_TOOLTIP); - } }); } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java index 6721b8453..2b6a33d77 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java @@ -54,9 +54,9 @@ public class CraftMetaEntityTag extends CraftMetaItem { void deserializeInternal(NBTTagCompound tag, Object context) { super.deserializeInternal(tag, context); - if (tag.contains(ENTITY_TAG.NBT)) { - entityTag = tag.getCompound(ENTITY_TAG.NBT); - } + tag.getCompound(ENTITY_TAG.NBT).ifPresent((entityTag) -> { + this.entityTag = entityTag; + }); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index ce3880486..846f86f49 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -23,12 +23,14 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.LinkedHashSet; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.Objects; import java.util.Optional; +import java.util.SequencedSet; import java.util.Set; import java.util.StringJoiner; import java.util.logging.Level; @@ -53,6 +55,7 @@ import net.minecraft.nbt.SnbtPrinterTagVisitor; import net.minecraft.network.chat.IChatBaseComponent; import net.minecraft.resources.MinecraftKey; import net.minecraft.server.MinecraftServer; +import net.minecraft.sounds.SoundEffect; import net.minecraft.sounds.SoundEffects; import net.minecraft.tags.TagKey; import net.minecraft.util.Unit; @@ -66,6 +69,7 @@ import net.minecraft.world.item.ItemUseAnimation; import net.minecraft.world.item.JukeboxPlayable; import net.minecraft.world.item.JukeboxSongs; import net.minecraft.world.item.component.BlockItemStateProperties; +import net.minecraft.world.item.component.BlocksAttacks; import net.minecraft.world.item.component.Consumable; import net.minecraft.world.item.component.CustomData; import net.minecraft.world.item.component.CustomModelData; @@ -73,9 +77,10 @@ import net.minecraft.world.item.component.DamageResistant; import net.minecraft.world.item.component.ItemAttributeModifiers; import net.minecraft.world.item.component.ItemLore; import net.minecraft.world.item.component.Tool; -import net.minecraft.world.item.component.Unbreakable; +import net.minecraft.world.item.component.TooltipDisplay; import net.minecraft.world.item.component.UseCooldown; import net.minecraft.world.item.component.UseRemainder; +import net.minecraft.world.item.component.Weapon; import net.minecraft.world.item.enchantment.Enchantable; import net.minecraft.world.item.enchantment.ItemEnchantments; import net.minecraft.world.item.equipment.Equippable; @@ -83,6 +88,8 @@ import net.minecraft.world.level.block.state.IBlockData; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.NamespacedKey; +import org.bukkit.Registry; +import org.bukkit.Sound; import org.bukkit.Tag; import org.bukkit.attribute.Attribute; import org.bukkit.attribute.AttributeModifier; @@ -90,6 +97,7 @@ import org.bukkit.block.data.BlockData; import org.bukkit.configuration.serialization.DelegateDeserialization; import org.bukkit.craftbukkit.CraftEquipmentSlot; import org.bukkit.craftbukkit.CraftRegistry; +import org.bukkit.craftbukkit.CraftSound; import org.bukkit.craftbukkit.Overridden; import org.bukkit.craftbukkit.attribute.CraftAttribute; import org.bukkit.craftbukkit.attribute.CraftAttributeInstance; @@ -97,12 +105,14 @@ import org.bukkit.craftbukkit.block.CraftBlockType; import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.enchantments.CraftEnchantment; import org.bukkit.craftbukkit.inventory.ItemMetaKey.Specific; +import org.bukkit.craftbukkit.inventory.components.CraftBlocksAttacksComponent; import org.bukkit.craftbukkit.inventory.components.CraftCustomModelDataComponent; import org.bukkit.craftbukkit.inventory.components.CraftEquippableComponent; import org.bukkit.craftbukkit.inventory.components.CraftFoodComponent; import org.bukkit.craftbukkit.inventory.components.CraftJukeboxComponent; import org.bukkit.craftbukkit.inventory.components.CraftToolComponent; import org.bukkit.craftbukkit.inventory.components.CraftUseCooldownComponent; +import org.bukkit.craftbukkit.inventory.components.CraftWeaponComponent; import org.bukkit.craftbukkit.inventory.components.consumable.CraftConsumableComponent; import org.bukkit.craftbukkit.inventory.tags.DeprecatedCustomTagContainer; import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer; @@ -122,12 +132,14 @@ import org.bukkit.inventory.meta.BlockDataMeta; import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.Repairable; +import org.bukkit.inventory.meta.components.BlocksAttacksComponent; import org.bukkit.inventory.meta.components.CustomModelDataComponent; import org.bukkit.inventory.meta.components.EquippableComponent; import org.bukkit.inventory.meta.components.FoodComponent; import org.bukkit.inventory.meta.components.JukeboxPlayableComponent; import org.bukkit.inventory.meta.components.ToolComponent; import org.bukkit.inventory.meta.components.UseCooldownComponent; +import org.bukkit.inventory.meta.components.WeaponComponent; import org.bukkit.inventory.meta.components.consumable.ConsumableComponent; import org.bukkit.inventory.meta.tags.CustomItemTagContainer; import org.bukkit.persistence.PersistentDataContainer; @@ -211,15 +223,15 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @Specific(Specific.To.NBT) static final ItemMetaKey ATTRIBUTES_SLOT = new ItemMetaKey("Slot"); @Specific(Specific.To.NBT) - static final ItemMetaKey HIDEFLAGS = new ItemMetaKey("ItemFlags"); + static final ItemMetaKeyType HIDEFLAGS = new ItemMetaKeyType<>(DataComponents.TOOLTIP_DISPLAY, "ItemFlags"); @Specific(Specific.To.NBT) - static final ItemMetaKeyType HIDE_TOOLTIP = new ItemMetaKeyType<>(DataComponents.HIDE_TOOLTIP, "hide-tool-tip"); + static final ItemMetaKey HIDE_TOOLTIP = new ItemMetaKey("hide-tool-tip"); @Specific(Specific.To.NBT) static final ItemMetaKeyType TOOLTIP_STYLE = new ItemMetaKeyType<>(DataComponents.TOOLTIP_STYLE, "tool-tip-style"); @Specific(Specific.To.NBT) static final ItemMetaKeyType ITEM_MODEL = new ItemMetaKeyType<>(DataComponents.ITEM_MODEL, "item-model"); @Specific(Specific.To.NBT) - static final ItemMetaKeyType UNBREAKABLE = new ItemMetaKeyType<>(DataComponents.UNBREAKABLE, "Unbreakable"); + static final ItemMetaKeyType UNBREAKABLE = new ItemMetaKeyType<>(DataComponents.UNBREAKABLE, "Unbreakable"); @Specific(Specific.To.NBT) static final ItemMetaKeyType ENCHANTMENT_GLINT_OVERRIDE = new ItemMetaKeyType<>(DataComponents.ENCHANTMENT_GLINT_OVERRIDE, "enchantment-glint-override"); @Specific(Specific.To.NBT) @@ -241,10 +253,16 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @Specific(Specific.To.NBT) static final ItemMetaKeyType TOOL = new ItemMetaKeyType<>(DataComponents.TOOL, "tool"); @Specific(Specific.To.NBT) + static final ItemMetaKeyType BLOCKS_ATTACKS = new ItemMetaKeyType<>(DataComponents.BLOCKS_ATTACKS, "blocks-attacks"); + @Specific(Specific.To.NBT) + static final ItemMetaKeyType WEAPON = new ItemMetaKeyType<>(DataComponents.WEAPON, "weapon"); + @Specific(Specific.To.NBT) static final ItemMetaKeyType EQUIPPABLE = new ItemMetaKeyType<>(DataComponents.EQUIPPABLE, "equippable"); @Specific(Specific.To.NBT) static final ItemMetaKeyType JUKEBOX_PLAYABLE = new ItemMetaKeyType<>(DataComponents.JUKEBOX_PLAYABLE, "jukebox-playable"); @Specific(Specific.To.NBT) + static final ItemMetaKeyType> BREAK_SOUND = new ItemMetaKeyType<>(DataComponents.BREAK_SOUND, "break-sound"); + @Specific(Specific.To.NBT) static final ItemMetaKeyType DAMAGE = new ItemMetaKeyType<>(DataComponents.DAMAGE, "Damage"); @Specific(Specific.To.NBT) static final ItemMetaKeyType MAX_DAMAGE = new ItemMetaKeyType<>(DataComponents.MAX_DAMAGE, "max-damage"); @@ -252,8 +270,6 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { static final ItemMetaKeyType BLOCK_DATA = new ItemMetaKeyType<>(DataComponents.BLOCK_STATE, "BlockStateTag"); static final ItemMetaKey BUKKIT_CUSTOM_TAG = new ItemMetaKey("PublicBukkitValues"); @Specific(Specific.To.NBT) - static final ItemMetaKeyType HIDE_ADDITIONAL_TOOLTIP = new ItemMetaKeyType(DataComponents.HIDE_ADDITIONAL_TOOLTIP); - @Specific(Specific.To.NBT) static final ItemMetaKeyType CUSTOM_DATA = new ItemMetaKeyType<>(DataComponents.CUSTOM_DATA); // We store the raw original JSON representation of all text data. See SPIGOT-5063, SPIGOT-5656, SPIGOT-5304 @@ -266,7 +282,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { private Map enchantments; private Multimap attributeModifiers; private int repairCost; - private int hideFlag; + private SequencedSet> hiddenComponents; private boolean hideTooltip; private NamespacedKey tooltipStyle; private NamespacedKey itemModel; @@ -281,8 +297,11 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { private CraftFoodComponent food; private CraftConsumableComponent consumable; private CraftToolComponent tool; + private CraftBlocksAttacksComponent blocksAttacks; + private CraftWeaponComponent weapon; private CraftEquippableComponent equippable; private CraftJukeboxComponent jukebox; + private Holder breakSound; private int damage; private Integer maxDamage; @@ -323,7 +342,9 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } this.repairCost = meta.repairCost; - this.hideFlag = meta.hideFlag; + if (meta.hasItemFlags()) { + this.hiddenComponents = new LinkedHashSet<>(meta.hiddenComponents); + } this.hideTooltip = meta.hideTooltip; this.tooltipStyle = meta.tooltipStyle; this.itemModel = meta.itemModel; @@ -348,12 +369,19 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { if (meta.hasTool()) { this.tool = new CraftToolComponent(meta.tool); } + if (meta.hasBlocksAttacks()) { + this.blocksAttacks = new CraftBlocksAttacksComponent(meta.blocksAttacks); + } + if (meta.hasWeapon()) { + this.weapon = new CraftWeaponComponent(meta.weapon); + } if (meta.hasEquippable()) { this.equippable = new CraftEquippableComponent(meta.equippable); } if (meta.hasJukeboxPlayable()) { this.jukebox = new CraftJukeboxComponent(meta.jukebox); } + this.breakSound = breakSound; this.damage = meta.damage; this.maxDamage = meta.maxDamage; this.unhandledTags.copy(meta.unhandledTags.build()); @@ -394,26 +422,24 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { getOrEmpty(tag, ENCHANTMENTS).ifPresent((en) -> { this.enchantments = buildEnchantments(en); - if (!en.showInTooltip) { - addItemFlags(ItemFlag.HIDE_ENCHANTS); - } }); getOrEmpty(tag, ATTRIBUTES).ifPresent((en) -> { this.attributeModifiers = buildModifiers(en); - if (!en.showInTooltip()) { - addItemFlags(ItemFlag.HIDE_ATTRIBUTES); - } }); getOrEmpty(tag, REPAIR).ifPresent((i) -> { repairCost = i; }); - getOrEmpty(tag, HIDE_ADDITIONAL_TOOLTIP).ifPresent((h) -> { - addItemFlags(ItemFlag.HIDE_ADDITIONAL_TOOLTIP); - }); - getOrEmpty(tag, HIDE_TOOLTIP).ifPresent((u) -> { - hideTooltip = true; + getOrEmpty(tag, HIDEFLAGS).ifPresent((h) -> { + for (DataComponentType hidden : h.hiddenComponents()) { + ItemFlag flag = CraftItemFlag.nmsToBukkit(hidden); + if (flag != null) { + addItemFlags(flag); + } + } + + hideTooltip = h.hideTooltip(); }); getOrEmpty(tag, TOOLTIP_STYLE).ifPresent((key) -> { tooltipStyle = CraftNamespacedKey.fromMinecraft(key); @@ -423,9 +449,6 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { }); getOrEmpty(tag, UNBREAKABLE).ifPresent((u) -> { unbreakable = true; - if (!u.showInTooltip()) { - addItemFlags(ItemFlag.HIDE_UNBREAKABLE); - } }); getOrEmpty(tag, ENCHANTMENT_GLINT_OVERRIDE).ifPresent((override) -> { enchantmentGlintOverride = override; @@ -457,12 +480,21 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { getOrEmpty(tag, TOOL).ifPresent((toolInfo) -> { tool = new CraftToolComponent(toolInfo); }); + getOrEmpty(tag, BLOCKS_ATTACKS).ifPresent((blocksInfo) -> { + blocksAttacks = new CraftBlocksAttacksComponent(blocksInfo); + }); + getOrEmpty(tag, WEAPON).ifPresent((weaponInfo) -> { + weapon = new CraftWeaponComponent(weaponInfo); + }); getOrEmpty(tag, EQUIPPABLE).ifPresent((equippableInfo) -> { equippable = new CraftEquippableComponent(equippableInfo); }); getOrEmpty(tag, JUKEBOX_PLAYABLE).ifPresent((jukeboxPlayable) -> { jukebox = new CraftJukeboxComponent(jukeboxPlayable); }); + getOrEmpty(tag, BREAK_SOUND).ifPresent((sound) -> { + breakSound = sound; + }); getOrEmpty(tag, DAMAGE).ifPresent((i) -> { damage = i; }); @@ -471,15 +503,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { }); getOrEmpty(tag, CUSTOM_DATA).ifPresent((customData) -> { customTag = customData.copyTag(); - if (customTag.contains(BUKKIT_CUSTOM_TAG.NBT)) { - NBTTagCompound compound = customTag.getCompound(BUKKIT_CUSTOM_TAG.NBT); - Set keys = compound.getAllKeys(); + customTag.getCompound(BUKKIT_CUSTOM_TAG.NBT).ifPresent((compound) -> { + Set keys = compound.keySet(); for (String key : keys) { persistentDataContainer.put(key, compound.get(key).copy()); } customTag.remove(BUKKIT_CUSTOM_TAG.NBT); - } + }); if (customTag.isEmpty()) { customTag = null; @@ -592,8 +623,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } else { // Legacy pre 1.20.5: NBTTagCompound nbtBlockData = (NBTTagCompound) CraftNBTTagConfigSerializer.deserialize(blockData); - for (String key : nbtBlockData.getAllKeys()) { - mapBlockData.put(key, nbtBlockData.getString(key)); + for (String key : nbtBlockData.keySet()) { + mapBlockData.put(key, nbtBlockData.getStringOr(key, "")); } } @@ -694,6 +725,16 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { setTool(tool); } + CraftBlocksAttacksComponent blocksAttacks = SerializableMeta.getObject(CraftBlocksAttacksComponent.class, map, BLOCKS_ATTACKS.BUKKIT, true); + if (blocksAttacks != null) { + setBlocksAttacks(blocksAttacks); + } + + CraftWeaponComponent weapon = SerializableMeta.getObject(CraftWeaponComponent.class, map, WEAPON.BUKKIT, true); + if (weapon != null) { + setWeapon(weapon); + } + CraftEquippableComponent equippable = SerializableMeta.getObject(CraftEquippableComponent.class, map, EQUIPPABLE.BUKKIT, true); if (equippable != null) { setEquippable(equippable); @@ -704,6 +745,11 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { setJukeboxPlayable(jukeboxPlayable); } + String snd = SerializableMeta.getString(map, "break-sound", true); + if (snd != null) { + setBreakSound(Registry.SOUNDS.get(NamespacedKey.fromString(snd))); + } + Integer damage = SerializableMeta.getObject(Integer.class, map, DAMAGE.BUKKIT, true); if (damage != null) { setDamage(damage); @@ -780,33 +826,30 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { void deserializeInternal(NBTTagCompound tag, Object context) { // SPIGOT-4576: Need to migrate from internal to proper data - if (tag.contains(ATTRIBUTES.NBT, CraftMagicNumbers.NBT.TAG_LIST)) { + tag.getList(ATTRIBUTES.NBT).ifPresent((ignore) -> { this.attributeModifiers = buildModifiersLegacy(tag, ATTRIBUTES); - } + }); } private static Multimap buildModifiersLegacy(NBTTagCompound tag, ItemMetaKey key) { Multimap modifiers = LinkedHashMultimap.create(); - if (!tag.contains(key.NBT, CraftMagicNumbers.NBT.TAG_LIST)) { - return modifiers; - } - NBTTagList mods = tag.getList(key.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND); + NBTTagList mods = tag.getListOrEmpty(key.NBT); int size = mods.size(); for (int i = 0; i < size; i++) { - NBTTagCompound entry = mods.getCompound(i); + NBTTagCompound entry = mods.getCompoundOrEmpty(i); if (entry.isEmpty()) { // entry is not an actual NBTTagCompound. getCompound returns empty NBTTagCompound in that case continue; } - net.minecraft.world.entity.ai.attributes.AttributeModifier nmsModifier = net.minecraft.world.entity.ai.attributes.AttributeModifier.load(entry); + net.minecraft.world.entity.ai.attributes.AttributeModifier nmsModifier = entry.read(net.minecraft.world.entity.ai.attributes.AttributeModifier.MAP_CODEC).orElse(null); if (nmsModifier == null) { continue; } AttributeModifier attribMod = CraftAttributeInstance.convert(nmsModifier); - String attributeName = entry.getString(ATTRIBUTES_IDENTIFIER.NBT); + String attributeName = entry.getStringOr(ATTRIBUTES_IDENTIFIER.NBT, null); if (attributeName == null || attributeName.isEmpty()) { continue; } @@ -816,27 +859,25 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { continue; } - if (entry.contains(ATTRIBUTES_SLOT.NBT, CraftMagicNumbers.NBT.TAG_STRING)) { - String slotName = entry.getString(ATTRIBUTES_SLOT.NBT); - if (slotName == null || slotName.isEmpty()) { - modifiers.put(attribute, attribMod); - continue; - } - - EquipmentSlot slot = null; - try { - slot = CraftEquipmentSlot.getSlot(EnumItemSlot.byName(slotName.toLowerCase(Locale.ROOT))); - } catch (IllegalArgumentException ex) { - // SPIGOT-4551 - Slot is invalid, should really match nothing but this is undefined behaviour anyway - } - - if (slot == null) { - modifiers.put(attribute, attribMod); - continue; - } - - attribMod = new AttributeModifier(attribMod.getKey(), attribMod.getAmount(), attribMod.getOperation(), slot.getGroup()); + String slotName = entry.getStringOr(ATTRIBUTES_SLOT.NBT, null); + if (slotName == null || slotName.isEmpty()) { + modifiers.put(attribute, attribMod); + continue; } + + EquipmentSlot slot = null; + try { + slot = CraftEquipmentSlot.getSlot(EnumItemSlot.byName(slotName.toLowerCase(Locale.ROOT))); + } catch (IllegalArgumentException ex) { + // SPIGOT-4551 - Slot is invalid, should really match nothing but this is undefined behaviour anyway + } + + if (slot == null) { + modifiers.put(attribute, attribMod); + continue; + } + + attribMod = new AttributeModifier(attribMod.getKey(), attribMod.getAmount(), attribMod.getOperation(), slot.getGroup()); modifiers.put(attribute, attribMod); } return modifiers; @@ -921,10 +962,9 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { itemTag.put(BLOCK_DATA, new BlockItemStateProperties(blockData)); } - if (hideFlag != 0) { - if (hasItemFlag(ItemFlag.HIDE_ADDITIONAL_TOOLTIP)) { - itemTag.put(HIDE_ADDITIONAL_TOOLTIP, Unit.INSTANCE); - } + if (hiddenComponents != null || hideTooltip) { + SequencedSet> hidden = (hiddenComponents != null) ? hiddenComponents : new LinkedHashSet<>(); + itemTag.put(HIDEFLAGS, new TooltipDisplay(hideTooltip, hidden)); } applyEnchantments(enchantments, itemTag, ENCHANTMENTS, ItemFlag.HIDE_ENCHANTS); @@ -934,10 +974,6 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { itemTag.put(REPAIR, repairCost); } - if (isHideTooltip()) { - itemTag.put(HIDE_TOOLTIP, Unit.INSTANCE); - } - if (hasTooltipStyle()) { itemTag.put(TOOLTIP_STYLE, CraftNamespacedKey.toMinecraft(getTooltipStyle())); } @@ -947,7 +983,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } if (isUnbreakable()) { - itemTag.put(UNBREAKABLE, new Unbreakable(!hasItemFlag(ItemFlag.HIDE_UNBREAKABLE))); + itemTag.put(UNBREAKABLE, Unit.INSTANCE); } if (hasEnchantmentGlintOverride()) { @@ -990,6 +1026,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { itemTag.put(TOOL, tool.getHandle()); } + if (hasBlocksAttacks()) { + itemTag.put(BLOCKS_ATTACKS, blocksAttacks.getHandle()); + } + + if (hasWeapon()) { + itemTag.put(WEAPON, weapon.getHandle()); + } + if (hasEquippable()) { itemTag.put(EQUIPPABLE, equippable.getHandle()); } @@ -998,6 +1042,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { itemTag.put(JUKEBOX_PLAYABLE, jukebox.getHandle()); } + if (hasBreakSound()) { + itemTag.put(BREAK_SOUND, breakSound); + } + if (hasDamage()) { itemTag.put(DAMAGE, damage); } @@ -1051,15 +1099,11 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } } - list.showInTooltip = !hasItemFlag(itemFlag); tag.put(key, list.toImmutable()); } void applyModifiers(Multimap modifiers, CraftMetaItem.Applicator tag) { if (modifiers == null || modifiers.isEmpty()) { - if (hasItemFlag(ItemFlag.HIDE_ATTRIBUTES)) { - tag.put(ATTRIBUTES, new ItemAttributeModifiers(Collections.emptyList(), false)); - } return; } @@ -1078,7 +1122,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { EquipmentSlotGroup group = CraftEquipmentSlot.getNMSGroup(entry.getValue().getSlotGroup()); list.add(name, nmsModifier, group); } - tag.put(ATTRIBUTES, list.build().withTooltip(!hasItemFlag(ItemFlag.HIDE_ATTRIBUTES))); + tag.put(ATTRIBUTES, list.build()); } boolean applicableTo(Material type) { @@ -1096,7 +1140,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @Overridden boolean isEmpty() { - return !(hasDisplayName() || hasItemName() || hasLocalizedName() || hasEnchants() || (lore != null) || hasCustomModelData() || hasEnchantable() || hasBlockData() || hasRepairCost() || !unhandledTags.build().isEmpty() || !removedTags.isEmpty() || !persistentDataContainer.isEmpty() || hideFlag != 0 || isHideTooltip() || hasTooltipStyle() || hasItemModel() || isUnbreakable() || hasEnchantmentGlintOverride() || isGlider() || hasDamageResistant() || hasMaxStackSize() || hasRarity() || hasUseRemainder() || hasUseCooldown() || hasFood() || hasConsumable() || hasTool() || hasJukeboxPlayable() || hasEquippable() || hasDamage() || hasMaxDamage() || hasAttributeModifiers() || customTag != null); + return !(hasDisplayName() || hasItemName() || hasLocalizedName() || hasEnchants() || (lore != null) || hasCustomModelData() || hasEnchantable() || hasBlockData() || hasRepairCost() || !unhandledTags.build().isEmpty() || !removedTags.isEmpty() || !persistentDataContainer.isEmpty() || hasItemFlags() || isHideTooltip() || hasTooltipStyle() || hasItemModel() || isUnbreakable() || hasEnchantmentGlintOverride() || isGlider() || hasDamageResistant() || hasMaxStackSize() || hasRarity() || hasUseRemainder() || hasUseCooldown() || hasFood() || hasConsumable() || hasTool() || hasBlocksAttacks() || hasWeapon() || hasJukeboxPlayable() || hasBreakSound() || hasEquippable() || hasDamage() || hasMaxDamage() || hasAttributeModifiers() || customTag != null); } @Override @@ -1219,14 +1263,28 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @Override public void addItemFlags(ItemFlag... hideFlags) { for (ItemFlag f : hideFlags) { - this.hideFlag |= getBitModifier(f); + Collection> nms = CraftItemFlag.bukkitToNMS(f); + if (nms != null) { + if (hiddenComponents == null) { + hiddenComponents = new LinkedHashSet<>(); + } + + hiddenComponents.addAll(nms); + } } } @Override public void removeItemFlags(ItemFlag... hideFlags) { + if (hiddenComponents == null) { + return; + } + for (ItemFlag f : hideFlags) { - this.hideFlag &= ~getBitModifier(f); + Collection> nms = CraftItemFlag.bukkitToNMS(f); + if (nms != null) { + hiddenComponents.removeAll(nms); + } } } @@ -1245,12 +1303,12 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @Override public boolean hasItemFlag(ItemFlag flag) { - int bitModifier = getBitModifier(flag); - return (this.hideFlag & bitModifier) == bitModifier; + Collection> nms = CraftItemFlag.bukkitToNMS(flag); + return nms != null && hiddenComponents != null && hiddenComponents.containsAll(nms); } - private int getBitModifier(ItemFlag hideFlag) { - return 1 << hideFlag.ordinal(); + public boolean hasItemFlags() { + return hiddenComponents != null && !hiddenComponents.isEmpty(); } @Override @@ -1545,7 +1603,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @Override public ToolComponent getTool() { - return (this.hasTool()) ? new CraftToolComponent(this.tool) : new CraftToolComponent(new Tool(Collections.emptyList(), 1.0F, 0)); + return (this.hasTool()) ? new CraftToolComponent(this.tool) : new CraftToolComponent(new Tool(Collections.emptyList(), 1.0F, 1, true)); } @Override @@ -1553,6 +1611,38 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { this.tool = (tool == null) ? null : new CraftToolComponent((CraftToolComponent) tool); } + @Override + public boolean hasBlocksAttacks() { + return this.blocksAttacks != null; + } + + @Override + public BlocksAttacksComponent getBlocksAttacks() { + return (this.hasBlocksAttacks()) ? new CraftBlocksAttacksComponent(this.blocksAttacks) : new CraftBlocksAttacksComponent(new BlocksAttacks(0.0F, 1.0F, Collections.emptyList(), + new net.minecraft.world.item.component.BlocksAttacks.b(0, 0, 0), + Optional.empty(), Optional.empty(), Optional.empty())); + } + + @Override + public void setBlocksAttacks(BlocksAttacksComponent blocksAttacks) { + this.blocksAttacks = (this.blocksAttacks == null) ? null : new CraftBlocksAttacksComponent((CraftBlocksAttacksComponent) this.blocksAttacks); + } + + @Override + public boolean hasWeapon() { + return this.weapon != null; + } + + @Override + public WeaponComponent getWeapon() { + return (this.hasWeapon()) ? new CraftWeaponComponent(this.weapon) : new CraftWeaponComponent(new Weapon(0)); + } + + @Override + public void setWeapon(WeaponComponent weapon) { + this.weapon = (weapon == null) ? null : new CraftWeaponComponent((CraftWeaponComponent) weapon); + } + @Override public boolean hasEquippable() { return this.equippable != null; @@ -1575,7 +1665,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @Override public JukeboxPlayableComponent getJukeboxPlayable() { - return (this.hasJukeboxPlayable()) ? new CraftJukeboxComponent(this.jukebox) : new CraftJukeboxComponent(new JukeboxPlayable(new EitherHolder<>(JukeboxSongs.THIRTEEN), true)); + return (this.hasJukeboxPlayable()) ? new CraftJukeboxComponent(this.jukebox) : new CraftJukeboxComponent(new JukeboxPlayable(new EitherHolder<>(JukeboxSongs.THIRTEEN))); } @Override @@ -1583,6 +1673,21 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { this.jukebox = (jukeboxPlayable == null) ? null : new CraftJukeboxComponent((CraftJukeboxComponent) jukeboxPlayable); } + @Override + public boolean hasBreakSound() { + return this.breakSound != null; + } + + @Override + public Sound getBreakSound() { + return (this.breakSound != null) ? CraftSound.minecraftHolderToBukkit(this.breakSound) : null; + } + + @Override + public void setBreakSound(Sound sound) { + this.breakSound = (sound != null) ? CraftSound.bukkitToMinecraftHolder(sound) : null; + } + @Override public boolean hasAttributeModifiers() { return attributeModifiers != null && !attributeModifiers.isEmpty(); @@ -1828,7 +1933,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { && (this.removedTags.equals(that.removedTags)) && (Objects.equals(this.customTag, that.customTag)) && (this.persistentDataContainer.equals(that.persistentDataContainer)) - && (this.hideFlag == that.hideFlag) + && (this.hasItemFlags() ? that.hasItemFlags() && this.hiddenComponents.equals(that.hiddenComponents) : !that.hasItemFlags()) && (this.isHideTooltip() == that.isHideTooltip()) && (this.hasTooltipStyle() ? that.hasTooltipStyle() && this.tooltipStyle.equals(that.tooltipStyle) : !that.hasTooltipStyle()) && (this.hasItemModel() ? that.hasItemModel() && this.itemModel.equals(that.itemModel) : !that.hasItemModel()) @@ -1843,8 +1948,11 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { && (this.hasFood() ? that.hasFood() && this.food.equals(that.food) : !that.hasFood()) && (this.hasConsumable() ? that.hasConsumable() && this.consumable.equals(that.consumable) : !that.hasConsumable()) && (this.hasTool() ? that.hasTool() && this.tool.equals(that.tool) : !that.hasTool()) + && (this.hasBlocksAttacks() ? that.hasBlocksAttacks() && this.blocksAttacks.equals(that.blocksAttacks) : !that.hasBlocksAttacks()) + && (this.hasWeapon() ? that.hasWeapon() && this.weapon.equals(that.weapon) : !that.hasWeapon()) && (this.hasEquippable() ? that.hasEquippable() && this.equippable.equals(that.equippable) : !that.hasEquippable()) && (this.hasJukeboxPlayable() ? that.hasJukeboxPlayable() && this.jukebox.equals(that.jukebox) : !that.hasJukeboxPlayable()) + && (this.hasBreakSound() ? that.hasBreakSound() && this.breakSound.equals(that.breakSound) : !that.hasBreakSound()) && (this.hasDamage() ? that.hasDamage() && this.damage == that.damage : !that.hasDamage()) && (this.hasMaxDamage() ? that.hasMaxDamage() && this.maxDamage.equals(that.maxDamage) : !that.hasMaxDamage()) && (this.version == that.version); @@ -1880,7 +1988,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { hash = 61 * hash + removedTags.hashCode(); hash = 61 * hash + ((customTag != null) ? this.customTag.hashCode() : 0); hash = 61 * hash + (!persistentDataContainer.isEmpty() ? persistentDataContainer.hashCode() : 0); - hash = 61 * hash + hideFlag; + hash = 61 * hash + (hasItemFlags() ? this.hiddenComponents.hashCode() : 0); hash = 61 * hash + (isHideTooltip() ? 1231 : 1237); hash = 61 * hash + (hasTooltipStyle() ? this.tooltipStyle.hashCode() : 0); hash = 61 * hash + (hasItemModel() ? this.itemModel.hashCode() : 0); @@ -1895,7 +2003,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { hash = 61 * hash + (hasFood() ? this.food.hashCode() : 0); hash = 61 * hash + (hasConsumable() ? this.consumable.hashCode() : 0); hash = 61 * hash + (hasTool() ? this.tool.hashCode() : 0); + hash = 61 * hash + (hasBlocksAttacks() ? this.blocksAttacks.hashCode() : 0); + hash = 61 * hash + (hasWeapon() ? this.weapon.hashCode() : 0); hash = 61 * hash + (hasJukeboxPlayable() ? this.jukebox.hashCode() : 0); + hash = 61 * hash + (hasBreakSound() ? this.breakSound.hashCode() : 0); hash = 61 * hash + (hasEquippable() ? this.equippable.hashCode() : 0); hash = 61 * hash + (hasDamage() ? this.damage : 0); hash = 61 * hash + (hasMaxDamage() ? 1231 : 1237); @@ -1928,7 +2039,9 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } clone.removedTags = Sets.newHashSet(this.removedTags); clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getRaw(), DATA_TYPE_REGISTRY); - clone.hideFlag = this.hideFlag; + if (this.hasItemFlags()) { + clone.hiddenComponents = new LinkedHashSet<>(this.hiddenComponents); + } clone.hideTooltip = this.hideTooltip; clone.tooltipStyle = this.tooltipStyle; clone.itemModel = this.itemModel; @@ -1953,12 +2066,19 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { if (this.hasTool()) { clone.tool = new CraftToolComponent(tool); } + if (this.hasBlocksAttacks()) { + clone.blocksAttacks = new CraftBlocksAttacksComponent(blocksAttacks); + } + if (this.hasWeapon()) { + clone.weapon = new CraftWeaponComponent(weapon); + } if (this.hasEquippable()) { clone.equippable = new CraftEquippableComponent(equippable); } if (this.hasJukeboxPlayable()) { clone.jukebox = new CraftJukeboxComponent(jukebox); } + clone.breakSound = breakSound; clone.damage = this.damage; clone.maxDamage = this.maxDamage; clone.version = this.version; @@ -2078,6 +2198,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { builder.put(TOOL.BUKKIT, tool); } + if (hasBlocksAttacks()) { + builder.put(BLOCKS_ATTACKS.BUKKIT, blocksAttacks); + } + + if (hasWeapon()) { + builder.put(WEAPON.BUKKIT, weapon); + } + if (hasEquippable()) { builder.put(EQUIPPABLE.BUKKIT, equippable); } @@ -2086,6 +2214,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { builder.put(JUKEBOX_PLAYABLE.BUKKIT, jukebox); } + if (hasBreakSound()) { + builder.put(BREAK_SOUND.BUKKIT, getBreakSound().getKey().toString()); + } + if (hasDamage()) { builder.put(DAMAGE.BUKKIT, damage); } @@ -2255,8 +2387,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { BLOCK_DATA.TYPE, REPAIR.TYPE, ENCHANTMENTS.TYPE, - HIDE_ADDITIONAL_TOOLTIP.TYPE, - HIDE_TOOLTIP.TYPE, + HIDEFLAGS.TYPE, TOOLTIP_STYLE.TYPE, ITEM_MODEL.TYPE, UNBREAKABLE.TYPE, @@ -2270,8 +2401,11 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { FOOD.TYPE, CONSUMABLE.TYPE, TOOL.TYPE, + BLOCKS_ATTACKS.TYPE, + WEAPON.TYPE, EQUIPPABLE.TYPE, JUKEBOX_PLAYABLE.TYPE, + BREAK_SOUND.TYPE, DAMAGE.TYPE, MAX_DAMAGE.TYPE, CUSTOM_DATA.TYPE, diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java index e4f521d91..ce90108d8 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java @@ -9,7 +9,6 @@ import net.minecraft.world.item.component.DyedItemColor; import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.configuration.serialization.DelegateDeserialization; -import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.meta.ColorableArmorMeta; import org.bukkit.inventory.meta.LeatherArmorMeta; @@ -125,10 +124,6 @@ class CraftMetaLeatherArmor extends CraftMetaItem implements LeatherArmorMeta { static void readColor(LeatherArmorMeta meta, DataComponentPatch tag) { getOrEmpty(tag, COLOR).ifPresent((dyedItemColor) -> { - if (!dyedItemColor.showInTooltip()) { - meta.addItemFlags(ItemFlag.HIDE_DYE); - } - try { meta.setColor(Color.fromRGB(dyedItemColor.rgb())); } catch (IllegalArgumentException ex) { @@ -147,7 +142,7 @@ class CraftMetaLeatherArmor extends CraftMetaItem implements LeatherArmorMeta { static void applyColor(LeatherArmorMeta meta, CraftMetaItem.Applicator tag) { if (hasColor(meta)) { - tag.put(COLOR, new DyedItemColor(meta.getColor().asRGB(), !meta.hasItemFlag(ItemFlag.HIDE_DYE))); + tag.put(COLOR, new DyedItemColor(meta.getColor().asRGB())); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMusicInstrument.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMusicInstrument.java index 1492081b4..56bafd23d 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMusicInstrument.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMusicInstrument.java @@ -2,19 +2,19 @@ package org.bukkit.craftbukkit.inventory; import com.google.common.collect.ImmutableMap; import java.util.Map; -import net.minecraft.core.Holder; import net.minecraft.core.component.DataComponentPatch; import net.minecraft.core.component.DataComponents; -import net.minecraft.world.item.Instrument; +import net.minecraft.world.item.component.InstrumentComponent; import org.bukkit.MusicInstrument; import org.bukkit.configuration.serialization.DelegateDeserialization; import org.bukkit.craftbukkit.CraftMusicInstrument; +import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.inventory.meta.MusicInstrumentMeta; @DelegateDeserialization(SerializableMeta.class) public class CraftMetaMusicInstrument extends CraftMetaItem implements MusicInstrumentMeta { - static final ItemMetaKeyType> GOAT_HORN_INSTRUMENT = new ItemMetaKeyType<>(DataComponents.INSTRUMENT, "instrument"); + static final ItemMetaKeyType GOAT_HORN_INSTRUMENT = new ItemMetaKeyType<>(DataComponents.INSTRUMENT, "instrument"); private MusicInstrument instrument; CraftMetaMusicInstrument(CraftMetaItem meta) { @@ -30,7 +30,9 @@ public class CraftMetaMusicInstrument extends CraftMetaItem implements MusicInst super(tag); getOrEmpty(tag, GOAT_HORN_INSTRUMENT).ifPresent((instrument) -> { - this.instrument = CraftMusicInstrument.minecraftHolderToBukkit(instrument); + instrument.instrument().unwrap(CraftRegistry.getMinecraftRegistry()).ifPresent((holder) -> { + this.instrument = CraftMusicInstrument.minecraftHolderToBukkit(holder); + }); }); } @@ -48,7 +50,7 @@ public class CraftMetaMusicInstrument extends CraftMetaItem implements MusicInst super.applyToItem(tag); if (instrument != null) { - tag.put(GOAT_HORN_INSTRUMENT, CraftMusicInstrument.bukkitToMinecraftHolder(instrument)); + tag.put(GOAT_HORN_INSTRUMENT, new InstrumentComponent(CraftMusicInstrument.bukkitToMinecraftHolder(instrument))); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java index 1aec60cbe..850ffda48 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java @@ -31,6 +31,7 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { @ItemMetaKey.Specific(ItemMetaKey.Specific.To.NBT) static final ItemMetaKeyType POTION_CONTENTS = new ItemMetaKeyType<>(DataComponents.POTION_CONTENTS); + static final ItemMetaKeyType POTION_DURATION_SCALE = new ItemMetaKeyType<>(DataComponents.POTION_DURATION_SCALE, "potion-duration-scale"); static final ItemMetaKey POTION_EFFECTS = new ItemMetaKey("custom-effects"); static final ItemMetaKey POTION_COLOR = new ItemMetaKey("custom-color"); static final ItemMetaKey CUSTOM_NAME = new ItemMetaKey("custom-name"); @@ -40,6 +41,7 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { private List customEffects; private Color color; private String customName; + private Float potionDurationScale; CraftMetaPotion(CraftMetaItem meta) { super(meta); @@ -52,6 +54,7 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { if (potionMeta.hasCustomEffects()) { this.customEffects = new ArrayList<>(potionMeta.customEffects); } + this.potionDurationScale = potionMeta.potionDurationScale; } CraftMetaPotion(DataComponentPatch tag) { @@ -93,6 +96,10 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { customEffects.add(new PotionEffect(type, duration, amp, ambient, particles, icon)); } }); + + getOrEmpty(tag, POTION_DURATION_SCALE).ifPresent((potionDurationScale) -> { + this.potionDurationScale = potionDurationScale; + }); } CraftMetaPotion(Map map) { @@ -121,6 +128,11 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { Preconditions.checkArgument(obj instanceof PotionEffect, "Object (%s) in effect list is not valid", obj.getClass()); addCustomEffect((PotionEffect) obj, true); } + + Float scale = SerializableMeta.getObject(Float.class, map, POTION_DURATION_SCALE.BUKKIT, true); + if (scale != null) { + setDurationScale(scale); + } } @Override @@ -143,6 +155,10 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { } tag.put(POTION_CONTENTS, new PotionContents(defaultPotion, potionColor, effectList, customName)); + + if (hasDurationScale()) { + tag.put(POTION_DURATION_SCALE, getDurationScale()); + } } @Override @@ -151,7 +167,7 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { } boolean isPotionEmpty() { - return (type == null) && !(hasCustomEffects() || hasColor() || hasCustomName()); + return (type == null) && !(hasCustomEffects() || hasColor() || hasCustomName() || hasDurationScale()); } @Override @@ -320,6 +336,23 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { this.customName = customName; } + @Override + public boolean hasDurationScale() { + return this.potionDurationScale != null; + } + + @Override + public float getDurationScale() { + Preconditions.checkState(hasDurationScale(), "hasDurationScale is false"); + + return this.potionDurationScale; + } + + @Override + public void setDurationScale(Float scale) { + this.potionDurationScale = scale; + } + @Override int applyHash() { final int original; @@ -336,6 +369,9 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { if (hasCustomEffects()) { hash = 73 * hash + customEffects.hashCode(); } + if (hasDurationScale()) { + hash = 73 * hash + potionDurationScale.hashCode(); + } return original != hash ? CraftMetaPotion.class.hashCode() ^ hash : hash; } @@ -350,7 +386,8 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { return Objects.equals(type, that.type) && (this.hasCustomEffects() ? that.hasCustomEffects() && this.customEffects.equals(that.customEffects) : !that.hasCustomEffects()) && (this.hasColor() ? that.hasColor() && this.color.equals(that.color) : !that.hasColor()) - && (this.hasCustomName() ? that.hasCustomName() && this.customName.equals(that.customName) : !that.hasCustomName()); + && (this.hasCustomName() ? that.hasCustomName() && this.customName.equals(that.customName) : !that.hasCustomName()) + && (this.hasDurationScale() ? that.hasDurationScale() && this.potionDurationScale.equals(that.potionDurationScale) : !that.hasDurationScale()); } return true; } @@ -379,6 +416,10 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { builder.put(POTION_EFFECTS.BUKKIT, ImmutableList.copyOf(this.customEffects)); } + if (hasDurationScale()) { + builder.put(POTION_DURATION_SCALE.BUKKIT, getDurationScale()); + } + return builder; } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java index 65bb9730c..d780f4910 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java @@ -6,6 +6,7 @@ import java.util.Map; import java.util.Objects; import java.util.UUID; import net.minecraft.SystemUtils; +import net.minecraft.core.UUIDUtil; import net.minecraft.core.component.DataComponentPatch; import net.minecraft.core.component.DataComponents; import net.minecraft.nbt.DynamicOpsNBT; @@ -18,7 +19,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.configuration.serialization.DelegateDeserialization; import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.profile.CraftPlayerProfile; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.profile.PlayerProfile; @@ -79,23 +79,19 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { void deserializeInternal(NBTTagCompound tag, Object context) { super.deserializeInternal(tag, context); - if (tag.contains(SKULL_PROFILE.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { - NBTTagCompound skullTag = tag.getCompound(SKULL_PROFILE.NBT); + tag.getCompound(SKULL_PROFILE.NBT).ifPresent((skullTag) -> { // convert type of stored Id from String to UUID for backwards compatibility - if (skullTag.contains("Id", CraftMagicNumbers.NBT.TAG_STRING)) { - UUID uuid = UUID.fromString(skullTag.getString("Id")); - skullTag.putUUID("Id", uuid); - } + skullTag.getString("Id").ifPresent((id) -> { + UUID uuid = UUID.fromString(id); + skullTag.store("Id", UUIDUtil.CODEC, uuid); + }); ResolvableProfile.CODEC.parse(DynamicOpsNBT.INSTANCE, skullTag).result().ifPresent(this::setProfile); - } + }); - if (tag.contains(BLOCK_ENTITY_TAG.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { - NBTTagCompound nbtTagCompound = tag.getCompound(BLOCK_ENTITY_TAG.NBT).copy(); - if (nbtTagCompound.contains(NOTE_BLOCK_SOUND.NBT, 8)) { - this.noteBlockSound = MinecraftKey.tryParse(nbtTagCompound.getString(NOTE_BLOCK_SOUND.NBT)); - } - } + tag.getCompound(BLOCK_ENTITY_TAG.NBT).flatMap((nbtTagCompound) -> nbtTagCompound.getString(NOTE_BLOCK_SOUND.NBT)).ifPresent((noteBlockSound) -> { + this.noteBlockSound = MinecraftKey.tryParse(noteBlockSound); + }); } private void setProfile(ResolvableProfile profile) { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java index 9c3b54144..5d15c1962 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java @@ -49,15 +49,15 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { void deserializeInternal(NBTTagCompound tag, Object context) { super.deserializeInternal(tag, context); - if (tag.contains(ENTITY_TAG.NBT)) { - entityTag = tag.getCompound(ENTITY_TAG.NBT); + tag.getCompound(ENTITY_TAG.NBT).ifPresent((entityTag) -> { + this.entityTag = entityTag; // Tag still has some other data, lets try our luck with a conversion if (!entityTag.isEmpty()) { // SPIGOT-4128: This is hopeless until we start versioning stacks. RIP data. // entityTag = (NBTTagCompound) MinecraftServer.getServer().dataConverterManager.update(DataConverterTypes.ENTITY, new Dynamic(DynamicOpsNBT.a, entityTag), -1, CraftMagicNumbers.DATA_VERSION).getValue(); } - } + }); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaTropicalFishBucket.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaTropicalFishBucket.java index 09743e9c2..5dde5a22e 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaTropicalFishBucket.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaTropicalFishBucket.java @@ -10,7 +10,6 @@ import net.minecraft.world.item.component.CustomData; import org.bukkit.DyeColor; import org.bukkit.configuration.serialization.DelegateDeserialization; import org.bukkit.craftbukkit.entity.CraftTropicalFish; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.entity.TropicalFish; import org.bukkit.inventory.meta.TropicalFishBucketMeta; @@ -44,16 +43,16 @@ class CraftMetaTropicalFishBucket extends CraftMetaItem implements TropicalFishB getOrEmpty(tag, ENTITY_TAG).ifPresent((nbt) -> { entityTag = nbt.copyTag(); - if (entityTag.contains(VARIANT.NBT, CraftMagicNumbers.NBT.TAG_INT)) { - this.variant = entityTag.getInt(VARIANT.NBT); - } + entityTag.getInt(VARIANT.NBT).ifPresent((variant) -> { + this.variant = variant; + }); }); getOrEmpty(tag, BUCKET_ENTITY_TAG).ifPresent((nbt) -> { bucketEntityTag = nbt.copyTag(); - if (bucketEntityTag.contains(VARIANT.NBT, CraftMagicNumbers.NBT.TAG_INT)) { - this.variant = bucketEntityTag.getInt(VARIANT.NBT); - } + bucketEntityTag.getInt(VARIANT.NBT).ifPresent((variant) -> { + this.variant = variant; + }); }); } @@ -70,12 +69,8 @@ class CraftMetaTropicalFishBucket extends CraftMetaItem implements TropicalFishB void deserializeInternal(NBTTagCompound tag, Object context) { super.deserializeInternal(tag, context); - if (tag.contains(ENTITY_TAG.NBT)) { - entityTag = tag.getCompound(ENTITY_TAG.NBT); - } - if (tag.contains(BUCKET_ENTITY_TAG.NBT)) { - bucketEntityTag = tag.getCompound(BUCKET_ENTITY_TAG.NBT); - } + entityTag = tag.getCompound(ENTITY_TAG.NBT).orElse(entityTag); + bucketEntityTag = tag.getCompound(BUCKET_ENTITY_TAG.NBT).orElse(bucketEntityTag); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java index 2473a1ad8..e65446972 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java @@ -8,8 +8,10 @@ import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.world.item.crafting.IRecipe; import net.minecraft.world.item.crafting.RecipeItemStack; +import net.minecraft.world.item.crafting.TransmuteResult; import org.bukkit.NamespacedKey; import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; import org.bukkit.inventory.RecipeChoice; import org.bukkit.inventory.recipe.CookingBookCategory; @@ -43,6 +45,12 @@ public interface CraftRecipe extends Recipe { return stack; } + default TransmuteResult toNMS(ItemStack stack) { + net.minecraft.world.item.ItemStack nms = CraftItemStack.asNMSCopy(stack); + + return new TransmuteResult(nms.getItemHolder(), nms.getCount(), nms.getComponentsPatch()); + } + public static RecipeChoice toBukkit(Optional list) { return list.map(CraftRecipe::toBukkit).orElse(null); } @@ -66,6 +74,12 @@ public interface CraftRecipe extends Recipe { } } + public static ItemStack toBukkit(TransmuteResult transmute) { + net.minecraft.world.item.ItemStack nms = new net.minecraft.world.item.ItemStack(transmute.item(), transmute.count(), transmute.components()); + + return CraftItemStack.asBukkitCopy(nms); + } + public static net.minecraft.world.item.crafting.CraftingBookCategory getCategory(CraftingBookCategory bukkit) { return net.minecraft.world.item.crafting.CraftingBookCategory.valueOf(bukkit.name()); } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java index 2a518ac13..dfbf06244 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java @@ -24,6 +24,6 @@ public class CraftSmithingTransformRecipe extends SmithingTransformRecipe implem public void addToCraftingManager() { ItemStack result = this.getResult(); - MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftRecipe.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(toNMSOptional(this.getTemplate(), false), toNMSOptional(this.getBase(), false), toNMSOptional(this.getAddition(), false), CraftItemStack.asNMSCopy(result)))); + MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftRecipe.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(toNMSOptional(this.getTemplate(), false), toNMS(this.getBase(), false), toNMSOptional(this.getAddition(), false), toNMS(result)))); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java index 339dcbfc7..564a70c05 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java @@ -3,25 +3,27 @@ package org.bukkit.craftbukkit.inventory; import net.minecraft.server.MinecraftServer; import net.minecraft.world.item.crafting.RecipeHolder; import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.inventory.trim.CraftTrimPattern; import org.bukkit.inventory.RecipeChoice; import org.bukkit.inventory.SmithingTrimRecipe; +import org.bukkit.inventory.meta.trim.TrimPattern; public class CraftSmithingTrimRecipe extends SmithingTrimRecipe implements CraftRecipe { - public CraftSmithingTrimRecipe(NamespacedKey key, RecipeChoice template, RecipeChoice base, RecipeChoice addition) { - super(key, template, base, addition); + public CraftSmithingTrimRecipe(NamespacedKey key, RecipeChoice template, RecipeChoice base, RecipeChoice addition, TrimPattern trimPattern) { + super(key, template, base, addition, trimPattern); } public static CraftSmithingTrimRecipe fromBukkitRecipe(SmithingTrimRecipe recipe) { if (recipe instanceof CraftSmithingTrimRecipe) { return (CraftSmithingTrimRecipe) recipe; } - CraftSmithingTrimRecipe ret = new CraftSmithingTrimRecipe(recipe.getKey(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition()); + CraftSmithingTrimRecipe ret = new CraftSmithingTrimRecipe(recipe.getKey(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition(), recipe.getTrimPattern()); return ret; } @Override public void addToCraftingManager() { - MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftRecipe.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(toNMSOptional(this.getTemplate(), false), toNMSOptional(this.getBase(), false), toNMSOptional(this.getAddition(), false)))); + MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftRecipe.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(toNMS(this.getTemplate(), false), toNMS(this.getBase(), false), toNMS(this.getAddition(), false), CraftTrimPattern.bukkitToMinecraftHolder(TrimPattern.BOLT)))); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftTransmuteRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftTransmuteRecipe.java index 6af50aaa6..579382739 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftTransmuteRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftTransmuteRecipe.java @@ -1,16 +1,15 @@ package org.bukkit.craftbukkit.inventory; -import net.minecraft.core.Holder; import net.minecraft.server.MinecraftServer; import net.minecraft.world.item.crafting.RecipeHolder; -import org.bukkit.Material; import org.bukkit.NamespacedKey; +import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.RecipeChoice; import org.bukkit.inventory.TransmuteRecipe; public class CraftTransmuteRecipe extends TransmuteRecipe implements CraftRecipe { - public CraftTransmuteRecipe(NamespacedKey key, Material result, RecipeChoice input, RecipeChoice material) { + public CraftTransmuteRecipe(NamespacedKey key, ItemStack result, RecipeChoice input, RecipeChoice material) { super(key, result, input, material); } @@ -18,7 +17,7 @@ public class CraftTransmuteRecipe extends TransmuteRecipe implements CraftRecipe if (recipe instanceof CraftTransmuteRecipe) { return (CraftTransmuteRecipe) recipe; } - CraftTransmuteRecipe ret = new CraftTransmuteRecipe(recipe.getKey(), recipe.getResult().getType(), recipe.getInput(), recipe.getMaterial()); + CraftTransmuteRecipe ret = new CraftTransmuteRecipe(recipe.getKey(), recipe.getResult(), recipe.getInput(), recipe.getMaterial()); ret.setGroup(recipe.getGroup()); ret.setCategory(recipe.getCategory()); return ret; @@ -32,7 +31,7 @@ public class CraftTransmuteRecipe extends TransmuteRecipe implements CraftRecipe CraftRecipe.getCategory(this.getCategory()), toNMS(this.getInput(), true), toNMS(this.getMaterial(), true), - Holder.direct(CraftItemType.bukkitToMinecraft(this.getResult().getType())) + toNMS(this.getResult()) ) ) ); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftBlocksAttacksComponent.java b/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftBlocksAttacksComponent.java new file mode 100644 index 000000000..eb85da468 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftBlocksAttacksComponent.java @@ -0,0 +1,429 @@ +package org.bukkit.craftbukkit.inventory.components; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; +import net.minecraft.core.Holder; +import net.minecraft.core.HolderSet; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.MinecraftKey; +import net.minecraft.sounds.SoundEffect; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.component.BlocksAttacks; +import org.bukkit.Bukkit; +import org.bukkit.Sound; +import org.bukkit.Tag; +import org.bukkit.configuration.serialization.SerializableAs; +import org.bukkit.craftbukkit.CraftRegistry; +import org.bukkit.craftbukkit.CraftSound; +import org.bukkit.craftbukkit.damage.CraftDamageType; +import org.bukkit.craftbukkit.inventory.SerializableMeta; +import org.bukkit.craftbukkit.tag.CraftDamageTag; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.damage.DamageType; +import org.bukkit.inventory.meta.components.BlocksAttacksComponent; +import org.bukkit.tag.DamageTypeTags; + +@SerializableAs("BlocksAttacks") +public final class CraftBlocksAttacksComponent implements BlocksAttacksComponent { + + private BlocksAttacks handle; + + public CraftBlocksAttacksComponent(BlocksAttacks blocksAttacks) { + this.handle = blocksAttacks; + } + + public CraftBlocksAttacksComponent(CraftBlocksAttacksComponent blocksAttacks) { + this.handle = blocksAttacks.handle; + } + + public CraftBlocksAttacksComponent(Map map) { + Float blockDelaySeconds = SerializableMeta.getObject(Float.class, map, "default-mining-speed", false); + Float disableCooldownScale = SerializableMeta.getObject(Float.class, map, "disable-cooldown-scale", false); + + ImmutableList.Builder reduction = ImmutableList.builder(); + Iterable rawReductionList = SerializableMeta.getObject(Iterable.class, map, "damage-reductions", true); + if (rawReductionList != null) { + for (Object obj : rawReductionList) { + Preconditions.checkArgument(obj instanceof DamageReduction, "Object (%s) in reduction list is not valid", obj.getClass()); + + CraftDamageReduction rule = new CraftDamageReduction((DamageReduction) obj); + reduction.add(rule); + } + } + + Float itemDamageThreshold = SerializableMeta.getObject(Float.class, map, "item-damage-threshold", false); + Float itemDamageBase = SerializableMeta.getObject(Float.class, map, "item-damage-base", false); + Float itemDamageFactor = SerializableMeta.getObject(Float.class, map, "item-damage-factor", false); + + String bypassedBy = SerializableMeta.getString(map, "bypassed-by", true); + TagKey tag = null; + if (bypassedBy != null) { + tag = TagKey.create(Registries.DAMAGE_TYPE, MinecraftKey.parse(bypassedBy)); + } + + Holder blockSound = null; + String blockSnd = SerializableMeta.getString(map, "block-sound", true); + if (blockSnd != null) { + blockSound = BuiltInRegistries.SOUND_EVENT.get(MinecraftKey.parse(blockSnd)).orElse(null); + } + + Holder disableSound = null; + String disableSnd = SerializableMeta.getString(map, "disable-sound", true); + if (disableSnd != null) { + disableSound = BuiltInRegistries.SOUND_EVENT.get(MinecraftKey.parse(disableSnd)).orElse(null); + } + + this.handle = new BlocksAttacks(blockDelaySeconds, disableCooldownScale, reduction.build().stream().map(CraftDamageReduction::new).map(CraftDamageReduction::getHandle).toList(), + new net.minecraft.world.item.component.BlocksAttacks.b(itemDamageThreshold, itemDamageBase, itemDamageFactor), + Optional.ofNullable(tag), Optional.ofNullable(blockSound), Optional.ofNullable(disableSound) + ); + } + + @Override + public Map serialize() { + Map result = new LinkedHashMap<>(); + result.put("block-delay-seconds", getBlockDelaySeconds()); + result.put("disable-cooldown-scale", getDisableCooldownScale()); + result.put("damage-reductions", getDamageReductions()); + result.put("item-damage-threshold", getItemDamageThreshold()); + result.put("item-damage-base", getItemDamageBase()); + result.put("item-damage-factor", getItemDamageFactor()); + + handle.bypassedBy().ifPresent((bypassedBy) -> { + result.put("bypassed-by", bypassedBy.location().toString()); + }); + + Sound blockSound = getBlockSound(); + if (blockSound != null) { + result.put("block-sound", blockSound); + } + + Sound disableSound = getDisableSound(); + if (disableSound != null) { + result.put("disable-sound", disableSound); + } + + return result; + } + + public BlocksAttacks getHandle() { + return handle; + } + + @Override + public float getBlockDelaySeconds() { + return handle.blockDelaySeconds(); + } + + @Override + public void setBlockDelaySeconds(float seconds) { + Preconditions.checkArgument(seconds >= 0, "seconds cannot be negative"); + + handle = new BlocksAttacks(seconds, handle.disableCooldownScale(), handle.damageReductions(), handle.itemDamage(), handle.bypassedBy(), handle.blockSound(), handle.disableSound()); + } + + @Override + public float getDisableCooldownScale() { + return handle.disableCooldownScale(); + } + + @Override + public void setDisableCooldownScale(float scale) { + Preconditions.checkArgument(scale >= 0, "scale cannot be negative"); + + handle = new BlocksAttacks(handle.blockDelaySeconds(), scale, handle.damageReductions(), handle.itemDamage(), handle.bypassedBy(), handle.blockSound(), handle.disableSound()); + } + + @Override + public List getDamageReductions() { + return handle.damageReductions().stream().map(CraftDamageReduction::new).collect(Collectors.toList()); + } + + @Override + public void setDamageReductions(List reductions) { + Preconditions.checkArgument(reductions != null, "reductions must not be null"); + handle = new BlocksAttacks(handle.blockDelaySeconds(), handle.disableCooldownScale(), + reductions.stream().map(CraftDamageReduction::new).map(CraftDamageReduction::getHandle).toList(), + handle.itemDamage(), handle.bypassedBy(), handle.blockSound(), handle.disableSound()); + } + + @Override + public DamageReduction addDamageReduction(DamageType type, float base, float factor, float horizontalBlockingAngle) { + return addRule((type != null) ? HolderSet.direct(CraftDamageType.bukkitToMinecraftHolder(type)) : null, base, factor, horizontalBlockingAngle); + } + + @Override + public DamageReduction addDamageReduction(Collection types, float base, float factor, float horizontalBlockingAngle) { + return addRule((types != null) ? HolderSet.direct(types.stream().map(CraftDamageType::bukkitToMinecraftHolder).toList()) : null, base, factor, horizontalBlockingAngle); + } + + @Override + public DamageReduction addDamageReduction(Tag tag, float base, float factor, float horizontalBlockingAngle) { + Preconditions.checkArgument(tag == null || tag instanceof CraftDamageTag, "tag must be a damage tag"); + return addRule((tag != null) ? ((CraftDamageTag) tag).getHandle() : null, base, factor, horizontalBlockingAngle); + } + + private DamageReduction addRule(HolderSet types, float base, float factor, float horizontalBlockingAngle) { + BlocksAttacks.a reduction = new net.minecraft.world.item.component.BlocksAttacks.a(horizontalBlockingAngle, Optional.ofNullable(types), base, factor); + + List reductions = new ArrayList<>(handle.damageReductions().size() + 1); + reductions.addAll(handle.damageReductions()); + reductions.add(reduction); + + handle = new BlocksAttacks(handle.blockDelaySeconds(), handle.disableCooldownScale(), reductions, handle.itemDamage(), handle.bypassedBy(), handle.blockSound(), handle.disableSound()); + return new CraftDamageReduction(reduction); + } + + @Override + public boolean removeDamageReduction(DamageReduction reduction) { + Preconditions.checkArgument(reduction != null, "reduction must not be null"); + + List reductions = new ArrayList<>(handle.damageReductions()); + boolean removed = reductions.remove(((CraftDamageReduction) reduction).handle); + handle = new BlocksAttacks(handle.blockDelaySeconds(), handle.disableCooldownScale(), reductions, handle.itemDamage(), handle.bypassedBy(), handle.blockSound(), handle.disableSound()); + + return removed; + } + + @Override + public float getItemDamageThreshold() { + return handle.itemDamage().threshold(); + } + + @Override + public void setItemDamageThreshold(float threshold) { + BlocksAttacks.b itemDamage = handle.itemDamage(); + + handle = new BlocksAttacks(handle.blockDelaySeconds(), handle.disableCooldownScale(), handle.damageReductions(), + new net.minecraft.world.item.component.BlocksAttacks.b(threshold, itemDamage.base(), itemDamage.factor()), + handle.bypassedBy(), handle.blockSound(), handle.disableSound()); + } + + @Override + public float getItemDamageBase() { + return handle.itemDamage().base(); + } + + @Override + public void setItemDamageBase(float base) { + BlocksAttacks.b itemDamage = handle.itemDamage(); + + handle = new BlocksAttacks(handle.blockDelaySeconds(), handle.disableCooldownScale(), handle.damageReductions(), + new net.minecraft.world.item.component.BlocksAttacks.b(itemDamage.threshold(), base, itemDamage.factor()), + handle.bypassedBy(), handle.blockSound(), handle.disableSound()); + } + + @Override + public float getItemDamageFactor() { + return handle.itemDamage().factor(); + } + + @Override + public void setItemDamageFactor(float factor) { + BlocksAttacks.b itemDamage = handle.itemDamage(); + + handle = new BlocksAttacks(handle.blockDelaySeconds(), handle.disableCooldownScale(), handle.damageReductions(), + new net.minecraft.world.item.component.BlocksAttacks.b(itemDamage.threshold(), itemDamage.base(), factor), + handle.bypassedBy(), handle.blockSound(), handle.disableSound()); + } + + @Override + public Sound getBlockSound() { + return handle.blockSound().map(CraftSound::minecraftHolderToBukkit).orElse(null); + } + + @Override + public void setBlockSound(Sound sound) { + handle = new BlocksAttacks(handle.blockDelaySeconds(), handle.disableCooldownScale(), handle.damageReductions(), handle.itemDamage(), handle.bypassedBy(), Optional.ofNullable(sound).map(CraftSound::bukkitToMinecraftHolder), handle.disableSound()); + } + + @Override + public Sound getDisableSound() { + return handle.disableSound().map(CraftSound::minecraftHolderToBukkit).orElse(null); + } + + @Override + public void setDisableSound(Sound sound) { + handle = new BlocksAttacks(handle.blockDelaySeconds(), handle.disableCooldownScale(), handle.damageReductions(), handle.itemDamage(), handle.bypassedBy(), handle.blockSound(), Optional.ofNullable(sound).map(CraftSound::bukkitToMinecraftHolder)); + } + + @Override + public Tag getBypassedBy() { + return handle.bypassedBy().map((bypassedBy) -> Bukkit.getTag(DamageTypeTags.REGISTRY_DAMAGE_TYPES, CraftNamespacedKey.fromMinecraft(bypassedBy.location()), DamageType.class)).orElse(null); + } + + @Override + public void setBypassedBy(Tag tag) { + handle = new BlocksAttacks(handle.blockDelaySeconds(), handle.disableCooldownScale(), handle.damageReductions(), handle.itemDamage(), + Optional.ofNullable(tag).map((t) -> ((CraftDamageTag) t).getHandle().key()), + handle.blockSound(), handle.disableSound()); + } + + @Override + public int hashCode() { + int hash = 7; + hash = 73 * hash + Objects.hashCode(this.handle); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final CraftBlocksAttacksComponent other = (CraftBlocksAttacksComponent) obj; + return Objects.equals(this.handle, other.handle); + } + + @Override + public String toString() { + return "CraftBlocksAttacksComponent{" + "handle=" + handle + '}'; + } + + @SerializableAs("DamageReduction") + public static class CraftDamageReduction implements DamageReduction { + + private BlocksAttacks.a handle; + + public CraftDamageReduction(BlocksAttacks.a handle) { + this.handle = handle; + } + + public CraftDamageReduction(DamageReduction bukkit) { + BlocksAttacks.a toCopy = ((CraftDamageReduction) bukkit).handle; + this.handle = new BlocksAttacks.a(toCopy.horizontalBlockingAngle(), toCopy.type(), toCopy.base(), toCopy.factor()); + } + + public CraftDamageReduction(Map map) { + Float base = SerializableMeta.getObject(Float.class, map, "base", false); + Float factor = SerializableMeta.getObject(Float.class, map, "factor", false); + Float horizontalBlockingAngle = SerializableMeta.getObject(Float.class, map, "horizontal-blocking-angle", false); + + HolderSet typesSet = null; + Object types = SerializableMeta.getObject(Object.class, map, "types", true); + if (types != null) { + typesSet = CraftHolderUtil.parse(types, Registries.DAMAGE_TYPE, CraftRegistry.getMinecraftRegistry(Registries.DAMAGE_TYPE)); + } + + this.handle = new net.minecraft.world.item.component.BlocksAttacks.a(horizontalBlockingAngle, Optional.ofNullable(typesSet), base, factor); + } + + @Override + public Map serialize() { + Map result = new LinkedHashMap<>(); + + result.put("base", getBase()); + result.put("factor", getFactor()); + result.put("horizontal-blocking-angle", getHorizontalBlockingAngle()); + + handle.type().ifPresent((type) -> { + CraftHolderUtil.serialize(result, "types", type); + }); + + return result; + } + + public BlocksAttacks.a getHandle() { + return handle; + } + + @Override + public Collection getTypes() { + return handle.type().map(type -> type.stream().map(CraftDamageType::minecraftHolderToBukkit).toList()).orElse(null); + } + + @Override + public void setTypes(DamageType type) { + handle = new net.minecraft.world.item.component.BlocksAttacks.a(handle.horizontalBlockingAngle(), + Optional.ofNullable(type).map((t) -> HolderSet.direct(CraftDamageType.bukkitToMinecraftHolder(t))), + handle.base(), handle.factor()); + } + + @Override + public void setTypes(Collection types) { + handle = new net.minecraft.world.item.component.BlocksAttacks.a(handle.horizontalBlockingAngle(), + Optional.ofNullable(types).map((t) -> HolderSet.direct(t.stream().map(CraftDamageType::bukkitToMinecraftHolder).toList())), + handle.base(), handle.factor()); + } + + @Override + public void setTypes(Tag tag) { + Preconditions.checkArgument(tag == null || tag instanceof CraftDamageTag, "tag must be a damage tag"); + handle = new net.minecraft.world.item.component.BlocksAttacks.a(handle.horizontalBlockingAngle(), + Optional.ofNullable(tag).map((t) -> ((CraftDamageTag) t).getHandle()), + handle.base(), handle.factor()); + } + + @Override + public float getBase() { + return handle.base(); + } + + @Override + public void setBase(float base) { + handle = new net.minecraft.world.item.component.BlocksAttacks.a(handle.horizontalBlockingAngle(), handle.type(), base, handle.factor()); + } + + @Override + public float getFactor() { + return handle.factor(); + } + + @Override + public void setFactor(float factor) { + handle = new net.minecraft.world.item.component.BlocksAttacks.a(handle.horizontalBlockingAngle(), handle.type(), handle.base(), factor); + } + + @Override + public float getHorizontalBlockingAngle() { + return handle.horizontalBlockingAngle(); + } + + @Override + public void setHorizontalBlockingAngle(float horizontalBlockingAngle) { + handle = new net.minecraft.world.item.component.BlocksAttacks.a(horizontalBlockingAngle, handle.type(), handle.base(), handle.factor()); + } + + @Override + public int hashCode() { + int hash = 5; + hash = 97 * hash + Objects.hashCode(this.handle); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final CraftDamageReduction other = (CraftDamageReduction) obj; + return Objects.equals(this.handle, other.handle); + } + + @Override + public String toString() { + return "CraftDamageReduction{" + "handle=" + handle + '}'; + } + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftEquippableComponent.java b/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftEquippableComponent.java index 56b825fe5..ee7ec9fb9 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftEquippableComponent.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftEquippableComponent.java @@ -67,6 +67,7 @@ public final class CraftEquippableComponent implements EquippableComponent { Boolean dispensable = SerializableMeta.getObject(Boolean.class, map, "dispensable", true); Boolean swappable = SerializableMeta.getObject(Boolean.class, map, "swappable", true); Boolean damageOnHurt = SerializableMeta.getObject(Boolean.class, map, "damage-on-hurt", true); + Boolean equipOnInteract = SerializableMeta.getObject(Boolean.class, map, "equip-on-interact", true); this.handle = new Equippable(slot, (equipSound != null) ? CraftSound.bukkitToMinecraftHolder(equipSound) : SoundEffects.ARMOR_EQUIP_GENERIC, @@ -75,7 +76,8 @@ public final class CraftEquippableComponent implements EquippableComponent { Optional.ofNullable(allowedEntities), (dispensable != null) ? dispensable : true, (swappable != null) ? swappable : true, - (damageOnHurt != null) ? damageOnHurt : true + (damageOnHurt != null) ? damageOnHurt : true, + (equipOnInteract != null) ? equipOnInteract : true ); } @@ -103,6 +105,7 @@ public final class CraftEquippableComponent implements EquippableComponent { result.put("dispensable", isDispensable()); result.put("swappable", isSwappable()); result.put("damage-on-hurt", isDamageOnHurt()); + result.put("equip-on-interact", isEquipOnInteract()); return result; } @@ -118,7 +121,7 @@ public final class CraftEquippableComponent implements EquippableComponent { @Override public void setSlot(EquipmentSlot slot) { - handle = new Equippable(CraftEquipmentSlot.getNMS(slot), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), handle.swappable(), handle.damageOnHurt()); + handle = new Equippable(CraftEquipmentSlot.getNMS(slot), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), handle.swappable(), handle.damageOnHurt(), handle.equipOnInteract()); } @Override @@ -128,7 +131,7 @@ public final class CraftEquippableComponent implements EquippableComponent { @Override public void setEquipSound(Sound sound) { - handle = new Equippable(handle.slot(), (sound != null) ? CraftSound.bukkitToMinecraftHolder(sound) : SoundEffects.ARMOR_EQUIP_GENERIC, handle.assetId(), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), handle.swappable(), handle.damageOnHurt()); + handle = new Equippable(handle.slot(), (sound != null) ? CraftSound.bukkitToMinecraftHolder(sound) : SoundEffects.ARMOR_EQUIP_GENERIC, handle.assetId(), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), handle.swappable(), handle.damageOnHurt(), handle.equipOnInteract()); } @Override @@ -138,7 +141,7 @@ public final class CraftEquippableComponent implements EquippableComponent { @Override public void setModel(NamespacedKey key) { - handle = new Equippable(handle.slot(), handle.equipSound(), Optional.ofNullable(key).map(CraftNamespacedKey::toMinecraft).map((k) -> ResourceKey.create(EquipmentAssets.ROOT_ID, k)), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), handle.swappable(), handle.damageOnHurt()); + handle = new Equippable(handle.slot(), handle.equipSound(), Optional.ofNullable(key).map(CraftNamespacedKey::toMinecraft).map((k) -> ResourceKey.create(EquipmentAssets.ROOT_ID, k)), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), handle.swappable(), handle.damageOnHurt(), handle.equipOnInteract()); } @Override @@ -148,7 +151,7 @@ public final class CraftEquippableComponent implements EquippableComponent { @Override public void setCameraOverlay(NamespacedKey key) { - handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), Optional.ofNullable(key).map(CraftNamespacedKey::toMinecraft), handle.allowedEntities(), handle.dispensable(), handle.swappable(), handle.damageOnHurt()); + handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), Optional.ofNullable(key).map(CraftNamespacedKey::toMinecraft), handle.allowedEntities(), handle.dispensable(), handle.swappable(), handle.damageOnHurt(), handle.equipOnInteract()); } @Override @@ -160,7 +163,7 @@ public final class CraftEquippableComponent implements EquippableComponent { public void setAllowedEntities(EntityType entities) { handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), (entities != null) ? Optional.of(HolderSet.direct(CraftEntityType.bukkitToMinecraftHolder(entities))) : Optional.empty(), - handle.dispensable(), handle.swappable(), handle.damageOnHurt() + handle.dispensable(), handle.swappable(), handle.damageOnHurt(), handle.equipOnInteract() ); } @@ -168,7 +171,7 @@ public final class CraftEquippableComponent implements EquippableComponent { public void setAllowedEntities(Collection entities) { handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), (entities != null) ? Optional.of(HolderSet.direct(entities.stream().map(CraftEntityType::bukkitToMinecraftHolder).collect(Collectors.toList()))) : Optional.empty(), - handle.dispensable(), handle.swappable(), handle.damageOnHurt() + handle.dispensable(), handle.swappable(), handle.damageOnHurt(), handle.equipOnInteract() ); } @@ -178,7 +181,7 @@ public final class CraftEquippableComponent implements EquippableComponent { handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), (tag != null) ? Optional.of(((CraftEntityTag) tag).getHandle()) : Optional.empty(), - handle.dispensable(), handle.swappable(), handle.damageOnHurt() + handle.dispensable(), handle.swappable(), handle.damageOnHurt(), handle.equipOnInteract() ); } @@ -189,7 +192,7 @@ public final class CraftEquippableComponent implements EquippableComponent { @Override public void setDispensable(boolean dispensable) { - handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), handle.allowedEntities(), dispensable, handle.swappable(), handle.damageOnHurt()); + handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), handle.allowedEntities(), dispensable, handle.swappable(), handle.damageOnHurt(), handle.equipOnInteract()); } @Override @@ -199,7 +202,7 @@ public final class CraftEquippableComponent implements EquippableComponent { @Override public void setSwappable(boolean swappable) { - handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), swappable, handle.damageOnHurt()); + handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), swappable, handle.damageOnHurt(), handle.equipOnInteract()); } @Override @@ -209,7 +212,17 @@ public final class CraftEquippableComponent implements EquippableComponent { @Override public void setDamageOnHurt(boolean damage) { - handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), handle.swappable(), damage); + handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), handle.swappable(), damage, handle.equipOnInteract()); + } + + @Override + public boolean isEquipOnInteract() { + return handle.equipOnInteract(); + } + + @Override + public void setEquipOnInteract(boolean equip) { + handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), handle.swappable(), handle.damageOnHurt(), equip); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftJukeboxComponent.java b/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftJukeboxComponent.java index 78ac53c69..b9ed22854 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftJukeboxComponent.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftJukeboxComponent.java @@ -35,16 +35,14 @@ public final class CraftJukeboxComponent implements JukeboxPlayableComponent { public CraftJukeboxComponent(Map map) { String song = SerializableMeta.getObject(String.class, map, "song", false); - Boolean showTooltip = SerializableMeta.getObject(Boolean.class, map, "show-in-tooltip", true); - this.handle = new JukeboxPlayable(new EitherHolder<>(ResourceKey.create(Registries.JUKEBOX_SONG, MinecraftKey.parse(song))), (showTooltip != null) ? showTooltip : true); + this.handle = new JukeboxPlayable(new EitherHolder<>(ResourceKey.create(Registries.JUKEBOX_SONG, MinecraftKey.parse(song)))); } @Override public Map serialize() { Map result = new LinkedHashMap<>(); result.put("song", getSongKey().toString()); - result.put("show-in-tooltip", isShowInTooltip()); return result; } @@ -60,31 +58,21 @@ public final class CraftJukeboxComponent implements JukeboxPlayableComponent { @Override public NamespacedKey getSongKey() { - return CraftNamespacedKey.fromMinecraft(handle.song().key().location()); + return handle.song().key().map(ResourceKey::location).map(CraftNamespacedKey::fromMinecraft).orElse(null); } @Override public void setSong(JukeboxSong song) { Preconditions.checkArgument(song != null, "song cannot be null"); - handle = new JukeboxPlayable(new EitherHolder<>(CraftJukeboxSong.bukkitToMinecraftHolder(song)), handle.showInTooltip()); + handle = new JukeboxPlayable(new EitherHolder<>(CraftJukeboxSong.bukkitToMinecraftHolder(song))); } @Override public void setSongKey(NamespacedKey song) { Preconditions.checkArgument(song != null, "song cannot be null"); - handle = new JukeboxPlayable(new EitherHolder<>(ResourceKey.create(Registries.JUKEBOX_SONG, CraftNamespacedKey.toMinecraft(song))), handle.showInTooltip()); - } - - @Override - public boolean isShowInTooltip() { - return handle.showInTooltip(); - } - - @Override - public void setShowInTooltip(boolean show) { - handle = new JukeboxPlayable(handle.song(), show); + handle = new JukeboxPlayable(new EitherHolder<>(ResourceKey.create(Registries.JUKEBOX_SONG, CraftNamespacedKey.toMinecraft(song)))); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftToolComponent.java b/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftToolComponent.java index 1484ac8ea..0c96949ef 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftToolComponent.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftToolComponent.java @@ -40,6 +40,7 @@ public final class CraftToolComponent implements ToolComponent { public CraftToolComponent(Map map) { Float speed = SerializableMeta.getObject(Float.class, map, "default-mining-speed", false); Integer damage = SerializableMeta.getObject(Integer.class, map, "damage-per-block", false); + Boolean canDestroy = SerializableMeta.getObject(Boolean.class, map, "can-destroy-blocks-in-creative", true); ImmutableList.Builder rules = ImmutableList.builder(); Iterable rawRuleList = SerializableMeta.getObject(Iterable.class, map, "rules", true); @@ -54,7 +55,7 @@ public final class CraftToolComponent implements ToolComponent { } } - this.handle = new Tool(rules.build().stream().map(CraftToolRule::new).map(CraftToolRule::getHandle).toList(), speed, damage); + this.handle = new Tool(rules.build().stream().map(CraftToolRule::new).map(CraftToolRule::getHandle).toList(), speed, damage, (canDestroy != null) ? canDestroy : true); } @Override @@ -62,6 +63,7 @@ public final class CraftToolComponent implements ToolComponent { Map result = new LinkedHashMap<>(); result.put("default-mining-speed", getDefaultMiningSpeed()); result.put("damage-per-block", getDamagePerBlock()); + result.put("can-destroy-blocks-in-creative", canDestroyBlocksInCreative()); result.put("rules", getRules()); return result; } @@ -77,7 +79,7 @@ public final class CraftToolComponent implements ToolComponent { @Override public void setDefaultMiningSpeed(float speed) { - handle = new Tool(handle.rules(), speed, handle.damagePerBlock()); + handle = new Tool(handle.rules(), speed, handle.damagePerBlock(), handle.canDestroyBlocksInCreative()); } @Override @@ -88,7 +90,17 @@ public final class CraftToolComponent implements ToolComponent { @Override public void setDamagePerBlock(int damage) { Preconditions.checkArgument(damage >= 0, "damage must be >= 0, was %d", damage); - handle = new Tool(handle.rules(), handle.defaultMiningSpeed(), damage); + handle = new Tool(handle.rules(), handle.defaultMiningSpeed(), damage, handle.canDestroyBlocksInCreative()); + } + + @Override + public boolean canDestroyBlocksInCreative() { + return handle.canDestroyBlocksInCreative(); + } + + @Override + public void setCanDestroyBlocksInCreative(boolean destroy) { + handle = new Tool(handle.rules(), handle.defaultMiningSpeed(), handle.damagePerBlock(), destroy); } @Override @@ -99,7 +111,7 @@ public final class CraftToolComponent implements ToolComponent { @Override public void setRules(List rules) { Preconditions.checkArgument(rules != null, "rules must not be null"); - handle = new Tool(rules.stream().map(CraftToolRule::new).map(CraftToolRule::getHandle).toList(), handle.defaultMiningSpeed(), handle.damagePerBlock()); + handle = new Tool(rules.stream().map(CraftToolRule::new).map(CraftToolRule::getHandle).toList(), handle.defaultMiningSpeed(), handle.damagePerBlock(), handle.canDestroyBlocksInCreative()); } @Override @@ -136,7 +148,7 @@ public final class CraftToolComponent implements ToolComponent { rules.addAll(handle.rules()); rules.add(rule); - handle = new Tool(rules, handle.defaultMiningSpeed(), handle.damagePerBlock()); + handle = new Tool(rules, handle.defaultMiningSpeed(), handle.damagePerBlock(), handle.canDestroyBlocksInCreative()); return new CraftToolRule(rule); } @@ -146,7 +158,7 @@ public final class CraftToolComponent implements ToolComponent { List rules = new ArrayList<>(handle.rules()); boolean removed = rules.remove(((CraftToolRule) rule).handle); - handle = new Tool(rules, handle.defaultMiningSpeed(), handle.damagePerBlock()); + handle = new Tool(rules, handle.defaultMiningSpeed(), handle.damagePerBlock(), handle.canDestroyBlocksInCreative()); return removed; } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftWeaponComponent.java b/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftWeaponComponent.java new file mode 100644 index 000000000..f678da91d --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftWeaponComponent.java @@ -0,0 +1,96 @@ +package org.bukkit.craftbukkit.inventory.components; + +import com.google.common.base.Preconditions; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import net.minecraft.world.item.component.Weapon; +import org.bukkit.configuration.serialization.SerializableAs; +import org.bukkit.craftbukkit.inventory.SerializableMeta; +import org.bukkit.inventory.meta.components.WeaponComponent; + +@SerializableAs("Weapon") +public final class CraftWeaponComponent implements WeaponComponent { + + private Weapon handle; + + public CraftWeaponComponent(Weapon weapon) { + this.handle = weapon; + } + + public CraftWeaponComponent(CraftWeaponComponent tool) { + this.handle = tool.handle; + } + + public CraftWeaponComponent(Map map) { + Integer itemDamagePerAttack = SerializableMeta.getObject(Integer.class, map, "item-damage-per-attack", false); + Float disableBlockingForSeconds = SerializableMeta.getObject(Float.class, map, "disable-blocking-for-seconds", true); + + this.handle = new Weapon(itemDamagePerAttack, (disableBlockingForSeconds != null) ? disableBlockingForSeconds : 0.0F); + } + + @Override + public Map serialize() { + Map result = new LinkedHashMap<>(); + result.put("item-damage-per-attack", getItemDamagePerAttack()); + if (getDisableBlockingForSeconds() != 0.0F) { + result.put("disable-blocking-for-seconds", getDisableBlockingForSeconds()); + } + return result; + } + + public Weapon getHandle() { + return handle; + } + + @Override + public int getItemDamagePerAttack() { + return getHandle().itemDamagePerAttack(); + } + + @Override + public void setItemDamagePerAttack(int damage) { + Preconditions.checkArgument(damage >= 0, "damage must be >= 0"); + + this.handle = new Weapon(damage, handle.disableBlockingForSeconds()); + } + + @Override + public float getDisableBlockingForSeconds() { + return getHandle().disableBlockingForSeconds(); + } + + @Override + public void setDisableBlockingForSeconds(float time) { + Preconditions.checkArgument(time >= 0, "time must be >= 0"); + + this.handle = new Weapon(handle.itemDamagePerAttack(), time); + } + + @Override + public int hashCode() { + int hash = 7; + hash = 73 * hash + Objects.hashCode(this.handle); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final CraftWeaponComponent other = (CraftWeaponComponent) obj; + return Objects.equals(this.handle, other.handle); + } + + @Override + public String toString() { + return "CraftWeaponComponent{" + "handle=" + handle + '}'; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftMenus.java b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftMenus.java index 3d5651ee3..65d8f186c 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftMenus.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftMenus.java @@ -56,7 +56,7 @@ public final class CraftMenus { final IMerchant minecraftMerchant = ((CraftMerchant) merchant.getBukkitView().getMerchant()).getMerchant(); int level = 1; if (minecraftMerchant instanceof EntityVillager villager) { - level = villager.getVillagerData().getLevel(); + level = villager.getVillagerData().level(); } if (minecraftMerchant.getTradingPlayer() != null) { // merchant's can only have one trader diff --git a/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java b/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java index 536db5de3..bdea5c6b7 100644 --- a/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java +++ b/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java @@ -352,7 +352,7 @@ public final class CraftLegacy { Optional propMap = blockTag.getElement("Properties").result(); if (propMap.isPresent()) { NBTTagCompound properties = propMap.get(); - for (String dataKey : properties.getAllKeys()) { + for (String dataKey : properties.keySet()) { IBlockState state = states.getProperty(dataKey); if (state == null) { @@ -360,8 +360,9 @@ public final class CraftLegacy { continue; } - Preconditions.checkState(!properties.getString(dataKey).isEmpty(), "Empty data string"); - Optional opt = state.getValue(properties.getString(dataKey)); + Optional propertyString = properties.getString(dataKey); + Preconditions.checkState(propertyString.isPresent() && !propertyString.get().isEmpty(), "Empty data string"); + Optional opt = state.getValue(propertyString.get()); Preconditions.checkArgument(opt.isPresent(), "No state value %s for %s", properties.getString(dataKey), dataKey); blockData = blockData.setValue(state, (Comparable) opt.get()); diff --git a/src/main/java/org/bukkit/craftbukkit/legacy/FieldRename.java b/src/main/java/org/bukkit/craftbukkit/legacy/FieldRename.java index 3a0dc5a73..ad25f8f06 100644 --- a/src/main/java/org/bukkit/craftbukkit/legacy/FieldRename.java +++ b/src/main/java/org/bukkit/craftbukkit/legacy/FieldRename.java @@ -161,7 +161,7 @@ public class FieldRename { .change("DROPPED_ITEM", "ITEM") .change("LEASH_HITCH", "LEASH_KNOT") .change("ENDER_SIGNAL", "EYE_OF_ENDER") - .change("SPLASH_POTION", "POTION") + .change("POTION", "SPLASH_POTION") .change("THROWN_EXP_BOTTLE", "EXPERIENCE_BOTTLE") .change("PRIMED_TNT", "TNT") .change("FIREWORK", "FIREWORK_ROCKET") diff --git a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java index af31f7546..ac968f4f3 100644 --- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java @@ -154,7 +154,7 @@ public class CraftPersistentDataContainer implements PersistentDataContainer { } public void putAll(NBTTagCompound compound) { - for (String key : compound.getAllKeys()) { + for (String key : compound.keySet()) { this.customDataTags.put(key, compound.get(key)); } } diff --git a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataTypeRegistry.java b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataTypeRegistry.java index a1b7442f3..65b2d1ef8 100644 --- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataTypeRegistry.java +++ b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataTypeRegistry.java @@ -141,40 +141,40 @@ public final class CraftPersistentDataTypeRegistry { if (Objects.equals(Byte.class, type)) { return this.createAdapter( Byte.class, NBTTagByte.class, NBTBase.TAG_BYTE, - NBTTagByte::valueOf, NBTTagByte::getAsByte + NBTTagByte::valueOf, NBTTagByte::byteValue ); } if (Objects.equals(Short.class, type)) { return this.createAdapter( - Short.class, NBTTagShort.class, NBTBase.TAG_SHORT, NBTTagShort::valueOf, NBTTagShort::getAsShort + Short.class, NBTTagShort.class, NBTBase.TAG_SHORT, NBTTagShort::valueOf, NBTTagShort::shortValue ); } if (Objects.equals(Integer.class, type)) { return this.createAdapter( - Integer.class, NBTTagInt.class, NBTBase.TAG_INT, NBTTagInt::valueOf, NBTTagInt::getAsInt + Integer.class, NBTTagInt.class, NBTBase.TAG_INT, NBTTagInt::valueOf, NBTTagInt::intValue ); } if (Objects.equals(Long.class, type)) { return this.createAdapter( - Long.class, NBTTagLong.class, NBTBase.TAG_LONG, NBTTagLong::valueOf, NBTTagLong::getAsLong + Long.class, NBTTagLong.class, NBTBase.TAG_LONG, NBTTagLong::valueOf, NBTTagLong::longValue ); } if (Objects.equals(Float.class, type)) { return this.createAdapter( Float.class, NBTTagFloat.class, NBTBase.TAG_FLOAT, - NBTTagFloat::valueOf, NBTTagFloat::getAsFloat + NBTTagFloat::valueOf, NBTTagFloat::floatValue ); } if (Objects.equals(Double.class, type)) { return this.createAdapter( Double.class, NBTTagDouble.class, NBTBase.TAG_DOUBLE, - NBTTagDouble::valueOf, NBTTagDouble::getAsDouble + NBTTagDouble::valueOf, NBTTagDouble::doubleValue ); } if (Objects.equals(String.class, type)) { return this.createAdapter( String.class, NBTTagString.class, NBTBase.TAG_STRING, - NBTTagString::valueOf, NBTTagString::getAsString + NBTTagString::valueOf, NBTTagString::value ); } @@ -216,8 +216,8 @@ public final class CraftPersistentDataTypeRegistry { final PersistentDataContainer[] containerArray = new CraftPersistentDataContainer[tag.size()]; for (int i = 0; i < tag.size(); i++) { final CraftPersistentDataContainer container = new CraftPersistentDataContainer(this); - final NBTTagCompound compound = tag.getCompound(i); - for (final String key : compound.getAllKeys()) { + final NBTTagCompound compound = tag.getCompoundOrEmpty(i); + for (final String key : compound.keySet()) { container.put(key, compound.get(key)); } containerArray[i] = container; @@ -236,7 +236,7 @@ public final class CraftPersistentDataTypeRegistry { CraftPersistentDataContainer::toTagCompound, tag -> { final CraftPersistentDataContainer container = new CraftPersistentDataContainer(this); - for (final String key : tag.getAllKeys()) { + for (final String key : tag.keySet()) { container.put(key, tag.get(key)); } return container; @@ -365,14 +365,12 @@ public final class CraftPersistentDataTypeRegistry { Preconditions.checkArgument(type instanceof ListPersistentDataType, "The passed list cannot be written to the PDC with a %s (expected a list data type)", type.getClass().getSimpleName()); final ListPersistentDataType listPersistentDataType = (ListPersistentDataType) type; - final TagAdapter elementAdapter = this.getOrCreateAdapter(listPersistentDataType.elementType()); - final List values = Lists.newArrayListWithCapacity(list.size()); for (final P primitiveValue : list) { values.add(this.wrap(listPersistentDataType.elementType(), primitiveValue)); } - return new NBTTagList(values, values.isEmpty() ? NBTTagList.TAG_END : elementAdapter.nmsTypeByte()); + return new NBTTagList(values); } /** @@ -424,7 +422,7 @@ public final class CraftPersistentDataTypeRegistry { return false; } - final byte elementType = listTag.getElementType(); + final byte elementType = listTag.identifyRawElementType(); final TagAdapter elementAdapter = this.getOrCreateAdapter(listPersistentDataType.elementType()); return elementAdapter.nmsTypeByte() == elementType || elementType == NBTTagList.TAG_END; diff --git a/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java b/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java index b59c2cb81..20bb35a02 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java +++ b/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java @@ -10,15 +10,17 @@ public final class ApiVersion implements Comparable, Serializable { public static final ApiVersion CURRENT; public static final ApiVersion FLATTENING; public static final ApiVersion FIELD_NAME_PARITY; + public static final ApiVersion ABSTRACT_COW; public static final ApiVersion NONE; private static final Map versions; static { versions = new HashMap<>(); - CURRENT = getOrCreateVersion("1.21.4"); + CURRENT = getOrCreateVersion("1.21.5"); FLATTENING = getOrCreateVersion("1.13"); FIELD_NAME_PARITY = getOrCreateVersion("1.20.5"); + ABSTRACT_COW = getOrCreateVersion("1.21.5"); NONE = getOrCreateVersion("none"); } diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java index 79e734f56..9baea2e24 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java @@ -12,6 +12,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Enumeration; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -209,6 +210,11 @@ public class Commodore { visitor = new LimitedClassRemapper(cw, new SimpleRemapper(ENUM_RENAMES)); } + Map renames = new HashMap<>(RENAMES); + if (pluginVersion.isOlderThan(ApiVersion.ABSTRACT_COW)) { + renames.put("org/bukkit/entity/Cow", "org/bukkit/entity/AbstractCow"); + } + cr.accept(new ClassRemapper(new ClassVisitor(Opcodes.ASM9, visitor) { final Set rerouteMethodData = new HashSet<>(); String className; @@ -598,7 +604,7 @@ public class Commodore { } }; } - }, new SimpleRemapper(RENAMES)), 0); + }, new SimpleRemapper(renames)), 0); return cw.toByteArray(); } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java index 7b18149ec..c67199fbf 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java @@ -3,6 +3,7 @@ package org.bukkit.craftbukkit.util; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; import com.google.gson.JsonParseException; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -11,8 +12,8 @@ import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; import net.minecraft.EnumChatFormat; +import net.minecraft.SystemUtils; import net.minecraft.network.chat.ChatClickable; -import net.minecraft.network.chat.ChatClickable.EnumClickAction; import net.minecraft.network.chat.ChatHexColor; import net.minecraft.network.chat.ChatModifier; import net.minecraft.network.chat.IChatBaseComponent; @@ -125,7 +126,10 @@ public final class CraftChatMessage { if (!(match.startsWith("http://") || match.startsWith("https://"))) { match = "http://" + match; } - modifier = modifier.withClickEvent(new ChatClickable(EnumClickAction.OPEN_URL, match)); + try { + modifier = modifier.withClickEvent(new ChatClickable.OpenUrl(SystemUtils.parseAndValidateUntrustedUri(match))); + } catch (URISyntaxException ex) { + } appendNewComponent(matcher.end(groupId)); modifier = modifier.withClickEvent((ChatClickable) null); } @@ -344,8 +348,11 @@ public final class CraftChatMessage { extras.add(prev); IChatMutableComponent link = IChatBaseComponent.literal(matcher.group()); - ChatModifier linkModi = modifier.withClickEvent(new ChatClickable(EnumClickAction.OPEN_URL, match)); - link.setStyle(linkModi); + try { + ChatModifier linkModi = modifier.withClickEvent(new ChatClickable.OpenUrl(SystemUtils.parseAndValidateUntrustedUri(match))); + link.setStyle(linkModi); + } catch (URISyntaxException ex) { + } extras.add(link); pos = matcher.end(); diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 62d8ba6b2..7892990ec 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -237,7 +237,7 @@ public final class CraftMagicNumbers implements UnsafeValues { * @return string */ public String getMappingsVersion() { - return "60ac387ca8007aa018e6aeb394a6988c"; + return "7ecad754373a5fbc43d381d7450c53a5"; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java b/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java index 44f133cf5..4427373a3 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java @@ -5,6 +5,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import java.util.List; import java.util.Map; import java.util.regex.Pattern; +import net.minecraft.nbt.DynamicOpsNBT; import net.minecraft.nbt.MojangsonParser; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; @@ -20,7 +21,7 @@ public class CraftNBTTagConfigSerializer { private static final Pattern ARRAY = Pattern.compile("^\\[.*]"); private static final Pattern INTEGER = Pattern.compile("[-+]?(?:0|[1-9][0-9]*)?i", Pattern.CASE_INSENSITIVE); private static final Pattern DOUBLE = Pattern.compile("[-+]?(?:[0-9]+[.]?|[0-9]*[.][0-9]+)(?:e[-+]?[0-9]+)?d", Pattern.CASE_INSENSITIVE); - private static final MojangsonParser MOJANGSON_PARSER = new MojangsonParser(new StringReader("")); + private static final MojangsonParser MOJANGSON_PARSER = MojangsonParser.create(DynamicOpsNBT.INSTANCE); public static String serialize(@NotNull final NBTBase base) { final SnbtPrinterTagVisitor snbtVisitor = new SnbtPrinterTagVisitor(); @@ -31,7 +32,7 @@ public class CraftNBTTagConfigSerializer { // The new logic expects the top level object to be a single string, holding the entire nbt tag as SNBT. if (object instanceof final String snbtString) { try { - return MojangsonParser.parseTag(snbtString); + return MojangsonParser.parseCompoundFully(snbtString); } catch (final CommandSyntaxException e) { throw new RuntimeException("Failed to deserialise nbt", e); } @@ -65,7 +66,7 @@ public class CraftNBTTagConfigSerializer { if (ARRAY.matcher(string).matches()) { try { - return new MojangsonParser(new StringReader(string)).readArrayTag(); + return MOJANGSON_PARSER.parseAsArgument(new StringReader(string)); } catch (CommandSyntaxException e) { throw new RuntimeException("Could not deserialize found list ", e); } @@ -74,12 +75,19 @@ public class CraftNBTTagConfigSerializer { } else if (DOUBLE.matcher(string).matches()) { return NBTTagDouble.valueOf(Double.parseDouble(string.substring(0, string.length() - 1))); } else { - NBTBase nbtBase = MOJANGSON_PARSER.type(string); + NBTBase nbtBase; + try { + nbtBase = MOJANGSON_PARSER.parseAsArgument(new StringReader(string)); + } catch (CommandSyntaxException e) { + throw new RuntimeException("Could not deserialize found value ", e); + } if (nbtBase instanceof NBTTagInt) { // If this returns an integer, it did not use our method from above - return NBTTagString.valueOf(nbtBase.getAsString()); // It then is a string that was falsely read as an int + return NBTTagString.valueOf(String.valueOf(((NBTTagInt) nbtBase).intValue())); // It then is a string that was falsely read as an int } else if (nbtBase instanceof NBTTagDouble) { - return NBTTagString.valueOf(String.valueOf(((NBTTagDouble) nbtBase).getAsDouble())); // Doubles add "d" at the end + return NBTTagString.valueOf(String.valueOf(((NBTTagDouble) nbtBase).doubleValue())); // Doubles add "d" at the end + } else if (nbtBase instanceof NBTTagString) { + return NBTTagString.valueOf(string); } else { return nbtBase; } diff --git a/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java index cb42d26f0..2aba9f0ad 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java +++ b/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java @@ -54,6 +54,7 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.ticks.LevelTickAccess; +import net.minecraft.world.ticks.NextTickListEntry; import net.minecraft.world.ticks.TickListPriority; import org.bukkit.event.entity.CreatureSpawnEvent; @@ -75,13 +76,13 @@ public abstract class DelegatedGeneratorAccess implements GeneratorAccessSeed { } @Override - public boolean ensureCanWrite(BlockPosition var0) { - return handle.ensureCanWrite(var0); + public boolean ensureCanWrite(BlockPosition blockposition) { + return handle.ensureCanWrite(blockposition); } @Override - public void setCurrentlyGenerating(Supplier var0) { - handle.setCurrentlyGenerating(var0); + public void setCurrentlyGenerating(Supplier supplier) { + handle.setCurrentlyGenerating(supplier); } @Override @@ -115,33 +116,13 @@ public abstract class DelegatedGeneratorAccess implements GeneratorAccessSeed { } @Override - public LevelTickAccess getBlockTicks() { - return handle.getBlockTicks(); + public NextTickListEntry createTick(BlockPosition blockposition, T t0, int i, TickListPriority ticklistpriority) { + return handle.createTick(blockposition, t0, i, ticklistpriority); } @Override - public void scheduleTick(BlockPosition blockposition, Block block, int i, TickListPriority ticklistpriority) { - handle.scheduleTick(blockposition, block, i, ticklistpriority); - } - - @Override - public void scheduleTick(BlockPosition blockposition, Block block, int i) { - handle.scheduleTick(blockposition, block, i); - } - - @Override - public LevelTickAccess getFluidTicks() { - return handle.getFluidTicks(); - } - - @Override - public void scheduleTick(BlockPosition blockposition, FluidType fluidtype, int i, TickListPriority ticklistpriority) { - handle.scheduleTick(blockposition, fluidtype, i, ticklistpriority); - } - - @Override - public void scheduleTick(BlockPosition blockposition, FluidType fluidtype, int i) { - handle.scheduleTick(blockposition, fluidtype, i); + public NextTickListEntry createTick(BlockPosition blockposition, T t0, int i) { + return handle.createTick(blockposition, t0, i); } @Override @@ -180,8 +161,8 @@ public abstract class DelegatedGeneratorAccess implements GeneratorAccessSeed { } @Override - public void blockUpdated(BlockPosition blockposition, Block block) { - handle.blockUpdated(blockposition, block); + public void updateNeighborsAt(BlockPosition blockposition, Block block) { + handle.updateNeighborsAt(blockposition, block); } @Override @@ -190,13 +171,13 @@ public abstract class DelegatedGeneratorAccess implements GeneratorAccessSeed { } @Override - public void playSound(EntityHuman entityhuman, BlockPosition blockposition, SoundEffect soundeffect, SoundCategory soundcategory) { - handle.playSound(entityhuman, blockposition, soundeffect, soundcategory); + public void playSound(Entity entity, BlockPosition blockposition, SoundEffect soundeffect, SoundCategory soundcategory) { + handle.playSound(entity, blockposition, soundeffect, soundcategory); } @Override - public void playSound(EntityHuman entityhuman, BlockPosition blockposition, SoundEffect soundeffect, SoundCategory soundcategory, float f, float f1) { - handle.playSound(entityhuman, blockposition, soundeffect, soundcategory, f, f1); + public void playSound(Entity entity, BlockPosition blockposition, SoundEffect soundeffect, SoundCategory soundcategory, float f, float f1) { + handle.playSound(entity, blockposition, soundeffect, soundcategory, f, f1); } @Override @@ -205,8 +186,8 @@ public abstract class DelegatedGeneratorAccess implements GeneratorAccessSeed { } @Override - public void levelEvent(EntityHuman entityhuman, int i, BlockPosition blockposition, int j) { - handle.levelEvent(entityhuman, i, blockposition, j); + public void levelEvent(Entity entity, int i, BlockPosition blockposition, int j) { + handle.levelEvent(entity, i, blockposition, j); } @Override @@ -240,23 +221,23 @@ public abstract class DelegatedGeneratorAccess implements GeneratorAccessSeed { } @Override - public Optional getBlockEntity(BlockPosition var0, TileEntityTypes var1) { - return handle.getBlockEntity(var0, var1); + public Optional getBlockEntity(BlockPosition blockposition, TileEntityTypes tileentitytypes) { + return handle.getBlockEntity(blockposition, tileentitytypes); } @Override - public List getEntityCollisions(Entity var0, AxisAlignedBB var1) { - return handle.getEntityCollisions(var0, var1); + public List getEntityCollisions(Entity entity, AxisAlignedBB axisalignedbb) { + return handle.getEntityCollisions(entity, axisalignedbb); } @Override - public boolean isUnobstructed(Entity var0, VoxelShape var1) { - return handle.isUnobstructed(var0, var1); + public boolean isUnobstructed(Entity entity, VoxelShape voxelshape) { + return handle.isUnobstructed(entity, voxelshape); } @Override - public BlockPosition getHeightmapPos(HeightMap.Type var0, BlockPosition var1) { - return handle.getHeightmapPos(var0, var1); + public BlockPosition getHeightmapPos(HeightMap.Type heightmap_type, BlockPosition blockposition) { + return handle.getHeightmapPos(heightmap_type, blockposition); } @Override @@ -265,8 +246,8 @@ public abstract class DelegatedGeneratorAccess implements GeneratorAccessSeed { } @Override - public float getTimeOfDay(float var0) { - return handle.getTimeOfDay(var0); + public float getTimeOfDay(float f) { + return handle.getTimeOfDay(f); } @Override @@ -275,13 +256,13 @@ public abstract class DelegatedGeneratorAccess implements GeneratorAccessSeed { } @Override - public IChunkAccess getChunk(int i, int i1, ChunkStatus cs, boolean bln) { - return handle.getChunk(i, i1, cs, bln); + public IChunkAccess getChunk(int i, int j, ChunkStatus chunkstatus, boolean flag) { + return handle.getChunk(i, j, chunkstatus, flag); } @Override - public int getHeight(HeightMap.Type type, int i, int i1) { - return handle.getHeight(type, i, i1); + public int getHeight(HeightMap.Type heightmap_type, int i, int j) { + return handle.getHeight(heightmap_type, i, j); } @Override @@ -295,28 +276,28 @@ public abstract class DelegatedGeneratorAccess implements GeneratorAccessSeed { } @Override - public Holder getBiome(BlockPosition var0) { - return handle.getBiome(var0); + public Holder getBiome(BlockPosition blockposition) { + return handle.getBiome(blockposition); } @Override - public Stream getBlockStatesIfLoaded(AxisAlignedBB var0) { - return handle.getBlockStatesIfLoaded(var0); + public Stream getBlockStatesIfLoaded(AxisAlignedBB axisalignedbb) { + return handle.getBlockStatesIfLoaded(axisalignedbb); } @Override - public int getBlockTint(BlockPosition var0, ColorResolver var1) { - return handle.getBlockTint(var0, var1); + public int getBlockTint(BlockPosition blockposition, ColorResolver colorresolver) { + return handle.getBlockTint(blockposition, colorresolver); } @Override - public Holder getNoiseBiome(int var0, int var1, int var2) { - return handle.getNoiseBiome(var0, var1, var2); + public Holder getNoiseBiome(int i, int j, int k) { + return handle.getNoiseBiome(i, j, k); } @Override - public Holder getUncachedNoiseBiome(int i, int i1, int i2) { - return handle.getUncachedNoiseBiome(i, i1, i2); + public Holder getUncachedNoiseBiome(int i, int j, int k) { + return handle.getUncachedNoiseBiome(i, j, k); } @Override @@ -345,88 +326,88 @@ public abstract class DelegatedGeneratorAccess implements GeneratorAccessSeed { } @Override - public boolean isEmptyBlock(BlockPosition var0) { - return handle.isEmptyBlock(var0); + public boolean isEmptyBlock(BlockPosition blockposition) { + return handle.isEmptyBlock(blockposition); } @Override - public boolean canSeeSkyFromBelowWater(BlockPosition var0) { - return handle.canSeeSkyFromBelowWater(var0); + public boolean canSeeSkyFromBelowWater(BlockPosition blockposition) { + return handle.canSeeSkyFromBelowWater(blockposition); } @Override - public float getPathfindingCostFromLightLevels(BlockPosition var0) { - return handle.getPathfindingCostFromLightLevels(var0); + public float getPathfindingCostFromLightLevels(BlockPosition blockposition) { + return handle.getPathfindingCostFromLightLevels(blockposition); } @Override - public float getLightLevelDependentMagicValue(BlockPosition var0) { - return handle.getLightLevelDependentMagicValue(var0); + public float getLightLevelDependentMagicValue(BlockPosition blockposition) { + return handle.getLightLevelDependentMagicValue(blockposition); } @Override - public IChunkAccess getChunk(BlockPosition var0) { - return handle.getChunk(var0); + public IChunkAccess getChunk(BlockPosition blockposition) { + return handle.getChunk(blockposition); } @Override - public IChunkAccess getChunk(int var0, int var1) { - return handle.getChunk(var0, var1); + public IChunkAccess getChunk(int i, int j) { + return handle.getChunk(i, j); } @Override - public IChunkAccess getChunk(int var0, int var1, ChunkStatus var2) { - return handle.getChunk(var0, var1, var2); + public IChunkAccess getChunk(int i, int j, ChunkStatus chunkstatus) { + return handle.getChunk(i, j, chunkstatus); } @Override - public IBlockAccess getChunkForCollisions(int var0, int var1) { - return handle.getChunkForCollisions(var0, var1); + public IBlockAccess getChunkForCollisions(int i, int j) { + return handle.getChunkForCollisions(i, j); } @Override - public boolean isWaterAt(BlockPosition var0) { - return handle.isWaterAt(var0); + public boolean isWaterAt(BlockPosition blockposition) { + return handle.isWaterAt(blockposition); } @Override - public boolean containsAnyLiquid(AxisAlignedBB var0) { - return handle.containsAnyLiquid(var0); + public boolean containsAnyLiquid(AxisAlignedBB axisalignedbb) { + return handle.containsAnyLiquid(axisalignedbb); } @Override - public int getMaxLocalRawBrightness(BlockPosition var0) { - return handle.getMaxLocalRawBrightness(var0); + public int getMaxLocalRawBrightness(BlockPosition blockposition) { + return handle.getMaxLocalRawBrightness(blockposition); } @Override - public int getMaxLocalRawBrightness(BlockPosition var0, int var1) { - return handle.getMaxLocalRawBrightness(var0, var1); + public int getMaxLocalRawBrightness(BlockPosition blockposition, int i) { + return handle.getMaxLocalRawBrightness(blockposition, i); } @Override - public boolean hasChunkAt(int var0, int var1) { - return handle.hasChunkAt(var0, var1); + public boolean hasChunkAt(int i, int j) { + return handle.hasChunkAt(i, j); } @Override - public boolean hasChunkAt(BlockPosition var0) { - return handle.hasChunkAt(var0); + public boolean hasChunkAt(BlockPosition blockposition) { + return handle.hasChunkAt(blockposition); } @Override - public boolean hasChunksAt(BlockPosition var0, BlockPosition var1) { - return handle.hasChunksAt(var0, var1); + public boolean hasChunksAt(BlockPosition blockposition, BlockPosition blockposition1) { + return handle.hasChunksAt(blockposition, blockposition1); } @Override - public boolean hasChunksAt(int var0, int var1, int var2, int var3, int var4, int var5) { - return handle.hasChunksAt(var0, var1, var2, var3, var4, var5); + public boolean hasChunksAt(int i, int j, int k, int l, int i1, int j1) { + return handle.hasChunksAt(i, j, k, l, i1, j1); } @Override - public boolean hasChunksAt(int var0, int var1, int var2, int var3) { - return handle.hasChunksAt(var0, var1, var2, var3); + public boolean hasChunksAt(int i, int j, int k, int l) { + return handle.hasChunksAt(i, j, k, l); } @Override @@ -440,13 +421,13 @@ public abstract class DelegatedGeneratorAccess implements GeneratorAccessSeed { } @Override - public HolderLookup holderLookup(ResourceKey> var0) { - return handle.holderLookup(var0); + public HolderLookup holderLookup(ResourceKey> resourcekey) { + return handle.holderLookup(resourcekey); } @Override - public float getShade(EnumDirection ed, boolean bln) { - return handle.getShade(ed, bln); + public float getShade(EnumDirection enumdirection, boolean flag) { + return handle.getShade(enumdirection, flag); } @Override @@ -455,18 +436,18 @@ public abstract class DelegatedGeneratorAccess implements GeneratorAccessSeed { } @Override - public int getBrightness(EnumSkyBlock var0, BlockPosition var1) { - return handle.getBrightness(var0, var1); + public int getBrightness(EnumSkyBlock enumskyblock, BlockPosition blockposition) { + return handle.getBrightness(enumskyblock, blockposition); } @Override - public int getRawBrightness(BlockPosition var0, int var1) { - return handle.getRawBrightness(var0, var1); + public int getRawBrightness(BlockPosition blockposition, int i) { + return handle.getRawBrightness(blockposition, i); } @Override - public boolean canSeeSky(BlockPosition var0) { - return handle.canSeeSky(var0); + public boolean canSeeSky(BlockPosition blockposition) { + return handle.canSeeSky(blockposition); } @Override @@ -475,108 +456,108 @@ public abstract class DelegatedGeneratorAccess implements GeneratorAccessSeed { } @Override - public boolean isUnobstructed(IBlockData var0, BlockPosition var1, VoxelShapeCollision var2) { - return handle.isUnobstructed(var0, var1, var2); + public boolean isUnobstructed(IBlockData iblockdata, BlockPosition blockposition, VoxelShapeCollision voxelshapecollision) { + return handle.isUnobstructed(iblockdata, blockposition, voxelshapecollision); } @Override - public boolean isUnobstructed(Entity var0) { - return handle.isUnobstructed(var0); + public boolean isUnobstructed(Entity entity) { + return handle.isUnobstructed(entity); } @Override - public boolean noCollision(AxisAlignedBB var0) { - return handle.noCollision(var0); + public boolean noCollision(AxisAlignedBB axisalignedbb) { + return handle.noCollision(axisalignedbb); } @Override - public boolean noCollision(Entity var0) { - return handle.noCollision(var0); + public boolean noCollision(Entity entity) { + return handle.noCollision(entity); } @Override - public boolean noCollision(Entity var0, AxisAlignedBB var1) { - return handle.noCollision(var0, var1); + public boolean noCollision(Entity entity, AxisAlignedBB axisalignedbb) { + return handle.noCollision(entity, axisalignedbb); } @Override - public boolean noCollision(Entity var0, AxisAlignedBB var1, boolean var2) { - return handle.noCollision(var0, var1, var2); + public boolean noCollision(Entity entity, AxisAlignedBB axisalignedbb, boolean flag) { + return handle.noCollision(entity, axisalignedbb, flag); } @Override - public boolean noBlockCollision(Entity var0, AxisAlignedBB var1) { - return handle.noBlockCollision(var0, var1); + public boolean noBlockCollision(Entity entity, AxisAlignedBB axisalignedbb) { + return handle.noBlockCollision(entity, axisalignedbb); } @Override - public Iterable getCollisions(Entity var0, AxisAlignedBB var1) { - return handle.getCollisions(var0, var1); + public Iterable getCollisions(Entity entity, AxisAlignedBB axisalignedbb) { + return handle.getCollisions(entity, axisalignedbb); } @Override - public Iterable getBlockCollisions(Entity var0, AxisAlignedBB var1) { - return handle.getBlockCollisions(var0, var1); + public Iterable getBlockCollisions(Entity entity, AxisAlignedBB axisalignedbb) { + return handle.getBlockCollisions(entity, axisalignedbb); } @Override - public Iterable getBlockAndLiquidCollisions(Entity var0, AxisAlignedBB var1) { - return handle.getBlockAndLiquidCollisions(var0, var1); + public Iterable getBlockAndLiquidCollisions(Entity entity, AxisAlignedBB axisalignedbb) { + return handle.getBlockAndLiquidCollisions(entity, axisalignedbb); } @Override - public MovingObjectPositionBlock clipIncludingBorder(RayTrace var0) { - return handle.clipIncludingBorder(var0); + public MovingObjectPositionBlock clipIncludingBorder(RayTrace raytrace) { + return handle.clipIncludingBorder(raytrace); } @Override - public boolean collidesWithSuffocatingBlock(Entity var0, AxisAlignedBB var1) { - return handle.collidesWithSuffocatingBlock(var0, var1); + public boolean collidesWithSuffocatingBlock(Entity entity, AxisAlignedBB axisalignedbb) { + return handle.collidesWithSuffocatingBlock(entity, axisalignedbb); } @Override - public Optional findSupportingBlock(Entity var0, AxisAlignedBB var1) { - return handle.findSupportingBlock(var0, var1); + public Optional findSupportingBlock(Entity entity, AxisAlignedBB axisalignedbb) { + return handle.findSupportingBlock(entity, axisalignedbb); } @Override - public Optional findFreePosition(Entity var0, VoxelShape var1, Vec3D var2, double var3, double var5, double var7) { - return handle.findFreePosition(var0, var1, var2, var3, var5, var7); + public Optional findFreePosition(Entity entity, VoxelShape voxelshape, Vec3D vec3d, double d0, double d1, double d2) { + return handle.findFreePosition(entity, voxelshape, vec3d, d0, d1, d2); } @Override - public int getDirectSignal(BlockPosition var0, EnumDirection var1) { - return handle.getDirectSignal(var0, var1); + public int getDirectSignal(BlockPosition blockposition, EnumDirection enumdirection) { + return handle.getDirectSignal(blockposition, enumdirection); } @Override - public int getDirectSignalTo(BlockPosition var0) { - return handle.getDirectSignalTo(var0); + public int getDirectSignalTo(BlockPosition blockposition) { + return handle.getDirectSignalTo(blockposition); } @Override - public int getControlInputSignal(BlockPosition var0, EnumDirection var1, boolean var2) { - return handle.getControlInputSignal(var0, var1, var2); + public int getControlInputSignal(BlockPosition blockposition, EnumDirection enumdirection, boolean flag) { + return handle.getControlInputSignal(blockposition, enumdirection, flag); } @Override - public boolean hasSignal(BlockPosition var0, EnumDirection var1) { - return handle.hasSignal(var0, var1); + public boolean hasSignal(BlockPosition blockposition, EnumDirection enumdirection) { + return handle.hasSignal(blockposition, enumdirection); } @Override - public int getSignal(BlockPosition var0, EnumDirection var1) { - return handle.getSignal(var0, var1); + public int getSignal(BlockPosition blockposition, EnumDirection enumdirection) { + return handle.getSignal(blockposition, enumdirection); } @Override - public boolean hasNeighborSignal(BlockPosition var0) { - return handle.hasNeighborSignal(var0); + public boolean hasNeighborSignal(BlockPosition blockposition) { + return handle.hasNeighborSignal(blockposition); } @Override - public int getBestNeighborSignal(BlockPosition var0) { - return handle.getBestNeighborSignal(var0); + public int getBestNeighborSignal(BlockPosition blockposition) { + return handle.getBestNeighborSignal(blockposition); } @Override @@ -635,18 +616,18 @@ public abstract class DelegatedGeneratorAccess implements GeneratorAccessSeed { } @Override - public List getEntities(Entity entity, AxisAlignedBB aabb, Predicate prdct) { - return handle.getEntities(entity, aabb, prdct); + public List getEntities(Entity entity, AxisAlignedBB axisalignedbb, Predicate predicate) { + return handle.getEntities(entity, axisalignedbb, predicate); } @Override - public List getEntities(EntityTypeTest ett, AxisAlignedBB aabb, Predicate prdct) { - return handle.getEntities(ett, aabb, prdct); + public List getEntities(EntityTypeTest entitytypetest, AxisAlignedBB axisalignedbb, Predicate predicate) { + return handle.getEntities(entitytypetest, axisalignedbb, predicate); } @Override - public List getEntitiesOfClass(Class var0, AxisAlignedBB var1, Predicate var2) { - return handle.getEntitiesOfClass(var0, var1, var2); + public List getEntitiesOfClass(Class oclass, AxisAlignedBB axisalignedbb, Predicate predicate) { + return handle.getEntitiesOfClass(oclass, axisalignedbb, predicate); } @Override @@ -655,38 +636,38 @@ public abstract class DelegatedGeneratorAccess implements GeneratorAccessSeed { } @Override - public List getEntities(Entity var0, AxisAlignedBB var1) { - return handle.getEntities(var0, var1); + public List getEntities(Entity entity, AxisAlignedBB axisalignedbb) { + return handle.getEntities(entity, axisalignedbb); } @Override - public List getEntitiesOfClass(Class var0, AxisAlignedBB var1) { - return handle.getEntitiesOfClass(var0, var1); + public List getEntitiesOfClass(Class oclass, AxisAlignedBB axisalignedbb) { + return handle.getEntitiesOfClass(oclass, axisalignedbb); } @Override - public EntityHuman getNearestPlayer(double var0, double var2, double var4, double var6, Predicate var8) { - return handle.getNearestPlayer(var0, var2, var4, var6, var8); + public EntityHuman getNearestPlayer(double d0, double d1, double d2, double d3, Predicate predicate) { + return handle.getNearestPlayer(d0, d1, d2, d3, predicate); } @Override - public EntityHuman getNearestPlayer(Entity var0, double var1) { - return handle.getNearestPlayer(var0, var1); + public EntityHuman getNearestPlayer(Entity entity, double d0) { + return handle.getNearestPlayer(entity, d0); } @Override - public EntityHuman getNearestPlayer(double var0, double var2, double var4, double var6, boolean var8) { - return handle.getNearestPlayer(var0, var2, var4, var6, var8); + public EntityHuman getNearestPlayer(double d0, double d1, double d2, double d3, boolean flag) { + return handle.getNearestPlayer(d0, d1, d2, d3, flag); } @Override - public boolean hasNearbyAlivePlayer(double var0, double var2, double var4, double var6) { - return handle.hasNearbyAlivePlayer(var0, var2, var4, var6); + public boolean hasNearbyAlivePlayer(double d0, double d1, double d2, double d3) { + return handle.hasNearbyAlivePlayer(d0, d1, d2, d3); } @Override - public EntityHuman getPlayerByUUID(UUID var0) { - return handle.getPlayerByUUID(var0); + public EntityHuman getPlayerByUUID(UUID uuid) { + return handle.getPlayerByUUID(uuid); } @Override @@ -750,42 +731,72 @@ public abstract class DelegatedGeneratorAccess implements GeneratorAccessSeed { } @Override - public boolean isInsideBuildHeight(int var0) { - return handle.isInsideBuildHeight(var0); + public boolean isInsideBuildHeight(int i) { + return handle.isInsideBuildHeight(i); } @Override - public boolean isOutsideBuildHeight(BlockPosition var0) { - return handle.isOutsideBuildHeight(var0); + public boolean isOutsideBuildHeight(BlockPosition blockposition) { + return handle.isOutsideBuildHeight(blockposition); } @Override - public boolean isOutsideBuildHeight(int var0) { - return handle.isOutsideBuildHeight(var0); + public boolean isOutsideBuildHeight(int i) { + return handle.isOutsideBuildHeight(i); } @Override - public int getSectionIndex(int var0) { - return handle.getSectionIndex(var0); + public int getSectionIndex(int i) { + return handle.getSectionIndex(i); } @Override - public int getSectionIndexFromSectionY(int var0) { - return handle.getSectionIndexFromSectionY(var0); + public int getSectionIndexFromSectionY(int i) { + return handle.getSectionIndexFromSectionY(i); } @Override - public int getSectionYFromSectionIndex(int var0) { - return handle.getSectionYFromSectionIndex(var0); + public int getSectionYFromSectionIndex(int i) { + return handle.getSectionYFromSectionIndex(i); } @Override - public boolean isStateAtPosition(BlockPosition bp, Predicate prdct) { - return handle.isStateAtPosition(bp, prdct); + public LevelTickAccess getBlockTicks() { + return handle.getBlockTicks(); } @Override - public boolean isFluidAtPosition(BlockPosition bp, Predicate prdct) { - return handle.isFluidAtPosition(bp, prdct); + public void scheduleTick(BlockPosition blockposition, Block block, int i, TickListPriority ticklistpriority) { + handle.scheduleTick(blockposition, block, i, ticklistpriority); + } + + @Override + public void scheduleTick(BlockPosition blockposition, Block block, int i) { + handle.scheduleTick(blockposition, block, i); + } + + @Override + public LevelTickAccess getFluidTicks() { + return handle.getFluidTicks(); + } + + @Override + public void scheduleTick(BlockPosition blockposition, FluidType fluidtype, int i, TickListPriority ticklistpriority) { + handle.scheduleTick(blockposition, fluidtype, i, ticklistpriority); + } + + @Override + public void scheduleTick(BlockPosition blockposition, FluidType fluidtype, int i) { + handle.scheduleTick(blockposition, fluidtype, i); + } + + @Override + public boolean isStateAtPosition(BlockPosition blockposition, Predicate predicate) { + return handle.isStateAtPosition(blockposition, predicate); + } + + @Override + public boolean isFluidAtPosition(BlockPosition blockposition, Predicate predicate) { + return handle.isFluidAtPosition(blockposition, predicate); } } diff --git a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java index be37cbc03..ab700ae67 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java +++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java @@ -104,7 +104,7 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed { } @Override - public void playSound(EntityHuman entityhuman, BlockPosition blockposition, SoundEffect soundeffect, SoundCategory soundcategory, float f, float f1) { + public void playSound(Entity entity, BlockPosition blockposition, SoundEffect soundeffect, SoundCategory soundcategory, float f, float f1) { throw new UnsupportedOperationException("Not supported yet."); } @@ -114,7 +114,7 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed { } @Override - public void levelEvent(EntityHuman entityhuman, int i, BlockPosition blockposition, int j) { + public void levelEvent(Entity entity, int i, BlockPosition blockposition, int j) { // Used by PowderSnowBlock.removeFluid } diff --git a/src/test/java/org/bukkit/ChatTest.java b/src/test/java/org/bukkit/ChatTest.java index c84d5f308..8ff24665b 100644 --- a/src/test/java/org/bukkit/ChatTest.java +++ b/src/test/java/org/bukkit/ChatTest.java @@ -27,15 +27,15 @@ public class ChatTest { public void testURLJsonConversion() { IChatBaseComponent[] components; components = CraftChatMessage.fromString("https://spigotmc.org/test Test Message"); - assertEquals("{\"text\":\"\",\"extra\":[{\"text\":\"https://spigotmc.org/test\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://spigotmc.org/test\"}},\" Test Message\"]}", + assertEquals("{\"text\":\"\",\"extra\":[{\"text\":\"https://spigotmc.org/test\",\"click_event\":{\"url\":\"https://spigotmc.org/test\",\"action\":\"open_url\"}},\" Test Message\"]}", CraftChatMessage.toJSON(components[0])); components = CraftChatMessage.fromString("123 " + ChatColor.GOLD + "https://spigotmc.org " + ChatColor.BOLD + "test"); - assertEquals("{\"text\":\"\",\"extra\":[\"123 \",{\"text\":\"https://spigotmc.org\",\"strikethrough\":false,\"obfuscated\":false,\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://spigotmc.org\"},\"bold\":false,\"italic\":false,\"underlined\":false,\"color\":\"gold\"},{\"text\":\" \",\"strikethrough\":false,\"obfuscated\":false,\"bold\":false,\"italic\":false,\"underlined\":false,\"color\":\"gold\"},{\"text\":\"test\",\"strikethrough\":false,\"obfuscated\":false,\"bold\":true,\"italic\":false,\"underlined\":false,\"color\":\"gold\"}]}", + assertEquals("{\"text\":\"\",\"extra\":[\"123 \",{\"text\":\"https://spigotmc.org\",\"strikethrough\":false,\"obfuscated\":false,\"click_event\":{\"url\":\"https://spigotmc.org\",\"action\":\"open_url\"},\"bold\":false,\"italic\":false,\"underlined\":false,\"color\":\"gold\"},{\"text\":\" \",\"strikethrough\":false,\"obfuscated\":false,\"bold\":false,\"italic\":false,\"underlined\":false,\"color\":\"gold\"},{\"text\":\"test\",\"strikethrough\":false,\"obfuscated\":false,\"bold\":true,\"italic\":false,\"underlined\":false,\"color\":\"gold\"}]}", CraftChatMessage.toJSON(components[0])); components = CraftChatMessage.fromString("multiCase http://SpigotMC.ORg/SpOngeBobMeEMeGoESHeRE"); - assertEquals("{\"text\":\"\",\"extra\":[\"multiCase \",{\"text\":\"http://SpigotMC.ORg/SpOngeBobMeEMeGoESHeRE\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"http://SpigotMC.ORg/SpOngeBobMeEMeGoESHeRE\"}}]}", + assertEquals("{\"text\":\"\",\"extra\":[\"multiCase \",{\"text\":\"http://SpigotMC.ORg/SpOngeBobMeEMeGoESHeRE\",\"click_event\":{\"url\":\"http://SpigotMC.ORg/SpOngeBobMeEMeGoESHeRE\",\"action\":\"open_url\"}}]}", CraftChatMessage.toJSON(components[0])); } } diff --git a/src/test/java/org/bukkit/craftbukkit/entity/EntityTypesTest.java b/src/test/java/org/bukkit/craftbukkit/entity/EntityTypesTest.java index adc50ef38..076a788af 100644 --- a/src/test/java/org/bukkit/craftbukkit/entity/EntityTypesTest.java +++ b/src/test/java/org/bukkit/craftbukkit/entity/EntityTypesTest.java @@ -11,6 +11,7 @@ import java.util.jar.JarFile; import java.util.stream.Stream; import java.util.zip.ZipEntry; import org.bukkit.entity.AbstractArrow; +import org.bukkit.entity.AbstractCow; import org.bukkit.entity.AbstractHorse; import org.bukkit.entity.AbstractSkeleton; import org.bukkit.entity.AbstractVillager; @@ -40,7 +41,6 @@ import org.bukkit.entity.Golem; import org.bukkit.entity.Hanging; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Illager; -import org.bukkit.entity.LingeringPotion; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Minecart; import org.bukkit.entity.Mob; @@ -51,10 +51,10 @@ import org.bukkit.entity.Projectile; import org.bukkit.entity.Raider; import org.bukkit.entity.SizedFireball; import org.bukkit.entity.Spellcaster; -import org.bukkit.entity.SplashPotion; import org.bukkit.entity.Steerable; import org.bukkit.entity.Tameable; import org.bukkit.entity.ThrowableProjectile; +import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.TippedArrow; import org.bukkit.entity.Vehicle; import org.bukkit.entity.WaterMob; @@ -73,6 +73,7 @@ public class EntityTypesTest { // Entity classes, which do not have any entity type / entity type data private static final List> EXCLUDE = Arrays.asList( AbstractArrow.class, + AbstractCow.class, AbstractHorse.class, AbstractSkeleton.class, AbstractVillager.class, @@ -101,7 +102,6 @@ public class EntityTypesTest { Hanging.class, HumanEntity.class, Illager.class, - LingeringPotion.class, LivingEntity.class, Minecart.class, Mob.class, @@ -112,10 +112,10 @@ public class EntityTypesTest { Raider.class, SizedFireball.class, Spellcaster.class, - SplashPotion.class, Steerable.class, Tameable.class, ThrowableProjectile.class, + ThrownPotion.class, TippedArrow.class, Vehicle.class, WaterMob.class diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/PlayerInventoryTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/PlayerInventoryTest.java index c1858713a..21de02ec0 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/PlayerInventoryTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/PlayerInventoryTest.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.inventory; import static org.junit.jupiter.api.Assertions.*; +import net.minecraft.world.entity.player.PlayerEquipment; import net.minecraft.world.entity.player.PlayerInventory; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -19,8 +20,8 @@ public class PlayerInventoryTest { ItemStack itemStack64Coal = new ItemStack(Items.COAL, 64); // keep one slot empty - PlayerInventory inventory = new PlayerInventory(null); - for (int i = 0; i < inventory.items.size() - 1; i++) { + PlayerInventory inventory = new PlayerInventory(null, new PlayerEquipment(null)); + for (int i = 0; i < inventory.getNonEquipmentItems().size() - 1; i++) { inventory.setItem(i, itemStackApple); } @@ -30,46 +31,46 @@ public class PlayerInventoryTest { assertEquals(64, inventory.canHold(itemStack64Coal)); // no free space with a stack of the item to check in the inventory - inventory.setItem(inventory.items.size() - 1, itemStack64Coal); + inventory.setItem(inventory.getNonEquipmentItems().size() - 1, itemStack64Coal); assertEquals(0, inventory.canHold(itemStack1Coal)); assertEquals(0, inventory.canHold(itemStack32Coal)); assertEquals(0, inventory.canHold(itemStack64Coal)); // no free space without a stack of the item to check in the inventory - inventory.setItem(inventory.items.size() - 1, itemStackApple); + inventory.setItem(inventory.getNonEquipmentItems().size() - 1, itemStackApple); assertEquals(0, inventory.canHold(itemStack1Coal)); assertEquals(0, inventory.canHold(itemStack32Coal)); assertEquals(0, inventory.canHold(itemStack64Coal)); // free space for 32 items in one slot - inventory.setItem(inventory.items.size() - 1, itemStack32Coal); + inventory.setItem(inventory.getNonEquipmentItems().size() - 1, itemStack32Coal); assertEquals(1, inventory.canHold(itemStack1Coal)); assertEquals(32, inventory.canHold(itemStack32Coal)); assertEquals(32, inventory.canHold(itemStack64Coal)); // free space for 1 item in two slots - inventory.setItem(inventory.items.size() - 1, itemStack63Coal); - inventory.setItem(inventory.items.size() - 2, itemStack63Coal); + inventory.setItem(inventory.getNonEquipmentItems().size() - 1, itemStack63Coal); + inventory.setItem(inventory.getNonEquipmentItems().size() - 2, itemStack63Coal); assertEquals(1, inventory.canHold(itemStack1Coal)); assertEquals(2, inventory.canHold(itemStack32Coal)); assertEquals(2, inventory.canHold(itemStack64Coal)); // free space for 32 items in non-empty off-hand slot - inventory.setItem(inventory.items.size() - 1, itemStackApple); - inventory.setItem(inventory.items.size() - 2, itemStackApple); - inventory.setItem(inventory.items.size() + inventory.armor.size(), itemStack32Coal); + inventory.setItem(inventory.getNonEquipmentItems().size() - 1, itemStackApple); + inventory.setItem(inventory.getNonEquipmentItems().size() - 2, itemStackApple); + inventory.setItem(inventory.getNonEquipmentItems().size() + inventory.getArmorContents().size(), itemStack32Coal); assertEquals(1, inventory.canHold(itemStack1Coal)); assertEquals(32, inventory.canHold(itemStack32Coal)); assertEquals(32, inventory.canHold(itemStack64Coal)); // free space for 1 item in non-empty off-hand slot and another slot - inventory.setItem(inventory.items.size() - 1, itemStack63Coal); - inventory.setItem(inventory.items.size() + inventory.armor.size(), itemStack63Coal); + inventory.setItem(inventory.getNonEquipmentItems().size() - 1, itemStack63Coal); + inventory.setItem(inventory.getNonEquipmentItems().size() + inventory.getArmorContents().size(), itemStack63Coal); assertEquals(1, inventory.canHold(itemStack1Coal)); assertEquals(2, inventory.canHold(itemStack32Coal)); diff --git a/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java b/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java index 848730054..b6fa69515 100644 --- a/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java +++ b/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java @@ -135,6 +135,8 @@ public class LegacyTest { // 1.21.4 Material.OPEN_EYEBLOSSOM, Material.CLOSED_EYEBLOSSOM, Material.RESIN_CLUMP, Material.RESIN_BLOCK, Material.RESIN_BRICKS, Material.RESIN_BRICK_STAIRS, Material.RESIN_BRICK_SLAB, Material.RESIN_BRICK_WALL, Material.CHISELED_RESIN_BRICKS, Material.RESIN_BRICK, Material.POTTED_OPEN_EYEBLOSSOM, Material.POTTED_CLOSED_EYEBLOSSOM, + // 1.21.5 + Material.WILDFLOWERS, Material.LEAF_LITTER, Material.TEST_BLOCK, Material.TEST_INSTANCE_BLOCK, Material.BUSH, Material.FIREFLY_BUSH, Material.SHORT_DRY_GRASS, Material.TALL_DRY_GRASS, Material.CACTUS_FLOWER, Material.BLUE_EGG, Material.BROWN_EGG, // Material.LEGACY_AIR, Material.LEGACY_DEAD_BUSH, Material.LEGACY_BURNING_FURNACE, Material.LEGACY_WALL_SIGN, Material.LEGACY_REDSTONE_TORCH_OFF, Material.LEGACY_SKULL, Material.LEGACY_REDSTONE_COMPARATOR_ON, Material.LEGACY_WALL_BANNER, Material.LEGACY_MONSTER_EGG)); diff --git a/src/test/java/org/bukkit/entity/VillagerTest.java b/src/test/java/org/bukkit/entity/VillagerTest.java index 28b6ac90d..0f01d87c4 100644 --- a/src/test/java/org/bukkit/entity/VillagerTest.java +++ b/src/test/java/org/bukkit/entity/VillagerTest.java @@ -10,6 +10,7 @@ import net.minecraft.world.entity.npc.EntityVillager; import net.minecraft.world.flag.FeatureFlags; import org.bukkit.Location; import org.bukkit.World; +import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.entity.CraftEntityTypes; import org.bukkit.support.environment.AllFeatures; import org.junit.jupiter.api.Test; @@ -99,6 +100,7 @@ public class VillagerTest { WorldServer worldServer = mock(withSettings().stubOnly()); when(worldServer.getMinecraftWorld()).thenReturn(worldServer); when(worldServer.enabledFeatures()).thenReturn(FeatureFlags.VANILLA_SET); + when(worldServer.registryAccess()).thenReturn(CraftRegistry.getMinecraftRegistry()); Location location = new Location(world, 0, 0, 0, 0, 0); CraftEntityTypes.SpawnData spawnData = new CraftEntityTypes.SpawnData(worldServer, location, false, false); EntityVillager entityVillager = (EntityVillager) CraftEntityTypes.getEntityTypeData(EntityType.VILLAGER).spawnFunction().apply(spawnData); diff --git a/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java b/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java index 9ed690ad3..deef3d243 100644 --- a/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java +++ b/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java @@ -9,8 +9,11 @@ import net.minecraft.sounds.SoundEffect; import net.minecraft.world.effect.MobEffectList; import net.minecraft.world.entity.ai.attributes.AttributeBase; import net.minecraft.world.entity.animal.CatVariant; -import net.minecraft.world.entity.animal.FrogVariant; -import net.minecraft.world.entity.animal.WolfVariant; +import net.minecraft.world.entity.animal.ChickenVariant; +import net.minecraft.world.entity.animal.CowVariant; +import net.minecraft.world.entity.animal.PigVariant; +import net.minecraft.world.entity.animal.frog.FrogVariant; +import net.minecraft.world.entity.animal.wolf.WolfVariant; import net.minecraft.world.entity.decoration.PaintingVariant; import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraft.world.entity.npc.VillagerType; @@ -43,7 +46,10 @@ import org.bukkit.craftbukkit.block.banner.CraftPatternType; import org.bukkit.craftbukkit.damage.CraftDamageType; import org.bukkit.craftbukkit.enchantments.CraftEnchantment; import org.bukkit.craftbukkit.entity.CraftCat; +import org.bukkit.craftbukkit.entity.CraftChicken; +import org.bukkit.craftbukkit.entity.CraftCow; import org.bukkit.craftbukkit.entity.CraftFrog; +import org.bukkit.craftbukkit.entity.CraftPig; import org.bukkit.craftbukkit.entity.CraftVillager; import org.bukkit.craftbukkit.entity.CraftWolf; import org.bukkit.craftbukkit.generator.structure.CraftStructure; @@ -57,7 +63,10 @@ import org.bukkit.craftbukkit.potion.CraftPotionEffectType; 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.Frog; +import org.bukkit.entity.Pig; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; import org.bukkit.generator.structure.Structure; @@ -103,7 +112,9 @@ public class RegistriesArgumentProvider implements ArgumentsProvider { register(Cat.Type.class, Registries.CAT_VARIANT, CraftCat.CraftType.class, CatVariant.class); register(MapCursor.Type.class, Registries.MAP_DECORATION_TYPE, CraftMapCursor.CraftType.class, MapDecorationType.class); register(PatternType.class, Registries.BANNER_PATTERN, CraftPatternType.class, EnumBannerPatternType.class); - + register(Pig.Variant.class, Registries.PIG_VARIANT, CraftPig.CraftVariant.class, PigVariant.class); + register(Cow.Variant.class, Registries.COW_VARIANT, CraftCow.CraftVariant.class, CowVariant.class); + register(Chicken.Variant.class, Registries.CHICKEN_VARIANT, CraftChicken.CraftVariant.class, ChickenVariant.class); } private static void register(Class bukkit, ResourceKey registry, Class craft, Class minecraft) {