From 43702a9e10ed373eaf724ead665d40ad1b2dc77a Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot <noreply+git-craftbukkit@papermc.io> Date: Mon, 22 Nov 2021 09:00:00 +1100 Subject: [PATCH] Update to Minecraft 1.18-pre5 By: md_5 <git@md-5.net> --- .../net/minecraft/CrashReport.patch | 4 +- .../minecraft/advancements/Advancement.patch | 11 +- .../minecraft/advancements/Advancements.patch | 8 +- .../commands/CommandDispatcher.patch | 58 +- .../commands/CommandListenerWrapper.patch | 18 +- .../minecraft/commands/ICommandListener.patch | 4 +- .../commands/arguments/ArgumentEntity.patch | 2 +- .../arguments/blocks/ArgumentBlock.patch | 16 +- .../selector/ArgumentParserSelector.patch | 8 +- .../arguments/selector/EntitySelector.patch | 2 +- .../net/minecraft/core/IRegistryCustom.patch | 75 ++ .../minecraft/core/RegistryMaterials.patch | 40 + .../core/cauldron/CauldronInteraction.patch | 142 +-- .../core/dispenser/DispenseBehaviorBoat.patch | 18 +- .../core/dispenser/DispenseBehaviorItem.patch | 38 +- .../DispenseBehaviorProjectile.patch | 28 +- .../dispenser/DispenseBehaviorShears.patch | 32 +- .../DispenseBehaviorShulkerBox.patch | 14 +- .../core/dispenser/IDispenseBehavior.patch | 373 +++---- .../minecraft/network/NetworkManager.patch | 10 +- .../network/PacketDataSerializer.patch | 62 +- .../minecraft/network/chat/ChatHexColor.patch | 8 +- .../network/chat/IChatBaseComponent.patch | 2 +- .../protocol/PlayerConnectionUtils.patch | 8 +- .../ClientboundInitializeBorderPacket.patch | 8 +- .../ClientboundSetBorderCenterPacket.patch | 4 +- .../protocol/game/PacketPlayInChat.patch | 4 +- .../game/PacketPlayOutMultiBlockChange.patch | 4 +- .../network/syncher/DataWatcher.patch | 12 +- .../resources/RegistryResourceAccess.patch | 61 ++ .../server/AdvancementDataPlayer.patch | 10 +- .../minecraft/server/CustomFunctionData.patch | 6 +- .../minecraft/server/DispenserRegistry.patch | 46 +- .../net/minecraft/server/Main.patch | 92 +- .../minecraft/server/MinecraftServer.patch | 482 ++++----- .../minecraft/server/ScoreboardServer.patch | 104 +- .../server/commands/CommandEffect.patch | 6 +- .../server/commands/CommandGamerule.patch | 20 +- .../server/commands/CommandList.patch | 6 +- .../server/commands/CommandReload.patch | 14 +- .../server/commands/CommandSchedule.patch | 17 +- .../commands/CommandSpreadPlayers.patch | 38 +- .../server/commands/CommandSummon.patch | 10 +- .../server/commands/CommandTeleport.patch | 18 +- .../server/commands/CommandTime.patch | 10 +- .../server/dedicated/DedicatedServer.patch | 88 +- .../dedicated/DedicatedServerProperties.patch | 28 +- .../dedicated/DedicatedServerSettings.patch | 4 +- .../server/dedicated/PropertyManager.patch | 30 +- .../net/minecraft/server/gui/ServerGUI.patch | 6 +- .../server/level/ChunkMapDistance.patch | 60 +- .../server/level/ChunkProviderServer.patch | 123 +-- .../minecraft/server/level/EntityPlayer.patch | 514 +++++----- .../server/level/EntityTrackerEntry.patch | 74 +- .../minecraft/server/level/PlayerChunk.patch | 61 +- .../server/level/PlayerChunkMap.patch | 96 +- .../server/level/PlayerInteractManager.patch | 198 ++-- .../level/RegionLimitedWorldAccess.patch | 12 +- .../minecraft/server/level/TicketType.patch | 12 +- .../minecraft/server/level/WorldServer.patch | 479 +++++---- .../server/network/HandshakeListener.patch | 16 +- .../server/network/LegacyPingHandler.patch | 16 +- .../server/network/LoginListener.patch | 30 +- .../server/network/PacketStatusListener.patch | 25 +- .../server/network/PlayerConnection.patch | 950 +++++++++--------- .../server/network/ServerConnection.patch | 10 +- .../server/players/ExpirableListEntry.patch | 6 +- .../minecraft/server/players/JsonList.patch | 25 +- .../NameReferencingFileConverter.patch | 28 +- .../minecraft/server/players/PlayerList.patch | 486 ++++----- .../server/players/SleepStatus.patch | 14 +- .../rcon/RemoteControlCommandListener.patch | 4 +- .../minecraft/stats/RecipeBookServer.patch | 14 +- .../stats/ServerStatisticManager.patch | 12 +- .../minecraft/stats/StatisticManager.patch | 8 +- .../net/minecraft/util/InclusiveRange.patch | 47 + .../util/datafix/DataConverterRegistry.patch | 23 +- .../util/worldupdate/WorldUpgrader.patch | 78 +- .../net/minecraft/world/ChestLock.patch | 12 +- .../net/minecraft/world/IInventory.patch | 2 +- .../minecraft/world/InventoryLargeChest.patch | 10 +- .../world/InventorySubcontainer.patch | 9 +- .../world/damagesource/DamageSource.patch | 2 +- .../EntityDamageSourceIndirect.patch | 2 +- .../world/effect/MobEffectList.patch | 20 +- .../minecraft/world/effect/MobEffects.patch | 4 +- .../net/minecraft/world/entity/Entity.patch | 335 +++--- .../world/entity/EntityAgeable.patch | 18 +- .../world/entity/EntityAreaEffectCloud.patch | 14 +- .../world/entity/EntityCreature.patch | 16 +- .../world/entity/EntityExperienceOrb.patch | 26 +- .../world/entity/EntityInsentient.patch | 210 ++-- .../world/entity/EntityLightning.patch | 45 +- .../minecraft/world/entity/EntityLiving.patch | 433 ++++---- .../minecraft/world/entity/EntityTypes.patch | 54 +- .../world/entity/IEntityAngerable.patch | 18 +- .../world/entity/IEntitySelector.patch | 6 +- .../world/entity/SaddleStorage.patch | 4 +- .../ai/attributes/AttributeRanged.patch | 6 +- .../ai/attributes/GenericAttributes.patch | 8 - .../behavior/BehaviorAttackTargetForget.patch | 8 +- .../ai/behavior/BehaviorAttackTargetSet.patch | 12 +- .../entity/ai/behavior/BehaviorCareer.patch | 20 +- .../entity/ai/behavior/BehaviorFarm.patch | 52 +- .../ai/behavior/BehaviorInteractDoor.patch | 22 +- .../entity/ai/behavior/BehaviorMakeLove.patch | 26 +- .../ai/behavior/BehaviorProfession.patch | 8 +- .../entity/ai/behavior/BehaviorUtil.patch | 58 +- .../ai/behavior/BehaviorWorkComposter.patch | 25 +- .../ai/goal/PathfinderGoalBreakDoor.patch | 10 +- .../ai/goal/PathfinderGoalEatTile.patch | 18 +- .../ai/goal/PathfinderGoalFollowOwner.patch | 12 +- .../entity/ai/goal/PathfinderGoalPanic.patch | 18 +- .../ai/goal/PathfinderGoalRemoveBlock.patch | 2 +- .../entity/ai/goal/PathfinderGoalSit.patch | 8 +- .../entity/ai/goal/PathfinderGoalTame.patch | 4 +- .../entity/ai/goal/PathfinderGoalTempt.patch | 12 +- .../target/PathfinderGoalDefendVillage.patch | 10 +- .../target/PathfinderGoalHurtByTarget.patch | 20 +- ...athfinderGoalNearestAttackableTarget.patch | 10 +- .../PathfinderGoalOwnerHurtByTarget.patch | 6 +- .../PathfinderGoalOwnerHurtTarget.patch | 6 +- .../ai/goal/target/PathfinderGoalTarget.patch | 14 +- .../entity/ai/village/VillageSiege.patch | 8 +- .../world/entity/ambient/EntityBat.patch | 32 +- .../world/entity/animal/Bucketable.patch | 24 +- .../world/entity/animal/EntityAnimal.patch | 57 +- .../world/entity/animal/EntityBee.patch | 34 +- .../world/entity/animal/EntityCat.patch | 31 +- .../world/entity/animal/EntityChicken.patch | 8 +- .../world/entity/animal/EntityCow.patch | 14 +- .../world/entity/animal/EntityDolphin.patch | 37 +- .../world/entity/animal/EntityFish.patch | 10 +- .../world/entity/animal/EntityFox.patch | 60 +- .../world/entity/animal/EntityIronGolem.patch | 8 +- .../entity/animal/EntityMushroomCow.patch | 38 +- .../world/entity/animal/EntityOcelot.patch | 20 +- .../world/entity/animal/EntityPanda.patch | 26 +- .../world/entity/animal/EntityParrot.patch | 35 +- .../world/entity/animal/EntityPig.patch | 16 +- .../entity/animal/EntityPufferFish.patch | 4 +- .../world/entity/animal/EntityRabbit.patch | 29 +- .../world/entity/animal/EntitySheep.patch | 50 +- .../world/entity/animal/EntitySnowman.patch | 24 +- .../world/entity/animal/EntitySquid.patch | 2 +- .../world/entity/animal/EntityTurtle.patch | 26 +- .../world/entity/animal/EntityWolf.patch | 67 +- .../world/entity/animal/axolotl/Axolotl.patch | 39 +- .../world/entity/animal/goat/Goat.patch | 37 +- .../animal/horse/EntityHorseAbstract.patch | 52 +- .../animal/horse/EntityLlamaTrader.patch | 6 +- .../horse/PathfinderGoalHorseTrap.patch | 24 +- .../boss/enderdragon/EntityEnderCrystal.patch | 24 +- .../boss/enderdragon/EntityEnderDragon.patch | 32 +- .../phases/DragonControllerManager.patch | 16 +- .../entity/boss/wither/EntityWither.patch | 46 +- .../entity/decoration/EntityArmorStand.patch | 96 +- .../entity/decoration/EntityHanging.patch | 72 +- .../entity/decoration/EntityItemFrame.patch | 42 +- .../world/entity/decoration/EntityLeash.patch | 14 +- .../entity/decoration/EntityPainting.patch | 13 - .../entity/item/EntityFallingBlock.patch | 38 +- .../world/entity/item/EntityItem.patch | 64 +- .../world/entity/item/EntityTNTPrimed.patch | 16 +- .../world/entity/monster/EntityCreeper.patch | 30 +- .../world/entity/monster/EntityEnderman.patch | 52 +- .../world/entity/monster/EntityGhast.patch | 14 +- .../world/entity/monster/EntityGuardian.patch | 11 - .../entity/monster/EntityGuardianElder.patch | 2 +- .../monster/EntityIllagerIllusioner.patch | 19 +- .../entity/monster/EntityIllagerWizard.patch | 8 +- .../world/entity/monster/EntityPhantom.patch | 16 +- .../entity/monster/EntityPigZombie.patch | 51 +- .../world/entity/monster/EntityPillager.patch | 11 - .../world/entity/monster/EntityRavager.patch | 17 +- .../world/entity/monster/EntityShulker.patch | 19 +- .../entity/monster/EntitySilverfish.patch | 29 +- .../world/entity/monster/EntitySkeleton.patch | 8 +- .../monster/EntitySkeletonAbstract.patch | 14 +- .../world/entity/monster/EntitySlime.patch | 20 +- .../world/entity/monster/EntityStrider.patch | 14 +- .../world/entity/monster/EntityVex.patch | 19 +- .../world/entity/monster/EntityWitch.patch | 2 +- .../world/entity/monster/EntityZombie.patch | 80 +- .../entity/monster/EntityZombieHusk.patch | 4 +- .../entity/monster/EntityZombieVillager.patch | 46 +- .../entity/monster/piglin/EntityPiglin.patch | 79 +- .../monster/piglin/EntityPiglinAbstract.patch | 10 +- .../entity/monster/piglin/PiglinAI.patch | 194 ++-- .../world/entity/npc/EntityVillager.patch | 102 +- .../entity/npc/EntityVillagerAbstract.patch | 6 +- .../entity/npc/EntityVillagerTrader.patch | 2 +- .../world/entity/npc/MobSpawnerTrader.patch | 18 +- .../world/entity/player/EntityHuman.patch | 305 +++--- .../world/entity/player/PlayerInventory.patch | 12 +- .../world/entity/projectile/EntityArrow.patch | 30 +- .../world/entity/projectile/EntityEgg.patch | 18 +- .../entity/projectile/EntityEnderPearl.patch | 38 +- .../entity/projectile/EntityEnderSignal.patch | 14 +- .../entity/projectile/EntityEvokerFangs.patch | 4 +- .../entity/projectile/EntityFireball.patch | 14 +- .../projectile/EntityFireballFireball.patch | 13 +- .../entity/projectile/EntityFireworks.patch | 22 +- .../entity/projectile/EntityFishingHook.patch | 64 +- .../projectile/EntityLargeFireball.patch | 12 +- .../entity/projectile/EntityLlamaSpit.patch | 12 +- .../entity/projectile/EntityPotion.patch | 86 +- .../entity/projectile/EntityProjectile.patch | 6 +- .../EntityProjectileThrowable.patch | 12 +- .../projectile/EntityShulkerBullet.patch | 16 +- .../projectile/EntitySmallFireball.patch | 30 +- .../projectile/EntitySpectralArrow.patch | 6 +- .../projectile/EntityThrownExpBottle.patch | 14 +- .../projectile/EntityThrownTrident.patch | 8 +- .../entity/projectile/EntityTippedArrow.patch | 12 +- .../entity/projectile/EntityWitherSkull.patch | 14 +- .../world/entity/projectile/IProjectile.patch | 16 +- .../world/entity/raid/EntityRaider.patch | 18 +- .../world/entity/raid/PersistentRaid.patch | 10 +- .../minecraft/world/entity/raid/Raid.patch | 40 +- .../world/entity/vehicle/EntityBoat.patch | 34 +- .../vehicle/EntityMinecartAbstract.patch | 107 +- .../vehicle/EntityMinecartCommandBlock.patch | 4 +- .../vehicle/EntityMinecartContainer.patch | 8 +- .../minecraft/world/food/FoodMetaData.patch | 24 +- .../minecraft/world/inventory/Container.patch | 26 +- .../world/inventory/ContainerAccess.patch | 6 +- .../world/inventory/ContainerAnvil.patch | 34 +- .../inventory/ContainerAnvilAbstract.patch | 6 +- .../world/inventory/ContainerBeacon.patch | 6 +- .../inventory/ContainerBrewingStand.patch | 8 +- .../inventory/ContainerCartography.patch | 16 +- .../world/inventory/ContainerChest.patch | 4 +- .../world/inventory/ContainerDispenser.patch | 10 +- .../inventory/ContainerEnchantTable.patch | 44 +- .../world/inventory/ContainerFurnace.patch | 18 +- .../world/inventory/ContainerGrindstone.patch | 20 +- .../world/inventory/ContainerHopper.patch | 6 +- .../world/inventory/ContainerHorse.patch | 2 +- .../world/inventory/ContainerLectern.patch | 14 +- .../world/inventory/ContainerLoom.patch | 32 +- .../world/inventory/ContainerMerchant.patch | 14 +- .../world/inventory/ContainerPlayer.patch | 6 +- .../world/inventory/ContainerShulkerBox.patch | 2 +- .../world/inventory/ContainerSmithing.patch | 8 +- .../inventory/ContainerStonecutter.patch | 10 +- .../world/inventory/ContainerWorkbench.patch | 30 +- .../world/inventory/Containers.patch | 21 +- .../inventory/InventoryCraftResult.patch | 2 +- .../world/inventory/InventoryCrafting.patch | 2 +- .../world/inventory/InventoryEnderChest.patch | 4 +- .../world/inventory/InventoryMerchant.patch | 2 +- .../world/inventory/SlotFurnaceResult.patch | 8 +- .../net/minecraft/world/item/ItemArmor.patch | 22 +- .../minecraft/world/item/ItemArmorStand.patch | 12 +- .../net/minecraft/world/item/ItemBlock.patch | 72 +- .../net/minecraft/world/item/ItemBoat.patch | 14 +- .../minecraft/world/item/ItemBoneMeal.patch | 8 +- .../net/minecraft/world/item/ItemBow.patch | 16 +- .../net/minecraft/world/item/ItemBucket.patch | 56 +- .../world/item/ItemChorusFruit.patch | 4 +- .../minecraft/world/item/ItemCrossbow.patch | 20 +- .../minecraft/world/item/ItemDebugStick.patch | 8 +- .../net/minecraft/world/item/ItemDye.patch | 6 +- .../net/minecraft/world/item/ItemEgg.patch | 18 +- .../minecraft/world/item/ItemEndCrystal.patch | 8 +- .../minecraft/world/item/ItemEnderEye.patch | 8 +- .../minecraft/world/item/ItemEnderPearl.patch | 22 +- .../minecraft/world/item/ItemFireball.patch | 32 +- .../minecraft/world/item/ItemFishingRod.patch | 20 +- .../world/item/ItemFlintAndSteel.patch | 22 +- .../minecraft/world/item/ItemHanging.patch | 8 +- .../net/minecraft/world/item/ItemLeash.patch | 8 +- .../minecraft/world/item/ItemMinecart.patch | 40 +- .../minecraft/world/item/ItemMonsterEgg.patch | 12 +- .../net/minecraft/world/item/ItemPotion.patch | 6 +- .../net/minecraft/world/item/ItemRecord.patch | 10 +- .../net/minecraft/world/item/ItemSign.patch | 6 +- .../world/item/ItemSkullPlayer.patch | 6 +- .../minecraft/world/item/ItemSnowball.patch | 24 +- .../net/minecraft/world/item/ItemStack.patch | 114 +-- .../minecraft/world/item/ItemTrident.patch | 22 +- .../minecraft/world/item/ItemWorldMap.patch | 16 +- .../world/item/crafting/CraftingManager.patch | 40 +- .../world/item/crafting/FurnaceRecipe.patch | 2 +- .../world/item/crafting/IRecipe.patch | 2 +- .../world/item/crafting/IRecipeComplex.patch | 2 +- .../world/item/crafting/RecipeBlasting.patch | 2 +- .../world/item/crafting/RecipeCampfire.patch | 2 +- .../world/item/crafting/RecipeItemStack.patch | 19 +- .../world/item/crafting/RecipeSmithing.patch | 4 +- .../world/item/crafting/RecipeSmoking.patch | 2 +- .../item/crafting/RecipeStonecutting.patch | 2 +- .../world/item/crafting/ShapedRecipes.patch | 2 +- .../item/crafting/ShapelessRecipes.patch | 2 +- .../enchantment/EnchantmentFrostWalker.patch | 10 +- .../enchantment/EnchantmentWeaponDamage.patch | 2 +- .../world/item/enchantment/Enchantments.patch | 12 +- .../world/item/trading/IMerchant.patch | 6 +- .../world/item/trading/MerchantRecipe.patch | 6 +- .../level/CommandBlockListenerAbstract.patch | 8 +- .../net/minecraft/world/level/Explosion.patch | 47 +- .../net/minecraft/world/level/GameRules.patch | 40 +- .../world/level/GeneratorAccess.patch | 20 +- .../minecraft/world/level/IBlockAccess.patch | 36 +- .../minecraft/world/level/IWorldWriter.patch | 4 +- .../world/level/MobSpawnerAbstract.patch | 18 +- .../net/minecraft/world/level/RayTrace.patch | 6 +- .../world/level/SpawnerCreature.patch | 62 +- .../world/level/StructureManager.patch | 2 +- .../world/level/TickListServer.patch | 31 - .../net/minecraft/world/level/World.patch | 158 +-- .../minecraft/world/level/WorldAccess.patch | 10 +- .../level/block/AbstractCandleBlock.patch | 10 +- .../world/level/block/AzaleaBlock.patch | 4 +- .../world/level/block/BigDripleafBlock.patch | 79 +- .../minecraft/world/level/block/Block.patch | 24 +- .../world/level/block/BlockBamboo.patch | 44 +- .../level/block/BlockBambooSapling.patch | 6 +- .../world/level/block/BlockBed.patch | 38 +- .../world/level/block/BlockBeehive.patch | 6 +- .../level/block/BlockButtonAbstract.patch | 30 +- .../world/level/block/BlockCactus.patch | 14 +- .../world/level/block/BlockCake.patch | 8 +- .../world/level/block/BlockCampfire.patch | 16 +- .../world/level/block/BlockCauldron.patch | 18 +- .../world/level/block/BlockChest.patch | 44 +- .../world/level/block/BlockChorusFlower.patch | 42 +- .../world/level/block/BlockCocoa.patch | 12 +- .../world/level/block/BlockCommand.patch | 12 +- .../world/level/block/BlockComposter.patch | 75 +- .../level/block/BlockConcretePowder.patch | 38 +- .../world/level/block/BlockCoral.patch | 8 +- .../world/level/block/BlockCoralFan.patch | 8 +- .../world/level/block/BlockCoralFanWall.patch | 8 +- .../world/level/block/BlockCoralPlant.patch | 8 +- .../world/level/block/BlockCrops.patch | 18 +- .../level/block/BlockDaylightDetector.patch | 10 +- .../level/block/BlockDiodeAbstract.patch | 16 +- .../level/block/BlockDirtSnowSpreadable.patch | 22 +- .../world/level/block/BlockDispenser.patch | 15 +- .../world/level/block/BlockDoor.patch | 20 +- .../world/level/block/BlockDragonEgg.patch | 10 +- .../world/level/block/BlockDropper.patch | 14 +- .../world/level/block/BlockEnderPortal.patch | 14 +- .../world/level/block/BlockFenceGate.patch | 12 +- .../world/level/block/BlockFire.patch | 86 +- .../world/level/block/BlockFireAbstract.patch | 32 +- .../world/level/block/BlockFluids.patch | 16 +- .../world/level/block/BlockFungi.patch | 4 +- .../world/level/block/BlockGrass.patch | 11 - .../world/level/block/BlockGrassPath.patch | 6 +- .../world/level/block/BlockGrowingTop.patch | 10 +- .../world/level/block/BlockIce.patch | 8 +- .../world/level/block/BlockJukeBox.patch | 10 +- .../world/level/block/BlockLeaves.patch | 14 +- .../world/level/block/BlockLectern.patch | 16 +- .../world/level/block/BlockLever.patch | 10 +- .../world/level/block/BlockMagma.patch | 4 +- .../level/block/BlockMinecartDetector.patch | 2 +- .../world/level/block/BlockMobSpawner.patch | 18 +- .../world/level/block/BlockMonsterEggs.patch | 10 +- .../world/level/block/BlockMushroom.patch | 10 +- .../world/level/block/BlockNetherWart.patch | 4 +- .../world/level/block/BlockNote.patch | 46 +- .../world/level/block/BlockNylium.patch | 10 +- .../world/level/block/BlockObserver.patch | 10 +- .../world/level/block/BlockOre.patch | 40 +- .../world/level/block/BlockPlant.patch | 10 +- .../world/level/block/BlockPortal.patch | 14 +- .../world/level/block/BlockPoweredRail.patch | 8 +- .../block/BlockPressurePlateAbstract.patch | 4 +- .../block/BlockPressurePlateBinary.patch | 4 +- .../block/BlockPressurePlateWeighted.patch | 8 +- .../level/block/BlockPumpkinCarved.patch | 48 +- .../level/block/BlockRedstoneComparator.patch | 20 +- .../world/level/block/BlockRedstoneLamp.patch | 18 +- .../world/level/block/BlockRedstoneOre.patch | 54 +- .../level/block/BlockRedstoneTorch.patch | 14 +- .../world/level/block/BlockRedstoneWire.patch | 25 +- .../world/level/block/BlockReed.patch | 10 +- .../world/level/block/BlockSapling.patch | 12 +- .../world/level/block/BlockScaffolding.patch | 12 +- .../world/level/block/BlockSnow.patch | 10 +- .../world/level/block/BlockSoil.patch | 26 +- .../world/level/block/BlockSponge.patch | 54 +- .../world/level/block/BlockStem.patch | 26 +- .../level/block/BlockSweetBerryBush.patch | 20 +- .../world/level/block/BlockTNT.patch | 10 +- .../world/level/block/BlockTallPlant.patch | 4 +- .../world/level/block/BlockTrapdoor.patch | 18 +- .../world/level/block/BlockTripwire.patch | 6 +- .../world/level/block/BlockTripwireHook.patch | 6 +- .../world/level/block/BlockTurtleEgg.patch | 28 +- .../world/level/block/BlockVine.patch | 50 +- .../world/level/block/BlockWaterLily.patch | 8 +- .../world/level/block/BlockWitherRose.patch | 2 +- .../world/level/block/BlockWitherSkull.patch | 44 +- .../level/block/BuddingAmethystBlock.patch | 4 +- .../world/level/block/CaveVines.patch | 18 +- .../world/level/block/CaveVinesBlock.patch | 6 +- .../level/block/CaveVinesPlantBlock.patch | 6 +- .../level/block/ChangeOverTimeBlock.patch | 4 +- .../level/block/LayeredCauldronBlock.patch | 52 +- .../world/level/block/LightningRodBlock.patch | 22 +- .../world/level/block/MultifaceBlock.patch | 37 +- .../level/block/PointedDripstoneBlock.patch | 76 +- .../world/level/block/PowderSnowBlock.patch | 12 +- .../world/level/block/RootedDirtBlock.patch | 6 +- .../world/level/block/SculkSensorBlock.patch | 30 +- .../entity/ContainerOpenersCounter.patch | 22 +- .../world/level/block/entity/TileEntity.patch | 34 +- .../level/block/entity/TileEntityBanner.patch | 4 +- .../level/block/entity/TileEntityBeacon.patch | 28 +- .../block/entity/TileEntityBeehive.patch | 62 +- .../block/entity/TileEntityBrewingStand.patch | 28 +- .../block/entity/TileEntityCampfire.patch | 10 +- .../level/block/entity/TileEntityChest.patch | 8 +- .../block/entity/TileEntityCommand.patch | 4 +- .../block/entity/TileEntityConduit.patch | 14 +- .../block/entity/TileEntityContainer.patch | 4 +- .../block/entity/TileEntityDispenser.patch | 5 +- .../block/entity/TileEntityEndGateway.patch | 29 +- .../block/entity/TileEntityFurnace.patch | 90 +- .../level/block/entity/TileEntityHopper.patch | 52 +- .../block/entity/TileEntityLectern.patch | 38 +- .../block/entity/TileEntityShulkerBox.patch | 12 +- .../level/block/entity/TileEntitySign.patch | 48 +- .../grower/WorldGenMegaTreeProvider.patch | 6 +- .../block/grower/WorldGenTreeProvider.patch | 50 +- .../level/block/piston/BlockPiston.patch | 22 +- .../block/state/properties/IBlockState.patch | 63 ++ .../world/level/border/WorldBorder.patch | 6 +- .../world/level/chunk/BiomeStorage.patch | 17 - .../minecraft/world/level/chunk/Chunk.patch | 169 ++-- .../world/level/chunk/ChunkGenerator.patch | 117 +-- .../world/level/chunk/ChunkSection.patch | 15 + .../world/level/chunk/ChunkStatus.patch | 21 +- .../world/level/chunk/DataPaletteBlock.patch | 152 +++ .../world/level/chunk/IChunkAccess.patch | 63 ++ .../chunk/storage/ChunkRegionLoader.patch | 59 +- .../level/chunk/storage/EntityStorage.patch | 26 - .../level/chunk/storage/IChunkLoader.patch | 36 +- .../level/chunk/storage/RegionFile.patch | 22 +- .../level/chunk/storage/RegionFileCache.patch | 48 +- .../PersistentEntitySectionManager.patch | 104 +- .../vibrations/VibrationListener.patch | 6 +- .../levelgen/ChunkGeneratorAbstract.patch | 70 +- .../level/levelgen/GeneratorSettings.patch | 57 +- .../level/levelgen/MobSpawnerPatrol.patch | 10 +- .../level/levelgen/MobSpawnerPhantom.patch | 10 +- .../world/level/levelgen/NoiseSampler.patch | 23 - .../level/levelgen/StructureSettings.patch | 27 +- .../structure/PersistentStructureLegacy.patch | 21 +- .../levelgen/structure/WorldGenWitchHut.patch | 24 +- .../templatesystem/DefinedStructure.patch | 38 +- .../templatesystem/DefinedStructureInfo.patch | 8 +- .../DefinedStructureManager.patch | 47 - .../level/material/FluidTypeFlowing.patch | 40 +- .../world/level/material/FluidTypeLava.patch | 22 +- .../world/level/portal/BlockPortalShape.patch | 44 +- .../level/portal/PortalTravelAgent.patch | 66 +- .../world/level/saveddata/maps/WorldMap.patch | 56 +- .../world/level/storage/Convertable.patch | 63 +- .../world/level/storage/WorldDataServer.patch | 55 +- .../world/level/storage/WorldNBTStorage.patch | 8 +- .../world/level/storage/loot/LootTable.patch | 10 +- .../storage/loot/LootTableRegistry.patch | 8 +- .../loot/functions/LootEnchantFunction.patch | 14 +- .../parameters/LootContextParameters.patch | 6 +- ...ItemConditionRandomChanceWithLooting.patch | 8 +- .../LootItemConditionSurvivesExplosion.patch | 2 +- .../world/ticks/NextTickListEntry.patch | 59 ++ .../minecraft/world/ticks/TickListChunk.patch | 53 + paper-server/pom.xml | 249 +++-- paper-server/src/assembly/META-INF/main-class | 1 + paper-server/src/assembly/bootstrap.xml | 65 ++ .../java/org/bukkit/craftbukkit/CraftArt.java | 2 +- .../org/bukkit/craftbukkit/CraftChunk.java | 106 +- .../craftbukkit/CraftChunkSnapshot.java | 21 +- .../bukkit/craftbukkit/CraftCrashReport.java | 2 +- .../org/bukkit/craftbukkit/CraftEffect.java | 2 +- .../bukkit/craftbukkit/CraftIpBanList.java | 2 +- .../bukkit/craftbukkit/CraftLootTable.java | 42 +- .../craftbukkit/CraftOfflinePlayer.java | 24 +- .../org/bukkit/craftbukkit/CraftParticle.java | 5 +- .../craftbukkit/CraftProfileBanList.java | 4 +- .../org/bukkit/craftbukkit/CraftRaid.java | 4 +- .../craftbukkit/CraftRegionAccessor.java | 271 ++--- .../org/bukkit/craftbukkit/CraftServer.java | 230 +++-- .../bukkit/craftbukkit/CraftStatistic.java | 48 +- .../org/bukkit/craftbukkit/CraftWorld.java | 214 ++-- .../bukkit/craftbukkit/CraftWorldBorder.java | 16 +- .../java/org/bukkit/craftbukkit/Main.java | 8 +- .../advancement/CraftAdvancement.java | 2 +- .../advancement/CraftAdvancementProgress.java | 10 +- .../attribute/CraftAttributeInstance.java | 8 +- .../attribute/CraftAttributeMap.java | 2 +- .../craftbukkit/block/CapturedBlockState.java | 4 +- .../bukkit/craftbukkit/block/CraftBanner.java | 8 +- .../bukkit/craftbukkit/block/CraftBarrel.java | 14 +- .../bukkit/craftbukkit/block/CraftBeacon.java | 6 +- .../craftbukkit/block/CraftBeehive.java | 4 +- .../bukkit/craftbukkit/block/CraftBlock.java | 72 +- .../block/CraftBlockEntityState.java | 14 +- .../craftbukkit/block/CraftBlockState.java | 6 +- .../craftbukkit/block/CraftBlockStates.java | 6 +- .../bukkit/craftbukkit/block/CraftChest.java | 14 +- .../block/CraftCreatureSpawner.java | 12 +- .../craftbukkit/block/CraftDispenser.java | 2 +- .../craftbukkit/block/CraftDropper.java | 2 +- .../craftbukkit/block/CraftFurnace.java | 2 +- .../craftbukkit/block/CraftJukebox.java | 12 +- .../craftbukkit/block/CraftLectern.java | 2 +- .../craftbukkit/block/CraftShulkerBox.java | 10 +- .../bukkit/craftbukkit/block/CraftSign.java | 6 +- .../bukkit/craftbukkit/block/CraftSkull.java | 4 +- .../block/CraftStructureBlock.java | 12 +- .../block/data/CraftBlockData.java | 32 +- .../block/impl/CraftBigDripleaf.java | 2 + .../bukkit/craftbukkit/bootstrap/Main.java | 168 ++++ .../bukkit/craftbukkit/boss/CraftBossBar.java | 12 +- .../craftbukkit/boss/CraftDragonBattle.java | 12 +- .../craftbukkit/boss/CraftKeyedBossbar.java | 2 +- .../command/BukkitCommandWrapper.java | 2 +- .../command/CraftBlockCommandSender.java | 4 +- .../command/VanillaCommandWrapper.java | 14 +- .../enchantments/CraftEnchantment.java | 6 +- .../entity/CraftAbstractHorse.java | 8 +- .../craftbukkit/entity/CraftAgeable.java | 2 +- .../craftbukkit/entity/CraftAnimals.java | 4 +- .../entity/CraftAreaEffectCloud.java | 18 +- .../craftbukkit/entity/CraftArmorStand.java | 14 +- .../bukkit/craftbukkit/entity/CraftArrow.java | 20 +- .../bukkit/craftbukkit/entity/CraftBat.java | 4 +- .../bukkit/craftbukkit/entity/CraftBee.java | 10 +- .../bukkit/craftbukkit/entity/CraftBoat.java | 2 +- .../bukkit/craftbukkit/entity/CraftCat.java | 4 +- .../craftbukkit/entity/CraftChestedHorse.java | 6 +- .../craftbukkit/entity/CraftCreeper.java | 2 +- .../craftbukkit/entity/CraftEnderCrystal.java | 4 +- .../craftbukkit/entity/CraftEnderDragon.java | 8 +- .../craftbukkit/entity/CraftEnderSignal.java | 6 +- .../craftbukkit/entity/CraftEnderman.java | 8 +- .../craftbukkit/entity/CraftEntity.java | 60 +- .../craftbukkit/entity/CraftEvoker.java | 4 +- .../craftbukkit/entity/CraftEvokerFangs.java | 2 +- .../craftbukkit/entity/CraftFallingBlock.java | 2 +- .../craftbukkit/entity/CraftFireball.java | 4 +- .../craftbukkit/entity/CraftFirework.java | 8 +- .../craftbukkit/entity/CraftFishHook.java | 8 +- .../bukkit/craftbukkit/entity/CraftFox.java | 14 +- .../craftbukkit/entity/CraftGlowSquid.java | 2 +- .../craftbukkit/entity/CraftGuardian.java | 8 +- .../bukkit/craftbukkit/entity/CraftHorse.java | 8 +- .../craftbukkit/entity/CraftHumanEntity.java | 70 +- .../bukkit/craftbukkit/entity/CraftItem.java | 4 +- .../craftbukkit/entity/CraftItemFrame.java | 6 +- .../craftbukkit/entity/CraftLivingEntity.java | 96 +- .../bukkit/craftbukkit/entity/CraftLlama.java | 2 +- .../craftbukkit/entity/CraftLlamaSpit.java | 4 +- .../craftbukkit/entity/CraftMinecart.java | 20 +- .../entity/CraftMinecartCommand.java | 2 +- .../bukkit/craftbukkit/entity/CraftMob.java | 8 +- .../craftbukkit/entity/CraftMushroomCow.java | 4 +- .../craftbukkit/entity/CraftPhantom.java | 4 +- .../bukkit/craftbukkit/entity/CraftPig.java | 2 +- .../craftbukkit/entity/CraftPigZombie.java | 4 +- .../craftbukkit/entity/CraftPlayer.java | 224 ++--- .../craftbukkit/entity/CraftProjectile.java | 4 +- .../craftbukkit/entity/CraftRabbit.java | 6 +- .../craftbukkit/entity/CraftRaider.java | 2 +- .../bukkit/craftbukkit/entity/CraftSheep.java | 4 +- .../craftbukkit/entity/CraftShulker.java | 8 +- .../entity/CraftShulkerBullet.java | 4 +- .../entity/CraftSizedFireball.java | 4 +- .../craftbukkit/entity/CraftSkeleton.java | 7 +- .../craftbukkit/entity/CraftSnowman.java | 2 +- .../craftbukkit/entity/CraftSpellcaster.java | 6 +- .../craftbukkit/entity/CraftStrider.java | 6 +- .../craftbukkit/entity/CraftTNTPrimed.java | 6 +- .../entity/CraftTameableAnimal.java | 12 +- .../entity/CraftThrowableProjectile.java | 4 +- .../craftbukkit/entity/CraftThrownPotion.java | 4 +- .../craftbukkit/entity/CraftTippedArrow.java | 12 +- .../bukkit/craftbukkit/entity/CraftVex.java | 2 +- .../craftbukkit/entity/CraftVillager.java | 22 +- .../entity/CraftVillagerZombie.java | 12 +- .../craftbukkit/entity/CraftWitherSkull.java | 4 +- .../bukkit/craftbukkit/entity/CraftWolf.java | 8 +- .../craftbukkit/entity/CraftZombie.java | 6 +- .../entity/memory/CraftMemoryMapper.java | 4 +- .../craftbukkit/event/CraftEventFactory.java | 46 +- .../craftbukkit/generator/CraftChunkData.java | 26 +- .../generator/CraftLimitedRegion.java | 30 +- .../craftbukkit/generator/CraftWorldInfo.java | 8 +- .../generator/CustomChunkGenerator.java | 99 +- .../generator/CustomWorldChunkManager.java | 7 +- .../generator/OldCraftChunkData.java | 28 +- .../inventory/CraftBlastingRecipe.java | 2 +- .../inventory/CraftCampfireRecipe.java | 2 +- .../inventory/CraftComplexRecipe.java | 6 +- .../craftbukkit/inventory/CraftContainer.java | 26 +- .../inventory/CraftEntityEquipment.java | 12 +- .../inventory/CraftFurnaceRecipe.java | 2 +- .../craftbukkit/inventory/CraftInventory.java | 4 +- .../inventory/CraftInventoryCrafting.java | 16 +- .../inventory/CraftInventoryCustom.java | 24 +- .../inventory/CraftInventoryDoubleChest.java | 4 +- .../inventory/CraftInventoryMerchant.java | 2 +- .../inventory/CraftInventoryPlayer.java | 10 +- .../craftbukkit/inventory/CraftItemStack.java | 32 +- .../craftbukkit/inventory/CraftMerchant.java | 2 +- .../inventory/CraftMerchantCustom.java | 26 +- .../inventory/CraftMetaArmorStand.java | 8 +- .../inventory/CraftMetaAxolotlBucket.java | 12 +- .../inventory/CraftMetaBanner.java | 16 +- .../inventory/CraftMetaBlockState.java | 18 +- .../craftbukkit/inventory/CraftMetaBook.java | 22 +- .../inventory/CraftMetaBundle.java | 6 +- .../inventory/CraftMetaCharge.java | 4 +- .../inventory/CraftMetaCompass.java | 26 +- .../inventory/CraftMetaCrossbow.java | 8 +- .../inventory/CraftMetaEnchantedBook.java | 2 +- .../inventory/CraftMetaEntityTag.java | 8 +- .../inventory/CraftMetaFirework.java | 18 +- .../craftbukkit/inventory/CraftMetaItem.java | 96 +- .../inventory/CraftMetaKnowledgeBook.java | 6 +- .../inventory/CraftMetaLeatherArmor.java | 6 +- .../craftbukkit/inventory/CraftMetaMap.java | 18 +- .../inventory/CraftMetaPotion.java | 28 +- .../craftbukkit/inventory/CraftMetaSkull.java | 22 +- .../inventory/CraftMetaSpawnEgg.java | 12 +- .../inventory/CraftMetaSuspiciousStew.java | 8 +- .../CraftMetaTropicalFishBucket.java | 12 +- .../craftbukkit/inventory/CraftRecipe.java | 4 +- .../inventory/CraftResultInventory.java | 10 +- .../inventory/CraftShapedRecipe.java | 6 +- .../inventory/CraftShapelessRecipe.java | 6 +- .../inventory/CraftSmithingRecipe.java | 2 +- .../inventory/CraftSmokingRecipe.java | 2 +- .../inventory/CraftStonecuttingRecipe.java | 2 +- .../craftbukkit/inventory/RecipeIterator.java | 2 +- .../util/CraftTileInventoryConverter.java | 16 +- .../craftbukkit/legacy/CraftLegacy.java | 40 +- .../craftbukkit/map/CraftMapCanvas.java | 2 +- .../craftbukkit/map/CraftMapRenderer.java | 2 +- .../bukkit/craftbukkit/map/CraftMapView.java | 4 +- .../CraftPersistentDataContainer.java | 4 +- .../CraftPersistentDataTypeRegistry.java | 24 +- .../craftbukkit/potion/CraftPotionBrewer.java | 2 +- .../potion/CraftPotionEffectType.java | 2 +- .../craftbukkit/potion/CraftPotionUtil.java | 6 +- .../CraftBlockProjectileSource.java | 54 +- .../scoreboard/CraftObjective.java | 12 +- .../craftbukkit/scoreboard/CraftScore.java | 8 +- .../scoreboard/CraftScoreboard.java | 28 +- .../scoreboard/CraftScoreboardManager.java | 12 +- .../CraftScoreboardTranslations.java | 4 +- .../craftbukkit/scoreboard/CraftTeam.java | 26 +- .../craftbukkit/structure/CraftPalette.java | 4 +- .../craftbukkit/structure/CraftStructure.java | 20 +- .../structure/CraftStructureManager.java | 20 +- .../bukkit/craftbukkit/tag/CraftBlockTag.java | 4 +- .../craftbukkit/tag/CraftEntityTag.java | 4 +- .../bukkit/craftbukkit/tag/CraftFluidTag.java | 4 +- .../bukkit/craftbukkit/tag/CraftItemTag.java | 4 +- .../org/bukkit/craftbukkit/tag/CraftTag.java | 2 +- .../util/BlockStateListPopulator.java | 28 +- .../bukkit/craftbukkit/util/Commodore.java | 45 + .../craftbukkit/util/CraftChatMessage.java | 56 +- .../craftbukkit/util/CraftDamageSource.java | 4 +- .../craftbukkit/util/CraftDimensionUtil.java | 2 +- .../craftbukkit/util/CraftMagicNumbers.java | 28 +- .../util/CraftNBTTagConfigSerializer.java | 18 +- .../craftbukkit/util/CraftNamespacedKey.java | 4 +- .../craftbukkit/util/CraftRayTraceResult.java | 4 +- .../craftbukkit/util/CraftVoxelShape.java | 2 +- .../util/DummyGeneratorAccess.java | 119 ++- .../src/test/java/org/bukkit/ArtTest.java | 2 +- .../org/bukkit/BlockDataConversionTest.java | 2 +- .../test/java/org/bukkit/BlockDataTest.java | 12 +- .../test/java/org/bukkit/DyeColorsTest.java | 4 +- .../test/java/org/bukkit/LootTablesTest.java | 2 +- .../test/java/org/bukkit/MaterialTest.java | 2 +- .../test/java/org/bukkit/PerMaterialTest.java | 24 +- .../src/test/java/org/bukkit/SoundTest.java | 2 +- .../bukkit/StatisticsAndAchievementsTest.java | 4 +- .../java/org/bukkit/StructureTypeTest.java | 2 +- .../bukkit/block/banner/PatternTypeTest.java | 6 +- .../craftbukkit/generator/ChunkDataTest.java | 12 +- .../craftbukkit/inventory/ItemMetaTest.java | 6 +- .../inventory/NMSCraftItemStackTest.java | 2 +- .../bukkit/craftbukkit/legacy/LegacyTest.java | 2 + .../util/CraftChatMessageTest.java | 4 +- .../org/bukkit/entity/EntityTypesTest.java | 4 +- .../entity/memory/CraftMemoryKeyTest.java | 4 +- .../java/org/bukkit/potion/PotionTest.java | 4 +- .../bukkit/support/AbstractTestingBase.java | 12 +- .../java/org/bukkit/support/DummyServer.java | 2 +- 700 files changed, 10286 insertions(+), 10098 deletions(-) create mode 100644 paper-server/nms-patches/net/minecraft/core/IRegistryCustom.patch create mode 100644 paper-server/nms-patches/net/minecraft/core/RegistryMaterials.patch create mode 100644 paper-server/nms-patches/net/minecraft/resources/RegistryResourceAccess.patch create mode 100644 paper-server/nms-patches/net/minecraft/util/InclusiveRange.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/entity/monster/EntityGuardian.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/level/TickListServer.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/level/block/BlockGrass.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/level/block/state/properties/IBlockState.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/level/chunk/BiomeStorage.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/level/chunk/DataPaletteBlock.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/level/chunk/storage/EntityStorage.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/level/levelgen/NoiseSampler.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureManager.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/ticks/NextTickListEntry.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/ticks/TickListChunk.patch create mode 100644 paper-server/src/assembly/META-INF/main-class create mode 100644 paper-server/src/assembly/bootstrap.xml create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/bootstrap/Main.java diff --git a/paper-server/nms-patches/net/minecraft/CrashReport.patch b/paper-server/nms-patches/net/minecraft/CrashReport.patch index d8cab27ec6..2317ea6d96 100644 --- a/paper-server/nms-patches/net/minecraft/CrashReport.patch +++ b/paper-server/nms-patches/net/minecraft/CrashReport.patch @@ -4,7 +4,7 @@ public CrashReport(String s, Throwable throwable) { this.title = s; this.exception = throwable; -+ this.systemReport.a("CraftBukkit Information", new org.bukkit.craftbukkit.CraftCrashReport()); // CraftBukkit ++ this.systemReport.setDetail("CraftBukkit Information", new org.bukkit.craftbukkit.CraftCrashReport()); // CraftBukkit } - public String a() { + public String getTitle() { diff --git a/paper-server/nms-patches/net/minecraft/advancements/Advancement.patch b/paper-server/nms-patches/net/minecraft/advancements/Advancement.patch index 963fa13e6a..840e7f5009 100644 --- a/paper-server/nms-patches/net/minecraft/advancements/Advancement.patch +++ b/paper-server/nms-patches/net/minecraft/advancements/Advancement.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/advancements/Advancement.java +++ b/net/minecraft/advancements/Advancement.java -@@ -39,6 +39,7 @@ +@@ -41,6 +41,7 @@ private final String[][] requirements; private final Set<Advancement> children = Sets.newLinkedHashSet(); private final IChatBaseComponent chatComponent; @@ -8,12 +8,3 @@ public Advancement(MinecraftKey minecraftkey, @Nullable Advancement advancement, @Nullable AdvancementDisplay advancementdisplay, AdvancementRewards advancementrewards, Map<String, Criterion> map, String[][] astring) { this.id = minecraftkey; -@@ -233,7 +234,7 @@ - } - - public Advancement b(MinecraftKey minecraftkey) { -- if (!this.a((minecraftkey1) -> { -+ if (!this.a((Function<MinecraftKey, Advancement>) (minecraftkey1) -> { // CraftBukkit - decompile error - return null; - })) { - throw new IllegalStateException("Tried to build incomplete advancement!"); diff --git a/paper-server/nms-patches/net/minecraft/advancements/Advancements.patch b/paper-server/nms-patches/net/minecraft/advancements/Advancements.patch index e543796631..3a6d36d59f 100644 --- a/paper-server/nms-patches/net/minecraft/advancements/Advancements.patch +++ b/paper-server/nms-patches/net/minecraft/advancements/Advancements.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/advancements/Advancements.java +++ b/net/minecraft/advancements/Advancements.java -@@ -79,7 +79,7 @@ +@@ -80,7 +80,7 @@ entry = (Entry) iterator.next(); MinecraftKey minecraftkey = (MinecraftKey) entry.getKey(); Advancement.SerializedAdvancement advancement_serializedadvancement = (Advancement.SerializedAdvancement) entry.getValue(); @@ -8,8 +8,8 @@ + Map<MinecraftKey, Advancement> map1 = this.advancements; // CraftBukkit - decompile error Objects.requireNonNull(this.advancements); - if (advancement_serializedadvancement.a(map1::get)) { -@@ -116,7 +116,7 @@ + if (advancement_serializedadvancement.canBuild(map1::get)) { +@@ -117,7 +117,7 @@ } } @@ -17,4 +17,4 @@ + // Advancements.LOGGER.info("Loaded {} advancements", this.advancements.size()); // CraftBukkit - moved to AdvancementDataWorld#reload } - public void a() { + public void clear() { diff --git a/paper-server/nms-patches/net/minecraft/commands/CommandDispatcher.patch b/paper-server/nms-patches/net/minecraft/commands/CommandDispatcher.patch index 0bbff55734..9d902619eb 100644 --- a/paper-server/nms-patches/net/minecraft/commands/CommandDispatcher.patch +++ b/paper-server/nms-patches/net/minecraft/commands/CommandDispatcher.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/CommandDispatcher.java +++ b/net/minecraft/commands/CommandDispatcher.java -@@ -103,6 +103,14 @@ +@@ -106,6 +106,14 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -15,32 +15,32 @@ public class CommandDispatcher { private static final Logger LOGGER = LogManager.getLogger(); -@@ -114,6 +122,7 @@ +@@ -117,6 +125,7 @@ private final com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> dispatcher = new com.mojang.brigadier.CommandDispatcher(); public CommandDispatcher(CommandDispatcher.ServerType commanddispatcher_servertype) { + this(); // CraftBukkit - CommandAdvancement.a(this.dispatcher); - CommandAttribute.a(this.dispatcher); - CommandExecute.a(this.dispatcher); -@@ -195,17 +204,61 @@ + CommandAdvancement.register(this.dispatcher); + CommandAttribute.register(this.dispatcher); + CommandExecute.register(this.dispatcher); +@@ -202,17 +211,63 @@ } this.dispatcher.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> { - CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.dispatcher.getPath(commandnode1), this.dispatcher.getPath(commandnode2), collection); -+ // CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.b.getPath(commandnode1), this.b.getPath(commandnode2), collection); // CraftBukkit ++ // CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.dispatcher.getPath(commandnode1), this.dispatcher.getPath(commandnode2), collection); // CraftBukkit }); -- this.dispatcher.setConsumer((commandcontext, flag, i) -> { -- ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag, i); ++ // CraftBukkit start + } + -+ // CraftBukkit start + public CommandDispatcher() { -+ this.dispatcher.setConsumer((commandcontext, flag1, i) -> { -+ ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag1, i); ++ // CraftBukkkit end + this.dispatcher.setConsumer((commandcontext, flag, i) -> { + ((CommandListenerWrapper) commandcontext.getSource()).onCommandComplete(commandcontext, flag, i); }); } ++ // CraftBukkit start + public int dispatchServerCommand(CommandListenerWrapper sender, String command) { + Joiner joiner = Joiner.on(" "); + if (command.startsWith("/")) { @@ -68,19 +68,19 @@ + } + + // Handle vanilla commands; -+ if (sender.getWorld().getCraftServer().getCommandBlockOverride(args[0])) { ++ if (sender.getLevel().getCraftServer().getCommandBlockOverride(args[0])) { + args[0] = "minecraft:" + args[0]; + } + + String newCommand = joiner.join(args); -+ return this.a(sender, newCommand, newCommand, false); ++ return this.performCommand(sender, newCommand, newCommand, false); + } + - public int a(CommandListenerWrapper commandlistenerwrapper, String s) { -+ return this.a(commandlistenerwrapper, s, s, true); + public int performCommand(CommandListenerWrapper commandlistenerwrapper, String s) { ++ return this.performCommand(commandlistenerwrapper, s, s, true); + } + -+ public int a(CommandListenerWrapper commandlistenerwrapper, String s, String label, boolean stripSlash) { ++ public int performCommand(CommandListenerWrapper commandlistenerwrapper, String s, String label, boolean stripSlash) { StringReader stringreader = new StringReader(s); - if (stringreader.canRead() && stringreader.peek() == '/') { @@ -89,34 +89,34 @@ stringreader.skip(); } -@@ -229,7 +282,7 @@ +@@ -236,7 +291,7 @@ if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) { int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor()); - IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).a(EnumChatFormat.GRAY).format((chatmodifier) -> { -- return chatmodifier.setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, s)); -+ return chatmodifier.setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, label)); // CraftBukkit + IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).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 }); if (j > 10) { -@@ -279,11 +332,36 @@ +@@ -286,11 +341,36 @@ } - public void a(EntityPlayer entityplayer) { + public void sendCommands(EntityPlayer entityplayer) { - Map<CommandNode<CommandListenerWrapper>, CommandNode<ICompletionProvider>> map = Maps.newHashMap(); + // CraftBukkit start + // Register Vanilla commands into builtRoot as before + Map<CommandNode<CommandListenerWrapper>, CommandNode<ICompletionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues + RootCommandNode vanillaRoot = new RootCommandNode(); + -+ RootCommandNode<CommandListenerWrapper> vanilla = entityplayer.server.vanillaCommandDispatcher.a().getRoot(); ++ RootCommandNode<CommandListenerWrapper> vanilla = entityplayer.server.vanillaCommandDispatcher.getDispatcher().getRoot(); + map.put(vanilla, vanillaRoot); -+ this.a(vanilla, vanillaRoot, entityplayer.getCommandListener(), (Map) map); ++ this.fillUsableCommands(vanilla, vanillaRoot, entityplayer.createCommandSourceStack(), (Map) map); + + // Now build the global commands in a second pass RootCommandNode<ICompletionProvider> rootcommandnode = new RootCommandNode(); map.put(this.dispatcher.getRoot(), rootcommandnode); - this.a(this.dispatcher.getRoot(), rootcommandnode, entityplayer.getCommandListener(), (Map) map); + this.fillUsableCommands(this.dispatcher.getRoot(), rootcommandnode, entityplayer.createCommandSourceStack(), map); + + Collection<String> bukkit = new LinkedHashSet<>(); + for (CommandNode node : rootcommandnode.getChildren()) { @@ -133,10 +133,10 @@ + } + } + // CraftBukkit end - entityplayer.connection.sendPacket(new PacketPlayOutCommands(rootcommandnode)); + entityplayer.connection.send(new PacketPlayOutCommands(rootcommandnode)); } -@@ -294,7 +372,7 @@ +@@ -301,7 +381,7 @@ CommandNode<CommandListenerWrapper> commandnode2 = (CommandNode) iterator.next(); if (commandnode2.canUse(commandlistenerwrapper)) { @@ -145,7 +145,7 @@ argumentbuilder.requires((icompletionprovider) -> { return true; -@@ -317,7 +395,7 @@ +@@ -324,7 +404,7 @@ argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect())); } diff --git a/paper-server/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch b/paper-server/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch index 061120e6ce..4fbe5d0d4c 100644 --- a/paper-server/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch +++ b/paper-server/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/CommandListenerWrapper.java +++ b/net/minecraft/commands/CommandListenerWrapper.java -@@ -36,6 +36,8 @@ +@@ -37,6 +37,8 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; @@ -9,7 +9,7 @@ public class CommandListenerWrapper implements ICompletionProvider { public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(new ChatMessage("permissions.requires.player")); -@@ -53,6 +55,7 @@ +@@ -55,6 +57,7 @@ private final ResultConsumer<CommandListenerWrapper> consumer; private final ArgumentAnchor.Anchor anchor; private final Vec2F rotation; @@ -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, (commandcontext, flag, j) -> { -@@ -153,9 +156,23 @@ +@@ -155,9 +158,23 @@ @Override public boolean hasPermission(int i) { @@ -34,25 +34,25 @@ + // CraftBukkit start + public boolean hasPermission(int i, String bukkitPermission) { + // World is null when loading functions -+ return ((getWorld() == null || !getWorld().getCraftServer().ignoreVanillaPermissions) && this.permissionLevel >= i) || getBukkitSender().hasPermission(bukkitPermission); ++ return ((getLevel() == null || !getLevel().getCraftServer().ignoreVanillaPermissions) && this.permissionLevel >= i) || getBukkitSender().hasPermission(bukkitPermission); + } + // CraftBukkit end + public Vec3D getPosition() { return this.worldPosition; } -@@ -217,7 +234,7 @@ +@@ -219,7 +236,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -- if (entityplayer != this.source && this.server.getPlayerList().isOp(entityplayer.getProfile())) { +- if (entityplayer != this.source && this.server.getPlayerList().isOp(entityplayer.getGameProfile())) { + if (entityplayer != this.source && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit entityplayer.sendMessage(ichatmutablecomponent, SystemUtils.NIL_UUID); } } -@@ -277,4 +294,10 @@ - public IRegistryCustom q() { - return this.server.getCustomRegistry(); +@@ -279,4 +296,10 @@ + public IRegistryCustom registryAccess() { + return this.server.registryAccess(); } + + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/commands/ICommandListener.patch b/paper-server/nms-patches/net/minecraft/commands/ICommandListener.patch index 726bc17dcd..97ea2ade9f 100644 --- a/paper-server/nms-patches/net/minecraft/commands/ICommandListener.patch +++ b/paper-server/nms-patches/net/minecraft/commands/ICommandListener.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/commands/ICommandListener.java +++ b/net/minecraft/commands/ICommandListener.java @@ -23,6 +23,13 @@ - public boolean shouldBroadcastCommands() { + public boolean shouldInformAdmins() { return false; } + @@ -15,7 +15,7 @@ void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid); @@ -36,4 +43,6 @@ - default boolean c_() { + default boolean alwaysAccepts() { return false; } + diff --git a/paper-server/nms-patches/net/minecraft/commands/arguments/ArgumentEntity.patch b/paper-server/nms-patches/net/minecraft/commands/arguments/ArgumentEntity.patch index 7818666e2a..7cd30fe503 100644 --- a/paper-server/nms-patches/net/minecraft/commands/arguments/ArgumentEntity.patch +++ b/paper-server/nms-patches/net/minecraft/commands/arguments/ArgumentEntity.patch @@ -15,5 +15,5 @@ - EntitySelector entityselector = argumentparserselector.parse(); + EntitySelector entityselector = argumentparserselector.parse(overridePermissions); // CraftBukkit - if (entityselector.a() > 1 && this.single) { + if (entityselector.getMaxResults() > 1 && this.single) { if (this.playersOnly) { diff --git a/paper-server/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch b/paper-server/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch index 3794599633..912accb289 100644 --- a/paper-server/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch +++ b/paper-server/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch @@ -10,7 +10,7 @@ private MinecraftKey id = new MinecraftKey(""); private BlockStateList<Block, IBlockData> definition; @@ -237,7 +237,7 @@ - Iterator iterator = iblockstate.getValues().iterator(); + Iterator iterator = iblockstate.getPossibleValues().iterator(); while (iterator.hasNext()) { - T t0 = (Comparable) iterator.next(); @@ -19,20 +19,20 @@ if (t0 instanceof Integer) { suggestionsbuilder.suggest((Integer) t0); @@ -506,7 +506,7 @@ - Optional<T> optional = iblockstate.b(s); + Optional<T> optional = iblockstate.getValue(s); if (optional.isPresent()) { -- this.state = (IBlockData) this.state.set(iblockstate, (Comparable) optional.get()); -+ this.state = (IBlockData) this.state.set(iblockstate, (T) optional.get()); // CraftBukkit - decompile error +- this.state = (IBlockData) this.state.setValue(iblockstate, (Comparable) optional.get()); ++ this.state = (IBlockData) this.state.setValue(iblockstate, (T) optional.get()); // CraftBukkit - decompile error this.properties.put(iblockstate, (Comparable) optional.get()); } else { this.reader.setCursor(i); @@ -540,7 +540,7 @@ - private static <T extends Comparable<T>> void a(StringBuilder stringbuilder, IBlockState<T> iblockstate, Comparable<?> comparable) { + private static <T extends Comparable<T>> void appendProperty(StringBuilder stringbuilder, IBlockState<T> iblockstate, Comparable<?> comparable) { stringbuilder.append(iblockstate.getName()); stringbuilder.append('='); -- stringbuilder.append(iblockstate.a(comparable)); -+ stringbuilder.append(iblockstate.a((T) comparable)); // CraftBukkit - decompile error +- stringbuilder.append(iblockstate.getName(comparable)); ++ stringbuilder.append(iblockstate.getName((T) comparable)); // CraftBukkit - decompile error } - public CompletableFuture<Suggestions> a(SuggestionsBuilder suggestionsbuilder, Tags<Block> tags) { + public CompletableFuture<Suggestions> fillSuggestions(SuggestionsBuilder suggestionsbuilder, Tags<Block> tags) { diff --git a/paper-server/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch b/paper-server/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch index 03f13fe98e..dbf2bf99ad 100644 --- a/paper-server/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch +++ b/paper-server/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java +++ b/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java @@ -149,7 +149,7 @@ - axisalignedbb = this.a(this.deltaX == null ? 0.0D : this.deltaX, this.deltaY == null ? 0.0D : this.deltaY, this.deltaZ == null ? 0.0D : this.deltaZ); + 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; @@ -19,7 +19,7 @@ + protected void parseSelector(boolean overridePermissions) throws CommandSyntaxException { + this.usesSelectors = !overridePermissions; + // CraftBukkit end - this.suggestions = this::d; + this.suggestions = this::suggestSelector; if (!this.reader.canRead()) { throw ArgumentParserSelector.ERROR_MISSING_SELECTOR_TYPE.createWithContext(this.reader); @@ -465,6 +467,12 @@ @@ -33,7 +33,7 @@ + public EntitySelector parse(boolean overridePermissions) throws CommandSyntaxException { + // CraftBukkit end this.startPosition = this.reader.getCursor(); - this.suggestions = this::b; + this.suggestions = this::suggestNameOrSelector; if (this.reader.canRead() && this.reader.peek() == '@') { @@ -473,7 +481,7 @@ } @@ -42,5 +42,5 @@ - this.parseSelector(); + this.parseSelector(overridePermissions); // CraftBukkit } else { - this.c(); + this.parseNameOrUUID(); } diff --git a/paper-server/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch b/paper-server/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch index 06ffb3ce2a..799c40542d 100644 --- a/paper-server/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch +++ b/paper-server/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch @@ -3,7 +3,7 @@ @@ -90,7 +90,7 @@ } - private void e(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException { + private void checkPermissions(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException { - if (this.usesSelector && !commandlistenerwrapper.hasPermission(2)) { + if (this.usesSelector && !commandlistenerwrapper.hasPermission(2, "minecraft.command.selector")) { // CraftBukkit throw ArgumentEntity.ERROR_SELECTORS_NOT_ALLOWED.create(); diff --git a/paper-server/nms-patches/net/minecraft/core/IRegistryCustom.patch b/paper-server/nms-patches/net/minecraft/core/IRegistryCustom.patch new file mode 100644 index 0000000000..db90c7ee9a --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/core/IRegistryCustom.patch @@ -0,0 +1,75 @@ +--- a/net/minecraft/core/IRegistryCustom.java ++++ b/net/minecraft/core/IRegistryCustom.java +@@ -80,7 +80,7 @@ + public <E> Optional<? extends IRegistry<E>> registry(ResourceKey<? extends IRegistry<? extends E>> resourcekey) { + Optional<? extends IRegistry<E>> optional = this.ownedRegistry(resourcekey); + +- return optional.isPresent() ? optional : IRegistry.REGISTRY.getOptional(resourcekey.location()); ++ return optional.isPresent() ? optional : (Optional<? extends IRegistry<E>>) IRegistry.REGISTRY.getOptional(resourcekey.location()); // CraftBukkit - decompile error + } + + public <E> IRegistry<E> registryOrThrow(ResourceKey<? extends IRegistry<? extends E>> resourcekey) { +@@ -138,7 +138,7 @@ + } + + private static <R extends IRegistry<?>> void copyBuiltin(IRegistryCustom.Dimension iregistrycustom_dimension, ResourceKey<R> resourcekey) { +- IRegistry<R> iregistry = RegistryGeneration.REGISTRY; ++ IRegistry<R> iregistry = (IRegistry<R>) RegistryGeneration.REGISTRY; // CraftBukkit - decompile error + IRegistry<?> iregistry1 = (IRegistry) iregistry.getOrThrow(resourcekey); + + copy(iregistrycustom_dimension, iregistry1); +@@ -178,8 +178,10 @@ + }); + } + +- public static final class RegistryData extends Record { ++ // CraftBukkit start ++ public static final record RegistryData<E>(ResourceKey<? extends IRegistry<E>> key, Codec<E> codec, @Nullable Codec<E> networkCodec) { + ++ /* + private final ResourceKey<? extends IRegistry<E>> key; + private final Codec<E> codec; + @Nullable +@@ -190,11 +192,15 @@ + this.codec = codec; + this.networkCodec = codec1; + } ++ */ ++ // CraftBukkit end + + public boolean sendToClient() { + return this.networkCodec != null; + } + ++ // CraftBukkit start ++ /* + public final String toString() { + return this.toString < invokedynamic > (this); + } +@@ -219,6 +225,8 @@ + public Codec<E> networkCodec() { + return this.networkCodec; + } ++ */ ++ // CraftBukkit end + } + + public static final class Dimension extends IRegistryCustom { +@@ -267,7 +275,7 @@ + } + + private static <E> RegistryMaterials<?> parseRegistry(ResourceKey<? extends IRegistry<?>> resourcekey, Dynamic<?> dynamic) { +- DataResult dataresult = RegistryLookupCodec.create(resourcekey).codec().parse(dynamic); ++ DataResult<?> dataresult = RegistryLookupCodec.create((ResourceKey) resourcekey).codec().parse(dynamic); // CraftBukkit - decompile error + String s = resourcekey + " registry: "; + Logger logger = IRegistryCustom.LOGGER; + +@@ -282,7 +290,7 @@ + } + + private static <E> RegistryMaterials<?> createRegistry(ResourceKey<? extends IRegistry<?>> resourcekey) { +- return new RegistryMaterials<>(resourcekey, Lifecycle.stable()); ++ return new RegistryMaterials(resourcekey, Lifecycle.stable()); // CraftBukkit - decompile error + } + + @Override diff --git a/paper-server/nms-patches/net/minecraft/core/RegistryMaterials.patch b/paper-server/nms-patches/net/minecraft/core/RegistryMaterials.patch new file mode 100644 index 0000000000..5f2ff3f7fe --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/core/RegistryMaterials.patch @@ -0,0 +1,40 @@ +--- a/net/minecraft/core/RegistryMaterials.java ++++ b/net/minecraft/core/RegistryMaterials.java +@@ -201,7 +201,7 @@ + }); + } + +- return SystemUtils.getRandom(this.randomCache, random); ++ return (T) SystemUtils.getRandom(this.randomCache, random); // CraftBukkit - decompile error + } + + @Override +@@ -228,7 +228,7 @@ + return registrymaterials; + }, (registrymaterials) -> { + Builder<RegistryMaterials.a<T>> builder = ImmutableList.builder(); +- Iterator iterator = registrymaterials.iterator(); ++ Iterator<T> iterator = registrymaterials.iterator(); // CraftBukkit - decompile error + + while (iterator.hasNext()) { + T t0 = iterator.next(); +@@ -257,8 +257,10 @@ + }); + } + +- private static final class a extends Record { ++ // CraftBukkit start ++ private static final record a<T>(ResourceKey<T> key, int id, T value) { + ++ /* + private final ResourceKey<T> key; + private final int id; + private final T value; +@@ -292,5 +294,7 @@ + public T value() { + return this.value; + } ++ */ ++ // CraftBukkit end + } + } diff --git a/paper-server/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch b/paper-server/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch index ef9a83a088..a3c1c3c0f1 100644 --- a/paper-server/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch +++ b/paper-server/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/core/cauldron/CauldronInteraction.java +++ b/net/minecraft/core/cauldron/CauldronInteraction.java -@@ -30,6 +30,10 @@ - import net.minecraft.world.level.block.state.properties.IBlockState; +@@ -29,6 +29,10 @@ + import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.gameevent.GameEvent; +// CraftBukkit start @@ -10,151 +10,151 @@ + public interface CauldronInteraction { - Map<Item, CauldronInteraction> EMPTY = a(); -@@ -52,6 +56,11 @@ + Map<Item, CauldronInteraction> EMPTY = newInteractionMap(); +@@ -51,6 +55,11 @@ return EnumInteractionResult.PASS; } else { if (!world.isClientSide) { + // CraftBukkit start -+ if (!LayeredCauldronBlock.decreaseLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.SHULKER_WASH)) { ++ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.SHULKER_WASH)) { + return EnumInteractionResult.SUCCESS; + } + // CraftBukkit end ItemStack itemstack1 = new ItemStack(Blocks.SHULKER_BOX); if (itemstack.hasTag()) { -@@ -60,7 +69,7 @@ +@@ -59,7 +68,7 @@ - entityhuman.a(enumhand, itemstack1); - entityhuman.a(StatisticList.CLEAN_SHULKER_BOX); -- LayeredCauldronBlock.e(iblockdata, world, blockposition); -+ // LayeredCauldronBlock.e(iblockdata, world, blockposition); // CraftBukkit + entityhuman.setItemInHand(enumhand, itemstack1); + entityhuman.awardStat(StatisticList.CLEAN_SHULKER_BOX); +- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); ++ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit } - return EnumInteractionResult.a(world.isClientSide); -@@ -71,6 +80,11 @@ + return EnumInteractionResult.sidedSuccess(world.isClientSide); +@@ -70,6 +79,11 @@ return EnumInteractionResult.PASS; } else { if (!world.isClientSide) { + // CraftBukkit start -+ if (!LayeredCauldronBlock.decreaseLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) { ++ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) { + return EnumInteractionResult.SUCCESS; + } + // CraftBukkit end - ItemStack itemstack1 = itemstack.cloneItemStack(); + ItemStack itemstack1 = itemstack.copy(); itemstack1.setCount(1); -@@ -88,7 +102,7 @@ +@@ -87,7 +101,7 @@ } - entityhuman.a(StatisticList.CLEAN_BANNER); -- LayeredCauldronBlock.e(iblockdata, world, blockposition); -+ // LayeredCauldronBlock.e(iblockdata, world, blockposition); // CraftBukkit + entityhuman.awardStat(StatisticList.CLEAN_BANNER); +- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); ++ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit } - return EnumInteractionResult.a(world.isClientSide); -@@ -106,9 +120,14 @@ + return EnumInteractionResult.sidedSuccess(world.isClientSide); +@@ -105,9 +119,14 @@ return EnumInteractionResult.PASS; } else { if (!world.isClientSide) { + // CraftBukkit start -+ if (!LayeredCauldronBlock.decreaseLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) { ++ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) { + return EnumInteractionResult.SUCCESS; + } + // CraftBukkit end - idyeable.e_(itemstack); - entityhuman.a(StatisticList.CLEAN_ARMOR); -- LayeredCauldronBlock.e(iblockdata, world, blockposition); -+ // LayeredCauldronBlock.e(iblockdata, world, blockposition); // CraftBukkit + idyeable.clearColor(itemstack); + entityhuman.awardStat(StatisticList.CLEAN_ARMOR); +- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); ++ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit } - return EnumInteractionResult.a(world.isClientSide); -@@ -117,7 +136,7 @@ + return EnumInteractionResult.sidedSuccess(world.isClientSide); +@@ -116,7 +135,7 @@ }; - static Object2ObjectOpenHashMap<Item, CauldronInteraction> a() { -- return (Object2ObjectOpenHashMap) SystemUtils.a((Object) (new Object2ObjectOpenHashMap()), (object2objectopenhashmap) -> { -+ return SystemUtils.a((new Object2ObjectOpenHashMap<>()), (object2objectopenhashmap) -> { // CraftBukkit - decompile error + static Object2ObjectOpenHashMap<Item, CauldronInteraction> newInteractionMap() { +- return (Object2ObjectOpenHashMap) SystemUtils.make(new Object2ObjectOpenHashMap(), (object2objectopenhashmap) -> { ++ return SystemUtils.make(new Object2ObjectOpenHashMap<>(), (object2objectopenhashmap) -> { // CraftBukkit - decompile error object2objectopenhashmap.defaultReturnValue((iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { return EnumInteractionResult.PASS; }); -@@ -133,12 +152,17 @@ +@@ -132,12 +151,17 @@ return EnumInteractionResult.PASS; } else { if (!world.isClientSide) { + // CraftBukkit start -+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.WATER_CAULDRON.getBlockData(), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) { ++ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.WATER_CAULDRON.defaultBlockState(), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) { + return EnumInteractionResult.SUCCESS; + } + // CraftBukkit end Item item = itemstack.getItem(); - entityhuman.a(enumhand, ItemLiquidUtil.a(itemstack, entityhuman, new ItemStack(Items.GLASS_BOTTLE))); - entityhuman.a(StatisticList.USE_CAULDRON); - entityhuman.b(StatisticList.ITEM_USED.b(item)); -- world.setTypeUpdate(blockposition, Blocks.WATER_CAULDRON.getBlockData()); -+ // world.setTypeUpdate(blockposition, Blocks.WATER_CAULDRON.getBlockData()); // CraftBukkit + entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, new ItemStack(Items.GLASS_BOTTLE))); + entityhuman.awardStat(StatisticList.USE_CAULDRON); + 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.a((Entity) null, GameEvent.FLUID_PLACE, blockposition); + world.gameEvent((Entity) null, GameEvent.FLUID_PLACE, blockposition); } -@@ -154,12 +178,17 @@ +@@ -153,12 +177,17 @@ }); CauldronInteraction.WATER.put(Items.GLASS_BOTTLE, (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { if (!world.isClientSide) { + // CraftBukkit start -+ if (!LayeredCauldronBlock.decreaseLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL)) { ++ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL)) { + return EnumInteractionResult.SUCCESS; + } + // CraftBukkit end Item item = itemstack.getItem(); - entityhuman.a(enumhand, ItemLiquidUtil.a(itemstack, entityhuman, PotionUtil.a(new ItemStack(Items.POTION), Potions.WATER))); - entityhuman.a(StatisticList.USE_CAULDRON); - entityhuman.b(StatisticList.ITEM_USED.b(item)); -- LayeredCauldronBlock.e(iblockdata, world, blockposition); -+ // LayeredCauldronBlock.e(iblockdata, world, blockposition); // CraftBukkit + entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, PotionUtil.setPotion(new ItemStack(Items.POTION), Potions.WATER))); + entityhuman.awardStat(StatisticList.USE_CAULDRON); + 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.a((Entity) null, GameEvent.FLUID_PICKUP, blockposition); + world.gameEvent((Entity) null, GameEvent.FLUID_PICKUP, blockposition); } -@@ -169,10 +198,15 @@ +@@ -168,10 +197,15 @@ CauldronInteraction.WATER.put(Items.POTION, (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { - if ((Integer) iblockdata.get(LayeredCauldronBlock.LEVEL) != 3 && PotionUtil.d(itemstack) == Potions.WATER) { + if ((Integer) iblockdata.getValue(LayeredCauldronBlock.LEVEL) != 3 && PotionUtil.getPotion(itemstack) == Potions.WATER) { if (!world.isClientSide) { + // CraftBukkit start -+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata.a(LayeredCauldronBlock.LEVEL), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) { ++ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata.cycle(LayeredCauldronBlock.LEVEL), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) { + return EnumInteractionResult.SUCCESS; + } + // CraftBukkit end - entityhuman.a(enumhand, ItemLiquidUtil.a(itemstack, entityhuman, new ItemStack(Items.GLASS_BOTTLE))); - entityhuman.a(StatisticList.USE_CAULDRON); - entityhuman.b(StatisticList.ITEM_USED.b(itemstack.getItem())); -- world.setTypeUpdate(blockposition, (IBlockData) iblockdata.a((IBlockState) LayeredCauldronBlock.LEVEL)); -+ // world.setTypeUpdate(blockposition, (IBlockData) iblockdata.a((IBlockState) LayeredCauldronBlock.LEVEL)); // CraftBukkit + entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, new ItemStack(Items.GLASS_BOTTLE))); + entityhuman.awardStat(StatisticList.USE_CAULDRON); + 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.a((Entity) null, GameEvent.FLUID_PLACE, blockposition); + world.gameEvent((Entity) null, GameEvent.FLUID_PLACE, blockposition); } -@@ -244,12 +278,17 @@ +@@ -243,12 +277,17 @@ return EnumInteractionResult.PASS; } else { if (!world.isClientSide) { + // CraftBukkit start -+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.CAULDRON.getBlockData(), entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) { ++ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.CAULDRON.defaultBlockState(), entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) { + return EnumInteractionResult.SUCCESS; + } + // CraftBukkit end Item item = itemstack.getItem(); - entityhuman.a(enumhand, ItemLiquidUtil.a(itemstack, entityhuman, itemstack1)); - entityhuman.a(StatisticList.USE_CAULDRON); - entityhuman.b(StatisticList.ITEM_USED.b(item)); -- world.setTypeUpdate(blockposition, Blocks.CAULDRON.getBlockData()); -+ // world.setTypeUpdate(blockposition, Blocks.CAULDRON.getBlockData()); // CraftBukkit + entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1)); + entityhuman.awardStat(StatisticList.USE_CAULDRON); + 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.a((Entity) null, GameEvent.FLUID_PICKUP, blockposition); + world.gameEvent((Entity) null, GameEvent.FLUID_PICKUP, blockposition); } -@@ -260,12 +299,17 @@ +@@ -259,12 +298,17 @@ - static EnumInteractionResult a(World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, IBlockData iblockdata, SoundEffect soundeffect) { + static EnumInteractionResult emptyBucket(World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, IBlockData iblockdata, SoundEffect soundeffect) { if (!world.isClientSide) { + // CraftBukkit start + if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata, entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY)) { @@ -163,11 +163,11 @@ + // CraftBukkit end Item item = itemstack.getItem(); - entityhuman.a(enumhand, ItemLiquidUtil.a(itemstack, entityhuman, new ItemStack(Items.BUCKET))); - entityhuman.a(StatisticList.FILL_CAULDRON); - entityhuman.b(StatisticList.ITEM_USED.b(item)); -- world.setTypeUpdate(blockposition, iblockdata); -+ // world.setTypeUpdate(blockposition, iblockdata); // CraftBukkit + entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, new ItemStack(Items.BUCKET))); + entityhuman.awardStat(StatisticList.FILL_CAULDRON); + 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.a((Entity) null, GameEvent.FLUID_PLACE, blockposition); + world.gameEvent((Entity) null, GameEvent.FLUID_PLACE, blockposition); } diff --git a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch index 9803fc11b8..59913877f2 100644 --- a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch +++ b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch @@ -19,8 +19,8 @@ - EntityBoat entityboat = new EntityBoat(worldserver, d0, d1 + d3, d2); + // EntityBoat entityboat = new EntityBoat(worldserver, d0, d1 + d3, d2); + // CraftBukkit start -+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ ItemStack itemstack1 = itemstack.split(1); ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1 + d3, d2)); @@ -29,12 +29,12 @@ + } + + if (event.isCancelled()) { -+ itemstack.add(1); ++ itemstack.grow(1); + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.add(1); ++ itemstack.grow(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); @@ -48,11 +48,11 @@ + // CraftBukkit end entityboat.setType(this.type); - entityboat.setYRot(enumdirection.o()); -- worldserver.addEntity(entityboat); -- itemstack.subtract(1); -+ if (!worldserver.addEntity(entityboat)) itemstack.add(1); // CraftBukkit -+ // itemstack.subtract(1); // CraftBukkit - handled during event processing + entityboat.setYRot(enumdirection.toYRot()); +- worldserver.addFreshEntity(entityboat); +- itemstack.shrink(1); ++ if (!worldserver.addFreshEntity(entityboat)) itemstack.grow(1); // CraftBukkit ++ // itemstack.shrink(1); // CraftBukkit - handled during event processing return itemstack; } diff --git a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorItem.patch b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorItem.patch index e71a36c402..07547d3059 100644 --- a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorItem.patch +++ b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorItem.patch @@ -14,37 +14,37 @@ public DispenseBehaviorItem() {} @@ -26,11 +32,19 @@ - IPosition iposition = BlockDispenser.a(isourceblock); - ItemStack itemstack1 = itemstack.cloneAndSubtract(1); + IPosition iposition = BlockDispenser.getDispensePosition(isourceblock); + ItemStack itemstack1 = itemstack.split(1); -- a(isourceblock.getWorld(), itemstack1, 6, enumdirection, iposition); +- spawnItem(isourceblock.getLevel(), itemstack1, 6, enumdirection, iposition); + // CraftBukkit start -+ if (!a(isourceblock.getWorld(), itemstack1, 6, enumdirection, isourceblock)) { -+ itemstack.add(1); ++ if (!spawnItem(isourceblock.getLevel(), itemstack1, 6, enumdirection, isourceblock)) { ++ itemstack.grow(1); + } + // CraftBukkit end return itemstack; } -- public static void a(World world, ItemStack itemstack, int i, EnumDirection enumdirection, IPosition iposition) { +- public static void spawnItem(World world, ItemStack itemstack, int i, EnumDirection enumdirection, IPosition iposition) { + // CraftBukkit start - void -> boolean return, IPosition -> ISourceBlock last argument -+ public static boolean a(World world, ItemStack itemstack, int i, EnumDirection enumdirection, ISourceBlock isourceblock) { ++ public static boolean spawnItem(World world, ItemStack itemstack, int i, EnumDirection enumdirection, ISourceBlock isourceblock) { + if (itemstack.isEmpty()) return true; -+ IPosition iposition = BlockDispenser.a(isourceblock); ++ IPosition iposition = BlockDispenser.getDispensePosition(isourceblock); + // CraftBukkit end - double d0 = iposition.getX(); - double d1 = iposition.getY(); - double d2 = iposition.getZ(); + double d0 = iposition.x(); + double d1 = iposition.y(); + double d2 = iposition.z(); @@ -45,7 +59,39 @@ double d3 = world.random.nextDouble() * 0.1D + 0.2D; - entityitem.setMot(world.random.nextGaussian() * 0.007499999832361937D * (double) i + (double) enumdirection.getAdjacentX() * d3, world.random.nextGaussian() * 0.007499999832361937D * (double) i + 0.20000000298023224D, world.random.nextGaussian() * 0.007499999832361937D * (double) i + (double) enumdirection.getAdjacentZ() * d3); + entityitem.setDeltaMovement(world.random.nextGaussian() * 0.007499999832361937D * (double) i + (double) enumdirection.getStepX() * d3, world.random.nextGaussian() * 0.007499999832361937D * (double) i + 0.20000000298023224D, world.random.nextGaussian() * 0.007499999832361937D * (double) i + (double) enumdirection.getStepZ() * d3); + + // CraftBukkit start -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + -+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), CraftVector.toBukkit(entityitem.getMot())); ++ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), CraftVector.toBukkit(entityitem.getDeltaMovement())); + if (!BlockDispenser.eventFired) { + world.getCraftServer().getPluginManager().callEvent(event); + } @@ -53,8 +53,8 @@ + return false; + } + -+ entityitem.setItemStack(CraftItemStack.asNMSCopy(event.getItem())); -+ entityitem.setMot(CraftVector.toNMS(event.getVelocity())); ++ entityitem.setItem(CraftItemStack.asNMSCopy(event.getItem())); ++ entityitem.setDeltaMovement(CraftVector.toNMS(event.getVelocity())); + + if (!event.getItem().getType().equals(craftItem.getType())) { + // Chain to handler for new item @@ -63,15 +63,15 @@ + if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior.getClass() != DispenseBehaviorItem.class) { + idispensebehavior.dispense(isourceblock, eventStack); + } else { -+ world.addEntity(entityitem); ++ world.addFreshEntity(entityitem); + } + return false; + } + - world.addEntity(entityitem); + world.addFreshEntity(entityitem); + + return true; + // CraftBukkit end } - protected void a(ISourceBlock isourceblock) { + protected void playSound(ISourceBlock isourceblock) { diff --git a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorProjectile.patch b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorProjectile.patch index 8658bd8498..80c1d7c290 100644 --- a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorProjectile.patch +++ b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorProjectile.patch @@ -15,28 +15,28 @@ public DispenseBehaviorProjectile() {} @@ -20,9 +27,38 @@ - EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); - IProjectile iprojectile = this.a((World) worldserver, iposition, itemstack); + EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING); + IProjectile iprojectile = this.getProjectile(worldserver, iposition, itemstack); -- iprojectile.shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), this.getPower(), this.a()); -+ // iprojectile.shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), this.getPower(), this.a()); +- iprojectile.shoot((double) enumdirection.getStepX(), (double) ((float) enumdirection.getStepY() + 0.1F), (double) enumdirection.getStepZ(), this.getPower(), this.getUncertainty()); + // CraftBukkit start -+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ // iprojectile.shoot((double) enumdirection.getStepX(), (double) ((float) enumdirection.getStepY() + 0.1F), (double) enumdirection.getStepZ(), this.getPower(), this.getUncertainty()); ++ ItemStack itemstack1 = itemstack.split(1); ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + -+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ())); ++ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumdirection.getStepX(), (double) ((float) enumdirection.getStepY() + 0.1F), (double) enumdirection.getStepZ())); + if (!BlockDispenser.eventFired) { + worldserver.getCraftServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { -+ itemstack.add(1); ++ itemstack.grow(1); + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.add(1); ++ itemstack.grow(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); @@ -46,12 +46,12 @@ + } + } + -+ iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.getPower(), this.a()); -+ ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity()); ++ iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.getPower(), this.getUncertainty()); ++ ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getEntity()); + // CraftBukkit end - worldserver.addEntity(iprojectile); -- itemstack.subtract(1); -+ // itemstack.subtract(1); // CraftBukkit - Handled during event processing + worldserver.addFreshEntity(iprojectile); +- itemstack.shrink(1); ++ // itemstack.shrink(1); // CraftBukkit - Handled during event processing return itemstack; } diff --git a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch index 953a248c70..26181a9bf2 100644 --- a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch +++ b/paper-server/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 -@@ -25,6 +25,12 @@ +@@ -24,6 +24,12 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AxisAlignedBB; @@ -13,12 +13,12 @@ public class DispenseBehaviorShears extends DispenseBehaviorMaybe { public DispenseBehaviorShears() {} -@@ -32,11 +38,34 @@ +@@ -31,11 +37,34 @@ @Override - protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - WorldServer worldserver = isourceblock.getWorld(); + protected ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) { + WorldServer worldserver = isourceblock.getLevel(); + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + + BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -42,31 +42,31 @@ + // CraftBukkit end if (!worldserver.isClientSide()) { - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); + BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING)); -- this.a(a((WorldServer) worldserver, blockposition) || b((WorldServer) worldserver, blockposition)); -+ this.a(a((WorldServer) worldserver, blockposition) || b((WorldServer) worldserver, blockposition, bukkitBlock, craftItem)); // CraftBukkit - if (this.a() && itemstack.isDamaged(1, worldserver.getRandom(), (EntityPlayer) null)) { +- this.setSuccess(tryShearBeehive((WorldServer) worldserver, blockposition) || tryShearLivingEntity((WorldServer) worldserver, blockposition)); ++ this.setSuccess(tryShearBeehive((WorldServer) worldserver, blockposition) || tryShearLivingEntity((WorldServer) worldserver, blockposition, bukkitBlock, craftItem)); // CraftBukkit + if (this.isSuccess() && itemstack.hurt(1, worldserver.getRandom(), (EntityPlayer) null)) { itemstack.setCount(0); } -@@ -63,7 +92,7 @@ +@@ -62,7 +91,7 @@ return false; } -- private static boolean b(WorldServer worldserver, BlockPosition blockposition) { -+ private static boolean b(WorldServer worldserver, BlockPosition blockposition, org.bukkit.block.Block bukkitBlock, CraftItemStack craftItem) { // CraftBukkit - add args - List<EntityLiving> list = worldserver.a(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.NO_SPECTATORS); +- private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition) { ++ private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition, org.bukkit.block.Block bukkitBlock, CraftItemStack craftItem) { // CraftBukkit - add args + List<EntityLiving> list = worldserver.getEntitiesOfClass(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.NO_SPECTATORS); Iterator iterator = list.iterator(); -@@ -74,6 +103,11 @@ +@@ -73,6 +102,11 @@ IShearable ishearable = (IShearable) entityliving; - if (ishearable.canShear()) { + if (ishearable.readyForShearing()) { + // CraftBukkit start + if (CraftEventFactory.callBlockShearEntityEvent(entityliving, bukkitBlock, craftItem).isCancelled()) { + continue; + } + // CraftBukkit end ishearable.shear(SoundCategory.BLOCKS); - worldserver.a((Entity) null, GameEvent.SHEAR, blockposition); + worldserver.gameEvent((Entity) null, GameEvent.SHEAR, blockposition); return true; diff --git a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.patch b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.patch index 649fc14eed..ae3b9e0eeb 100644 --- a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.patch +++ b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.java +++ b/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.java -@@ -12,6 +12,11 @@ +@@ -11,6 +11,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -12,17 +12,17 @@ public class DispenseBehaviorShulkerBox extends DispenseBehaviorMaybe { private static final Logger LOGGER = LogManager.getLogger(); -@@ -28,6 +33,30 @@ - BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); - EnumDirection enumdirection1 = isourceblock.getWorld().isEmpty(blockposition.down()) ? enumdirection : EnumDirection.UP; +@@ -27,6 +32,30 @@ + BlockPosition blockposition = isourceblock.getPos().relative(enumdirection); + EnumDirection enumdirection1 = isourceblock.getLevel().isEmptyBlock(blockposition.below()) ? enumdirection : EnumDirection.UP; + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = isourceblock.getWorld().getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block bukkitBlock = isourceblock.getLevel().getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + 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) { -+ isourceblock.getWorld().getCraftServer().getPluginManager().callEvent(event); ++ isourceblock.getLevel().getCraftServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -41,5 +41,5 @@ + // CraftBukkit end + try { - this.a(((ItemBlock) item).a((BlockActionContext) (new BlockActionContextDirectional(isourceblock.getWorld(), blockposition, enumdirection, itemstack, enumdirection1))).a()); + this.setSuccess(((ItemBlock) item).place(new BlockActionContextDirectional(isourceblock.getLevel(), blockposition, enumdirection, itemstack, enumdirection1)).consumesAction()); } catch (Exception exception) { diff --git a/paper-server/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch b/paper-server/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch index 7ee234dd7a..2c7b9c0a21 100644 --- a/paper-server/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch +++ b/paper-server/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 -@@ -79,6 +79,21 @@ +@@ -76,6 +76,21 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -22,59 +22,14 @@ public interface IDispenseBehavior { Logger LOGGER = LogManager.getLogger(); -@@ -120,7 +135,7 @@ - BlockDispenser.a((IMaterial) Items.EGG, (IDispenseBehavior) (new DispenseBehaviorProjectile() { - @Override - protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) { -- return (IProjectile) SystemUtils.a((Object) (new EntityEgg(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entityegg) -> { -+ return (IProjectile) SystemUtils.a((new EntityEgg(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entityegg) -> { // CraftBukkit - decompile error - entityegg.setItem(itemstack); - }); - } -@@ -128,7 +143,7 @@ - BlockDispenser.a((IMaterial) Items.SNOWBALL, (IDispenseBehavior) (new DispenseBehaviorProjectile() { - @Override - protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) { -- return (IProjectile) SystemUtils.a((Object) (new EntitySnowball(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitysnowball) -> { -+ return (IProjectile) SystemUtils.a((new EntitySnowball(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitysnowball) -> { // CraftBukkit - decompile error - entitysnowball.setItem(itemstack); - }); - } -@@ -136,7 +151,7 @@ - BlockDispenser.a((IMaterial) Items.EXPERIENCE_BOTTLE, (IDispenseBehavior) (new DispenseBehaviorProjectile() { - @Override - protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) { -- return (IProjectile) SystemUtils.a((Object) (new EntityThrownExpBottle(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitythrownexpbottle) -> { -+ return (IProjectile) SystemUtils.a((new EntityThrownExpBottle(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitythrownexpbottle) -> { // CraftBukkit - decompile error - entitythrownexpbottle.setItem(itemstack); - }); - } -@@ -157,7 +172,7 @@ - return (new DispenseBehaviorProjectile() { - @Override - protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) { -- return (IProjectile) SystemUtils.a((Object) (new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitypotion) -> { -+ return (IProjectile) SystemUtils.a((new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitypotion) -> { // CraftBukkit - decompile error - entitypotion.setItem(itemstack1); - }); - } -@@ -180,7 +195,7 @@ - return (new DispenseBehaviorProjectile() { - @Override - protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) { -- return (IProjectile) SystemUtils.a((Object) (new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitypotion) -> { -+ return (IProjectile) SystemUtils.a((new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitypotion) -> { // CraftBukkit - decompile error - entitypotion.setItem(itemstack1); - }); - } -@@ -203,14 +218,42 @@ - EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); - EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).a(itemstack.getTag()); +@@ -200,14 +215,42 @@ + EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING); + EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(itemstack.getTag()); + // CraftBukkit start -+ WorldServer worldserver = isourceblock.getWorld(); -+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ WorldServer worldserver = isourceblock.getLevel(); ++ ItemStack itemstack1 = itemstack.split(1); ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -83,12 +38,12 @@ + } + + if (event.isCancelled()) { -+ itemstack.add(1); ++ itemstack.grow(1); + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.add(1); ++ itemstack.grow(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); @@ -99,27 +54,27 @@ + } + try { - entitytypes.spawnCreature(isourceblock.getWorld(), itemstack, (EntityHuman) null, isourceblock.getBlockPosition().shift(enumdirection), EnumMobSpawn.DISPENSER, enumdirection != EnumDirection.UP, false); + entitytypes.spawn(isourceblock.getLevel(), itemstack, (EntityHuman) null, isourceblock.getPos().relative(enumdirection), EnumMobSpawn.DISPENSER, enumdirection != EnumDirection.UP, false); } catch (Exception exception) { -- null.LOGGER.error("Error while dispensing spawn egg from dispenser at {}", isourceblock.getBlockPosition(), exception); -+ LOGGER.error("Error while dispensing spawn egg from dispenser at {}", isourceblock.getBlockPosition(), exception); // CraftBukkit - decompile error +- null.LOGGER.error("Error while dispensing spawn egg from dispenser at {}", isourceblock.getPos(), exception); ++ LOGGER.error("Error while dispensing spawn egg from dispenser at {}", isourceblock.getPos(), exception); // CraftBukkit - decompile error return ItemStack.EMPTY; } -- itemstack.subtract(1); -+ // itemstack.subtract(1); // Handled during event processing +- itemstack.shrink(1); ++ // itemstack.shrink(1); // Handled during event processing + // CraftBukkit end - isourceblock.getWorld().a(GameEvent.ENTITY_PLACE, isourceblock.getBlockPosition()); + isourceblock.getLevel().gameEvent(GameEvent.ENTITY_PLACE, isourceblock.getPos()); return itemstack; } -@@ -229,12 +272,40 @@ - EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); - BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); - WorldServer worldserver = isourceblock.getWorld(); +@@ -226,12 +269,40 @@ + EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING); + BlockPosition blockposition = isourceblock.getPos().relative(enumdirection); + WorldServer worldserver = isourceblock.getLevel(); + + // CraftBukkit start -+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ ItemStack itemstack1 = itemstack.split(1); ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -128,12 +83,12 @@ + } + + if (event.isCancelled()) { -+ itemstack.add(1); ++ itemstack.grow(1); + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.add(1); ++ itemstack.grow(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); @@ -146,22 +101,22 @@ + EntityArmorStand entityarmorstand = new EntityArmorStand(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D); - EntityTypes.a((World) worldserver, (EntityHuman) null, (Entity) entityarmorstand, itemstack.getTag()); - entityarmorstand.setYRot(enumdirection.o()); - worldserver.addEntity(entityarmorstand); -- itemstack.subtract(1); -+ // itemstack.subtract(1); // CraftBukkit - Handled during event processing + EntityTypes.updateCustomEntityTag(worldserver, (EntityHuman) null, entityarmorstand, itemstack.getTag()); + entityarmorstand.setYRot(enumdirection.toYRot()); + worldserver.addFreshEntity(entityarmorstand); +- itemstack.shrink(1); ++ // itemstack.shrink(1); // CraftBukkit - Handled during event processing return itemstack; } - })); -@@ -253,8 +324,35 @@ + }); +@@ -250,8 +321,35 @@ }); if (!list.isEmpty()) { + // CraftBukkit start -+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ World world = isourceblock.getWorld(); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ ItemStack itemstack1 = itemstack.split(1); ++ World world = isourceblock.getLevel(); ++ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) list.get(0).getBukkitEntity()); @@ -170,12 +125,12 @@ + } + + if (event.isCancelled()) { -+ itemstack.add(1); ++ itemstack.grow(1); + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.add(1); ++ itemstack.grow(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); @@ -185,21 +140,21 @@ + } + } + // CraftBukkit end - ((ISaddleable) list.get(0)).saddle(SoundCategory.BLOCKS); -- itemstack.subtract(1); -+ // itemstack.subtract(1); // CraftBukkit - handled above - this.a(true); + ((ISaddleable) list.get(0)).equipSaddle(SoundCategory.BLOCKS); +- itemstack.shrink(1); ++ // itemstack.shrink(1); // CraftBukkit - handled above + this.setSuccess(true); return itemstack; } else { -@@ -281,7 +379,35 @@ +@@ -278,7 +376,35 @@ entityhorseabstract = (EntityHorseAbstract) iterator1.next(); - } while (!entityhorseabstract.m(itemstack) || entityhorseabstract.gd() || !entityhorseabstract.isTamed()); + } while (!entityhorseabstract.isArmor(itemstack) || entityhorseabstract.isWearingArmor() || !entityhorseabstract.isTamed()); -- entityhorseabstract.k(401).a(itemstack.cloneAndSubtract(1)); +- entityhorseabstract.getSlot(401).set(itemstack.split(1)); + // CraftBukkit start -+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ World world = isourceblock.getWorld(); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ ItemStack itemstack1 = itemstack.split(1); ++ World world = isourceblock.getLevel(); ++ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorseabstract.getBukkitEntity()); @@ -208,12 +163,12 @@ + } + + if (event.isCancelled()) { -+ itemstack.add(1); ++ itemstack.grow(1); + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.add(1); ++ itemstack.grow(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); @@ -223,21 +178,21 @@ + } + } + -+ entityhorseabstract.k(401).a(CraftItemStack.asNMSCopy(event.getItem())); ++ entityhorseabstract.getSlot(401).set(CraftItemStack.asNMSCopy(event.getItem())); + // CraftBukkit end - this.a(true); + this.setSuccess(true); return itemstack; } -@@ -324,9 +450,35 @@ +@@ -321,9 +447,35 @@ } entityhorsechestedabstract = (EntityHorseChestedAbstract) iterator1.next(); -- } while (!entityhorsechestedabstract.isTamed() || !entityhorsechestedabstract.k(499).a(itemstack)); +- } while (!entityhorsechestedabstract.isTamed() || !entityhorsechestedabstract.getSlot(499).set(itemstack)); + // CraftBukkit start + } while (!entityhorsechestedabstract.isTamed()); -+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ World world = isourceblock.getWorld(); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ ItemStack itemstack1 = itemstack.split(1); ++ World world = isourceblock.getLevel(); ++ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorsechestedabstract.getBukkitEntity()); @@ -245,7 +200,7 @@ + world.getCraftServer().getPluginManager().callEvent(event); + } -- itemstack.subtract(1); +- itemstack.shrink(1); + if (event.isCancelled()) { + return itemstack; + } @@ -259,35 +214,35 @@ + return itemstack; + } + } -+ entityhorsechestedabstract.k(499).a(CraftItemStack.asNMSCopy(event.getItem())); ++ entityhorsechestedabstract.getSlot(499).set(CraftItemStack.asNMSCopy(event.getItem())); + // CraftBukkit end + -+ // itemstack.subtract(1); // CraftBukkit - handled above - this.a(true); ++ // itemstack.shrink(1); // CraftBukkit - handled above + this.setSuccess(true); return itemstack; } -@@ -335,12 +487,41 @@ +@@ -332,12 +484,41 @@ @Override - public ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); + public ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) { + EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING); + // CraftBukkit start -+ WorldServer worldserver = isourceblock.getWorld(); -+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ WorldServer worldserver = isourceblock.getLevel(); ++ ItemStack itemstack1 = itemstack.split(1); ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + -+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(enumdirection.getAdjacentX(), enumdirection.getAdjacentY(), enumdirection.getAdjacentZ())); ++ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(enumdirection.getStepX(), enumdirection.getStepY(), enumdirection.getStepZ())); + if (!BlockDispenser.eventFired) { + worldserver.getCraftServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { -+ itemstack.add(1); ++ itemstack.grow(1); + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.add(1); ++ itemstack.grow(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); @@ -298,30 +253,30 @@ + } + + itemstack1 = CraftItemStack.asNMSCopy(event.getItem()); - EntityFireworks entityfireworks = new EntityFireworks(isourceblock.getWorld(), itemstack, isourceblock.getX(), isourceblock.getY(), isourceblock.getX(), true); + EntityFireworks entityfireworks = new EntityFireworks(isourceblock.getLevel(), itemstack, isourceblock.x(), isourceblock.y(), isourceblock.x(), true); - IDispenseBehavior.a(isourceblock, entityfireworks, enumdirection); - entityfireworks.shoot((double) enumdirection.getAdjacentX(), (double) enumdirection.getAdjacentY(), (double) enumdirection.getAdjacentZ(), 0.5F, 1.0F); - isourceblock.getWorld().addEntity(entityfireworks); -- itemstack.subtract(1); -+ // itemstack.subtract(1); // Handled during event processing + IDispenseBehavior.setEntityPokingOutOfBlock(isourceblock, entityfireworks, enumdirection); + entityfireworks.shoot((double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ(), 0.5F, 1.0F); + isourceblock.getLevel().addFreshEntity(entityfireworks); +- itemstack.shrink(1); ++ // itemstack.shrink(1); // Handled during event processing + // CraftBukkit end return itemstack; } -@@ -362,12 +543,40 @@ - double d3 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentX(); - double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY(); - double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ(); +@@ -359,12 +540,40 @@ + double d3 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepX(); + double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepY(); + double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepZ(); - EntitySmallFireball entitysmallfireball = new EntitySmallFireball(worldserver, d0, d1, d2, d3, d4, d5); -- worldserver.addEntity((Entity) SystemUtils.a((Object) entitysmallfireball, (entitysmallfireball1) -> { +- worldserver.addFreshEntity((Entity) SystemUtils.make(entitysmallfireball, (entitysmallfireball1) -> { - entitysmallfireball1.setItem(itemstack); - })); -- itemstack.subtract(1); +- itemstack.shrink(1); + // CraftBukkit start -+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ ItemStack itemstack1 = itemstack.split(1); ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d3, d4, d5)); @@ -330,12 +285,12 @@ + } + + if (event.isCancelled()) { -+ itemstack.add(1); ++ itemstack.grow(1); + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.add(1); ++ itemstack.grow(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); @@ -347,26 +302,26 @@ + + EntitySmallFireball entitysmallfireball = new EntitySmallFireball(worldserver, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); + entitysmallfireball.setItem(itemstack1); -+ entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity()); ++ entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getEntity()); + -+ worldserver.addEntity(entitysmallfireball); -+ // itemstack.subtract(1); // Handled during event processing ++ worldserver.addFreshEntity(entitysmallfireball); ++ // itemstack.shrink(1); // Handled during event processing + // CraftBukkit end return itemstack; } -@@ -391,9 +600,52 @@ - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); - WorldServer worldserver = isourceblock.getWorld(); +@@ -388,9 +597,52 @@ + BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING)); + WorldServer worldserver = isourceblock.getLevel(); + // CraftBukkit start + int x = blockposition.getX(); + int y = blockposition.getY(); + int z = blockposition.getZ(); -+ IBlockData iblockdata = worldserver.getType(blockposition); ++ IBlockData iblockdata = worldserver.getBlockState(blockposition); + Material material = iblockdata.getMaterial(); -+ if (worldserver.isEmpty(blockposition) || !material.isBuildable() || material.isReplaceable() || (dispensiblecontaineritem instanceof ItemBucket && iblockdata.getBlock() instanceof IFluidContainer && ((IFluidContainer) iblockdata.getBlock()).canPlace(worldserver, blockposition, iblockdata, ((ItemBucket) dispensiblecontaineritem).content))) { -+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ if (worldserver.isEmptyBlock(blockposition) || !material.isSolid() || material.isReplaceable() || (dispensiblecontaineritem instanceof ItemBucket && iblockdata.getBlock() instanceof IFluidContainer && ((IFluidContainer) iblockdata.getBlock()).canPlaceLiquid(worldserver, blockposition, iblockdata, ((ItemBucket) dispensiblecontaineritem).content))) { ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + + BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z)); @@ -392,38 +347,38 @@ + } + // CraftBukkit end + - if (dispensiblecontaineritem.a((EntityHuman) null, worldserver, blockposition, (MovingObjectPositionBlock) null)) { - dispensiblecontaineritem.a((EntityHuman) null, worldserver, itemstack, blockposition); + if (dispensiblecontaineritem.emptyContents((EntityHuman) null, worldserver, blockposition, (MovingObjectPositionBlock) null)) { + dispensiblecontaineritem.checkExtraContent((EntityHuman) null, worldserver, itemstack, blockposition); - return new ItemStack(Items.BUCKET); + // CraftBukkit start - Handle stacked buckets + Item item = Items.BUCKET; -+ itemstack.subtract(1); ++ itemstack.shrink(1); + if (itemstack.isEmpty()) { + itemstack.setItem(Items.BUCKET); + itemstack.setCount(1); -+ } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) { ++ } else if (((TileEntityDispenser) isourceblock.getEntity()).addItem(new ItemStack(item)) < 0) { + this.defaultDispenseItemBehavior.dispense(isourceblock, new ItemStack(item)); + } -+ // CraftBukkit end + return itemstack; ++ // CraftBukkit end } else { return this.defaultDispenseItemBehavior.dispense(isourceblock, itemstack); } -@@ -419,7 +671,7 @@ +@@ -416,7 +668,7 @@ Block block = iblockdata.getBlock(); if (block instanceof IFluidSource) { -- ItemStack itemstack1 = ((IFluidSource) block).removeFluid(worldserver, blockposition, iblockdata); -+ ItemStack itemstack1 = ((IFluidSource) block).removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit +- ItemStack itemstack1 = ((IFluidSource) block).pickupBlock(worldserver, blockposition, iblockdata); ++ ItemStack itemstack1 = ((IFluidSource) block).pickupBlock(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit if (itemstack1.isEmpty()) { - return super.a(isourceblock, itemstack); -@@ -427,6 +679,32 @@ - worldserver.a((Entity) null, GameEvent.FLUID_PICKUP, blockposition); + return super.execute(isourceblock, itemstack); +@@ -424,6 +676,32 @@ + worldserver.gameEvent((Entity) null, GameEvent.FLUID_PICKUP, blockposition); Item item = itemstack1.getItem(); + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + + BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); @@ -445,18 +400,18 @@ + } + } + -+ itemstack1 = ((IFluidSource) block).removeFluid(worldserver, blockposition, iblockdata); // From above ++ itemstack1 = ((IFluidSource) block).pickupBlock(worldserver, blockposition, iblockdata); // From above + // CraftBukkit end + - itemstack.subtract(1); + itemstack.shrink(1); if (itemstack.isEmpty()) { return new ItemStack(item); -@@ -448,14 +726,42 @@ - protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - WorldServer worldserver = isourceblock.getWorld(); +@@ -445,14 +723,42 @@ + protected ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) { + WorldServer worldserver = isourceblock.getLevel(); + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + + BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -479,29 +434,29 @@ + } + // CraftBukkit end + - this.a(true); - EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); - BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); - IBlockData iblockdata = worldserver.getType(blockposition); + this.setSuccess(true); + EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING); + BlockPosition blockposition = isourceblock.getPos().relative(enumdirection); + IBlockData iblockdata = worldserver.getBlockState(blockposition); - if (BlockFireAbstract.a((World) worldserver, blockposition, enumdirection)) { -- worldserver.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) worldserver, blockposition)); -- worldserver.a((Entity) null, GameEvent.BLOCK_PLACE, blockposition); + if (BlockFireAbstract.canBePlacedAt(worldserver, blockposition, enumdirection)) { +- worldserver.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(worldserver, blockposition)); +- worldserver.gameEvent((Entity) null, GameEvent.BLOCK_PLACE, blockposition); + // CraftBukkit start - Ignition by dispensing flint and steel -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(worldserver, blockposition, isourceblock.getBlockPosition()).isCancelled()) { -+ worldserver.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) worldserver, blockposition)); -+ worldserver.a((Entity) null, GameEvent.BLOCK_PLACE, blockposition); ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(worldserver, blockposition, isourceblock.getPos()).isCancelled()) { ++ worldserver.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(worldserver, blockposition)); ++ worldserver.gameEvent((Entity) null, GameEvent.BLOCK_PLACE, blockposition); + } + // CraftBukkit end - } else if (!BlockCampfire.h(iblockdata) && !CandleBlock.g(iblockdata) && !CandleCakeBlock.g(iblockdata)) { + } else if (!BlockCampfire.canLight(iblockdata) && !CandleBlock.canLight(iblockdata) && !CandleCakeBlock.canLight(iblockdata)) { if (iblockdata.getBlock() instanceof BlockTNT) { - BlockTNT.a((World) worldserver, blockposition); -@@ -481,12 +787,62 @@ - this.a(true); - WorldServer worldserver = isourceblock.getWorld(); - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); + BlockTNT.explode(worldserver, blockposition); +@@ -478,12 +784,62 @@ + this.setSuccess(true); + WorldServer worldserver = isourceblock.getLevel(); + BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING)); + // CraftBukkit start -+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + + BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -526,10 +481,10 @@ + worldserver.captureTreeGeneration = true; + // CraftBukkit end - if (!ItemBoneMeal.a(itemstack, (World) worldserver, blockposition) && !ItemBoneMeal.a(itemstack, (World) worldserver, blockposition, (EnumDirection) null)) { - this.a(false); + if (!ItemBoneMeal.growCrop(itemstack, worldserver, blockposition) && !ItemBoneMeal.growWaterPlant(itemstack, worldserver, blockposition, (EnumDirection) null)) { + this.setSuccess(false); } else if (!worldserver.isClientSide) { - worldserver.triggerEffect(1505, blockposition, 0); + worldserver.levelEvent(1505, blockposition, 0); } + // CraftBukkit start + worldserver.captureTreeGeneration = false; @@ -559,16 +514,16 @@ return itemstack; } -@@ -496,12 +852,41 @@ - protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - WorldServer worldserver = isourceblock.getWorld(); - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); +@@ -493,12 +849,41 @@ + protected ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) { + WorldServer worldserver = isourceblock.getLevel(); + BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().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); + -+ // CraftBukkit start -+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ ItemStack itemstack1 = itemstack.split(1); ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + 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)); @@ -577,12 +532,12 @@ + } + + if (event.isCancelled()) { -+ itemstack.add(1); ++ itemstack.grow(1); + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.add(1); ++ itemstack.grow(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); @@ -595,20 +550,20 @@ + EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), (EntityLiving) null); + // CraftBukkit end - worldserver.addEntity(entitytntprimed); - worldserver.playSound((EntityHuman) null, entitytntprimed.locX(), entitytntprimed.locY(), entitytntprimed.locZ(), SoundEffects.TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); - worldserver.a((Entity) null, GameEvent.ENTITY_PLACE, blockposition); -- itemstack.subtract(1); -+ // itemstack.subtract(1); // CraftBukkit - handled above + 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, GameEvent.ENTITY_PLACE, blockposition); +- itemstack.shrink(1); ++ // itemstack.shrink(1); // CraftBukkit - handled above return itemstack; } - })); -@@ -525,6 +910,30 @@ - EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); - BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); + }); +@@ -522,6 +907,30 @@ + EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING); + BlockPosition blockposition = isourceblock.getPos().relative(enumdirection); + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + + BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); @@ -631,15 +586,15 @@ + } + // CraftBukkit end + - if (worldserver.isEmpty(blockposition) && BlockWitherSkull.b((World) worldserver, blockposition, itemstack)) { - worldserver.setTypeAndData(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.getBlockData().set(BlockSkull.ROTATION, enumdirection.n() == EnumDirection.EnumAxis.Y ? 0 : enumdirection.opposite().get2DRotationValue() * 4), 3); - worldserver.a((Entity) null, GameEvent.BLOCK_PLACE, blockposition); -@@ -550,6 +959,30 @@ - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); + if (worldserver.isEmptyBlock(blockposition) && BlockWitherSkull.canSpawnMob(worldserver, blockposition, itemstack)) { + worldserver.setBlock(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.defaultBlockState().setValue(BlockSkull.ROTATION, enumdirection.getAxis() == EnumDirection.EnumAxis.Y ? 0 : enumdirection.getOpposite().get2DDataValue() * 4), 3); + worldserver.gameEvent((Entity) null, GameEvent.BLOCK_PLACE, blockposition); +@@ -547,6 +956,30 @@ + BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING)); BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN; + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + + BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); @@ -662,15 +617,15 @@ + } + // CraftBukkit end + - if (worldserver.isEmpty(blockposition) && blockpumpkincarved.a((IWorldReader) worldserver, blockposition)) { + if (worldserver.isEmptyBlock(blockposition) && blockpumpkincarved.canSpawnGolem(worldserver, blockposition)) { if (!worldserver.isClientSide) { - worldserver.setTypeAndData(blockposition, blockpumpkincarved.getBlockData(), 3); -@@ -599,6 +1032,30 @@ - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); - IBlockData iblockdata = worldserver.getType(blockposition); + worldserver.setBlock(blockposition, blockpumpkincarved.defaultBlockState(), 3); +@@ -596,6 +1029,30 @@ + BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING)); + IBlockData iblockdata = worldserver.getBlockState(blockposition); + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + + BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); @@ -693,6 +648,6 @@ + } + // CraftBukkit end + - if (iblockdata.a((Tag) TagsBlock.BEEHIVES, (blockbase_blockdata) -> { - return blockbase_blockdata.b(BlockBeehive.HONEY_LEVEL); - }) && (Integer) iblockdata.get(BlockBeehive.HONEY_LEVEL) >= 5) { + if (iblockdata.is(TagsBlock.BEEHIVES, (blockbase_blockdata) -> { + return blockbase_blockdata.hasProperty(BlockBeehive.HONEY_LEVEL); + }) && (Integer) iblockdata.getValue(BlockBeehive.HONEY_LEVEL) >= 5) { diff --git a/paper-server/nms-patches/net/minecraft/network/NetworkManager.patch b/paper-server/nms-patches/net/minecraft/network/NetworkManager.patch index af44ec6f76..7e444519c1 100644 --- a/paper-server/nms-patches/net/minecraft/network/NetworkManager.patch +++ b/paper-server/nms-patches/net/minecraft/network/NetworkManager.patch @@ -3,15 +3,15 @@ @@ -156,7 +156,7 @@ } - private static <T extends PacketListener> void a(Packet<T> packet, PacketListener packetlistener) { -- packet.a(packetlistener); -+ packet.a((T) packetlistener); // CraftBukkit - decompile error + private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener packetlistener) { +- packet.handle(packetlistener); ++ packet.handle((T) packetlistener); // CraftBukkit - decompile error } - public void setPacketListener(PacketListener packetlistener) { + public void setListener(PacketListener packetlistener) { @@ -268,7 +268,7 @@ - public void close(IChatBaseComponent ichatbasecomponent) { + public void disconnect(IChatBaseComponent ichatbasecomponent) { if (this.channel.isOpen()) { - this.channel.close().awaitUninterruptibly(); + this.channel.close(); // We can't wait as this may be called from an event loop. diff --git a/paper-server/nms-patches/net/minecraft/network/PacketDataSerializer.patch b/paper-server/nms-patches/net/minecraft/network/PacketDataSerializer.patch index ca017d22ba..0e39e884bb 100644 --- a/paper-server/nms-patches/net/minecraft/network/PacketDataSerializer.patch +++ b/paper-server/nms-patches/net/minecraft/network/PacketDataSerializer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/PacketDataSerializer.java +++ b/net/minecraft/network/PacketDataSerializer.java -@@ -55,6 +55,8 @@ +@@ -54,6 +54,8 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.Vec3D; @@ -9,79 +9,79 @@ public class PacketDataSerializer extends ByteBuf { private static final int MAX_VARINT_SIZE = 5; -@@ -123,7 +125,7 @@ +@@ -122,7 +124,7 @@ - public <T, C extends Collection<T>> C a(IntFunction<C> intfunction, Function<PacketDataSerializer, T> function) { - int i = this.j(); + public <T, C extends Collection<T>> C readCollection(IntFunction<C> intfunction, Function<PacketDataSerializer, T> function) { + 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(function.apply(this)); -@@ -134,7 +136,7 @@ +@@ -133,7 +135,7 @@ - public <T> void a(Collection<T> collection, BiConsumer<PacketDataSerializer, T> biconsumer) { - this.d(collection.size()); + public <T> void writeCollection(Collection<T> collection, BiConsumer<PacketDataSerializer, T> biconsumer) { + this.writeVarInt(collection.size()); - Iterator iterator = collection.iterator(); + Iterator<T> iterator = collection.iterator(); // CraftBukkit - decompile error while (iterator.hasNext()) { T t0 = iterator.next(); -@@ -145,7 +147,7 @@ +@@ -144,7 +146,7 @@ } - public <T> List<T> a(Function<PacketDataSerializer, T> function) { -- return (List) this.a(Lists::newArrayListWithCapacity, function); -+ return (List) this.a((java.util.function.IntFunction) Lists::newArrayListWithCapacity, function); // CraftBukkit - decompile error + public <T> List<T> readList(Function<PacketDataSerializer, T> function) { +- return (List) this.readCollection(Lists::newArrayListWithCapacity, function); ++ return (List) this.readCollection((java.util.function.IntFunction) Lists::newArrayListWithCapacity, function); // CraftBukkit - decompile error } - public IntList a() { -@@ -161,12 +163,12 @@ + public IntList readIntIdList() { +@@ -160,12 +162,12 @@ - public void a(IntList intlist) { - this.d(intlist.size()); -- intlist.forEach(this::d); -+ intlist.forEach((java.util.function.IntConsumer) this::d); // CraftBukkit - decompile error + public void writeIntIdList(IntList intlist) { + this.writeVarInt(intlist.size()); +- intlist.forEach(this::writeVarInt); ++ intlist.forEach((java.util.function.IntConsumer) this::writeVarInt); // CraftBukkit - decompile error } - public <K, V, M extends Map<K, V>> M a(IntFunction<M> intfunction, Function<PacketDataSerializer, K> function, Function<PacketDataSerializer, V> function1) { - int i = this.j(); + public <K, V, M extends Map<K, V>> M readMap(IntFunction<M> intfunction, Function<PacketDataSerializer, K> function, Function<PacketDataSerializer, V> function1) { + 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 = function.apply(this); -@@ -355,7 +357,7 @@ +@@ -354,7 +356,7 @@ } - public <T extends Enum<T>> T a(Class<T> oclass) { -- return ((Enum[]) oclass.getEnumConstants())[this.j()]; -+ return ((T[]) oclass.getEnumConstants())[this.j()]; // CraftBukkit - fix decompile error + public <T extends Enum<T>> T readEnum(Class<T> oclass) { +- return ((Enum[]) oclass.getEnumConstants())[this.readVarInt()]; ++ return ((T[]) oclass.getEnumConstants())[this.readVarInt()]; // CraftBukkit - fix decompile error } - public PacketDataSerializer a(Enum<?> oenum) { -@@ -432,7 +434,7 @@ + public PacketDataSerializer writeEnum(Enum<?> oenum) { +@@ -431,7 +433,7 @@ } else { try { - NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this))); + NBTCompressedStreamTools.write(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this))); - } catch (IOException ioexception) { + } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception throw new EncoderException(ioexception); } } -@@ -469,7 +471,7 @@ +@@ -468,7 +470,7 @@ } - public PacketDataSerializer a(ItemStack itemstack) { + public PacketDataSerializer writeItem(ItemStack itemstack) { - if (itemstack.isEmpty()) { + if (itemstack.isEmpty() || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem() this.writeBoolean(false); } else { this.writeBoolean(true); -@@ -498,6 +500,11 @@ - ItemStack itemstack = new ItemStack(Item.getById(i), b0); +@@ -497,6 +499,11 @@ + ItemStack itemstack = new ItemStack(Item.byId(i), b0); - itemstack.setTag(this.m()); + itemstack.setTag(this.readNbt()); + // CraftBukkit start + if (itemstack.getTag() != null) { + CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); diff --git a/paper-server/nms-patches/net/minecraft/network/chat/ChatHexColor.patch b/paper-server/nms-patches/net/minecraft/network/chat/ChatHexColor.patch index 92dae25115..3ce3d84915 100644 --- a/paper-server/nms-patches/net/minecraft/network/chat/ChatHexColor.patch +++ b/paper-server/nms-patches/net/minecraft/network/chat/ChatHexColor.patch @@ -3,9 +3,9 @@ @@ -12,7 +12,7 @@ private static final String CUSTOM_COLOR_PREFIX = "#"; - private static final Map<EnumChatFormat, ChatHexColor> LEGACY_FORMAT_TO_COLOR = (Map) Stream.of(EnumChatFormat.values()).filter(EnumChatFormat::d).collect(ImmutableMap.toImmutableMap(Function.identity(), (enumchatformat) -> { -- return new ChatHexColor(enumchatformat.e(), enumchatformat.f()); -+ return new ChatHexColor(enumchatformat.e(), enumchatformat.f(), enumchatformat); // CraftBukkit + private static final Map<EnumChatFormat, ChatHexColor> LEGACY_FORMAT_TO_COLOR = (Map) Stream.of(EnumChatFormat.values()).filter(EnumChatFormat::isColor).collect(ImmutableMap.toImmutableMap(Function.identity(), (enumchatformat) -> { +- return new ChatHexColor(enumchatformat.getColor(), enumchatformat.getName()); ++ return new ChatHexColor(enumchatformat.getColor(), enumchatformat.getName(), enumchatformat); // CraftBukkit })); private static final Map<String, ChatHexColor> NAMED_COLORS = (Map) ChatHexColor.LEGACY_FORMAT_TO_COLOR.values().stream().collect(ImmutableMap.toImmutableMap((chathexcolor) -> { return chathexcolor.name; @@ -31,5 +31,5 @@ } + // CraftBukkit end - public int a() { + public int getValue() { return this.value; diff --git a/paper-server/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch b/paper-server/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch index c38085d296..122ad4e8ec 100644 --- a/paper-server/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch +++ b/paper-server/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch @@ -23,5 +23,5 @@ + } + // CraftBukkit end - ChatModifier getChatModifier(); + ChatModifier getStyle(); diff --git a/paper-server/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch b/paper-server/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch index b73a409f7b..7949555509 100644 --- a/paper-server/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch +++ b/paper-server/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch @@ -13,12 +13,12 @@ private static final Logger LOGGER = LogManager.getLogger(); @@ -20,6 +25,7 @@ - public static <T extends PacketListener> void ensureMainThread(Packet<T> packet, T t0, IAsyncTaskHandler<?> iasynctaskhandler) throws CancelledPacketHandleException { - if (!iasynctaskhandler.isMainThread()) { + public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T t0, IAsyncTaskHandler<?> iasynctaskhandler) throws CancelledPacketHandleException { + if (!iasynctaskhandler.isSameThread()) { iasynctaskhandler.execute(() -> { + if (MinecraftServer.getServer().hasStopped() || (t0 instanceof PlayerConnection && ((PlayerConnection) t0).processedDisconnect)) return; // CraftBukkit, MC-142590 - if (t0.a().isConnected()) { - packet.a(t0); + if (t0.getConnection().isConnected()) { + packet.handle(t0); } else { @@ -28,6 +34,10 @@ diff --git a/paper-server/nms-patches/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.patch b/paper-server/nms-patches/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.patch index c451f9d7b2..fa0dc08cc7 100644 --- a/paper-server/nms-patches/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.patch +++ b/paper-server/nms-patches/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.patch @@ -7,9 +7,9 @@ - this.newCenterX = worldborder.getCenterX(); - this.newCenterZ = worldborder.getCenterZ(); + // CraftBukkit start - multiply out nether border -+ this.newCenterX = worldborder.getCenterX() * worldborder.world.getDimensionManager().getCoordinateScale(); -+ this.newCenterZ = worldborder.getCenterZ() * worldborder.world.getDimensionManager().getCoordinateScale(); ++ this.newCenterX = worldborder.getCenterX() * worldborder.world.dimensionType().coordinateScale(); ++ this.newCenterZ = worldborder.getCenterZ() * worldborder.world.dimensionType().coordinateScale(); + // CraftBukkit end this.oldSize = worldborder.getSize(); - this.newSize = worldborder.k(); - this.lerpTime = worldborder.j(); + this.newSize = worldborder.getLerpTarget(); + this.lerpTime = worldborder.getLerpRemainingTime(); diff --git a/paper-server/nms-patches/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.patch b/paper-server/nms-patches/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.patch index 3c0fefce71..4f381d1a98 100644 --- a/paper-server/nms-patches/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.patch +++ b/paper-server/nms-patches/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.patch @@ -7,8 +7,8 @@ - this.newCenterX = worldborder.getCenterX(); - this.newCenterZ = worldborder.getCenterZ(); + // CraftBukkit start - multiply out nether border -+ this.newCenterX = worldborder.getCenterX() * worldborder.world.getDimensionManager().getCoordinateScale(); -+ this.newCenterZ = worldborder.getCenterZ() * worldborder.world.getDimensionManager().getCoordinateScale(); ++ this.newCenterX = worldborder.getCenterX() * worldborder.world.dimensionType().coordinateScale(); ++ this.newCenterZ = worldborder.getCenterZ() * worldborder.world.dimensionType().coordinateScale(); + // CraftBukkit end } diff --git a/paper-server/nms-patches/net/minecraft/network/protocol/game/PacketPlayInChat.patch b/paper-server/nms-patches/net/minecraft/network/protocol/game/PacketPlayInChat.patch index cbd53fda49..cbc1829501 100644 --- a/paper-server/nms-patches/net/minecraft/network/protocol/game/PacketPlayInChat.patch +++ b/paper-server/nms-patches/net/minecraft/network/protocol/game/PacketPlayInChat.patch @@ -4,8 +4,8 @@ } public PacketPlayInChat(PacketDataSerializer packetdataserializer) { -- this.message = packetdataserializer.e(256); -+ this.message = org.apache.commons.lang3.StringUtils.normalizeSpace(packetdataserializer.e(256)); // CraftBukkit - see PlayerConnection +- this.message = packetdataserializer.readUtf(256); ++ this.message = org.apache.commons.lang3.StringUtils.normalizeSpace(packetdataserializer.readUtf(256)); // CraftBukkit - see PlayerConnection } @Override diff --git a/paper-server/nms-patches/net/minecraft/network/protocol/game/PacketPlayOutMultiBlockChange.patch b/paper-server/nms-patches/net/minecraft/network/protocol/game/PacketPlayOutMultiBlockChange.patch index 56a7921189..c0e4b3f5b7 100644 --- a/paper-server/nms-patches/net/minecraft/network/protocol/game/PacketPlayOutMultiBlockChange.patch +++ b/paper-server/nms-patches/net/minecraft/network/protocol/game/PacketPlayOutMultiBlockChange.patch @@ -4,8 +4,8 @@ short short0 = (Short) shortiterator.next(); this.positions[j] = short0; -- this.states[j] = chunksection.getType(SectionPosition.a(short0), SectionPosition.b(short0), SectionPosition.c(short0)); -+ this.states[j] = (chunksection != null) ? chunksection.getType(SectionPosition.a(short0), SectionPosition.b(short0), SectionPosition.c(short0)) : net.minecraft.world.level.block.Blocks.AIR.getBlockData(); // CraftBukkit - SPIGOT-6076, Mojang bug when empty chunk section notified +- this.states[j] = chunksection.getBlockState(SectionPosition.sectionRelativeX(short0), SectionPosition.sectionRelativeY(short0), SectionPosition.sectionRelativeZ(short0)); ++ this.states[j] = (chunksection != null) ? chunksection.getBlockState(SectionPosition.sectionRelativeX(short0), SectionPosition.sectionRelativeY(short0), SectionPosition.sectionRelativeZ(short0)) : net.minecraft.world.level.block.Blocks.AIR.defaultBlockState(); // CraftBukkit - SPIGOT-6076, Mojang bug when empty chunk section notified } } diff --git a/paper-server/nms-patches/net/minecraft/network/syncher/DataWatcher.patch b/paper-server/nms-patches/net/minecraft/network/syncher/DataWatcher.patch index e4e1d6d16d..7958b471c2 100644 --- a/paper-server/nms-patches/net/minecraft/network/syncher/DataWatcher.patch +++ b/paper-server/nms-patches/net/minecraft/network/syncher/DataWatcher.patch @@ -6,20 +6,20 @@ + // CraftBukkit start - add method from above + public <T> void markDirty(DataWatcherObject<T> datawatcherobject) { -+ this.b(datawatcherobject).a(true); ++ this.getItem(datawatcherobject).setDirty(true); + this.isDirty = true; + } + // CraftBukkit end + - public boolean a() { + public boolean isDirty() { return this.isDirty; } @@ -273,7 +280,7 @@ - if (!Objects.equals(datawatcher_item1.accessor.b(), datawatcher_item.accessor.b())) { - throw new IllegalStateException(String.format("Invalid entity data item type for field %d on entity %s: old=%s(%s), new=%s(%s)", datawatcher_item.accessor.a(), this.entity, datawatcher_item.value, datawatcher_item.value.getClass(), datawatcher_item1.value, datawatcher_item1.value.getClass())); + if (!Objects.equals(datawatcher_item1.accessor.getSerializer(), datawatcher_item.accessor.getSerializer())) { + throw new IllegalStateException(String.format("Invalid entity data item type for field %d on entity %s: old=%s(%s), new=%s(%s)", datawatcher_item.accessor.getId(), this.entity, datawatcher_item.value, datawatcher_item.value.getClass(), datawatcher_item1.value, datawatcher_item1.value.getClass())); } else { -- datawatcher_item.a(datawatcher_item1.b()); -+ datawatcher_item.a((T) datawatcher_item1.b()); // CraftBukkit - decompile error +- datawatcher_item.setValue(datawatcher_item1.getValue()); ++ datawatcher_item.setValue((T) datawatcher_item1.getValue()); // CraftBukkit - decompile error } } diff --git a/paper-server/nms-patches/net/minecraft/resources/RegistryResourceAccess.patch b/paper-server/nms-patches/net/minecraft/resources/RegistryResourceAccess.patch new file mode 100644 index 0000000000..71556e619b --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/resources/RegistryResourceAccess.patch @@ -0,0 +1,61 @@ +--- a/net/minecraft/resources/RegistryResourceAccess.java ++++ b/net/minecraft/resources/RegistryResourceAccess.java +@@ -160,8 +160,10 @@ + })); + } + +- private static final class Entry extends Record { ++ // CraftBukkit start ++ private static final record Entry(JsonElement data, int id, Lifecycle lifecycle) { + ++ /* + final JsonElement data; + final int id; + final Lifecycle lifecycle; +@@ -183,6 +185,8 @@ + public final boolean equals(Object object) { + return this.equals<invokedynamic>(this, object); + } ++ */ ++ // CraftBukkit end + + public JsonElement data() { + return this.data; +@@ -198,8 +202,10 @@ + } + } + +- public static final class ParsedEntry extends Record { ++ // CraftBukkit start ++ public static final record ParsedEntry<E>(E value, OptionalInt fixedId) { + ++ /* + private final E value; + private final OptionalInt fixedId; + +@@ -207,6 +213,8 @@ + this.value = e0; + this.fixedId = optionalint; + } ++ */ ++ // CraftBukkit end + + public static <E> RegistryResourceAccess.ParsedEntry<E> createWithoutId(E e0) { + return new RegistryResourceAccess.ParsedEntry(e0, OptionalInt.empty()); +@@ -216,6 +224,8 @@ + return new RegistryResourceAccess.ParsedEntry(e0, OptionalInt.of(i)); + } + ++ // CraftBukkit start ++ /* + public final String toString() { + return this.toString < invokedynamic > (this); + } +@@ -235,5 +245,7 @@ + public OptionalInt fixedId() { + return this.fixedId; + } ++ */ ++ // CraftBukkit end + } + } diff --git a/paper-server/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch b/paper-server/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch index 45c0c1181b..850e29a645 100644 --- a/paper-server/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch +++ b/paper-server/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/AdvancementDataPlayer.java +++ b/net/minecraft/server/AdvancementDataPlayer.java @@ -181,7 +181,11 @@ - Advancement advancement = advancementdataworld.a((MinecraftKey) entry.getKey()); + Advancement advancement = advancementdataworld.getAdvancement((MinecraftKey) entry.getKey()); if (advancement == null) { - AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.file); @@ -11,13 +11,13 @@ + } + // CraftBukkit end } else { - this.a(advancement, (AdvancementProgress) entry.getValue()); + this.startProgress(advancement, (AdvancementProgress) entry.getValue()); } @@ -276,6 +280,7 @@ this.progressChanged.add(advancement); flag = true; if (!flag1 && advancementprogress.isDone()) { + this.player.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit)); // CraftBukkit - advancement.d().a(this.player); - if (advancement.c() != null && advancement.c().i() && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) { - this.playerList.sendMessage(new ChatMessage("chat.type.advancement." + advancement.c().e().a(), new Object[]{this.player.getScoreboardDisplayName(), advancement.j()}), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID); + advancement.getRewards().grant(this.player); + if (advancement.getDisplay() != null && advancement.getDisplay().shouldAnnounceChat() && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) { + this.playerList.broadcastMessage(new ChatMessage("chat.type.advancement." + advancement.getDisplay().getFrame().getName(), new Object[]{this.player.getDisplayName(), advancement.getChatComponent()}), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID); diff --git a/paper-server/nms-patches/net/minecraft/server/CustomFunctionData.patch b/paper-server/nms-patches/net/minecraft/server/CustomFunctionData.patch index bc1e2ce150..61f81938ef 100644 --- a/paper-server/nms-patches/net/minecraft/server/CustomFunctionData.patch +++ b/paper-server/nms-patches/net/minecraft/server/CustomFunctionData.patch @@ -3,9 +3,9 @@ @@ -44,7 +44,7 @@ } - public CommandDispatcher<CommandListenerWrapper> getCommandDispatcher() { -- return this.server.getCommandDispatcher().a(); -+ return this.server.vanillaCommandDispatcher.a(); // CraftBukkit + public CommandDispatcher<CommandListenerWrapper> getDispatcher() { +- return this.server.getCommands().getDispatcher(); ++ return this.server.vanillaCommandDispatcher.getDispatcher(); // CraftBukkit } public void tick() { diff --git a/paper-server/nms-patches/net/minecraft/server/DispenserRegistry.patch b/paper-server/nms-patches/net/minecraft/server/DispenserRegistry.patch index c06dd3a701..e01e33b283 100644 --- a/paper-server/nms-patches/net/minecraft/server/DispenserRegistry.patch +++ b/paper-server/nms-patches/net/minecraft/server/DispenserRegistry.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/DispenserRegistry.java +++ b/net/minecraft/server/DispenserRegistry.java -@@ -28,6 +28,12 @@ +@@ -34,6 +34,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -13,9 +13,9 @@ public class DispenserRegistry { public static final PrintStream STDOUT = System.out; -@@ -38,6 +44,23 @@ +@@ -44,6 +50,23 @@ - public static void init() { + public static void bootStrap() { if (!DispenserRegistry.isBootstrapped) { + // CraftBukkit start + String name = DispenserRegistry.class.getSimpleName(); @@ -37,30 +37,30 @@ DispenserRegistry.isBootstrapped = true; if (IRegistry.REGISTRY.keySet().isEmpty()) { throw new IllegalStateException("Unable to load registries"); -@@ -55,6 +78,69 @@ - TagStatic.b(); - d(); +@@ -61,6 +84,69 @@ + TagStatic.bootStrap(); + wrapStreams(); } + // CraftBukkit start - easier than fixing the decompile -+ DataConverterFlattenData.map(1008, "{Name:'minecraft:oak_sign',Properties:{rotation:'0'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'0'}}"); -+ DataConverterFlattenData.map(1009, "{Name:'minecraft:oak_sign',Properties:{rotation:'1'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'1'}}"); -+ DataConverterFlattenData.map(1010, "{Name:'minecraft:oak_sign',Properties:{rotation:'2'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'2'}}"); -+ DataConverterFlattenData.map(1011, "{Name:'minecraft:oak_sign',Properties:{rotation:'3'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'3'}}"); -+ DataConverterFlattenData.map(1012, "{Name:'minecraft:oak_sign',Properties:{rotation:'4'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'4'}}"); -+ DataConverterFlattenData.map(1013, "{Name:'minecraft:oak_sign',Properties:{rotation:'5'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'5'}}"); -+ DataConverterFlattenData.map(1014, "{Name:'minecraft:oak_sign',Properties:{rotation:'6'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'6'}}"); -+ DataConverterFlattenData.map(1015, "{Name:'minecraft:oak_sign',Properties:{rotation:'7'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'7'}}"); -+ DataConverterFlattenData.map(1016, "{Name:'minecraft:oak_sign',Properties:{rotation:'8'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'8'}}"); -+ DataConverterFlattenData.map(1017, "{Name:'minecraft:oak_sign',Properties:{rotation:'9'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'9'}}"); -+ DataConverterFlattenData.map(1018, "{Name:'minecraft:oak_sign',Properties:{rotation:'10'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'10'}}"); -+ DataConverterFlattenData.map(1019, "{Name:'minecraft:oak_sign',Properties:{rotation:'11'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'11'}}"); -+ DataConverterFlattenData.map(1020, "{Name:'minecraft:oak_sign',Properties:{rotation:'12'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'12'}}"); -+ DataConverterFlattenData.map(1021, "{Name:'minecraft:oak_sign',Properties:{rotation:'13'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'13'}}"); -+ DataConverterFlattenData.map(1022, "{Name:'minecraft:oak_sign',Properties:{rotation:'14'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'14'}}"); -+ DataConverterFlattenData.map(1023, "{Name:'minecraft:oak_sign',Properties:{rotation:'15'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'15'}}"); ++ 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'}}"); + DataConverterMaterialId.ITEM_NAMES.put(323, "minecraft:oak_sign"); + -+ DataConverterFlattenData.map(1440, "{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}", new String[]{"{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}"}); ++ DataConverterFlattenData.register(1440, "{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}", new String[]{"{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}"}); + + DataConverterMaterialId.ITEM_NAMES.put(409, "minecraft:prismarine_shard"); + DataConverterMaterialId.ITEM_NAMES.put(410, "minecraft:prismarine_crystals"); diff --git a/paper-server/nms-patches/net/minecraft/server/Main.patch b/paper-server/nms-patches/net/minecraft/server/Main.patch index b0107760ee..1ce8885029 100644 --- a/paper-server/nms-patches/net/minecraft/server/Main.patch +++ b/paper-server/nms-patches/net/minecraft/server/Main.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -58,6 +58,12 @@ +@@ -56,6 +56,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -13,34 +13,39 @@ public class Main { private static final Logger LOGGER = LogManager.getLogger(); -@@ -65,8 +71,9 @@ +@@ -63,8 +69,9 @@ public Main() {} @DontObfuscate - public static void main(String[] astring) { + public static void main(final OptionSet optionset) { // CraftBukkit - replaces main(String[] astring) - SharedConstants.a(); + SharedConstants.tryDetectVersion(); + /* CraftBukkit start - Replace everything OptionParser optionparser = new OptionParser(); OptionSpec<Void> optionspec = optionparser.accepts("nogui"); OptionSpec<Void> optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); -@@ -90,20 +97,22 @@ +@@ -89,9 +96,12 @@ optionparser.printHelpOn(System.err); return; } + */ // CraftBukkit end - ++ + try { - CrashReport.h(); - DispenserRegistry.init(); - DispenserRegistry.c(); - SystemUtils.l(); - IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.a(); + + CrashReport.preload(); +- if (optionset.has(optionspec13)) { ++ if (optionset.has("jfrProfile")) { // CraftBukkit + JvmProfiler.INSTANCE.start(Environment.SERVER); + } + +@@ -100,13 +110,13 @@ + SystemUtils.startTimerHackThread(); + IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.builtin(); Path path = Paths.get("server.properties"); - DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(path); + DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(optionset); // CraftBukkit - CLI argument support - dedicatedserversettings.save(); + dedicatedserversettings.forceSave(); Path path1 = Paths.get("eula.txt"); EULA eula = new EULA(path1); @@ -49,7 +54,7 @@ Main.LOGGER.info("Initialized '{}' and '{}'", path.toAbsolutePath(), path1.toAbsolutePath()); return; } -@@ -113,14 +122,15 @@ +@@ -116,14 +126,15 @@ return; } @@ -62,16 +67,16 @@ - String s = (String) Optional.ofNullable((String) optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.getProperties().levelName); + // CraftBukkit start + String s = (String) Optional.ofNullable((String) optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName); - Convertable convertable = Convertable.a(file.toPath()); -- Convertable.ConversionSession convertable_conversionsession = convertable.c(s); -+ Convertable.ConversionSession convertable_conversionsession = convertable.c(s, WorldDimension.OVERWORLD); + Convertable convertable = Convertable.createDefault(file.toPath()); +- Convertable.ConversionSession convertable_conversionsession = convertable.createAccess(s); ++ Convertable.ConversionSession convertable_conversionsession = convertable.createAccess(s, WorldDimension.OVERWORLD); + WorldInfo worldinfo = convertable_conversionsession.getSummary(); - MinecraftServer.convertWorld(convertable_conversionsession); - WorldInfo worldinfo = convertable_conversionsession.d(); -@@ -131,13 +141,30 @@ + if (worldinfo != null) { +@@ -139,13 +150,30 @@ } - DataPackConfiguration datapackconfiguration = convertable_conversionsession.e(); + DataPackConfiguration datapackconfiguration = convertable_conversionsession.getDataPacks(); - boolean flag = optionset.has(optionspec6); + boolean flag = optionset.has("safeMode"); @@ -79,9 +84,9 @@ Main.LOGGER.warn("Safe mode active, only vanilla datapack will be loaded"); } - ResourcePackRepository resourcepackrepository = new ResourcePackRepository(EnumResourcePackType.SERVER_DATA, new ResourcePackSource[]{new ResourcePackSourceVanilla(), new ResourcePackSourceFolder(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACK_DIR).toFile(), PackSource.WORLD)}); + ResourcePackRepository resourcepackrepository = new ResourcePackRepository(EnumResourcePackType.SERVER_DATA, new ResourcePackSource[]{new ResourcePackSourceVanilla(), new ResourcePackSourceFolder(convertable_conversionsession.getLevelPath(SavedFile.DATAPACK_DIR).toFile(), PackSource.WORLD)}); + // CraftBukkit start -+ File bukkitDataPackFolder = new File(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACK_DIR).toFile(), "bukkit"); ++ File bukkitDataPackFolder = new File(convertable_conversionsession.getLevelPath(SavedFile.DATAPACK_DIR).toFile(), "bukkit"); + if (!bukkitDataPackFolder.exists()) { + bukkitDataPackFolder.mkdirs(); + } @@ -90,44 +95,44 @@ + com.google.common.io.Files.write("{\n" + + " \"pack\": {\n" + + " \"description\": \"Data pack for resources provided by Bukkit plugins\",\n" -+ + " \"pack_format\": " + SharedConstants.getGameVersion().getPackVersion() + "\n" ++ + " \"pack_format\": " + SharedConstants.getCurrentVersion().getPackVersion() + "\n" + + " }\n" + + "}\n", mcMeta, com.google.common.base.Charsets.UTF_8); + } catch (java.io.IOException ex) { + throw new RuntimeException("Could not initialize Bukkit datapack", ex); + } + // CraftBukkit end - DataPackConfiguration datapackconfiguration1 = MinecraftServer.a(resourcepackrepository, datapackconfiguration == null ? DataPackConfiguration.DEFAULT : datapackconfiguration, flag); - CompletableFuture completablefuture = DataPackResources.a(resourcepackrepository.f(), iregistrycustom_dimension, CommandDispatcher.ServerType.DEDICATED, dedicatedserversettings.getProperties().functionPermissionLevel, SystemUtils.f(), Runnable::run); + DataPackConfiguration datapackconfiguration1 = MinecraftServer.configurePackRepository(resourcepackrepository, datapackconfiguration == null ? DataPackConfiguration.DEFAULT : datapackconfiguration, flag); + CompletableFuture completablefuture = DataPackResources.loadResources(resourcepackrepository.openAllSelected(), iregistrycustom_dimension, CommandDispatcher.ServerType.DEDICATED, dedicatedserversettings.getProperties().functionPermissionLevel, SystemUtils.backgroundExecutor(), Runnable::run); -@@ -152,6 +179,7 @@ +@@ -160,6 +188,7 @@ } - datapackresources.j(); + datapackresources.updateGlobals(); + /* - RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.INSTANCE, datapackresources.i(), (IRegistryCustom) iregistrycustom_dimension); + RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.createAndLoad(DynamicOpsNBT.INSTANCE, datapackresources.getResourceManager(), iregistrycustom_dimension); - dedicatedserversettings.getProperties().a((IRegistryCustom) iregistrycustom_dimension); -@@ -181,21 +209,32 @@ + dedicatedserversettings.getProperties().getWorldGenSettings(iregistrycustom_dimension); +@@ -189,21 +218,32 @@ } - convertable_conversionsession.a((IRegistryCustom) iregistrycustom_dimension, (SaveData) object); + convertable_conversionsession.saveDataTag(iregistrycustom_dimension, (SaveData) object); + */ - final DedicatedServer dedicatedserver = (DedicatedServer) MinecraftServer.a((thread) -> { -- DedicatedServer dedicatedserver1 = new DedicatedServer(thread, iregistrycustom_dimension, convertable_conversionsession, resourcepackrepository, datapackresources, object, dedicatedserversettings, DataConverterRegistry.a(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new); -+ DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, datapackconfiguration1, thread, iregistrycustom_dimension, convertable_conversionsession, resourcepackrepository, datapackresources, null, dedicatedserversettings, DataConverterRegistry.a(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new); + final DedicatedServer dedicatedserver = (DedicatedServer) MinecraftServer.spin((thread) -> { +- DedicatedServer dedicatedserver1 = new DedicatedServer(thread, iregistrycustom_dimension, convertable_conversionsession, resourcepackrepository, datapackresources, object, dedicatedserversettings, DataConverterRegistry.getDataFixer(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new); ++ DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, datapackconfiguration1, thread, iregistrycustom_dimension, convertable_conversionsession, resourcepackrepository, datapackresources, null, dedicatedserversettings, DataConverterRegistry.getDataFixer(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new); + /* - dedicatedserver1.d((String) optionset.valueOf(optionspec8)); + dedicatedserver1.setSingleplayerName((String) optionset.valueOf(optionspec8)); dedicatedserver1.setPort((Integer) optionset.valueOf(optionspec11)); - dedicatedserver1.c(optionset.has(optionspec2)); - dedicatedserver1.b((String) optionset.valueOf(optionspec12)); + dedicatedserver1.setDemo(optionset.has(optionspec2)); + dedicatedserver1.setId((String) optionset.valueOf(optionspec12)); - boolean flag1 = !optionset.has(optionspec) && !optionset.valuesOf(nonoptionargumentspec).contains("nogui"); + */ + boolean flag1 = !optionset.has("nogui") && !optionset.nonOptionArguments().contains("nogui"); if (flag1 && !GraphicsEnvironment.isHeadless()) { - dedicatedserver1.bh(); + dedicatedserver1.showGui(); } + if (optionset.has("port")) { @@ -142,8 +147,8 @@ + /* CraftBukkit start Thread thread = new Thread("Server Shutdown Thread") { public void run() { - dedicatedserver.safeShutdown(true); -@@ -204,14 +243,15 @@ + dedicatedserver.halt(true); +@@ -212,6 +252,7 @@ thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER)); Runtime.getRuntime().addShutdownHook(thread); @@ -151,13 +156,12 @@ } catch (Exception exception1) { Main.LOGGER.fatal("Failed to start the minecraft server", exception1); } - +@@ -219,7 +260,7 @@ } -- public static void convertWorld(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, ImmutableSet<ResourceKey<World>> immutableset) { + public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, GeneratorSettings generatorsettings) { - Main.LOGGER.info("Forcing world upgrade!"); -+ public static void convertWorld(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, ImmutableSet<ResourceKey<DimensionManager>> immutableset) { // CraftBukkit -+ Main.LOGGER.info("Forcing world upgrade! {}", convertable_conversionsession.getLevelName()); // CraftBukkit - WorldUpgrader worldupgrader = new WorldUpgrader(convertable_conversionsession, datafixer, immutableset, flag); ++ Main.LOGGER.info("Forcing world upgrade! {}", convertable_conversionsession.getLevelId()); // CraftBukkit + WorldUpgrader worldupgrader = new WorldUpgrader(convertable_conversionsession, datafixer, generatorsettings, flag); IChatBaseComponent ichatbasecomponent = null; diff --git a/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch b/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch index 74c2ebb174..d3c58dd7e4 100644 --- a/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch +++ b/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch @@ -1,13 +1,12 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -163,6 +163,27 @@ +@@ -160,6 +160,27 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start +import com.mojang.serialization.DynamicOps; +import com.mojang.serialization.Lifecycle; -+import com.google.common.collect.ImmutableSet; +import jline.console.ConsoleReader; +import joptsimple.OptionSet; +import net.minecraft.nbt.DynamicOpsNBT; @@ -16,6 +15,7 @@ +import net.minecraft.server.dedicated.DedicatedServer; +import net.minecraft.server.dedicated.DedicatedServerProperties; +import net.minecraft.util.datafix.DataConverterRegistry; ++import net.minecraft.world.level.biome.WorldChunkManager; +import net.minecraft.world.level.levelgen.ChunkGeneratorAbstract; +import net.minecraft.world.level.storage.WorldDataServer; +import org.bukkit.Bukkit; @@ -25,12 +25,12 @@ +import org.bukkit.event.server.ServerLoadEvent; +// CraftBukkit end + - public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable { + public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ICommandListener, AutoCloseable { public static final Logger LOGGER = LogManager.getLogger(); -@@ -254,6 +275,20 @@ - private final DefinedStructureManager structureManager; +@@ -252,6 +273,20 @@ protected SaveData worldData; + private volatile boolean isSaving; + // CraftBukkit start + public DataPackConfiguration datapackconfiguration; @@ -46,13 +46,13 @@ + private boolean forceTicks; + // CraftBukkit end + - public static <S extends MinecraftServer> S a(Function<Thread, S> function) { + public static <S extends MinecraftServer> S spin(Function<Thread, S> function) { AtomicReference<S> atomicreference = new AtomicReference(); Thread thread = new Thread(() -> { -@@ -263,14 +298,14 @@ - thread.setUncaughtExceptionHandler((thread1, throwable) -> { - MinecraftServer.LOGGER.error(throwable); - }); +@@ -265,14 +300,14 @@ + thread.setPriority(8); + } + - S s0 = (MinecraftServer) function.apply(thread); + S s0 = function.apply(thread); // CraftBukkit - decompile error @@ -65,8 +65,8 @@ + public MinecraftServer(OptionSet options, DataPackConfiguration datapackconfiguration, Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, SaveData savedata, ResourcePackRepository resourcepackrepository, Proxy proxy, DataFixer datafixer, DataPackResources datapackresources, @Nullable MinecraftSessionService minecraftsessionservice, @Nullable GameProfileRepository gameprofilerepository, @Nullable UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { super("Server"); this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; - this.profiler = this.metricsRecorder.e(); -@@ -282,7 +317,7 @@ + this.profiler = this.metricsRecorder.getProfiler(); +@@ -284,7 +319,7 @@ this.status = new ServerPing(); this.random = new Random(); this.port = -1; @@ -75,10 +75,10 @@ this.running = true; this.tickTimes = new long[100]; this.resourcePack = ""; -@@ -312,13 +347,40 @@ - this.structureManager = new DefinedStructureManager(datapackresources.i(), convertable_conversionsession, datafixer); +@@ -314,13 +349,40 @@ + this.structureManager = new DefinedStructureManager(datapackresources.getResourceManager(), convertable_conversionsession, datafixer); this.serverThread = thread; - this.executor = SystemUtils.f(); + this.executor = SystemUtils.backgroundExecutor(); + // CraftBukkit start + this.options = options; + this.datapackconfiguration = datapackconfiguration; @@ -108,66 +108,95 @@ } + // CraftBukkit end - private void initializeScoreboards(WorldPersistentData worldpersistentdata) { + private void readScoreboard(WorldPersistentData worldpersistentdata) { ScoreboardServer scoreboardserver = this.getScoreboard(); Objects.requireNonNull(scoreboardserver); -- Function function = scoreboardserver::a; -+ Function<net.minecraft.nbt.NBTTagCompound, net.minecraft.world.scores.PersistentScoreboard> function = scoreboardserver::a; // CraftBukkit - decompile error +- Function function = scoreboardserver::createData; ++ Function<net.minecraft.nbt.NBTTagCompound, net.minecraft.world.scores.PersistentScoreboard> function = scoreboardserver::createData; // CraftBukkit - decompile error ScoreboardServer scoreboardserver1 = this.getScoreboard(); Objects.requireNonNull(scoreboardserver1); @@ -329,7 +391,7 @@ - public static void convertWorld(Convertable.ConversionSession convertable_conversionsession) { - if (convertable_conversionsession.isConvertable()) { -- MinecraftServer.LOGGER.info("Converting map!"); -+ MinecraftServer.LOGGER.info("Converting map! {}", convertable_conversionsession.getLevelName()); // CraftBukkit - convertable_conversionsession.convert(new IProgressUpdate() { - private long timeStamp = SystemUtils.getMonotonicMillis(); + protected abstract boolean initServer() throws IOException; -@@ -358,48 +420,211 @@ +- protected void loadLevel() { ++ protected void loadLevel(String s) { // CraftBukkit + if (!JvmProfiler.INSTANCE.isRunning()) { + ; + } +@@ -337,13 +399,8 @@ + boolean flag = false; + ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted(); + +- this.detectBundledResources(); +- this.worldData.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified()); +- WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11); ++ loadWorld0(s); // CraftBukkit + +- this.createLevels(worldloadlistener); +- this.forceDifficulty(); +- this.prepareLevels(worldloadlistener); + if (profiledduration != null) { + profiledduration.finish(); + } +@@ -358,35 +415,204 @@ } -- protected void loadWorld() { -- this.loadResourcesZip(); -- this.worldData.a(this.getServerModName(), this.getModded().isPresent()); -- WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11); -+ protected void loadWorld(String s) { -+ // CraftBukkit start +- protected void forceDifficulty() {} ++ // CraftBukkit start ++ private void loadWorld0(String s) { + Convertable.ConversionSession worldSession = this.storageSource; + IRegistryCustom.Dimension iregistrycustom_dimension = this.registryHolder; -+ RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.INSTANCE, this.resources.i(), (IRegistryCustom) iregistrycustom_dimension); -+ WorldDataServer overworldData = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, datapackconfiguration); ++ RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.createAndLoad(DynamicOpsNBT.INSTANCE, this.resources.getResourceManager(), iregistrycustom_dimension); ++ WorldDataServer overworldData = (WorldDataServer) worldSession.getDataTag(registryreadops, datapackconfiguration); + if (overworldData == null) { + WorldSettings worldsettings; + GeneratorSettings generatorsettings; + -+ if (this.isDemoMode()) { ++ if (this.isDemo()) { + worldsettings = MinecraftServer.DEMO_SETTINGS; -+ generatorsettings = GeneratorSettings.a((IRegistryCustom) iregistrycustom_dimension); ++ generatorsettings = GeneratorSettings.demoSettings(iregistrycustom_dimension); + } else { -+ DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getDedicatedServerProperties(); -+ ++ DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getProperties(); + +- protected void createLevels(WorldLoadListener worldloadlistener) { +- IWorldDataServer iworlddataserver = this.worldData.overworldData(); +- GeneratorSettings generatorsettings = this.worldData.worldGenSettings(); +- boolean flag = generatorsettings.isDebug(); +- long i = generatorsettings.seed(); +- long j = BiomeManager.obfuscateSeed(i); +- List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver)); +- RegistryMaterials<WorldDimension> registrymaterials = generatorsettings.dimensions(); +- WorldDimension worlddimension = (WorldDimension) registrymaterials.get(WorldDimension.OVERWORLD); +- DimensionManager dimensionmanager; +- Object object; +- +- if (worlddimension == null) { +- dimensionmanager = (DimensionManager) this.registryHolder.registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrThrow(DimensionManager.OVERWORLD_LOCATION); +- object = GeneratorSettings.makeDefaultOverworld(this.registryHolder, (new Random()).nextLong()); +- } else { +- dimensionmanager = worlddimension.type(); +- object = worlddimension.generator(); + worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), datapackconfiguration); -+ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.a((IRegistryCustom) iregistrycustom_dimension).j() : dedicatedserverproperties.a((IRegistryCustom) iregistrycustom_dimension); ++ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.getWorldGenSettings(iregistrycustom_dimension).withBonusChest() : dedicatedserverproperties.getWorldGenSettings(iregistrycustom_dimension); + } + + overworldData = new WorldDataServer(worldsettings, generatorsettings, Lifecycle.stable()); + } + -+ GeneratorSettings overworldSettings = overworldData.getGeneratorSettings(); -+ RegistryMaterials<WorldDimension> registrymaterials = overworldSettings.d(); -+ for (Entry<ResourceKey<WorldDimension>, WorldDimension> entry : registrymaterials.d()) { ++ GeneratorSettings overworldSettings = overworldData.worldGenSettings(); ++ RegistryMaterials<WorldDimension> registrymaterials = overworldSettings.dimensions(); ++ for (Entry<ResourceKey<WorldDimension>, WorldDimension> entry : registrymaterials.entrySet()) { + ResourceKey<WorldDimension> dimensionKey = entry.getKey(); + + WorldServer world; + int dimension = 0; - -- this.a(worldloadlistener); ++ + if (dimensionKey == WorldDimension.NETHER) { -+ if (getAllowNether()) { ++ if (isNetherEnabled()) { + dimension = -1; + } else { + continue; @@ -182,11 +211,11 @@ + dimension = -999; + } + -+ String worldType = (dimension == -999) ? dimensionKey.a().getNamespace() + "_" + dimensionKey.a().getKey() : org.bukkit.World.Environment.getEnvironment(dimension).toString().toLowerCase(); ++ String worldType = (dimension == -999) ? dimensionKey.location().getNamespace() + "_" + dimensionKey.location().getPath() : org.bukkit.World.Environment.getEnvironment(dimension).toString().toLowerCase(); + String name = (dimensionKey == WorldDimension.OVERWORLD) ? s : s + "_" + worldType; + if (dimension != 0) { -+ File newWorld = Convertable.getFolder(new File(name), dimensionKey); -+ File oldWorld = Convertable.getFolder(new File(s), dimensionKey); ++ File newWorld = Convertable.getStorageFolder(new File(name).toPath(), dimensionKey).toFile(); ++ File oldWorld = Convertable.getStorageFolder(new File(s).toPath(), dimensionKey).toFile(); + File oldLevelDat = new File(new File(s), "level.dat"); // The data folders exist on first run as they are created in the PersistentCollection constructor above, but the level.dat won't + + if (!newWorld.isDirectory() && oldWorld.isDirectory() && oldLevelDat.isFile()) { @@ -220,58 +249,55 @@ + } + + try { -+ worldSession = Convertable.a(server.getWorldContainer().toPath()).c(name, dimensionKey); ++ worldSession = Convertable.createDefault(server.getWorldContainer().toPath()).createAccess(name, dimensionKey); + } catch (IOException ex) { + throw new RuntimeException(ex); + } -+ MinecraftServer.convertWorld(worldSession); // Run conversion now + } + + org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name); + org.bukkit.generator.BiomeProvider biomeProvider = this.server.getBiomeProvider(name); + -+ WorldDataServer worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, datapackconfiguration); ++ WorldDataServer worlddata = (WorldDataServer) worldSession.getDataTag((DynamicOps) registryreadops, datapackconfiguration); + if (worlddata == null) { + WorldSettings worldsettings; + GeneratorSettings generatorsettings; + -+ if (this.isDemoMode()) { ++ if (this.isDemo()) { + worldsettings = MinecraftServer.DEMO_SETTINGS; -+ generatorsettings = GeneratorSettings.a((IRegistryCustom) iregistrycustom_dimension); ++ generatorsettings = GeneratorSettings.demoSettings(iregistrycustom_dimension); + } else { -+ DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getDedicatedServerProperties(); ++ DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getProperties(); + + worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), datapackconfiguration); -+ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.a((IRegistryCustom) iregistrycustom_dimension).j() : dedicatedserverproperties.a((IRegistryCustom) iregistrycustom_dimension); ++ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.getWorldGenSettings(iregistrycustom_dimension).withBonusChest() : dedicatedserverproperties.getWorldGenSettings(iregistrycustom_dimension); + } + + worlddata = new WorldDataServer(worldsettings, generatorsettings, Lifecycle.stable()); + } + 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.convertWorld(worldSession, DataConverterRegistry.a(), options.has("eraseCache"), () -> { ++ net.minecraft.server.Main.forceUpgrade(worldSession, DataConverterRegistry.getDataFixer(), options.has("eraseCache"), () -> { + return true; -+ }, worlddata.getGeneratorSettings().d().d().stream().map((entry1) -> { -+ return ResourceKey.a(IRegistry.DIMENSION_TYPE_REGISTRY, ((ResourceKey) entry1.getKey()).a()); -+ }).collect(ImmutableSet.toImmutableSet())); ++ }, worlddata.worldGenSettings()); + } + + IWorldDataServer iworlddataserver = worlddata; -+ GeneratorSettings generatorsettings = worlddata.getGeneratorSettings(); -+ boolean flag = generatorsettings.isDebugWorld(); -+ long i = generatorsettings.getSeed(); -+ long j = BiomeManager.a(i); ++ GeneratorSettings generatorsettings = worlddata.worldGenSettings(); ++ boolean flag = generatorsettings.isDebug(); ++ long i = generatorsettings.seed(); ++ long j = BiomeManager.obfuscateSeed(i); + List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver)); -+ WorldDimension worlddimension = (WorldDimension) registrymaterials.a(dimensionKey); ++ WorldDimension worlddimension = (WorldDimension) registrymaterials.get(WorldDimension.OVERWORLD); + DimensionManager dimensionmanager; + ChunkGenerator chunkgenerator; + + if (worlddimension == null) { -+ dimensionmanager = (DimensionManager) this.registryHolder.d(IRegistry.DIMENSION_TYPE_REGISTRY).d(DimensionManager.OVERWORLD_LOCATION); -+ chunkgenerator = GeneratorSettings.a(this.registryHolder.d(IRegistry.BIOME_REGISTRY), this.registryHolder.d(IRegistry.NOISE_GENERATOR_SETTINGS_REGISTRY), (new Random()).nextLong()); ++ dimensionmanager = (DimensionManager) this.registryHolder.registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrThrow(DimensionManager.OVERWORLD_LOCATION); ++ chunkgenerator = GeneratorSettings.makeDefaultOverworld(this.registryHolder, (new Random()).nextLong()); + } else { -+ dimensionmanager = worlddimension.b(); -+ chunkgenerator = worlddimension.c(); ++ dimensionmanager = worlddimension.type(); ++ chunkgenerator = worlddimension.generator(); + } + + org.bukkit.generator.WorldInfo worldInfo = new org.bukkit.craftbukkit.generator.CraftWorldInfo(iworlddataserver, worldSession, org.bukkit.World.Environment.getEnvironment(dimension), dimensionmanager); @@ -280,23 +306,23 @@ + } + + if (biomeProvider != null) { -+ WorldChunkManager worldChunkManager = new CustomWorldChunkManager(worldInfo, biomeProvider, registryHolder.b(IRegistry.BIOME_REGISTRY)); ++ WorldChunkManager worldChunkManager = new CustomWorldChunkManager(worldInfo, biomeProvider, registryHolder.ownedRegistryOrThrow(IRegistry.BIOME_REGISTRY)); + if (chunkgenerator instanceof ChunkGeneratorAbstract) { -+ chunkgenerator = new ChunkGeneratorAbstract(worldChunkManager, chunkgenerator.strongholdSeed, ((ChunkGeneratorAbstract) chunkgenerator).settings); ++ chunkgenerator = new ChunkGeneratorAbstract(((ChunkGeneratorAbstract) chunkgenerator).noises, worldChunkManager, chunkgenerator.strongholdSeed, ((ChunkGeneratorAbstract) chunkgenerator).settings); + } + } + -+ ResourceKey<World> worldKey = ResourceKey.a(IRegistry.DIMENSION_REGISTRY, dimensionKey.a()); ++ ResourceKey<World> worldKey = ResourceKey.create(IRegistry.DIMENSION_REGISTRY, dimensionKey.location()); + + if (dimensionKey == WorldDimension.OVERWORLD) { + this.worldData = worlddata; -+ this.worldData.setGameType(((DedicatedServer) this).getDedicatedServerProperties().gamemode); // From DedicatedServer.init ++ this.worldData.setGameType(((DedicatedServer) this).getProperties().gamemode); // From DedicatedServer.init + + WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11); + + world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, list, true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider); -+ WorldPersistentData worldpersistentdata = world.getWorldPersistentData(); -+ this.initializeScoreboards(worldpersistentdata); ++ WorldPersistentData worldpersistentdata = world.getDataStorage(); ++ this.readScoreboard(worldpersistentdata); + this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard()); + this.commandStorage = new PersistentCommandStorage(worldpersistentdata); + } else { @@ -304,108 +330,84 @@ + world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider); + } + -+ worlddata.a(this.getServerModName(), this.getModded().isPresent()); -+ this.initWorld(world, worlddata, worldData, worlddata.getGeneratorSettings()); ++ worlddata.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified()); ++ this.initWorld(world, worlddata, worldData, worlddata.worldGenSettings()); + -+ this.levels.put(world.getDimensionKey(), world); -+ this.getPlayerList().setPlayerFileData(world); ++ this.levels.put(world.dimension(), world); ++ this.getPlayerList().addWorldborderListener(world); + + if (worlddata.getCustomBossEvents() != null) { -+ this.getBossBattleCustomData().load(worlddata.getCustomBossEvents()); ++ this.getCustomBossEvents().load(worlddata.getCustomBossEvents()); + } + } - this.updateWorldSettings(); -- this.loadSpawn(worldloadlistener); -+ for (WorldServer worldserver : this.getWorlds()) { -+ this.loadSpawn(worldserver.getChunkProvider().chunkMap.progressListener, worldserver); ++ this.forceDifficulty(); ++ for (WorldServer worldserver : this.getAllLevels()) { ++ this.prepareLevels(worldserver.getChunkSource().chunkMap.progressListener, worldserver); + worldserver.entityManager.tick(); // SPIGOT-6526: Load pending entities so they are available to the API + this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(worldserver.getWorld())); -+ } -+ + } + +- WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, dimensionmanager, worldloadlistener, (ChunkGenerator) object, flag, j, list, true); + this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD); + this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP)); + this.connection.acceptConnections(); -+ // CraftBukkit end - } ++ } ++ // CraftBukkit end - protected void updateWorldSettings() {} +- this.levels.put(World.OVERWORLD, worldserver); +- WorldPersistentData worldpersistentdata = worldserver.getDataStorage(); ++ protected void forceDifficulty() {} -- protected void a(WorldLoadListener worldloadlistener) { -- IWorldDataServer iworlddataserver = this.worldData.H(); -- GeneratorSettings generatorsettings = this.worldData.getGeneratorSettings(); +- this.readScoreboard(worldpersistentdata); +- this.commandStorage = new PersistentCommandStorage(worldpersistentdata); + // CraftBukkit start + public void initWorld(WorldServer worldserver, IWorldDataServer iworlddataserver, SaveData saveData, GeneratorSettings generatorsettings) { - boolean flag = generatorsettings.isDebugWorld(); -- long i = generatorsettings.getSeed(); -- long j = BiomeManager.a(i); -- List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver)); -- RegistryMaterials<WorldDimension> registrymaterials = generatorsettings.d(); -- WorldDimension worlddimension = (WorldDimension) registrymaterials.a(WorldDimension.OVERWORLD); -- DimensionManager dimensionmanager; -- Object object; -- -- if (worlddimension == null) { -- dimensionmanager = (DimensionManager) this.registryHolder.d(IRegistry.DIMENSION_TYPE_REGISTRY).d(DimensionManager.OVERWORLD_LOCATION); -- object = GeneratorSettings.a(this.registryHolder.d(IRegistry.BIOME_REGISTRY), this.registryHolder.d(IRegistry.NOISE_GENERATOR_SETTINGS_REGISTRY), (new Random()).nextLong()); -- } else { -- dimensionmanager = worlddimension.b(); -- object = worlddimension.c(); ++ boolean flag = generatorsettings.isDebug(); + // CraftBukkit start + if (worldserver.generator != null) { + worldserver.getWorld().getPopulators().addAll(worldserver.generator.getDefaultPopulators(worldserver.getWorld())); - } -- -- WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, dimensionmanager, worldloadlistener, (ChunkGenerator) object, flag, j, list, true); -- -- this.levels.put(World.OVERWORLD, worldserver); -- WorldPersistentData worldpersistentdata = worldserver.getWorldPersistentData(); -- -- this.initializeScoreboards(worldpersistentdata); -- this.commandStorage = new PersistentCommandStorage(worldpersistentdata); ++ } WorldBorder worldborder = worldserver.getWorldBorder(); - worldborder.a(iworlddataserver.r()); -+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(worldserver.getWorld())); // CraftBukkit - SPIGOT-5569 - if (!iworlddataserver.p()) { - try { - a(worldserver, iworlddataserver, generatorsettings.c(), flag); -@@ -421,31 +646,8 @@ - - iworlddataserver.c(true); + if (!iworlddataserver.isInitialized()) { +@@ -411,31 +637,10 @@ + iworlddataserver.setInitialized(true); } -- -- this.getPlayerList().setPlayerFileData(worldserver); + +- this.getPlayerList().addWorldborderListener(worldserver); - if (this.worldData.getCustomBossEvents() != null) { -- this.getBossBattleCustomData().load(this.worldData.getCustomBossEvents()); +- this.getCustomBossEvents().load(this.worldData.getCustomBossEvents()); - } - -- Iterator iterator = registrymaterials.d().iterator(); +- Iterator iterator = registrymaterials.entrySet().iterator(); - - while (iterator.hasNext()) { - Entry<ResourceKey<WorldDimension>, WorldDimension> entry = (Entry) iterator.next(); - ResourceKey<WorldDimension> resourcekey = (ResourceKey) entry.getKey(); - - if (resourcekey != WorldDimension.OVERWORLD) { -- ResourceKey<World> resourcekey1 = ResourceKey.a(IRegistry.DIMENSION_REGISTRY, resourcekey.a()); -- DimensionManager dimensionmanager1 = ((WorldDimension) entry.getValue()).b(); -- ChunkGenerator chunkgenerator = ((WorldDimension) entry.getValue()).c(); +- ResourceKey<World> resourcekey1 = ResourceKey.create(IRegistry.DIMENSION_REGISTRY, resourcekey.location()); +- DimensionManager dimensionmanager1 = ((WorldDimension) entry.getValue()).type(); +- ChunkGenerator chunkgenerator = ((WorldDimension) entry.getValue()).generator(); - SecondaryWorldData secondaryworlddata = new SecondaryWorldData(this.worldData, iworlddataserver); - WorldServer worldserver1 = new WorldServer(this, this.executor, this.storageSource, secondaryworlddata, resourcekey1, dimensionmanager1, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), false); - -- worldborder.a((IWorldBorderListener) (new IWorldBorderListener.a(worldserver1.getWorldBorder()))); +- worldborder.addListener(new IWorldBorderListener.a(worldserver1.getWorldBorder())); - this.levels.put(resourcekey1, worldserver1); - } - } - + worldborder.applySettings(iworlddataserver.getWorldBorder()); ++ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(worldserver.getWorld())); // CraftBukkit - SPIGOT-5569 } + // CraftBukkit end - private static void a(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) { + private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) { if (flag1) { -@@ -458,6 +660,21 @@ - return biomebase.b().b(); - }, random); - ChunkCoordIntPair chunkcoordintpair = blockposition == null ? new ChunkCoordIntPair(0, 0) : new ChunkCoordIntPair(blockposition); +@@ -443,6 +648,21 @@ + } else { + ChunkGenerator chunkgenerator = worldserver.getChunkSource().getGenerator(); + ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkgenerator.climateSampler().findSpawnPosition()); + // CraftBukkit start + if (worldserver.generator != null) { + Random rand = new Random(worldserver.getSeed()); @@ -413,7 +415,7 @@ + + if (spawn != null) { + if (spawn.getWorld() != worldserver.getWorld()) { -+ throw new IllegalStateException("Cannot set spawn point for " + iworlddataserver.getName() + " to be in another world (" + spawn.getWorld().getName() + ")"); ++ throw new IllegalStateException("Cannot set spawn point for " + iworlddataserver.getLevelName() + " to be in another world (" + spawn.getWorld().getName() + ")"); + } else { + iworlddataserver.setSpawn(new BlockPosition(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ()), spawn.getYaw()); + return; @@ -421,97 +423,97 @@ + } + } + // CraftBukkit end + int i = chunkgenerator.getSpawnHeight(worldserver); - if (blockposition == null) { - MinecraftServer.LOGGER.warn("Unable to find spawn biome"); -@@ -532,8 +749,15 @@ + if (i < worldserver.getMinBuildHeight()) { +@@ -500,8 +720,15 @@ iworlddataserver.setGameType(EnumGamemode.SPECTATOR); } -- public void loadSpawn(WorldLoadListener worldloadlistener) { -- WorldServer worldserver = this.E(); +- public void prepareLevels(WorldLoadListener worldloadlistener) { +- WorldServer worldserver = this.overworld(); + // CraftBukkit start -+ public void loadSpawn(WorldLoadListener worldloadlistener, WorldServer worldserver) { ++ public void prepareLevels(WorldLoadListener worldloadlistener, WorldServer worldserver) { + if (!worldserver.getWorld().getKeepSpawnInMemory()) { + return; + } + -+ // WorldServer worldserver = this.E(); ++ // WorldServer worldserver = this.overworld(); + this.forceTicks = true; + // CraftBukkit end - MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.getDimensionKey().a()); - BlockPosition blockposition = worldserver.getSpawn(); -@@ -546,16 +770,20 @@ - chunkproviderserver.addTicket(TicketType.START, new ChunkCoordIntPair(blockposition), 11, Unit.INSTANCE); + MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location()); + BlockPosition blockposition = worldserver.getSharedSpawnPos(); +@@ -514,16 +741,20 @@ + chunkproviderserver.addRegionTicket(TicketType.START, new ChunkCoordIntPair(blockposition), 11, Unit.INSTANCE); - while (chunkproviderserver.b() != 441) { -- this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L; -- this.sleepForTick(); + while (chunkproviderserver.getTickingGenerated() != 441) { +- this.nextTickTime = SystemUtils.getMillis() + 10L; +- this.waitUntilNextTick(); + // CraftBukkit start -+ // this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L; ++ // this.nextTickTime = SystemUtils.getMillis() + 10L; + this.executeModerately(); + // CraftBukkit end } -- this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L; -- this.sleepForTick(); +- this.nextTickTime = SystemUtils.getMillis() + 10L; +- this.waitUntilNextTick(); - Iterator iterator = this.levels.values().iterator(); - - while (iterator.hasNext()) { - WorldServer worldserver1 = (WorldServer) iterator.next(); + // CraftBukkit start -+ // this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L; ++ // this.nextTickTime = SystemUtils.getMillis() + 10L; + this.executeModerately(); -+ // Iterator iterator = this.worldServer.values().iterator(); ++ // Iterator iterator = this.levels.values().iterator(); + + if (true) { + WorldServer worldserver1 = worldserver; + // CraftBukkit end - ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getWorldPersistentData().a(ForcedChunk::b, "chunks"); + ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk::load, "chunks"); if (forcedchunk != null) { -@@ -570,11 +798,18 @@ +@@ -538,11 +769,18 @@ } } -- this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L; -- this.sleepForTick(); +- this.nextTickTime = SystemUtils.getMillis() + 10L; +- this.waitUntilNextTick(); + // CraftBukkit start -+ // this.nextTick = SystemUtils.getMonotonicMillis() + 10L; ++ // this.nextTickTime = SystemUtils.getMillis() + 10L; + this.executeModerately(); + // CraftBukkit end - worldloadlistener.b(); - chunkproviderserver.getLightEngine().a(5); -- this.updateSpawnFlags(); + worldloadlistener.stop(); + chunkproviderserver.getLightEngine().setTaskPerBatch(5); +- this.updateMobSpawningFlags(); + // CraftBukkit start -+ // this.updateSpawnFlags(); -+ worldserver.setSpawnFlags(this.getSpawnMonsters(), this.getSpawnAnimals()); ++ // this.updateMobSpawningFlags(); ++ worldserver.setSpawnSettings(this.isSpawningMonsters(), this.isSpawningAnimals()); + + this.forceTicks = false; + // CraftBukkit end } - protected void loadResourcesZip() { -@@ -619,12 +854,16 @@ + protected void detectBundledResources() { +@@ -587,12 +825,16 @@ worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2); } + // CraftBukkit start - moved to WorldServer.save + /* - WorldServer worldserver1 = this.E(); - IWorldDataServer iworlddataserver = this.worldData.H(); + WorldServer worldserver1 = this.overworld(); + IWorldDataServer iworlddataserver = this.worldData.overworldData(); - iworlddataserver.a(worldserver1.getWorldBorder().t()); - this.worldData.setCustomBossEvents(this.getBossBattleCustomData().save()); - this.storageSource.a(this.registryHolder, this.worldData, this.getPlayerList().save()); + iworlddataserver.setWorldBorder(worldserver1.getWorldBorder().createSettings()); + this.worldData.setCustomBossEvents(this.getCustomBossEvents().save()); + this.storageSource.saveDataTag(this.registryHolder, this.worldData, this.getPlayerList().getSingleplayerData()); + */ + // CraftBukkit end if (flag1) { - Iterator iterator1 = this.getWorlds().iterator(); + Iterator iterator1 = this.getAllLevels().iterator(); -@@ -645,8 +884,29 @@ - this.stop(); +@@ -627,8 +869,29 @@ + this.stopServer(); } + // CraftBukkit start @@ -524,7 +526,7 @@ + } + // CraftBukkit end + - public void stop() { + public void stopServer() { + // CraftBukkit start - prevent double stopping on multiple threads + synchronized(stopLock) { + if (hasStopped) return; @@ -537,20 +539,20 @@ + this.server.disablePlugins(); + } + // CraftBukkit end - if (this.getServerConnection() != null) { - this.getServerConnection().b(); + if (this.getConnection() != null) { + this.getConnection().stop(); } -@@ -655,6 +915,7 @@ +@@ -638,6 +901,7 @@ MinecraftServer.LOGGER.info("Saving players"); - this.playerList.savePlayers(); - this.playerList.shutdown(); + this.playerList.saveAll(); + this.playerList.removeAll(); + try { Thread.sleep(100); } catch (InterruptedException ex) {} // CraftBukkit - SPIGOT-625 - give server at least a chance to send packets } MinecraftServer.LOGGER.info("Saving worlds"); -@@ -732,9 +993,10 @@ +@@ -712,9 +976,10 @@ while (this.running) { - long i = SystemUtils.getMonotonicMillis() - this.nextTickTime; + long i = SystemUtils.getMillis() - this.nextTickTime; - if (i > 2000L && this.nextTickTime - this.lastOverloadWarning >= 15000L) { + if (i > 5000L && this.nextTickTime - this.lastOverloadWarning >= 30000L) { // CraftBukkit @@ -560,62 +562,71 @@ MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j); this.nextTickTime += j * 50L; this.lastOverloadWarning = this.nextTickTime; -@@ -745,6 +1007,7 @@ - this.debugCommandProfiler = new MinecraftServer.a(SystemUtils.getMonotonicNanos(), this.tickCount); +@@ -725,6 +990,7 @@ + this.debugCommandProfiler = new MinecraftServer.a(SystemUtils.getNanos(), this.tickCount); } + MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit this.nextTickTime += 50L; - this.bh(); - this.profiler.enter("tick"); -@@ -790,6 +1053,12 @@ - } catch (Throwable throwable1) { - MinecraftServer.LOGGER.error("Exception stopping the server", throwable1); - } finally { + this.startMetricsRecordingTick(); + this.profiler.push("tick"); +@@ -775,6 +1041,12 @@ + this.profileCache.clearExecutor(); + } + + // CraftBukkit start - Restore terminal to original settings + try { + reader.getTerminal().restore(); + } catch (Exception ignored) { + } + // CraftBukkit end - this.exit(); + this.onServerExit(); } -@@ -798,8 +1067,15 @@ +@@ -783,8 +1055,15 @@ } - private boolean canSleepForTick() { -- return this.isEntered() || SystemUtils.getMonotonicMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime); + private boolean haveTime() { +- return this.runningTask() || SystemUtils.getMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime); + // CraftBukkit start -+ return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime); ++ return this.forceTicks || this.runningTask() || SystemUtils.getMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime); + } + + private void executeModerately() { -+ this.executeAll(); ++ this.runAllTasks(); + java.util.concurrent.locks.LockSupport.parkNanos("executing tasks", 1000L); } + // CraftBukkit end - protected void sleepForTick() { - this.executeAll(); -@@ -908,7 +1184,7 @@ - this.status.b().a(agameprofile); + protected void waitUntilNextTick() { + this.runAllTasks(); +@@ -830,7 +1109,7 @@ + } + } + +- protected void doRunTask(TickTask ticktask) { ++ public void doRunTask(TickTask ticktask) { // CraftBukkit - decompile error + this.getProfiler().incrementCounter("runTask"); + super.doRunTask(ticktask); + } +@@ -901,7 +1180,7 @@ + } } - if (this.tickCount % 6000 == 0) { + if (autosavePeriod > 0 && this.tickCount % autosavePeriod == 0) { // CraftBukkit MinecraftServer.LOGGER.debug("Autosave started"); - this.profiler.enter("save"); - this.playerList.savePlayers(); -@@ -938,22 +1214,39 @@ + this.profiler.push("save"); + this.saveEverything(true, false, false); +@@ -920,22 +1199,39 @@ } - public void b(BooleanSupplier booleansupplier) { + public void tickChildren(BooleanSupplier booleansupplier) { + this.server.getScheduler().mainThreadHeartbeat(this.tickCount); // CraftBukkit - this.profiler.enter("commandFunctions"); - this.getFunctionData().tick(); - this.profiler.exitEnter("levels"); - Iterator iterator = this.getWorlds().iterator(); + this.profiler.push("commandFunctions"); + this.getFunctions().tick(); + this.profiler.popPush("levels"); + Iterator iterator = this.getAllLevels().iterator(); + // CraftBukkit start + // Run tasks that are waiting on processing @@ -627,27 +638,27 @@ + if (this.tickCount % 20 == 0) { + for (int i = 0; i < this.getPlayerList().players.size(); ++i) { + EntityPlayer entityplayer = (EntityPlayer) this.getPlayerList().players.get(i); -+ entityplayer.connection.sendPacket(new PacketPlayOutUpdateTime(entityplayer.level.getTime(), entityplayer.getPlayerTime(), entityplayer.level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); // Add support for per player time ++ entityplayer.connection.send(new PacketPlayOutUpdateTime(entityplayer.level.getGameTime(), entityplayer.getPlayerTime(), entityplayer.level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); // Add support for per player time + } + } + while (iterator.hasNext()) { WorldServer worldserver = (WorldServer) iterator.next(); - this.profiler.a(() -> { - return worldserver + " " + worldserver.getDimensionKey().a(); + this.profiler.push(() -> { + return worldserver + " " + worldserver.dimension().location(); }); + /* Drop global time updates if (this.tickCount % 20 == 0) { - this.profiler.enter("timeSync"); - this.playerList.a((Packet) (new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))), worldserver.getDimensionKey()); - this.profiler.exit(); + this.profiler.push("timeSync"); + this.playerList.broadcastAll(new PacketPlayOutUpdateTime(worldserver.getGameTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)), worldserver.dimension()); + this.profiler.pop(); } + // CraftBukkit end */ - this.profiler.enter("tick"); + this.profiler.push("tick"); -@@ -1042,7 +1335,7 @@ +@@ -1024,7 +1320,7 @@ @DontObfuscate public String getServerModName() { @@ -655,35 +666,44 @@ + return server.getName(); // CraftBukkit - cb > vanilla! } - public SystemReport b(SystemReport systemreport) { -@@ -1414,16 +1707,17 @@ + public SystemReport fillSystemReport(SystemReport systemreport) { +@@ -1351,16 +1647,17 @@ - public CompletableFuture<Void> a(Collection<String> collection) { + public CompletableFuture<Void> reloadResources(Collection<String> collection) { CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> { - Stream stream = collection.stream(); + Stream<String> stream = collection.stream(); // CraftBukkit - decompile error ResourcePackRepository resourcepackrepository = this.packRepository; Objects.requireNonNull(this.packRepository); -- return (ImmutableList) stream.map(resourcepackrepository::a).filter(Objects::nonNull).map(ResourcePackLoader::d).collect(ImmutableList.toImmutableList()); -+ return stream.map(resourcepackrepository::a).filter(Objects::nonNull).map(ResourcePackLoader::d).collect(ImmutableList.toImmutableList()); // CraftBukkit - decompile error +- 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) -> { - return DataPackResources.a(immutablelist, this.registryHolder, this.k() ? CommandDispatcher.ServerType.DEDICATED : CommandDispatcher.ServerType.INTEGRATED, this.i(), this.executor, this); + return DataPackResources.loadResources(immutablelist, this.registryHolder, this.isDedicatedServer() ? CommandDispatcher.ServerType.DEDICATED : CommandDispatcher.ServerType.INTEGRATED, this.getFunctionCompilationLevel(), this.executor, this); }).thenAcceptAsync((datapackresources) -> { this.resources.close(); this.resources = datapackresources; + this.server.syncCommands(); // SPIGOT-5884: Lost on reload - this.packRepository.a(collection); - this.worldData.a(a(this.packRepository)); - datapackresources.j(); -@@ -1768,6 +2062,22 @@ + this.packRepository.setSelected(collection); + this.worldData.setDataPackConfig(getSelectedPacks(this.packRepository)); + datapackresources.updateGlobals(); +@@ -1714,7 +2011,7 @@ + try { + label51: + { +- ArrayList arraylist; ++ ArrayList<NativeModuleLister.a> arraylist; // CraftBukkit - decompile error + + try { + arraylist = Lists.newArrayList(NativeModuleLister.listModules()); +@@ -1764,6 +2061,22 @@ } + // CraftBukkit start + @Override -+ public boolean isMainThread() { -+ return super.isMainThread() || this.isStopped(); // CraftBukkit - MC-142590 ++ public boolean isSameThread() { ++ return super.isSameThread() || this.isStopped(); // CraftBukkit - MC-142590 + } + + public boolean isDebugging() { @@ -696,6 +716,6 @@ + } + // CraftBukkit end + - private void bh() { + private void startMetricsRecordingTick() { if (this.willStartRecordingMetrics) { - this.metricsRecorder = ActiveMetricsRecorder.a(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.k()), SystemUtils.timeSource, SystemUtils.g(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> { + this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> { diff --git a/paper-server/nms-patches/net/minecraft/server/ScoreboardServer.patch b/paper-server/nms-patches/net/minecraft/server/ScoreboardServer.patch index 7f7fcf3d45..7625398a4b 100644 --- a/paper-server/nms-patches/net/minecraft/server/ScoreboardServer.patch +++ b/paper-server/nms-patches/net/minecraft/server/ScoreboardServer.patch @@ -1,100 +1,100 @@ --- a/net/minecraft/server/ScoreboardServer.java +++ b/net/minecraft/server/ScoreboardServer.java @@ -34,7 +34,7 @@ - public void handleScoreChanged(ScoreboardScore scoreboardscore) { - super.handleScoreChanged(scoreboardscore); + public void onScoreChanged(ScoreboardScore scoreboardscore) { + super.onScoreChanged(scoreboardscore); if (this.trackedObjectives.contains(scoreboardscore.getObjective())) { -- this.server.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, scoreboardscore.getObjective().getName(), scoreboardscore.getPlayerName(), scoreboardscore.getScore())); -+ this.sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, scoreboardscore.getObjective().getName(), scoreboardscore.getPlayerName(), scoreboardscore.getScore())); +- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, scoreboardscore.getObjective().getName(), scoreboardscore.getOwner(), scoreboardscore.getScore())); ++ this.broadcastAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, scoreboardscore.getObjective().getName(), scoreboardscore.getOwner(), scoreboardscore.getScore())); } - this.a(); + this.setDirty(); @@ -43,7 +43,7 @@ @Override - public void handlePlayerRemoved(String s) { - super.handlePlayerRemoved(s); -- this.server.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, (String) null, s, 0)); -+ this.sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, (String) null, s, 0)); - this.a(); + public void onPlayerRemoved(String s) { + super.onPlayerRemoved(s); +- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, (String) null, s, 0)); ++ this.broadcastAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, (String) null, s, 0)); + this.setDirty(); } @@ -51,7 +51,7 @@ - public void a(String s, ScoreboardObjective scoreboardobjective) { - super.a(s, scoreboardobjective); + public void onPlayerScoreRemoved(String s, ScoreboardObjective scoreboardobjective) { + super.onPlayerScoreRemoved(s, scoreboardobjective); if (this.trackedObjectives.contains(scoreboardobjective)) { -- this.server.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, scoreboardobjective.getName(), s, 0)); -+ this.sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, scoreboardobjective.getName(), s, 0)); +- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, scoreboardobjective.getName(), s, 0)); ++ this.broadcastAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, scoreboardobjective.getName(), s, 0)); } - this.a(); + this.setDirty(); @@ -64,7 +64,7 @@ - super.setDisplaySlot(i, scoreboardobjective); + super.setDisplayObjective(i, scoreboardobjective); if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) { - if (this.h(scoreboardobjective1) > 0) { -- this.server.getPlayerList().sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); -+ this.sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); + if (this.getObjectiveDisplaySlotCount(scoreboardobjective1) > 0) { +- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); ++ this.broadcastAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); } else { - this.g(scoreboardobjective1); + this.stopTrackingObjective(scoreboardobjective1); } @@ -72,7 +72,7 @@ if (scoreboardobjective != null) { if (this.trackedObjectives.contains(scoreboardobjective)) { -- this.server.getPlayerList().sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); -+ this.sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); +- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); ++ this.broadcastAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); } else { - this.e(scoreboardobjective); + this.startTrackingObjective(scoreboardobjective); } @@ -84,7 +84,7 @@ @Override public boolean addPlayerToTeam(String s, ScoreboardTeam scoreboardteam) { if (super.addPlayerToTeam(s, scoreboardteam)) { -- this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.ADD)); -+ this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.ADD)); - this.a(); +- this.server.getPlayerList().broadcastAll(PacketPlayOutScoreboardTeam.createPlayerPacket(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.ADD)); ++ this.broadcastAll(PacketPlayOutScoreboardTeam.createPlayerPacket(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.ADD)); + this.setDirty(); return true; } else { @@ -95,7 +95,7 @@ @Override public void removePlayerFromTeam(String s, ScoreboardTeam scoreboardteam) { super.removePlayerFromTeam(s, scoreboardteam); -- this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.REMOVE)); -+ this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.REMOVE)); - this.a(); +- this.server.getPlayerList().broadcastAll(PacketPlayOutScoreboardTeam.createPlayerPacket(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.REMOVE)); ++ this.broadcastAll(PacketPlayOutScoreboardTeam.createPlayerPacket(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.REMOVE)); + this.setDirty(); } @@ -109,7 +109,7 @@ - public void handleObjectiveChanged(ScoreboardObjective scoreboardobjective) { - super.handleObjectiveChanged(scoreboardobjective); + public void onObjectiveChanged(ScoreboardObjective scoreboardobjective) { + super.onObjectiveChanged(scoreboardobjective); if (this.trackedObjectives.contains(scoreboardobjective)) { -- this.server.getPlayerList().sendAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2)); -+ this.sendAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2)); +- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2)); ++ this.broadcastAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2)); } - this.a(); + this.setDirty(); @@ -128,21 +128,21 @@ @Override - public void handleTeamAdded(ScoreboardTeam scoreboardteam) { - super.handleTeamAdded(scoreboardteam); -- this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, true)); -+ this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, true)); - this.a(); + public void onTeamAdded(ScoreboardTeam scoreboardteam) { + super.onTeamAdded(scoreboardteam); +- this.server.getPlayerList().broadcastAll(PacketPlayOutScoreboardTeam.createAddOrModifyPacket(scoreboardteam, true)); ++ this.broadcastAll(PacketPlayOutScoreboardTeam.createAddOrModifyPacket(scoreboardteam, true)); + this.setDirty(); } @Override - public void handleTeamChanged(ScoreboardTeam scoreboardteam) { - super.handleTeamChanged(scoreboardteam); -- this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, false)); -+ this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, false)); - this.a(); + public void onTeamChanged(ScoreboardTeam scoreboardteam) { + super.onTeamChanged(scoreboardteam); +- this.server.getPlayerList().broadcastAll(PacketPlayOutScoreboardTeam.createAddOrModifyPacket(scoreboardteam, false)); ++ this.broadcastAll(PacketPlayOutScoreboardTeam.createAddOrModifyPacket(scoreboardteam, false)); + this.setDirty(); } @Override - public void handleTeamRemoved(ScoreboardTeam scoreboardteam) { - super.handleTeamRemoved(scoreboardteam); -- this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam)); -+ this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam)); - this.a(); + public void onTeamRemoved(ScoreboardTeam scoreboardteam) { + super.onTeamRemoved(scoreboardteam); +- this.server.getPlayerList().broadcastAll(PacketPlayOutScoreboardTeam.createRemovePacket(scoreboardteam)); ++ this.broadcastAll(PacketPlayOutScoreboardTeam.createRemovePacket(scoreboardteam)); + this.setDirty(); } @@ -189,6 +189,7 @@ @@ -114,14 +114,14 @@ while (iterator1.hasNext()) { @@ -257,6 +259,16 @@ - return this.b().b(nbttagcompound); + return this.createData().load(nbttagcompound); } + // CraftBukkit start - Send to players -+ private void sendAll(Packet packet) { ++ private void broadcastAll(Packet packet) { + for (EntityPlayer entityplayer : (List<EntityPlayer>) this.server.getPlayerList().players) { + if (entityplayer.getBukkitEntity().getScoreboard().getHandle() == this) { -+ entityplayer.connection.sendPacket(packet); ++ entityplayer.connection.send(packet); + } + } + } diff --git a/paper-server/nms-patches/net/minecraft/server/commands/CommandEffect.patch b/paper-server/nms-patches/net/minecraft/server/commands/CommandEffect.patch index 04b9eb3e42..9de0636aa6 100644 --- a/paper-server/nms-patches/net/minecraft/server/commands/CommandEffect.patch +++ b/paper-server/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 -@@ -73,7 +73,7 @@ +@@ -72,7 +72,7 @@ if (entity instanceof EntityLiving) { MobEffect mobeffect = new MobEffect(mobeffectlist, k, i, false, flag); @@ -9,7 +9,7 @@ ++j; } } -@@ -99,7 +99,7 @@ +@@ -98,7 +98,7 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); @@ -18,7 +18,7 @@ ++i; } } -@@ -124,7 +124,7 @@ +@@ -123,7 +123,7 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); diff --git a/paper-server/nms-patches/net/minecraft/server/commands/CommandGamerule.patch b/paper-server/nms-patches/net/minecraft/server/commands/CommandGamerule.patch index ac5aa4d311..f932ae5759 100644 --- a/paper-server/nms-patches/net/minecraft/server/commands/CommandGamerule.patch +++ b/paper-server/nms-patches/net/minecraft/server/commands/CommandGamerule.patch @@ -2,19 +2,19 @@ +++ b/net/minecraft/server/commands/CommandGamerule.java @@ -31,7 +31,7 @@ - static <T extends GameRules.GameRuleValue<T>> int a(CommandContext<CommandListenerWrapper> commandcontext, GameRules.GameRuleKey<T> gamerules_gamerulekey) { + static <T extends GameRules.GameRuleValue<T>> int setRule(CommandContext<CommandListenerWrapper> commandcontext, GameRules.GameRuleKey<T> gamerules_gamerulekey) { CommandListenerWrapper commandlistenerwrapper = (CommandListenerWrapper) commandcontext.getSource(); -- T t0 = commandlistenerwrapper.getServer().getGameRules().get(gamerules_gamerulekey); -+ T t0 = commandlistenerwrapper.getWorld().getGameRules().get(gamerules_gamerulekey); // CraftBukkit +- T t0 = commandlistenerwrapper.getServer().getGameRules().getRule(gamerules_gamerulekey); ++ T t0 = commandlistenerwrapper.getLevel().getGameRules().getRule(gamerules_gamerulekey); // CraftBukkit - t0.b(commandcontext, "value"); - commandlistenerwrapper.sendMessage(new ChatMessage("commands.gamerule.set", new Object[]{gamerules_gamerulekey.a(), t0.toString()}), true); + t0.setFromArgument(commandcontext, "value"); + commandlistenerwrapper.sendSuccess(new ChatMessage("commands.gamerule.set", new Object[]{gamerules_gamerulekey.getId(), t0.toString()}), true); @@ -39,7 +39,7 @@ } - static <T extends GameRules.GameRuleValue<T>> int a(CommandListenerWrapper commandlistenerwrapper, GameRules.GameRuleKey<T> gamerules_gamerulekey) { -- T t0 = commandlistenerwrapper.getServer().getGameRules().get(gamerules_gamerulekey); -+ T t0 = commandlistenerwrapper.getWorld().getGameRules().get(gamerules_gamerulekey); // CraftBukkit + static <T extends GameRules.GameRuleValue<T>> int queryRule(CommandListenerWrapper commandlistenerwrapper, GameRules.GameRuleKey<T> gamerules_gamerulekey) { +- T t0 = commandlistenerwrapper.getServer().getGameRules().getRule(gamerules_gamerulekey); ++ T t0 = commandlistenerwrapper.getLevel().getGameRules().getRule(gamerules_gamerulekey); // CraftBukkit - commandlistenerwrapper.sendMessage(new ChatMessage("commands.gamerule.query", new Object[]{gamerules_gamerulekey.a(), t0.toString()}), false); - return t0.getIntValue(); + commandlistenerwrapper.sendSuccess(new ChatMessage("commands.gamerule.query", new Object[]{gamerules_gamerulekey.getId(), t0.toString()}), false); + return t0.getCommandResult(); diff --git a/paper-server/nms-patches/net/minecraft/server/commands/CommandList.patch b/paper-server/nms-patches/net/minecraft/server/commands/CommandList.patch index cf9bddb538..4635b54e3e 100644 --- a/paper-server/nms-patches/net/minecraft/server/commands/CommandList.patch +++ b/paper-server/nms-patches/net/minecraft/server/commands/CommandList.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/commands/CommandList.java +++ b/net/minecraft/server/commands/CommandList.java @@ -37,6 +37,12 @@ - private static int a(CommandListenerWrapper commandlistenerwrapper, Function<EntityPlayer, IChatBaseComponent> function) { + private static int format(CommandListenerWrapper commandlistenerwrapper, Function<EntityPlayer, IChatBaseComponent> function) { PlayerList playerlist = commandlistenerwrapper.getServer().getPlayerList(); List<EntityPlayer> list = playerlist.getPlayers(); + // CraftBukkit start @@ -10,6 +10,6 @@ + list = list.stream().filter((ep) -> sender.canSee(ep.getBukkitEntity())).collect(java.util.stream.Collectors.toList()); + } + // CraftBukkit end - IChatBaseComponent ichatbasecomponent = ChatComponentUtils.b(list, function); + IChatBaseComponent ichatbasecomponent = ChatComponentUtils.formatList(list, function); - commandlistenerwrapper.sendMessage(new ChatMessage("commands.list.players", new Object[]{list.size(), playerlist.getMaxPlayers(), ichatbasecomponent}), false); + commandlistenerwrapper.sendSuccess(new ChatMessage("commands.list.players", new Object[]{list.size(), playerlist.getMaxPlayers(), ichatbasecomponent}), false); diff --git a/paper-server/nms-patches/net/minecraft/server/commands/CommandReload.patch b/paper-server/nms-patches/net/minecraft/server/commands/CommandReload.patch index 4af5a0e996..46887c0149 100644 --- a/paper-server/nms-patches/net/minecraft/server/commands/CommandReload.patch +++ b/paper-server/nms-patches/net/minecraft/server/commands/CommandReload.patch @@ -6,14 +6,14 @@ + // CraftBukkit start + public static void reload(MinecraftServer minecraftserver) { -+ ResourcePackRepository resourcepackrepository = minecraftserver.getResourcePackRepository(); -+ SaveData savedata = minecraftserver.getSaveData(); -+ Collection<String> collection = resourcepackrepository.d(); -+ Collection<String> collection1 = a(resourcepackrepository, savedata, collection); -+ minecraftserver.a(collection1); ++ ResourcePackRepository resourcepackrepository = minecraftserver.getPackRepository(); ++ SaveData savedata = minecraftserver.getWorldData(); ++ Collection<String> collection = resourcepackrepository.getSelectedIds(); ++ Collection<String> collection1 = discoverNewPacks(resourcepackrepository, savedata, collection); ++ minecraftserver.reloadResources(collection1); + } + // CraftBukkit end + - public static void a(CommandDispatcher<CommandListenerWrapper> commanddispatcher) { - commanddispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) net.minecraft.commands.CommandDispatcher.a("reload").requires((commandlistenerwrapper) -> { + public static void register(CommandDispatcher<CommandListenerWrapper> commanddispatcher) { + commanddispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) net.minecraft.commands.CommandDispatcher.literal("reload").requires((commandlistenerwrapper) -> { return commandlistenerwrapper.hasPermission(2); diff --git a/paper-server/nms-patches/net/minecraft/server/commands/CommandSchedule.patch b/paper-server/nms-patches/net/minecraft/server/commands/CommandSchedule.patch index d7fa2e2b65..52d0ff922c 100644 --- a/paper-server/nms-patches/net/minecraft/server/commands/CommandSchedule.patch +++ b/paper-server/nms-patches/net/minecraft/server/commands/CommandSchedule.patch @@ -1,20 +1,11 @@ --- a/net/minecraft/server/commands/CommandSchedule.java +++ b/net/minecraft/server/commands/CommandSchedule.java -@@ -57,7 +57,7 @@ +@@ -56,7 +56,7 @@ } else { - long j = commandlistenerwrapper.getWorld().getTime() + (long) i; + long j = commandlistenerwrapper.getLevel().getGameTime() + (long) i; MinecraftKey minecraftkey = (MinecraftKey) pair.getFirst(); -- CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue = commandlistenerwrapper.getServer().getSaveData().H().u(); -+ CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue = commandlistenerwrapper.getWorld().serverLevelData.H().u(); // CraftBukkit - SPIGOT-6667: Use world specific function timer +- CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue = commandlistenerwrapper.getServer().getWorldData().overworldData().getScheduledEvents(); ++ CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue = commandlistenerwrapper.getLevel().serverLevelData.overworldData().getScheduledEvents(); // CraftBukkit - SPIGOT-6667: Use world specific function timer ((Either) pair.getSecond()).ifLeft((customfunction) -> { String s = minecraftkey.toString(); -@@ -78,7 +78,7 @@ - customfunctioncallbacktimerqueue.a(s, j, new CustomFunctionCallbackTag(minecraftkey)); - commandlistenerwrapper.sendMessage(new ChatMessage("commands.schedule.created.tag", new Object[]{minecraftkey, i, j}), true); - }); -- return Math.floorMod(j, Integer.MAX_VALUE); -+ return (int) Math.floorMod(j, (long) Integer.MAX_VALUE); // CraftBukkit - Downgrade to Java 8 method - } - } - diff --git a/paper-server/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch b/paper-server/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch index 27e25e1ed3..0ce193f86d 100644 --- a/paper-server/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch +++ b/paper-server/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch @@ -1,41 +1,41 @@ --- a/net/minecraft/server/commands/CommandSpreadPlayers.java +++ b/net/minecraft/server/commands/CommandSpreadPlayers.java -@@ -80,7 +80,7 @@ +@@ -79,7 +79,7 @@ if (entity instanceof EntityHuman) { - set.add(entity.getScoreboardTeam()); + set.add(entity.getTeam()); } else { - set.add((Object) null); + set.add((ScoreboardTeamBase) null); // CraftBukkit - decompile error } } -@@ -289,7 +289,7 @@ +@@ -288,7 +288,7 @@ - for (boolean flag2 = iblockaccess.getType(blockposition_mutableblockposition).isAir(); blockposition_mutableblockposition.getY() > iblockaccess.getMinBuildHeight(); flag2 = flag1) { - blockposition_mutableblockposition.c(EnumDirection.DOWN); -- flag1 = iblockaccess.getType(blockposition_mutableblockposition).isAir(); -+ flag1 = getType(iblockaccess, blockposition_mutableblockposition).isAir(); // CraftBukkit + for (boolean flag2 = iblockaccess.getBlockState(blockposition_mutableblockposition).isAir(); blockposition_mutableblockposition.getY() > iblockaccess.getMinBuildHeight(); flag2 = flag1) { + blockposition_mutableblockposition.move(EnumDirection.DOWN); +- flag1 = iblockaccess.getBlockState(blockposition_mutableblockposition).isAir(); ++ flag1 = getBlockState(iblockaccess, blockposition_mutableblockposition).isAir(); // CraftBukkit if (!flag1 && flag2 && flag) { return blockposition_mutableblockposition.getY() + 1; } -@@ -302,7 +302,7 @@ +@@ -301,7 +301,7 @@ - public boolean b(IBlockAccess iblockaccess, int i) { - BlockPosition blockposition = new BlockPosition(this.x, (double) (this.a(iblockaccess, i) - 1), this.z); -- IBlockData iblockdata = iblockaccess.getType(blockposition); -+ IBlockData iblockdata = getType(iblockaccess, blockposition); // CraftBukkit + public boolean isSafe(IBlockAccess iblockaccess, int i) { + BlockPosition blockposition = new BlockPosition(this.x, (double) (this.getSpawnY(iblockaccess, i) - 1), this.z); +- IBlockData iblockdata = iblockaccess.getBlockState(blockposition); ++ IBlockData iblockdata = getBlockState(iblockaccess, blockposition); // CraftBukkit Material material = iblockdata.getMaterial(); return blockposition.getY() < i && !material.isLiquid() && material != Material.FIRE; -@@ -312,5 +312,12 @@ - this.x = MathHelper.a(random, d0, d2); - this.z = MathHelper.a(random, d1, d3); +@@ -311,5 +311,12 @@ + this.x = MathHelper.nextDouble(random, d0, d2); + this.z = MathHelper.nextDouble(random, d1, d3); } + -+ // CraftBukkit start - add a version of getType which force loads chunks -+ private static IBlockData getType(IBlockAccess iblockaccess, BlockPosition position) { -+ ((WorldServer) iblockaccess).getChunkProvider().getChunkAt(position.getX() >> 4, position.getZ() >> 4, true); -+ return iblockaccess.getType(position); ++ // CraftBukkit start - add a version of getBlockState which force loads chunks ++ private static IBlockData getBlockState(IBlockAccess iblockaccess, BlockPosition position) { ++ ((WorldServer) iblockaccess).getChunkSource().getChunk(position.getX() >> 4, position.getZ() >> 4, true); ++ return iblockaccess.getBlockState(position); + } + // CraftBukkit end } diff --git a/paper-server/nms-patches/net/minecraft/server/commands/CommandSummon.patch b/paper-server/nms-patches/net/minecraft/server/commands/CommandSummon.patch index f39ba596ec..bcd18d0886 100644 --- a/paper-server/nms-patches/net/minecraft/server/commands/CommandSummon.patch +++ b/paper-server/nms-patches/net/minecraft/server/commands/CommandSummon.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/commands/CommandSummon.java +++ b/net/minecraft/server/commands/CommandSummon.java -@@ -66,7 +66,7 @@ - ((EntityInsentient) entity).prepare(commandlistenerwrapper.getWorld(), commandlistenerwrapper.getWorld().getDamageScaler(entity.getChunkCoordinates()), EnumMobSpawn.COMMAND, (GroupDataEntity) null, (NBTTagCompound) null); +@@ -65,7 +65,7 @@ + ((EntityInsentient) entity).finalizeSpawn(commandlistenerwrapper.getLevel(), commandlistenerwrapper.getLevel().getCurrentDifficultyAt(entity.blockPosition()), EnumMobSpawn.COMMAND, (GroupDataEntity) null, (NBTTagCompound) null); } -- if (!worldserver.addAllEntitiesSafely(entity)) { -+ if (!worldserver.addAllEntitiesSafely(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND)) { // CraftBukkit - pass a spawn reason of "COMMAND" +- if (!worldserver.tryAddFreshEntityWithPassengers(entity)) { ++ if (!worldserver.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND)) { // CraftBukkit - pass a spawn reason of "COMMAND" throw CommandSummon.ERROR_DUPLICATE_UUID.create(); } else { - commandlistenerwrapper.sendMessage(new ChatMessage("commands.summon.success", new Object[]{entity.getScoreboardDisplayName()}), true); + commandlistenerwrapper.sendSuccess(new ChatMessage("commands.summon.success", new Object[]{entity.getDisplayName()}), true); diff --git a/paper-server/nms-patches/net/minecraft/server/commands/CommandTeleport.patch b/paper-server/nms-patches/net/minecraft/server/commands/CommandTeleport.patch index e70b31fbba..7cf6c74067 100644 --- a/paper-server/nms-patches/net/minecraft/server/commands/CommandTeleport.patch +++ b/paper-server/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 -@@ -36,6 +36,12 @@ +@@ -35,6 +35,12 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; @@ -13,20 +13,20 @@ public class CommandTeleport { private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(new ChatMessage("commands.teleport.invalidPosition")); -@@ -160,14 +166,29 @@ +@@ -159,14 +165,29 @@ } if (worldserver == entity.level) { -- ((EntityPlayer) entity).connection.a(d0, d1, d2, f2, f3, set); -+ ((EntityPlayer) entity).connection.a(d0, d1, d2, f2, f3, set, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit +- ((EntityPlayer) entity).connection.teleport(d0, d1, d2, f2, f3, set); ++ ((EntityPlayer) entity).connection.teleport(d0, d1, d2, f2, f3, set, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit } else { -- ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f2, f3); -+ ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f2, f3, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit +- ((EntityPlayer) entity).teleportTo(worldserver, d0, d1, d2, f2, f3); ++ ((EntityPlayer) entity).teleportTo(worldserver, d0, d1, d2, f2, f3, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit } - entity.setHeadRotation(f2); + entity.setYHeadRot(f2); } else { - float f4 = MathHelper.a(f3, -90.0F, 90.0F); + float f4 = MathHelper.clamp(f3, -90.0F, 90.0F); + // CraftBukkit start - Teleport event + Location to = new Location(worldserver.getWorld(), d0, d1, d2, f2, f4); + EntityTeleportEvent event = new EntityTeleportEvent(entity.getBukkitEntity(), entity.getBukkitEntity().getLocation(), to); @@ -44,4 +44,4 @@ + // CraftBukkit end if (worldserver == entity.level) { - entity.setPositionRotation(d0, d1, d2, f2, f4); + entity.moveTo(d0, d1, d2, f2, f4); diff --git a/paper-server/nms-patches/net/minecraft/server/commands/CommandTime.patch b/paper-server/nms-patches/net/minecraft/server/commands/CommandTime.patch index e2ab216064..442c59a244 100644 --- a/paper-server/nms-patches/net/minecraft/server/commands/CommandTime.patch +++ b/paper-server/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 -@@ -10,6 +10,11 @@ +@@ -9,6 +9,11 @@ import net.minecraft.network.chat.ChatMessage; import net.minecraft.server.level.WorldServer; @@ -12,7 +12,7 @@ public class CommandTime { public CommandTime() {} -@@ -53,7 +58,13 @@ +@@ -52,7 +57,13 @@ while (iterator.hasNext()) { WorldServer worldserver = (WorldServer) iterator.next(); @@ -26,8 +26,8 @@ + // CraftBukkit end } - commandlistenerwrapper.sendMessage(new ChatMessage("commands.time.set", new Object[]{i}), true); -@@ -66,7 +77,13 @@ + commandlistenerwrapper.sendSuccess(new ChatMessage("commands.time.set", new Object[]{i}), true); +@@ -65,7 +76,13 @@ while (iterator.hasNext()) { WorldServer worldserver = (WorldServer) iterator.next(); @@ -41,4 +41,4 @@ + // CraftBukkit end } - int j = a(commandlistenerwrapper.getWorld()); + int j = getDayTime(commandlistenerwrapper.getLevel()); diff --git a/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch b/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch index 1b772ca86a..b5d366b522 100644 --- a/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch +++ b/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -65,6 +65,15 @@ +@@ -61,6 +61,15 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -16,7 +16,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer { static final Logger LOGGER = LogManager.getLogger(); -@@ -83,8 +92,10 @@ +@@ -81,8 +90,10 @@ @Nullable private final IChatBaseComponent resourcePackPrompt; @@ -28,9 +28,9 @@ + // CraftBukkit end this.settings = dedicatedserversettings; this.rconConsoleSource = new RemoteControlCommandListener(this); - this.textFilterClient = TextFilter.a(dedicatedserversettings.getProperties().textFilteringConfig); -@@ -95,13 +106,44 @@ - public boolean init() throws IOException { + this.textFilterClient = TextFilter.createFromConfig(dedicatedserversettings.getProperties().textFilteringConfig); +@@ -93,13 +104,44 @@ + public boolean initServer() throws IOException { Thread thread = new Thread("Server console handler") { public void run() { - BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); @@ -52,7 +52,7 @@ try { - while (!DedicatedServer.this.isStopped() && DedicatedServer.this.isRunning() && (s = bufferedreader.readLine()) != null) { -- DedicatedServer.this.issueCommand(s, DedicatedServer.this.getServerCommandListener()); +- DedicatedServer.this.handleConsoleInput(s, DedicatedServer.this.createCommandSourceStack()); + // CraftBukkit start - JLine disabling compatibility + while (!DedicatedServer.this.isStopped() && DedicatedServer.this.isRunning()) { + if (org.bukkit.craftbukkit.Main.useJline) { @@ -71,13 +71,13 @@ + continue; + } + if (s.trim().length() > 0) { // Trim to filter lines which are just spaces -+ DedicatedServer.this.issueCommand(s, DedicatedServer.this.getServerCommandListener()); ++ DedicatedServer.this.handleConsoleInput(s, DedicatedServer.this.createCommandSourceStack()); + } + // CraftBukkit end } } catch (IOException ioexception) { DedicatedServer.LOGGER.error("Exception handling console input", ioexception); -@@ -110,6 +152,27 @@ +@@ -108,6 +150,27 @@ } }; @@ -105,83 +105,81 @@ thread.setDaemon(true); thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER)); thread.start(); -@@ -135,7 +198,7 @@ +@@ -133,7 +196,7 @@ this.setMotd(dedicatedserverproperties.motd); - super.setIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get()); + super.setPlayerIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get()); this.setEnforceWhitelist(dedicatedserverproperties.enforceWhitelist); - this.worldData.setGameType(dedicatedserverproperties.gamemode); + // this.worldData.setGameType(dedicatedserverproperties.gamemode); // CraftBukkit - moved to world loading DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode); InetAddress inetaddress = null; -@@ -159,6 +222,12 @@ +@@ -157,6 +220,12 @@ return false; } + // CraftBukkit start -+ this.a((PlayerList) (new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage))); ++ this.setPlayerList(new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage)); + server.loadPlugins(); + server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP); + // CraftBukkit end + - if (!this.getOnlineMode()) { + if (!this.usesAuthentication()) { DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); -@@ -173,7 +242,7 @@ - if (!NameReferencingFileConverter.e(this)) { +@@ -171,13 +240,13 @@ + if (!NameReferencingFileConverter.serverReadyAfterUserconversion(this)) { return false; } else { -- this.a((PlayerList) (new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage))); -+ // this.a((PlayerList) (new DedicatedPlayerList(this, this.customRegistry, this.worldNBTStorage))); // CraftBukkit - moved up - long i = SystemUtils.getMonotonicNanos(); +- this.setPlayerList(new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage)); ++ // this.setPlayerList(new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage)); // CraftBukkit - moved up + long i = SystemUtils.getNanos(); - TileEntitySkull.a(this.getUserCache()); -@@ -181,7 +250,7 @@ - TileEntitySkull.a((Executor) this); - UserCache.a(this.getOnlineMode()); - DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getWorld()); -- this.loadWorld(); -+ this.loadWorld(storageSource.getLevelName()); // CraftBukkit - long j = SystemUtils.getMonotonicNanos() - i; + TileEntitySkull.setup(this.getProfileCache(), this.getSessionService(), this); + UserCache.setUsesAuthentication(this.usesAuthentication()); + DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName()); +- this.loadLevel(); ++ this.loadLevel(storageSource.getLevelId()); // CraftBukkit + long j = SystemUtils.getNanos() - i; String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D); -@@ -198,6 +267,7 @@ +@@ -194,6 +263,7 @@ if (dedicatedserverproperties.enableRcon) { DedicatedServer.LOGGER.info("Starting remote control listener"); - this.rconThread = RemoteControlListener.a((IMinecraftServer) this); + this.rconThread = RemoteControlListener.create(this); + this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this.rconConsoleSource); // CraftBukkit } - if (this.getMaxTickTime() > 0L) { -@@ -347,6 +417,7 @@ - this.queryThreadGs4.b(); + if (this.getMaxTickLength() > 0L) { +@@ -337,6 +407,7 @@ + this.queryThreadGs4.stop(); } + System.exit(0); // CraftBukkit } @Override -@@ -380,7 +451,15 @@ +@@ -358,7 +429,15 @@ while (!this.consoleInput.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0); -- this.getCommandDispatcher().a(servercommand.source, servercommand.msg); +- this.getCommands().performCommand(servercommand.source, servercommand.msg); + // CraftBukkit start - ServerCommand for preprocessing + ServerCommandEvent event = new ServerCommandEvent(console, servercommand.msg); + server.getPluginManager().callEvent(event); + if (event.isCancelled()) continue; + servercommand = new ServerCommand(event.getCommand(), servercommand.source); + -+ // this.getCommandDispatcher().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand ++ // this.getCommands().performCommand(servercommand.source, servercommand.msg); // Called in dispatchServerCommand + server.dispatchServerCommand(console, servercommand); + // CraftBukkit end } } -@@ -585,14 +664,45 @@ +@@ -568,14 +647,45 @@ @Override - public String getPlugins() { + public String getPluginNames() { - return ""; + // CraftBukkit start - Whole method + StringBuilder result = new StringBuilder(); @@ -210,30 +208,30 @@ } @Override - public String executeRemoteCommand(String s) { - this.rconConsoleSource.clearMessages(); - this.executeSync(() -> { -- this.getCommandDispatcher().a(this.rconConsoleSource.getWrapper(), s); + public String runCommand(String s) { + this.rconConsoleSource.prepareForCommand(); + this.executeBlocking(() -> { +- this.getCommands().performCommand(this.rconConsoleSource.createCommandSourceStack(), s); + // CraftBukkit start - fire RemoteServerCommandEvent + RemoteServerCommandEvent event = new RemoteServerCommandEvent(remoteConsole, s); + server.getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } -+ ServerCommand serverCommand = new ServerCommand(event.getCommand(), rconConsoleSource.getWrapper()); ++ ServerCommand serverCommand = new ServerCommand(event.getCommand(), rconConsoleSource.createCommandSourceStack()); + server.dispatchServerCommand(remoteConsole, serverCommand); + // CraftBukkit end }); - return this.rconConsoleSource.getMessages(); + return this.rconConsoleSource.getCommandResponse(); } -@@ -665,4 +775,15 @@ - public IChatBaseComponent ba() { +@@ -649,4 +759,15 @@ + public IChatBaseComponent getResourcePackPrompt() { return this.resourcePackPrompt; } + + // CraftBukkit start + public boolean isDebugging() { -+ return this.getDedicatedServerProperties().debug; ++ return this.getProperties().debug; + } + + @Override diff --git a/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch b/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch index 920c7c9b6b..f8dacbb945 100644 --- a/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch +++ b/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch @@ -11,11 +11,11 @@ + public class DedicatedServerProperties extends PropertyManager<DedicatedServerProperties> { -+ public final boolean debug = this.getBoolean("debug", false); // CraftBukkit - public final boolean onlineMode = this.getBoolean("online-mode", true); - public final boolean preventProxyConnections = this.getBoolean("prevent-proxy-connections", false); - public final String serverIp = this.getString("server-ip", ""); -@@ -64,8 +70,10 @@ ++ public final boolean debug = this.get("debug", false); // CraftBukkit + public final boolean onlineMode = this.get("online-mode", true); + public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false); + public final String serverIp = this.get("server-ip", ""); +@@ -67,8 +73,10 @@ @Nullable private GeneratorSettings worldGenSettings; @@ -25,18 +25,18 @@ + public DedicatedServerProperties(Properties properties, OptionSet optionset) { + super(properties, optionset); + // CraftBukkit end - this.difficulty = (EnumDifficulty) this.a("difficulty", a(EnumDifficulty::getById, EnumDifficulty::a), EnumDifficulty::c, EnumDifficulty.EASY); - this.gamemode = (EnumGamemode) this.a("gamemode", a(EnumGamemode::getById, EnumGamemode::a), EnumGamemode::b, EnumGamemode.SURVIVAL); - this.levelName = this.getString("level-name", "world"); + this.difficulty = (EnumDifficulty) this.get("difficulty", dispatchNumberOrString(EnumDifficulty::byId, EnumDifficulty::byName), EnumDifficulty::getKey, EnumDifficulty.EASY); + this.gamemode = (EnumGamemode) this.get("gamemode", dispatchNumberOrString(EnumGamemode::byId, EnumGamemode::byName), EnumGamemode::getName, EnumGamemode.SURVIVAL); + this.levelName = this.get("level-name", "world"); @@ -112,13 +120,15 @@ - this.whiteList = this.b("white-list", false); + this.whiteList = this.getMutable("white-list", false); } -- public static DedicatedServerProperties load(Path path) { -- return new DedicatedServerProperties(loadPropertiesFile(path)); +- public static DedicatedServerProperties fromFile(Path path) { +- return new DedicatedServerProperties(loadFromFile(path)); + // CraftBukkit start -+ public static DedicatedServerProperties load(Path path, OptionSet optionset) { -+ return new DedicatedServerProperties(loadPropertiesFile(path), optionset); ++ public static DedicatedServerProperties fromFile(Path path, OptionSet optionset) { ++ return new DedicatedServerProperties(loadFromFile(path), optionset); } @Override @@ -46,5 +46,5 @@ + DedicatedServerProperties dedicatedserverproperties = new DedicatedServerProperties(properties, optionset); + // CraftBukkit end - dedicatedserverproperties.a(iregistrycustom); + dedicatedserverproperties.getWorldGenSettings(iregistrycustom); return dedicatedserverproperties; diff --git a/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServerSettings.patch b/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServerSettings.patch index 995ba6eb56..9a52b5cc81 100644 --- a/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServerSettings.patch +++ b/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServerSettings.patch @@ -16,11 +16,11 @@ - public DedicatedServerSettings(Path path) { - this.source = path; -- this.properties = DedicatedServerProperties.load(path); +- this.properties = DedicatedServerProperties.fromFile(path); + // CraftBukkit start + public DedicatedServerSettings(OptionSet optionset) { + this.source = ((File) optionset.valueOf("config")).toPath(); -+ this.properties = DedicatedServerProperties.load(source, optionset); ++ this.properties = DedicatedServerProperties.fromFile(source, optionset); + // CraftBukkit end } diff --git a/paper-server/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch b/paper-server/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch index 7a1ffdd803..9364eaa320 100644 --- a/paper-server/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch +++ b/paper-server/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch @@ -29,12 +29,12 @@ + } + // CraftBukkit end + - public static Properties loadPropertiesFile(Path path) { + public static Properties loadFromFile(Path path) { Properties properties = new Properties(); @@ -58,6 +73,11 @@ - public void savePropertiesFile(Path path) { + 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()) { @@ -45,7 +45,7 @@ try { @@ -86,7 +106,7 @@ - private static <V extends Number> Function<String, V> a(Function<String, V> function) { + private static <V extends Number> Function<String, V> wrapNumberDeserializer(Function<String, V> function) { return (s) -> { try { - return (Number) function.apply(s); @@ -56,7 +56,7 @@ @@ -105,7 +125,7 @@ @Nullable - private String c(String s) { + private String getStringRaw(String s) { - return (String) this.properties.get(s); + return (String) getOverride(s, this.properties.getProperty(s)); // CraftBukkit } @@ -70,25 +70,7 @@ + return new PropertyManager.EditableProperty(s, v1, function1); // CraftBukkit - decompile error } - protected <V> V a(String s, Function<String, V> function, UnaryOperator<V> unaryoperator, Function<V, String> function1, V v0) { -@@ -162,7 +182,7 @@ - } - - protected int getInt(String s, int i) { -- return (Integer) this.a(s, a(Integer::parseInt), (Object) i); -+ return (Integer) this.a(s, a(Integer::parseInt), i); // CraftBukkit - decompile error - } - - protected PropertyManager<T>.EditableProperty<Integer> b(String s, int i) { -@@ -174,7 +194,7 @@ - } - - protected long getLong(String s, long i) { -- return (Long) this.a(s, a(Long::parseLong), (Object) i); -+ return (Long) this.a(s, a(Long::parseLong), i); // CraftBukkit - decompile error - } - - protected boolean getBoolean(String s, boolean flag) { + protected <V> V get(String s, Function<String, V> function, UnaryOperator<V> unaryoperator, Function<V, String> function1, V v0) { @@ -197,7 +217,7 @@ return properties; } @@ -108,7 +90,7 @@ this.value = object; this.serializer = function; @@ -219,7 +239,7 @@ - Properties properties = PropertyManager.this.a(); + Properties properties = PropertyManager.this.cloneProperties(); properties.put(this.key, this.serializer.apply(v0)); - return PropertyManager.this.reload(iregistrycustom, properties); diff --git a/paper-server/nms-patches/net/minecraft/server/gui/ServerGUI.patch b/paper-server/nms-patches/net/minecraft/server/gui/ServerGUI.patch index 5f7fad052e..5c6b09ab35 100644 --- a/paper-server/nms-patches/net/minecraft/server/gui/ServerGUI.patch +++ b/paper-server/nms-patches/net/minecraft/server/gui/ServerGUI.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/server/gui/ServerGUI.java +++ b/net/minecraft/server/gui/ServerGUI.java @@ -96,7 +96,7 @@ - private JComponent c() { + private JComponent buildInfoPanel() { JPanel jpanel = new JPanel(new BorderLayout()); GuiStatsComponent guistatscomponent = new GuiStatsComponent(this.server); - Collection collection = this.finalizers; + Collection<Runnable> collection = this.finalizers; // CraftBukkit - decompile error Objects.requireNonNull(guistatscomponent); - collection.add(guistatscomponent::a); + collection.add(guistatscomponent::close); @@ -166,6 +166,7 @@ this.finalizers.forEach(Runnable::run); } + private static final java.util.regex.Pattern ANSI = java.util.regex.Pattern.compile("\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})*)?[m|K]"); // CraftBukkit - public void a(JTextArea jtextarea, JScrollPane jscrollpane, String s) { + public void print(JTextArea jtextarea, JScrollPane jscrollpane, String s) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(() -> { @@ -181,7 +182,7 @@ diff --git a/paper-server/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch b/paper-server/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch index a7258366b4..100ddc4c49 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/server/level/ChunkMapDistance.java +++ b/net/minecraft/server/level/ChunkMapDistance.java -@@ -73,7 +73,7 @@ - while (objectiterator.hasNext()) { - Entry<ArraySetSorted<Ticket<?>>> entry = (Entry) objectiterator.next(); - -- if (((ArraySetSorted) entry.getValue()).removeIf((ticket) -> { -+ if ((entry.getValue()).removeIf((ticket) -> { // CraftBukkit - decompile error - return ticket.b(this.ticketTickCounter); - })) { - this.ticketTracker.update(entry.getLongKey(), getLowestTicketLevel((ArraySetSorted) entry.getValue()), false); -@@ -109,10 +109,25 @@ +@@ -125,10 +125,25 @@ } if (!this.chunksToUpdateFutures.isEmpty()) { @@ -23,7 +14,7 @@ + iter.remove(); + expectedSize--; + - playerchunk.a(playerchunkmap, this.mainThreadExecutor); + playerchunk.updateFutures(playerchunkmap, this.mainThreadExecutor); - }); - this.chunksToUpdateFutures.clear(); + @@ -38,20 +29,17 @@ return true; } else { if (!this.ticketsToRelease.isEmpty()) { -@@ -148,23 +163,25 @@ +@@ -164,7 +179,7 @@ } } - void addTicket(long i, Ticket<?> ticket) { + boolean addTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean - ArraySetSorted<Ticket<?>> arraysetsorted = this.e(i); - int j = getLowestTicketLevel(arraysetsorted); -- Ticket<?> ticket1 = (Ticket) arraysetsorted.a((Object) ticket); -+ Ticket<?> ticket1 = (Ticket) arraysetsorted.a(ticket); // CraftBukkit - decompile error - - ticket1.a(this.ticketTickCounter); - if (ticket.b() < j) { - this.ticketTracker.update(i, ticket.b(), true); + ArraySetSorted<Ticket<?>> arraysetsorted = this.getTickets(i); + int j = getTicketLevelAt(arraysetsorted); + Ticket<?> ticket1 = (Ticket) arraysetsorted.addOrGet(ticket); +@@ -174,13 +189,15 @@ + this.ticketTracker.update(i, ticket.getTicketLevel(), true); } + return ticket == ticket1; // CraftBukkit @@ -59,7 +47,7 @@ - void removeTicket(long i, Ticket<?> ticket) { + boolean removeTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean - ArraySetSorted<Ticket<?>> arraysetsorted = this.e(i); + ArraySetSorted<Ticket<?>> arraysetsorted = this.getTickets(i); + boolean removed = false; // CraftBukkit if (arraysetsorted.remove(ticket)) { @@ -68,49 +56,49 @@ } if (arraysetsorted.isEmpty()) { -@@ -172,16 +189,29 @@ +@@ -188,16 +205,29 @@ } - this.ticketTracker.update(i, getLowestTicketLevel(arraysetsorted), false); + this.ticketTracker.update(i, getTicketLevelAt(arraysetsorted), false); + return removed; // CraftBukkit } - public <T> void a(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { -- this.addTicket(chunkcoordintpair.pair(), new Ticket<>(tickettype, i, t0)); + public <T> void addTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { +- this.addTicket(chunkcoordintpair.toLong(), new Ticket<>(tickettype, i, t0)); + // CraftBukkit start + this.addTicketAtLevel(tickettype, chunkcoordintpair, i, t0); + } + + public <T> boolean addTicketAtLevel(TicketType<T> ticketType, ChunkCoordIntPair chunkcoordintpair, int level, T identifier) { -+ return this.addTicket(chunkcoordintpair.pair(), new Ticket<>(ticketType, level, identifier)); ++ return this.addTicket(chunkcoordintpair.toLong(), new Ticket<>(ticketType, level, identifier)); + // CraftBukkit end } - public <T> void b(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { + public <T> void removeTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { - Ticket<T> ticket = new Ticket<>(tickettype, i, t0); + // CraftBukkit start + this.removeTicketAtLevel(tickettype, chunkcoordintpair, i, t0); + } -- this.removeTicket(chunkcoordintpair.pair(), ticket); +- this.removeTicket(chunkcoordintpair.toLong(), ticket); + public <T> boolean removeTicketAtLevel(TicketType<T> ticketType, ChunkCoordIntPair chunkcoordintpair, int level, T identifier) { + Ticket<T> ticket = new Ticket<>(ticketType, level, identifier); + -+ return this.removeTicket(chunkcoordintpair.pair(), ticket); ++ return this.removeTicket(chunkcoordintpair.toLong(), ticket); + // CraftBukkit end } - public <T> void addTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { -@@ -224,6 +254,7 @@ - public void b(SectionPosition sectionposition, EntityPlayer entityplayer) { - long i = sectionposition.r().pair(); + public <T> void addRegionTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { +@@ -252,6 +282,7 @@ + ChunkCoordIntPair chunkcoordintpair = sectionposition.chunk(); + long i = chunkcoordintpair.toLong(); ObjectSet<EntityPlayer> objectset = (ObjectSet) this.playersPerChunk.get(i); + if (objectset == null) return; // CraftBukkit - SPIGOT-6208 objectset.remove(entityplayer); if (objectset.isEmpty()) { -@@ -300,6 +331,26 @@ - +@@ -347,6 +378,26 @@ + return this.tickingTicketsTracker; } + // CraftBukkit start @@ -122,7 +110,7 @@ + ArraySetSorted<Ticket<?>> tickets = entry.getValue(); + if (tickets.remove(target)) { + // copied from removeTicket -+ this.ticketTracker.update(entry.getLongKey(), getLowestTicketLevel(tickets), false); ++ this.ticketTracker.update(entry.getLongKey(), getTicketLevelAt(tickets), false); + + // can't use entry after it's removed + if (tickets.isEmpty()) { diff --git a/paper-server/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch b/paper-server/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch index 58bf8544bc..3e6ac6495e 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch @@ -6,7 +6,7 @@ + // CraftBukkit start - properly implement isChunkLoaded + public boolean isChunkLoaded(int chunkX, int chunkZ) { -+ PlayerChunk chunk = this.chunkMap.getUpdatingChunk(ChunkCoordIntPair.pair(chunkX, chunkZ)); ++ PlayerChunk chunk = this.chunkMap.getUpdatingChunkIfPresent(ChunkCoordIntPair.asLong(chunkX, chunkZ)); + if (chunk == null) { + return false; + } @@ -14,7 +14,7 @@ + } + + public Chunk getChunkUnchecked(int chunkX, int chunkZ) { -+ PlayerChunk chunk = this.chunkMap.getUpdatingChunk(ChunkCoordIntPair.pair(chunkX, chunkZ)); ++ PlayerChunk chunk = this.chunkMap.getUpdatingChunkIfPresent(ChunkCoordIntPair.asLong(chunkX, chunkZ)); + if (chunk == null) { + return null; + } @@ -38,8 +38,8 @@ if (playerchunk == null) { return null; } else { -- Either<IChunkAccess, PlayerChunk.Failure> either = (Either) playerchunk.b(ChunkStatus.FULL).getNow((Object) null); -+ Either<IChunkAccess, PlayerChunk.Failure> either = (Either) playerchunk.b(ChunkStatus.FULL).getNow(null); // CraftBukkit - decompile error +- Either<IChunkAccess, PlayerChunk.Failure> either = (Either) playerchunk.getFutureIfPresent(ChunkStatus.FULL).getNow((Object) null); ++ Either<IChunkAccess, PlayerChunk.Failure> either = (Either) playerchunk.getFutureIfPresent(ChunkStatus.FULL).getNow(null); // CraftBukkit - decompile error if (either == null) { return null; @@ -48,43 +48,43 @@ + IChunkAccess ichunkaccess1 = (IChunkAccess) either.left().orElse(null); // CraftBukkit - decompile error if (ichunkaccess1 != null) { - this.a(k, ichunkaccess1, ChunkStatus.FULL); + this.storeInCache(k, ichunkaccess1, ChunkStatus.FULL); @@ -228,7 +246,15 @@ - int l = 33 + ChunkStatus.a(chunkstatus); - PlayerChunk playerchunk = this.getChunk(k); + int l = 33 + ChunkStatus.getDistance(chunkstatus); + PlayerChunk playerchunk = this.getVisibleChunkIfPresent(k); - if (flag) { + // CraftBukkit start - don't add new ticket for currently unloading chunk + boolean currentlyUnloading = false; + if (playerchunk != null) { -+ PlayerChunk.State oldChunkState = PlayerChunk.getChunkState(playerchunk.oldTicketLevel); -+ PlayerChunk.State currentChunkState = PlayerChunk.getChunkState(playerchunk.getTicketLevel()); -+ currentlyUnloading = (oldChunkState.isAtLeast(PlayerChunk.State.BORDER) && !currentChunkState.isAtLeast(PlayerChunk.State.BORDER)); ++ PlayerChunk.State oldChunkState = PlayerChunk.getFullChunkStatus(playerchunk.oldTicketLevel); ++ PlayerChunk.State currentChunkState = PlayerChunk.getFullChunkStatus(playerchunk.getTicketLevel()); ++ currentlyUnloading = (oldChunkState.isOrAfter(PlayerChunk.State.BORDER) && !currentChunkState.isOrAfter(PlayerChunk.State.BORDER)); + } + if (flag && !currentlyUnloading) { + // CraftBukkit end - this.distanceManager.a(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair); - if (this.a(playerchunk, l)) { - GameProfilerFiller gameprofilerfiller = this.level.getMethodProfiler(); + this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair); + if (this.chunkAbsent(playerchunk, l)) { + GameProfilerFiller gameprofilerfiller = this.level.getProfiler(); @@ -247,7 +273,7 @@ } - private boolean a(@Nullable PlayerChunk playerchunk, int i) { + private boolean chunkAbsent(@Nullable PlayerChunk playerchunk, int i) { - return playerchunk == null || playerchunk.getTicketLevel() > i; + return playerchunk == null || playerchunk.oldTicketLevel > i; // CraftBukkit using oldTicketLevel for isLoaded checks } @Override -@@ -307,7 +333,7 @@ - } +@@ -314,7 +340,7 @@ + } else if (!this.level.shouldTickBlocksAt(i)) { + return false; + } else { +- Either<Chunk, PlayerChunk.Failure> either = (Either) playerchunk.getTickingChunkFuture().getNow((Object) null); ++ Either<Chunk, PlayerChunk.Failure> either = (Either) playerchunk.getTickingChunkFuture().getNow(null); // CraftBukkit - decompile error - public boolean a(long i) { -- return this.a(i, PlayerChunk::a); -+ return this.a(i, (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::a); // CraftBukkit - decompile error - } - - private boolean a(long i, Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>> function) { -@@ -329,11 +355,31 @@ + return either != null && either.left().isPresent(); + } +@@ -327,11 +353,31 @@ @Override public void close() throws IOException { @@ -104,56 +104,50 @@ + // CraftBukkit start - modelled on below + public void purgeUnload() { -+ this.level.getMethodProfiler().enter("purge"); -+ this.distanceManager.purgeTickets(); -+ this.tickDistanceManager(); -+ this.level.getMethodProfiler().exitEnter("unload"); -+ this.chunkMap.unloadChunks(() -> true); -+ this.level.getMethodProfiler().exit(); ++ this.level.getProfiler().push("purge"); ++ this.distanceManager.purgeStaleTickets(); ++ this.runDistanceManagerUpdates(); ++ this.level.getProfiler().popPush("unload"); ++ this.chunkMap.tick(() -> true); ++ this.level.getProfiler().pop(); + this.clearCache(); + } + // CraftBukkit end + @Override public void tick(BooleanSupplier booleansupplier) { - this.level.getMethodProfiler().enter("purge"); -@@ -354,12 +400,12 @@ - this.lastInhabitedUpdate = i; - WorldData worlddata = this.level.getWorldData(); - boolean flag = this.level.isDebugWorld(); -- boolean flag1 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING); -+ boolean flag1 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !level.getPlayers().isEmpty(); // CraftBukkit + this.level.getProfiler().push("purge"); +@@ -360,7 +406,7 @@ - if (!flag) { - this.level.getMethodProfiler().enter("pollingChunks"); + gameprofilerfiller.push("pollingChunks"); int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); -- boolean flag2 = worlddata.getTime() % 400L == 0L; -+ boolean flag2 = level.ticksPerAnimalSpawns != 0L && worlddata.getTime() % level.ticksPerAnimalSpawns == 0L; // CraftBukkit +- boolean flag1 = worlddata.getGameTime() % 400L == 0L; ++ boolean flag1 = level.ticksPerAnimalSpawns != 0L && worlddata.getGameTime() % level.ticksPerAnimalSpawns == 0L; // CraftBukkit - this.level.getMethodProfiler().enter("naturalSpawnCount"); - int l = this.distanceManager.b(); -@@ -394,7 +440,7 @@ + gameprofilerfiller.push("naturalSpawnCount"); + int l = this.distanceManager.getNaturalSpawnChunkCount(); +@@ -381,7 +427,7 @@ + } - this.level.getMethodProfiler().exitEnter("broadcast"); - list.forEach((playerchunk) -> { -- Optional optional = ((Either) playerchunk.a().getNow(PlayerChunk.UNLOADED_LEVEL_CHUNK)).left(); -+ Optional<Chunk> optional = ((Either) playerchunk.a().getNow(PlayerChunk.UNLOADED_LEVEL_CHUNK)).left(); // CraftBukkit - decompile error + gameprofilerfiller.popPush("spawnAndTick"); +- boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING); ++ boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !level.players().isEmpty(); // CraftBukkit - Objects.requireNonNull(playerchunk); - optional.ifPresent(playerchunk::a); -@@ -551,13 +597,19 @@ + Collections.shuffle(list); + Iterator iterator1 = list.iterator(); +@@ -571,18 +617,26 @@ } @Override -- protected boolean executeNext() { +- protected boolean pollTask() { + // CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task -+ public boolean executeNext() { ++ public boolean pollTask() { + try { - if (ChunkProviderServer.this.tickDistanceManager()) { + if (ChunkProviderServer.this.runDistanceManagerUpdates()) { return true; } else { - ChunkProviderServer.this.lightEngine.queueUpdate(); - return super.executeNext(); + ChunkProviderServer.this.lightEngine.tryScheduleUpdate(); + return super.pollTask(); } + } finally { + chunkMap.callbackExecutor.run(); @@ -161,4 +155,21 @@ + // CraftBukkit end } } - } + +- private static final class a extends Record { ++ // CraftBukkit start - decompile error ++ private static final record a(Chunk chunk, PlayerChunk holder) { + ++ /* + final Chunk chunk; + final PlayerChunk holder; + +@@ -602,6 +656,8 @@ + public final boolean equals(Object object) { + return this.equals<invokedynamic>(this, object); + } ++ */ ++ // CraftBukkit end + + public Chunk chunk() { + return this.chunk; diff --git a/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch b/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch index 300cb58dee..21df6e9aa8 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch +++ b/paper-server/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 -@@ -141,6 +141,36 @@ +@@ -140,6 +140,36 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -37,7 +37,7 @@ public class EntityPlayer extends EntityHuman { private static final Logger LOGGER = LogManager.getLogger(); -@@ -188,6 +218,20 @@ +@@ -194,6 +224,20 @@ public int latency; public boolean wonGame; @@ -56,15 +56,15 @@ + // CraftBukkit end + public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile) { - super(worldserver, worldserver.getSpawn(), worldserver.x(), gameprofile); + super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile); this.chatVisibility = EnumChatVisibility.FULL; -@@ -249,12 +293,56 @@ - this.advancements = minecraftserver.getPlayerList().f(this); +@@ -256,12 +300,56 @@ + this.advancements = minecraftserver.getPlayerList().getPlayerAdvancements(this); this.maxUpStep = 1.0F; - this.d(worldserver); + this.fudgeSpawnLocation(worldserver); + + // CraftBukkit start -+ this.displayName = this.getName(); ++ this.displayName = this.getScoreboardName(); + this.bukkitPickUpLoot = true; + this.maxHealthCache = this.getMaxHealth(); + } @@ -72,11 +72,11 @@ + // Yes, this doesn't match Vanilla, but it's the best we can do for now. + // If this is an issue, PRs are welcome + public final BlockPosition getSpawnPoint(WorldServer worldserver) { -+ BlockPosition blockposition = worldserver.getSpawn(); ++ BlockPosition blockposition = worldserver.getSharedSpawnPos(); + -+ if (worldserver.getDimensionManager().hasSkyLight() && worldserver.serverLevelData.getGameType() != EnumGamemode.ADVENTURE) { -+ int i = Math.max(0, this.server.a(worldserver)); -+ int j = MathHelper.floor(worldserver.getWorldBorder().b((double) blockposition.getX(), (double) blockposition.getZ())); ++ if (worldserver.dimensionType().hasSkyLight() && worldserver.serverLevelData.getGameType() != EnumGamemode.ADVENTURE) { ++ int i = Math.max(0, this.server.getSpawnRadius(worldserver)); ++ int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ())); + + if (j < i) { + i = j; @@ -89,14 +89,14 @@ + long k = (long) (i * 2 + 1); + long l = k * k; + int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l; -+ int j1 = this.v(i1); ++ int j1 = this.getCoprime(i1); + int k1 = (new Random()).nextInt(i1); + + for (int l1 = 0; l1 < i1; ++l1) { + int i2 = (k1 + j1 * l1) % i1; + int j2 = i2 % (i * 2 + 1); + int k2 = i2 / (i * 2 + 1); -+ BlockPosition blockposition1 = WorldProviderNormal.a(worldserver, blockposition.getX() + j2 - i, blockposition.getZ() + k2 - i, false); ++ BlockPosition blockposition1 = WorldProviderNormal.getOverworldRespawnPos(worldserver, blockposition.getX() + j2 - i, blockposition.getZ() + k2 - i); + + if (blockposition1 != null) { + return blockposition1; @@ -108,40 +108,40 @@ } + // CraftBukkit end - private void d(WorldServer worldserver) { - BlockPosition blockposition = worldserver.getSpawn(); + private void fudgeSpawnLocation(WorldServer worldserver) { + BlockPosition blockposition = worldserver.getSharedSpawnPos(); -- if (worldserver.getDimensionManager().hasSkyLight() && worldserver.getMinecraftServer().getSaveData().getGameType() != EnumGamemode.ADVENTURE) { -+ if (worldserver.getDimensionManager().hasSkyLight() && worldserver.serverLevelData.getGameType() != EnumGamemode.ADVENTURE) { // CraftBukkit - int i = Math.max(0, this.server.a(worldserver)); - int j = MathHelper.floor(worldserver.getWorldBorder().b((double) blockposition.getX(), (double) blockposition.getZ())); +- if (worldserver.dimensionType().hasSkyLight() && worldserver.getServer().getWorldData().getGameType() != EnumGamemode.ADVENTURE) { ++ if (worldserver.dimensionType().hasSkyLight() && worldserver.serverLevelData.getGameType() != EnumGamemode.ADVENTURE) { // CraftBukkit + int i = Math.max(0, this.server.getSpawnRadius(worldserver)); + int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ())); -@@ -312,11 +400,20 @@ - if (nbttagcompound.hasKeyOfType("recipeBook", 10)) { - this.recipeBook.a(nbttagcompound.getCompound("recipeBook"), this.server.getCraftingManager()); +@@ -319,11 +407,20 @@ + if (nbttagcompound.contains("recipeBook", 10)) { + this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager()); } + this.getBukkitEntity().readExtraData(nbttagcompound); // CraftBukkit if (this.isSleeping()) { - this.entityWakeup(); + this.stopSleeping(); } + // CraftBukkit start + String spawnWorld = nbttagcompound.getString("SpawnWorld"); + CraftWorld oldWorld = (CraftWorld) Bukkit.getWorld(spawnWorld); + if (oldWorld != null) { -+ this.respawnDimension = oldWorld.getHandle().getDimensionKey(); ++ this.respawnDimension = oldWorld.getHandle().dimension(); + } + // CraftBukkit end + - if (nbttagcompound.hasKeyOfType("SpawnX", 99) && nbttagcompound.hasKeyOfType("SpawnY", 99) && nbttagcompound.hasKeyOfType("SpawnZ", 99)) { + 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"); -@@ -349,7 +446,20 @@ +@@ -356,7 +453,20 @@ Entity entity = this.getRootVehicle(); Entity entity1 = this.getVehicle(); -- if (entity1 != null && entity != this && entity.hasSinglePlayerPassenger()) { +- if (entity1 != null && entity != this && entity.hasExactlyOnePlayerPassenger()) { + // CraftBukkit start - handle non-persistent vehicles + boolean persistVehicle = true; + if (entity1 != null) { @@ -154,22 +154,22 @@ + } + } + -+ if (persistVehicle && entity1 != null && entity != this && entity.hasSinglePlayerPassenger()) { ++ if (persistVehicle && entity1 != null && entity != this && entity.hasExactlyOnePlayerPassenger()) { + // CraftBukkit end NBTTagCompound nbttagcompound2 = new NBTTagCompound(); NBTTagCompound nbttagcompound3 = new NBTTagCompound(); -@@ -367,7 +477,7 @@ - nbttagcompound.setInt("SpawnZ", this.respawnPosition.getZ()); - nbttagcompound.setBoolean("SpawnForced", this.respawnForced); - nbttagcompound.setFloat("SpawnAngle", this.respawnAngle); -- DataResult dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.respawnDimension.a()); -+ DataResult<NBTBase> dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.respawnDimension.a()); // CraftBukkit - decompile error +@@ -374,7 +484,7 @@ + nbttagcompound.putInt("SpawnZ", this.respawnPosition.getZ()); + nbttagcompound.putBoolean("SpawnForced", this.respawnForced); + nbttagcompound.putFloat("SpawnAngle", this.respawnAngle); +- DataResult dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.respawnDimension.location()); ++ DataResult<NBTBase> dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.respawnDimension.location()); // CraftBukkit - decompile error Logger logger = EntityPlayer.LOGGER; Objects.requireNonNull(logger); -@@ -375,9 +485,33 @@ - nbttagcompound.set("SpawnDimension", nbtbase); +@@ -382,9 +492,33 @@ + nbttagcompound.put("SpawnDimension", nbtbase); }); } + this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit @@ -183,26 +183,26 @@ + this.unsetRemoved(); + Vec3D position = null; + if (this.respawnDimension != null) { -+ world = this.getWorldServer().getCraftServer().getHandle().getServer().getWorldServer(this.respawnDimension); -+ if (world != null && this.getSpawn() != null) { -+ position = EntityHuman.getBed((WorldServer) world, this.getSpawn(), this.getSpawnAngle(), false, false).orElse(null); ++ world = this.getLevel().getCraftServer().getHandle().getServer().getLevel(this.respawnDimension); ++ if (world != null && this.getRespawnPosition() != null) { ++ position = EntityHuman.findRespawnPositionAndUseSpawnBlock((WorldServer) world, this.getRespawnPosition(), this.getRespawnAngle(), false, false).orElse(null); + } + } + if (world == null || position == null) { + world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle(); -+ position = Vec3D.a(((WorldServer) world).getSpawn()); ++ position = Vec3D.atCenterOf(((WorldServer) world).getSharedSpawnPos()); + } + this.level = world; -+ this.setPosition(position.getX(), position.getY(), position.getZ()); ++ this.setPos(position.x(), position.y(), position.z()); + } -+ this.gameMode.a((WorldServer) world); ++ this.gameMode.setLevel((WorldServer) world); + } + // CraftBukkit end + - public void a(int i) { - float f = (float) this.getExpToLevel(); + public void setExperiencePoints(int i) { + float f = (float) this.getXpNeededForNextLevel(); float f1 = (f - 1.0F) / f; -@@ -436,6 +570,11 @@ +@@ -443,6 +577,11 @@ @Override public void tick() { @@ -211,20 +211,20 @@ + this.joining = false; + } + // CraftBukkit end - this.gameMode.a(); + this.gameMode.tick(); --this.spawnInvulnerableTime; if (this.invulnerableTime > 0) { -@@ -489,7 +628,7 @@ +@@ -498,7 +637,7 @@ } if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { -- this.connection.sendPacket(new PacketPlayOutUpdateHealth(this.getHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel())); -+ this.connection.sendPacket(new PacketPlayOutUpdateHealth(this.getBukkitEntity().getScaledHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel())); // CraftBukkit +- this.connection.send(new PacketPlayOutUpdateHealth(this.getHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel())); ++ this.connection.send(new PacketPlayOutUpdateHealth(this.getBukkitEntity().getScaledHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel())); // CraftBukkit this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -520,6 +659,12 @@ - this.a(IScoreboardCriteria.EXPERIENCE, MathHelper.f((float) this.lastRecordedExperience)); +@@ -529,6 +668,12 @@ + this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience)); } + // CraftBukkit start - Force max health updates @@ -235,9 +235,9 @@ + if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; - this.a(IScoreboardCriteria.LEVEL, MathHelper.f((float) this.lastRecordedLevel)); -@@ -534,6 +679,16 @@ - CriterionTriggers.LOCATION.a(this); + this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel)); +@@ -543,6 +688,16 @@ + CriterionTriggers.LOCATION.trigger(this); } + // CraftBukkit start - initialize oldLevel and fire PlayerLevelChangeEvent @@ -251,19 +251,19 @@ + } + // CraftBukkit end } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Ticking player"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked"); -@@ -544,7 +699,8 @@ + CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player"); + CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked"); +@@ -585,7 +740,8 @@ } - private void a(IScoreboardCriteria iscoreboardcriteria, int i) { -- this.getScoreboard().getObjectivesForCriteria(iscoreboardcriteria, this.getName(), (scoreboardscore) -> { + private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) { +- this.getScoreboard().forAllObjectives(iscoreboardcriteria, this.getScoreboardName(), (scoreboardscore) -> { + // CraftBukkit - Use our scores instead -+ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(iscoreboardcriteria, this.getName(), (scoreboardscore) -> { ++ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(iscoreboardcriteria, this.getScoreboardName(), (scoreboardscore) -> { scoreboardscore.setScore(i); }); } -@@ -552,9 +708,47 @@ +@@ -593,9 +749,47 @@ @Override public void die(DamageSource damagesource) { boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); @@ -271,18 +271,18 @@ + if (this.isRemoved()) { + return; + } -+ java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(this.getInventory().getSize()); ++ java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(this.getInventory().getContainerSize()); + boolean keepInventory = this.level.getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || this.isSpectator(); + + if (!keepInventory) { + for (ItemStack item : this.getInventory().getContents()) { -+ if (!item.isEmpty() && !EnchantmentManager.shouldNotDrop(item)) { ++ if (!item.isEmpty() && !EnchantmentManager.hasVanishingCurse(item)) { + loot.add(CraftItemStack.asCraftMirror(item)); + } + } + } + // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule) -+ this.a(damagesource, this.lastHurtByPlayerTime > 0); ++ this.dropFromLootTable(damagesource, this.lastHurtByPlayerTime > 0); + for (org.bukkit.inventory.ItemStack item : this.drops) { + loot.add(item); + } @@ -298,7 +298,7 @@ + + // SPIGOT-943 - only call if they have an inventory open + if (this.containerMenu != this.inventoryMenu) { -+ this.closeInventory(); ++ this.closeContainer(); + } + + String deathMessage = event.getDeathMessage(); @@ -311,72 +311,72 @@ + ichatbasecomponent = org.bukkit.craftbukkit.util.CraftChatMessage.fromStringOrNull(deathMessage); + } - this.connection.a((Packet) (new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), ichatbasecomponent)), (future) -> { + this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), ichatbasecomponent), (future) -> { if (!future.isSuccess()) { -@@ -588,12 +782,18 @@ +@@ -629,12 +823,18 @@ if (this.level.getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) { - this.fI(); + this.tellNeutralMobsThatIDied(); } - - if (!this.isSpectator()) { -- this.f(damagesource); +- this.dropAllDeathLoot(damagesource); + // SPIGOT-5478 must be called manually now + this.dropExperience(); + // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. + if (!event.getKeepInventory()) { -+ this.getInventory().clear(); ++ this.getInventory().clearContent(); } -- this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.DEATH_COUNT, this.getName(), ScoreboardScore::incrementScore); -+ this.setSpectatorTarget(this); // Remove spectated target +- this.getScoreboard().forAllObjectives(IScoreboardCriteria.DEATH_COUNT, this.getScoreboardName(), ScoreboardScore::increment); ++ this.setCamera(this); // Remove spectated target + // CraftBukkit end + + // CraftBukkit - Get our scores instead -+ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.DEATH_COUNT, this.getName(), ScoreboardScore::incrementScore); - EntityLiving entityliving = this.getKillingEntity(); ++ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.DEATH_COUNT, this.getScoreboardName(), ScoreboardScore::increment); + EntityLiving entityliving = this.getKillCredit(); if (entityliving != null) { -@@ -630,10 +830,12 @@ - String s = this.getName(); - String s1 = entity.getName(); +@@ -671,10 +871,12 @@ + String s = this.getScoreboardName(); + String s1 = entity.getScoreboardName(); -- this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.KILL_COUNT_ALL, s, ScoreboardScore::incrementScore); +- this.getScoreboard().forAllObjectives(IScoreboardCriteria.KILL_COUNT_ALL, s, ScoreboardScore::increment); + // CraftBukkit - Get our scores instead -+ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.KILL_COUNT_ALL, s, ScoreboardScore::incrementScore); ++ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.KILL_COUNT_ALL, s, ScoreboardScore::increment); if (entity instanceof EntityHuman) { - this.a(StatisticList.PLAYER_KILLS); -- this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.KILL_COUNT_PLAYERS, s, ScoreboardScore::incrementScore); + this.awardStat(StatisticList.PLAYER_KILLS); +- this.getScoreboard().forAllObjectives(IScoreboardCriteria.KILL_COUNT_PLAYERS, s, ScoreboardScore::increment); + // CraftBukkit - Get our scores instead -+ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.KILL_COUNT_PLAYERS, s, ScoreboardScore::incrementScore); ++ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.KILL_COUNT_PLAYERS, s, ScoreboardScore::increment); } else { - this.a(StatisticList.MOB_KILLS); + this.awardStat(StatisticList.MOB_KILLS); } -@@ -651,7 +853,8 @@ - int i = scoreboardteam.getColor().b(); +@@ -692,7 +894,8 @@ + int i = scoreboardteam.getColor().getId(); if (i >= 0 && i < aiscoreboardcriteria.length) { -- this.getScoreboard().getObjectivesForCriteria(aiscoreboardcriteria[i], s, ScoreboardScore::incrementScore); +- this.getScoreboard().forAllObjectives(aiscoreboardcriteria[i], s, ScoreboardScore::increment); + // CraftBukkit - Get our scores instead -+ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(aiscoreboardcriteria[i], s, ScoreboardScore::incrementScore); ++ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(aiscoreboardcriteria[i], s, ScoreboardScore::increment); } } -@@ -695,18 +898,20 @@ +@@ -736,18 +939,20 @@ } - private boolean canPvP() { -- return this.server.getPVP(); -+ // CraftBukkit - this.server.getPvP() -> this.world.pvpMode + private boolean isPvpAllowed() { +- return this.server.isPvpAllowed(); ++ // CraftBukkit - this.server.isPvpAllowed() -> this.world.pvpMode + return this.level.pvpMode; } @Nullable @Override - protected ShapeDetectorShape a(WorldServer worldserver) { - ShapeDetectorShape shapedetectorshape = super.a(worldserver); + protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) { + ShapeDetectorShape shapedetectorshape = super.findDimensionEntryPoint(worldserver); + worldserver = (shapedetectorshape == null) ? worldserver : shapedetectorshape.world; // CraftBukkit -- if (shapedetectorshape != null && this.level.getDimensionKey() == World.OVERWORLD && worldserver.getDimensionKey() == World.END) { +- if (shapedetectorshape != null && this.level.dimension() == World.OVERWORLD && worldserver.dimension() == World.END) { + if (shapedetectorshape != null && this.level.getTypeKey() == DimensionManager.OVERWORLD_LOCATION && worldserver != null && worldserver.getTypeKey() == DimensionManager.END_LOCATION) { // CraftBukkit Vec3D vec3d = shapedetectorshape.pos.add(0.0D, -1.0D, 0.0D); @@ -385,57 +385,57 @@ } else { return shapedetectorshape; } -@@ -715,11 +920,20 @@ +@@ -756,11 +961,20 @@ @Nullable @Override - public Entity b(WorldServer worldserver) { + public Entity changeDimension(WorldServer worldserver) { - this.isChangingDimension = true; + // CraftBukkit start -+ return b(worldserver, TeleportCause.UNKNOWN); ++ return changeDimension(worldserver, TeleportCause.UNKNOWN); + } + + @Nullable -+ public Entity b(WorldServer worldserver, PlayerTeleportEvent.TeleportCause cause) { ++ public Entity changeDimension(WorldServer worldserver, PlayerTeleportEvent.TeleportCause cause) { + // CraftBukkit end + if (this.isSleeping()) return this; // CraftBukkit - SPIGOT-3154 -+ // this.worldChangeInvuln = true; // CraftBukkit - Moved down and into PlayerList#changeDimension - WorldServer worldserver1 = this.getWorldServer(); -- ResourceKey<World> resourcekey = worldserver1.getDimensionKey(); ++ // this.isChangingDimension = true; // CraftBukkit - Moved down and into PlayerList#changeDimension + WorldServer worldserver1 = this.getLevel(); +- ResourceKey<World> resourcekey = worldserver1.dimension(); + ResourceKey<DimensionManager> resourcekey = worldserver1.getTypeKey(); // CraftBukkit -- if (resourcekey == World.END && worldserver.getDimensionKey() == World.OVERWORLD) { +- if (resourcekey == World.END && worldserver.dimension() == World.OVERWORLD) { + if (resourcekey == DimensionManager.END_LOCATION && worldserver != null && worldserver.getTypeKey() == DimensionManager.OVERWORLD_LOCATION) { // CraftBukkit + this.isChangingDimension = true; // CraftBukkit - Moved down from above - this.decouple(); - this.getWorldServer().a(this, Entity.RemovalReason.CHANGED_DIMENSION); + this.unRide(); + this.getLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); if (!this.wonGame) { -@@ -730,6 +944,8 @@ +@@ -771,6 +985,8 @@ return this; } else { + // CraftBukkit start + /* - WorldData worlddata = worldserver.getWorldData(); + WorldData worlddata = worldserver.getLevelData(); - this.connection.sendPacket(new PacketPlayOutRespawn(worldserver.getDimensionManager(), worldserver.getDimensionKey(), BiomeManager.a(worldserver.getSeed()), this.gameMode.getGameMode(), this.gameMode.c(), worldserver.isDebugWorld(), worldserver.isFlatWorld(), true)); -@@ -739,22 +955,52 @@ - playerlist.d(this); - worldserver1.a(this, Entity.RemovalReason.CHANGED_DIMENSION); + this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionType(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true)); +@@ -780,22 +996,52 @@ + playerlist.sendPlayerPermissionLevel(this); + worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); this.unsetRemoved(); + */ + // CraftBukkit end - ShapeDetectorShape shapedetectorshape = this.a(worldserver); + ShapeDetectorShape shapedetectorshape = this.findDimensionEntryPoint(worldserver); if (shapedetectorshape != null) { - worldserver1.getMethodProfiler().enter("moving"); -- if (resourcekey == World.OVERWORLD && worldserver.getDimensionKey() == World.NETHER) { + worldserver1.getProfiler().push("moving"); +- if (resourcekey == World.OVERWORLD && worldserver.dimension() == World.NETHER) { + worldserver = shapedetectorshape.world; // CraftBukkit + if (worldserver == null) { } else // CraftBukkit - empty to fall through to null to event + if (resourcekey == DimensionManager.OVERWORLD_LOCATION && worldserver.getTypeKey() == DimensionManager.NETHER_LOCATION) { // CraftBukkit - this.enteredNetherPosition = this.getPositionVector(); -- } else if (worldserver.getDimensionKey() == World.END) { + this.enteredNetherPosition = this.position(); +- } else if (worldserver.dimension() == World.END) { + } else if (worldserver.getTypeKey() == DimensionManager.END_LOCATION && shapedetectorshape.portalEventInfo != null && shapedetectorshape.portalEventInfo.getCanCreatePortal()) { // CraftBukkit - this.a(worldserver, new BlockPosition(shapedetectorshape.pos)); + this.createEndPlatform(worldserver, new BlockPosition(shapedetectorshape.pos)); } + // CraftBukkit start + } else { @@ -452,32 +452,32 @@ + worldserver = ((CraftWorld) exit.getWorld()).getHandle(); + // CraftBukkit end + -+ worldserver1.getMethodProfiler().exit(); -+ worldserver1.getMethodProfiler().enter("placing"); ++ worldserver1.getProfiler().pop(); ++ worldserver1.getProfiler().push("placing"); + if (true) { // CraftBukkit + this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds + -+ this.connection.sendPacket(new PacketPlayOutRespawn(worldserver.getDimensionManager(), worldserver.getDimensionKey(), BiomeManager.a(worldserver.getSeed()), this.gameMode.getGameMode(), this.gameMode.c(), worldserver.isDebugWorld(), worldserver.isFlatWorld(), true)); -+ this.connection.sendPacket(new PacketPlayOutServerDifficulty(this.level.getDifficulty(), this.level.getWorldData().isDifficultyLocked())); ++ this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionType(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true)); ++ this.connection.send(new PacketPlayOutServerDifficulty(this.level.getDifficulty(), this.level.getLevelData().isDifficultyLocked())); + PlayerList playerlist = this.server.getPlayerList(); + -+ playerlist.d(this); -+ worldserver1.a(this, Entity.RemovalReason.CHANGED_DIMENSION); ++ playerlist.sendPlayerPermissionLevel(this); ++ worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); + this.unsetRemoved(); -- worldserver1.getMethodProfiler().exit(); -- worldserver1.getMethodProfiler().enter("placing"); +- worldserver1.getProfiler().pop(); +- worldserver1.getProfiler().push("placing"); + // CraftBukkit end - this.spawnIn(worldserver); - worldserver.addPlayerPortal(this); -- this.setYawPitch(shapedetectorshape.yRot, shapedetectorshape.xRot); -- this.teleportAndSync(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z); + this.setLevel(worldserver); + worldserver.addDuringPortalTeleport(this); +- this.setRot(shapedetectorshape.yRot, shapedetectorshape.xRot); +- this.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z); + this.connection.teleport(exit); // CraftBukkit - use internal teleport without event -+ this.connection.syncPosition(); // CraftBukkit - sync position after changing it (from PortalTravelAgent#findAndteleport) - worldserver1.getMethodProfiler().exit(); - this.triggerDimensionAdvancements(worldserver1); - this.connection.sendPacket(new PacketPlayOutAbilities(this.getAbilities())); -@@ -772,12 +1018,31 @@ ++ this.connection.resetPosition(); // CraftBukkit - sync position after changing it (from PortalTravelAgent#findAndteleport) + worldserver1.getProfiler().pop(); + this.triggerDimensionChangeTriggers(worldserver1); + this.connection.send(new PacketPlayOutAbilities(this.getAbilities())); +@@ -813,12 +1059,31 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -506,25 +506,25 @@ + } + // CraftBukkit end + - private void a(WorldServer worldserver, BlockPosition blockposition) { - BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.i(); + private void createEndPlatform(WorldServer worldserver, BlockPosition blockposition) { + BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable(); -@@ -794,17 +1059,17 @@ +@@ -835,17 +1100,17 @@ } @Override -- protected Optional<BlockUtil.Rectangle> findOrCreatePortal(WorldServer worldserver, BlockPosition blockposition, boolean flag) { -- Optional<BlockUtil.Rectangle> optional = super.findOrCreatePortal(worldserver, blockposition, flag); -+ protected Optional<BlockUtil.Rectangle> findOrCreatePortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, int searchRadius, boolean canCreatePortal, int createRadius) { // CraftBukkit -+ Optional<BlockUtil.Rectangle> optional = super.findOrCreatePortal(worldserver, blockposition, flag, searchRadius, canCreatePortal, createRadius); // CraftBukkit +- protected Optional<BlockUtil.Rectangle> getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder) { +- Optional<BlockUtil.Rectangle> optional = super.getExitPortal(worldserver, blockposition, flag, worldborder); ++ protected Optional<BlockUtil.Rectangle> getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder, int searchRadius, boolean canCreatePortal, int createRadius) { // CraftBukkit ++ Optional<BlockUtil.Rectangle> optional = super.getExitPortal(worldserver, blockposition, flag, worldborder, searchRadius, canCreatePortal, createRadius); // CraftBukkit - if (optional.isPresent()) { + if (optional.isPresent() || !canCreatePortal) { // CraftBukkit return optional; } else { - EnumDirection.EnumAxis enumdirection_enumaxis = (EnumDirection.EnumAxis) this.level.getType(this.portalEntrancePos).d(BlockPortal.AXIS).orElse(EnumDirection.EnumAxis.X); -- Optional<BlockUtil.Rectangle> optional1 = worldserver.getTravelAgent().createPortal(blockposition, enumdirection_enumaxis); -+ Optional<BlockUtil.Rectangle> optional1 = worldserver.getTravelAgent().createPortal(blockposition, enumdirection_enumaxis, this, createRadius); // CraftBukkit + EnumDirection.EnumAxis enumdirection_enumaxis = (EnumDirection.EnumAxis) this.level.getBlockState(this.portalEntrancePos).getOptionalValue(BlockPortal.AXIS).orElse(EnumDirection.EnumAxis.X); +- Optional<BlockUtil.Rectangle> optional1 = worldserver.getPortalForcer().createPortal(blockposition, enumdirection_enumaxis); ++ Optional<BlockUtil.Rectangle> optional1 = worldserver.getPortalForcer().createPortal(blockposition, enumdirection_enumaxis, this, createRadius); // CraftBukkit if (!optional1.isPresent()) { - EntityPlayer.LOGGER.error("Unable to create a portal, likely target out of worldborder"); @@ -532,24 +532,24 @@ } return optional1; -@@ -814,13 +1079,21 @@ - public void triggerDimensionAdvancements(WorldServer worldserver) { - ResourceKey<World> resourcekey = worldserver.getDimensionKey(); - ResourceKey<World> resourcekey1 = this.level.getDimensionKey(); +@@ -855,13 +1120,21 @@ + public void triggerDimensionChangeTriggers(WorldServer worldserver) { + ResourceKey<World> resourcekey = worldserver.dimension(); + ResourceKey<World> resourcekey1 = this.level.dimension(); + // CraftBukkit start + ResourceKey<World> maindimensionkey = CraftDimensionUtil.getMainDimensionKey(worldserver); + ResourceKey<World> maindimensionkey1 = CraftDimensionUtil.getMainDimensionKey(this.level); -- CriterionTriggers.CHANGED_DIMENSION.a(this, resourcekey, resourcekey1); +- CriterionTriggers.CHANGED_DIMENSION.trigger(this, resourcekey, resourcekey1); - if (resourcekey == World.NETHER && resourcekey1 == World.OVERWORLD && this.enteredNetherPosition != null) { -+ CriterionTriggers.CHANGED_DIMENSION.a(this, maindimensionkey, maindimensionkey1); ++ CriterionTriggers.CHANGED_DIMENSION.trigger(this, maindimensionkey, maindimensionkey1); + if (maindimensionkey != resourcekey || maindimensionkey1 != resourcekey1) { -+ CriterionTriggers.CHANGED_DIMENSION.a(this, resourcekey, resourcekey1); ++ CriterionTriggers.CHANGED_DIMENSION.trigger(this, resourcekey, resourcekey1); + } + + if (maindimensionkey == World.NETHER && maindimensionkey1 == World.OVERWORLD && this.enteredNetherPosition != null) { + // CraftBukkit end - CriterionTriggers.NETHER_TRAVEL.a(this, this.enteredNetherPosition); + CriterionTriggers.NETHER_TRAVEL.trigger(this, this.enteredNetherPosition); } - if (resourcekey1 != World.NETHER) { @@ -557,27 +557,27 @@ this.enteredNetherPosition = null; } -@@ -848,12 +1121,10 @@ - this.containerMenu.d(); +@@ -878,12 +1151,10 @@ + this.containerMenu.broadcastChanges(); } - @Override -- public Either<EntityHuman.EnumBedResult, Unit> sleep(BlockPosition blockposition) { -- EnumDirection enumdirection = (EnumDirection) this.level.getType(blockposition).get(BlockFacingHorizontal.FACING); +- public Either<EntityHuman.EnumBedResult, Unit> startSleepInBed(BlockPosition blockposition) { +- EnumDirection enumdirection = (EnumDirection) this.level.getBlockState(blockposition).getValue(BlockFacingHorizontal.FACING); - + // CraftBukkit start - moved bed result checks from below into separate method + private Either<EntityHuman.EnumBedResult, Unit> getBedResult(BlockPosition blockposition, EnumDirection enumdirection) { if (!this.isSleeping() && this.isAlive()) { -- if (!this.level.getDimensionManager().isNatural()) { -+ if (!this.level.getDimensionManager().isNatural() || !this.level.getDimensionManager().isBedWorks()) { +- if (!this.level.dimensionType().natural()) { ++ if (!this.level.dimensionType().natural() || !this.level.dimensionType().bedWorks()) { return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE); - } else if (!this.a(blockposition, enumdirection)) { + } else if (!this.bedInRange(blockposition, enumdirection)) { return Either.left(EntityHuman.EnumBedResult.TOO_FAR_AWAY); -@@ -877,7 +1148,36 @@ +@@ -907,7 +1178,36 @@ } } -- Either<EntityHuman.EnumBedResult, Unit> either = super.sleep(blockposition).ifRight((unit) -> { +- Either<EntityHuman.EnumBedResult, Unit> either = super.startSleepInBed(blockposition).ifRight((unit) -> { + return Either.right(Unit.INSTANCE); + } + } @@ -587,8 +587,8 @@ + } + + @Override -+ public Either<EntityHuman.EnumBedResult, Unit> sleep(BlockPosition blockposition, boolean force) { -+ EnumDirection enumdirection = (EnumDirection) this.level.getType(blockposition).get(BlockFacingHorizontal.FACING); ++ public Either<EntityHuman.EnumBedResult, Unit> startSleepInBed(BlockPosition blockposition, boolean force) { ++ EnumDirection enumdirection = (EnumDirection) this.level.getBlockState(blockposition).getValue(BlockFacingHorizontal.FACING); + Either<EntityHuman.EnumBedResult, Unit> bedResult = this.getBedResult(blockposition, enumdirection); + + if (bedResult.left().orElse(null) == EntityHuman.EnumBedResult.OTHER_PROBLEM) { @@ -607,11 +607,11 @@ + { + { + { -+ Either<EntityHuman.EnumBedResult, Unit> either = super.sleep(blockposition, force).ifRight((unit) -> { - this.a(StatisticList.SLEEP_IN_BED); - CriterionTriggers.SLEPT_IN_BED.a(this); ++ Either<EntityHuman.EnumBedResult, Unit> either = super.startSleepInBed(blockposition, force).ifRight((unit) -> { + this.awardStat(StatisticList.SLEEP_IN_BED); + CriterionTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -890,9 +1190,8 @@ +@@ -920,9 +1220,8 @@ return either; } } @@ -622,14 +622,14 @@ } @Override -@@ -919,6 +1218,24 @@ +@@ -949,6 +1248,24 @@ @Override - public void wakeup(boolean flag, boolean flag1) { + public void stopSleepInBed(boolean flag, boolean flag1) { + if (!this.isSleeping()) return; // CraftBukkit - Can't leave bed if not in one! + // CraftBukkit start - fire PlayerBedLeaveEvent + CraftPlayer player = this.getBukkitEntity(); -+ BlockPosition bedPosition = this.getBedPosition().orElse(null); ++ BlockPosition bedPosition = this.getSleepingPos().orElse(null); + + org.bukkit.block.Block bed; + if (bedPosition != null) { @@ -645,10 +645,10 @@ + } + // CraftBukkit end if (this.isSleeping()) { - this.getWorldServer().getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutAnimation(this, 2)); + this.getLevel().getChunkSource().broadcastAndSend(this, new PacketPlayOutAnimation(this, 2)); } -@@ -1000,8 +1317,9 @@ - this.connection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition())); +@@ -1030,8 +1347,9 @@ + this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos())); } - public void nextContainerCounter() { @@ -658,14 +658,14 @@ } @Override -@@ -1009,13 +1327,35 @@ +@@ -1039,13 +1357,35 @@ if (itileinventory == null) { return OptionalInt.empty(); } else { + // CraftBukkit start - SPIGOT-6552: Handle inventory closing in CraftEventFactory#callInventoryOpenEvent(...) + /* if (this.containerMenu != this.inventoryMenu) { - this.closeInventory(); + this.closeContainer(); } + */ + // CraftBukkit end @@ -675,17 +675,17 @@ + // CraftBukkit start - Inventory open hook + if (container != null) { -+ container.setTitle(itileinventory.getScoreboardDisplayName()); ++ container.setTitle(itileinventory.getDisplayName()); + + boolean cancelled = false; + container = CraftEventFactory.callInventoryOpenEvent(this, container, cancelled); + if (container == null && !cancelled) { // Let pre-cancelled events fall through + // SPIGOT-5263 - close chest if cancelled + if (itileinventory instanceof IInventory) { -+ ((IInventory) itileinventory).closeContainer(this); ++ ((IInventory) itileinventory).stopOpen(this); + } else if (itileinventory instanceof BlockChest.DoubleInventory) { + // SPIGOT-5355 - double chests too :( -+ ((BlockChest.DoubleInventory) itileinventory).inventorylargechest.closeContainer(this); ++ ((BlockChest.DoubleInventory) itileinventory).inventorylargechest.stopOpen(this); + } + return OptionalInt.empty(); + } @@ -693,123 +693,119 @@ + // CraftBukkit end if (container == null) { if (this.isSpectator()) { - this.a((IChatBaseComponent) (new ChatMessage("container.spectatorCantOpen")).a(EnumChatFormat.RED), true); -@@ -1023,9 +1363,11 @@ + this.displayClientMessage((new ChatMessage("container.spectatorCantOpen")).withStyle(EnumChatFormat.RED), true); +@@ -1053,9 +1393,11 @@ return OptionalInt.empty(); } else { -- this.connection.sendPacket(new PacketPlayOutOpenWindow(container.containerId, container.getType(), itileinventory.getScoreboardDisplayName())); +- this.connection.send(new PacketPlayOutOpenWindow(container.containerId, container.getType(), itileinventory.getDisplayName())); - this.initMenu(container); + // CraftBukkit start this.containerMenu = container; -+ this.connection.sendPacket(new PacketPlayOutOpenWindow(container.containerId, container.getType(), container.getTitle())); ++ this.connection.send(new PacketPlayOutOpenWindow(container.containerId, container.getType(), container.getTitle())); + // CraftBukkit end + this.initMenu(container); return OptionalInt.of(this.containerCounter); } } -@@ -1038,13 +1380,24 @@ +@@ -1068,13 +1410,24 @@ @Override public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { + // CraftBukkit start - Inventory open hook + this.nextContainerCounter(); + Container container = new ContainerHorse(this.containerCounter, this.getInventory(), iinventory, entityhorseabstract); -+ container.setTitle(entityhorseabstract.getScoreboardDisplayName()); ++ container.setTitle(entityhorseabstract.getDisplayName()); + container = CraftEventFactory.callInventoryOpenEvent(this, container); + + if (container == null) { -+ iinventory.closeContainer(this); ++ iinventory.stopOpen(this); + return; + } + // CraftBukkit end if (this.containerMenu != this.inventoryMenu) { - this.closeInventory(); + this.closeContainer(); } - this.nextContainerCounter(); + // this.nextContainerCounter(); // CraftBukkit - moved up - this.connection.sendPacket(new PacketPlayOutOpenWindowHorse(this.containerCounter, iinventory.getSize(), entityhorseabstract.getId())); + this.connection.send(new PacketPlayOutOpenWindowHorse(this.containerCounter, iinventory.getContainerSize(), entityhorseabstract.getId())); - this.containerMenu = new ContainerHorse(this.containerCounter, this.getInventory(), iinventory, entityhorseabstract); + this.containerMenu = container; // CraftBukkit this.initMenu(this.containerMenu); } -@@ -1068,6 +1421,7 @@ +@@ -1097,6 +1450,7 @@ @Override - public void closeInventory() { + public void closeContainer() { + CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit - this.connection.sendPacket(new PacketPlayOutCloseWindow(this.containerMenu.containerId)); - this.o(); + this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId)); + this.doCloseContainer(); } -@@ -1097,7 +1451,7 @@ +@@ -1126,7 +1480,7 @@ @Override - public void a(Statistic<?> statistic, int i) { - this.stats.b(this, statistic, i); -- this.getScoreboard().getObjectivesForCriteria(statistic, this.getName(), (scoreboardscore) -> { -+ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(statistic, this.getName(), (scoreboardscore) -> { // CraftBukkit - Get our scores instead - scoreboardscore.addScore(i); + public void awardStat(Statistic<?> statistic, int i) { + this.stats.increment(this, statistic, i); +- this.getScoreboard().forAllObjectives(statistic, this.getScoreboardName(), (scoreboardscore) -> { ++ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(statistic, this.getScoreboardName(), (scoreboardscore) -> { // CraftBukkit - Get our scores instead + scoreboardscore.add(i); }); } -@@ -1105,7 +1459,7 @@ +@@ -1134,7 +1488,7 @@ @Override - public void a(Statistic<?> statistic) { - this.stats.setStatistic(this, statistic, 0); -- this.getScoreboard().getObjectivesForCriteria(statistic, this.getName(), ScoreboardScore::c); -+ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(statistic, this.getName(), ScoreboardScore::c); // CraftBukkit - Get our scores instead + public void resetStat(Statistic<?> statistic) { + this.stats.setValue(this, statistic, 0); +- this.getScoreboard().forAllObjectives(statistic, this.getScoreboardName(), ScoreboardScore::reset); ++ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(statistic, this.getScoreboardName(), ScoreboardScore::reset); // CraftBukkit - Get our scores instead } @Override -@@ -1121,7 +1475,7 @@ +@@ -1150,7 +1504,7 @@ for (int j = 0; j < i; ++j) { MinecraftKey minecraftkey = aminecraftkey1[j]; -- Optional optional = this.server.getCraftingManager().getRecipe(minecraftkey); -+ Optional<? extends IRecipe<?>> optional = this.server.getCraftingManager().getRecipe(minecraftkey); // CraftBukkit - decompile error +- Optional optional = this.server.getRecipeManager().byKey(minecraftkey); ++ Optional<? extends IRecipe<?>> optional = this.server.getRecipeManager().byKey(minecraftkey); // CraftBukkit - decompile error Objects.requireNonNull(list); optional.ifPresent(list::add); -@@ -1156,7 +1510,16 @@ +@@ -1185,8 +1539,17 @@ - public void triggerHealthUpdate() { + public void resetSentInfo() { this.lastSentHealth = -1.0E8F; + this.lastSentExp = -1; // CraftBukkit - Added to reset -+ } -+ + } + + // CraftBukkit start - Support multi-line messages + public void sendMessage(UUID uuid, IChatBaseComponent[] ichatbasecomponent) { + for (IChatBaseComponent component : ichatbasecomponent) { + this.sendMessage(component, (uuid == null) ? SystemUtils.NIL_UUID : uuid); + } - } ++ } + // CraftBukkit end - ++ @Override - public void a(IChatBaseComponent ichatbasecomponent, boolean flag) { -@@ -1211,11 +1574,12 @@ + public void displayClientMessage(IChatBaseComponent ichatbasecomponent, boolean flag) { + this.sendMessage(ichatbasecomponent, flag ? ChatMessageType.GAME_INFO : ChatMessageType.CHAT, SystemUtils.NIL_UUID); +@@ -1240,7 +1603,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; -- this.recipeBook.a((RecipeBook) entityplayer.recipeBook); -+ // this.recipeBook.a((RecipeBook) entityplayer.recipeBook); // CraftBukkit +- this.recipeBook.copyOverData(entityplayer.recipeBook); ++ // this.recipeBook.copyOverData(entityplayer.recipeBook); // CraftBukkit this.seenCredits = entityplayer.seenCredits; this.enteredNetherPosition = entityplayer.enteredNetherPosition; this.setShoulderEntityLeft(entityplayer.getShoulderEntityLeft()); - this.setShoulderEntityRight(entityplayer.getShoulderEntityRight()); -+ - } - - @Override -@@ -1337,7 +1701,20 @@ +@@ -1367,7 +1730,20 @@ return s; } + public String locale = "en_us"; // CraftBukkit - add, lowercase - public void a(PacketPlayInSettings packetplayinsettings) { + public void updateOptions(PacketPlayInSettings packetplayinsettings) { + // CraftBukkit start -+ if (getMainHand() != packetplayinsettings.getMainHand()) { -+ PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(getBukkitEntity(), getMainHand() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT); ++ if (getMainArm() != packetplayinsettings.mainHand()) { ++ PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(getBukkitEntity(), getMainArm() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT); + this.server.server.getPluginManager().callEvent(event); + } + if (!this.locale.equals(packetplayinsettings.language)) { @@ -819,47 +815,47 @@ + this.locale = packetplayinsettings.language; + this.clientViewDistance = packetplayinsettings.viewDistance; + // CraftBukkit end - this.chatVisibility = packetplayinsettings.d(); - this.canChatColor = packetplayinsettings.e(); - this.textFilteringEnabled = packetplayinsettings.h(); -@@ -1407,7 +1784,7 @@ + this.chatVisibility = packetplayinsettings.chatVisibility(); + this.canChatColor = packetplayinsettings.chatColors(); + this.textFilteringEnabled = packetplayinsettings.textFilteringEnabled(); +@@ -1438,7 +1814,7 @@ this.camera = (Entity) (entity == null ? this : entity); if (entity1 != this.camera) { - this.connection.sendPacket(new PacketPlayOutCamera(this.camera)); -- this.enderTeleportTo(this.camera.locX(), this.camera.locY(), this.camera.locZ()); -+ this.connection.b(this.camera.locX(), this.camera.locY(), this.camera.locZ(), this.getYRot(), this.getXRot(), TeleportCause.SPECTATE); // CraftBukkit + this.connection.send(new PacketPlayOutCamera(this.camera)); +- this.teleportTo(this.camera.getX(), this.camera.getY(), this.camera.getZ()); ++ this.connection.teleport(this.camera.getX(), this.camera.getY(), this.camera.getZ(), this.getYRot(), this.getXRot(), TeleportCause.SPECTATE); // CraftBukkit } } -@@ -1436,7 +1813,7 @@ +@@ -1467,7 +1843,7 @@ @Nullable - public IChatBaseComponent getPlayerListName() { + public IChatBaseComponent getTabListDisplayName() { - return null; + return listName; // CraftBukkit } @Override -@@ -1457,9 +1834,16 @@ +@@ -1488,9 +1864,16 @@ return this.advancements; } + // CraftBukkit start - public void a(WorldServer worldserver, double d0, double d1, double d2, float f, float f1) { -+ this.a(worldserver, d0, d1, d2, f, f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN); + public void teleportTo(WorldServer worldserver, double d0, double d1, double d2, float f, float f1) { ++ this.teleportTo(worldserver, d0, d1, d2, f, f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN); + } + -+ public void a(WorldServer worldserver, double d0, double d1, double d2, float f, float f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { ++ public void teleportTo(WorldServer worldserver, double d0, double d1, double d2, float f, float f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { + // CraftBukkit end - this.setSpectatorTarget(this); + this.setCamera(this); this.stopRiding(); + /* CraftBukkit start - replace with bukkit handling for multi-world if (worldserver == this.level) { - this.connection.b(d0, d1, d2, f, f1); + this.connection.teleport(d0, d1, d2, f, f1); } else { -@@ -1479,6 +1863,9 @@ - this.server.getPlayerList().a(this, worldserver); - this.server.getPlayerList().updateClient(this); +@@ -1510,6 +1893,9 @@ + this.server.getPlayerList().sendLevelInfo(this, worldserver); + this.server.getPlayerList().sendAllPlayerInfo(this); } + */ + this.getBukkitEntity().teleport(new Location(worldserver.getWorld(), d0, d1, d2, f, f1), cause); @@ -867,9 +863,9 @@ } -@@ -1634,4 +2021,145 @@ - }); - return this.a(itemstack, false, true) != null; +@@ -1668,4 +2054,145 @@ + public boolean allowsListing() { + return this.allowsListing; } + + // CraftBukkit start - Add per-player time and weather. @@ -902,9 +898,9 @@ + } + + if (type == WeatherType.DOWNFALL) { -+ this.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.STOP_RAINING, 0)); ++ this.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.STOP_RAINING, 0)); + } else { -+ this.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.START_RAINING, 0)); ++ this.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.START_RAINING, 0)); + } + } + @@ -915,20 +911,20 @@ + if (this.weather == null) { + // Vanilla + if (oldRain != newRain) { -+ this.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, newRain)); ++ this.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, newRain)); + } + } else { + // Plugin + if (pluginRainPositionPrevious != pluginRainPosition) { -+ this.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, pluginRainPosition)); ++ this.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, pluginRainPosition)); + } + } + + if (oldThunder != newThunder) { + if (weather == WeatherType.DOWNFALL || weather == null) { -+ this.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, newThunder)); ++ this.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, newThunder)); + } else { -+ this.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, 0)); ++ this.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, 0)); + } + } + } @@ -943,28 +939,28 @@ + pluginRainPosition -= 0.01; + } + -+ pluginRainPosition = MathHelper.a(pluginRainPosition, 0.0F, 1.0F); ++ pluginRainPosition = MathHelper.clamp(pluginRainPosition, 0.0F, 1.0F); + } + + public void resetPlayerWeather() { + this.weather = null; -+ this.setPlayerWeather(this.level.getWorldData().hasStorm() ? WeatherType.DOWNFALL : WeatherType.CLEAR, false); ++ this.setPlayerWeather(this.level.getLevelData().isRaining() ? WeatherType.DOWNFALL : WeatherType.CLEAR, false); + } + + @Override + public String toString() { -+ return super.toString() + "(" + this.getName() + " at " + this.locX() + "," + this.locY() + "," + this.locZ() + ")"; ++ return super.toString() + "(" + this.getScoreboardName() + " at " + this.getX() + "," + this.getY() + "," + this.getZ() + ")"; + } + + // SPIGOT-1903, MC-98153 + public void forceSetPositionRotation(double x, double y, double z, float yaw, float pitch) { -+ this.setPositionRotation(x, y, z, yaw, pitch); -+ this.connection.syncPosition(); ++ this.moveTo(x, y, z, yaw, pitch); ++ this.connection.resetPosition(); + } + + @Override -+ public boolean isFrozen() { -+ return super.isFrozen() || !getBukkitEntity().isOnline(); ++ public boolean isImmobile() { ++ return super.isImmobile() || !getBukkitEntity().isOnline(); + } + + @Override @@ -983,7 +979,7 @@ + } + + this.setHealth(this.getMaxHealth()); -+ this.clearActiveItem(); // CraftBukkit - SPIGOT-6682: Clear active item on reset ++ this.stopUsingItem(); // CraftBukkit - SPIGOT-6682: Clear active item on reset + this.remainingFireTicks = 0; + this.fallDistance = 0; + this.foodData = new FoodMetaData(this); @@ -1002,7 +998,7 @@ + if (this.keepLevel) { // CraftBukkit - SPIGOT-6687: Only use keepLevel (was pre-set with RULE_KEEPINVENTORY value in PlayerDeathEvent) + this.experienceProgress = exp; + } else { -+ this.giveExp(this.newExp); ++ this.giveExperiencePoints(this.newExp); + } + this.keepLevel = false; + } diff --git a/paper-server/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch b/paper-server/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch index 9685ed04f5..cddd06be26 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch +++ b/paper-server/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 -@@ -42,6 +42,12 @@ +@@ -40,6 +40,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -13,7 +13,7 @@ public class EntityTrackerEntry { private static final Logger LOGGER = LogManager.getLogger(); -@@ -63,8 +69,12 @@ +@@ -61,8 +67,12 @@ private List<Entity> lastPassengers; private boolean wasRiding; private boolean wasOnGround; @@ -27,12 +27,12 @@ this.ap = Vec3D.ZERO; this.lastPassengers = Collections.emptyList(); this.level = worldserver; -@@ -84,22 +94,22 @@ +@@ -82,22 +92,22 @@ if (!list.equals(this.lastPassengers)) { this.lastPassengers = list; - this.broadcast.accept(new PacketPlayOutMount(this.entity)); -+ this.broadcastIncludingSelf(new PacketPlayOutMount(this.entity)); // CraftBukkit ++ this.broadcastAndSend(new PacketPlayOutMount(this.entity)); // CraftBukkit } - if (this.entity instanceof EntityItemFrame && this.tickCount % 10 == 0) { @@ -42,26 +42,26 @@ - if (itemstack.getItem() instanceof ItemWorldMap) { + if (this.tickCount % 10 == 0 && itemstack.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.tickCounter % 10 logic here so item frames do not enter the other blocks - Integer integer = ItemWorldMap.d(itemstack); - WorldMap worldmap = ItemWorldMap.a(integer, (World) this.level); + Integer integer = ItemWorldMap.getMapId(itemstack); + WorldMap worldmap = ItemWorldMap.getSavedData(integer, this.level); if (worldmap != null) { -- Iterator iterator = this.level.getPlayers().iterator(); +- Iterator iterator = this.level.players().iterator(); + Iterator<ServerPlayerConnection> iterator = this.trackedPlayers.iterator(); // CraftBukkit while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -+ EntityPlayer entityplayer = iterator.next().d(); // CraftBukkit ++ EntityPlayer entityplayer = iterator.next().getPlayer(); // CraftBukkit - worldmap.a((EntityHuman) entityplayer, itemstack); - Packet<?> packet = worldmap.a(integer, entityplayer); -@@ -142,6 +152,17 @@ + worldmap.tickCarriedBy(entityplayer, itemstack); + Packet<?> packet = worldmap.getUpdatePacket(integer, entityplayer); +@@ -140,6 +150,17 @@ boolean flag2 = flag1 || this.tickCount % 60 == 0; boolean flag3 = Math.abs(i - this.yRotp) >= 1 || Math.abs(j - this.xRotp) >= 1; + // CraftBukkit start - Code moved from below + if (flag2) { -+ this.d(); ++ this.updateSentPos(); + } + + if (flag3) { @@ -71,17 +71,17 @@ + // CraftBukkit end + if (this.tickCount > 0 || this.entity instanceof EntityArrow) { - long k = PacketPlayOutEntity.a(vec3d.x); - long l = PacketPlayOutEntity.a(vec3d.y); -@@ -180,6 +201,7 @@ + long k = PacketPlayOutEntity.entityToPacket(vec3d.x); + long l = PacketPlayOutEntity.entityToPacket(vec3d.y); +@@ -178,6 +199,7 @@ } - this.c(); + this.sendDirtyEntityData(); + /* CraftBukkit start - Code moved up if (flag2) { - this.d(); + this.updateSentPos(); } -@@ -188,6 +210,7 @@ +@@ -186,6 +208,7 @@ this.yRotp = i; this.xRotp = j; } @@ -89,11 +89,11 @@ this.wasRiding = false; } -@@ -203,7 +226,27 @@ +@@ -201,7 +224,27 @@ ++this.tickCount; if (this.entity.hurtMarked) { -- this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.entity)); +- this.broadcastAndSend(new PacketPlayOutEntityVelocity(this.entity)); + // CraftBukkit start - Create PlayerVelocity event + boolean cancelled = false; + @@ -112,23 +112,23 @@ + } + + if (!cancelled) { -+ this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.entity)); ++ this.broadcastAndSend(new PacketPlayOutEntityVelocity(this.entity)); + } + // CraftBukkit end this.entity.hurtMarked = false; } -@@ -218,13 +261,16 @@ +@@ -216,13 +259,16 @@ PlayerConnection playerconnection = entityplayer.connection; Objects.requireNonNull(entityplayer.connection); -- this.a(playerconnection::sendPacket); -+ this.a(playerconnection::sendPacket, entityplayer); // CraftBukkit - add player - this.entity.c(entityplayer); +- this.sendPairingData(playerconnection::send); ++ this.sendPairingData(playerconnection::send, entityplayer); // CraftBukkit - add player + this.entity.startSeenByPlayer(entityplayer); } -- public void a(Consumer<Packet<?>> consumer) { -+ public void a(Consumer<Packet<?>> consumer, EntityPlayer entityplayer) { // CraftBukkit - add player +- public void sendPairingData(Consumer<Packet<?>> consumer) { ++ public void sendPairingData(Consumer<Packet<?>> consumer, EntityPlayer entityplayer) { // CraftBukkit - add player if (this.entity.isRemoved()) { - EntityTrackerEntry.LOGGER.warn("Fetching packet for removed entity {}", this.entity); + // CraftBukkit start - Remove useless error spam, just return @@ -137,10 +137,10 @@ + // CraftBukkit end } - Packet<?> packet = this.entity.getPacket(); -@@ -240,6 +286,12 @@ + Packet<?> packet = this.entity.getAddEntityPacket(); +@@ -238,6 +284,12 @@ if (this.entity instanceof EntityLiving) { - Collection<AttributeModifiable> collection = ((EntityLiving) this.entity).getAttributeMap().b(); + Collection<AttributeModifiable> collection = ((EntityLiving) this.entity).getAttributes().getSyncableAttributes(); + // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health + if (this.entity.getId() == entityplayer.getId()) { @@ -151,23 +151,23 @@ if (!collection.isEmpty()) { consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection)); } -@@ -271,8 +323,14 @@ +@@ -269,8 +321,14 @@ if (!list.isEmpty()) { consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list)); } -+ ((EntityLiving) this.entity).updateEquipment(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending ++ ((EntityLiving) this.entity).detectEquipmentUpdates(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending } + // CraftBukkit start - Fix for nonsensical head yaw -+ this.yHeadRotp = MathHelper.d(this.entity.getHeadRotation() * 256.0F / 360.0F); ++ this.yHeadRotp = MathHelper.floor(this.entity.getYHeadRot() * 256.0F / 360.0F); + consumer.accept(new PacketPlayOutEntityHeadRotation(this.entity, (byte) yHeadRotp)); + // CraftBukkit end + if (this.entity instanceof EntityLiving) { EntityLiving entityliving = (EntityLiving) this.entity; - Iterator iterator = entityliving.getEffects().iterator(); -@@ -313,6 +371,11 @@ - Set<AttributeModifiable> set = ((EntityLiving) this.entity).getAttributeMap().getAttributes(); + Iterator iterator = entityliving.getActiveEffects().iterator(); +@@ -311,6 +369,11 @@ + Set<AttributeModifiable> set = ((EntityLiving) this.entity).getAttributes().getDirtyAttributes(); if (!set.isEmpty()) { + // CraftBukkit start - Send scaled max health @@ -175,6 +175,6 @@ + ((EntityPlayer) this.entity).getBukkitEntity().injectScaledMaxHealth(set, false); + } + // CraftBukkit end - this.broadcastIncludingSelf(new PacketPlayOutUpdateAttributes(this.entity.getId(), set)); + this.broadcastAndSend(new PacketPlayOutUpdateAttributes(this.entity.getId(), set)); } diff --git a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunk.patch b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunk.patch index d68950097b..e4a4e3acfb 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunk.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunk.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/PlayerChunk.java +++ b/net/minecraft/server/level/PlayerChunk.java -@@ -38,6 +38,10 @@ +@@ -35,6 +35,10 @@ import net.minecraft.world.level.chunk.ProtoChunkExtension; import net.minecraft.world.level.lighting.LightEngine; @@ -11,7 +11,7 @@ public class PlayerChunk { public static final Either<IChunkAccess, PlayerChunk.Failure> UNLOADED_CHUNK = Either.right(PlayerChunk.Failure.UNLOADED); -@@ -75,11 +79,11 @@ +@@ -72,11 +76,11 @@ this.fullChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE; this.tickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE; this.entityTickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE; @@ -25,30 +25,30 @@ this.pos = chunkcoordintpair; this.levelHeightAccessor = levelheightaccessor; this.lightEngine = lightengine; -@@ -92,6 +96,19 @@ +@@ -89,6 +93,19 @@ this.changedBlocksPerSection = new ShortSet[levelheightaccessor.getSectionsCount()]; } + // CraftBukkit start + public Chunk getFullChunk() { -+ if (!getChunkState(this.oldTicketLevel).isAtLeast(PlayerChunk.State.BORDER)) return null; // note: using oldTicketLevel for isLoaded checks ++ if (!getFullChunkStatus(this.oldTicketLevel).isOrAfter(PlayerChunk.State.BORDER)) return null; // note: using oldTicketLevel for isLoaded checks + return this.getFullChunkUnchecked(); + } + + public Chunk getFullChunkUnchecked() { -+ CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> statusFuture = this.getStatusFutureUnchecked(ChunkStatus.FULL); ++ CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> statusFuture = this.getFutureIfPresentUnchecked(ChunkStatus.FULL); + Either<IChunkAccess, PlayerChunk.Failure> either = (Either<IChunkAccess, PlayerChunk.Failure>) statusFuture.getNow(null); + return (either == null) ? null : (Chunk) either.left().orElse(null); + } + // CraftBukkit end + - public CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> getStatusFutureUnchecked(ChunkStatus chunkstatus) { - CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.futures.get(chunkstatus.c()); + public CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> getFutureIfPresentUnchecked(ChunkStatus chunkstatus) { + CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.futures.get(chunkstatus.getIndex()); -@@ -117,9 +134,9 @@ +@@ -114,9 +131,9 @@ @Nullable - public Chunk getChunk() { - CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture = this.a(); + public Chunk getTickingChunk() { + CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture = this.getTickingChunkFuture(); - Either<Chunk, PlayerChunk.Failure> either = (Either) completablefuture.getNow((Object) null); + Either<Chunk, PlayerChunk.Failure> either = (Either) completablefuture.getNow(null); // CraftBukkit - decompile error @@ -57,15 +57,15 @@ } @Nullable -@@ -164,6 +181,7 @@ +@@ -161,6 +178,7 @@ if (chunk != null) { int i = this.levelHeightAccessor.getSectionIndex(blockposition.getY()); + if (i < 0 || i >= this.changedBlocksPerSection.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296 if (this.changedBlocksPerSection[i] == null) { this.hasChangedSections = true; - this.changedBlocksPerSection[i] = new ShortArraySet(); -@@ -274,7 +292,7 @@ + this.changedBlocksPerSection[i] = new ShortOpenHashSet(); +@@ -271,7 +289,7 @@ CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.futures.get(i); if (completablefuture != null) { @@ -74,7 +74,7 @@ boolean flag = either != null && either.right().isPresent(); if (!flag) { -@@ -341,7 +359,7 @@ +@@ -338,7 +356,7 @@ this.pendingFullStateConfirmation = completablefuture1; completablefuture.thenAccept((either) -> { either.ifLeft((chunk) -> { @@ -83,21 +83,21 @@ }); }); } -@@ -358,6 +376,30 @@ +@@ -355,6 +373,30 @@ boolean flag1 = this.ticketLevel <= PlayerChunkMap.MAX_CHUNK_DISTANCE; - PlayerChunk.State playerchunk_state = getChunkState(this.oldTicketLevel); - PlayerChunk.State playerchunk_state1 = getChunkState(this.ticketLevel); + PlayerChunk.State playerchunk_state = getFullChunkStatus(this.oldTicketLevel); + PlayerChunk.State playerchunk_state1 = getFullChunkStatus(this.ticketLevel); + // CraftBukkit start + // ChunkUnloadEvent: Called before the chunk is unloaded: isChunkLoaded is still true and chunk can still be modified by plugins. -+ if (playerchunk_state.isAtLeast(PlayerChunk.State.BORDER) && !playerchunk_state1.isAtLeast(PlayerChunk.State.BORDER)) { -+ this.getStatusFutureUnchecked(ChunkStatus.FULL).thenAccept((either) -> { ++ if (playerchunk_state.isOrAfter(PlayerChunk.State.BORDER) && !playerchunk_state1.isOrAfter(PlayerChunk.State.BORDER)) { ++ this.getFutureIfPresentUnchecked(ChunkStatus.FULL).thenAccept((either) -> { + Chunk chunk = (Chunk)either.left().orElse(null); + if (chunk != null) { + playerchunkmap.callbackExecutor.execute(() -> { + // Minecraft will apply the chunks tick lists to the world once the chunk got loaded, and then store the tick + // lists again inside the chunk once the chunk becomes inaccessible and set the chunk's needsSaving flag. + // These actions may however happen deferred, so we manually set the needsSaving flag already here. -+ chunk.setNeedsSaving(true); ++ chunk.setUnsaved(true); + chunk.unloadCallback(); + }); + } @@ -111,26 +111,17 @@ + playerchunkmap.callbackExecutor.run(); + } + // CraftBukkit end - CompletableFuture completablefuture; if (flag) { -@@ -388,7 +430,7 @@ - if (flag2 && !flag3) { - completablefuture = this.fullChunkFuture; - this.fullChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE; -- this.a(completablefuture.thenApply((either1) -> { -+ this.a(((CompletableFuture<Either<Chunk, PlayerChunk.Failure>>) completablefuture).thenApply((either1) -> { // CraftBukkit - decompile error - Objects.requireNonNull(playerchunkmap); - return either1.ifLeft(playerchunkmap::a); - }), "unfull"); -@@ -432,6 +474,26 @@ + Either<IChunkAccess, PlayerChunk.Failure> either = Either.right(new PlayerChunk.Failure() { +@@ -425,6 +467,26 @@ - this.onLevelChange.a(this.pos, this::k, this.ticketLevel, this::d); + this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel); this.oldTicketLevel = this.ticketLevel; + // CraftBukkit start + // ChunkLoadEvent: Called after the chunk is loaded: isChunkLoaded returns true and chunk is ready to be modified by plugins. -+ if (!playerchunk_state.isAtLeast(PlayerChunk.State.BORDER) && playerchunk_state1.isAtLeast(PlayerChunk.State.BORDER)) { -+ this.getStatusFutureUnchecked(ChunkStatus.FULL).thenAccept((either) -> { ++ if (!playerchunk_state.isOrAfter(PlayerChunk.State.BORDER) && playerchunk_state1.isOrAfter(PlayerChunk.State.BORDER)) { ++ this.getFutureIfPresentUnchecked(ChunkStatus.FULL).thenAccept((either) -> { + Chunk chunk = (Chunk)either.left().orElse(null); + if (chunk != null) { + playerchunkmap.callbackExecutor.execute(() -> { @@ -149,4 +140,4 @@ + // CraftBukkit end } - public static ChunkStatus getChunkStatus(int i) { + public static ChunkStatus getStatus(int i) { diff --git a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch index 835e4594bc..afd3fef088 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch +++ b/paper-server/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 -@@ -91,6 +91,8 @@ +@@ -95,6 +95,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -9,7 +9,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.e { private static final byte CHUNK_TYPE_REPLACEABLE = -1; -@@ -129,6 +131,27 @@ +@@ -133,6 +135,27 @@ private final Queue<Runnable> unloadQueue; int viewDistance; @@ -35,9 +35,9 @@ + // CraftBukkit end + public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler<Runnable> iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier<WorldPersistentData> supplier, int i, boolean flag) { - super(new File(convertable_conversionsession.a(worldserver.getDimensionKey()), "region"), datafixer, flag); + super(convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag); this.visibleChunkMap = this.updatingChunkMap.clone(); -@@ -281,9 +304,12 @@ +@@ -326,9 +349,12 @@ return completablefuture1.thenApply((list1) -> { List<IChunkAccess> list2 = Lists.newArrayList(); @@ -52,47 +52,39 @@ final Either<IChunkAccess, PlayerChunk.Failure> either = (Either) iterator.next(); Optional<IChunkAccess> optional = either.left(); -@@ -390,7 +416,7 @@ - this.j(); +@@ -435,7 +461,7 @@ + this.flushWorker(); } else { - this.visibleChunkMap.values().stream().filter(PlayerChunk::hasBeenLoaded).forEach((playerchunk) -> { -- IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow((Object) null); -+ IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow(null); // CraftBukkit - decompile error + this.visibleChunkMap.values().stream().filter(PlayerChunk::wasAccessibleSinceLastSave).forEach((playerchunk) -> { +- IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkToSave().getNow((Object) null); ++ IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkToSave().getNow(null); // CraftBukkit - decompile error if (ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk) { - this.saveChunk(ichunkaccess); -@@ -401,7 +427,6 @@ - } + this.save(ichunkaccess); +@@ -488,7 +514,7 @@ - } -- - protected void unloadChunks(BooleanSupplier booleansupplier) { - GameProfilerFiller gameprofilerfiller = this.level.getMethodProfiler(); - -@@ -440,7 +465,7 @@ - - private void a(long i, PlayerChunk playerchunk) { - CompletableFuture<IChunkAccess> completablefuture = playerchunk.getChunkSave(); + private void scheduleUnload(long i, PlayerChunk playerchunk) { + CompletableFuture<IChunkAccess> completablefuture = playerchunk.getChunkToSave(); - Consumer consumer = (ichunkaccess) -> { + Consumer<IChunkAccess> consumer = (ichunkaccess) -> { // CraftBukkit - decompile error - CompletableFuture<IChunkAccess> completablefuture1 = playerchunk.getChunkSave(); + CompletableFuture<IChunkAccess> completablefuture1 = playerchunk.getChunkToSave(); if (completablefuture1 != completablefuture) { -@@ -616,7 +641,21 @@ +@@ -664,7 +690,21 @@ - private static void a(WorldServer worldserver, List<NBTTagCompound> list) { + private static void postLoadProtoChunk(WorldServer worldserver, List<NBTTagCompound> list) { if (!list.isEmpty()) { -- worldserver.b(EntityTypes.a(list, (World) worldserver)); +- worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver)); + // CraftBukkit start - these are spawned serialized (DefinedStructure) and we don't call an add event below at the moment due to ordering complexities -+ worldserver.b(EntityTypes.a(list, (World) worldserver).filter((entity) -> { ++ worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver).filter((entity) -> { + boolean needsRemoval = false; + net.minecraft.server.dedicated.DedicatedServer server = worldserver.getCraftServer().getServer(); -+ if (!server.getSpawnNPCs() && entity instanceof net.minecraft.world.entity.npc.NPC) { -+ entity.die(); ++ if (!server.areNpcsEnabled() && entity instanceof net.minecraft.world.entity.npc.NPC) { ++ entity.discard(); + needsRemoval = true; + } -+ if (!server.getSpawnAnimals() && (entity instanceof net.minecraft.world.entity.animal.EntityAnimal || entity instanceof net.minecraft.world.entity.animal.EntityWaterAnimal)) { -+ entity.die(); ++ if (!server.isSpawningAnimals() && (entity instanceof net.minecraft.world.entity.animal.EntityAnimal || entity instanceof net.minecraft.world.entity.animal.EntityWaterAnimal)) { ++ entity.discard(); + needsRemoval = true; + } + return !needsRemoval; @@ -101,35 +93,35 @@ } } -@@ -844,7 +883,8 @@ +@@ -894,7 +934,8 @@ return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty(); }); -- csvwriter.a(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getChunkStatus).orElse((Object) null), optional1.map(Chunk::getState).orElse((Object) null), a(playerchunk.c()), a(playerchunk.a()), a(playerchunk.b()), this.distanceManager.c(entry.getLongKey()), !this.isOutsideOfRange(chunkcoordintpair), optional1.map((chunk) -> { +- csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getStatus).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) -> { + // CraftBukkit - decompile error -+ csvwriter.a(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getChunkStatus).orElse(null), optional1.map(Chunk::getState).orElse(null), a(playerchunk.c()), a(playerchunk.a()), a(playerchunk.b()), this.distanceManager.c(entry.getLongKey()), !this.isOutsideOfRange(chunkcoordintpair), optional1.map((chunk) -> { - return chunk.getTileEntities().size(); - }).orElse(0)); - } -@@ -853,7 +893,7 @@ ++ csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getStatus).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) -> { + return chunk.getBlockEntities().size(); + }).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> { + return chunk.getBlockTicks().count(); +@@ -907,7 +948,7 @@ - private static String a(CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture) { + private static String printFuture(CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture) { try { - Either<Chunk, PlayerChunk.Failure> either = (Either) completablefuture.getNow((Object) null); + Either<Chunk, PlayerChunk.Failure> either = (Either) completablefuture.getNow(null); // CraftBukkit - decompile error return either != null ? (String) either.map((chunk) -> { return "done"; -@@ -871,7 +911,7 @@ - private NBTTagCompound readChunkData(ChunkCoordIntPair chunkcoordintpair) throws IOException { +@@ -925,7 +966,7 @@ + private NBTTagCompound readChunk(ChunkCoordIntPair chunkcoordintpair) throws IOException { NBTTagCompound nbttagcompound = this.read(chunkcoordintpair); -- return nbttagcompound == null ? null : this.getChunkData(this.level.getDimensionKey(), this.overworldDataStorage, nbttagcompound); -+ return nbttagcompound == null ? null : this.getChunkData(this.level.getTypeKey(), this.overworldDataStorage, nbttagcompound, chunkcoordintpair, level); // CraftBukkit +- return nbttagcompound == null ? null : this.upgradeChunkTag(this.level.dimension(), this.overworldDataStorage, nbttagcompound, this.generator.getTypeNameForDataFixer()); ++ return nbttagcompound == null ? null : this.upgradeChunkTag(this.level.getTypeKey(), this.overworldDataStorage, nbttagcompound, this.generator.getTypeNameForDataFixer(), chunkcoordintpair, level); // CraftBukkit } - boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair) { -@@ -1238,7 +1278,7 @@ + boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) { +@@ -1349,7 +1390,7 @@ public final Set<ServerPlayerConnection> seenBy = Sets.newIdentityHashSet(); public EntityTracker(Entity entity, int i, int j, boolean flag) { @@ -137,15 +129,17 @@ + this.serverEntity = new EntityTrackerEntry(PlayerChunkMap.this.level, entity, j, flag, this::broadcast, seenBy); // CraftBukkit this.entity = entity; this.range = i; - this.lastSectionPos = SectionPosition.a(entity); -@@ -1291,10 +1331,18 @@ + this.lastSectionPos = SectionPosition.of(entity); +@@ -1402,12 +1443,20 @@ public void updatePlayer(EntityPlayer entityplayer) { if (entityplayer != this.entity) { -- Vec3D vec3d = entityplayer.getPositionVector().d(this.serverEntity.b()); -+ Vec3D vec3d = entityplayer.getPositionVector().d(this.entity.getPositionVector()); // MC-155077, SPIGOT-5113 - int i = Math.min(this.b(), (PlayerChunkMap.this.viewDistance - 1) * 16); - boolean flag = vec3d.x >= (double) (-i) && vec3d.x <= (double) i && vec3d.z >= (double) (-i) && vec3d.z <= (double) i && this.entity.a(entityplayer); +- Vec3D vec3d = entityplayer.position().subtract(this.serverEntity.sentPos()); ++ Vec3D vec3d = entityplayer.position().subtract(this.entity.position()); // MC-155077, SPIGOT-5113 + double d0 = (double) Math.min(this.getEffectiveRange(), (PlayerChunkMap.this.viewDistance - 1) * 16); + double d1 = vec3d.x * vec3d.x + vec3d.z * vec3d.z; + double d2 = d0 * d0; + boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer); + // CraftBukkit start - respect vanish API + if (this.entity instanceof EntityPlayer) { @@ -157,4 +151,4 @@ + // CraftBukkit end if (flag) { if (this.seenBy.add(entityplayer.connection)) { - this.serverEntity.b(entityplayer); + this.serverEntity.addPairing(entityplayer); diff --git a/paper-server/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch b/paper-server/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch index 184dbf252e..c0c7a58f1b 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/PlayerInteractManager.java +++ b/net/minecraft/server/level/PlayerInteractManager.java -@@ -25,6 +25,27 @@ +@@ -24,6 +24,27 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -28,7 +28,7 @@ public class PlayerInteractManager { private static final Logger LOGGER = LogManager.getLogger(); -@@ -55,6 +76,13 @@ +@@ -54,6 +75,13 @@ if (enumgamemode == this.gameModeForPlayer) { return false; } else { @@ -39,93 +39,93 @@ + return false; + } + // CraftBukkit end - this.a(enumgamemode, this.gameModeForPlayer); + this.setGameModeForPlayer(enumgamemode, this.gameModeForPlayer); return true; } -@@ -65,7 +93,7 @@ +@@ -64,7 +92,7 @@ this.gameModeForPlayer = enumgamemode; - enumgamemode.a(this.player.getAbilities()); - this.player.updateAbilities(); -- this.player.server.getPlayerList().sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[]{this.player})); -+ this.player.server.getPlayerList().sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[]{this.player}), this.player); // CraftBukkit - this.level.everyoneSleeping(); + enumgamemode.updatePlayerAbilities(this.player.getAbilities()); + this.player.onUpdateAbilities(); +- this.player.server.getPlayerList().broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[]{this.player})); ++ this.player.server.getPlayerList().broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[]{this.player}), this.player); // CraftBukkit + this.level.updateSleepingPlayerList(); } -@@ -87,7 +115,7 @@ +@@ -86,7 +114,7 @@ } - public void a() { + public void tick() { - ++this.gameTicks; + this.gameTicks = MinecraftServer.currentTick; // CraftBukkit; IBlockData iblockdata; if (this.hasDelayedDestroy) { -@@ -143,9 +171,31 @@ +@@ -142,9 +170,31 @@ if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) { - if (!this.level.a((EntityHuman) this.player, blockposition)) { + if (!this.level.mayInteract(this.player, blockposition)) { + // CraftBukkit start - fire PlayerInteractEvent -+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getItemInHand(), EnumHand.MAIN_HAND); - this.player.connection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.level.getType(blockposition), packetplayinblockdig_enumplayerdigtype, false, "may not interact")); ++ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getSelected(), EnumHand.MAIN_HAND); + this.player.connection.send(new PacketPlayOutBlockBreak(blockposition, this.level.getBlockState(blockposition), packetplayinblockdig_enumplayerdigtype, false, "may not interact")); + // Update any tile entity data for this block -+ TileEntity tileentity = level.getTileEntity(blockposition); ++ TileEntity tileentity = level.getBlockEntity(blockposition); + if (tileentity != null) { -+ this.player.connection.sendPacket(tileentity.getUpdatePacket()); ++ this.player.connection.send(tileentity.getUpdatePacket()); + } + // CraftBukkit end + return; + } + + // CraftBukkit start -+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getItemInHand(), EnumHand.MAIN_HAND); ++ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getSelected(), EnumHand.MAIN_HAND); + if (event.isCancelled()) { + // Let the client know the block still exists -+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition)); ++ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition)); + // Update any tile entity data for this block -+ TileEntity tileentity = this.level.getTileEntity(blockposition); ++ TileEntity tileentity = this.level.getBlockEntity(blockposition); + if (tileentity != null) { -+ this.player.connection.sendPacket(tileentity.getUpdatePacket()); ++ this.player.connection.send(tileentity.getUpdatePacket()); + } return; } + // CraftBukkit end if (this.isCreative()) { - this.a(blockposition, packetplayinblockdig_enumplayerdigtype, "creative destroy"); -@@ -161,11 +211,43 @@ + this.destroyAndAck(blockposition, packetplayinblockdig_enumplayerdigtype, "creative destroy"); +@@ -160,11 +210,43 @@ float f = 1.0F; - iblockdata = this.level.getType(blockposition); + iblockdata = this.level.getBlockState(blockposition); - if (!iblockdata.isAir()) { + // CraftBukkit start - Swings at air do *NOT* exist. + if (event.useInteractedBlock() == Event.Result.DENY) { + // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. -+ IBlockData data = this.level.getType(blockposition); ++ IBlockData data = this.level.getBlockState(blockposition); + if (data.getBlock() instanceof BlockDoor) { + // For some reason *BOTH* the bottom/top part have to be marked updated. -+ boolean bottom = data.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER; -+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition)); -+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, bottom ? blockposition.up() : blockposition.down())); ++ boolean bottom = data.getValue(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER; ++ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition)); ++ this.player.connection.send(new PacketPlayOutBlockChange(this.level, bottom ? blockposition.above() : blockposition.below())); + } else if (data.getBlock() instanceof BlockTrapdoor) { -+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition)); ++ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition)); + } + } else if (!iblockdata.isAir()) { iblockdata.attack(this.level, blockposition, this.player); - f = iblockdata.getDamage(this.player, this.player.level, blockposition); + f = iblockdata.getDestroyProgress(this.player, this.player.level, blockposition); } + if (event.useItemInHand() == Event.Result.DENY) { + // If we 'insta destroyed' then the client needs to be informed. + if (f > 1.0f) { -+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition)); ++ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition)); + } + return; + } -+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.player.getInventory().getItemInHand(), f >= 1.0f); ++ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.player.getInventory().getSelected(), f >= 1.0f); + + if (blockEvent.isCancelled()) { + // Let the client know the block still exists -+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition)); ++ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition)); + return; + } + @@ -135,42 +135,42 @@ + // CraftBukkit end + if (!iblockdata.isAir() && f >= 1.0F) { - this.a(blockposition, packetplayinblockdig_enumplayerdigtype, "insta mine"); + this.destroyAndAck(blockposition, packetplayinblockdig_enumplayerdigtype, "insta mine"); } else { -@@ -209,7 +291,7 @@ +@@ -208,7 +290,7 @@ } else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) { this.isDestroyingBlock = false; if (!Objects.equals(this.destroyPos, blockposition)) { - PlayerInteractManager.LOGGER.warn("Mismatch in destroy block pos: {} {}", this.destroyPos, blockposition); + PlayerInteractManager.LOGGER.debug("Mismatch in destroy block pos: {} {}", this.destroyPos, blockposition); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled - this.level.a(this.player.getId(), this.destroyPos, -1); - this.player.connection.sendPacket(new PacketPlayOutBlockBreak(this.destroyPos, this.level.getType(this.destroyPos), packetplayinblockdig_enumplayerdigtype, true, "aborted mismatched destroying")); + this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1); + this.player.connection.send(new PacketPlayOutBlockBreak(this.destroyPos, this.level.getBlockState(this.destroyPos), packetplayinblockdig_enumplayerdigtype, true, "aborted mismatched destroying")); } -@@ -225,17 +307,72 @@ - if (this.breakBlock(blockposition)) { - this.player.connection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.level.getType(blockposition), packetplayinblockdig_enumplayerdigtype, true, s)); +@@ -224,17 +306,72 @@ + if (this.destroyBlock(blockposition)) { + this.player.connection.send(new PacketPlayOutBlockBreak(blockposition, this.level.getBlockState(blockposition), packetplayinblockdig_enumplayerdigtype, true, s)); } else { -- this.player.connection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.level.getType(blockposition), packetplayinblockdig_enumplayerdigtype, false, s)); -+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition)); // CraftBukkit - SPIGOT-5196 +- this.player.connection.send(new PacketPlayOutBlockBreak(blockposition, this.level.getBlockState(blockposition), packetplayinblockdig_enumplayerdigtype, false, s)); ++ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition)); // CraftBukkit - SPIGOT-5196 } } - public boolean breakBlock(BlockPosition blockposition) { - IBlockData iblockdata = this.level.getType(blockposition); + public boolean destroyBlock(BlockPosition blockposition) { + IBlockData iblockdata = this.level.getBlockState(blockposition); + // CraftBukkit start - fire BlockBreakEvent + org.bukkit.block.Block bblock = CraftBlock.at(level, blockposition); + BlockBreakEvent event = null; + + if (this.player instanceof EntityPlayer) { + // Sword + Creative mode pre-cancel -+ boolean isSwordNoBreak = !this.player.getItemInMainHand().getItem().a(iblockdata, this.level, blockposition, (EntityHuman) this.player); ++ boolean isSwordNoBreak = !this.player.getMainHandItem().getItem().canAttackBlock(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! -+ if (level.getTileEntity(blockposition) == null && !isSwordNoBreak) { -+ PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(blockposition, Blocks.AIR.getBlockData()); -+ this.player.connection.sendPacket(packet); ++ if (level.getBlockEntity(blockposition) == null && !isSwordNoBreak) { ++ PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(blockposition, Blocks.AIR.defaultBlockState()); ++ this.player.connection.send(packet); + } + + event = new BlockBreakEvent(bblock, this.player.getBukkitEntity()); @@ -179,12 +179,12 @@ + event.setCancelled(isSwordNoBreak); + + // Calculate default block experience -+ IBlockData nmsData = this.level.getType(blockposition); ++ IBlockData nmsData = this.level.getBlockState(blockposition); + Block nmsBlock = nmsData.getBlock(); + -+ ItemStack itemstack = this.player.getEquipment(EnumItemSlot.MAINHAND); ++ ItemStack itemstack = this.player.getItemBySlot(EnumItemSlot.MAINHAND); + -+ if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasBlock(nmsBlock.getBlockData())) { ++ if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasCorrectToolForDrops(nmsBlock.defaultBlockState())) { + event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.level, blockposition, itemstack)); + } + @@ -195,58 +195,58 @@ + return false; + } + // Let the client know the block still exists -+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition)); ++ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition)); + + // Brute force all possible updates + for (EnumDirection dir : EnumDirection.values()) { -+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(level, blockposition.shift(dir))); ++ this.player.connection.send(new PacketPlayOutBlockChange(level, blockposition.relative(dir))); + } -- if (!this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.level, blockposition, (EntityHuman) this.player)) { +- if (!this.player.getMainHandItem().getItem().canAttackBlock(iblockdata, this.level, blockposition, this.player)) { + // Update any tile entity data for this block -+ TileEntity tileentity = this.level.getTileEntity(blockposition); ++ TileEntity tileentity = this.level.getBlockEntity(blockposition); + if (tileentity != null) { -+ this.player.connection.sendPacket(tileentity.getUpdatePacket()); ++ this.player.connection.send(tileentity.getUpdatePacket()); + } + return false; + } + } + // CraftBukkit end + -+ if (false && !this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.level, blockposition, (EntityHuman) this.player)) { // CraftBukkit - false ++ if (false && !this.player.getMainHandItem().getItem().canAttackBlock(iblockdata, this.level, blockposition, this.player)) { // CraftBukkit - false return false; } else { -+ iblockdata = this.level.getType(blockposition); // CraftBukkit - update state from plugins ++ iblockdata = this.level.getBlockState(blockposition); // CraftBukkit - update state from plugins + if (iblockdata.isAir()) return false; // CraftBukkit - A plugin set block to air without cancelling - TileEntity tileentity = this.level.getTileEntity(blockposition); + TileEntity tileentity = this.level.getBlockEntity(blockposition); Block block = iblockdata.getBlock(); -@@ -245,6 +382,10 @@ - } else if (this.player.a((World) this.level, blockposition, this.gameModeForPlayer)) { +@@ -244,6 +381,10 @@ + } else if (this.player.blockActionRestricted(this.level, blockposition, this.gameModeForPlayer)) { return false; } else { + // CraftBukkit start + org.bukkit.block.BlockState state = bblock.getState(); + level.captureDrops = new ArrayList<>(); + // CraftBukkit end - block.a((World) this.level, blockposition, iblockdata, (EntityHuman) this.player); - boolean flag = this.level.a(blockposition, false); + block.playerWillDestroy(this.level, blockposition, iblockdata, this.player); + boolean flag = this.level.removeBlock(blockposition, false); -@@ -253,19 +394,32 @@ +@@ -252,19 +393,32 @@ } if (this.isCreative()) { - return true; + // return true; // CraftBukkit } else { - ItemStack itemstack = this.player.getItemInMainHand(); - ItemStack itemstack1 = itemstack.cloneItemStack(); - boolean flag1 = this.player.hasBlock(iblockdata); + ItemStack itemstack = this.player.getMainHandItem(); + ItemStack itemstack1 = itemstack.copy(); + boolean flag1 = this.player.hasCorrectToolForDrops(iblockdata); - itemstack.a(this.level, iblockdata, blockposition, this.player); + itemstack.mineBlock(this.level, iblockdata, blockposition, this.player); - if (flag && flag1) { + if (flag && flag1 && event.isDropItems()) { // CraftBukkit - Check if block should drop items - block.a(this.level, this.player, blockposition, iblockdata, tileentity, itemstack1); + block.playerDestroy(this.level, this.player, blockposition, iblockdata, tileentity, itemstack1); } - return true; @@ -260,7 +260,7 @@ + + // Drop event experience + if (flag && event != null) { -+ iblockdata.getBlock().dropExperience(this.level, blockposition, event.getExpToDrop()); ++ iblockdata.getBlock().popExperience(this.level, blockposition, event.getExpToDrop()); } + + return true; @@ -268,7 +268,7 @@ } } } -@@ -307,12 +461,52 @@ +@@ -306,12 +460,52 @@ } } @@ -278,63 +278,63 @@ + public BlockPosition interactPosition; + public EnumHand interactHand; + public ItemStack interactItemStack; - public EnumInteractionResult a(EntityPlayer entityplayer, World world, ItemStack itemstack, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) { - BlockPosition blockposition = movingobjectpositionblock.getBlockPosition(); - IBlockData iblockdata = world.getType(blockposition); + public EnumInteractionResult useItemOn(EntityPlayer entityplayer, World world, ItemStack itemstack, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) { + BlockPosition blockposition = movingobjectpositionblock.getBlockPos(); + IBlockData iblockdata = world.getBlockState(blockposition); + EnumInteractionResult enuminteractionresult = EnumInteractionResult.PASS; + boolean cancelledBlock = false; if (this.gameModeForPlayer == EnumGamemode.SPECTATOR) { - ITileInventory itileinventory = iblockdata.b(world, blockposition); + ITileInventory itileinventory = iblockdata.getMenuProvider(world, blockposition); + cancelledBlock = !(itileinventory instanceof ITileInventory); + } + -+ if (entityplayer.getCooldownTracker().hasCooldown(itemstack.getItem())) { ++ if (entityplayer.getCooldowns().isOnCooldown(itemstack.getItem())) { + cancelledBlock = true; + } + + PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityplayer, Action.RIGHT_CLICK_BLOCK, blockposition, movingobjectpositionblock.getDirection(), itemstack, cancelledBlock, enumhand); + firedInteract = true; + interactResult = event.useItemInHand() == Event.Result.DENY; -+ interactPosition = blockposition.immutableCopy(); ++ interactPosition = blockposition.immutable(); + interactHand = enumhand; -+ interactItemStack = itemstack.cloneItemStack(); ++ interactItemStack = itemstack.copy(); + + if (event.useInteractedBlock() == Event.Result.DENY) { + // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. + if (iblockdata.getBlock() instanceof BlockDoor) { -+ boolean bottom = iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER; -+ entityplayer.connection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down())); ++ boolean bottom = iblockdata.getValue(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER; ++ entityplayer.connection.send(new PacketPlayOutBlockChange(world, bottom ? blockposition.above() : blockposition.below())); + } else if (iblockdata.getBlock() instanceof BlockCake) { + entityplayer.getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake + } else if (interactItemStack.getItem() instanceof ItemBisected) { + // send a correcting update to the client, as it already placed the upper half of the bisected item -+ entityplayer.connection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(movingobjectpositionblock.getDirection()).up())); ++ entityplayer.connection.send(new PacketPlayOutBlockChange(world, blockposition.relative(movingobjectpositionblock.getDirection()).above())); + + // send a correcting update to the client for the block above as well, this because of replaceable blocks (such as grass, sea grass etc) -+ entityplayer.connection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.up())); ++ entityplayer.connection.send(new PacketPlayOutBlockChange(world, blockposition.above())); + } + entityplayer.getBukkitEntity().updateInventory(); // SPIGOT-2867 + enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS; + } else if (this.gameModeForPlayer == EnumGamemode.SPECTATOR) { -+ ITileInventory itileinventory = iblockdata.b(world, blockposition); ++ ITileInventory itileinventory = iblockdata.getMenuProvider(world, blockposition); if (itileinventory != null) { - entityplayer.openContainer(itileinventory); -@@ -326,7 +520,7 @@ - ItemStack itemstack1 = itemstack.cloneItemStack(); + entityplayer.openMenu(itileinventory); +@@ -325,7 +519,7 @@ + ItemStack itemstack1 = itemstack.copy(); if (!flag1) { -- EnumInteractionResult enuminteractionresult = iblockdata.interact(world, entityplayer, enumhand, movingobjectpositionblock); -+ enuminteractionresult = iblockdata.interact(world, entityplayer, enumhand, movingobjectpositionblock); +- EnumInteractionResult enuminteractionresult = iblockdata.use(world, entityplayer, enumhand, movingobjectpositionblock); ++ enuminteractionresult = iblockdata.use(world, entityplayer, enumhand, movingobjectpositionblock); - if (enuminteractionresult.a()) { - CriterionTriggers.ITEM_USED_ON_BLOCK.a(entityplayer, blockposition, itemstack1); -@@ -334,17 +528,17 @@ + if (enuminteractionresult.consumesAction()) { + CriterionTriggers.ITEM_USED_ON_BLOCK.trigger(entityplayer, blockposition, itemstack1); +@@ -333,17 +527,17 @@ } } -- if (!itemstack.isEmpty() && !entityplayer.getCooldownTracker().hasCooldown(itemstack.getItem())) { +- if (!itemstack.isEmpty() && !entityplayer.getCooldowns().isOnCooldown(itemstack.getItem())) { + if (!itemstack.isEmpty() && enuminteractionresult != EnumInteractionResult.SUCCESS && !interactResult) { // add !interactResult SPIGOT-764 ItemActionContext itemactioncontext = new ItemActionContext(entityplayer, enumhand, movingobjectpositionblock); EnumInteractionResult enuminteractionresult1; @@ -342,16 +342,16 @@ if (this.isCreative()) { int i = itemstack.getCount(); -- enuminteractionresult1 = itemstack.placeItem(itemactioncontext); -+ enuminteractionresult1 = itemstack.placeItem(itemactioncontext, enumhand); +- enuminteractionresult1 = itemstack.useOn(itemactioncontext); ++ enuminteractionresult1 = itemstack.useOn(itemactioncontext, enumhand); itemstack.setCount(i); } else { -- enuminteractionresult1 = itemstack.placeItem(itemactioncontext); -+ enuminteractionresult1 = itemstack.placeItem(itemactioncontext, enumhand); +- enuminteractionresult1 = itemstack.useOn(itemactioncontext); ++ enuminteractionresult1 = itemstack.useOn(itemactioncontext, enumhand); } - if (enuminteractionresult1.a()) { -@@ -352,10 +546,10 @@ + if (enuminteractionresult1.consumesAction()) { +@@ -351,10 +545,10 @@ } return enuminteractionresult1; @@ -363,4 +363,4 @@ + // CraftBukkit end } - public void a(WorldServer worldserver) { + public void setLevel(WorldServer worldserver) { diff --git a/paper-server/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch b/paper-server/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch index 388fe75724..1dd06fb250 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/server/level/RegionLimitedWorldAccess.java +++ b/net/minecraft/server/level/RegionLimitedWorldAccess.java -@@ -308,6 +308,13 @@ +@@ -319,6 +319,13 @@ @Override - public boolean addEntity(Entity entity) { + public boolean addFreshEntity(Entity entity) { + // CraftBukkit start -+ return addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); ++ return addFreshEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } + + @Override -+ public boolean addEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ public boolean addFreshEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + // CraftBukkit end - int i = SectionPosition.a(entity.cW()); - int j = SectionPosition.a(entity.dc()); + int i = SectionPosition.blockToSectionCoord(entity.getBlockX()); + int j = SectionPosition.blockToSectionCoord(entity.getBlockZ()); diff --git a/paper-server/nms-patches/net/minecraft/server/level/TicketType.patch b/paper-server/nms-patches/net/minecraft/server/level/TicketType.patch index 9a4be5c15d..24c2b2c7a5 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/TicketType.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/TicketType.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/level/TicketType.java +++ b/net/minecraft/server/level/TicketType.java @@ -23,6 +23,8 @@ - public static final TicketType<BlockPosition> PORTAL = a("portal", BaseBlockPosition::compareTo, 300); - public static final TicketType<Integer> POST_TELEPORT = a("post_teleport", Integer::compareTo, 5); - public static final TicketType<ChunkCoordIntPair> UNKNOWN = a("unknown", Comparator.comparingLong(ChunkCoordIntPair::pair), 1); -+ public static final TicketType<Unit> PLUGIN = a("plugin", (a, b) -> 0); // CraftBukkit -+ public static final TicketType<org.bukkit.plugin.Plugin> PLUGIN_TICKET = a("plugin_ticket", (plugin1, plugin2) -> plugin1.getClass().getName().compareTo(plugin2.getClass().getName())); // CraftBukkit + public static final TicketType<BlockPosition> PORTAL = create("portal", BaseBlockPosition::compareTo, 300); + public static final TicketType<Integer> POST_TELEPORT = create("post_teleport", Integer::compareTo, 5); + public static final TicketType<ChunkCoordIntPair> UNKNOWN = create("unknown", Comparator.comparingLong(ChunkCoordIntPair::toLong), 1); ++ public static final TicketType<Unit> PLUGIN = create("plugin", (a, b) -> 0); // CraftBukkit ++ public static final TicketType<org.bukkit.plugin.Plugin> PLUGIN_TICKET = create("plugin_ticket", (plugin1, plugin2) -> plugin1.getClass().getName().compareTo(plugin2.getClass().getName())); // CraftBukkit - public static <T> TicketType<T> a(String s, Comparator<T> comparator) { + public static <T> TicketType<T> create(String s, Comparator<T> comparator) { return new TicketType<>(s, comparator, 0L); diff --git a/paper-server/nms-patches/net/minecraft/server/level/WorldServer.patch b/paper-server/nms-patches/net/minecraft/server/level/WorldServer.patch index d70ac9a387..5fc60ecac9 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/WorldServer.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/WorldServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/WorldServer.java +++ b/net/minecraft/server/level/WorldServer.java -@@ -152,6 +152,19 @@ +@@ -147,6 +147,19 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -20,7 +20,7 @@ public class WorldServer extends World implements GeneratorAccessSeed { public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0); -@@ -160,7 +173,7 @@ +@@ -164,7 +177,7 @@ final List<EntityPlayer> players; private final ChunkProviderServer chunkSource; private final MinecraftServer server; @@ -29,13 +29,13 @@ final EntityTickList entityTickList; public final PersistentEntitySectionManager<Entity> entityManager; public boolean noSave; -@@ -180,31 +193,52 @@ - private final StructureManager structureFeatureManager; +@@ -186,9 +199,24 @@ + private final StructureCheck structureCheck; private final boolean tickTime; - public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<MobSpawner> list, boolean flag1) { - Objects.requireNonNull(minecraftserver); -- super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i); +- super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getProfiler, false, flag, i); + + // CraftBukkit start + private int tickPosition; @@ -43,39 +43,21 @@ + public final UUID uuid; + + public Chunk getChunkIfLoaded(int x, int z) { -+ return this.chunkSource.getChunkAt(x, z, false); ++ return this.chunkSource.getChunk(x, z, false); + } + + // Add env and gen to constructor, WorldData -> WorldDataServer + public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<MobSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { + // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error -+ super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i, gen, biomeProvider, env); -+ this.pvpMode = minecraftserver.getPVP(); ++ super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getProfiler, false, flag, i, gen, biomeProvider, env); ++ this.pvpMode = minecraftserver.isPvpAllowed(); + convertable = convertable_conversionsession; + uuid = WorldUUID.getUUID(convertable_conversionsession.levelPath.toFile()); + // CraftBukkit end this.players = Lists.newArrayList(); this.entityTickList = new EntityTickList(); -- Predicate predicate = (block) -> { -+ Predicate<Block> predicate = (block) -> { // CraftBukkit - decompile eror - return block == null || block.getBlockData().isAir(); - }; - RegistryBlocks registryblocks = IRegistry.BLOCK; - - Objects.requireNonNull(registryblocks); -- this.blockTicks = new TickListServer<>(this, predicate, registryblocks::getKey, this::b); -- predicate = (fluidtype) -> { -+ this.blockTicks = new TickListServer<>(this, predicate, IRegistry.BLOCK::getKey, this::b); // CraftBukkit - decompile error -+ Predicate<FluidType> predicate2 = (fluidtype) -> { // CraftBukkit - decompile error - return fluidtype == null || fluidtype == FluidTypes.EMPTY; - }; - registryblocks = IRegistry.FLUID; - Objects.requireNonNull(registryblocks); -- this.liquidTicks = new TickListServer<>(this, predicate, registryblocks::getKey, this::a); -+ this.liquidTicks = new TickListServer<>(this, predicate2, IRegistry.FLUID::getKey, this::a); // CraftBukkit - decompile error - this.navigatingMobs = new ObjectOpenHashSet(); - this.blockEvents = new ObjectLinkedOpenHashSet(); - this.dragonParts = new Int2ObjectOpenHashMap(); + this.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier()); +@@ -200,7 +228,13 @@ this.tickTime = flag1; this.server = minecraftserver; this.customSpawners = list; @@ -87,18 +69,18 @@ + chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen); + } + // CraftBukkit end - boolean flag2 = minecraftserver.isSyncChunkWrites(); - DataFixer datafixer = minecraftserver.getDataFixer(); - EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, new File(convertable_conversionsession.a(resourcekey), "entities"), datafixer, flag2, minecraftserver); + boolean flag2 = minecraftserver.forceSynchronousWrites(); + DataFixer datafixer = minecraftserver.getFixerUpper(); + EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver); @@ -231,14 +265,15 @@ - iworlddataserver.setGameType(minecraftserver.getGamemode()); - } + long l = minecraftserver.getWorldData().worldGenSettings().seed(); -- this.structureFeatureManager = new StructureManager(this, minecraftserver.getSaveData().getGeneratorSettings()); -+ this.structureFeatureManager = new StructureManager(this, this.serverLevelData.getGeneratorSettings()); // CraftBukkit - if (this.getDimensionManager().isCreateDragonBattle()) { -- this.dragonFight = new EnderDragonBattle(this, minecraftserver.getSaveData().getGeneratorSettings().getSeed(), minecraftserver.getSaveData().C()); -+ this.dragonFight = new EnderDragonBattle(this, this.serverLevelData.getGeneratorSettings().getSeed(), this.serverLevelData.C()); // CraftBukkit + this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this, chunkgenerator.getBiomeSource(), l, datafixer); +- this.structureFeatureManager = new StructureManager(this, minecraftserver.getWorldData().worldGenSettings(), this.structureCheck); ++ this.structureFeatureManager = new StructureManager(this, this.serverLevelData.worldGenSettings(), structureCheck); // CraftBukkit + if (this.dimensionType().createDragonFight()) { +- this.dragonFight = new EnderDragonBattle(this, l, minecraftserver.getWorldData().endDragonFightData()); ++ this.dragonFight = new EnderDragonBattle(this, this.serverLevelData.worldGenSettings().seed(), this.serverLevelData.endDragonFightData()); // CraftBukkit } else { this.dragonFight = null; } @@ -107,18 +89,101 @@ + this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit } - public void a(int i, int j, boolean flag, boolean flag1) { -@@ -331,6 +366,7 @@ - this.rainLevel = MathHelper.a(this.rainLevel, 0.0F, 1.0F); + public void setWeatherParameters(int i, int j, boolean flag, boolean flag1) { +@@ -270,12 +305,20 @@ + long j; + + 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()); + if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { +- j = this.levelData.getDayTime() + 24000L; +- this.setDayTime(j - j % 24000L); ++ getCraftServer().getPluginManager().callEvent(event); ++ if (!event.isCancelled()) { ++ this.setDayTime(this.getDayTime() + event.getSkipAmount()); ++ } + } + +- this.wakeUpAllPlayers(); ++ if (!event.isCancelled()) { ++ this.wakeUpAllPlayers(); ++ } ++ // CraftBukkit end + if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) { + this.resetWeatherCycle(); + } +@@ -301,7 +344,7 @@ + this.runBlockEvents(); + this.handlingTick = false; + gameprofilerfiller.pop(); +- boolean flag = !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); ++ boolean flag = true || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players + + if (flag) { + this.resetEmptyTime(); +@@ -317,7 +360,7 @@ + + this.entityTickList.forEach((entity) -> { + if (!entity.isRemoved()) { +- if (this.shouldDiscardEntity(entity)) { ++ if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed + entity.discard(); + } else { + gameprofilerfiller.push("checkDespawn"); +@@ -389,7 +432,7 @@ + + private void wakeUpAllPlayers() { + this.sleepStatus.removeAllSleepers(); +- ((List) this.players.stream().filter(EntityLiving::isSleeping).collect(Collectors.toList())).forEach((entityplayer) -> { ++ (this.players.stream().filter(EntityLiving::isSleeping).collect(Collectors.toList())).forEach((entityplayer) -> { // CraftBukkit - decompile error + entityplayer.stopSleepInBed(false, false); + }); + } +@@ -416,14 +459,14 @@ + entityhorseskeleton.setTrap(true); + entityhorseskeleton.setAge(0); + entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); +- this.addFreshEntity(entityhorseskeleton); ++ this.addFreshEntity(entityhorseskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit + } + + EntityLightning entitylightning = (EntityLightning) EntityTypes.LIGHTNING_BOLT.create(this); + + entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition)); + entitylightning.setVisualOnly(flag1); +- this.addFreshEntity(entitylightning); ++ this.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.WEATHER); // CraftBukkit + } + } + +@@ -434,12 +477,12 @@ + BiomeBase biomebase = this.getBiome(blockposition); + + if (biomebase.shouldFreeze(this, blockposition1)) { +- this.setBlockAndUpdate(blockposition1, Blocks.ICE.defaultBlockState()); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.defaultBlockState(), null); // CraftBukkit + } + + if (flag) { + if (biomebase.shouldSnow(this, blockposition)) { +- this.setBlockAndUpdate(blockposition, Blocks.SNOW.defaultBlockState()); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.defaultBlockState(), null); // CraftBukkit + } + + IBlockData iblockdata = this.getBlockState(blockposition1); +@@ -635,6 +678,7 @@ + this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F); } + /* CraftBukkit start if (this.oRainLevel != this.rainLevel) { - this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel)), this.getDimensionKey()); + this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension()); } -@@ -349,16 +385,45 @@ - this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel)); - this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel)); +@@ -653,14 +697,47 @@ + this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel)); + this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } + // */ + for (int idx = 0; idx < this.players.size(); ++idx) { @@ -142,100 +207,17 @@ + } + // CraftBukkit end - i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); - if (this.sleepStatus.a(i) && this.sleepStatus.a(i, this.players)) { -+ // CraftBukkit start -+ long l = this.levelData.getDayTime() + 24000L; -+ TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (l - l % 24000L) - this.getDayTime()); - if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { -- long l = this.levelData.getDayTime() + 24000L; -+ getCraftServer().getPluginManager().callEvent(event); -+ if (!event.isCancelled()) { -+ this.setDayTime(this.getDayTime() + event.getSkipAmount()); -+ } - -- this.setDayTime(l - l % 24000L); - } - -- this.wakeupPlayers(); -+ if (!event.isCancelled()) { -+ this.wakeupPlayers(); -+ } -+ // CraftBukkit end - if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE)) { - this.clearWeather(); - } -@@ -380,7 +445,7 @@ - this.aq(); - this.handlingTick = false; - gameprofilerfiller.exit(); -- boolean flag3 = !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); -+ boolean flag3 = true || !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players - - if (flag3) { - this.resetEmptyTime(); -@@ -396,7 +461,7 @@ - - this.entityTickList.a((entity) -> { - if (!entity.isRemoved()) { -- if (this.i(entity)) { -+ if (false && this.i(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed - entity.die(); - } else { - gameprofilerfiller.enter("checkDespawn"); -@@ -461,7 +526,7 @@ - - private void wakeupPlayers() { - this.sleepStatus.a(); -- ((List) this.players.stream().filter(EntityLiving::isSleeping).collect(Collectors.toList())).forEach((entityplayer) -> { -+ (this.players.stream().filter(EntityLiving::isSleeping).collect(Collectors.toList())).forEach((entityplayer) -> { // CraftBukkit - decompile error - entityplayer.wakeup(false, false); - }); - } -@@ -488,14 +553,14 @@ - entityhorseskeleton.v(true); - entityhorseskeleton.setAgeRaw(0); - entityhorseskeleton.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); -- this.addEntity(entityhorseskeleton); -+ this.addEntity(entityhorseskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit - } - - EntityLightning entitylightning = (EntityLightning) EntityTypes.LIGHTNING_BOLT.a((World) this); - - entitylightning.d(Vec3D.c((BaseBlockPosition) blockposition)); - entitylightning.setEffect(flag1); -- this.addEntity(entitylightning); -+ this.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.WEATHER); // CraftBukkit - } - } - -@@ -506,12 +571,12 @@ - BiomeBase biomebase = this.getBiome(blockposition); - - if (biomebase.a((IWorldReader) this, blockposition1)) { -- this.setTypeUpdate(blockposition1, Blocks.ICE.getBlockData()); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.getBlockData(), null); // CraftBukkit - } - - if (flag) { - if (biomebase.b(this, blockposition)) { -- this.setTypeUpdate(blockposition, Blocks.SNOW.getBlockData()); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.getBlockData(), null); // CraftBukkit - } - - IBlockData iblockdata = this.getType(blockposition1); -@@ -642,10 +707,22 @@ } - private void clearWeather() { -- this.serverLevelData.setWeatherDuration(0); + private void resetWeatherCycle() { +- this.serverLevelData.setRainTime(0); + // CraftBukkit start - this.serverLevelData.setStorm(false); -- this.serverLevelData.setThunderDuration(0); + this.serverLevelData.setRaining(false); +- this.serverLevelData.setThunderTime(0); + // If we stop due to everyone sleeping we should reset the weather duration to some other random value. + // Not that everyone ever manages to get the whole server to sleep at the same time.... -+ if (!this.serverLevelData.hasStorm()) { -+ this.serverLevelData.setWeatherDuration(0); ++ if (!this.serverLevelData.isRaining()) { ++ this.serverLevelData.setRainTime(0); + } + // CraftBukkit end this.serverLevelData.setThundering(false); @@ -243,37 +225,37 @@ + // If we stop due to everyone sleeping we should reset the weather duration to some other random value. + // Not that everyone ever manages to get the whole server to sleep at the same time.... + if (!this.serverLevelData.isThundering()) { -+ this.serverLevelData.setThunderDuration(0); ++ this.serverLevelData.setThunderTime(0); + } + // CraftBukkit end } public void resetEmptyTime() { -@@ -680,6 +757,7 @@ +@@ -695,6 +772,7 @@ }); - gameprofilerfiller.c("tickNonPassenger"); + gameprofilerfiller.incrementCounter("tickNonPassenger"); entity.tick(); + entity.postTick(); // CraftBukkit - this.getMethodProfiler().exit(); + this.getProfiler().pop(); Iterator iterator = entity.getPassengers().iterator(); -@@ -703,6 +781,7 @@ +@@ -718,6 +796,7 @@ }); - gameprofilerfiller.c("tickPassenger"); - entity1.passengerTick(); + gameprofilerfiller.incrementCounter("tickPassenger"); + entity1.rideTick(); + entity1.postTick(); // CraftBukkit - gameprofilerfiller.exit(); + gameprofilerfiller.pop(); Iterator iterator = entity1.getPassengers().iterator(); -@@ -727,6 +806,7 @@ - ChunkProviderServer chunkproviderserver = this.getChunkProvider(); +@@ -742,6 +821,7 @@ + ChunkProviderServer chunkproviderserver = this.getChunkSource(); if (!flag1) { + org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit if (iprogressupdate != null) { - iprogressupdate.a(new ChatMessage("menu.savingLevel")); + iprogressupdate.progressStartNoAbort(new ChatMessage("menu.savingLevel")); } -@@ -744,11 +824,19 @@ +@@ -759,11 +839,19 @@ } } @@ -281,105 +263,100 @@ + // CraftBukkit start - moved from MinecraftServer.saveChunks + WorldServer worldserver1 = this; + -+ serverLevelData.a(worldserver1.getWorldBorder().t()); -+ serverLevelData.setCustomBossEvents(this.server.getBossBattleCustomData().save()); -+ convertable.a(this.server.registryHolder, this.serverLevelData, this.server.getPlayerList().save()); ++ serverLevelData.setWorldBorder(worldserver1.getWorldBorder().createSettings()); ++ serverLevelData.setCustomBossEvents(this.server.getCustomBossEvents().save()); ++ convertable.saveDataTag(this.server.registryHolder, this.serverLevelData, this.server.getPlayerList().getSingleplayerData()); + // CraftBukkit end } - private void ap() { + private void saveLevelData() { if (this.dragonFight != null) { -- this.server.getSaveData().a(this.dragonFight.a()); -+ this.serverLevelData.a(this.dragonFight.a()); // CraftBukkit +- this.server.getWorldData().setEndDragonFightData(this.dragonFight.saveData()); ++ this.serverLevelData.setEndDragonFightData(this.dragonFight.saveData()); // CraftBukkit } - this.getChunkProvider().getWorldPersistentData().a(); -@@ -794,15 +882,34 @@ + this.getChunkSource().getDataStorage().save(); +@@ -809,15 +897,34 @@ @Override - public boolean addEntity(Entity entity) { -- return this.addEntity0(entity); + public boolean addFreshEntity(Entity entity) { +- return this.addEntity(entity); + // CraftBukkit start -+ return this.addEntity0(entity, CreatureSpawnEvent.SpawnReason.DEFAULT); ++ return this.addFreshEntity(entity, CreatureSpawnEvent.SpawnReason.DEFAULT); + } + + @Override -+ public boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) { -+ return this.addEntity0(entity, reason); ++ public boolean addFreshEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) { ++ return this.addEntity(entity, reason); + // CraftBukkit end } - public boolean addEntitySerialized(Entity entity) { -- return this.addEntity0(entity); + public boolean addWithUUID(Entity entity) { +- return this.addEntity(entity); + // CraftBukkit start -+ return this.addEntitySerialized(entity, CreatureSpawnEvent.SpawnReason.DEFAULT); ++ return this.addWithUUID(entity, CreatureSpawnEvent.SpawnReason.DEFAULT); + } + -+ public boolean addEntitySerialized(Entity entity, CreatureSpawnEvent.SpawnReason reason) { -+ return this.addEntity0(entity, reason); ++ public boolean addWithUUID(Entity entity, CreatureSpawnEvent.SpawnReason reason) { ++ return this.addEntity(entity, reason); + // CraftBukkit end } - public void addEntityTeleport(Entity entity) { -- this.addEntity0(entity); + public void addDuringTeleport(Entity entity) { +- this.addEntity(entity); + // CraftBukkit start -+ this.addEntity0(entity, CreatureSpawnEvent.SpawnReason.DEFAULT); ++ this.addDuringTeleport(entity, CreatureSpawnEvent.SpawnReason.DEFAULT); + } + -+ public void addEntityTeleport(Entity entity, CreatureSpawnEvent.SpawnReason reason) { -+ this.addEntity0(entity, reason); ++ public void addDuringTeleport(Entity entity, CreatureSpawnEvent.SpawnReason reason) { ++ this.addEntity(entity, reason); + // CraftBukkit end } - public void addPlayerCommand(EntityPlayer entityplayer) { -@@ -830,27 +937,39 @@ - this.a((EntityPlayer) entity, Entity.RemovalReason.DISCARDED); - } - -- this.entityManager.a((EntityAccess) entityplayer); -+ this.entityManager.a(entityplayer); // CraftBukkit - decompile error + public void addDuringCommandTeleport(EntityPlayer entityplayer) { +@@ -848,24 +955,36 @@ + this.entityManager.addNewEntity(entityplayer); } -- private boolean addEntity0(Entity entity) { +- private boolean addEntity(Entity entity) { + // CraftBukkit start -+ private boolean addEntity0(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) { ++ private boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) { if (entity.isRemoved()) { -- WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.getEntityType())); -+ // WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.getEntityType())); // CraftBukkit +- WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getKey(entity.getType())); ++ // WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getKey(entity.getType())); // CraftBukkit return false; } else { -- return this.entityManager.a((EntityAccess) entity); + if (!CraftEventFactory.doEntityAddEventCalling(this, entity, spawnReason)) { + return false; + } + // CraftBukkit end + -+ return this.entityManager.a(entity); // CraftBukkit - decompile error + return this.entityManager.addNewEntity(entity); } } - public boolean addAllEntitiesSafely(Entity entity) { -- Stream stream = entity.recursiveStream().map(Entity::getUniqueID); + public boolean tryAddFreshEntityWithPassengers(Entity entity) { +- Stream stream = entity.getSelfAndPassengers().map(Entity::getUUID); + // CraftBukkit start -+ return this.addAllEntitiesSafely(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); ++ return this.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } + -+ public boolean addAllEntitiesSafely(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ public boolean tryAddFreshEntityWithPassengers(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + // CraftBukkit end -+ Stream<UUID> stream = entity.recursiveStream().map(Entity::getUniqueID); // CraftBukkit - decompile error ++ Stream<UUID> stream = entity.getSelfAndPassengers().map(Entity::getUUID); // CraftBukkit - decompile error PersistentEntitySectionManager persistententitysectionmanager = this.entityManager; Objects.requireNonNull(this.entityManager); - if (stream.anyMatch(persistententitysectionmanager::a)) { + if (stream.anyMatch(persistententitysectionmanager::isLoaded)) { return false; } else { -- this.addAllEntities(entity); -+ this.addAllEntities(entity, reason); // CraftBukkit +- this.addFreshEntityWithPassengers(entity); ++ this.addFreshEntityWithPassengers(entity, reason); // CraftBukkit return true; } } -@@ -863,10 +982,32 @@ - entityplayer.a(entity_removalreason); +@@ -879,10 +998,32 @@ + entityplayer.remove(entity_removalreason); } + // CraftBukkit start @@ -394,12 +371,12 @@ + return false; + } + -+ return this.addEntity(entitylightning); ++ return this.addFreshEntity(entitylightning); + } + // CraftBukkit end + @Override - public void a(int i, BlockPosition blockposition, int j) { + public void destroyBlockProgress(int i, BlockPosition blockposition, int j) { Iterator iterator = this.server.getPlayerList().getPlayers().iterator(); + // CraftBukkit start @@ -411,9 +388,9 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -875,6 +1016,12 @@ - double d1 = (double) blockposition.getY() - entityplayer.locY(); - double d2 = (double) blockposition.getZ() - entityplayer.locZ(); +@@ -891,6 +1032,12 @@ + double d1 = (double) blockposition.getY() - entityplayer.getY(); + double d2 = (double) blockposition.getZ() - entityplayer.getZ(); + // CraftBukkit start + if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) { @@ -422,9 +399,9 @@ + // CraftBukkit end + if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { - entityplayer.connection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); + entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); } -@@ -923,7 +1070,18 @@ +@@ -938,7 +1085,18 @@ Iterator iterator = this.navigatingMobs.iterator(); while (iterator.hasNext()) { @@ -437,19 +414,19 @@ + // 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 + // As this is a relative edge case it is much faster than copying navigators (on either read or write) -+ notify(blockposition, iblockdata, iblockdata1, i); ++ sendBlockUpdated(blockposition, iblockdata, iblockdata1, i); + return; + } + // CraftBukkit end NavigationAbstract navigationabstract = entityinsentient.getNavigation(); - if (!navigationabstract.i()) { -@@ -946,10 +1104,20 @@ + if (!navigationabstract.hasDelayedRecomputation()) { +@@ -961,10 +1119,20 @@ @Override - public Explosion createExplosion(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) { + public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) { + // CraftBukkit start -+ Explosion explosion = super.createExplosion(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, explosion_effect); ++ Explosion explosion = super.explode(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, explosion_effect); + + if (explosion.wasCanceled) { + return explosion; @@ -458,17 +435,17 @@ + /* Remove Explosion explosion = new Explosion(this, entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, explosion_effect); - explosion.a(); - explosion.a(false); + explosion.explode(); + explosion.finalizeExplosion(false); + */ + // CraftBukkit end - TODO: Check if explosions are still properly implemented if (explosion_effect == Explosion.Effect.NONE) { - explosion.clearBlocks(); + explosion.clearToBlow(); } -@@ -1023,13 +1191,20 @@ +@@ -1045,13 +1213,20 @@ } - public <T extends ParticleParam> int a(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { + public <T extends ParticleParam> int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { - PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, false, d0, d1, d2, (float) d3, (float) d4, (float) d5, (float) d6, i); + // CraftBukkit - visibility api support + return sendParticles(null, t0, d0, d1, d2, i, d3, d4, d5, d6, false); @@ -483,72 +460,72 @@ EntityPlayer entityplayer = (EntityPlayer) this.players.get(k); + if (sender != null && !entityplayer.getBukkitEntity().canSee(sender.getBukkitEntity())) continue; // CraftBukkit -- if (this.a(entityplayer, false, d0, d1, d2, packetplayoutworldparticles)) { -+ if (this.a(entityplayer, force, d0, d1, d2, packetplayoutworldparticles)) { // CraftBukkit +- if (this.sendParticles(entityplayer, false, d0, d1, d2, packetplayoutworldparticles)) { ++ if (this.sendParticles(entityplayer, force, d0, d1, d2, packetplayoutworldparticles)) { // CraftBukkit ++j; } } -@@ -1079,7 +1254,7 @@ +@@ -1101,7 +1276,7 @@ @Nullable - public BlockPosition a(StructureGenerator<?> structuregenerator, BlockPosition blockposition, int i, boolean flag) { -- return !this.server.getSaveData().getGeneratorSettings().shouldGenerateMapFeatures() ? null : this.getChunkProvider().getChunkGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag); -+ return !this.serverLevelData.getGeneratorSettings().shouldGenerateMapFeatures() ? null : this.getChunkProvider().getChunkGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag); // CraftBukkit + public BlockPosition findNearestMapFeature(StructureGenerator<?> structuregenerator, BlockPosition blockposition, int i, boolean flag) { +- return !this.server.getWorldData().worldGenSettings().generateFeatures() ? null : this.getChunkSource().getGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag); ++ return !this.serverLevelData.worldGenSettings().generateFeatures() ? null : this.getChunkSource().getGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag); // CraftBukkit } @Nullable -@@ -1116,11 +1291,21 @@ +@@ -1138,11 +1313,21 @@ @Nullable @Override - public WorldMap a(String s) { -- return (WorldMap) this.getMinecraftServer().E().getWorldPersistentData().a(WorldMap::b, s); -+ return (WorldMap) this.getMinecraftServer().E().getWorldPersistentData().a((nbttagcompound) -> { -+ // CraftBukkit start + public WorldMap getMapData(String s) { +- return (WorldMap) this.getServer().overworld().getDataStorage().get(WorldMap::load, s); ++ // CraftBukkit start ++ return (WorldMap) this.getServer().overworld().getDataStorage().get((nbttagcompound) -> { + // We only get here when the data file exists, but is not a valid map -+ WorldMap newMap = WorldMap.b(nbttagcompound); ++ WorldMap newMap = WorldMap.load(nbttagcompound); + newMap.id = s; + MapInitializeEvent event = new MapInitializeEvent(newMap.mapView); + Bukkit.getServer().getPluginManager().callEvent(event); + return newMap; -+ // CraftBukkit end + }, s); ++ // CraftBukkit end } @Override - public void a(String s, WorldMap worldmap) { + public void setMapData(String s, WorldMap worldmap) { + worldmap.id = s; // CraftBukkit - this.getMinecraftServer().E().getWorldPersistentData().a(s, (PersistentBase) worldmap); + this.getServer().overworld().getDataStorage().set(s, worldmap); } -@@ -1432,6 +1617,11 @@ +@@ -1454,6 +1639,11 @@ @Override - public void update(BlockPosition blockposition, Block block) { - if (!this.isDebugWorld()) { + public void blockUpdated(BlockPosition blockposition, Block block) { + if (!this.isDebug()) { + // CraftBukkit start + if (populating) { + return; + } + // CraftBukkit end - this.applyPhysics(blockposition, block); + this.updateNeighborsAt(blockposition, block); } -@@ -1451,12 +1641,12 @@ +@@ -1473,12 +1663,12 @@ } - public boolean isFlatWorld() { -- return this.server.getSaveData().getGeneratorSettings().isFlatWorld(); -+ return this.serverLevelData.getGeneratorSettings().isFlatWorld(); // CraftBukkit + public boolean isFlat() { +- return this.server.getWorldData().worldGenSettings().isFlatWorld(); ++ return this.serverLevelData.worldGenSettings().isFlatWorld(); // CraftBukkit } @Override public long getSeed() { -- return this.server.getSaveData().getGeneratorSettings().getSeed(); -+ return this.serverLevelData.getGeneratorSettings().getSeed(); // CraftBukkit +- return this.server.getWorldData().worldGenSettings().seed(); ++ return this.serverLevelData.worldGenSettings().seed(); // CraftBukkit } @Nullable -@@ -1484,7 +1674,7 @@ - private static <T> String a(Iterable<T> iterable, Function<T, String> function) { +@@ -1506,7 +1696,7 @@ + private static <T> String getTypeCount(Iterable<T> iterable, Function<T, String> function) { try { Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap(); - Iterator iterator = iterable.iterator(); @@ -556,7 +533,7 @@ while (iterator.hasNext()) { T t0 = iterator.next(); -@@ -1493,7 +1683,7 @@ +@@ -1515,7 +1705,7 @@ object2intopenhashmap.addTo(s, 1); } @@ -565,15 +542,15 @@ String s1 = (String) entry.getKey(); return s1 + ":" + entry.getIntValue(); -@@ -1504,17 +1694,33 @@ +@@ -1526,17 +1716,33 @@ } - public static void a(WorldServer worldserver) { + public static void makeObsidianPlatform(WorldServer worldserver) { + // CraftBukkit start -+ WorldServer.a(worldserver, null); ++ WorldServer.makeObsidianPlatform(worldserver, null); + } + -+ public static void a(WorldServer worldserver, Entity entity) { ++ public static void makeObsidianPlatform(WorldServer worldserver, Entity entity) { + // CraftBukkit end BlockPosition blockposition = WorldServer.END_SPAWN_POINT; int i = blockposition.getX(); @@ -582,13 +559,13 @@ + // CraftBukkit start + org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(worldserver); - BlockPosition.b(i - 2, j + 1, k - 2, i + 2, j + 3, k + 2).forEach((blockposition1) -> { -- worldserver.setTypeUpdate(blockposition1, Blocks.AIR.getBlockData()); -+ blockList.setTypeAndData(blockposition1, Blocks.AIR.getBlockData(), 3); + BlockPosition.betweenClosed(i - 2, j + 1, k - 2, i + 2, j + 3, k + 2).forEach((blockposition1) -> { +- worldserver.setBlockAndUpdate(blockposition1, Blocks.AIR.defaultBlockState()); ++ blockList.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3); }); - BlockPosition.b(i - 2, j, k - 2, i + 2, j, k + 2).forEach((blockposition1) -> { -- worldserver.setTypeUpdate(blockposition1, Blocks.OBSIDIAN.getBlockData()); -+ blockList.setTypeAndData(blockposition1, Blocks.OBSIDIAN.getBlockData(), 3); + BlockPosition.betweenClosed(i - 2, j, k - 2, i + 2, j, k + 2).forEach((blockposition1) -> { +- worldserver.setBlockAndUpdate(blockposition1, Blocks.OBSIDIAN.defaultBlockState()); ++ blockList.setBlock(blockposition1, Blocks.OBSIDIAN.defaultBlockState(), 3); }); + org.bukkit.World bworld = worldserver.getWorld(); + org.bukkit.event.world.PortalCreateEvent portalEvent = new org.bukkit.event.world.PortalCreateEvent((List<org.bukkit.block.BlockState>) (List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM); @@ -601,16 +578,16 @@ } @Override -@@ -1601,6 +1807,7 @@ +@@ -1629,6 +1835,7 @@ } } + entity.valid = true; // CraftBukkit } - public void a(Entity entity) { -@@ -1633,6 +1840,7 @@ - gameeventlistenerregistrar.a(entity.level); + public void onTrackingEnd(Entity entity) { +@@ -1661,6 +1868,7 @@ + gameeventlistenerregistrar.onListenerRemoved(entity.level); } + entity.valid = false; // CraftBukkit diff --git a/paper-server/nms-patches/net/minecraft/server/network/HandshakeListener.patch b/paper-server/nms-patches/net/minecraft/server/network/HandshakeListener.patch index 2deb382cca..76b05b3205 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/HandshakeListener.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/HandshakeListener.patch @@ -19,21 +19,21 @@ private final MinecraftServer server; private final NetworkManager connection; @@ -27,6 +36,40 @@ - switch (packethandshakinginsetprotocol.b()) { + switch (packethandshakinginsetprotocol.getIntention()) { case LOGIN: this.connection.setProtocol(EnumProtocol.LOGIN); + // CraftBukkit start - Connection throttle + try { + long currentTime = System.currentTimeMillis(); + long connectionThrottle = this.server.server.getConnectionThrottle(); -+ InetAddress address = ((java.net.InetSocketAddress) this.connection.getSocketAddress()).getAddress(); ++ InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress(); + + synchronized (throttleTracker) { + if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) { + throttleTracker.put(address, currentTime); + ChatMessage chatmessage = new ChatMessage("Connection throttled! Please wait before reconnecting."); -+ this.connection.sendPacket(new PacketLoginOutDisconnect(chatmessage)); -+ this.connection.close(chatmessage); ++ this.connection.send(new PacketLoginOutDisconnect(chatmessage)); ++ this.connection.disconnect(chatmessage); + return; + } + @@ -56,14 +56,14 @@ + org.apache.logging.log4j.LogManager.getLogger().debug("Failed to check connection throttle", t); + } + // CraftBukkit end - if (packethandshakinginsetprotocol.c() != SharedConstants.getGameVersion().getProtocolVersion()) { + if (packethandshakinginsetprotocol.getProtocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) { ChatMessage chatmessage; @@ -40,6 +83,7 @@ - this.connection.close(chatmessage); + this.connection.disconnect(chatmessage); } else { - this.connection.setPacketListener(new LoginListener(this.server, this.connection)); -+ ((LoginListener) this.connection.j()).hostname = packethandshakinginsetprotocol.hostName + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname + this.connection.setListener(new LoginListener(this.server, this.connection)); ++ ((LoginListener) this.connection.getPacketListener()).hostname = packethandshakinginsetprotocol.hostName + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname } break; case STATUS: diff --git a/paper-server/nms-patches/net/minecraft/server/network/LegacyPingHandler.patch b/paper-server/nms-patches/net/minecraft/server/network/LegacyPingHandler.patch index efcac2c2d4..d9deac6c49 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/LegacyPingHandler.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/LegacyPingHandler.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/network/LegacyPingHandler.java +++ b/net/minecraft/server/network/LegacyPingHandler.java @@ -36,11 +36,12 @@ - MinecraftServer minecraftserver = this.serverConnectionListener.d(); + MinecraftServer minecraftserver = this.serverConnectionListener.getServer(); int i = bytebuf.readableBytes(); String s; + org.bukkit.event.server.ServerListPingEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(minecraftserver.server, inetsocketaddress.getAddress(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); // CraftBukkit @@ -11,24 +11,24 @@ LegacyPingHandler.LOGGER.debug("Ping: (<1.3.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort()); - s = String.format("%s\u00a7%d\u00a7%d", minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); + s = String.format("%s\u00a7%d\u00a7%d", event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit - this.a(channelhandlercontext, this.a(s)); + this.sendFlushAndClose(channelhandlercontext, this.createReply(s)); break; case 1: @@ -49,7 +50,7 @@ } LegacyPingHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort()); -- s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); -+ s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit - this.a(channelhandlercontext, this.a(s)); +- s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); ++ s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit + this.sendFlushAndClose(channelhandlercontext, this.createReply(s)); break; default: @@ -68,7 +69,7 @@ } LegacyPingHandler.LOGGER.debug("Ping: (1.6) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort()); -- String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); -+ String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit - ByteBuf bytebuf1 = this.a(s1); +- String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); ++ String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit + ByteBuf bytebuf1 = this.createReply(s1); try { diff --git a/paper-server/nms-patches/net/minecraft/server/network/LoginListener.patch b/paper-server/nms-patches/net/minecraft/server/network/LoginListener.patch index 2b7f7ade4d..1bbda9b1c6 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/LoginListener.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/LoginListener.patch @@ -31,9 +31,9 @@ + public void disconnect(String s) { + try { + IChatBaseComponent ichatbasecomponent = new ChatComponentText(s); -+ LoginListener.LOGGER.info("Disconnecting {}: {}", this.d(), s); -+ this.connection.sendPacket(new PacketLoginOutDisconnect(ichatbasecomponent)); -+ this.connection.close(ichatbasecomponent); ++ LoginListener.LOGGER.info("Disconnecting {}: {}", this.getUserName(), s); ++ this.connection.send(new PacketLoginOutDisconnect(ichatbasecomponent)); ++ this.connection.disconnect(ichatbasecomponent); + } catch (Exception exception) { + LoginListener.LOGGER.error("Error whilst disconnecting player", exception); + } @@ -41,15 +41,15 @@ + // CraftBukkit end + @Override - public NetworkManager a() { + public NetworkManager getConnection() { return this.connection; @@ -101,10 +123,12 @@ - this.gameProfile = this.a(this.gameProfile); + this.gameProfile = this.createFakeProfile(this.gameProfile); } -- IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().attemptLogin(this.connection.getSocketAddress(), this.gameProfile); +- IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().canPlayerLogin(this.connection.getRemoteAddress(), this.gameProfile); + // CraftBukkit start - fire PlayerLoginEvent -+ EntityPlayer s = this.server.getPlayerList().attemptLogin(this, this.gameProfile, hostname); ++ EntityPlayer s = this.server.getPlayerList().canPlayerLogin(this, this.gameProfile, hostname); - if (ichatbasecomponent != null) { - this.disconnect(ichatbasecomponent); @@ -58,19 +58,19 @@ + // CraftBukkit end } else { this.state = LoginListener.EnumProtocolState.ACCEPTED; - if (this.server.av() >= 0 && !this.connection.isLocal()) { + if (this.server.getCompressionThreshold() >= 0 && !this.connection.isMemoryConnection()) { @@ -117,7 +141,7 @@ EntityPlayer entityplayer = this.server.getPlayerList().getPlayer(this.gameProfile.getId()); try { -- EntityPlayer entityplayer1 = this.server.getPlayerList().processLogin(this.gameProfile); -+ EntityPlayer entityplayer1 = this.server.getPlayerList().processLogin(this.gameProfile, s); // CraftBukkit - add player reference +- EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile); ++ EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile, s); // CraftBukkit - add player reference if (entityplayer != null) { this.state = LoginListener.EnumProtocolState.DELAY_ACCEPT; -@@ -191,6 +215,43 @@ +@@ -192,6 +216,43 @@ try { - LoginListener.this.gameProfile = LoginListener.this.server.getMinecraftSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.a()); + LoginListener.this.gameProfile = LoginListener.this.server.getSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.getAddress()); if (LoginListener.this.gameProfile != null) { + // CraftBukkit start - fire PlayerPreLoginEvent + if (!connection.isConnected()) { @@ -78,7 +78,7 @@ + } + + String playerName = gameProfile.getName(); -+ java.net.InetAddress address = ((java.net.InetSocketAddress) connection.getSocketAddress()).getAddress(); ++ java.net.InetAddress address = ((java.net.InetSocketAddress) connection.getRemoteAddress()).getAddress(); + java.util.UUID uniqueId = gameProfile.getId(); + final org.bukkit.craftbukkit.CraftServer server = LoginListener.this.server.server; + @@ -111,8 +111,8 @@ + // CraftBukkit end LoginListener.LOGGER.info("UUID of player {} is {}", LoginListener.this.gameProfile.getName(), LoginListener.this.gameProfile.getId()); LoginListener.this.state = LoginListener.EnumProtocolState.READY_TO_ACCEPT; - } else if (LoginListener.this.server.isEmbeddedServer()) { -@@ -210,6 +271,11 @@ + } else if (LoginListener.this.server.isSingleplayer()) { +@@ -211,6 +272,11 @@ LoginListener.this.disconnect(new ChatMessage("multiplayer.disconnect.authservers_down")); LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable"); } diff --git a/paper-server/nms-patches/net/minecraft/server/network/PacketStatusListener.patch b/paper-server/nms-patches/net/minecraft/server/network/PacketStatusListener.patch index d33e9e278a..ac7755c7fa 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/PacketStatusListener.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/PacketStatusListener.patch @@ -19,11 +19,11 @@ public class PacketStatusListener implements PacketStatusInListener { private static final IChatBaseComponent DISCONNECT_REASON = new ChatMessage("multiplayer.status.request_handled"); -@@ -36,8 +48,96 @@ - this.connection.close(PacketStatusListener.DISCONNECT_REASON); +@@ -36,7 +48,95 @@ + this.connection.disconnect(PacketStatusListener.DISCONNECT_REASON); } else { this.hasRequestedStatus = true; -- this.connection.sendPacket(new PacketStatusOutServerInfo(this.server.getServerPing())); +- this.connection.send(new PacketStatusOutServerInfo(this.server.getStatus())); + // CraftBukkit start + // this.networkManager.sendPacket(new PacketStatusOutServerInfo(this.minecraftServer.getServerPing())); + final Object[] players = server.getPlayerList().players.toArray(); @@ -32,7 +32,7 @@ + CraftIconCache icon = server.server.getServerIcon(); + + ServerListPingEvent() { -+ super(((InetSocketAddress) connection.getSocketAddress()).getAddress(), server.getMotd(), server.getPlayerList().getMaxPlayers()); ++ super(((InetSocketAddress) connection.getRemoteAddress()).getAddress(), server.getMotd(), server.getPlayerList().getMaxPlayers()); + } + + @Override @@ -97,23 +97,22 @@ + java.util.List<GameProfile> profiles = new java.util.ArrayList<GameProfile>(players.length); + for (Object player : players) { + if (player != null) { -+ profiles.add(((EntityPlayer) player).getProfile()); ++ profiles.add(((EntityPlayer) player).getGameProfile()); + } + } + + ServerPing.ServerPingPlayerSample playerSample = new ServerPing.ServerPingPlayerSample(event.getMaxPlayers(), profiles.size()); -+ playerSample.a(profiles.toArray(new GameProfile[profiles.size()])); ++ playerSample.setSample(profiles.toArray(new GameProfile[profiles.size()])); + + ServerPing ping = new ServerPing(); + ping.setFavicon(event.icon.value); -+ ping.setMOTD(CraftChatMessage.fromString(event.getMotd(), true)[0]); -+ ping.setPlayerSample(playerSample); -+ int version = SharedConstants.getGameVersion().getProtocolVersion(); -+ ping.setServerInfo(new ServerPing.ServerData(server.getServerModName() + " " + server.getVersion(), version)); ++ ping.setDescription(CraftChatMessage.fromString(event.getMotd(), true)[0]); ++ ping.setPlayers(playerSample); ++ int version = SharedConstants.getCurrentVersion().getProtocolVersion(); ++ ping.setVersion(new ServerPing.ServerData(server.getServerModName() + " " + server.getServerVersion(), version)); + -+ this.connection.sendPacket(new PacketStatusOutServerInfo(ping)); ++ this.connection.send(new PacketStatusOutServerInfo(ping)); ++ // CraftBukkit end } -+ // CraftBukkit end } - @Override diff --git a/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch b/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch index 21ece93251..413d1f1ea1 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch +++ b/paper-server/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 -@@ -157,6 +157,62 @@ +@@ -156,6 +156,62 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -63,21 +63,21 @@ public class PlayerConnection implements ServerPlayerConnection, PacketListenerPlayIn { static final Logger LOGGER = LogManager.getLogger(); -@@ -168,7 +224,9 @@ +@@ -167,7 +223,9 @@ private long keepAliveTime; private boolean keepAlivePending; private long keepAliveChallenge; - private int chatSpamTickCount; + // CraftBukkit start - multithreaded fields -+ private AtomicInteger chatSpamTickCount = new AtomicInteger(); ++ private final AtomicInteger chatSpamTickCount = new AtomicInteger(); + // CraftBukkit end private int dropSpamTickCount; private double firstGoodX; private double firstGoodY; -@@ -202,7 +260,33 @@ +@@ -201,7 +259,33 @@ this.player = entityplayer; entityplayer.connection = this; - entityplayer.Q().a(); + entityplayer.getTextFilter().join(); + + // CraftBukkit start - add fields and methods + this.cserver = minecraftserver.server; @@ -101,26 +101,26 @@ + private float lastYaw = Float.MAX_VALUE; + private boolean justTeleported = false; + -+ public CraftPlayer getPlayer() { ++ public CraftPlayer getCraftPlayer() { + return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity(); } + // CraftBukkit end public void tick() { - this.syncPosition(); -@@ -251,7 +335,7 @@ - this.server.getMethodProfiler().enter("keepAlive"); - long i = SystemUtils.getMonotonicMillis(); + this.resetPosition(); +@@ -250,7 +334,7 @@ + this.server.getProfiler().push("keepAlive"); + long i = SystemUtils.getMillis(); - if (i - this.keepAliveTime >= 15000L) { + if (i - this.keepAliveTime >= 25000L) { // CraftBukkit if (this.keepAlivePending) { this.disconnect(new ChatMessage("disconnect.timeout")); } else { -@@ -263,15 +347,21 @@ +@@ -262,15 +346,21 @@ } - this.server.getMethodProfiler().exit(); + this.server.getProfiler().pop(); + // CraftBukkit start + for (int spam; (spam = this.chatSpamTickCount.get()) > 0 && !chatSpamTickCount.compareAndSet(spam, spam - 1); ) ; + /* Use thread-safe field access instead @@ -134,13 +134,13 @@ --this.dropSpamTickCount; } - if (this.player.F() > 0L && this.server.getIdleTimeout() > 0 && SystemUtils.getMonotonicMillis() - this.player.F() > (long) (this.server.getIdleTimeout() * 1000 * 60)) { -+ this.player.resetIdleTimer(); // CraftBukkit - SPIGOT-854 + if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && SystemUtils.getMillis() - this.player.getLastActionTime() > (long) (this.server.getPlayerIdleTimeout() * 1000 * 60)) { ++ this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854 this.disconnect(new ChatMessage("multiplayer.disconnect.idling")); } -@@ -295,16 +385,46 @@ - return this.server.a(this.player.getProfile()); +@@ -294,16 +384,46 @@ + return this.server.isSingleplayerOwner(this.player.getGameProfile()); } + // CraftBukkit start @@ -155,7 +155,7 @@ + if (this.processedDisconnect) { + return; + } -+ String leaveMessage = EnumChatFormat.YELLOW + this.player.getName() + " left the game."; ++ String leaveMessage = EnumChatFormat.YELLOW + this.player.getScoreboardName() + " left the game."; + + PlayerKickEvent event = new PlayerKickEvent(this.player.getBukkitEntity(), s, leaveMessage); + @@ -172,40 +172,26 @@ + final IChatBaseComponent ichatbasecomponent = CraftChatMessage.fromString(s, true)[0]; + // CraftBukkit end + - this.connection.sendPacket(new PacketPlayOutKickDisconnect(ichatbasecomponent), (future) -> { - this.connection.close(ichatbasecomponent); + this.connection.send(new PacketPlayOutKickDisconnect(ichatbasecomponent), (future) -> { + this.connection.disconnect(ichatbasecomponent); }); -+ this.a(ichatbasecomponent); // CraftBukkit - fire quit instantly - this.connection.stopReading(); ++ this.onDisconnect(ichatbasecomponent); // CraftBukkit - fire quit instantly + this.connection.setReadOnly(); MinecraftServer minecraftserver = this.server; NetworkManager networkmanager = this.connection; Objects.requireNonNull(this.connection); -- minecraftserver.executeSync(networkmanager::handleDisconnection); +- minecraftserver.executeBlocking(networkmanager::handleDisconnection); + // CraftBukkit - Don't wait -+ minecraftserver.postToMainThread(networkmanager::handleDisconnection); ++ minecraftserver.wrapRunnable(networkmanager::handleDisconnection); } - private <T, R> void a(T t0, Consumer<R> consumer, BiFunction<ITextFilter, T, CompletableFuture<R>> bifunction) { -@@ -322,11 +442,11 @@ - } - - private void a(String s, Consumer<ITextFilter.a> consumer) { -- this.a((Object) s, consumer, ITextFilter::a); -+ this.a(s, consumer, ITextFilter::a); // CraftBukkit - decompile error - } - - private void a(List<String> list, Consumer<List<ITextFilter.a>> consumer) { -- this.a((Object) list, consumer, ITextFilter::a); -+ this.a(list, consumer, ITextFilter::a); // CraftBukkit - decompile error - } - - @Override -@@ -371,7 +491,34 @@ - double d9 = entity.getMot().g(); + private <T, R> void filterTextPacket(T t0, Consumer<R> consumer, BiFunction<ITextFilter, T, CompletableFuture<R>> bifunction) { +@@ -370,7 +490,34 @@ + double d9 = entity.getDeltaMovement().lengthSqr(); double d10 = d6 * d6 + d7 * d7 + d8 * d8; -- if (d10 - d9 > 100.0D && !this.isExemptPlayer()) { +- if (d10 - d9 > 100.0D && !this.isSingleplayerOwner()) { + + // CraftBukkit start - handle custom speeds and skipped ticks + this.allowedPlayerTicks += (System.currentTimeMillis() / 50) - this.lastTick; @@ -215,7 +201,7 @@ + ++this.receivedMovePacketCount; + int i = this.receivedMovePacketCount - this.knownMovePacketCount; + if (i > Math.max(this.allowedPlayerTicks, 5)) { -+ PlayerConnection.LOGGER.debug(this.player.getName() + " is sending move packets too frequently (" + i + " packets since last tick)"); ++ PlayerConnection.LOGGER.debug(this.player.getScoreboardName() + " is sending move packets too frequently (" + i + " packets since last tick)"); + i = 1; + } + @@ -232,27 +218,27 @@ + } + speed *= 2f; // TODO: Get the speed of the vehicle instead of the player + -+ if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && !this.isExemptPlayer()) { ++ if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { + // CraftBukkit end - PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getDisplayName().getString(), this.player.getDisplayName().getString(), d6, d7, d8); - this.connection.sendPacket(new PacketPlayOutVehicleMove(entity)); + PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getName().getString(), this.player.getName().getString(), d6, d7, d8); + this.connection.send(new PacketPlayOutVehicleMove(entity)); return; -@@ -401,14 +548,72 @@ +@@ -400,14 +547,72 @@ } - entity.setLocation(d3, d4, d5, f, f1); -+ player.setLocation(d3, d4, d5, this.player.getYRot(), this.player.getXRot()); // CraftBukkit - boolean flag2 = worldserver.getCubes(entity, entity.getBoundingBox().shrink(0.0625D)); + entity.absMoveTo(d3, d4, d5, f, f1); ++ player.absMoveTo(d3, d4, d5, this.player.getYRot(), this.player.getXRot()); // CraftBukkit + boolean flag2 = worldserver.noCollision(entity, entity.getBoundingBox().deflate(0.0625D)); if (flag && (flag1 || !flag2)) { - entity.setLocation(d0, d1, d2, f, f1); -+ player.setLocation(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit - this.connection.sendPacket(new PacketPlayOutVehicleMove(entity)); + entity.absMoveTo(d0, d1, d2, f, f1); ++ player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit + this.connection.send(new PacketPlayOutVehicleMove(entity)); return; } + // CraftBukkit start - fire PlayerMoveEvent -+ Player player = this.getPlayer(); ++ Player player = this.getCraftPlayer(); + 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. + @@ -263,14 +249,14 @@ + + + // If the packet contains look information then we update the To location with the correct Yaw & Pitch. -+ to.setYaw(packetplayinvehiclemove.getYaw()); -+ to.setPitch(packetplayinvehiclemove.getPitch()); ++ to.setYaw(packetplayinvehiclemove.getYRot()); ++ to.setPitch(packetplayinvehiclemove.getXRot()); + + // 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.isFrozen()) { ++ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.isImmobile()) { + this.lastPosX = to.getX(); + this.lastPosY = to.getY(); + this.lastPosZ = to.getZ(); @@ -299,7 +285,7 @@ + + // 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.getPlayer().getLocation()) && this.justTeleported) { ++ if (!from.equals(this.getCraftPlayer().getLocation()) && this.justTeleported) { + this.justTeleported = false; + return; + } @@ -307,68 +293,68 @@ + } + // CraftBukkit end + - this.player.getWorldServer().getChunkProvider().movePlayer(this.player); - this.player.checkMovement(this.player.locX() - d0, this.player.locY() - d1, this.player.locZ() - d2); - this.clientVehicleIsFloating = d11 >= -0.03125D && !this.server.getAllowFlight() && this.a(entity); -@@ -427,7 +632,7 @@ + this.player.getLevel().getChunkSource().move(this.player); + this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2); + this.clientVehicleIsFloating = d11 >= -0.03125D && !this.server.isFlightAllowed() && this.noBlocksAround(entity); +@@ -426,7 +631,7 @@ @Override - public void a(PacketPlayInTeleportAccept packetplayinteleportaccept) { - PlayerConnectionUtils.ensureMainThread(packetplayinteleportaccept, this, this.player.getWorldServer()); -- if (packetplayinteleportaccept.b() == this.awaitingTeleport) { -+ if (packetplayinteleportaccept.b() == this.awaitingTeleport && this.awaitingPositionFromClient != null) { // CraftBukkit - this.player.setLocation(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); + public void handleAcceptTeleportPacket(PacketPlayInTeleportAccept packetplayinteleportaccept) { + PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinteleportaccept, this, this.player.getLevel()); +- if (packetplayinteleportaccept.getId() == this.awaitingTeleport) { ++ if (packetplayinteleportaccept.getId() == this.awaitingTeleport && this.awaitingPositionFromClient != null) { // CraftBukkit + this.player.absMoveTo(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); this.lastGoodX = this.awaitingPositionFromClient.x; this.lastGoodY = this.awaitingPositionFromClient.y; -@@ -437,6 +642,7 @@ +@@ -436,6 +641,7 @@ } this.awaitingPositionFromClient = null; -+ this.player.getWorldServer().getChunkProvider().movePlayer(this.player); // CraftBukkit ++ this.player.getLevel().getChunkSource().move(this.player); // CraftBukkit } } -@@ -444,7 +650,7 @@ +@@ -443,7 +649,7 @@ @Override - public void a(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) { - PlayerConnectionUtils.ensureMainThread(packetplayinrecipedisplayed, this, this.player.getWorldServer()); -- Optional optional = this.server.getCraftingManager().getRecipe(packetplayinrecipedisplayed.b()); -+ Optional<? extends IRecipe<?>> optional = this.server.getCraftingManager().getRecipe(packetplayinrecipedisplayed.b()); // CraftBukkit - decompile error + public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) { + PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.getLevel()); +- Optional optional = this.server.getRecipeManager().byKey(packetplayinrecipedisplayed.getRecipe()); ++ Optional<? extends IRecipe<?>> optional = this.server.getRecipeManager().byKey(packetplayinrecipedisplayed.getRecipe()); // CraftBukkit - decompile error RecipeBookServer recipebookserver = this.player.getRecipeBook(); Objects.requireNonNull(recipebookserver); -@@ -474,6 +680,12 @@ +@@ -473,6 +679,12 @@ @Override - public void a(PacketPlayInTabComplete packetplayintabcomplete) { - PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer()); + public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) { + PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.getLevel()); + // CraftBukkit start -+ if (chatSpamTickCount.addAndGet(1) > 500 && !this.server.getPlayerList().isOp(this.player.getProfile())) { ++ if (chatSpamTickCount.addAndGet(1) > 500 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { + this.disconnect(new ChatMessage("disconnect.spam", new Object[0])); + return; + } + // CraftBukkit end - StringReader stringreader = new StringReader(packetplayintabcomplete.c()); + StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand()); if (stringreader.canRead() && stringreader.peek() == '/') { -@@ -483,6 +695,7 @@ - ParseResults<CommandListenerWrapper> parseresults = this.server.getCommandDispatcher().a().parse(stringreader, this.player.getCommandListener()); +@@ -482,6 +694,7 @@ + ParseResults<CommandListenerWrapper> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); - this.server.getCommandDispatcher().a().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { + this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { + if (suggestions.isEmpty()) return; // CraftBukkit - don't send through empty suggestions - prevents [<args>] from showing for plugins with nothing more to offer - this.connection.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), suggestions)); + this.connection.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions)); }); } -@@ -715,6 +928,7 @@ +@@ -714,6 +927,7 @@ if (container instanceof ContainerMerchant) { ContainerMerchant containermerchant = (ContainerMerchant) container; + CraftEventFactory.callTradeSelectEvent(this.player, i, containermerchant); // CraftBukkit - containermerchant.d(i); - containermerchant.g(i); -@@ -724,6 +938,13 @@ + containermerchant.setSelectionHint(i); + containermerchant.tryMoveItems(i); +@@ -723,6 +937,13 @@ @Override - public void a(PacketPlayInBEdit packetplayinbedit) { + public void handleEditBook(PacketPlayInBEdit packetplayinbedit) { + // CraftBukkit start + if (this.lastBookTick + 20 > MinecraftServer.currentTick) { + this.disconnect("Book edited too quickly!"); @@ -376,31 +362,31 @@ + } + this.lastBookTick = MinecraftServer.currentTick; + // CraftBukkit end - int i = packetplayinbedit.d(); + int i = packetplayinbedit.getSlot(); - if (PlayerInventory.d(i) || i == 40) { -@@ -732,7 +953,7 @@ + if (PlayerInventory.isHotbarSlot(i) || i == 40) { +@@ -731,7 +952,7 @@ Objects.requireNonNull(list); optional.ifPresent(list::add); -- Stream stream = packetplayinbedit.b().stream().limit(100L); -+ Stream<String> stream = packetplayinbedit.b().stream().limit(100L); // CraftBukkit - decompile error +- Stream stream = packetplayinbedit.getPages().stream().limit(100L); ++ Stream<String> stream = packetplayinbedit.getPages().stream().limit(100L); // CraftBukkit - decompile error Objects.requireNonNull(list); stream.forEach(list::add); -@@ -748,7 +969,7 @@ +@@ -747,7 +968,7 @@ ItemStack itemstack = this.player.getInventory().getItem(i); - if (itemstack.a(Items.WRITABLE_BOOK)) { -- this.a(list, UnaryOperator.identity(), itemstack); -+ this.a(list, UnaryOperator.identity(), itemstack.cloneItemStack(), i, itemstack); // CraftBukkit + if (itemstack.is(Items.WRITABLE_BOOK)) { +- this.updateBookPages(list, UnaryOperator.identity(), itemstack); ++ this.updateBookPages(list, UnaryOperator.identity(), itemstack.copy(), i, itemstack); // CraftBukkit } } -@@ -773,16 +994,16 @@ +@@ -772,16 +993,16 @@ - this.a(list, (s) -> { - return IChatBaseComponent.ChatSerializer.a((IChatBaseComponent) (new ChatComponentText(s))); + this.updateBookPages(list, (s) -> { + return IChatBaseComponent.ChatSerializer.toJson(new ChatComponentText(s)); - }, itemstack1); - this.player.getInventory().setItem(i, itemstack1); + }, itemstack1, i, itemstack); // CraftBukkit @@ -408,59 +394,59 @@ } } -- private void a(List<ITextFilter.a> list, UnaryOperator<String> unaryoperator, ItemStack itemstack) { -+ private void a(List<ITextFilter.a> list, UnaryOperator<String> unaryoperator, ItemStack itemstack, int slot, ItemStack handItem) { // CraftBukkit +- private void updateBookPages(List<ITextFilter.a> list, UnaryOperator<String> unaryoperator, ItemStack itemstack) { ++ private void updateBookPages(List<ITextFilter.a> list, UnaryOperator<String> unaryoperator, ItemStack itemstack, int slot, ItemStack handItem) { // CraftBukkit NBTTagList nbttaglist = new NBTTagList(); - if (this.player.R()) { + if (this.player.isTextFilteringEnabled()) { - Stream stream = list.stream().map((itextfilter_a) -> { + Stream<NBTTagString> stream = list.stream().map((itextfilter_a) -> { // CraftBukkit - decompile error - return NBTTagString.a((String) unaryoperator.apply(itextfilter_a.b())); + return NBTTagString.valueOf((String) unaryoperator.apply(itextfilter_a.getFiltered())); }); -@@ -810,6 +1031,7 @@ +@@ -809,6 +1030,7 @@ } - itemstack.a("pages", (NBTBase) nbttaglist); + itemstack.addTagElement("pages", nbttaglist); + CraftEventFactory.handleEditBookEvent(player, slot, handItem, itemstack); // CraftBukkit } @Override -@@ -846,7 +1068,7 @@ +@@ -845,7 +1067,7 @@ } else { - WorldServer worldserver = this.player.getWorldServer(); + WorldServer worldserver = this.player.getLevel(); - if (!this.player.wonGame) { -+ if (!this.player.wonGame && !this.player.isFrozen()) { // CraftBukkit ++ if (!this.player.wonGame && !this.player.isImmobile()) { // CraftBukkit if (this.tickCount == 0) { - this.syncPosition(); + this.resetPosition(); } -@@ -856,7 +1078,7 @@ +@@ -855,7 +1077,7 @@ this.awaitingTeleportTime = this.tickCount; - this.b(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); + this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); } - + this.allowedPlayerTicks = 20; // CraftBukkit } else { this.awaitingTeleportTime = this.tickCount; - double d0 = a(packetplayinflying.a(this.player.locX())); -@@ -868,7 +1090,15 @@ + double d0 = clampHorizontal(packetplayinflying.getX(this.player.getX())); +@@ -867,7 +1089,15 @@ if (this.player.isPassenger()) { - this.player.setLocation(this.player.locX(), this.player.locY(), this.player.locZ(), f, f1); - this.player.getWorldServer().getChunkProvider().movePlayer(this.player); + this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); + this.player.getLevel().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.locX(); -+ double prevY = player.locY(); -+ double prevZ = player.locZ(); ++ 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.locX(); - double d4 = this.player.locY(); - double d5 = this.player.locZ(); -@@ -888,15 +1118,33 @@ + double d3 = this.player.getX(); + double d4 = this.player.getY(); + double d5 = this.player.getZ(); +@@ -887,15 +1117,33 @@ ++this.receivedMovePacketCount; int i = this.receivedMovePacketCount - this.knownMovePacketCount; @@ -471,7 +457,7 @@ + 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.getDisplayName().getString(), i); + PlayerConnection.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", this.player.getName().getString(), i); i = 1; } @@ -487,33 +473,33 @@ + speed = player.getAbilities().walkingSpeed * 10f; + } + - if (!this.player.H() && (!this.player.getWorldServer().getGameRules().getBoolean(GameRules.RULE_DISABLE_ELYTRA_MOVEMENT_CHECK) || !this.player.isGliding())) { - float f2 = this.player.isGliding() ? 300.0F : 100.0F; + if (!this.player.isChangingDimension() && (!this.player.getLevel().getGameRules().getBoolean(GameRules.RULE_DISABLE_ELYTRA_MOVEMENT_CHECK) || !this.player.isFallFlying())) { + float f2 = this.player.isFallFlying() ? 300.0F : 100.0F; -- if (d11 - d10 > (double) (f2 * (float) i) && !this.isExemptPlayer()) { -+ if (d11 - d10 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && !this.isExemptPlayer()) { +- if (d11 - d10 > (double) (f2 * (float) i) && !this.isSingleplayerOwner()) { ++ if (d11 - d10 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { + // CraftBukkit end - PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getDisplayName().getString(), d7, d8, d9); - this.b(this.player.locX(), this.player.locY(), this.player.locZ(), this.player.getYRot(), this.player.getXRot()); + PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName().getString(), d7, d8, d9); + this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot()); return; -@@ -915,6 +1163,7 @@ +@@ -914,6 +1162,7 @@ } this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9)); -+ this.player.setOnGround(packetplayinflying.b()); // CraftBukkit - SPIGOT-5810, SPIGOT-5835: reset by this.player.move ++ this.player.setOnGround(packetplayinflying.isOnGround()); // CraftBukkit - SPIGOT-5810, SPIGOT-5835: reset by this.player.move double d12 = d8; - d7 = d0 - this.player.locX(); -@@ -936,10 +1185,74 @@ - if (!this.player.noPhysics && !this.player.isSleeping() && (flag1 && worldserver.getCubes(this.player, axisalignedbb) || this.a((IWorldReader) worldserver, axisalignedbb))) { - this.b(d3, d4, d5, f, f1); + d7 = d0 - this.player.getX(); +@@ -935,10 +1184,74 @@ + if (!this.player.noPhysics && !this.player.isSleeping() && (flag1 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb))) { + this.teleport(d3, d4, d5, f, f1); } else { -- this.clientIsFloating = d12 >= -0.03125D && this.player.gameMode.getGameMode() != EnumGamemode.SPECTATOR && !this.server.getAllowFlight() && !this.player.getAbilities().mayfly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isGliding() && this.a((Entity) this.player); +- this.clientIsFloating = d12 >= -0.03125D && this.player.gameMode.getGameModeForPlayer() != EnumGamemode.SPECTATOR && !this.server.isFlightAllowed() && !this.player.getAbilities().mayfly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isFallFlying() && this.noBlocksAround(this.player); + // CraftBukkit start - fire PlayerMoveEvent + // Rest to old location first -+ this.player.setLocation(prevX, prevY, prevZ, prevYaw, prevPitch); ++ this.player.absMoveTo(prevX, prevY, prevZ, prevYaw, prevPitch); + -+ Player player = this.getPlayer(); ++ Player player = this.getCraftPlayer(); + 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. + @@ -534,7 +520,7 @@ + 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.isFrozen()) { ++ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.isImmobile()) { + this.lastPosX = to.getX(); + this.lastPosY = to.getY(); + this.lastPosZ = to.getZ(); @@ -563,59 +549,59 @@ + + // 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.getPlayer().getLocation()) && this.justTeleported) { ++ if (!from.equals(this.getCraftPlayer().getLocation()) && this.justTeleported) { + this.justTeleported = false; + return; + } + } + } -+ this.player.setLocation(d0, d1, d2, f, f1); // Copied from above ++ this.player.absMoveTo(d0, d1, d2, f, f1); // Copied from above + + // MC-135989, SPIGOT-5564: isRiptiding -+ this.clientIsFloating = d12 >= -0.03125D && this.player.gameMode.getGameMode() != EnumGamemode.SPECTATOR && !this.server.getAllowFlight() && !this.player.getAbilities().mayfly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isGliding() && this.a((Entity) this.player) && !this.player.isRiptiding(); ++ this.clientIsFloating = d12 >= -0.03125D && this.player.gameMode.getGameModeForPlayer() != EnumGamemode.SPECTATOR && !this.server.isFlightAllowed() && !this.player.getAbilities().mayfly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isFallFlying() && this.noBlocksAround(this.player) && !this.player.isAutoSpinAttack(); + // CraftBukkit end - this.player.getWorldServer().getChunkProvider().movePlayer(this.player); - this.player.a(this.player.locY() - d6, packetplayinflying.b()); -- this.player.setOnGround(packetplayinflying.b()); -+ // this.player.setOnGround(packetplayinflying.b()); // CraftBukkit - moved up + this.player.getLevel().getChunkSource().move(this.player); + this.player.doCheckFallDamage(this.player.getY() - d6, packetplayinflying.isOnGround()); +- this.player.setOnGround(packetplayinflying.isOnGround()); ++ // this.player.setOnGround(packetplayinflying.isOnGround()); // CraftBukkit - moved up if (flag) { - this.player.fallDistance = 0.0F; + this.player.resetFallDistance(); } -@@ -967,19 +1280,80 @@ - }); +@@ -973,19 +1286,80 @@ + return true; } + // CraftBukkit start - Delegate to teleport(Location) - public void a(double d0, double d1, double d2, float f, float f1) { -- this.a(d0, d1, d2, f, f1, Collections.emptySet(), true); -+ this.a(d0, d1, d2, f, f1, PlayerTeleportEvent.TeleportCause.UNKNOWN); + public void dismount(double d0, double d1, double d2, float f, float f1) { +- this.teleport(d0, d1, d2, f, f1, Collections.emptySet(), true); ++ this.dismount(d0, d1, d2, f, f1, PlayerTeleportEvent.TeleportCause.UNKNOWN); + } + -+ public void a(double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) { -+ this.a(d0, d1, d2, f, f1, Collections.emptySet(), true, cause); ++ public void dismount(double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) { ++ this.teleport(d0, d1, d2, f, f1, Collections.emptySet(), true, cause); } - public void b(double d0, double d1, double d2, float f, float f1) { -- this.a(d0, d1, d2, f, f1, Collections.emptySet(), false); -+ this.b(d0, d1, d2, f, f1, PlayerTeleportEvent.TeleportCause.UNKNOWN); + public void teleport(double d0, double d1, double d2, float f, float f1) { +- this.teleport(d0, d1, d2, f, f1, Collections.emptySet(), false); ++ this.teleport(d0, d1, d2, f, f1, PlayerTeleportEvent.TeleportCause.UNKNOWN); + } + -+ public void b(double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) { -+ this.a(d0, d1, d2, f, f1, Collections.emptySet(), false, cause); ++ public void teleport(double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) { ++ this.teleport(d0, d1, d2, f, f1, Collections.emptySet(), false, cause); } - public void a(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set) { -- this.a(d0, d1, d2, f, f1, set, false); -+ this.a(d0, d1, d2, f, f1, set, PlayerTeleportEvent.TeleportCause.UNKNOWN); + public void teleport(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set) { +- this.teleport(d0, d1, d2, f, f1, set, false); ++ this.teleport(d0, d1, d2, f, f1, set, PlayerTeleportEvent.TeleportCause.UNKNOWN); } -- public void a(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, boolean flag) { -+ public void a(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, PlayerTeleportEvent.TeleportCause cause) { -+ this.a(d0, d1, d2, f, f1, set, false, cause); +- public void teleport(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, boolean flag) { ++ public void teleport(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, PlayerTeleportEvent.TeleportCause cause) { ++ this.teleport(d0, d1, d2, f, f1, set, false, cause); + } + -+ public boolean a(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, boolean flag, PlayerTeleportEvent.TeleportCause cause) { // CraftBukkit - Return event status -+ Player player = this.getPlayer(); ++ public boolean teleport(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, boolean flag, PlayerTeleportEvent.TeleportCause cause) { // CraftBukkit - Return event status ++ Player player = this.getCraftPlayer(); + Location from = player.getLocation(); + + double x = d0; @@ -624,7 +610,7 @@ + float yaw = f; + float pitch = f1; + -+ Location to = new Location(this.getPlayer().getWorld(), x, y, z, yaw, pitch); ++ Location to = new Location(this.getCraftPlayer().getWorld(), x, y, z, yaw, pitch); + // SPIGOT-5171: Triggered on join + if (from.equals(to)) { + this.internalTeleport(d0, d1, d2, f, f1, set, flag); @@ -663,10 +649,10 @@ + + this.justTeleported = true; + // CraftBukkit end - double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.locX() : 0.0D; - double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.locY() : 0.0D; - double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.locZ() : 0.0D; -@@ -991,6 +1365,14 @@ + double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.getX() : 0.0D; + double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.getY() : 0.0D; + double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.getZ() : 0.0D; +@@ -997,6 +1371,14 @@ this.awaitingTeleport = 0; } @@ -679,42 +665,42 @@ + // CraftBukkit end + this.awaitingTeleportTime = this.tickCount; - this.player.setLocation(d0, d1, d2, f, f1); - this.player.connection.sendPacket(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag)); -@@ -999,6 +1381,7 @@ + this.player.absMoveTo(d0, d1, d2, f, f1); + this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag)); +@@ -1005,6 +1387,7 @@ @Override - public void a(PacketPlayInBlockDig packetplayinblockdig) { - PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.getWorldServer()); -+ if (this.player.isFrozen()) return; // CraftBukkit - BlockPosition blockposition = packetplayinblockdig.b(); + public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) { + PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.getLevel()); ++ if (this.player.isImmobile()) return; // CraftBukkit + BlockPosition blockposition = packetplayinblockdig.getPos(); - this.player.resetIdleTimer(); -@@ -1009,14 +1392,46 @@ + this.player.resetLastActionTime(); +@@ -1015,14 +1398,46 @@ if (!this.player.isSpectator()) { - ItemStack itemstack = this.player.b(EnumHand.OFF_HAND); + ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND); -- this.player.a(EnumHand.OFF_HAND, this.player.b(EnumHand.MAIN_HAND)); -- this.player.a(EnumHand.MAIN_HAND, itemstack); +- this.player.setItemInHand(EnumHand.OFF_HAND, this.player.getItemInHand(EnumHand.MAIN_HAND)); +- this.player.setItemInHand(EnumHand.MAIN_HAND, itemstack); + // CraftBukkit start - inspiration taken from DispenserRegistry (See SpigotCraft#394) + CraftItemStack mainHand = CraftItemStack.asCraftMirror(itemstack); -+ CraftItemStack offHand = CraftItemStack.asCraftMirror(this.player.b(EnumHand.MAIN_HAND)); -+ PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(getPlayer(), mainHand.clone(), offHand.clone()); ++ CraftItemStack offHand = CraftItemStack.asCraftMirror(this.player.getItemInHand(EnumHand.MAIN_HAND)); ++ PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(getCraftPlayer(), mainHand.clone(), offHand.clone()); + this.cserver.getPluginManager().callEvent(swapItemsEvent); + if (swapItemsEvent.isCancelled()) { + return; + } + if (swapItemsEvent.getOffHandItem().equals(offHand)) { -+ this.player.a(EnumHand.OFF_HAND, this.player.b(EnumHand.MAIN_HAND)); ++ this.player.setItemInHand(EnumHand.OFF_HAND, this.player.getItemInHand(EnumHand.MAIN_HAND)); + } else { -+ this.player.a(EnumHand.OFF_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem())); ++ this.player.setItemInHand(EnumHand.OFF_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem())); + } + if (swapItemsEvent.getMainHandItem().equals(mainHand)) { -+ this.player.a(EnumHand.MAIN_HAND, itemstack); ++ this.player.setItemInHand(EnumHand.MAIN_HAND, itemstack); + } else { -+ this.player.a(EnumHand.MAIN_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem())); ++ this.player.setItemInHand(EnumHand.MAIN_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem())); + } + // CraftBukkit end - this.player.clearActiveItem(); + this.player.stopUsingItem(); } return; @@ -729,56 +715,56 @@ + // Else we increment the drop count and check the amount. + this.dropCount++; + if (this.dropCount >= 20) { -+ LOGGER.warn(this.player.getName() + " dropped their items too quickly!"); ++ LOGGER.warn(this.player.getScoreboardName() + " dropped their items too quickly!"); + this.disconnect("You dropped your items too quickly (Hacking?)"); + return; + } + } + // CraftBukkit end - this.player.dropItem(false); + this.player.drop(false); } -@@ -1053,6 +1468,7 @@ +@@ -1059,6 +1474,7 @@ @Override - public void a(PacketPlayInUseItem packetplayinuseitem) { - PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.getWorldServer()); -+ if (this.player.isFrozen()) return; // CraftBukkit - WorldServer worldserver = this.player.getWorldServer(); - EnumHand enumhand = packetplayinuseitem.b(); - ItemStack itemstack = this.player.b(enumhand); -@@ -1065,6 +1481,14 @@ + public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) { + PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.getLevel()); ++ if (this.player.isImmobile()) return; // CraftBukkit + WorldServer worldserver = this.player.getLevel(); + EnumHand enumhand = packetplayinuseitem.getHand(); + ItemStack itemstack = this.player.getItemInHand(enumhand); +@@ -1071,6 +1487,14 @@ if (blockposition.getY() < i) { - if (this.awaitingPositionFromClient == null && this.player.h((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.a((EntityHuman) this.player, blockposition)) { + if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) { + // CraftBukkit start - Check if we can actually do something over this large a distance -+ Location eyeLoc = this.getPlayer().getEyeLocation(); ++ Location eyeLoc = this.getCraftPlayer().getEyeLocation(); + double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ()); -+ if (reachDistance > (this.getPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) { ++ if (reachDistance > (this.getCraftPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) { + return; + } -+ this.player.clearActiveItem(); // SPIGOT-4706 ++ this.player.stopUsingItem(); // SPIGOT-4706 + // CraftBukkit end - EnumInteractionResult enuminteractionresult = this.player.gameMode.a(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); + EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); - if (enumdirection == EnumDirection.UP && !enuminteractionresult.a() && blockposition.getY() >= i - 1 && a(this.player, itemstack)) { -@@ -1088,12 +1512,51 @@ + if (enumdirection == EnumDirection.UP && !enuminteractionresult.consumesAction() && blockposition.getY() >= i - 1 && wasBlockPlacementAttempt(this.player, itemstack)) { +@@ -1094,12 +1518,51 @@ @Override - public void a(PacketPlayInBlockPlace packetplayinblockplace) { - PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.getWorldServer()); -+ if (this.player.isFrozen()) return; // CraftBukkit - WorldServer worldserver = this.player.getWorldServer(); - EnumHand enumhand = packetplayinblockplace.b(); - ItemStack itemstack = this.player.b(enumhand); + public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) { + PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.getLevel()); ++ if (this.player.isImmobile()) return; // CraftBukkit + WorldServer worldserver = this.player.getLevel(); + EnumHand enumhand = packetplayinblockplace.getHand(); + ItemStack itemstack = this.player.getItemInHand(enumhand); - this.player.resetIdleTimer(); + this.player.resetLastActionTime(); if (!itemstack.isEmpty()) { + // CraftBukkit start + // Raytrace to look for 'rogue armswings' + float f1 = this.player.getXRot(); + float f2 = this.player.getYRot(); -+ double d0 = this.player.locX(); -+ double d1 = this.player.locY() + (double) this.player.getHeadHeight(); -+ double d2 = this.player.locZ(); ++ double d0 = this.player.getX(); ++ double d1 = this.player.getY() + (double) this.player.getEyeHeight(); ++ double d2 = this.player.getZ(); + Vec3D vec3d = new Vec3D(d0, d1, d2); + + float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F); @@ -787,9 +773,9 @@ + float f6 = MathHelper.sin(-f1 * 0.017453292F); + float f7 = f4 * f5; + float f8 = f3 * f5; -+ double d3 = player.gameMode.getGameMode()== EnumGamemode.CREATIVE ? 5.0D : 4.5D; ++ double d3 = player.gameMode.getGameModeForPlayer()== EnumGamemode.CREATIVE ? 5.0D : 4.5D; + Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); -+ MovingObjectPosition movingobjectposition = this.player.level.rayTrace(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.OUTLINE, RayTrace.FluidCollisionOption.NONE, player)); ++ MovingObjectPosition movingobjectposition = this.player.level.clip(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.OUTLINE, RayTrace.FluidCollisionOption.NONE, player)); + + boolean cancelled; + if (movingobjectposition == null || movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.BLOCK) { @@ -797,10 +783,10 @@ + cancelled = event.useItemInHand() == Event.Result.DENY; + } else { + MovingObjectPositionBlock movingobjectpositionblock = (MovingObjectPositionBlock) movingobjectposition; -+ if (player.gameMode.firedInteract && player.gameMode.interactPosition.equals(movingobjectpositionblock.getBlockPosition()) && player.gameMode.interactHand == enumhand && ItemStack.equals(player.gameMode.interactItemStack, itemstack)) { ++ if (player.gameMode.firedInteract && player.gameMode.interactPosition.equals(movingobjectpositionblock.getBlockPos()) && player.gameMode.interactHand == enumhand && ItemStack.tagMatches(player.gameMode.interactItemStack, itemstack)) { + cancelled = player.gameMode.interactResult; + } else { -+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPosition(), movingobjectpositionblock.getDirection(), itemstack, true, enumhand); ++ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), itemstack, true, enumhand); + cancelled = event.useItemInHand() == Event.Result.DENY; + } + player.gameMode.firedInteract = false; @@ -810,30 +796,30 @@ + this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524 + return; + } - EnumInteractionResult enuminteractionresult = this.player.gameMode.a(this.player, worldserver, itemstack, enumhand); + EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand); - if (enuminteractionresult.b()) { -@@ -1114,7 +1577,7 @@ - Entity entity = packetplayinspectate.a(worldserver); + if (enuminteractionresult.shouldSwing()) { +@@ -1120,7 +1583,7 @@ + Entity entity = packetplayinspectate.getEntity(worldserver); if (entity != null) { -- this.player.a(worldserver, entity.locX(), entity.locY(), entity.locZ(), entity.getYRot(), entity.getXRot()); -+ this.player.a(worldserver, entity.locX(), entity.locY(), entity.locZ(), entity.getYRot(), entity.getXRot(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit +- this.player.teleportTo(worldserver, entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); ++ this.player.teleportTo(worldserver, entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit return; } } -@@ -1129,6 +1592,7 @@ - PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getDisplayName()); +@@ -1135,6 +1598,7 @@ + PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName()); this.disconnect(new ChatMessage("multiplayer.requiredTexturePrompt.disconnect")); } -+ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.action.ordinal()])); // CraftBukkit ++ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getCraftPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.action.ordinal()])); // CraftBukkit } -@@ -1148,11 +1612,26 @@ +@@ -1154,11 +1618,26 @@ @Override - public void a(IChatBaseComponent ichatbasecomponent) { + public void onDisconnect(IChatBaseComponent ichatbasecomponent) { + // CraftBukkit start - Rarely it would send a disconnect line twice + if (this.processedDisconnect) { + return; @@ -841,92 +827,92 @@ + this.processedDisconnect = true; + } + // CraftBukkit end - PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getDisplayName().getString(), ichatbasecomponent.getString()); + PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), ichatbasecomponent.getString()); + // CraftBukkit start - Replace vanilla quit message handling with our own. + /* - this.server.invalidatePingSample(); - this.server.getPlayerList().sendMessage((new ChatMessage("multiplayer.player.left", new Object[]{this.player.getScoreboardDisplayName()})).a(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID); + this.server.invalidateStatus(); + this.server.getPlayerList().broadcastMessage((new ChatMessage("multiplayer.player.left", new Object[]{this.player.getDisplayName()})).withStyle(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID); + */ + - this.player.p(); -- this.server.getPlayerList().disconnect(this.player); -+ String quitMessage = this.server.getPlayerList().disconnect(this.player); + this.player.disconnect(); +- this.server.getPlayerList().remove(this.player); ++ String quitMessage = this.server.getPlayerList().remove(this.player); + if ((quitMessage != null) && (quitMessage.length() > 0)) { -+ this.server.getPlayerList().sendMessage(CraftChatMessage.fromString(quitMessage)); ++ this.server.getPlayerList().broadcastMessage(CraftChatMessage.fromString(quitMessage)); + } + // CraftBukkit end - this.player.Q().b(); - if (this.isExemptPlayer()) { + this.player.getTextFilter().leave(); + if (this.isSingleplayerOwner()) { PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out"); -@@ -1167,6 +1646,15 @@ +@@ -1173,6 +1652,15 @@ } - public void a(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericfuturelistener) { + public void send(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericfuturelistener) { + // CraftBukkit start + if (packet == null) { + return; + } else if (packet instanceof PacketPlayOutSpawnPosition) { + PacketPlayOutSpawnPosition packet6 = (PacketPlayOutSpawnPosition) packet; -+ this.player.compassTarget = new Location(this.getPlayer().getWorld(), packet6.pos.getX(), packet6.pos.getY(), packet6.pos.getZ()); ++ this.player.compassTarget = new Location(this.getCraftPlayer().getWorld(), packet6.pos.getX(), packet6.pos.getY(), packet6.pos.getZ()); + } + // CraftBukkit end + try { - this.connection.sendPacket(packet, genericfuturelistener); + this.connection.send(packet, genericfuturelistener); } catch (Throwable throwable) { -@@ -1183,7 +1671,16 @@ +@@ -1189,7 +1677,16 @@ @Override - public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) { - PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.getWorldServer()); -+ if (this.player.isFrozen()) return; // CraftBukkit - if (packetplayinhelditemslot.b() >= 0 && packetplayinhelditemslot.b() < PlayerInventory.getHotbarSize()) { -+ PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.getInventory().selected, packetplayinhelditemslot.b()); + public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) { + PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.getLevel()); ++ 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()); + this.cserver.getPluginManager().callEvent(event); + if (event.isCancelled()) { -+ this.sendPacket(new PacketPlayOutHeldItemSlot(this.player.getInventory().selected)); -+ this.player.resetIdleTimer(); ++ this.send(new PacketPlayOutHeldItemSlot(this.player.getInventory().selected)); ++ this.player.resetLastActionTime(); + return; + } + // CraftBukkit end - if (this.player.getInventory().selected != packetplayinhelditemslot.b() && this.player.getRaisedHand() == EnumHand.MAIN_HAND) { - this.player.clearActiveItem(); + if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) { + this.player.stopUsingItem(); } -@@ -1192,11 +1689,18 @@ - this.player.resetIdleTimer(); +@@ -1198,11 +1695,18 @@ + this.player.resetLastActionTime(); } else { - PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getDisplayName().getString()); + PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString()); + this.disconnect("Invalid hotbar selection (Hacking?)"); // CraftBukkit } } @Override - public void a(PacketPlayInChat packetplayinchat) { + public void handleChat(PacketPlayInChat packetplayinchat) { + // CraftBukkit start - async chat + // SPIGOT-3638 + if (this.server.isStopped()) { + return; + } + // CraftBukkit end - String s = StringUtils.normalizeSpace(packetplayinchat.b()); + String s = StringUtils.normalizeSpace(packetplayinchat.getMessage()); for (int i = 0; i < s.length(); ++i) { -@@ -1210,20 +1714,42 @@ - PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.getWorldServer()); - this.a(ITextFilter.a.a(s)); +@@ -1216,20 +1720,42 @@ + PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinchat, this, this.player.getLevel()); + this.handleChat(ITextFilter.a.passThrough(s)); } else { -- this.a(s, this::a); -+ this.a(ITextFilter.a.a(s)); // CraftBukkit - filter NYI +- this.filterTextPacket(s, this::handleChat); ++ this.handleChat(ITextFilter.a.passThrough(s)); // CraftBukkit - filter NYI } } - private void a(ITextFilter.a itextfilter_a) { -- if (this.player.getChatFlags() == EnumChatVisibility.HIDDEN) { -+ if (this.player.isRemoved() || this.player.getChatFlags() == EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales - this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.disabled.options")).a(EnumChatFormat.RED), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID)); + private void handleChat(ITextFilter.a itextfilter_a) { +- if (this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { ++ if (this.player.isRemoved() || this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales + this.send(new PacketPlayOutChat((new ChatMessage("chat.disabled.options")).withStyle(EnumChatFormat.RED), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID)); } else { - this.player.resetIdleTimer(); - String s = itextfilter_a.a(); + this.player.resetLastActionTime(); + String s = itextfilter_a.getRaw(); - if (s.startsWith("/")) { - this.handleCommand(s); @@ -940,33 +926,33 @@ + this.server.server.playerCommandState = false; + } + } else if (s.isEmpty()) { -+ LOGGER.warn(this.player.getName() + " tried to send an empty message"); -+ } else if (getPlayer().isConversing()) { ++ LOGGER.warn(this.player.getScoreboardName() + " tried to send an empty message"); ++ } else if (getCraftPlayer().isConversing()) { + final String conversationInput = s; + this.server.processQueue.add(new Runnable() { + @Override + public void run() { -+ getPlayer().acceptConversationInput(conversationInput); ++ getCraftPlayer().acceptConversationInput(conversationInput); + } + }); -+ } else if (this.player.getChatFlags() == EnumChatVisibility.SYSTEM) { // Re-add "Command Only" flag check -+ this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.cannotSend")).a(EnumChatFormat.RED), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID)); ++ } else if (this.player.getChatVisibility() == EnumChatVisibility.SYSTEM) { // Re-add "Command Only" flag check ++ this.send(new PacketPlayOutChat((new ChatMessage("chat.cannotSend")).withStyle(EnumChatFormat.RED), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID)); + } else if (true) { + this.chat(s, true); + // CraftBukkit end - the below is for reference. :) } else { - String s1 = itextfilter_a.b(); - ChatMessage chatmessage = s1.isEmpty() ? null : new ChatMessage("chat.type.text", new Object[]{this.player.getScoreboardDisplayName(), s1}); -@@ -1234,28 +1760,198 @@ - }, ChatMessageType.CHAT, this.player.getUniqueID()); + String s1 = itextfilter_a.getFiltered(); + ChatMessage chatmessage = s1.isEmpty() ? null : new ChatMessage("chat.type.text", new Object[]{this.player.getDisplayName(), s1}); +@@ -1240,28 +1766,198 @@ + }, ChatMessageType.CHAT, this.player.getUUID()); } - this.chatSpamTickCount += 20; -- if (this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getProfile())) { +- if (this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { - this.disconnect(new ChatMessage("disconnect.spam")); + // CraftBukkit start - replaced with thread safe throttle -+ // this.chatThrottle += 20; -+ if (chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getProfile())) { ++ // this.chatSpamTickCount += 20; ++ if (chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { + if (!isSync) { + Waitable waitable = new Waitable() { + @Override @@ -996,16 +982,16 @@ + // CraftBukkit start - add method + public void chat(String s, boolean async) { -+ if (s.isEmpty() || this.player.getChatFlags() == EnumChatVisibility.HIDDEN) { ++ if (s.isEmpty() || this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { + return; + } + + if (!async && s.startsWith("/")) { + this.handleCommand(s); -+ } else if (this.player.getChatFlags() == EnumChatVisibility.SYSTEM) { ++ } else if (this.player.getChatVisibility() == EnumChatVisibility.SYSTEM) { + // Do nothing, this is coming from a plugin + } else { -+ Player player = this.getPlayer(); ++ Player player = this.getCraftPlayer(); + AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet(server)); + this.cserver.getPluginManager().callEvent(event); + @@ -1026,11 +1012,11 @@ + PlayerConnection.this.server.console.sendMessage(message); + if (((LazyPlayerSet) queueEvent.getRecipients()).isLazy()) { + for (EntityPlayer recipient : server.getPlayerList().players) { -+ recipient.getBukkitEntity().sendMessage(PlayerConnection.this.player.getUniqueID(), message); ++ recipient.getBukkitEntity().sendMessage(PlayerConnection.this.player.getUUID(), message); + } + } else { + for (Player player : queueEvent.getRecipients()) { -+ player.sendMessage(PlayerConnection.this.player.getUniqueID(), message); ++ player.sendMessage(PlayerConnection.this.player.getUUID(), message); + } + } + return null; @@ -1056,11 +1042,11 @@ + server.console.sendMessage(s); + if (((LazyPlayerSet) event.getRecipients()).isLazy()) { + for (EntityPlayer recipient : server.getPlayerList().players) { -+ recipient.getBukkitEntity().sendMessage(PlayerConnection.this.player.getUniqueID(), s); ++ recipient.getBukkitEntity().sendMessage(PlayerConnection.this.player.getUUID(), s); + } + } else { + for (Player recipient : event.getRecipients()) { -+ recipient.sendMessage(PlayerConnection.this.player.getUniqueID(), s); ++ recipient.sendMessage(PlayerConnection.this.player.getUUID(), s); + } + } + } @@ -1069,11 +1055,11 @@ + // CraftBukkit end + private void handleCommand(String s) { -- this.server.getCommandDispatcher().a(this.player.getCommandListener(), s); +- this.server.getCommands().performCommand(this.player.createCommandSourceStack(), s); + // CraftBukkit start - whole method -+ this.LOGGER.info(this.player.getName() + " issued server command: " + s); ++ this.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + s); + -+ CraftPlayer player = this.getPlayer(); ++ CraftPlayer player = this.getCraftPlayer(); + + PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(player, s, new LazyPlayerSet(server)); + this.cserver.getPluginManager().callEvent(event); @@ -1091,21 +1077,21 @@ + java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + return; + } -+ // this.minecraftServer.getCommandDispatcher().a(this.player.getCommandListener(), s); ++ // this.server.getCommands().performCommand(this.player.createCommandSourceStack(), s); + // CraftBukkit end } @Override - public void a(PacketPlayInArmAnimation packetplayinarmanimation) { - PlayerConnectionUtils.ensureMainThread(packetplayinarmanimation, this, this.player.getWorldServer()); -+ if (this.player.isFrozen()) return; // CraftBukkit - this.player.resetIdleTimer(); + public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) { + PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.getLevel()); ++ if (this.player.isImmobile()) return; // CraftBukkit + this.player.resetLastActionTime(); + // CraftBukkit start - Raytrace to look for 'rogue armswings' + float f1 = this.player.getXRot(); + float f2 = this.player.getYRot(); -+ double d0 = this.player.locX(); -+ double d1 = this.player.locY() + (double) this.player.getHeadHeight(); -+ double d2 = this.player.locZ(); ++ double d0 = this.player.getX(); ++ double d1 = this.player.getY() + (double) this.player.getEyeHeight(); ++ double d2 = this.player.getZ(); + Vec3D vec3d = new Vec3D(d0, d1, d2); + + float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F); @@ -1114,32 +1100,32 @@ + float f6 = MathHelper.sin(-f1 * 0.017453292F); + float f7 = f4 * f5; + float f8 = f3 * f5; -+ double d3 = player.gameMode.getGameMode()== EnumGamemode.CREATIVE ? 5.0D : 4.5D; ++ double d3 = player.gameMode.getGameModeForPlayer()== EnumGamemode.CREATIVE ? 5.0D : 4.5D; + Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); -+ MovingObjectPosition movingobjectposition = this.player.level.rayTrace(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.OUTLINE, RayTrace.FluidCollisionOption.NONE, player)); ++ MovingObjectPosition movingobjectposition = this.player.level.clip(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.OUTLINE, RayTrace.FluidCollisionOption.NONE, player)); + + if (movingobjectposition == null || movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.BLOCK) { -+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getItemInHand(), EnumHand.MAIN_HAND); ++ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), EnumHand.MAIN_HAND); + } + + // Arm swing animation -+ PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer()); ++ PlayerAnimationEvent event = new PlayerAnimationEvent(this.getCraftPlayer()); + this.cserver.getPluginManager().callEvent(event); + + if (event.isCancelled()) return; + // CraftBukkit end - this.player.swingHand(packetplayinarmanimation.b()); + this.player.swing(packetplayinarmanimation.getHand()); } @Override - public void a(PacketPlayInEntityAction packetplayinentityaction) { - PlayerConnectionUtils.ensureMainThread(packetplayinentityaction, this, this.player.getWorldServer()); + public void handlePlayerCommand(PacketPlayInEntityAction packetplayinentityaction) { + PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinentityaction, this, this.player.getLevel()); + // CraftBukkit start + if (this.player.isRemoved()) return; -+ switch (packetplayinentityaction.c()) { ++ switch (packetplayinentityaction.getAction()) { + case PRESS_SHIFT_KEY: + case RELEASE_SHIFT_KEY: -+ PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getPlayer(), packetplayinentityaction.c() == PacketPlayInEntityAction.EnumPlayerAction.PRESS_SHIFT_KEY); ++ PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getCraftPlayer(), packetplayinentityaction.getAction() == PacketPlayInEntityAction.EnumPlayerAction.PRESS_SHIFT_KEY); + this.cserver.getPluginManager().callEvent(event); + + if (event.isCancelled()) { @@ -1148,7 +1134,7 @@ + break; + case START_SPRINTING: + case STOP_SPRINTING: -+ PlayerToggleSprintEvent e2 = new PlayerToggleSprintEvent(this.getPlayer(), packetplayinentityaction.c() == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING); ++ PlayerToggleSprintEvent e2 = new PlayerToggleSprintEvent(this.getCraftPlayer(), packetplayinentityaction.getAction() == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING); + this.cserver.getPluginManager().callEvent(e2); + + if (e2.isCancelled()) { @@ -1157,45 +1143,45 @@ + break; + } + // CraftBukkit end - this.player.resetIdleTimer(); + this.player.resetLastActionTime(); IJumpable ijumpable; -@@ -1313,6 +2009,7 @@ +@@ -1319,6 +2015,7 @@ @Override - public void a(PacketPlayInUseEntity packetplayinuseentity) { - PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.getWorldServer()); -+ if (this.player.isFrozen()) return; // CraftBukkit - WorldServer worldserver = this.player.getWorldServer(); - final Entity entity = packetplayinuseentity.a(worldserver); + public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) { + PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.getLevel()); ++ if (this.player.isImmobile()) return; // CraftBukkit + WorldServer worldserver = this.player.getLevel(); + final Entity entity = packetplayinuseentity.getTarget(worldserver); -@@ -1323,10 +2020,44 @@ +@@ -1333,10 +2030,44 @@ - if (this.player.f(entity) < 36.0D) { - packetplayinuseentity.a(new PacketPlayInUseEntity.c() { -- private void a(EnumHand enumhand, PlayerConnection.a playerconnection_a) { -+ private void a(EnumHand enumhand, PlayerConnection.a playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit - ItemStack itemstack = PlayerConnection.this.player.b(enumhand).cloneItemStack(); + if (this.player.distanceToSqr(entity) < 36.0D) { + packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() { +- private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a) { ++ private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit + ItemStack itemstack = PlayerConnection.this.player.getItemInHand(enumhand).copy(); + // CraftBukkit start -+ ItemStack itemInHand = PlayerConnection.this.player.b(enumhand); ++ ItemStack itemInHand = PlayerConnection.this.player.getItemInHand(enumhand); + boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient; -+ Item origItem = player.getInventory().getItemInHand() == null ? null : player.getInventory().getItemInHand().getItem(); ++ Item origItem = player.getInventory().getSelected() == null ? null : player.getInventory().getSelected().getItem(); + + cserver.getPluginManager().callEvent(event); + + // Fish bucket - SPIGOT-4048 -+ if ((entity instanceof EntityFish && origItem != null && origItem.getItem() == Items.WATER_BUCKET) && (event.isCancelled() || player.getInventory().getItemInHand() == null || player.getInventory().getItemInHand().getItem() != origItem)) { -+ sendPacket(new PacketPlayOutSpawnEntityLiving((EntityFish) entity)); -+ player.containerMenu.updateInventory(); ++ if ((entity instanceof EntityFish && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) { ++ send(new PacketPlayOutSpawnEntityLiving((EntityFish) entity)); ++ player.containerMenu.sendAllDataToRemote(); + } + -+ if (triggerLeashUpdate && (event.isCancelled() || player.getInventory().getItemInHand() == null || player.getInventory().getItemInHand().getItem() != origItem)) { ++ if (triggerLeashUpdate && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) { + // Refresh the current leash state -+ sendPacket(new PacketPlayOutAttachEntity(entity, ((EntityInsentient) entity).getLeashHolder())); ++ send(new PacketPlayOutAttachEntity(entity, ((EntityInsentient) entity).getLeashHolder())); + } + -+ if (event.isCancelled() || player.getInventory().getItemInHand() == null || player.getInventory().getItemInHand().getItem() != origItem) { ++ if (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem) { + // Refresh the current entity metadata -+ sendPacket(new PacketPlayOutEntityMetadata(entity.getId(), entity.getDataWatcher(), true)); ++ send(new PacketPlayOutEntityMetadata(entity.getId(), entity.getEntityData(), true)); + } + + if (event.isCancelled()) { @@ -1207,78 +1193,78 @@ + // CraftBukkit start + if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { -+ player.containerMenu.updateInventory(); ++ player.containerMenu.sendAllDataToRemote(); + } + // CraftBukkit end + - if (enuminteractionresult.a()) { - CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.a(PlayerConnection.this.player, itemstack, entity); - if (enuminteractionresult.b()) { -@@ -1338,20 +2069,27 @@ + if (enuminteractionresult.consumesAction()) { + CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack, entity); + if (enuminteractionresult.shouldSwing()) { +@@ -1348,20 +2079,27 @@ @Override - public void a(EnumHand enumhand) { -- this.a(enumhand, EntityHuman::a); -+ this.a(enumhand, EntityHuman::a, new PlayerInteractEntityEvent((Player) getPlayer(), entity.getBukkitEntity(), (enumhand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); + public void onInteraction(EnumHand enumhand) { +- this.performInteraction(enumhand, EntityHuman::interactOn); ++ this.performInteraction(enumhand, EntityHuman::interactOn, new PlayerInteractEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), (enumhand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); } @Override - public void a(EnumHand enumhand, Vec3D vec3d) { - this.a(enumhand, (entityplayer, entity1, enumhand1) -> { - return entity1.a((EntityHuman) entityplayer, vec3d, enumhand1); + public void onInteraction(EnumHand enumhand, Vec3D vec3d) { + this.performInteraction(enumhand, (entityplayer, entity1, enumhand1) -> { + return entity1.interactAt(entityplayer, vec3d, enumhand1); - }); -+ }, new PlayerInteractAtEntityEvent((Player) getPlayer(), entity.getBukkitEntity(), new org.bukkit.util.Vector(vec3d.x, vec3d.y, vec3d.z), (enumhand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); // CraftBukkit ++ }, new PlayerInteractAtEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), new org.bukkit.util.Vector(vec3d.x, vec3d.y, vec3d.z), (enumhand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); // CraftBukkit } @Override - public void a() { + public void onAttack() { - if (!(entity instanceof EntityItem) && !(entity instanceof EntityExperienceOrb) && !(entity instanceof EntityArrow) && entity != PlayerConnection.this.player) { + // CraftBukkit start + if (!(entity instanceof EntityItem) && !(entity instanceof EntityExperienceOrb) && !(entity instanceof EntityArrow) && (entity != PlayerConnection.this.player || player.isSpectator())) { -+ ItemStack itemInHand = PlayerConnection.this.player.getItemInMainHand(); ++ ItemStack itemInHand = PlayerConnection.this.player.getMainHandItem(); PlayerConnection.this.player.attack(entity); + + if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { -+ player.containerMenu.updateInventory(); ++ player.containerMenu.sendAllDataToRemote(); + } + // CraftBukkit end } else { PlayerConnection.this.disconnect(new ChatMessage("multiplayer.disconnect.invalid_entity_attacked")); - PlayerConnection.LOGGER.warn("Player {} tried to attack an invalid entity", PlayerConnection.this.player.getDisplayName().getString()); -@@ -1396,21 +2134,304 @@ + PlayerConnection.LOGGER.warn("Player {} tried to attack an invalid entity", PlayerConnection.this.player.getName().getString()); +@@ -1406,21 +2144,304 @@ @Override - public void a(PacketPlayInCloseWindow packetplayinclosewindow) { - PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer()); + public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) { + PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.getLevel()); + -+ if (this.player.isFrozen()) return; // CraftBukkit ++ if (this.player.isImmobile()) return; // CraftBukkit + CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit + - this.player.o(); + this.player.doCloseContainer(); } @Override - public void a(PacketPlayInWindowClick packetplayinwindowclick) { - PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.getWorldServer()); -+ if (this.player.isFrozen()) return; // CraftBukkit - this.player.resetIdleTimer(); -- if (this.player.containerMenu.containerId == packetplayinwindowclick.b()) { + public void handleContainerClick(PacketPlayInWindowClick packetplayinwindowclick) { + PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinwindowclick, this, this.player.getLevel()); ++ if (this.player.isImmobile()) return; // CraftBukkit + this.player.resetLastActionTime(); +- if (this.player.containerMenu.containerId == packetplayinwindowclick.getContainerId()) { - if (this.player.isSpectator()) { -+ if (this.player.containerMenu.containerId == packetplayinwindowclick.b() && this.player.containerMenu.canUse(this.player)) { // CraftBukkit ++ if (this.player.containerMenu.containerId == packetplayinwindowclick.getContainerId() && 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.updateInventory(); + this.player.containerMenu.sendAllDataToRemote(); } else { - boolean flag = packetplayinwindowclick.h() != this.player.containerMenu.getStateId(); + boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId(); - this.player.containerMenu.h(); -- this.player.containerMenu.a(packetplayinwindowclick.c(), packetplayinwindowclick.d(), packetplayinwindowclick.g(), this.player); + this.player.containerMenu.suppressRemoteUpdates(); +- this.player.containerMenu.clicked(packetplayinwindowclick.getSlotNum(), packetplayinwindowclick.getButtonNum(), packetplayinwindowclick.getClickType(), this.player); + // CraftBukkit start - Call InventoryClickEvent -+ if (packetplayinwindowclick.c() < -1 && packetplayinwindowclick.c() != -999) { ++ if (packetplayinwindowclick.getSlotNum() < -1 && packetplayinwindowclick.getSlotNum() != -999) { + return; + } + + InventoryView inventory = this.player.containerMenu.getBukkitView(); -+ SlotType type = inventory.getSlotType(packetplayinwindowclick.c()); ++ SlotType type = inventory.getSlotType(packetplayinwindowclick.getSlotNum()); + + InventoryClickEvent event; + ClickType click = ClickType.UNKNOWN; @@ -1286,36 +1272,36 @@ + + ItemStack itemstack = ItemStack.EMPTY; + -+ switch (packetplayinwindowclick.g()) { ++ switch (packetplayinwindowclick.getClickType()) { + case PICKUP: -+ if (packetplayinwindowclick.d() == 0) { ++ if (packetplayinwindowclick.getButtonNum() == 0) { + click = ClickType.LEFT; -+ } else if (packetplayinwindowclick.d() == 1) { ++ } else if (packetplayinwindowclick.getButtonNum() == 1) { + click = ClickType.RIGHT; + } -+ if (packetplayinwindowclick.d() == 0 || packetplayinwindowclick.d() == 1) { ++ if (packetplayinwindowclick.getButtonNum() == 0 || packetplayinwindowclick.getButtonNum() == 1) { + action = InventoryAction.NOTHING; // Don't want to repeat ourselves -+ if (packetplayinwindowclick.c() == -999) { ++ if (packetplayinwindowclick.getSlotNum() == -999) { + if (!player.containerMenu.getCarried().isEmpty()) { -+ action = packetplayinwindowclick.d() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR; ++ action = packetplayinwindowclick.getButtonNum() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR; + } -+ } else if (packetplayinwindowclick.c() < 0) { ++ } else if (packetplayinwindowclick.getSlotNum() < 0) { + action = InventoryAction.NOTHING; + } else { -+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.c()); ++ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); + if (slot != null) { + ItemStack clickedItem = slot.getItem(); + ItemStack cursor = player.containerMenu.getCarried(); + if (clickedItem.isEmpty()) { + if (!cursor.isEmpty()) { -+ action = packetplayinwindowclick.d() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE; ++ action = packetplayinwindowclick.getButtonNum() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE; + } -+ } else if (slot.isAllowed(player)) { ++ } else if (slot.mayPickup(player)) { + if (cursor.isEmpty()) { -+ action = packetplayinwindowclick.d() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF; -+ } else if (slot.isAllowed(cursor)) { -+ if (clickedItem.doMaterialsMatch(cursor) && ItemStack.equals(clickedItem, cursor)) { -+ int toPlace = packetplayinwindowclick.d() == 0 ? cursor.getCount() : 1; ++ action = packetplayinwindowclick.getButtonNum() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF; ++ } else if (slot.mayPlace(cursor)) { ++ if (clickedItem.sameItem(cursor) && ItemStack.tagMatches(clickedItem, cursor)) { ++ int toPlace = packetplayinwindowclick.getButtonNum() == 0 ? cursor.getCount() : 1; + toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.getCount()); + toPlace = Math.min(toPlace, slot.container.getMaxStackSize() - clickedItem.getCount()); + if (toPlace == 1) { @@ -1330,7 +1316,7 @@ + } else if (cursor.getCount() <= slot.getMaxStackSize()) { + action = InventoryAction.SWAP_WITH_CURSOR; + } -+ } else if (cursor.getItem() == clickedItem.getItem() && ItemStack.equals(cursor, clickedItem)) { ++ } else if (cursor.getItem() == clickedItem.getItem() && ItemStack.tagMatches(cursor, clickedItem)) { + if (clickedItem.getCount() >= 0) { + if (clickedItem.getCount() + cursor.getCount() <= cursor.getMaxStackSize()) { + // As of 1.5, this is result slots only @@ -1345,17 +1331,17 @@ + break; + // TODO check on updates + case QUICK_MOVE: -+ if (packetplayinwindowclick.d() == 0) { ++ if (packetplayinwindowclick.getButtonNum() == 0) { + click = ClickType.SHIFT_LEFT; -+ } else if (packetplayinwindowclick.d() == 1) { ++ } else if (packetplayinwindowclick.getButtonNum() == 1) { + click = ClickType.SHIFT_RIGHT; + } -+ if (packetplayinwindowclick.d() == 0 || packetplayinwindowclick.d() == 1) { -+ if (packetplayinwindowclick.c() < 0) { ++ if (packetplayinwindowclick.getButtonNum() == 0 || packetplayinwindowclick.getButtonNum() == 1) { ++ if (packetplayinwindowclick.getSlotNum() < 0) { + action = InventoryAction.NOTHING; + } else { -+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.c()); -+ if (slot != null && slot.isAllowed(this.player) && slot.hasItem()) { ++ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); ++ if (slot != null && slot.mayPickup(this.player) && slot.hasItem()) { + action = InventoryAction.MOVE_TO_OTHER_INVENTORY; + } else { + action = InventoryAction.NOTHING; @@ -1364,19 +1350,19 @@ + } + break; + case SWAP: -+ if ((packetplayinwindowclick.d() >= 0 && packetplayinwindowclick.d() < 9) || packetplayinwindowclick.d() == 40) { -+ click = (packetplayinwindowclick.d() == 40) ? ClickType.SWAP_OFFHAND : ClickType.NUMBER_KEY; -+ Slot clickedSlot = this.player.containerMenu.getSlot(packetplayinwindowclick.c()); -+ if (clickedSlot.isAllowed(player)) { -+ ItemStack hotbar = this.player.getInventory().getItem(packetplayinwindowclick.d()); -+ boolean canCleanSwap = hotbar.isEmpty() || (clickedSlot.container == player.getInventory() && clickedSlot.isAllowed(hotbar)); // the slot will accept the hotbar item ++ 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 (clickedSlot.mayPickup(player)) { ++ ItemStack hotbar = this.player.getInventory().getItem(packetplayinwindowclick.getButtonNum()); ++ boolean canCleanSwap = hotbar.isEmpty() || (clickedSlot.container == player.getInventory() && clickedSlot.mayPlace(hotbar)); // the slot will accept the hotbar item + if (clickedSlot.hasItem()) { + if (canCleanSwap) { + action = InventoryAction.HOTBAR_SWAP; + } else { + action = InventoryAction.HOTBAR_MOVE_AND_READD; + } -+ } else if (!clickedSlot.hasItem() && !hotbar.isEmpty() && clickedSlot.isAllowed(hotbar)) { ++ } else if (!clickedSlot.hasItem() && !hotbar.isEmpty() && clickedSlot.mayPlace(hotbar)) { + action = InventoryAction.HOTBAR_SWAP; + } else { + action = InventoryAction.NOTHING; @@ -1387,12 +1373,12 @@ + } + break; + case CLONE: -+ if (packetplayinwindowclick.d() == 2) { ++ if (packetplayinwindowclick.getButtonNum() == 2) { + click = ClickType.MIDDLE; -+ if (packetplayinwindowclick.c() < 0) { ++ if (packetplayinwindowclick.getSlotNum() < 0) { + action = InventoryAction.NOTHING; + } else { -+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.c()); ++ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); + if (slot != null && slot.hasItem() && player.getAbilities().instabuild && player.containerMenu.getCarried().isEmpty()) { + action = InventoryAction.CLONE_STACK; + } else { @@ -1405,19 +1391,19 @@ + } + break; + case THROW: -+ if (packetplayinwindowclick.c() >= 0) { -+ if (packetplayinwindowclick.d() == 0) { ++ if (packetplayinwindowclick.getSlotNum() >= 0) { ++ if (packetplayinwindowclick.getButtonNum() == 0) { + click = ClickType.DROP; -+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.c()); -+ if (slot != null && slot.hasItem() && slot.isAllowed(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) { ++ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); ++ 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.d() == 1) { ++ } else if (packetplayinwindowclick.getButtonNum() == 1) { + click = ClickType.CONTROL_DROP; -+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.c()); -+ if (slot != null && slot.hasItem() && slot.isAllowed(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) { ++ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); ++ if (slot != null && slot.hasItem() && slot.mayPickup(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.byBlock(Blocks.AIR)) { + action = InventoryAction.DROP_ALL_SLOT; + } else { + action = InventoryAction.NOTHING; @@ -1426,19 +1412,19 @@ + } else { + // Sane default (because this happens when they are holding nothing. Don't ask why.) + click = ClickType.LEFT; -+ if (packetplayinwindowclick.d() == 1) { ++ if (packetplayinwindowclick.getButtonNum() == 1) { + click = ClickType.RIGHT; + } + action = InventoryAction.NOTHING; + } + break; + case QUICK_CRAFT: -+ this.player.containerMenu.a(packetplayinwindowclick.c(), packetplayinwindowclick.d(), packetplayinwindowclick.g(), this.player); ++ this.player.containerMenu.clicked(packetplayinwindowclick.getSlotNum(), packetplayinwindowclick.getButtonNum(), packetplayinwindowclick.getClickType(), this.player); + break; + case PICKUP_ALL: + click = ClickType.DOUBLE_CLICK; + action = InventoryAction.NOTHING; -+ if (packetplayinwindowclick.c() >= 0 && !this.player.containerMenu.getCarried().isEmpty()) { ++ if (packetplayinwindowclick.getSlotNum() >= 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 @@ -1451,32 +1437,32 @@ + break; + } + -+ if (packetplayinwindowclick.g() != InventoryClickType.QUICK_CRAFT) { ++ if (packetplayinwindowclick.getClickType() != InventoryClickType.QUICK_CRAFT) { + if (click == ClickType.NUMBER_KEY) { -+ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.c(), click, action, packetplayinwindowclick.d()); ++ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action, packetplayinwindowclick.getButtonNum()); + } else { -+ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.c(), click, action); ++ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action); + } + + org.bukkit.inventory.Inventory top = inventory.getTopInventory(); -+ if (packetplayinwindowclick.c() == 0 && top instanceof CraftingInventory) { ++ if (packetplayinwindowclick.getSlotNum() == 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.c(), click, action, packetplayinwindowclick.d()); ++ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.getSlotNum(), click, action, packetplayinwindowclick.getButtonNum()); + } else { -+ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.c(), click, action); ++ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.getSlotNum(), click, action); + } + } + } + -+ if (packetplayinwindowclick.c() == 2 && top instanceof SmithingInventory) { ++ if (packetplayinwindowclick.getSlotNum() == 2 && 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.c(), click, action, packetplayinwindowclick.d()); ++ event = new SmithItemEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action, packetplayinwindowclick.getButtonNum()); + } else { -+ event = new SmithItemEvent(inventory, type, packetplayinwindowclick.c(), click, action); ++ event = new SmithItemEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action); + } + } + } @@ -1491,7 +1477,7 @@ + switch (event.getResult()) { + case ALLOW: + case DEFAULT: -+ this.player.containerMenu.a(packetplayinwindowclick.c(), packetplayinwindowclick.d(), packetplayinwindowclick.g(), this.player); ++ this.player.containerMenu.clicked(packetplayinwindowclick.getSlotNum(), packetplayinwindowclick.getButtonNum(), packetplayinwindowclick.getClickType(), this.player); + break; + case DENY: + /* Needs enum constructor in InventoryAction @@ -1513,7 +1499,7 @@ + case HOTBAR_SWAP: + case COLLECT_TO_CURSOR: + case UNKNOWN: -+ this.player.containerMenu.updateInventory(); ++ this.player.containerMenu.sendAllDataToRemote(); + break; + // Modified cursor and clicked + case PICKUP_SOME: @@ -1523,19 +1509,19 @@ + case PLACE_SOME: + case PLACE_ONE: + case SWAP_WITH_CURSOR: -+ this.player.connection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.player.inventoryMenu.incrementStateId(), this.player.containerMenu.getCarried())); -+ this.player.connection.sendPacket(new PacketPlayOutSetSlot(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), packetplayinwindowclick.c(), this.player.containerMenu.getSlot(packetplayinwindowclick.c()).getItem())); ++ 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())); + break; + // Modified clicked only + case DROP_ALL_SLOT: + case DROP_ONE_SLOT: -+ this.player.connection.sendPacket(new PacketPlayOutSetSlot(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), packetplayinwindowclick.c(), this.player.containerMenu.getSlot(packetplayinwindowclick.c()).getItem())); ++ this.player.connection.send(new PacketPlayOutSetSlot(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), packetplayinwindowclick.getSlotNum(), this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()).getItem())); + break; + // Modified cursor only + case DROP_ALL_CURSOR: + case DROP_ONE_CURSOR: + case CLONE_STACK: -+ this.player.connection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.player.inventoryMenu.incrementStateId(), this.player.containerMenu.getCarried())); ++ this.player.connection.send(new PacketPlayOutSetSlot(-1, -1, this.player.inventoryMenu.incrementStateId(), this.player.containerMenu.getCarried())); + break; + // Nothing + case NOTHING: @@ -1546,41 +1532,41 @@ + if (event instanceof CraftItemEvent || event instanceof SmithItemEvent) { + // Need to update the inventory on crafting to + // correctly support custom recipes -+ player.containerMenu.updateInventory(); ++ player.containerMenu.sendAllDataToRemote(); + } + } + // CraftBukkit end - ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.f()).iterator(); + ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator(); while (objectiterator.hasNext()) { -@@ -1445,6 +2466,7 @@ +@@ -1455,6 +2476,7 @@ @Override - public void a(PacketPlayInEnchantItem packetplayinenchantitem) { - PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.getWorldServer()); -+ if (this.player.isFrozen()) return; // CraftBukkit - this.player.resetIdleTimer(); - if (this.player.containerMenu.containerId == packetplayinenchantitem.b() && !this.player.isSpectator()) { - this.player.containerMenu.a((EntityHuman) this.player, packetplayinenchantitem.c()); -@@ -1477,6 +2499,43 @@ + public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) { + PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.getLevel()); ++ if (this.player.isImmobile()) return; // CraftBukkit + this.player.resetLastActionTime(); + if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) { + this.player.containerMenu.clickMenuButton(this.player, packetplayinenchantitem.getButtonId()); +@@ -1482,6 +2504,43 @@ - boolean flag1 = packetplayinsetcreativeslot.b() >= 1 && packetplayinsetcreativeslot.b() <= 45; - boolean flag2 = itemstack.isEmpty() || itemstack.getDamage() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); -+ if (flag || (flag1 && !ItemStack.matches(this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.b()).getItem(), packetplayinsetcreativeslot.getItemStack()))) { // Insist on valid slot + boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45; + boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); ++ if (flag || (flag1 && !ItemStack.matches(this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).getItem(), packetplayinsetcreativeslot.getItem()))) { // Insist on valid slot + // CraftBukkit start - Call click event + InventoryView inventory = this.player.inventoryMenu.getBukkitView(); -+ org.bukkit.inventory.ItemStack item = CraftItemStack.asBukkitCopy(packetplayinsetcreativeslot.getItemStack()); ++ org.bukkit.inventory.ItemStack item = CraftItemStack.asBukkitCopy(packetplayinsetcreativeslot.getItem()); + + SlotType type = SlotType.QUICKBAR; + if (flag) { + type = SlotType.OUTSIDE; -+ } else if (packetplayinsetcreativeslot.b() < 36) { -+ if (packetplayinsetcreativeslot.b() >= 5 && packetplayinsetcreativeslot.b() < 9) { ++ } else if (packetplayinsetcreativeslot.getSlotNum() < 36) { ++ if (packetplayinsetcreativeslot.getSlotNum() >= 5 && packetplayinsetcreativeslot.getSlotNum() < 9) { + type = SlotType.ARMOR; + } else { + type = SlotType.CONTAINER; + } + } -+ InventoryCreativeEvent event = new InventoryCreativeEvent(inventory, type, flag ? -999 : packetplayinsetcreativeslot.b(), item); ++ InventoryCreativeEvent event = new InventoryCreativeEvent(inventory, type, flag ? -999 : packetplayinsetcreativeslot.getSlotNum(), item); + cserver.getPluginManager().callEvent(event); + + itemstack = CraftItemStack.asNMSCopy(event.getCursor()); @@ -1594,9 +1580,9 @@ + break; + case DENY: + // Reset the slot -+ if (packetplayinsetcreativeslot.b() >= 0) { -+ this.player.connection.sendPacket(new PacketPlayOutSetSlot(this.player.inventoryMenu.containerId, this.player.inventoryMenu.incrementStateId(), packetplayinsetcreativeslot.b(), this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.b()).getItem())); -+ this.player.connection.sendPacket(new PacketPlayOutSetSlot(-1, this.player.inventoryMenu.incrementStateId(), -1, ItemStack.EMPTY)); ++ if (packetplayinsetcreativeslot.getSlotNum() >= 0) { ++ this.player.connection.send(new PacketPlayOutSetSlot(this.player.inventoryMenu.containerId, this.player.inventoryMenu.incrementStateId(), packetplayinsetcreativeslot.getSlotNum(), this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).getItem())); ++ this.player.connection.send(new PacketPlayOutSetSlot(-1, this.player.inventoryMenu.incrementStateId(), -1, ItemStack.EMPTY)); + } + return; + } @@ -1604,39 +1590,39 @@ + // CraftBukkit end if (flag1 && flag2) { - this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.b()).set(itemstack); -@@ -1499,6 +2558,7 @@ + this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).set(itemstack); +@@ -1504,6 +2563,7 @@ } - private void a(PacketPlayInUpdateSign packetplayinupdatesign, List<ITextFilter.a> list) { -+ if (this.player.isFrozen()) return; // CraftBukkit - this.player.resetIdleTimer(); - WorldServer worldserver = this.player.getWorldServer(); - BlockPosition blockposition = packetplayinupdatesign.b(); -@@ -1515,18 +2575,37 @@ + private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<ITextFilter.a> list) { ++ if (this.player.isImmobile()) return; // CraftBukkit + this.player.resetLastActionTime(); + WorldServer worldserver = this.player.getLevel(); + BlockPosition blockposition = packetplayinupdatesign.getPos(); +@@ -1520,18 +2580,37 @@ - if (!tileentitysign.d() || !this.player.getUniqueID().equals(tileentitysign.f())) { - PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getDisplayName().getString()); -+ this.sendPacket(tileentity.getUpdatePacket()); // CraftBukkit + if (!tileentitysign.isEditable() || !this.player.getUUID().equals(tileentitysign.getPlayerWhoMayEdit())) { + PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getName().getString()); ++ this.send(tileentity.getUpdatePacket()); // CraftBukkit return; } + // CraftBukkit start + Player player = this.player.getBukkitEntity(); -+ int x = packetplayinupdatesign.b().getX(); -+ int y = packetplayinupdatesign.b().getY(); -+ int z = packetplayinupdatesign.b().getZ(); ++ int x = packetplayinupdatesign.getPos().getX(); ++ int y = packetplayinupdatesign.getPos().getY(); ++ int z = packetplayinupdatesign.getPos().getZ(); + String[] lines = new String[4]; + for (int i = 0; i < list.size(); ++i) { ITextFilter.a itextfilter_a = (ITextFilter.a) list.get(i); - if (this.player.R()) { -- tileentitysign.a(i, new ChatComponentText(itextfilter_a.b())); -+ lines[i] = EnumChatFormat.a(new ChatComponentText(EnumChatFormat.a(itextfilter_a.b())).getString()); + if (this.player.isTextFilteringEnabled()) { +- tileentitysign.setMessage(i, new ChatComponentText(itextfilter_a.getFiltered())); ++ lines[i] = EnumChatFormat.stripFormatting(new ChatComponentText(EnumChatFormat.stripFormatting(itextfilter_a.getFiltered())).getString()); } else { -- tileentitysign.a(i, new ChatComponentText(itextfilter_a.a()), new ChatComponentText(itextfilter_a.b())); -+ lines[i] = EnumChatFormat.a(new ChatComponentText(EnumChatFormat.a(itextfilter_a.a())).getString()); +- tileentitysign.setMessage(i, new ChatComponentText(itextfilter_a.getRaw()), new ChatComponentText(itextfilter_a.getFiltered())); ++ lines[i] = EnumChatFormat.stripFormatting(new ChatComponentText(EnumChatFormat.stripFormatting(itextfilter_a.getRaw())).getString()); + } + } + SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.player.getBukkitEntity(), lines); @@ -1645,26 +1631,26 @@ + if (!event.isCancelled()) { + IChatBaseComponent[] components = org.bukkit.craftbukkit.block.CraftSign.sanitizeLines(event.getLines()); + for (int i = 0; i < components.length; i++) { -+ tileentitysign.a(i, components[i]); ++ tileentitysign.setMessage(i, components[i]); } + tileentitysign.isEditable = false; } + // CraftBukkit end - tileentitysign.update(); - worldserver.notify(blockposition, iblockdata, iblockdata, 3); -@@ -1536,6 +2615,7 @@ + tileentitysign.setChanged(); + worldserver.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3); +@@ -1541,6 +2620,7 @@ @Override - public void a(PacketPlayInKeepAlive packetplayinkeepalive) { -+ PlayerConnectionUtils.ensureMainThread(packetplayinkeepalive, this, this.player.getWorldServer()); // CraftBukkit - if (this.keepAlivePending && packetplayinkeepalive.b() == this.keepAliveChallenge) { - int i = (int) (SystemUtils.getMonotonicMillis() - this.keepAliveTime); + public void handleKeepAlive(PacketPlayInKeepAlive packetplayinkeepalive) { ++ PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinkeepalive, this, this.player.getLevel()); // CraftBukkit + if (this.keepAlivePending && packetplayinkeepalive.getId() == this.keepAliveChallenge) { + int i = (int) (SystemUtils.getMillis() - this.keepAliveTime); -@@ -1550,7 +2630,17 @@ +@@ -1555,7 +2635,17 @@ @Override - public void a(PacketPlayInAbilities packetplayinabilities) { - PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer()); + public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) { + PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.getLevel()); - this.player.getAbilities().flying = packetplayinabilities.isFlying() && this.player.getAbilities().mayfly; + // CraftBukkit start + if (this.player.getAbilities().mayfly && this.player.getAbilities().flying != packetplayinabilities.isFlying()) { @@ -1673,31 +1659,31 @@ + if (!event.isCancelled()) { + this.player.getAbilities().flying = packetplayinabilities.isFlying(); // Actually set the player's flying status + } else { -+ this.player.updateAbilities(); // Tell the player their ability was reverted ++ this.player.onUpdateAbilities(); // Tell the player their ability was reverted + } + } + // CraftBukkit end } @Override -@@ -1559,8 +2649,50 @@ - this.player.a(packetplayinsettings); +@@ -1564,8 +2654,50 @@ + this.player.updateOptions(packetplayinsettings); } - @Override -- public void a(PacketPlayInCustomPayload packetplayincustompayload) {} +- public void handleCustomPayload(PacketPlayInCustomPayload packetplayincustompayload) {} + // CraftBukkit start + private static final MinecraftKey CUSTOM_REGISTER = new MinecraftKey("register"); + private static final MinecraftKey CUSTOM_UNREGISTER = new MinecraftKey("unregister"); + + @Override -+ public void a(PacketPlayInCustomPayload packetplayincustompayload) { -+ PlayerConnectionUtils.ensureMainThread(packetplayincustompayload, this, this.player.getWorldServer()); ++ public void handleCustomPayload(PacketPlayInCustomPayload packetplayincustompayload) { ++ PlayerConnectionUtils.ensureRunningOnSameThread(packetplayincustompayload, this, this.player.getLevel()); + if (packetplayincustompayload.identifier.equals(CUSTOM_REGISTER)) { + try { + String channels = packetplayincustompayload.data.toString(com.google.common.base.Charsets.UTF_8); + for (String channel : channels.split("\0")) { -+ getPlayer().addChannel(channel); ++ getCraftPlayer().addChannel(channel); + } + } catch (Exception ex) { + PlayerConnection.LOGGER.error("Couldn\'t register custom payload", ex); @@ -1707,7 +1693,7 @@ + try { + String channels = packetplayincustompayload.data.toString(com.google.common.base.Charsets.UTF_8); + for (String channel : channels.split("\0")) { -+ getPlayer().removeChannel(channel); ++ getCraftPlayer().removeChannel(channel); + } + } catch (Exception ex) { + PlayerConnection.LOGGER.error("Couldn\'t unregister custom payload", ex); @@ -1732,4 +1718,4 @@ + // CraftBukkit end @Override - public void a(PacketPlayInDifficultyChange packetplayindifficultychange) { + public void handleChangeDifficulty(PacketPlayInDifficultyChange packetplayindifficultychange) { diff --git a/paper-server/nms-patches/net/minecraft/server/network/ServerConnection.patch b/paper-server/nms-patches/net/minecraft/server/network/ServerConnection.patch index 6e7aa6b81d..7e3db6ee4d 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/ServerConnection.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/ServerConnection.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/server/network/ServerConnection.java +++ b/net/minecraft/server/network/ServerConnection.java @@ -96,14 +96,24 @@ - int j = ServerConnection.this.server.l(); + int j = ServerConnection.this.server.getRateLimitPacketsPerSecond(); Object object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND); - ServerConnection.this.connections.add(object); + ServerConnection.this.connections.add((NetworkManager) object); // CraftBukkit - decompile error channel.pipeline().addLast("packet_handler", (ChannelHandler) object); - ((NetworkManager) object).setPacketListener(new HandshakeListener(ServerConnection.this.server, (NetworkManager) object)); + ((NetworkManager) object).setListener(new HandshakeListener(ServerConnection.this.server, (NetworkManager) object)); } -- }).group((EventLoopGroup) lazyinitvar.a()).localAddress(inetaddress, i)).bind().syncUninterruptibly()); -+ }).group((EventLoopGroup) lazyinitvar.a()).localAddress(inetaddress, i)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit +- }).group((EventLoopGroup) lazyinitvar.get()).localAddress(inetaddress, i)).bind().syncUninterruptibly()); ++ }).group((EventLoopGroup) lazyinitvar.get()).localAddress(inetaddress, i)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit } } @@ -24,6 +24,6 @@ + } + // CraftBukkit end + - public SocketAddress a() { + public SocketAddress startMemoryChannel() { List list = this.channels; ChannelFuture channelfuture; diff --git a/paper-server/nms-patches/net/minecraft/server/players/ExpirableListEntry.patch b/paper-server/nms-patches/net/minecraft/server/players/ExpirableListEntry.patch index 85fbf3f9b8..b31c488e7d 100644 --- a/paper-server/nms-patches/net/minecraft/server/players/ExpirableListEntry.patch +++ b/paper-server/nms-patches/net/minecraft/server/players/ExpirableListEntry.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/players/ExpirableListEntry.java +++ b/net/minecraft/server/players/ExpirableListEntry.java -@@ -25,7 +25,7 @@ +@@ -26,7 +26,7 @@ } protected ExpirableListEntry(T t0, JsonObject jsonobject) { - super(t0); -+ super(checkExpiry(t0, jsonobject)); ++ super(checkExpiry(t0, jsonobject)); // CraftBukkit Date date; -@@ -80,4 +80,22 @@ +@@ -82,4 +82,22 @@ jsonobject.addProperty("expires", this.expires == null ? "forever" : ExpirableListEntry.DATE_FORMAT.format(this.expires)); jsonobject.addProperty("reason", this.reason); } diff --git a/paper-server/nms-patches/net/minecraft/server/players/JsonList.patch b/paper-server/nms-patches/net/minecraft/server/players/JsonList.patch index c8a7aef408..12737531a2 100644 --- a/paper-server/nms-patches/net/minecraft/server/players/JsonList.patch +++ b/paper-server/nms-patches/net/minecraft/server/players/JsonList.patch @@ -3,9 +3,9 @@ @@ -54,7 +54,7 @@ @Nullable public V get(K k0) { - this.g(); -- return (JsonListEntry) this.map.get(this.a(k0)); -+ return (V) this.map.get(this.a(k0)); // CraftBukkit - fix decompile error + this.removeExpired(); +- return (JsonListEntry) this.map.get(this.getKeyForUser(k0)); ++ return (V) this.map.get(this.getKeyForUser(k0)); // CraftBukkit - fix decompile error } public void remove(K k0) { @@ -30,7 +30,7 @@ + V v0 = (V) iterator.next(); // CraftBukkit - decompile error if (v0.hasExpired()) { - list.add(v0.getKey()); + list.add(v0.getUser()); @@ -103,7 +109,7 @@ iterator = list.iterator(); @@ -38,9 +38,9 @@ - K k0 = iterator.next(); + K k0 = (K) iterator.next(); // CraftBukkit - decompile error - this.map.remove(this.a(k0)); + this.map.remove(this.getKeyForUser(k0)); } -@@ -118,11 +124,11 @@ +@@ -118,7 +124,7 @@ public void save() throws IOException { JsonArray jsonarray = new JsonArray(); @@ -49,17 +49,12 @@ JsonObject jsonobject = new JsonObject(); Objects.requireNonNull(jsonlistentry); -- return (JsonObject) SystemUtils.a((Object) jsonobject, jsonlistentry::a); -+ return (JsonObject) SystemUtils.a(jsonobject, jsonlistentry::a); // CraftBukkit - decompile error - }); - - Objects.requireNonNull(jsonarray); @@ -165,7 +171,7 @@ - JsonListEntry<K> jsonlistentry = this.a(jsonobject); + JsonListEntry<K> jsonlistentry = this.createEntry(jsonobject); - if (jsonlistentry.getKey() != null) { -- this.map.put(this.a(jsonlistentry.getKey()), jsonlistentry); -+ this.map.put(this.a(jsonlistentry.getKey()), (V) jsonlistentry); // CraftBukkit - fix 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/paper-server/nms-patches/net/minecraft/server/players/NameReferencingFileConverter.patch b/paper-server/nms-patches/net/minecraft/server/players/NameReferencingFileConverter.patch index 6e385decf1..1aa20d26bb 100644 --- a/paper-server/nms-patches/net/minecraft/server/players/NameReferencingFileConverter.patch +++ b/paper-server/nms-patches/net/minecraft/server/players/NameReferencingFileConverter.patch @@ -16,8 +16,8 @@ try { gameprofilebanlist.load(); } catch (IOException ioexception) { -- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.b().getName(), ioexception); -+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.b().getName()); // CraftBukkit - don't print stacktrace +- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.getFile().getName(), ioexception); ++ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.getFile().getName()); // CraftBukkit - don't print stacktrace } } @@ -25,8 +25,8 @@ try { ipbanlist.load(); } catch (IOException ioexception) { -- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.b().getName(), ioexception); -+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.b().getName()); // CraftBukkit - don't print stacktrace +- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.getFile().getName(), ioexception); ++ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.getFile().getName()); // CraftBukkit - don't print stacktrace } } @@ -34,8 +34,8 @@ try { oplist.load(); } catch (IOException ioexception) { -- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.b().getName(), ioexception); -+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.b().getName()); // CraftBukkit - don't print stacktrace +- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.getFile().getName(), ioexception); ++ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.getFile().getName()); // CraftBukkit - don't print stacktrace } } @@ -43,8 +43,8 @@ try { whitelist.load(); } catch (IOException ioexception) { -- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.b().getName(), ioexception); -+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.b().getName()); // CraftBukkit - don't print stacktrace +- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.getFile().getName(), ioexception); ++ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.getFile().getName()); // CraftBukkit - don't print stacktrace } } @@ -56,26 +56,26 @@ + NBTTagCompound root = null; + + try { -+ root = NBTCompressedStreamTools.a(new java.io.FileInputStream(file5)); ++ root = NBTCompressedStreamTools.readCompressed(new java.io.FileInputStream(file5)); + } catch (Exception exception) { + exception.printStackTrace(); + } + + if (root != null) { -+ if (!root.hasKey("bukkit")) { -+ root.set("bukkit", new NBTTagCompound()); ++ if (!root.contains("bukkit")) { ++ root.put("bukkit", new NBTTagCompound()); + } + NBTTagCompound data = root.getCompound("bukkit"); -+ data.setString("lastKnownName", s2); ++ data.putString("lastKnownName", s2); + + try { -+ NBTCompressedStreamTools.a(root, new java.io.FileOutputStream(file2)); ++ NBTCompressedStreamTools.writeCompressed(root, new java.io.FileOutputStream(file2)); + } catch (Exception exception) { + exception.printStackTrace(); + } + } + // CraftBukkit end + - NameReferencingFileConverter.a(file4); + NameReferencingFileConverter.ensureDirectoryExists(file4); if (!file5.renameTo(file6)) { throw new NameReferencingFileConverter.FileConversionException("Could not convert file for " + s2); diff --git a/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch b/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch index d40808cd98..05287b1b94 100644 --- a/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch +++ b/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch @@ -47,7 +47,7 @@ public final WorldNBTStorage playerIo; private boolean doWhiteList; private final IRegistryCustom.Dimension registryHolder; -@@ -122,13 +144,23 @@ +@@ -123,13 +145,23 @@ private static final boolean ALLOW_LOGOUTIVATOR = false; private int sendAllPlayerInfoIn; @@ -73,51 +73,51 @@ this.server = minecraftserver; this.registryHolder = iregistrycustom_dimension; this.maxPlayers = i; -@@ -144,6 +176,12 @@ - usercache.a(gameprofile); - NBTTagCompound nbttagcompound = this.a(entityplayer); +@@ -145,6 +177,12 @@ + usercache.add(gameprofile); + NBTTagCompound nbttagcompound = this.load(entityplayer); ResourceKey resourcekey; + // CraftBukkit start - Better rename detection -+ if (nbttagcompound != null && nbttagcompound.hasKey("bukkit")) { ++ if (nbttagcompound != null && nbttagcompound.contains("bukkit")) { + NBTTagCompound bukkit = nbttagcompound.getCompound("bukkit"); -+ s = bukkit.hasKeyOfType("lastKnownName", 8) ? bukkit.getString("lastKnownName") : s; ++ s = bukkit.contains("lastKnownName", 8) ? bukkit.getString("lastKnownName") : s; + } + // CraftBukkit end if (nbttagcompound != null) { - DataResult dataresult = DimensionManager.a(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("Dimension"))); -@@ -173,7 +211,8 @@ - s1 = networkmanager.getSocketAddress().toString(); + DataResult dataresult = DimensionManager.parseLegacy(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("Dimension"))); +@@ -174,7 +212,8 @@ + s1 = networkmanager.getRemoteAddress().toString(); } -- PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ()); +- PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getName().getString(), s1, entityplayer.getId(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ()); + // CraftBukkit - Moved message to after join -+ // PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ()); - WorldData worlddata = worldserver1.getWorldData(); ++ // PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getName().getString(), s1, entityplayer.getId(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ()); + WorldData worlddata = worldserver1.getLevelData(); - entityplayer.c(nbttagcompound); -@@ -183,6 +222,7 @@ + entityplayer.loadGameTypes(nbttagcompound); +@@ -184,6 +223,7 @@ boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO); - playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.gameMode.getGameMode(), entityplayer.gameMode.c(), BiomeManager.a(worldserver1.getSeed()), worlddata.isHardcore(), this.server.F(), this.registryHolder, worldserver1.getDimensionManager(), worldserver1.getDimensionKey(), this.getMaxPlayers(), this.viewDistance, flag1, !flag, worldserver1.isDebugWorld(), worldserver1.isFlatWorld())); + playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), entityplayer.gameMode.getGameModeForPlayer(), entityplayer.gameMode.getPreviousGameModeForPlayer(), this.server.levelKeys(), this.registryHolder, worldserver1.dimensionType(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, worldserver1.isDebug(), worldserver1.isFlat())); + entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit - playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.BRAND, (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName()))); - playerconnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); - playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.getAbilities())); -@@ -201,19 +241,66 @@ + playerconnection.send(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.BRAND, (new PacketDataSerializer(Unpooled.buffer())).writeUtf(this.getServer().getServerModName()))); + playerconnection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); + playerconnection.send(new PacketPlayOutAbilities(entityplayer.getAbilities())); +@@ -202,19 +242,66 @@ } else { - chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[]{entityplayer.getScoreboardDisplayName(), s}); + chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[]{entityplayer.getDisplayName(), s}); } + // CraftBukkit start -+ chatmessage.a(EnumChatFormat.YELLOW); ++ chatmessage.withStyle(EnumChatFormat.YELLOW); + String joinMessage = CraftChatMessage.fromComponent(chatmessage); -- this.sendMessage(chatmessage.a(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID); - playerconnection.b(entityplayer.locX(), entityplayer.locY(), entityplayer.locZ(), entityplayer.getYRot(), entityplayer.getXRot()); +- this.broadcastMessage(chatmessage.withStyle(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID); + playerconnection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot()); this.players.add(entityplayer); - this.playersByUUID.put(entityplayer.getUniqueID(), entityplayer); -- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer})); -+ // this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer})); // CraftBukkit - replaced with loop below + this.playersByUUID.put(entityplayer.getUUID(), entityplayer); +- this.broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer})); ++ // this.broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer})); // CraftBukkit - replaced with loop below + + // CraftBukkit start + CraftPlayer bukkitPlayer = entityplayer.getBukkitEntity(); @@ -136,7 +136,7 @@ + + if (joinMessage != null && joinMessage.length() > 0) { + for (IChatBaseComponent line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) { -+ server.getPlayerList().sendAll(new PacketPlayOutChat(line, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID)); ++ server.getPlayerList().broadcastAll(new PacketPlayOutChat(line, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID)); + } + } + // CraftBukkit end @@ -145,142 +145,142 @@ + PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entityplayer); for (int i = 0; i < this.players.size(); ++i) { -- entityplayer.connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{(EntityPlayer) this.players.get(i)})); +- entityplayer.connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{(EntityPlayer) this.players.get(i)})); + EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i); + + if (entityplayer1.getBukkitEntity().canSee(bukkitPlayer)) { -+ entityplayer1.connection.sendPacket(packet); ++ entityplayer1.connection.send(packet); + } + + if (!bukkitPlayer.canSee(entityplayer1.getBukkitEntity())) { + continue; + } + -+ entityplayer.connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer1})); ++ entityplayer.connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer1})); } + entityplayer.sentListPacket = true; + // CraftBukkit end -- worldserver1.addPlayerJoin(entityplayer); -- this.server.getBossBattleCustomData().a(entityplayer); -+ entityplayer.connection.sendPacket(new PacketPlayOutEntityMetadata(entityplayer.getId(), entityplayer.getDataWatcher(), true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn +- worldserver1.addNewPlayer(entityplayer); +- this.server.getCustomBossEvents().onPlayerConnect(entityplayer); ++ entityplayer.connection.send(new PacketPlayOutEntityMetadata(entityplayer.getId(), entityplayer.getEntityData(), true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn + + // CraftBukkit start - Only add if the player wasn't moved in the event -+ if (entityplayer.level == worldserver1 && !worldserver1.getPlayers().contains(entityplayer)) { -+ worldserver1.addPlayerJoin(entityplayer); -+ this.server.getBossBattleCustomData().a(entityplayer); ++ if (entityplayer.level == worldserver1 && !worldserver1.players().contains(entityplayer)) { ++ worldserver1.addNewPlayer(entityplayer); ++ this.server.getCustomBossEvents().onPlayerConnect(entityplayer); + } + -+ worldserver1 = entityplayer.getWorldServer(); // CraftBukkit - Update in case join event changed it ++ worldserver1 = entityplayer.getLevel(); // CraftBukkit - Update in case join event changed it + // CraftBukkit end - this.a(entityplayer, worldserver1); + this.sendLevelInfo(entityplayer, worldserver1); if (!this.server.getResourcePack().isEmpty()) { - entityplayer.setResourcePack(this.server.getResourcePack(), this.server.getResourcePackHash(), this.server.aX(), this.server.ba()); -@@ -229,8 +316,11 @@ + entityplayer.sendTexturePack(this.server.getResourcePack(), this.server.getResourcePackHash(), this.server.isResourcePackRequired(), this.server.getResourcePackPrompt()); +@@ -230,8 +317,11 @@ - if (nbttagcompound != null && nbttagcompound.hasKeyOfType("RootVehicle", 10)) { + if (nbttagcompound != null && nbttagcompound.contains("RootVehicle", 10)) { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle"); -- Entity entity = EntityTypes.a(nbttagcompound1.getCompound("Entity"), worldserver1, (entity1) -> { -- return !worldserver1.addEntitySerialized(entity1) ? null : entity1; +- Entity entity = EntityTypes.loadEntityRecursive(nbttagcompound1.getCompound("Entity"), worldserver1, (entity1) -> { +- return !worldserver1.addWithUUID(entity1) ? null : entity1; + // CraftBukkit start + WorldServer finalWorldServer = worldserver1; -+ Entity entity = EntityTypes.a(nbttagcompound1.getCompound("Entity"), finalWorldServer, (entity1) -> { -+ return !finalWorldServer.addEntitySerialized(entity1) ? null : entity1; ++ Entity entity = EntityTypes.loadEntityRecursive(nbttagcompound1.getCompound("Entity"), finalWorldServer, (entity1) -> { ++ return !finalWorldServer.addWithUUID(entity1) ? null : entity1; + // CraftBukkit end }); if (entity != null) { -@@ -273,6 +363,8 @@ +@@ -274,6 +364,8 @@ } - entityplayer.syncInventory(); + entityplayer.initInventoryMenu(); + // CraftBukkit - Moved from above, added world -+ PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), worldserver1.serverLevelData.getName(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ()); ++ 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 sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { -@@ -305,30 +397,31 @@ + public void updateEntireScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { +@@ -306,30 +398,31 @@ } - public void setPlayerFileData(WorldServer worldserver) { + public void addWorldborderListener(WorldServer worldserver) { + if (playerIo != null) return; // CraftBukkit - worldserver.getWorldBorder().a(new IWorldBorderListener() { + worldserver.getWorldBorder().addListener(new IWorldBorderListener() { @Override - public void a(WorldBorder worldborder, double d0) { -- PlayerList.this.sendAll(new ClientboundSetBorderSizePacket(worldborder)); -+ PlayerList.this.sendAll(new ClientboundSetBorderSizePacket(worldborder), worldborder.world); // CraftBukkit + public void onBorderSizeSet(WorldBorder worldborder, double d0) { +- PlayerList.this.broadcastAll(new ClientboundSetBorderSizePacket(worldborder)); ++ PlayerList.this.broadcastAll(new ClientboundSetBorderSizePacket(worldborder), worldborder.world); // CraftBukkit } @Override - public void a(WorldBorder worldborder, double d0, double d1, long i) { -- PlayerList.this.sendAll(new ClientboundSetBorderLerpSizePacket(worldborder)); -+ PlayerList.this.sendAll(new ClientboundSetBorderLerpSizePacket(worldborder), worldborder.world); // CraftBukkit + public void onBorderSizeLerping(WorldBorder worldborder, double d0, double d1, long i) { +- PlayerList.this.broadcastAll(new ClientboundSetBorderLerpSizePacket(worldborder)); ++ PlayerList.this.broadcastAll(new ClientboundSetBorderLerpSizePacket(worldborder), worldborder.world); // CraftBukkit } @Override - public void a(WorldBorder worldborder, double d0, double d1) { -- PlayerList.this.sendAll(new ClientboundSetBorderCenterPacket(worldborder)); -+ PlayerList.this.sendAll(new ClientboundSetBorderCenterPacket(worldborder), worldborder.world); // CraftBukkit + public void onBorderCenterSet(WorldBorder worldborder, double d0, double d1) { +- PlayerList.this.broadcastAll(new ClientboundSetBorderCenterPacket(worldborder)); ++ PlayerList.this.broadcastAll(new ClientboundSetBorderCenterPacket(worldborder), worldborder.world); // CraftBukkit } @Override - public void a(WorldBorder worldborder, int i) { -- PlayerList.this.sendAll(new ClientboundSetBorderWarningDelayPacket(worldborder)); -+ PlayerList.this.sendAll(new ClientboundSetBorderWarningDelayPacket(worldborder), worldborder.world); // CraftBukkit + public void onBorderSetWarningTime(WorldBorder worldborder, int i) { +- PlayerList.this.broadcastAll(new ClientboundSetBorderWarningDelayPacket(worldborder)); ++ PlayerList.this.broadcastAll(new ClientboundSetBorderWarningDelayPacket(worldborder), worldborder.world); // CraftBukkit } @Override - public void b(WorldBorder worldborder, int i) { -- PlayerList.this.sendAll(new ClientboundSetBorderWarningDistancePacket(worldborder)); -+ PlayerList.this.sendAll(new ClientboundSetBorderWarningDistancePacket(worldborder), worldborder.world); // CraftBukkit + public void onBorderSetWarningBlocks(WorldBorder worldborder, int i) { +- PlayerList.this.broadcastAll(new ClientboundSetBorderWarningDistancePacket(worldborder)); ++ PlayerList.this.broadcastAll(new ClientboundSetBorderWarningDistancePacket(worldborder), worldborder.world); // CraftBukkit } @Override -@@ -356,14 +449,15 @@ +@@ -357,14 +450,15 @@ } - protected void savePlayerFile(EntityPlayer entityplayer) { + protected void save(EntityPlayer entityplayer) { + if (!entityplayer.getBukkitEntity().isPersistent()) return; // CraftBukkit this.playerIo.save(entityplayer); -- ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) this.stats.get(entityplayer.getUniqueID()); -+ ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) entityplayer.getStatisticManager(); // CraftBukkit +- ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) this.stats.get(entityplayer.getUUID()); ++ ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) entityplayer.getStats(); // CraftBukkit if (serverstatisticmanager != null) { serverstatisticmanager.save(); } -- AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.advancements.get(entityplayer.getUniqueID()); -+ AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit +- AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.advancements.get(entityplayer.getUUID()); ++ AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancements(); // CraftBukkit if (advancementdataplayer != null) { - advancementdataplayer.b(); -@@ -371,10 +465,24 @@ + advancementdataplayer.save(); +@@ -372,10 +466,24 @@ } -- public void disconnect(EntityPlayer entityplayer) { -+ public String disconnect(EntityPlayer entityplayer) { // CraftBukkit - return string - WorldServer worldserver = entityplayer.getWorldServer(); +- public void remove(EntityPlayer entityplayer) { ++ public String remove(EntityPlayer entityplayer) { // CraftBukkit - return string + WorldServer worldserver = entityplayer.getLevel(); - entityplayer.a(StatisticList.LEAVE_GAME); + entityplayer.awardStat(StatisticList.LEAVE_GAME); + + // CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it + // See SPIGOT-5799, SPIGOT-6145 + if (entityplayer.containerMenu != entityplayer.inventoryMenu) { -+ entityplayer.closeInventory(); ++ entityplayer.closeContainer(); + } + -+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), "\u00A7e" + entityplayer.getName() + " left the game"); ++ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), "\u00A7e" + entityplayer.getScoreboardName() + " left the game"); + cserver.getPluginManager().callEvent(playerQuitEvent); + entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage()); + -+ entityplayer.playerTick(); // SPIGOT-924 ++ entityplayer.doTick(); // SPIGOT-924 + // CraftBukkit end + - this.savePlayerFile(entityplayer); + this.save(entityplayer); if (entityplayer.isPassenger()) { Entity entity = entityplayer.getRootVehicle(); -@@ -398,18 +506,66 @@ +@@ -399,18 +507,66 @@ if (entityplayer1 == entityplayer) { this.playersByUUID.remove(uuid); @@ -293,13 +293,13 @@ + } + + // CraftBukkit start -+ // this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer})); ++ // this.broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer})); + PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityplayer); + for (int i = 0; i < players.size(); i++) { + EntityPlayer entityplayer2 = (EntityPlayer) this.players.get(i); + + if (entityplayer2.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) { -+ entityplayer2.connection.sendPacket(packet); ++ entityplayer2.connection.send(packet); + } else { + entityplayer2.getBukkitEntity().removeDisconnectingPlayer(entityplayer.getBukkitEntity()); + } @@ -308,26 +308,26 @@ + cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity()); + // CraftBukkit end -- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer})); +- this.broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer})); + return playerQuitEvent.getQuitMessage(); // CraftBukkit } - @Nullable -- public IChatBaseComponent attemptLogin(SocketAddress socketaddress, GameProfile gameprofile) { +- public IChatBaseComponent canPlayerLogin(SocketAddress socketaddress, GameProfile gameprofile) { + // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer -+ public EntityPlayer attemptLogin(LoginListener loginlistener, GameProfile gameprofile, String hostname) { ++ public EntityPlayer canPlayerLogin(LoginListener loginlistener, GameProfile gameprofile, String hostname) { ChatMessage chatmessage; - if (this.bans.isBanned(gameprofile)) { + // Moved from processLogin -+ UUID uuid = EntityHuman.a(gameprofile); ++ UUID uuid = EntityHuman.createPlayerUUID(gameprofile); + List<EntityPlayer> list = Lists.newArrayList(); + + EntityPlayer entityplayer; + + for (int i = 0; i < this.players.size(); ++i) { + entityplayer = (EntityPlayer) this.players.get(i); -+ if (entityplayer.getUniqueID().equals(uuid)) { ++ if (entityplayer.getUUID().equals(uuid)) { + list.add(entityplayer); + } + } @@ -336,50 +336,50 @@ + + while (iterator.hasNext()) { + entityplayer = (EntityPlayer) iterator.next(); -+ savePlayerFile(entityplayer); // CraftBukkit - Force the player's inventory to be saved ++ save(entityplayer); // CraftBukkit - Force the player's inventory to be saved + entityplayer.connection.disconnect(new ChatMessage("multiplayer.disconnect.duplicate_login", new Object[0])); + } + + // Instead of kicking then returning, we need to store the kick reason + // in the event, check with plugins to see if it's ok, and THEN kick + // depending on the outcome. -+ SocketAddress socketaddress = loginlistener.connection.getSocketAddress(); ++ SocketAddress socketaddress = loginlistener.connection.getRemoteAddress(); + -+ EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(World.OVERWORLD), gameprofile); ++ EntityPlayer entity = new EntityPlayer(this.server, this.server.getLevel(World.OVERWORLD), gameprofile); + Player player = entity.getBukkitEntity(); + PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress()); + -+ if (getProfileBans().isBanned(gameprofile) && !getProfileBans().get(gameprofile).hasExpired()) { ++ if (getBans().isBanned(gameprofile) && !getBans().get(gameprofile).hasExpired()) { GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile); chatmessage = new ChatMessage("multiplayer.disconnect.banned.reason", new Object[]{gameprofilebanentry.getReason()}); -@@ -417,10 +573,12 @@ - chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned.expiration", new Object[]{PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())})); +@@ -418,10 +574,12 @@ + chatmessage.append((IChatBaseComponent) (new ChatMessage("multiplayer.disconnect.banned.expiration", new Object[]{PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())}))); } - return chatmessage; + // return chatmessage; + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage)); - } else if (!this.isWhitelisted(gameprofile)) { + } else if (!this.isWhiteListed(gameprofile)) { - return new ChatMessage("multiplayer.disconnect.not_whitelisted"); - } else if (this.ipBans.isBanned(socketaddress)) { + chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted"); + event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, CraftChatMessage.fromComponent(chatmessage)); -+ } else if (getIPBans().isBanned(socketaddress) && !getIPBans().get(socketaddress).hasExpired()) { ++ } else if (getIpBans().isBanned(socketaddress) && !getIpBans().get(socketaddress).hasExpired()) { IpBanEntry ipbanentry = this.ipBans.get(socketaddress); chatmessage = new ChatMessage("multiplayer.disconnect.banned_ip.reason", new Object[]{ipbanentry.getReason()}); -@@ -428,13 +586,25 @@ - chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned_ip.expiration", new Object[]{PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())})); +@@ -429,13 +587,25 @@ + chatmessage.append((IChatBaseComponent) (new ChatMessage("multiplayer.disconnect.banned_ip.expiration", new Object[]{PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())}))); } - return chatmessage; + // return chatmessage; + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage)); } else { -- return this.players.size() >= this.maxPlayers && !this.d(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null; -+ // return this.players.size() >= this.maxPlayers && !this.d(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null; -+ if (this.players.size() >= this.maxPlayers && !this.d(gameprofile)) { +- return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null; ++ // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null; ++ if (this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile)) { + event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full"); + } } @@ -392,41 +392,41 @@ + return entity; } -- public EntityPlayer processLogin(GameProfile gameprofile) { -+ public EntityPlayer processLogin(GameProfile gameprofile, EntityPlayer player) { // CraftBukkit - added EntityPlayer +- public EntityPlayer getPlayerForLogin(GameProfile gameprofile) { ++ public EntityPlayer getPlayerForLogin(GameProfile gameprofile, EntityPlayer player) { // CraftBukkit - added EntityPlayer + /* CraftBukkit startMoved up - UUID uuid = EntityHuman.a(gameprofile); + UUID uuid = EntityHuman.createPlayerUUID(gameprofile); List<EntityPlayer> list = Lists.newArrayList(); -@@ -461,14 +631,24 @@ +@@ -462,14 +632,24 @@ } - return new EntityPlayer(this.server, this.server.E(), gameprofile); + return new EntityPlayer(this.server, this.server.overworld(), gameprofile); + */ + return player; + // CraftBukkit end } + // CraftBukkit start - public EntityPlayer moveToWorld(EntityPlayer entityplayer, boolean flag) { -+ return this.moveToWorld(entityplayer, this.server.getWorldServer(entityplayer.getSpawnDimension()), flag, null, true); + public EntityPlayer respawn(EntityPlayer entityplayer, boolean flag) { ++ return this.respawn(entityplayer, this.server.getLevel(entityplayer.getRespawnDimension()), flag, null, true); + } + -+ public EntityPlayer moveToWorld(EntityPlayer entityplayer, WorldServer worldserver, boolean flag, Location location, boolean avoidSuffocation) { ++ public EntityPlayer respawn(EntityPlayer entityplayer, WorldServer worldserver, boolean flag, Location location, boolean avoidSuffocation) { + entityplayer.stopRiding(); // CraftBukkit this.players.remove(entityplayer); - entityplayer.getWorldServer().a(entityplayer, Entity.RemovalReason.DISCARDED); - BlockPosition blockposition = entityplayer.getSpawn(); - float f = entityplayer.getSpawnAngle(); - boolean flag1 = entityplayer.isSpawnForced(); + entityplayer.getLevel().removePlayerImmediately(entityplayer, Entity.RemovalReason.DISCARDED); + BlockPosition blockposition = entityplayer.getRespawnPosition(); + float f = entityplayer.getRespawnAngle(); + boolean flag1 = entityplayer.isRespawnForced(); + /* CraftBukkit start - WorldServer worldserver = this.server.getWorldServer(entityplayer.getSpawnDimension()); + WorldServer worldserver = this.server.getLevel(entityplayer.getRespawnDimension()); Optional optional; -@@ -480,6 +660,11 @@ +@@ -481,6 +661,11 @@ - WorldServer worldserver1 = worldserver != null && optional.isPresent() ? worldserver : this.server.E(); - EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getProfile()); + WorldServer worldserver1 = worldserver != null && optional.isPresent() ? worldserver : this.server.overworld(); + EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getGameProfile()); + // */ + EntityPlayer entityplayer1 = entityplayer; + org.bukkit.World fromWorld = entityplayer.getBukkitEntity().getWorld(); @@ -434,69 +434,69 @@ + // CraftBukkit end entityplayer1.connection = entityplayer.connection; - entityplayer1.copyFrom(entityplayer, flag); -@@ -495,49 +680,111 @@ + entityplayer1.restoreFrom(entityplayer, flag); +@@ -496,49 +681,110 @@ boolean flag2 = false; - if (optional.isPresent()) { -- IBlockData iblockdata = worldserver1.getType(blockposition); -- boolean flag3 = iblockdata.a(Blocks.RESPAWN_ANCHOR); +- IBlockData iblockdata = worldserver1.getBlockState(blockposition); +- boolean flag3 = iblockdata.is(Blocks.RESPAWN_ANCHOR); - Vec3D vec3d = (Vec3D) optional.get(); - float f1; + // CraftBukkit start - fire PlayerRespawnEvent + if (location == null) { + boolean isBedSpawn = false; -+ WorldServer worldserver1 = this.server.getWorldServer(entityplayer.getSpawnDimension()); ++ WorldServer worldserver1 = this.server.getLevel(entityplayer.getRespawnDimension()); + if (worldserver1 != null) { + Optional optional; -- if (!iblockdata.a((Tag) TagsBlock.BEDS) && !flag3) { +- if (!iblockdata.is((Tag) TagsBlock.BEDS) && !flag3) { - f1 = f; - } else { -- Vec3D vec3d1 = Vec3D.c((BaseBlockPosition) blockposition).d(vec3d).d(); +- Vec3D vec3d1 = Vec3D.atBottomCenterOf(blockposition).subtract(vec3d).normalize(); + if (blockposition != null) { -+ optional = EntityHuman.getBed(worldserver1, blockposition, f, flag1, flag); ++ optional = EntityHuman.findRespawnPositionAndUseSpawnBlock(worldserver1, blockposition, f, flag1, flag); + } else { + optional = Optional.empty(); + } + + if (optional.isPresent()) { -+ IBlockData iblockdata = worldserver1.getType(blockposition); -+ boolean flag3 = iblockdata.a(Blocks.RESPAWN_ANCHOR); ++ IBlockData iblockdata = worldserver1.getBlockState(blockposition); ++ boolean flag3 = iblockdata.is(Blocks.RESPAWN_ANCHOR); + Vec3D vec3d = (Vec3D) optional.get(); + float f1; + -+ if (!iblockdata.a((Tag) TagsBlock.BEDS) && !flag3) { ++ if (!iblockdata.is((Tag) TagsBlock.BEDS) && !flag3) { + f1 = f; + } else { -+ Vec3D vec3d1 = Vec3D.c((BaseBlockPosition) blockposition).d(vec3d).d(); ++ Vec3D vec3d1 = Vec3D.atBottomCenterOf(blockposition).subtract(vec3d).normalize(); -- f1 = (float) MathHelper.f(MathHelper.d(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); -+ f1 = (float) MathHelper.f(MathHelper.d(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); +- f1 = (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); ++ f1 = (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); + } + -+ entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, f, flag1, false); ++ entityplayer1.setRespawnPosition(worldserver1.dimension(), blockposition, f, flag1, false); + flag2 = !flag && flag3; + isBedSpawn = true; + location = new Location(worldserver1.getWorld(), vec3d.x, vec3d.y, vec3d.z, f1, 0.0F); + } else if (blockposition != null) { -+ entityplayer1.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); ++ entityplayer1.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); + entityplayer1.setRespawnPosition(null, null, 0f, false, false); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed + } + } + + if (location == null) { -+ worldserver1 = this.server.getWorldServer(World.OVERWORLD); ++ worldserver1 = this.server.getLevel(World.OVERWORLD); + blockposition = entityplayer1.getSpawnPoint(worldserver1); + location = new Location(worldserver1.getWorld(), (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F)); } -- entityplayer1.setPositionRotation(vec3d.x, vec3d.y, vec3d.z, f1, 0.0F); -- entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, f, flag1, false); +- entityplayer1.moveTo(vec3d.x, vec3d.y, vec3d.z, f1, 0.0F); +- entityplayer1.setRespawnPosition(worldserver1.dimension(), blockposition, f, flag1, false); - flag2 = !flag && flag3; - } else if (blockposition != null) { -- entityplayer1.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); +- entityplayer1.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); + Player respawnPlayer = entityplayer1.getBukkitEntity(); + PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !flag2, flag2); + cserver.getPluginManager().callEvent(respawnEvent); @@ -510,52 +510,51 @@ + entityplayer1.forceSetPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + // CraftBukkit end -- while (!worldserver1.getCubes(entityplayer1) && entityplayer1.locY() < (double) worldserver1.getMaxBuildHeight()) { -+ while (avoidSuffocation && !worldserver1.getCubes(entityplayer1) && entityplayer1.locY() < (double) worldserver1.getMaxBuildHeight()) { - entityplayer1.setPosition(entityplayer1.locX(), entityplayer1.locY() + 1.0D, entityplayer1.locZ()); +- while (!worldserver1.noCollision((Entity) entityplayer1) && entityplayer1.getY() < (double) worldserver1.getMaxBuildHeight()) { ++ while (avoidSuffocation && !worldserver1.noCollision(entityplayer1) && entityplayer1.getY() < (double) worldserver1.getMaxBuildHeight()) { + entityplayer1.setPos(entityplayer1.getX(), entityplayer1.getY() + 1.0D, entityplayer1.getZ()); } + // CraftBukkit start -+ WorldData worlddata = worldserver1.getWorldData(); -+ entityplayer1.connection.sendPacket(new PacketPlayOutRespawn(worldserver1.getDimensionManager(), worldserver1.getDimensionKey(), BiomeManager.a(worldserver1.getSeed()), entityplayer1.gameMode.getGameMode(), entityplayer1.gameMode.c(), worldserver1.isDebugWorld(), worldserver1.isFlatWorld(), flag)); ++ WorldData worlddata = worldserver1.getLevelData(); ++ entityplayer1.connection.send(new PacketPlayOutRespawn(worldserver1.dimensionType(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), worldserver1.isDebug(), worldserver1.isFlat(), flag)); + entityplayer1.spawnIn(worldserver1); + entityplayer1.unsetRemoved(); -+ entityplayer1.connection.teleport(new Location(worldserver1.getWorld(), entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.getYRot(), entityplayer1.getXRot())); -+ entityplayer1.setSneaking(false); ++ entityplayer1.connection.teleport(new Location(worldserver1.getWorld(), entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot())); ++ entityplayer1.setShiftKeyDown(false); -- WorldData worlddata = entityplayer1.level.getWorldData(); +- WorldData worlddata = entityplayer1.level.getLevelData(); - -- entityplayer1.connection.sendPacket(new PacketPlayOutRespawn(entityplayer1.level.getDimensionManager(), entityplayer1.level.getDimensionKey(), BiomeManager.a(entityplayer1.getWorldServer().getSeed()), entityplayer1.gameMode.getGameMode(), entityplayer1.gameMode.c(), entityplayer1.getWorldServer().isDebugWorld(), entityplayer1.getWorldServer().isFlatWorld(), flag)); -- entityplayer1.connection.b(entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.getYRot(), entityplayer1.getXRot()); -+ // entityplayer1.connection.b(entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.getYRot(), entityplayer1.getXRot()); - entityplayer1.connection.sendPacket(new PacketPlayOutSpawnPosition(worldserver1.getSpawn(), worldserver1.x())); - entityplayer1.connection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); - entityplayer1.connection.sendPacket(new PacketPlayOutExperience(entityplayer1.experienceProgress, entityplayer1.totalExperience, entityplayer1.experienceLevel)); - this.a(entityplayer1, worldserver1); - this.d(entityplayer1); -- worldserver1.addPlayerRespawn(entityplayer1); +- entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.level.dimensionType(), entityplayer1.level.dimension(), BiomeManager.obfuscateSeed(entityplayer1.getLevel().getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), entityplayer1.getLevel().isDebug(), entityplayer1.getLevel().isFlat(), flag)); +- entityplayer1.connection.teleport(entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot()); ++ // entityplayer1.connection.teleport(entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot()); + entityplayer1.connection.send(new PacketPlayOutSpawnPosition(worldserver1.getSharedSpawnPos(), worldserver1.getSharedSpawnAngle())); + entityplayer1.connection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); + entityplayer1.connection.send(new PacketPlayOutExperience(entityplayer1.experienceProgress, entityplayer1.totalExperience, entityplayer1.experienceLevel)); + this.sendLevelInfo(entityplayer1, worldserver1); + this.sendPlayerPermissionLevel(entityplayer1); +- worldserver1.addRespawnedPlayer(entityplayer1); - this.players.add(entityplayer1); -- this.playersByUUID.put(entityplayer1.getUniqueID(), entityplayer1); -- entityplayer1.syncInventory(); +- this.playersByUUID.put(entityplayer1.getUUID(), entityplayer1); +- entityplayer1.initInventoryMenu(); + if (!entityplayer.connection.isDisconnected()) { -+ worldserver1.addPlayerRespawn(entityplayer1); ++ worldserver1.addRespawnedPlayer(entityplayer1); + this.players.add(entityplayer1); -+ this.playersByUUID.put(entityplayer1.getUniqueID(), entityplayer1); ++ this.playersByUUID.put(entityplayer1.getUUID(), entityplayer1); + } -+ // entityplayer1.syncInventory(); ++ // entityplayer1.initInventoryMenu(); entityplayer1.setHealth(entityplayer1.getHealth()); if (flag2) { - entityplayer1.connection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F)); + entityplayer1.connection.send(new PacketPlayOutNamedSoundEffect(SoundEffects.RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F)); } + // Added from changeDimension -+ updateClient(entityplayer); // Update health, etc... -+ entityplayer.updateAbilities(); -+ for (Object o1 : entityplayer.getEffects()) { -+ MobEffect mobEffect = (MobEffect) o1; -+ entityplayer.connection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobEffect)); ++ sendAllPlayerInfo(entityplayer); // Update health, etc... ++ entityplayer.onUpdateAbilities(); ++ for (MobEffect mobEffect : entityplayer.getActiveEffects()) { ++ entityplayer.connection.send(new PacketPlayOutEntityEffect(entityplayer.getId(), mobEffect)); + } + + // Fire advancement trigger -+ entityplayer.triggerDimensionAdvancements(((CraftWorld) fromWorld).getHandle()); ++ entityplayer.triggerDimensionChangeTriggers(((CraftWorld) fromWorld).getHandle()); + // Don't fire on respawn + if (fromWorld != location.getWorld()) { @@ -565,22 +564,22 @@ + + // Save player file again if they were disconnected + if (entityplayer.connection.isDisconnected()) { -+ this.savePlayerFile(entityplayer); ++ this.save(entityplayer); + } + // CraftBukkit end return entityplayer1; } -@@ -550,7 +797,18 @@ +@@ -551,7 +797,18 @@ public void tick() { if (++this.sendAllPlayerInfoIn > 600) { -- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players)); +- this.broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players)); + // CraftBukkit start + for (int i = 0; i < this.players.size(); ++i) { + final EntityPlayer target = (EntityPlayer) this.players.get(i); + -+ target.connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players.stream().filter(new Predicate<EntityPlayer>() { ++ target.connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players.stream().filter(new Predicate<EntityPlayer>() { + @Override + public boolean apply(EntityPlayer input) { + return target.getBukkitEntity().canSee(input.getBukkitEntity()); @@ -591,41 +590,50 @@ this.sendAllPlayerInfoIn = 0; } -@@ -567,6 +825,25 @@ +@@ -568,6 +825,25 @@ } + // CraftBukkit start - add a world/entity limited version -+ public void sendAll(Packet packet, EntityHuman entityhuman) { ++ public void broadcastAll(Packet packet, EntityHuman entityhuman) { + for (int i = 0; i < this.players.size(); ++i) { + EntityPlayer entityplayer = this.players.get(i); + if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) { + continue; + } -+ ((EntityPlayer) this.players.get(i)).connection.sendPacket(packet); ++ ((EntityPlayer) this.players.get(i)).connection.send(packet); + } + } + -+ public void sendAll(Packet packet, World world) { -+ for (int i = 0; i < world.getPlayers().size(); ++i) { -+ ((EntityPlayer) world.getPlayers().get(i)).connection.sendPacket(packet); ++ public void broadcastAll(Packet packet, World world) { ++ for (int i = 0; i < world.players().size(); ++i) { ++ ((EntityPlayer) world.players().get(i)).connection.send(packet); + } + + } + // CraftBukkit end + - public void a(Packet<?> packet, ResourceKey<World> resourcekey) { + public void broadcastAll(Packet<?> packet, ResourceKey<World> resourcekey) { Iterator iterator = this.players.iterator(); -@@ -669,6 +946,7 @@ - entityplayer.connection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, b0)); +@@ -646,7 +922,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) { +@@ -670,6 +946,7 @@ + entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0)); } + entityplayer.getBukkitEntity().recalculatePermissions(); // CraftBukkit - this.server.getCommandDispatcher().a(entityplayer); + this.server.getCommands().sendCommands(entityplayer); } -@@ -701,6 +979,12 @@ +@@ -702,6 +979,12 @@ for (int i = 0; i < this.players.size(); ++i) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(i); @@ -635,27 +643,27 @@ + } + // CraftBukkit end + - if (entityplayer != entityhuman && entityplayer.level.getDimensionKey() == resourcekey) { - double d4 = d0 - entityplayer.locX(); - double d5 = d1 - entityplayer.locY(); -@@ -740,23 +1024,34 @@ - public void reloadWhitelist() {} + if (entityplayer != entityhuman && entityplayer.level.dimension() == resourcekey) { + double d4 = d0 - entityplayer.getX(); + double d5 = d1 - entityplayer.getY(); +@@ -741,23 +1024,34 @@ + public void reloadWhiteList() {} - public void a(EntityPlayer entityplayer, WorldServer worldserver) { -- WorldBorder worldborder = this.server.E().getWorldBorder(); + public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) { +- WorldBorder worldborder = this.server.overworld().getWorldBorder(); + WorldBorder worldborder = entityplayer.level.getWorldBorder(); // CraftBukkit - entityplayer.connection.sendPacket(new ClientboundInitializeBorderPacket(worldborder)); - entityplayer.connection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); - entityplayer.connection.sendPacket(new PacketPlayOutSpawnPosition(worldserver.getSpawn(), worldserver.x())); + entityplayer.connection.send(new ClientboundInitializeBorderPacket(worldborder)); + entityplayer.connection.send(new PacketPlayOutUpdateTime(worldserver.getGameTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); + entityplayer.connection.send(new PacketPlayOutSpawnPosition(worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle())); if (worldserver.isRaining()) { -- entityplayer.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.START_RAINING, 0.0F)); -- entityplayer.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, worldserver.d(1.0F))); -- entityplayer.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, worldserver.b(1.0F))); +- entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.START_RAINING, 0.0F)); +- entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, worldserver.getRainLevel(1.0F))); +- entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, worldserver.getThunderLevel(1.0F))); + // CraftBukkit start - handle player weather -+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.b, 0.0F)); -+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, worldserver.d(1.0F))); -+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.i, worldserver.b(1.0F))); ++ // entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.START_RAINING, 0.0F)); ++ // entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, worldserver.getRainLevel(1.0F))); ++ // entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, worldserver.getThunderLevel(1.0F))); + entityplayer.setPlayerWeather(org.bukkit.WeatherType.DOWNFALL, false); + entityplayer.updateWeather(-worldserver.rainLevel, worldserver.rainLevel, -worldserver.thunderLevel, worldserver.thunderLevel); + // CraftBukkit end @@ -663,25 +671,25 @@ } - public void updateClient(EntityPlayer entityplayer) { - entityplayer.inventoryMenu.updateInventory(); -- entityplayer.triggerHealthUpdate(); -+ // entityplayer.triggerHealthUpdate(); + public void sendAllPlayerInfo(EntityPlayer entityplayer) { + entityplayer.inventoryMenu.sendAllDataToRemote(); +- entityplayer.resetSentInfo(); ++ // entityplayer.resetSentInfo(); + entityplayer.getBukkitEntity().updateScaledHealth(); // CraftBukkit - Update scaled health on respawn and worldchange - entityplayer.connection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().selected)); + entityplayer.connection.send(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().selected)); + // CraftBukkit start - from GameRules + int i = entityplayer.level.getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23; -+ entityplayer.connection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) i)); ++ entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, (byte) i)); + float immediateRespawn = entityplayer.level.getGameRules().getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN) ? 1.0F: 0.0F; -+ entityplayer.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.IMMEDIATE_RESPAWN, immediateRespawn)); ++ entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.IMMEDIATE_RESPAWN, immediateRespawn)); + // CraftBukkit end } public int getPlayerCount() { -@@ -807,12 +1102,22 @@ +@@ -813,12 +1107,22 @@ } - public void shutdown() { + public void removeAll() { - for (int i = 0; i < this.players.size(); ++i) { - ((EntityPlayer) this.players.get(i)).connection.disconnect(new ChatMessage("multiplayer.disconnect.server_shutdown")); + // CraftBukkit start - disconnect safely @@ -693,45 +701,45 @@ } + // CraftBukkit start -+ public void sendMessage(IChatBaseComponent[] iChatBaseComponents) { ++ public void broadcastMessage(IChatBaseComponent[] iChatBaseComponents) { + for (IChatBaseComponent component : iChatBaseComponents) { -+ sendMessage(component, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID); ++ broadcastMessage(component, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID); + } + } + // CraftBukkit end + - public void sendMessage(IChatBaseComponent ichatbasecomponent, ChatMessageType chatmessagetype, UUID uuid) { + public void broadcastMessage(IChatBaseComponent ichatbasecomponent, ChatMessageType chatmessagetype, UUID uuid) { this.server.sendMessage(ichatbasecomponent, uuid); Iterator iterator = this.players.iterator(); -@@ -840,16 +1145,23 @@ +@@ -846,16 +1150,23 @@ } -- public ServerStatisticManager getStatisticManager(EntityHuman entityhuman) { -- UUID uuid = entityhuman.getUniqueID(); -- ServerStatisticManager serverstatisticmanager = uuid == null ? null : (ServerStatisticManager) this.stats.get(uuid); +- public ServerStatisticManager getPlayerStats(EntityHuman entityhuman) { +- UUID uuid = entityhuman.getUUID(); +- ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) this.stats.get(uuid); + // CraftBukkit start -+ public ServerStatisticManager getStatisticManager(EntityPlayer entityhuman) { -+ ServerStatisticManager serverstatisticmanager = entityhuman.getStatisticManager(); -+ return serverstatisticmanager == null ? getStatisticManager(entityhuman.getUniqueID(), entityhuman.getDisplayName().getString()) : serverstatisticmanager; ++ public ServerStatisticManager getPlayerStats(EntityPlayer entityhuman) { ++ ServerStatisticManager serverstatisticmanager = entityhuman.getStats(); ++ return serverstatisticmanager == null ? getPlayerStats(entityhuman.getUUID(), entityhuman.getDisplayName().getString()) : serverstatisticmanager; + } + -+ public ServerStatisticManager getStatisticManager(UUID uuid, String displayName) { ++ public ServerStatisticManager getPlayerStats(UUID uuid, String displayName) { + EntityPlayer entityhuman = this.getPlayer(uuid); -+ ServerStatisticManager serverstatisticmanager = entityhuman == null ? null : (ServerStatisticManager) entityhuman.getStatisticManager(); ++ ServerStatisticManager serverstatisticmanager = entityhuman == null ? null : (ServerStatisticManager) entityhuman.getStats(); + // CraftBukkit end if (serverstatisticmanager == null) { - File file = this.server.a(SavedFile.PLAYER_STATS_DIR).toFile(); + File file = this.server.getWorldPath(SavedFile.PLAYER_STATS_DIR).toFile(); File file1 = new File(file, uuid + ".json"); if (!file1.exists()) { -- File file2 = new File(file, entityhuman.getDisplayName().getString() + ".json"); +- File file2 = new File(file, entityhuman.getName().getString() + ".json"); + File file2 = new File(file, displayName + ".json"); // CraftBukkit Path path = file2.toPath(); - if (FileUtils.a(path) && FileUtils.b(path) && path.startsWith(file.getPath()) && file2.isFile()) { -@@ -858,7 +1170,7 @@ + if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) { +@@ -864,7 +1175,7 @@ } serverstatisticmanager = new ServerStatisticManager(this.server, file1); @@ -740,27 +748,27 @@ } return serverstatisticmanager; -@@ -866,14 +1178,14 @@ +@@ -872,14 +1183,14 @@ - public AdvancementDataPlayer f(EntityPlayer entityplayer) { - UUID uuid = entityplayer.getUniqueID(); + public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) { + UUID uuid = entityplayer.getUUID(); - AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.advancements.get(uuid); -+ AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit ++ AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancements(); // CraftBukkit if (advancementdataplayer == null) { - File file = this.server.a(SavedFile.PLAYER_ADVANCEMENTS_DIR).toFile(); + File file = this.server.getWorldPath(SavedFile.PLAYER_ADVANCEMENTS_DIR).toFile(); File file1 = new File(file, uuid + ".json"); - advancementdataplayer = new AdvancementDataPlayer(this.server.getDataFixer(), this, this.server.getAdvancementData(), file1, entityplayer); + advancementdataplayer = new AdvancementDataPlayer(this.server.getFixerUpper(), this, this.server.getAdvancements(), file1, entityplayer); - this.advancements.put(uuid, advancementdataplayer); + // this.advancements.put(uuid, advancementdataplayer); // CraftBukkit } - advancementdataplayer.a(entityplayer); -@@ -909,13 +1221,20 @@ + advancementdataplayer.setPlayer(entityplayer); +@@ -930,13 +1241,20 @@ } - public void reload() { + public void reloadResources() { - Iterator iterator = this.advancements.values().iterator(); + // CraftBukkit start + /*Iterator iterator = this.advancements.values().iterator(); @@ -768,14 +776,14 @@ while (iterator.hasNext()) { AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) iterator.next(); - advancementdataplayer.a(this.server.getAdvancementData()); + advancementdataplayer.reload(this.server.getAdvancements()); + }*/ + + for (EntityPlayer player : players) { -+ player.getAdvancementData().a(this.server.getAdvancementData()); -+ player.getAdvancementData().b(player); // CraftBukkit - trigger immediate flush of advancements ++ player.getAdvancements().reload(this.server.getAdvancements()); ++ player.getAdvancements().flushDirty(player); // CraftBukkit - trigger immediate flush of advancements } + // CraftBukkit end - this.sendAll(new PacketPlayOutTags(this.server.getTagRegistry().a((IRegistryCustom) this.registryHolder))); - PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(this.server.getCraftingManager().b()); + this.broadcastAll(new PacketPlayOutTags(this.server.getTags().serializeToNetwork(this.registryHolder))); + PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(this.server.getRecipeManager().getRecipes()); diff --git a/paper-server/nms-patches/net/minecraft/server/players/SleepStatus.patch b/paper-server/nms-patches/net/minecraft/server/players/SleepStatus.patch index 103940b96f..3af51ebff8 100644 --- a/paper-server/nms-patches/net/minecraft/server/players/SleepStatus.patch +++ b/paper-server/nms-patches/net/minecraft/server/players/SleepStatus.patch @@ -3,18 +3,18 @@ @@ -18,9 +18,12 @@ } - public boolean a(int i, List<EntityPlayer> list) { -- int j = (int) list.stream().filter(EntityHuman::isDeeplySleeping).count(); + public boolean areEnoughDeepSleeping(int i, List<EntityPlayer> list) { +- int j = (int) list.stream().filter(EntityHuman::isSleepingLongEnough).count(); + // CraftBukkit start -+ int j = (int) list.stream().filter((eh) -> { return eh.isDeeplySleeping() || eh.fauxSleeping; }).count(); -+ boolean anyDeepSleep = list.stream().anyMatch(EntityHuman::isDeeplySleeping); ++ int j = (int) list.stream().filter((eh) -> { return eh.isSleepingLongEnough() || eh.fauxSleeping; }).count(); ++ boolean anyDeepSleep = list.stream().anyMatch(EntityHuman::isSleepingLongEnough); -- return j >= this.b(i); -+ return anyDeepSleep && j >= this.b(i); +- return j >= this.sleepersNeeded(i); ++ return anyDeepSleep && j >= this.sleepersNeeded(i); + // CraftBukkit end } - public int b(int i) { + public int sleepersNeeded(int i) { @@ -42,18 +45,24 @@ this.activePlayers = 0; this.sleepingPlayers = 0; diff --git a/paper-server/nms-patches/net/minecraft/server/rcon/RemoteControlCommandListener.patch b/paper-server/nms-patches/net/minecraft/server/rcon/RemoteControlCommandListener.patch index d647a378c2..340c66e669 100644 --- a/paper-server/nms-patches/net/minecraft/server/rcon/RemoteControlCommandListener.patch +++ b/paper-server/nms-patches/net/minecraft/server/rcon/RemoteControlCommandListener.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/rcon/RemoteControlCommandListener.java +++ b/net/minecraft/server/rcon/RemoteControlCommandListener.java -@@ -37,6 +37,17 @@ - return new CommandListenerWrapper(this, Vec3D.b((BaseBlockPosition) worldserver.getSpawn()), Vec2F.ZERO, worldserver, 4, "Rcon", RemoteControlCommandListener.RCON_COMPONENT, this.server, (Entity) null); +@@ -36,6 +36,17 @@ + return new CommandListenerWrapper(this, Vec3D.atLowerCornerOf(worldserver.getSharedSpawnPos()), Vec2F.ZERO, worldserver, 4, "Rcon", RemoteControlCommandListener.RCON_COMPONENT, this.server, (Entity) null); } + // CraftBukkit start - Send a String diff --git a/paper-server/nms-patches/net/minecraft/stats/RecipeBookServer.patch b/paper-server/nms-patches/net/minecraft/stats/RecipeBookServer.patch index 821de7dc8e..8c242568f2 100644 --- a/paper-server/nms-patches/net/minecraft/stats/RecipeBookServer.patch +++ b/paper-server/nms-patches/net/minecraft/stats/RecipeBookServer.patch @@ -11,18 +11,18 @@ public static final String RECIPE_BOOK_TAG = "recipeBook"; @@ -36,7 +38,7 @@ IRecipe<?> irecipe = (IRecipe) iterator.next(); - MinecraftKey minecraftkey = irecipe.getKey(); + MinecraftKey minecraftkey = irecipe.getId(); -- if (!this.known.contains(minecraftkey) && !irecipe.isComplex()) { -+ if (!this.known.contains(minecraftkey) && !irecipe.isComplex() && CraftEventFactory.handlePlayerRecipeListUpdateEvent(entityplayer, minecraftkey)) { // CraftBukkit - this.a(minecraftkey); - this.d(minecraftkey); +- if (!this.known.contains(minecraftkey) && !irecipe.isSpecial()) { ++ if (!this.known.contains(minecraftkey) && !irecipe.isSpecial() && CraftEventFactory.handlePlayerRecipeListUpdateEvent(entityplayer, minecraftkey)) { // CraftBukkit + this.add(minecraftkey); + this.addHighlight(minecraftkey); list.add(minecraftkey); @@ -70,6 +72,7 @@ } - private void a(PacketPlayOutRecipes.Action packetplayoutrecipes_action, EntityPlayer entityplayer, List<MinecraftKey> list) { + private void sendRecipes(PacketPlayOutRecipes.Action packetplayoutrecipes_action, EntityPlayer entityplayer, List<MinecraftKey> list) { + if (entityplayer.connection == null) return; // SPIGOT-4478 during PlayerLoginEvent - entityplayer.connection.sendPacket(new PacketPlayOutRecipes(packetplayoutrecipes_action, list, Collections.emptyList(), this.a())); + entityplayer.connection.send(new PacketPlayOutRecipes(packetplayoutrecipes_action, list, Collections.emptyList(), this.getBookSettings())); } diff --git a/paper-server/nms-patches/net/minecraft/stats/ServerStatisticManager.patch b/paper-server/nms-patches/net/minecraft/stats/ServerStatisticManager.patch index 71b6afb949..3b006c8860 100644 --- a/paper-server/nms-patches/net/minecraft/stats/ServerStatisticManager.patch +++ b/paper-server/nms-patches/net/minecraft/stats/ServerStatisticManager.patch @@ -8,19 +8,19 @@ @@ -161,13 +162,12 @@ } - private <T> Optional<Statistic<T>> a(StatisticWrapper<T> statisticwrapper, String s) { -- Optional optional = Optional.ofNullable(MinecraftKey.a(s)); + private <T> Optional<Statistic<T>> getStat(StatisticWrapper<T> statisticwrapper, String s) { +- Optional optional = Optional.ofNullable(MinecraftKey.tryParse(s)); - IRegistry iregistry = statisticwrapper.getRegistry(); + // CraftBukkit - decompile error start -+ Optional<MinecraftKey> optional = Optional.ofNullable(MinecraftKey.a(s)); ++ Optional<MinecraftKey> optional = Optional.ofNullable(MinecraftKey.tryParse(s)); + IRegistry<T> iregistry = statisticwrapper.getRegistry(); - Objects.requireNonNull(iregistry); - optional = optional.flatMap(iregistry::getOptional); - Objects.requireNonNull(statisticwrapper); -- return optional.map(statisticwrapper::b); -+ return optional.flatMap(iregistry::getOptional).map(statisticwrapper::b); +- return optional.map(statisticwrapper::get); ++ return optional.flatMap(iregistry::getOptional).map(statisticwrapper::get); + // CraftBukkit - decompile error end } - private static NBTTagCompound a(JsonObject jsonobject) { + private static NBTTagCompound fromJson(JsonObject jsonobject) { diff --git a/paper-server/nms-patches/net/minecraft/stats/StatisticManager.patch b/paper-server/nms-patches/net/minecraft/stats/StatisticManager.patch index e2ba82193d..118075d566 100644 --- a/paper-server/nms-patches/net/minecraft/stats/StatisticManager.patch +++ b/paper-server/nms-patches/net/minecraft/stats/StatisticManager.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/stats/StatisticManager.java +++ b/net/minecraft/stats/StatisticManager.java @@ -16,6 +16,12 @@ - public void b(EntityHuman entityhuman, Statistic<?> statistic, int i) { - int j = (int) Math.min((long) this.getStatisticValue(statistic) + (long) i, 2147483647L); + public void increment(EntityHuman entityhuman, Statistic<?> statistic, int i) { + int j = (int) Math.min((long) this.getValue(statistic) + (long) i, 2147483647L); + // CraftBukkit start - fire Statistic events -+ org.bukkit.event.Cancellable cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.handleStatisticsIncrease(entityhuman, statistic, this.getStatisticValue(statistic), j); ++ org.bukkit.event.Cancellable cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.handleStatisticsIncrease(entityhuman, statistic, this.getValue(statistic), j); + if (cancellable != null && cancellable.isCancelled()) { + return; + } + // CraftBukkit end - this.setStatistic(entityhuman, statistic, j); + this.setValue(entityhuman, statistic, j); } diff --git a/paper-server/nms-patches/net/minecraft/util/InclusiveRange.patch b/paper-server/nms-patches/net/minecraft/util/InclusiveRange.patch new file mode 100644 index 0000000000..97035cba77 --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/util/InclusiveRange.patch @@ -0,0 +1,47 @@ +--- a/net/minecraft/util/InclusiveRange.java ++++ b/net/minecraft/util/InclusiveRange.java +@@ -4,19 +4,23 @@ + import com.mojang.serialization.DataResult; + import java.util.function.Function; + +-public final class InclusiveRange extends Record { ++// CraftBukkit start - decompile error ++public final record InclusiveRange<T extends Comparable<T>>(T minInclusive, T maxInclusive) { + ++ /* + private final T minInclusive; + private final T maxInclusive; ++ */ + public static final Codec<InclusiveRange<Integer>> INT = codec(Codec.INT); + +- public InclusiveRange(T t0, T t1) { +- if (t0.compareTo(t1) > 0) { ++ public InclusiveRange(T minInclusive, T maxInclusive) { ++ if (minInclusive.compareTo(maxInclusive) > 0) { + throw new IllegalArgumentException("min_inclusive must be less than or equal to max_inclusive"); + } else { +- this.minInclusive = t0; +- this.maxInclusive = t1; ++ this.minInclusive = minInclusive; ++ this.maxInclusive = maxInclusive; + } ++ // CraftBukkit end + } + + public static <T extends Comparable<T>> Codec<InclusiveRange<T>> codec(Codec<T> codec) { +@@ -47,6 +51,8 @@ + return "[" + this.minInclusive + ", " + this.maxInclusive + "]"; + } + ++ // CraftBukkit start ++ /* + public final int hashCode() { + return this.hashCode < invokedynamic > (this); + } +@@ -62,4 +68,6 @@ + public T maxInclusive() { + return this.maxInclusive; + } ++ */ ++ // CraftBukkit end + } diff --git a/paper-server/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch b/paper-server/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch index ecdefd48be..8889bbc25d 100644 --- a/paper-server/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch +++ b/paper-server/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/datafix/DataConverterRegistry.java +++ b/net/minecraft/util/datafix/DataConverterRegistry.java -@@ -380,6 +380,18 @@ +@@ -391,6 +391,18 @@ datafixerbuilder.addFixer(new DataConverterItemFrame(schema46, false)); Schema schema47 = datafixerbuilder.addSchema(1458, DataConverterRegistry.SAME_NAMESPACED); @@ -10,7 +10,7 @@ + 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.a(dynamic); ++ return DataConverterCustomNameEntity.fixTagCustomName(dynamic); + }); + }); + } @@ -19,7 +19,7 @@ datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema47, false)); datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema47, false)); datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema47, false)); -@@ -693,17 +705,20 @@ +@@ -704,12 +716,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); @@ -27,19 +27,22 @@ + // CraftBukkit - decompile error + ImmutableMap<String, String> immutablemap = ImmutableMap.<String, String>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.a(schema131, "Renamed copper block items to new oxidized terms", a((Map) immutablemap))); - datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.b(schema131, "Renamed copper blocks to new oxidized terms", a((Map) immutablemap))); + datafixerbuilder.addFixer(DataConverterItemName.create(schema131, "Renamed copper block items to new oxidized terms", createRenamer(immutablemap))); + datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema131, "Renamed copper blocks to new oxidized terms", createRenamer(immutablemap))); Schema schema132 = datafixerbuilder.addSchema(2691, DataConverterRegistry.SAME_NAMESPACED); - ImmutableMap<String, String> 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<String, String> immutablemap1 = ImmutableMap.<String, String>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.a(schema132, "Rename copper item suffixes", a((Map) immutablemap1))); - datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.b(schema132, "Rename copper blocks suffixes", a((Map) immutablemap1))); - Schema schema133 = datafixerbuilder.addSchema(2696, DataConverterRegistry.SAME_NAMESPACED); + datafixerbuilder.addFixer(DataConverterItemName.create(schema132, "Rename copper item suffixes", createRenamer(immutablemap1))); + datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema132, "Rename copper blocks suffixes", createRenamer(immutablemap1))); +@@ -717,7 +731,8 @@ + + datafixerbuilder.addFixer(new AddFlagIfNotPresentFix(schema133, DataConverterTypes.WORLD_GEN_SETTINGS, "has_increased_height_already", false)); + Schema schema134 = datafixerbuilder.addSchema(2696, DataConverterRegistry.SAME_NAMESPACED); - ImmutableMap<String, String> 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<String, String> immutablemap2 = ImmutableMap.<String, String>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.a(schema133, "Renamed grimstone block items to deepslate", a((Map) immutablemap2))); - datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.b(schema133, "Renamed grimstone blocks to deepslate", a((Map) immutablemap2))); + datafixerbuilder.addFixer(DataConverterItemName.create(schema134, "Renamed grimstone block items to deepslate", createRenamer(immutablemap2))); + datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema134, "Renamed grimstone blocks to deepslate", createRenamer(immutablemap2))); diff --git a/paper-server/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch b/paper-server/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch index 92b747b761..f30ef34c84 100644 --- a/paper-server/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch +++ b/paper-server/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/worldupdate/WorldUpgrader.java +++ b/net/minecraft/util/worldupdate/WorldUpgrader.java -@@ -34,11 +34,15 @@ +@@ -38,6 +38,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -11,43 +11,33 @@ public class WorldUpgrader { private static final Logger LOGGER = LogManager.getLogger(); - private static final ThreadFactory THREAD_FACTORY = (new ThreadFactoryBuilder()).setDaemon(true).build(); -- private final ImmutableSet<ResourceKey<World>> levels; -+ private final ImmutableSet<ResourceKey<DimensionManager>> levels; // CraftBukkit - private final boolean eraseCache; - private final Convertable.ConversionSession levelStorage; - private final Thread thread; -@@ -49,12 +53,12 @@ +@@ -53,7 +57,7 @@ private volatile int totalChunks; private volatile int converted; private volatile int skipped; -- private final Object2FloatMap<ResourceKey<World>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.k())); -+ private final Object2FloatMap<ResourceKey<DimensionManager>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.k())); // CraftBukkit +- private final Object2FloatMap<ResourceKey<World>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.identityStrategy())); ++ private final Object2FloatMap<ResourceKey<DimensionManager>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.identityStrategy())); // CraftBukkit private volatile IChatBaseComponent status = new ChatMessage("optimizeWorld.stage.counting"); private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$"); private final WorldPersistentData overworldDataStorage; +@@ -86,13 +90,13 @@ -- public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, ImmutableSet<ResourceKey<World>> immutableset, boolean flag) { -+ public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, ImmutableSet<ResourceKey<DimensionManager>> immutableset, boolean flag) { // CraftBukkit - this.levels = immutableset; - this.eraseCache = flag; - this.dataFixer = datafixer; -@@ -82,12 +86,12 @@ - - private void i() { + private void work() { this.totalChunks = 0; - Builder<ResourceKey<World>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder(); +- ImmutableSet<ResourceKey<World>> immutableset = this.worldGenSettings.levels(); + Builder<ResourceKey<DimensionManager>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder(); // CraftBukkit ++ ImmutableSet<ResourceKey<DimensionManager>> immutableset = this.worldGenSettings.levels(); // CraftBukkit List list; - for (UnmodifiableIterator unmodifiableiterator = this.levels.iterator(); unmodifiableiterator.hasNext(); this.totalChunks += list.size()) { + for (UnmodifiableIterator unmodifiableiterator = immutableset.iterator(); unmodifiableiterator.hasNext(); this.totalChunks += list.size()) { - ResourceKey<World> resourcekey = (ResourceKey) unmodifiableiterator.next(); + ResourceKey<DimensionManager> resourcekey = (ResourceKey) unmodifiableiterator.next(); // CraftBukkit - list = this.b(resourcekey); + list = this.getAllChunkPos(resourcekey); builder.put(resourcekey, list.listIterator()); -@@ -97,18 +101,18 @@ +@@ -102,18 +106,18 @@ this.finished = true; } else { float f = (float) this.totalChunks; @@ -55,57 +45,57 @@ - Builder<ResourceKey<World>, IChunkLoader> builder1 = ImmutableMap.builder(); + ImmutableMap<ResourceKey<DimensionManager>, ListIterator<ChunkCoordIntPair>> immutablemap = builder.build(); // CraftBukkit + Builder<ResourceKey<DimensionManager>, IChunkLoader> builder1 = ImmutableMap.builder(); // CraftBukkit - UnmodifiableIterator unmodifiableiterator1 = this.levels.iterator(); + UnmodifiableIterator unmodifiableiterator1 = immutableset.iterator(); while (unmodifiableiterator1.hasNext()) { - ResourceKey<World> resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); -- File file = this.levelStorage.a(resourcekey1); +- Path path = this.levelStorage.getDimensionPath(resourcekey1); + ResourceKey<DimensionManager> resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); // CraftBukkit -+ File file = this.levelStorage.a((ResourceKey) null); // CraftBukkit ++ Path path = this.levelStorage.getDimensionPath((ResourceKey) null); // CraftBukkit - builder1.put(resourcekey1, new IChunkLoader(new File(file, "region"), this.dataFixer, true)); + builder1.put(resourcekey1, new IChunkLoader(path.resolve("region"), this.dataFixer, true)); } - ImmutableMap<ResourceKey<World>, IChunkLoader> immutablemap1 = builder1.build(); + ImmutableMap<ResourceKey<DimensionManager>, IChunkLoader> immutablemap1 = builder1.build(); // CraftBukkit - long i = SystemUtils.getMonotonicMillis(); + long i = SystemUtils.getMillis(); this.status = new ChatMessage("optimizeWorld.stage.upgrading"); -@@ -120,7 +124,7 @@ +@@ -125,7 +129,7 @@ float f2; - for (UnmodifiableIterator unmodifiableiterator2 = this.levels.iterator(); unmodifiableiterator2.hasNext(); f1 += f2) { + for (UnmodifiableIterator unmodifiableiterator2 = immutableset.iterator(); unmodifiableiterator2.hasNext(); f1 += f2) { - ResourceKey<World> resourcekey2 = (ResourceKey) unmodifiableiterator2.next(); + ResourceKey<DimensionManager> resourcekey2 = (ResourceKey) unmodifiableiterator2.next(); // CraftBukkit ListIterator<ChunkCoordIntPair> listiterator = (ListIterator) immutablemap.get(resourcekey2); IChunkLoader ichunkloader = (IChunkLoader) immutablemap1.get(resourcekey2); -@@ -135,7 +139,7 @@ - int j = IChunkLoader.a(nbttagcompound); - NBTTagCompound nbttagcompound1 = ichunkloader.getChunkData(resourcekey2, () -> { +@@ -141,7 +145,7 @@ + ChunkGenerator chunkgenerator = ((WorldDimension) this.worldGenSettings.dimensions().get(GeneratorSettings.levelToLevelStem(resourcekey2))).generator(); + NBTTagCompound nbttagcompound1 = ichunkloader.upgradeChunkTag(resourcekey2, () -> { return this.overworldDataStorage; -- }, nbttagcompound); -+ }, nbttagcompound, chunkcoordintpair, null); // CraftBukkit - NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompound("Level"); - ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound2.getInt("xPos"), nbttagcompound2.getInt("zPos")); +- }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer()); ++ }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer(), chunkcoordintpair, null); // CraftBukkit + ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos")); -@@ -208,8 +212,8 @@ + if (!chunkcoordintpair1.equals(chunkcoordintpair)) { +@@ -213,8 +217,8 @@ } } -- private List<ChunkCoordIntPair> b(ResourceKey<World> resourcekey) { -- File file = this.levelStorage.a(resourcekey); -+ private List<ChunkCoordIntPair> b(ResourceKey<DimensionManager> resourcekey) { // CraftBukkit -+ File file = this.levelStorage.a((ResourceKey) null); // CraftBukkit +- private List<ChunkCoordIntPair> getAllChunkPos(ResourceKey<World> resourcekey) { +- File file = this.levelStorage.getDimensionPath(resourcekey).toFile(); ++ private List<ChunkCoordIntPair> getAllChunkPos(ResourceKey<DimensionManager> resourcekey) { // CraftBukkit ++ File file = this.levelStorage.getDimensionPath((ResourceKey) null).toFile(); // CraftBukkit File file1 = new File(file, "region"); File[] afile = file1.listFiles((file2, s) -> { return s.endsWith(".mca"); -@@ -269,7 +273,7 @@ +@@ -274,7 +278,7 @@ } - public ImmutableSet<ResourceKey<World>> c() { -- return this.levels; + public ImmutableSet<ResourceKey<World>> levels() { +- return this.worldGenSettings.levels(); + throw new AssertionError("Unsupported"); // CraftBukkit } - public float a(ResourceKey<World> resourcekey) { + public float dimensionProgress(ResourceKey<World> resourcekey) { diff --git a/paper-server/nms-patches/net/minecraft/world/ChestLock.patch b/paper-server/nms-patches/net/minecraft/world/ChestLock.patch index 46ebc23735..424ef2ca00 100644 --- a/paper-server/nms-patches/net/minecraft/world/ChestLock.patch +++ b/paper-server/nms-patches/net/minecraft/world/ChestLock.patch @@ -15,21 +15,21 @@ @@ -16,7 +21,19 @@ } - public boolean a(ItemStack itemstack) { -- return this.key.isEmpty() || !itemstack.isEmpty() && itemstack.hasName() && this.key.equals(itemstack.getName().getString()); + public boolean unlocksWith(ItemStack itemstack) { +- return this.key.isEmpty() || !itemstack.isEmpty() && itemstack.hasCustomHoverName() && this.key.equals(itemstack.getHoverName().getString()); + // CraftBukkit start - SPIGOT-6307: Check for color codes if the lock contains color codes + if (this.key.isEmpty()) return true; -+ if (!itemstack.isEmpty() && itemstack.hasName()) { ++ if (!itemstack.isEmpty() && itemstack.hasCustomHoverName()) { + if (this.key.indexOf(ChatColor.COLOR_CHAR) == -1) { + // The lock key contains no color codes, so let's ignore colors in the item display name (vanilla Minecraft behavior): -+ return this.key.equals(itemstack.getName().getString()); ++ return this.key.equals(itemstack.getHoverName().getString()); + } else { + // The lock key contains color codes, so let's take them into account: -+ return this.key.equals(CraftChatMessage.fromComponent(itemstack.getName())); ++ return this.key.equals(CraftChatMessage.fromComponent(itemstack.getHoverName())); + } + } + return false; + // CraftBukkit end } - public void a(NBTTagCompound nbttagcompound) { + public void addToTag(NBTTagCompound nbttagcompound) { diff --git a/paper-server/nms-patches/net/minecraft/world/IInventory.patch b/paper-server/nms-patches/net/minecraft/world/IInventory.patch index 45c87882dd..8e527d98a1 100644 --- a/paper-server/nms-patches/net/minecraft/world/IInventory.patch +++ b/paper-server/nms-patches/net/minecraft/world/IInventory.patch @@ -21,7 +21,7 @@ - } + int getMaxStackSize(); // CraftBukkit - void update(); + void setChanged(); @@ -62,4 +65,29 @@ diff --git a/paper-server/nms-patches/net/minecraft/world/InventoryLargeChest.patch b/paper-server/nms-patches/net/minecraft/world/InventoryLargeChest.patch index d3be7ec5ce..871fff1b74 100644 --- a/paper-server/nms-patches/net/minecraft/world/InventoryLargeChest.patch +++ b/paper-server/nms-patches/net/minecraft/world/InventoryLargeChest.patch @@ -22,8 +22,8 @@ + public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); + + public List<ItemStack> getContents() { -+ List<ItemStack> result = new ArrayList<ItemStack>(this.getSize()); -+ for (int i = 0; i < this.getSize(); i++) { ++ List<ItemStack> result = new ArrayList<ItemStack>(this.getContainerSize()); ++ for (int i = 0; i < this.getContainerSize(); i++) { + result.add(this.getItem(i)); + } + return result; @@ -61,9 +61,9 @@ + // CraftBukkit end + public InventoryLargeChest(IInventory iinventory, IInventory iinventory1) { - if (iinventory == null) { - iinventory = iinventory1; -@@ -62,7 +113,7 @@ + this.container1 = iinventory; + this.container2 = iinventory1; +@@ -54,7 +105,7 @@ @Override public int getMaxStackSize() { diff --git a/paper-server/nms-patches/net/minecraft/world/InventorySubcontainer.patch b/paper-server/nms-patches/net/minecraft/world/InventorySubcontainer.patch index 1e8edf978d..c77b2aa78e 100644 --- a/paper-server/nms-patches/net/minecraft/world/InventorySubcontainer.patch +++ b/paper-server/nms-patches/net/minecraft/world/InventorySubcontainer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/InventorySubcontainer.java +++ b/net/minecraft/world/InventorySubcontainer.java -@@ -13,13 +13,71 @@ +@@ -14,6 +14,12 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -13,7 +13,8 @@ public class InventorySubcontainer implements IInventory, AutoRecipeOutput { private final int size; - public final NonNullList<ItemStack> items; +@@ -21,7 +27,59 @@ + @Nullable private List<IInventoryListener> listeners; + // CraftBukkit start - add fields and methods @@ -58,7 +59,7 @@ + public InventorySubcontainer(InventorySubcontainer original) { + this(original.size); + for (int slot = 0; slot < original.size; slot++) { -+ this.items.set(slot, original.items.get(slot).cloneItemStack()); ++ this.items.set(slot, original.items.get(slot).copy()); + } + } + @@ -70,5 +71,5 @@ + this.bukkitOwner = owner; + // CraftBukkit end this.size = i; - this.items = NonNullList.a(i, ItemStack.EMPTY); + this.items = NonNullList.withSize(i, ItemStack.EMPTY); } diff --git a/paper-server/nms-patches/net/minecraft/world/damagesource/DamageSource.patch b/paper-server/nms-patches/net/minecraft/world/damagesource/DamageSource.patch index 74eeac7035..0d3349504b 100644 --- a/paper-server/nms-patches/net/minecraft/world/damagesource/DamageSource.patch +++ b/paper-server/nms-patches/net/minecraft/world/damagesource/DamageSource.patch @@ -17,5 +17,5 @@ + } + // CraftBukkit end - public static DamageSource b(EntityLiving entityliving) { + public static DamageSource sting(EntityLiving entityliving) { return new EntityDamageSource("sting", entityliving); diff --git a/paper-server/nms-patches/net/minecraft/world/damagesource/EntityDamageSourceIndirect.patch b/paper-server/nms-patches/net/minecraft/world/damagesource/EntityDamageSourceIndirect.patch index 5b6a15488b..bd9c6e2370 100644 --- a/paper-server/nms-patches/net/minecraft/world/damagesource/EntityDamageSourceIndirect.patch +++ b/paper-server/nms-patches/net/minecraft/world/damagesource/EntityDamageSourceIndirect.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/damagesource/EntityDamageSourceIndirect.java @@ -38,4 +38,10 @@ - return !itemstack.isEmpty() && itemstack.hasName() ? new ChatMessage(s1, new Object[]{entityliving.getScoreboardDisplayName(), ichatbasecomponent, itemstack.G()}) : new ChatMessage(s, new Object[]{entityliving.getScoreboardDisplayName(), ichatbasecomponent}); + return !itemstack.isEmpty() && itemstack.hasCustomHoverName() ? new ChatMessage(s1, new Object[]{entityliving.getDisplayName(), ichatbasecomponent, itemstack.getDisplayName()}) : new ChatMessage(s, new Object[]{entityliving.getDisplayName(), ichatbasecomponent}); } + + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/world/effect/MobEffectList.patch b/paper-server/nms-patches/net/minecraft/world/effect/MobEffectList.patch index ce57471cd3..5feec7d80f 100644 --- a/paper-server/nms-patches/net/minecraft/world/effect/MobEffectList.patch +++ b/paper-server/nms-patches/net/minecraft/world/effect/MobEffectList.patch @@ -15,7 +15,7 @@ private final Map<AttributeBase, AttributeModifier> attributeModifiers = Maps.newHashMap(); @@ -44,26 +51,37 @@ - public void tick(EntityLiving entityliving, int i) { + public void applyEffectTick(EntityLiving entityliving, int i) { if (this == MobEffects.REGENERATION) { if (entityliving.getHealth() < entityliving.getMaxHealth()) { - entityliving.heal(1.0F); @@ -23,14 +23,14 @@ } } else if (this == MobEffects.POISON) { if (entityliving.getHealth() > 1.0F) { -- entityliving.damageEntity(DamageSource.MAGIC, 1.0F); -+ entityliving.damageEntity(CraftEventFactory.POISON, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON +- entityliving.hurt(DamageSource.MAGIC, 1.0F); ++ entityliving.hurt(CraftEventFactory.POISON, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON } } else if (this == MobEffects.WITHER) { - entityliving.damageEntity(DamageSource.WITHER, 1.0F); + entityliving.hurt(DamageSource.WITHER, 1.0F); } else if (this == MobEffects.HUNGER && entityliving instanceof EntityHuman) { -- ((EntityHuman) entityliving).applyExhaustion(0.005F * (float) (i + 1)); -+ ((EntityHuman) entityliving).applyExhaustion(0.005F * (float) (i + 1), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.HUNGER_EFFECT); // CraftBukkit - EntityExhaustionEvent +- ((EntityHuman) entityliving).causeFoodExhaustion(0.005F * (float) (i + 1)); ++ ((EntityHuman) entityliving).causeFoodExhaustion(0.005F * (float) (i + 1), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.HUNGER_EFFECT); // CraftBukkit - EntityExhaustionEvent } else if (this == MobEffects.SATURATION && entityliving instanceof EntityHuman) { if (!entityliving.level.isClientSide) { - ((EntityHuman) entityliving).getFoodData().eat(i + 1, 1.0F); @@ -44,12 +44,12 @@ + entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F); + } + -+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel)); ++ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel)); + // CraftBukkit end } - } else if ((this != MobEffects.HEAL || entityliving.dT()) && (this != MobEffects.HARM || !entityliving.dT())) { - if (this == MobEffects.HARM && !entityliving.dT() || this == MobEffects.HEAL && entityliving.dT()) { - entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i)); + } else if ((this != MobEffects.HEAL || entityliving.isInvertedHealAndHarm()) && (this != MobEffects.HARM || !entityliving.isInvertedHealAndHarm())) { + if (this == MobEffects.HARM && !entityliving.isInvertedHealAndHarm() || this == MobEffects.HEAL && entityliving.isInvertedHealAndHarm()) { + entityliving.hurt(DamageSource.MAGIC, (float) (6 << i)); } } else { - entityliving.heal((float) Math.max(4 << i, 0)); diff --git a/paper-server/nms-patches/net/minecraft/world/effect/MobEffects.patch b/paper-server/nms-patches/net/minecraft/world/effect/MobEffects.patch index e9a9096b4c..ab46c0f525 100644 --- a/paper-server/nms-patches/net/minecraft/world/effect/MobEffects.patch +++ b/paper-server/nms-patches/net/minecraft/world/effect/MobEffects.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/effect/MobEffects.java @@ -65,6 +65,14 @@ }); - public static final MobEffectList HERO_OF_THE_VILLAGE = a(32, "hero_of_the_village", new MobEffectList(MobEffectInfo.BENEFICIAL, 4521796)); + public static final MobEffectList HERO_OF_THE_VILLAGE = register(32, "hero_of_the_village", new MobEffectList(MobEffectInfo.BENEFICIAL, 4521796)); + // CraftBukkit start + static { @@ -14,4 +14,4 @@ + public MobEffects() {} - private static MobEffectList a(int i, String s, MobEffectList mobeffectlist) { + private static MobEffectList register(int i, String s, MobEffectList mobeffectlist) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch b/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch index 9e56d85885..e6cb581ec9 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -116,8 +116,58 @@ +@@ -117,8 +117,58 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -38,7 +38,7 @@ + // CraftBukkit start + private static final int CURRENT_LEVEL = 2; + static boolean isLevelAtLeast(NBTTagCompound tag, int level) { -+ return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level; ++ return tag.contains("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level; + } + + private CraftEntity bukkitEntity; @@ -59,10 +59,10 @@ protected static final Logger LOGGER = LogManager.getLogger(); public static final String ID_TAG = "id"; public static final String PASSENGERS_TAG = "Passengers"; -@@ -224,6 +274,22 @@ - private float crystalSoundIntensity; - private int lastCrystalSoundPlayTick; +@@ -229,6 +279,22 @@ public boolean hasVisualFire; + @Nullable + private IBlockData feetBlockState; + // CraftBukkit start + public boolean persist = true; + public boolean valid; @@ -76,14 +76,14 @@ + } + + public boolean isChunkLoaded() { -+ return level.isChunkLoaded((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4); ++ return level.hasChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4); + } + // CraftBukkit end public Entity(EntityTypes<?> entitytypes, World world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -359,6 +425,12 @@ - public void ae() {} +@@ -366,6 +432,12 @@ + public void onClientRemoval() {} public void setPose(EntityPose entitypose) { + // CraftBukkit start @@ -95,10 +95,10 @@ this.entityData.set(Entity.DATA_POSE, entitypose); } -@@ -375,6 +447,33 @@ +@@ -382,6 +454,33 @@ } - protected void setYawPitch(float f, float f1) { + protected void setRot(float f, float f1) { + // CraftBukkit start - yaw was sometimes set to NaN, so we need to set it back to 0 + if (Float.isNaN(f)) { + f = 0; @@ -106,7 +106,7 @@ + + if (f == Float.POSITIVE_INFINITY || f == Float.NEGATIVE_INFINITY) { + if (this instanceof EntityPlayer) { -+ this.level.getCraftServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid yaw"); ++ this.level.getCraftServer().getLogger().warning(this.getScoreboardName() + " was caught trying to crash the server with an invalid yaw"); + ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite yaw (Hacking?)"); + } + f = 0; @@ -119,7 +119,7 @@ + + if (f1 == Float.POSITIVE_INFINITY || f1 == Float.NEGATIVE_INFINITY) { + if (this instanceof EntityPlayer) { -+ this.level.getCraftServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid pitch"); ++ this.level.getCraftServer().getLogger().warning(this.getScoreboardName() + " was caught trying to crash the server with an invalid pitch"); + ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite pitch (Hacking?)"); + } + f1 = 0; @@ -129,36 +129,36 @@ this.setYRot(f % 360.0F); this.setXRot(f1 % 360.0F); } -@@ -416,6 +515,15 @@ - this.entityBaseTick(); +@@ -423,6 +522,15 @@ + this.baseTick(); } + // CraftBukkit start + public void postTick() { + // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle + if (!(this instanceof EntityPlayer)) { -+ this.doPortalTick(); ++ this.handleNetherPortal(); + } + } + // CraftBukkit end + - public void entityBaseTick() { - this.level.getMethodProfiler().enter("entityBaseTick"); + public void baseTick() { + this.level.getProfiler().push("entityBaseTick"); if (this.isPassenger() && this.getVehicle().isRemoved()) { -@@ -429,7 +537,7 @@ +@@ -436,7 +544,7 @@ this.walkDistO = this.walkDist; this.xRotO = this.getXRot(); this.yRotO = this.getYRot(); -- this.doPortalTick(); -+ if (this instanceof EntityPlayer) this.doPortalTick(); // CraftBukkit - // Moved up to postTick - if (this.aV()) { - this.aW(); +- this.handleNetherPortal(); ++ if (this instanceof EntityPlayer) this.handleNetherPortal(); // CraftBukkit - // Moved up to postTick + if (this.canSpawnSprintParticle()) { + this.spawnSprintParticle(); } -@@ -507,7 +615,23 @@ +@@ -514,7 +622,23 @@ - public void burnFromLava() { - if (!this.isFireProof()) { -- this.setOnFire(15); + public void lavaHurt() { + if (!this.fireImmune()) { +- this.setSecondsOnFire(15); + // CraftBukkit start - Fallen in lava TODO: this event spams! + if (this instanceof EntityLiving && remainingFireTicks <= 0) { + // not on fire yet @@ -169,25 +169,25 @@ + this.level.getCraftServer().getPluginManager().callEvent(combustEvent); + + if (!combustEvent.isCancelled()) { -+ this.setOnFire(combustEvent.getDuration(), false); ++ this.setSecondsOnFire(combustEvent.getDuration(), false); + } + } else { + // This will be called every single tick the entity is in lava, so don't throw an event -+ this.setOnFire(15, false); ++ this.setSecondsOnFire(15, false); + } + // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls - if (this.damageEntity(DamageSource.LAVA, 4.0F)) { + if (this.hurt(DamageSource.LAVA, 4.0F)) { this.playSound(SoundEffects.GENERIC_BURN, 0.4F, 2.0F + this.random.nextFloat() * 0.4F); } -@@ -516,6 +640,22 @@ +@@ -523,6 +647,22 @@ } - public void setOnFire(int i) { + public void setSecondsOnFire(int i) { + // CraftBukkit start -+ this.setOnFire(i, true); ++ this.setSecondsOnFire(i, true); + } + -+ public void setOnFire(int i, boolean callEvent) { ++ public void setSecondsOnFire(int i, boolean callEvent) { + if (callEvent) { + EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), i); + this.level.getCraftServer().getPluginManager().callEvent(event); @@ -202,14 +202,14 @@ int j = i * 20; if (this instanceof EntityLiving) { -@@ -614,6 +754,28 @@ - block.a((IBlockAccess) this.level, this); +@@ -627,6 +767,28 @@ + block.updateEntityAfterFallOn(this.level, this); } + // CraftBukkit start + if (horizontalCollision && getBukkitEntity() instanceof Vehicle) { + Vehicle vehicle = (Vehicle) this.getBukkitEntity(); -+ org.bukkit.block.Block bl = this.level.getWorld().getBlockAt(MathHelper.floor(this.locX()), MathHelper.floor(this.locY()), MathHelper.floor(this.locZ())); ++ org.bukkit.block.Block bl = this.level.getWorld().getBlockAt(MathHelper.floor(this.getX()), MathHelper.floor(this.getY()), MathHelper.floor(this.getZ())); + + if (vec3d.x > vec3d1.x) { + bl = bl.getRelative(BlockFace.EAST); @@ -228,43 +228,52 @@ + } + // CraftBukkit end + - if (this.onGround && !this.bE()) { + if (this.onGround && !this.isSteppingCarefully()) { block.stepOn(this.level, blockposition, iblockdata, this); } -@@ -1276,6 +1438,7 @@ +@@ -846,7 +1008,7 @@ + boolean flag4 = flag && flag1 || flag && flag2 || flag1 && flag2; + + if (flag4) { +- List<VoxelShape> list1 = flag3 ? ImmutableList.builderWithExpectedSize(list.size() + 1).addAll(list).add(worldborder.getCollisionShape()).build() : list; ++ List<VoxelShape> list1 = flag3 ? ImmutableList.<VoxelShape>builderWithExpectedSize(list.size() + 1).addAll(list).add(worldborder.getCollisionShape()).build() : list; // CraftBukkit - decompile error + + return collideBoundingBox(vec3d, axisalignedbb, world, voxelshapecollision, (List) list1); + } else { +@@ -1306,6 +1468,7 @@ this.yo = d1; this.zo = d4; - this.setPosition(d3, d1, d4); -+ if (valid) level.getChunkAt((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4); // CraftBukkit + this.setPos(d3, d1, d4); ++ if (valid) level.getChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4); // CraftBukkit } - public void d(Vec3D vec3d) { -@@ -1466,6 +1629,12 @@ + public void moveTo(Vec3D vec3d) { +@@ -1496,6 +1659,12 @@ return false; } + // CraftBukkit start - collidable API + public boolean canCollideWithBukkit(Entity entity) { -+ return isCollidable(); ++ return isPushable(); + } + // CraftBukkit end + - public void a(Entity entity, int i, DamageSource damagesource) { + public void awardKillScore(Entity entity, int i, DamageSource damagesource) { if (entity instanceof EntityPlayer) { - CriterionTriggers.ENTITY_KILLED_PLAYER.a((EntityPlayer) entity, this, damagesource); -@@ -1499,7 +1668,7 @@ + CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource); +@@ -1529,7 +1698,7 @@ } else { - String s = this.getSaveID(); + String s = this.getEncodeId(); - if (s == null) { + if (!this.persist || s == null) { // CraftBukkit - persist flag return false; } else { - nbttagcompound.setString("id", s); -@@ -1524,6 +1693,18 @@ - Vec3D vec3d = this.getMot(); + nbttagcompound.putString("id", s); +@@ -1554,6 +1723,18 @@ + Vec3D vec3d = this.getDeltaMovement(); - nbttagcompound.set("Motion", this.newDoubleList(vec3d.x, vec3d.y, vec3d.z)); + nbttagcompound.put("Motion", this.newDoubleList(vec3d.x, vec3d.y, vec3d.z)); + + // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero + // TODO: make sure this is the best way to address this. @@ -277,29 +286,29 @@ + } + // CraftBukkit end + - nbttagcompound.set("Rotation", this.newFloatList(this.getYRot(), this.getXRot())); - nbttagcompound.setFloat("FallDistance", this.fallDistance); - nbttagcompound.setShort("Fire", (short) this.remainingFireTicks); -@@ -1532,6 +1713,18 @@ - nbttagcompound.setBoolean("Invulnerable", this.invulnerable); - nbttagcompound.setInt("PortalCooldown", this.portalCooldown); - nbttagcompound.a("UUID", this.getUniqueID()); + nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot())); + nbttagcompound.putFloat("FallDistance", this.fallDistance); + nbttagcompound.putShort("Fire", (short) this.remainingFireTicks); +@@ -1562,6 +1743,18 @@ + nbttagcompound.putBoolean("Invulnerable", this.invulnerable); + nbttagcompound.putInt("PortalCooldown", this.portalCooldown); + nbttagcompound.putUUID("UUID", this.getUUID()); + // CraftBukkit start + // PAIL: Check above UUID reads 1.8 properly, ie: UUIDMost / UUIDLeast -+ nbttagcompound.setLong("WorldUUIDLeast", ((WorldServer) this.level).getWorld().getUID().getLeastSignificantBits()); -+ nbttagcompound.setLong("WorldUUIDMost", ((WorldServer) this.level).getWorld().getUID().getMostSignificantBits()); -+ nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL); ++ nbttagcompound.putLong("WorldUUIDLeast", ((WorldServer) this.level).getWorld().getUID().getLeastSignificantBits()); ++ nbttagcompound.putLong("WorldUUIDMost", ((WorldServer) this.level).getWorld().getUID().getMostSignificantBits()); ++ nbttagcompound.putInt("Bukkit.updateLevel", CURRENT_LEVEL); + if (!this.persist) { -+ nbttagcompound.setBoolean("Bukkit.persist", this.persist); ++ nbttagcompound.putBoolean("Bukkit.persist", this.persist); + } + if (this.persistentInvisibility) { -+ nbttagcompound.setBoolean("Bukkit.invisible", this.persistentInvisibility); ++ nbttagcompound.putBoolean("Bukkit.invisible", this.persistentInvisibility); + } + // CraftBukkit end IChatBaseComponent ichatbasecomponent = this.getCustomName(); if (ichatbasecomponent != null) { -@@ -1599,6 +1792,11 @@ +@@ -1629,6 +1822,11 @@ } } @@ -310,8 +319,8 @@ + // CraftBukkit end return nbttagcompound; } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Saving entity NBT"); -@@ -1680,6 +1878,49 @@ + CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); +@@ -1710,6 +1908,49 @@ } else { throw new IllegalStateException("Entity has invalid position"); } @@ -323,10 +332,10 @@ + // Reset the persistence for tamed animals + if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) { + EntityInsentient entityinsentient = (EntityInsentient) entity; -+ entityinsentient.setPersistenceRequired(!entityinsentient.isTypeNotPersistent(0)); ++ entityinsentient.setPersistenceRequired(!entityinsentient.removeWhenFarAway(0)); + } + } -+ this.persist = !nbttagcompound.hasKey("Bukkit.persist") || nbttagcompound.getBoolean("Bukkit.persist"); ++ this.persist = !nbttagcompound.contains("Bukkit.persist") || nbttagcompound.getBoolean("Bukkit.persist"); + // CraftBukkit end + + // CraftBukkit start - Reset world @@ -337,7 +346,7 @@ + // TODO: Remove World related checks, replaced with WorldUID + String worldName = nbttagcompound.getString("world"); + -+ if (nbttagcompound.hasKey("WorldUUIDMost") && nbttagcompound.hasKey("WorldUUIDLeast")) { ++ if (nbttagcompound.contains("WorldUUIDMost") && nbttagcompound.contains("WorldUUIDLeast")) { + UUID uid = new UUID(nbttagcompound.getLong("WorldUUIDMost"), nbttagcompound.getLong("WorldUUIDLeast")); + bworld = server.getWorld(uid); + } else { @@ -345,13 +354,13 @@ + } + + if (bworld == null) { -+ bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(World.OVERWORLD).getWorld(); ++ bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getLevel(World.OVERWORLD).getWorld(); + } + -+ ((EntityPlayer) this).spawnIn(bworld == null ? null : ((CraftWorld) bworld).getHandle()); ++ ((EntityPlayer) this).setLevel(bworld == null ? null : ((CraftWorld) bworld).getHandle()); + } + this.getBukkitEntity().readBukkitValues(nbttagcompound); -+ if (nbttagcompound.hasKey("Bukkit.invisible")) { ++ if (nbttagcompound.contains("Bukkit.invisible")) { + boolean bukkitInvisible = nbttagcompound.getBoolean("Bukkit.invisible"); + this.setInvisible(bukkitInvisible); + this.persistentInvisibility = bukkitInvisible; @@ -359,9 +368,9 @@ + // CraftBukkit end + } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded"); -@@ -1755,9 +1996,22 @@ + CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); + CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded"); +@@ -1785,9 +2026,22 @@ } else if (this.level.isClientSide) { return null; } else { @@ -371,9 +380,9 @@ + return null; + } + // CraftBukkit end - EntityItem entityitem = new EntityItem(this.level, this.locX(), this.locY() + (double) f, this.locZ(), itemstack); + EntityItem entityitem = new EntityItem(this.level, this.getX(), this.getY() + (double) f, this.getZ(), itemstack); - entityitem.defaultPickupDelay(); + entityitem.setDefaultPickUpDelay(); + // CraftBukkit start + EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); + Bukkit.getPluginManager().callEvent(event); @@ -381,19 +390,19 @@ + return null; + } + // CraftBukkit end - this.level.addEntity(entityitem); + this.level.addFreshEntity(entityitem); return entityitem; } -@@ -1849,7 +2103,7 @@ +@@ -1882,7 +2136,7 @@ this.setPose(EntityPose.STANDING); this.vehicle = entity; - this.vehicle.addPassenger(this); + if (!this.vehicle.addPassenger(this)) this.vehicle = null; // CraftBukkit - entity.n().filter((entity2) -> { + entity.getIndirectPassengersStream().filter((entity2) -> { return entity2 instanceof EntityPlayer; }).forEach((entity2) -> { -@@ -1880,7 +2134,7 @@ +@@ -1913,7 +2167,7 @@ Entity entity = this.vehicle; this.vehicle = null; @@ -402,8 +411,8 @@ } } -@@ -1889,10 +2143,31 @@ - this.bo(); +@@ -1922,10 +2176,31 @@ + this.removeVehicle(); } - protected void addPassenger(Entity entity) { @@ -435,7 +444,7 @@ if (this.passengers.isEmpty()) { this.passengers = ImmutableList.of(entity); } else { -@@ -1908,12 +2183,32 @@ +@@ -1941,12 +2216,32 @@ } } @@ -469,39 +478,39 @@ if (this.passengers.size() == 1 && this.passengers.get(0) == entity) { this.passengers = ImmutableList.of(); } else { -@@ -1924,6 +2219,7 @@ +@@ -1957,6 +2252,7 @@ entity.boardingCooldown = 60; } + return true; // CraftBukkit } - protected boolean o(Entity entity) { -@@ -1974,14 +2270,20 @@ + protected boolean canAddPassenger(Entity entity) { +@@ -2007,14 +2303,20 @@ if (this.isInsidePortal) { - MinecraftServer minecraftserver = worldserver.getMinecraftServer(); -- ResourceKey<World> resourcekey = this.level.getDimensionKey() == World.NETHER ? World.OVERWORLD : World.NETHER; + MinecraftServer minecraftserver = worldserver.getServer(); +- ResourceKey<World> resourcekey = this.level.dimension() == World.NETHER ? World.OVERWORLD : World.NETHER; + ResourceKey<World> resourcekey = this.level.getTypeKey() == DimensionManager.NETHER_LOCATION ? World.OVERWORLD : World.NETHER; // CraftBukkit - WorldServer worldserver1 = minecraftserver.getWorldServer(resourcekey); + WorldServer worldserver1 = minecraftserver.getLevel(resourcekey); -- if (worldserver1 != null && minecraftserver.getAllowNether() && !this.isPassenger() && this.portalTime++ >= i) { +- if (worldserver1 != null && minecraftserver.isNetherEnabled() && !this.isPassenger() && this.portalTime++ >= i) { + if (true && !this.isPassenger() && this.portalTime++ >= i) { // CraftBukkit - this.level.getMethodProfiler().enter("portal"); + this.level.getProfiler().push("portal"); this.portalTime = i; - this.resetPortalCooldown(); -- this.b(worldserver1); + this.setPortalCooldown(); +- this.changeDimension(worldserver1); + // CraftBukkit start + if (this instanceof EntityPlayer) { -+ ((EntityPlayer) this).b(worldserver1, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); ++ ((EntityPlayer) this).changeDimension(worldserver1, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); + } else { -+ this.b(worldserver1); ++ this.changeDimension(worldserver1); + } + // CraftBukkit end - this.level.getMethodProfiler().exit(); + this.level.getProfiler().pop(); } -@@ -2099,6 +2401,13 @@ +@@ -2132,6 +2434,13 @@ } public void setSwimming(boolean flag) { @@ -512,27 +521,27 @@ + } + } + // CraftBukkit end - this.setFlag(4, flag); + this.setSharedFlag(4, flag); } -@@ -2147,8 +2456,12 @@ - return this.getScoreboardTeam() != null ? this.getScoreboardTeam().isAlly(scoreboardteambase) : false; +@@ -2180,8 +2489,12 @@ + return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false; } + // CraftBukkit - start public void setInvisible(boolean flag) { -- this.setFlag(5, flag); +- this.setSharedFlag(5, flag); + if (!this.persistentInvisibility) { // Prevent Minecraft from removing our invisibility flag -+ this.setFlag(5, flag); ++ this.setSharedFlag(5, flag); + } + // CraftBukkit - end } - public boolean getFlag(int i) { -@@ -2175,7 +2488,17 @@ + public boolean getSharedFlag(int i) { +@@ -2208,7 +2521,17 @@ } - public void setAirTicks(int i) { + public void setAirSupply(int i) { - this.entityData.set(Entity.DATA_AIR_SUPPLY_ID, i); + // CraftBukkit start + EntityAirChangeEvent event = new EntityAirChangeEvent(this.getBukkitEntity(), i); @@ -548,10 +557,10 @@ } public int getTicksFrozen() { -@@ -2202,11 +2525,41 @@ +@@ -2235,11 +2558,41 @@ - public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) { - this.setFireTicks(this.remainingFireTicks + 1); + public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { + this.setRemainingFireTicks(this.remainingFireTicks + 1); + // CraftBukkit start + final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity(); + final org.bukkit.entity.Entity stormBukkitEntity = entitylightning.getBukkitEntity(); @@ -559,12 +568,12 @@ + // CraftBukkit end + if (this.remainingFireTicks == 0) { -- this.setOnFire(8); +- this.setSecondsOnFire(8); + // CraftBukkit start - Call a combust event when lightning strikes + EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8); + pluginManager.callEvent(entityCombustEvent); + if (!entityCombustEvent.isCancelled()) { -+ this.setOnFire(entityCombustEvent.getDuration(), false); ++ this.setSecondsOnFire(entityCombustEvent.getDuration(), false); + } + // CraftBukkit end + } @@ -579,23 +588,23 @@ + } } -- this.damageEntity(DamageSource.LIGHTNING_BOLT, 5.0F); -+ if (this.isFireProof()) { +- this.hurt(DamageSource.LIGHTNING_BOLT, 5.0F); ++ if (this.fireImmune()) { + return; + } + CraftEventFactory.entityDamage = entitylightning; -+ if (!this.damageEntity(DamageSource.LIGHTNING_BOLT, 5.0F)) { ++ if (!this.hurt(DamageSource.LIGHTNING_BOLT, 5.0F)) { + CraftEventFactory.entityDamage = null; + return; + } + // CraftBukkit end } - public void k(boolean flag) { -@@ -2356,15 +2709,32 @@ + public void onAboveBubbleCol(boolean flag) { +@@ -2393,15 +2746,32 @@ @Nullable - public Entity b(WorldServer worldserver) { + public Entity changeDimension(WorldServer worldserver) { + // CraftBukkit start + return teleportTo(worldserver, null); + } @@ -604,55 +613,55 @@ + public Entity teleportTo(WorldServer worldserver, BlockPosition location) { + // CraftBukkit end if (this.level instanceof WorldServer && !this.isRemoved()) { - this.level.getMethodProfiler().enter("changeDimension"); -- this.decouple(); + this.level.getProfiler().push("changeDimension"); +- this.unRide(); + // CraftBukkit start + // this.decouple(); + if (worldserver == null) { + return null; + } + // CraftBukkit end - this.level.getMethodProfiler().enter("reposition"); -- ShapeDetectorShape shapedetectorshape = this.a(worldserver); -+ ShapeDetectorShape shapedetectorshape = (location == null) ? this.a(worldserver) : new ShapeDetectorShape(new Vec3D(location.getX(), location.getY(), location.getZ()), Vec3D.ZERO, this.yRot, this.xRot, worldserver, null); // CraftBukkit + this.level.getProfiler().push("reposition"); +- ShapeDetectorShape shapedetectorshape = this.findDimensionEntryPoint(worldserver); ++ ShapeDetectorShape shapedetectorshape = (location == null) ? this.findDimensionEntryPoint(worldserver) : new ShapeDetectorShape(new Vec3D(location.getX(), location.getY(), location.getZ()), Vec3D.ZERO, this.yRot, this.xRot, worldserver, null); // CraftBukkit if (shapedetectorshape == null) { return null; } else { + // CraftBukkit start + worldserver = shapedetectorshape.world; -+ this.decouple(); ++ this.unRide(); + // CraftBukkit end + - this.level.getMethodProfiler().exitEnter("reloading"); - Entity entity = this.getEntityType().a((World) worldserver); + this.level.getProfiler().popPush("reloading"); + Entity entity = this.getType().create(worldserver); -@@ -2373,9 +2743,17 @@ - entity.setPositionRotation(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot()); - entity.setMot(shapedetectorshape.speed); - worldserver.addEntityTeleport(entity); -- if (worldserver.getDimensionKey() == World.END) { -- WorldServer.a(worldserver); +@@ -2410,9 +2780,17 @@ + entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot()); + entity.setDeltaMovement(shapedetectorshape.speed); + worldserver.addDuringTeleport(entity); +- if (worldserver.dimension() == World.END) { +- WorldServer.makeObsidianPlatform(worldserver); + if (worldserver.getTypeKey() == DimensionManager.END_LOCATION) { // CraftBukkit -+ WorldServer.a(worldserver, this); // CraftBukkit ++ WorldServer.makeObsidianPlatform(worldserver, this); // CraftBukkit + } + // CraftBukkit start - Forward the CraftEntity to the new entity + this.getBukkitEntity().setHandle(entity); + entity.bukkitEntity = this.getBukkitEntity(); + + if (this instanceof EntityInsentient) { -+ ((EntityInsentient) this).unleash(true, false); // Unleash to prevent duping of leads. ++ ((EntityInsentient) this).dropLeash(true, false); // Unleash to prevent duping of leads. } + // CraftBukkit end } - this.cc(); -@@ -2396,13 +2774,18 @@ + this.removeAfterChangingDimensions(); +@@ -2433,20 +2811,33 @@ @Nullable - protected ShapeDetectorShape a(WorldServer worldserver) { -- boolean flag = this.level.getDimensionKey() == World.END && worldserver.getDimensionKey() == World.OVERWORLD; -- boolean flag1 = worldserver.getDimensionKey() == World.END; + protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) { +- boolean flag = this.level.dimension() == World.END && worldserver.dimension() == World.OVERWORLD; +- boolean flag1 = worldserver.dimension() == World.END; + // CraftBukkit start + if (worldserver == null) { + return null; @@ -662,18 +671,16 @@ + // CraftBukkit end if (!flag && !flag1) { -- boolean flag2 = worldserver.getDimensionKey() == World.NETHER; +- boolean flag2 = worldserver.dimension() == World.NETHER; + boolean flag2 = worldserver.getTypeKey() == DimensionManager.NETHER_LOCATION; // CraftBukkit -- if (this.level.getDimensionKey() != World.NETHER && !flag2) { +- if (this.level.dimension() != World.NETHER && !flag2) { + if (this.level.getTypeKey() != DimensionManager.NETHER_LOCATION && !flag2) { return null; } else { WorldBorder worldborder = worldserver.getWorldBorder(); -@@ -2412,8 +2795,16 @@ - double d3 = Math.min(2.9999872E7D, worldborder.h() - 16.0D); - double d4 = DimensionManager.a(this.level.getDimensionManager(), worldserver.getDimensionManager()); - BlockPosition blockposition = new BlockPosition(MathHelper.a(this.locX() * d4, d0, d2), this.locY(), MathHelper.a(this.locZ() * d4, d1, d3)); + double d0 = DimensionManager.getTeleportationScale(this.level.dimensionType(), worldserver.dimensionType()); + BlockPosition blockposition = worldborder.clampToBounds(this.getX() * d0, this.getY(), this.getZ() * d0); + // CraftBukkit start + CraftPortalEvent event = callPortalEvent(this, worldserver, blockposition, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16); + if (event == null) { @@ -682,26 +689,26 @@ + final WorldServer worldserverFinal = worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle(); + blockposition = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); -- return (ShapeDetectorShape) this.findOrCreatePortal(worldserver, blockposition, flag2).map((blockutil_rectangle) -> { -+ return (ShapeDetectorShape) this.findOrCreatePortal(worldserver, blockposition, flag2, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius()).map((blockutil_rectangle) -> { +- return (ShapeDetectorShape) this.getExitPortal(worldserver, blockposition, flag2, worldborder).map((blockutil_rectangle) -> { ++ return (ShapeDetectorShape) this.getExitPortal(worldserver, blockposition, flag2, worldborder, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius()).map((blockutil_rectangle) -> { + // CraftBukkit end - IBlockData iblockdata = this.level.getType(this.portalEntrancePos); + IBlockData iblockdata = this.level.getBlockState(this.portalEntrancePos); EnumDirection.EnumAxis enumdirection_enumaxis; Vec3D vec3d; -@@ -2430,8 +2821,8 @@ +@@ -2463,8 +2854,8 @@ vec3d = new Vec3D(0.5D, 0.0D, 0.0D); } -- return BlockPortalShape.a(worldserver, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.a(this.getPose()), this.getMot(), this.getYRot(), this.getXRot()); +- return BlockPortalShape.createPortalInfo(worldserver, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.getDimensions(this.getPose()), this.getDeltaMovement(), this.getYRot(), this.getXRot()); - }).orElse((Object) null); -+ return BlockPortalShape.a(worldserverFinal, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.a(this.getPose()), this.getMot(), this.getYRot(), this.getXRot(), event); // CraftBukkit ++ return BlockPortalShape.createPortalInfo(worldserverFinal, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.getDimensions(this.getPose()), this.getDeltaMovement(), this.getYRot(), this.getXRot(), event); // CraftBukkit + }).orElse(null); // CraftBuukkit - decompile error } } else { BlockPosition blockposition1; -@@ -2441,8 +2832,15 @@ +@@ -2474,8 +2865,15 @@ } else { - blockposition1 = worldserver.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSpawn()); + blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos()); } + // CraftBukkit start + CraftPortalEvent event = callPortalEvent(this, worldserver, blockposition1, PlayerTeleportEvent.TeleportCause.END_PORTAL, 0, 0); @@ -710,18 +717,18 @@ + } + blockposition1 = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); -- return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getMot(), this.getYRot(), this.getXRot()); -+ return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getMot(), this.getYRot(), this.getXRot(), ((CraftWorld) event.getTo().getWorld()).getHandle(), event); +- return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getDeltaMovement(), this.getYRot(), this.getXRot()); ++ return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getDeltaMovement(), this.getYRot(), this.getXRot(), ((CraftWorld) event.getTo().getWorld()).getHandle(), event); + // CraftBukkit end } } -@@ -2450,8 +2848,23 @@ - return BlockPortalShape.a(blockutil_rectangle, enumdirection_enumaxis, this.getPositionVector(), this.a(this.getPose())); +@@ -2483,8 +2881,23 @@ + return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose())); } -- protected Optional<BlockUtil.Rectangle> findOrCreatePortal(WorldServer worldserver, BlockPosition blockposition, boolean flag) { -- return worldserver.getTravelAgent().findPortal(blockposition, flag); +- protected Optional<BlockUtil.Rectangle> getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder) { +- return worldserver.getPortalForcer().findPortalAround(blockposition, flag, worldborder); + // CraftBukkit start + protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, BlockPosition exitPosition, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) { + org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity(); @@ -736,16 +743,16 @@ + return new CraftPortalEvent(event); + } + -+ protected Optional<BlockUtil.Rectangle> findOrCreatePortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, int searchRadius, boolean canCreatePortal, int createRadius) { -+ return worldserver.getTravelAgent().findPortal(blockposition, searchRadius); ++ protected Optional<BlockUtil.Rectangle> getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder, int searchRadius, boolean canCreatePortal, int createRadius) { ++ return worldserver.getPortalForcer().findPortalAround(blockposition, worldborder, searchRadius); + // CraftBukkit end } - public boolean canPortal() { -@@ -2660,7 +3073,26 @@ + public boolean canChangeDimensions() { +@@ -2693,7 +3106,26 @@ } - public final void a(AxisAlignedBB axisalignedbb) { + public final void setBoundingBox(AxisAlignedBB axisalignedbb) { - this.bb = axisalignedbb; + // CraftBukkit start - block invalid bounding boxes + double minX = axisalignedbb.minX, @@ -769,4 +776,4 @@ + // CraftBukkit end } - protected float getHeadHeight(EntityPose entitypose, EntitySize entitysize) { + protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityAgeable.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityAgeable.patch index 58903b2a7a..fa57995fb0 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityAgeable.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityAgeable.patch @@ -9,16 +9,16 @@ protected EntityAgeable(EntityTypes<? extends EntityAgeable> entitytypes, World world) { super(entitytypes, world); @@ -102,6 +103,7 @@ - super.saveData(nbttagcompound); - nbttagcompound.setInt("Age", this.getAge()); - nbttagcompound.setInt("ForcedAge", this.forcedAge); -+ nbttagcompound.setBoolean("AgeLocked", this.ageLocked); // CraftBukkit + super.addAdditionalSaveData(nbttagcompound); + nbttagcompound.putInt("Age", this.getAge()); + nbttagcompound.putInt("ForcedAge", this.forcedAge); ++ nbttagcompound.putBoolean("AgeLocked", this.ageLocked); // CraftBukkit } @Override @@ -109,6 +111,7 @@ - super.loadData(nbttagcompound); - this.setAgeRaw(nbttagcompound.getInt("Age")); + super.readAdditionalSaveData(nbttagcompound); + this.setAge(nbttagcompound.getInt("Age")); this.forcedAge = nbttagcompound.getInt("ForcedAge"); + this.ageLocked = nbttagcompound.getBoolean("AgeLocked"); // CraftBukkit } @@ -26,10 +26,10 @@ @Override @@ -123,7 +126,7 @@ @Override - public void movementTick() { - super.movementTick(); + public void aiStep() { + super.aiStep(); - if (this.level.isClientSide) { + if (this.level.isClientSide || ageLocked) { // CraftBukkit if (this.forcedAgeTimer > 0) { if (this.forcedAgeTimer % 4 == 0) { - this.level.addParticle(Particles.HAPPY_VILLAGER, this.d(1.0D), this.da() + 0.5D, this.g(1.0D), 0.0D, 0.0D, 0.0D); + this.level.addParticle(Particles.HAPPY_VILLAGER, this.getRandomX(1.0D), this.getRandomY() + 0.5D, this.getRandomZ(1.0D), 0.0D, 0.0D, 0.0D); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch index d3bcf93fe5..4a9525c951 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch @@ -20,21 +20,21 @@ + // CraftBukkit start accessor methods + public void refreshEffects() { + if (!this.fixedColor) { -+ this.getDataWatcher().set(EntityAreaEffectCloud.DATA_COLOR, PotionUtil.a((Collection) PotionUtil.a(this.potion, (Collection) this.effects))); // PAIL: rename ++ this.getEntityData().set(EntityAreaEffectCloud.DATA_COLOR, PotionUtil.getColor((Collection) PotionUtil.getAllEffects(this.potion, this.effects))); + } + } + -+ public String getType() { ++ public String getPotionType() { + return ((MinecraftKey) IRegistry.POTION.getKey(this.potion)).toString(); + } + -+ public void setType(String string) { -+ a(IRegistry.POTION.get(new MinecraftKey(string))); ++ public void setPotionType(String string) { ++ setPotion(IRegistry.POTION.get(new MinecraftKey(string))); + } + // CraftBukkit end + public int getColor() { - return (Integer) this.getDataWatcher().get(EntityAreaEffectCloud.DATA_COLOR); + return (Integer) this.getEntityData().get(EntityAreaEffectCloud.DATA_COLOR); } @@ -259,6 +281,7 @@ if (!list1.isEmpty()) { @@ -63,8 +63,8 @@ Iterator iterator2 = list.iterator(); @@ -277,7 +311,7 @@ - if (mobeffect1.getMobEffect().isInstant()) { - mobeffect1.getMobEffect().applyInstantEffect(this, this.getSource(), entityliving, mobeffect1.getAmplifier(), 0.5D); + if (mobeffect1.getEffect().isInstantenous()) { + mobeffect1.getEffect().applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect1.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 diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityCreature.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityCreature.patch index 277b257a92..99e9b9786a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityCreature.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityCreature.patch @@ -10,20 +10,20 @@ + public abstract class EntityCreature extends EntityInsentient { - protected EntityCreature(EntityTypes<? extends EntityCreature> entitytypes, World world) { -@@ -41,6 +45,7 @@ + protected static final float DEFAULT_WALK_TARGET_VALUE = 0.0F; +@@ -43,6 +47,7 @@ - if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isSitting()) { + if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isInSittingPose()) { if (f > 10.0F) { + this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit - this.unleash(true, true); + this.dropLeash(true, true); } -@@ -49,6 +54,7 @@ +@@ -51,6 +56,7 @@ - this.y(f); + this.onLeashDistance(f); if (f > 10.0F) { + this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit - this.unleash(true, true); - this.goalSelector.a(PathfinderGoal.Type.MOVE); + this.dropLeash(true, true); + this.goalSelector.disableControlFlag(PathfinderGoal.Type.MOVE); } else if (f > 6.0F) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch index cdaed47f49..3577ba1290 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch @@ -18,9 +18,9 @@ public void tick() { super.tick(); + EntityHuman prevTarget = this.followingPlayer;// CraftBukkit - store old target - this.xo = this.locX(); - this.yo = this.locY(); - this.zo = this.locZ(); + this.xo = this.getX(); + this.yo = this.getY(); + this.zo = this.getZ(); @@ -84,7 +91,22 @@ this.followingPlayer = null; } @@ -42,22 +42,22 @@ + + if (this.followingPlayer != null && !cancelled) { + // CraftBukkit end - Vec3D vec3d = new Vec3D(this.followingPlayer.locX() - this.locX(), this.followingPlayer.locY() + (double) this.followingPlayer.getHeadHeight() / 2.0D - this.locY(), this.followingPlayer.locZ() - this.locZ()); - double d0 = vec3d.g(); + 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(); @@ -225,7 +247,7 @@ - int i = this.a(entityhuman, this.value); + int i = this.repairPlayerItems(entityhuman, this.value); if (i > 0) { -- entityhuman.giveExp(i); -+ entityhuman.giveExp(CraftEventFactory.callPlayerExpChangeEvent(entityhuman, i).getAmount()); // CraftBukkit - this.value -> event.getAmount() +- entityhuman.giveExperiencePoints(i); ++ entityhuman.giveExperiencePoints(CraftEventFactory.callPlayerExpChangeEvent(entityhuman, i).getAmount()); // CraftBukkit - this.value -> event.getAmount() } --this.count; @@ -243,9 +265,17 @@ if (entry != null) { ItemStack itemstack = (ItemStack) entry.getValue(); - int j = Math.min(this.c(this.value), itemstack.getDamage()); + int j = Math.min(this.xpToDurability(this.value), itemstack.getDamageValue()); + // CraftBukkit start + org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(entityhuman, this, itemstack, j); + j = event.getRepairAmount(); @@ -66,16 +66,16 @@ + } + // CraftBukkit end - itemstack.setDamage(itemstack.getDamage() - j); - int k = i - this.b(j); + itemstack.setDamageValue(itemstack.getDamageValue() - j); + int k = i - this.durabilityToXp(j); + this.value = k; // CraftBukkit - update exp value of orb for PlayerItemMendEvent calls - return k > 0 ? this.a(entityhuman, k) : 0; + return k > 0 ? this.repairPlayerItems(entityhuman, k) : 0; } else { @@ -270,6 +300,24 @@ } - public static int getOrbValue(int i) { + public static int getExperienceValue(int i) { + // CraftBukkit start + if (i > 162670129) return i - 100000; + if (i > 81335063) return 81335063; diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityInsentient.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityInsentient.patch index 2c20ff4d21..8dbdb2e908 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityInsentient.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityInsentient.patch @@ -19,17 +19,8 @@ + public abstract class EntityInsentient extends EntityLiving { - private static final DataWatcherObject<Byte> DATA_MOB_FLAGS_ID = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.BYTE); -@@ -101,7 +114,7 @@ - private final NonNullList<ItemStack> armorItems; - public final float[] armorDropChances; - private boolean canPickUpLoot; -- public boolean persistenceRequired; -+ private boolean persistenceRequired; - private final Map<PathType, Float> pathfindingMalus; - public MinecraftKey lootTable; - public long lootTableSeed; -@@ -113,6 +126,8 @@ + private static final DataWatcherObject<Byte> DATA_MOB_FLAGS_ID = DataWatcher.defineId(EntityInsentient.class, DataWatcherRegistry.BYTE); +@@ -116,6 +129,8 @@ private BlockPosition restrictCenter; private float restrictRadius; @@ -37,13 +28,13 @@ + protected EntityInsentient(EntityTypes<? extends EntityInsentient> entitytypes, World world) { super(entitytypes, world); - this.handItems = NonNullList.a(2, ItemStack.EMPTY); -@@ -136,7 +151,14 @@ - this.initPathfinder(); + this.handItems = NonNullList.withSize(2, ItemStack.EMPTY); +@@ -139,7 +154,14 @@ + this.registerGoals(); } + // CraftBukkit start - default persistance to type's persistance value -+ this.persistenceRequired = !isTypeNotPersistent(0); ++ this.persistenceRequired = !removeWhenFarAway(0); + } + + public void setPersistenceRequired(boolean persistenceRequired) { @@ -51,21 +42,21 @@ } + // CraftBukkit end - protected void initPathfinder() {} + protected void registerGoals() {} -@@ -216,7 +238,38 @@ +@@ -219,7 +241,38 @@ } - public void setGoalTarget(@Nullable EntityLiving entityliving) { + public void setTarget(@Nullable EntityLiving entityliving) { + // CraftBukkit start - fire event -+ setGoalTarget(entityliving, EntityTargetEvent.TargetReason.UNKNOWN, true); ++ setTarget(entityliving, EntityTargetEvent.TargetReason.UNKNOWN, true); + } + -+ public boolean setGoalTarget(EntityLiving entityliving, EntityTargetEvent.TargetReason reason, boolean fireEvent) { -+ if (getGoalTarget() == entityliving) return false; ++ public boolean setTarget(EntityLiving entityliving, EntityTargetEvent.TargetReason reason, boolean fireEvent) { ++ if (getTarget() == entityliving) return false; + if (fireEvent) { -+ if (reason == EntityTargetEvent.TargetReason.UNKNOWN && getGoalTarget() != null && entityliving == null) { -+ reason = getGoalTarget().isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED; ++ if (reason == EntityTargetEvent.TargetReason.UNKNOWN && getTarget() != null && entityliving == null) { ++ reason = getTarget().isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED; + } + if (reason == EntityTargetEvent.TargetReason.UNKNOWN) { + level.getCraftServer().getLogger().log(java.util.logging.Level.WARNING, "Unknown target reason, please report on the issue tracker", new Exception()); @@ -92,23 +83,23 @@ } @Override -@@ -443,16 +496,26 @@ - nbttagcompound.setBoolean("NoAI", this.isNoAI()); +@@ -446,16 +499,26 @@ + nbttagcompound.putBoolean("NoAI", this.isNoAi()); } -+ nbttagcompound.setBoolean("Bukkit.Aware", this.aware); // CraftBukkit ++ nbttagcompound.putBoolean("Bukkit.Aware", this.aware); // CraftBukkit } @Override - public void loadData(NBTTagCompound nbttagcompound) { - super.loadData(nbttagcompound); + public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { + super.readAdditionalSaveData(nbttagcompound); + + // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it - if (nbttagcompound.hasKeyOfType("CanPickUpLoot", 1)) { -- this.setCanPickupLoot(nbttagcompound.getBoolean("CanPickUpLoot")); + if (nbttagcompound.contains("CanPickUpLoot", 1)) { +- this.setCanPickUpLoot(nbttagcompound.getBoolean("CanPickUpLoot")); + boolean data = nbttagcompound.getBoolean("CanPickUpLoot"); + if (isLevelAtLeast(nbttagcompound, 1) || data) { -+ this.setCanPickupLoot(data); ++ this.setCanPickUpLoot(data); + } } @@ -121,207 +112,202 @@ NBTTagList nbttaglist; int i; -@@ -499,6 +562,11 @@ +@@ -502,6 +565,11 @@ } - this.setNoAI(nbttagcompound.getBoolean("NoAI")); + this.setNoAi(nbttagcompound.getBoolean("NoAI")); + // CraftBukkit start -+ if (nbttagcompound.hasKey("Bukkit.Aware")) { ++ if (nbttagcompound.contains("Bukkit.Aware")) { + this.aware = nbttagcompound.getBoolean("Bukkit.Aware"); + } + // CraftBukkit end } @Override -@@ -562,7 +630,7 @@ - protected void b(EntityItem entityitem) { - ItemStack itemstack = entityitem.getItemStack(); +@@ -565,7 +633,7 @@ + protected void pickUpItem(EntityItem entityitem) { + ItemStack itemstack = entityitem.getItem(); -- if (this.j(itemstack)) { -+ if (this.j(itemstack, entityitem)) { // CraftBukkit - add item - this.a(entityitem); - this.receive(entityitem, itemstack.getCount()); - entityitem.die(); -@@ -571,15 +639,29 @@ +- if (this.equipItemIfPossible(itemstack)) { ++ if (this.equipItemIfPossible(itemstack, entityitem)) { // CraftBukkit - add item + this.onItemPickup(entityitem); + this.take(entityitem, itemstack.getCount()); + entityitem.discard(); +@@ -574,15 +642,29 @@ } - public boolean j(ItemStack itemstack) { + public boolean equipItemIfPossible(ItemStack itemstack) { + // CraftBukkit start - add item -+ return this.j(itemstack, null); ++ return this.equipItemIfPossible(itemstack, null); + } + -+ public boolean j(ItemStack itemstack, EntityItem entityitem) { ++ public boolean equipItemIfPossible(ItemStack itemstack, EntityItem entityitem) { + // CraftBukkit end EnumItemSlot enumitemslot = getEquipmentSlotForItem(itemstack); - ItemStack itemstack1 = this.getEquipment(enumitemslot); - boolean flag = this.a(itemstack, itemstack1); + ItemStack itemstack1 = this.getItemBySlot(enumitemslot); + boolean flag = this.canReplaceCurrentItem(itemstack, itemstack1); -- if (flag && this.canPickup(itemstack)) { +- if (flag && this.canHoldItem(itemstack)) { + // CraftBukkit start -+ boolean canPickup = flag && this.canPickup(itemstack); ++ 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.e(enumitemslot); + 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.b(itemstack1); + this.spawnAtLocation(itemstack1); + this.forceDrops = false; // CraftBukkit } - this.b(enumitemslot, itemstack); -@@ -692,18 +774,18 @@ - EntityHuman entityhuman = this.level.findNearbyPlayer(this, -1.0D); - - if (entityhuman != null) { -- double d0 = entityhuman.f(this); -+ double d0 = entityhuman.f((Entity) this); // CraftBukkit - decompile error - int i = this.getEntityType().f().f(); + this.setItemSlotAndDropWhenKilled(enumitemslot, itemstack); +@@ -699,14 +781,14 @@ + int i = this.getType().getCategory().getDespawnDistance(); int j = i * i; -- if (d0 > (double) j && this.isTypeNotPersistent(d0)) { +- if (d0 > (double) j && this.removeWhenFarAway(d0)) { + if (d0 > (double) j) { // CraftBukkit - remove isTypeNotPersistent() check - this.die(); + this.discard(); } - int k = this.getEntityType().f().g(); + int k = this.getType().getCategory().getNoDespawnDistance(); int l = k * k; -- if (this.noActionTime > 600 && this.random.nextInt(800) == 0 && d0 > (double) l && this.isTypeNotPersistent(d0)) { +- if (this.noActionTime > 600 && this.random.nextInt(800) == 0 && d0 > (double) l && this.removeWhenFarAway(d0)) { + if (this.noActionTime > 600 && this.random.nextInt(800) == 0 && d0 > (double) l) { // CraftBukkit - remove isTypeNotPersistent() check - this.die(); + this.discard(); } else if (d0 < (double) l) { this.noActionTime = 0; -@@ -718,6 +800,7 @@ +@@ -721,6 +803,7 @@ @Override - protected final void doTick() { + protected final void serverAiStep() { ++this.noActionTime; + if (!this.aware) return; // CraftBukkit - this.level.getMethodProfiler().enter("sensing"); - this.sensing.a(); - this.level.getMethodProfiler().exit(); -@@ -1101,6 +1184,12 @@ + this.level.getProfiler().push("sensing"); + this.sensing.tick(); + this.level.getProfiler().pop(); +@@ -1116,6 +1199,12 @@ if (!this.isAlive()) { return EnumInteractionResult.PASS; } else if (this.getLeashHolder() == entityhuman) { + // CraftBukkit start - fire PlayerUnleashEntityEvent + if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) { -+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder())); ++ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(this, this.getLeashHolder())); + return EnumInteractionResult.PASS; + } + // CraftBukkit end - this.unleash(true, !entityhuman.getAbilities().instabuild); - return EnumInteractionResult.a(this.level.isClientSide); + this.dropLeash(true, !entityhuman.getAbilities().instabuild); + return EnumInteractionResult.sidedSuccess(this.level.isClientSide); } else { -@@ -1119,6 +1208,12 @@ - ItemStack itemstack = entityhuman.b(enumhand); +@@ -1134,6 +1223,12 @@ + ItemStack itemstack = entityhuman.getItemInHand(enumhand); - if (itemstack.a(Items.LEAD) && this.a(entityhuman)) { + if (itemstack.is(Items.LEAD) && this.canBeLeashed(entityhuman)) { + // CraftBukkit start - fire PlayerLeashEntityEvent + if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) { -+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder())); ++ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(this, this.getLeashHolder())); + return EnumInteractionResult.PASS; + } + // CraftBukkit end - this.setLeashHolder(entityhuman, true); - itemstack.subtract(1); - return EnumInteractionResult.a(this.level.isClientSide); -@@ -1134,7 +1229,7 @@ + this.setLeashedTo(entityhuman, true); + itemstack.shrink(1); + return EnumInteractionResult.sidedSuccess(this.level.isClientSide); +@@ -1149,7 +1244,7 @@ if (itemstack.getItem() instanceof ItemMonsterEgg) { if (this.level instanceof WorldServer) { ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem(); -- Optional<EntityInsentient> optional = itemmonsteregg.a(entityhuman, this, this.getEntityType(), (WorldServer) this.level, this.getPositionVector(), itemstack); -+ Optional<EntityInsentient> optional = itemmonsteregg.a(entityhuman, this, (EntityTypes<? extends EntityInsentient>) this.getEntityType(), (WorldServer) this.level, this.getPositionVector(), itemstack); // CraftBukkit - decompile error +- Optional<EntityInsentient> optional = itemmonsteregg.spawnOffspringFromSpawnEgg(entityhuman, this, this.getType(), (WorldServer) this.level, this.position(), itemstack); ++ Optional<EntityInsentient> optional = itemmonsteregg.spawnOffspringFromSpawnEgg(entityhuman, this, (EntityTypes<? extends EntityInsentient>) this.getType(), (WorldServer) this.level, this.position(), itemstack); // CraftBukkit - decompile error optional.ifPresent((entityinsentient) -> { - this.a(entityhuman, entityinsentient); -@@ -1184,12 +1279,19 @@ + this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient); +@@ -1199,12 +1294,19 @@ return this.restrictRadius != -1.0F; } + // CraftBukkit start @Nullable - public <T extends EntityInsentient> T a(EntityTypes<T> entitytypes, boolean flag) { -+ return this.a(entitytypes, flag, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT); + public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, boolean flag) { ++ return this.convertTo(entitytypes, flag, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT); + } + + @Nullable -+ public <T extends EntityInsentient> T a(EntityTypes<T> entitytypes, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) { ++ public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) { + // CraftBukkit end if (this.isRemoved()) { return null; } else { -- T t0 = (EntityInsentient) entitytypes.a(this.level); -+ T t0 = entitytypes.a(this.level); // CraftBukkit - decompile error +- T t0 = (EntityInsentient) entitytypes.create(this.level); ++ T t0 = entitytypes.create(this.level); // CraftBukkit - decompile error - t0.s(this); + t0.copyPosition(this); t0.setBaby(this.isBaby()); -@@ -1221,7 +1323,12 @@ +@@ -1236,7 +1338,12 @@ } } -- this.level.addEntity(t0); +- this.level.addFreshEntity(t0); + // CraftBukkit start + if (CraftEventFactory.callEntityTransformEvent(this, t0, transformReason).isCancelled()) { + return null; + } -+ this.level.addEntity(t0, spawnReason); ++ this.level.addFreshEntity(t0, spawnReason); + // CraftBukkit end if (this.isPassenger()) { Entity entity = this.getVehicle(); -@@ -1241,6 +1348,7 @@ +@@ -1256,6 +1363,7 @@ if (this.leashHolder != null) { if (!this.isAlive() || !this.leashHolder.isAlive()) { + this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit - this.unleash(true, true); + this.dropLeash(true, true); } -@@ -1252,7 +1360,9 @@ +@@ -1267,7 +1375,9 @@ this.leashHolder = null; this.leashInfoTag = null; if (!this.level.isClientSide && flag1) { + this.forceDrops = true; // CraftBukkit - this.a((IMaterial) Items.LEAD); + this.spawnAtLocation((IMaterial) Items.LEAD); + this.forceDrops = false; // CraftBukkit } if (!this.level.isClientSide && flag && this.level instanceof WorldServer) { -@@ -1302,6 +1412,7 @@ - boolean flag1 = super.a(entity, flag); +@@ -1317,6 +1427,7 @@ + boolean flag1 = super.startRiding(entity, flag); if (flag1 && this.isLeashed()) { + this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit - this.unleash(true, true); + this.dropLeash(true, true); } -@@ -1397,7 +1508,14 @@ - int i = EnchantmentManager.getFireAspectEnchantmentLevel(this); +@@ -1412,7 +1523,14 @@ + int i = EnchantmentManager.getFireAspect(this); if (i > 0) { -- entity.setOnFire(i * 4); +- entity.setSecondsOnFire(i * 4); + // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item + EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), i * 4); + org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); + + if (!combustEvent.isCancelled()) { -+ entity.setOnFire(combustEvent.getDuration(), false); ++ entity.setSecondsOnFire(combustEvent.getDuration(), false); + } + // CraftBukkit end } - boolean flag = entity.damageEntity(DamageSource.mobAttack(this), f); -@@ -1465,9 +1583,10 @@ + boolean flag = entity.hurt(DamageSource.mobAttack(this), f); +@@ -1480,9 +1598,10 @@ @Override - protected void cc() { - super.cc(); + protected void removeAfterChangingDimensions() { + super.removeAfterChangingDimensions(); + this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit - this.unleash(true, false); - this.by().forEach((itemstack) -> { + this.dropLeash(true, false); + this.getAllSlots().forEach((itemstack) -> { - itemstack.setCount(0); + if (!itemstack.isEmpty()) itemstack.setCount(0); // CraftBukkit }); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityLightning.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityLightning.patch index 392fad4c1a..886ddea34a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityLightning.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityLightning.patch @@ -1,64 +1,63 @@ --- a/net/minecraft/world/entity/EntityLightning.java +++ b/net/minecraft/world/entity/EntityLightning.java -@@ -32,6 +32,11 @@ +@@ -31,6 +31,10 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start -+import net.minecraft.network.protocol.game.PacketPlayOutNamedSoundEffect; +import org.bukkit.craftbukkit.event.CraftEventFactory; +// CraftBukkit end + public class EntityLightning extends Entity { private static final int START_LIFE = 2; -@@ -132,7 +137,7 @@ +@@ -131,7 +135,7 @@ } } - if (this.life >= 0) { -+ if (this.life >= 0 && !this.visualOnly) { // CraftBukkit - add !this.isEffect ++ if (this.life >= 0 && !this.visualOnly) { // CraftBukkit - add !this.visualOnly if (!(this.level instanceof WorldServer)) { - this.level.c(2); + this.level.setSkyFlashTime(2); } else if (!this.visualOnly) { -@@ -166,8 +171,12 @@ - IBlockData iblockdata = BlockFireAbstract.a((IBlockAccess) this.level, blockposition); +@@ -165,8 +169,12 @@ + IBlockData iblockdata = BlockFireAbstract.getState(this.level, blockposition); - if (this.level.getType(blockposition).isAir() && iblockdata.canPlace(this.level, blockposition)) { -- this.level.setTypeUpdate(blockposition, iblockdata); + if (this.level.getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level, blockposition)) { +- this.level.setBlockAndUpdate(blockposition, iblockdata); - ++this.blocksSetOnFire; -+ // CraftBukkit start - add "!isEffect" ++ // CraftBukkit start - add "!visualOnly" + if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(level, blockposition, this).isCancelled()) { -+ this.level.setTypeUpdate(blockposition, iblockdata); ++ this.level.setBlockAndUpdate(blockposition, iblockdata); + ++this.blocksSetOnFire; + } + // CraftBukkit end } for (int j = 0; j < i; ++j) { -@@ -175,8 +184,12 @@ +@@ -174,8 +182,12 @@ - iblockdata = BlockFireAbstract.a((IBlockAccess) this.level, blockposition1); - if (this.level.getType(blockposition1).isAir() && iblockdata.canPlace(this.level, blockposition1)) { -- this.level.setTypeUpdate(blockposition1, iblockdata); + iblockdata = BlockFireAbstract.getState(this.level, blockposition1); + if (this.level.getBlockState(blockposition1).isAir() && iblockdata.canSurvive(this.level, blockposition1)) { +- this.level.setBlockAndUpdate(blockposition1, iblockdata); - ++this.blocksSetOnFire; -+ // CraftBukkit start - add "!isEffect" ++ // CraftBukkit start - add "!visualOnly" + if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(level, blockposition1, this).isCancelled()) { -+ this.level.setTypeUpdate(blockposition1, iblockdata); ++ this.level.setBlockAndUpdate(blockposition1, iblockdata); + ++this.blocksSetOnFire; + } + // CraftBukkit end } } -@@ -240,8 +253,9 @@ - iblockdata = world.getType(blockposition1); +@@ -239,8 +251,9 @@ + iblockdata = world.getBlockState(blockposition1); } while (!(iblockdata.getBlock() instanceof WeatheringCopper)); + BlockPosition blockposition1Final = blockposition1; // CraftBukkit - decompile error - WeatheringCopper.b(iblockdata).ifPresent((iblockdata1) -> { -- world.setTypeUpdate(blockposition1, iblockdata1); -+ world.setTypeUpdate(blockposition1Final, iblockdata1); // CraftBukkit - decompile error + WeatheringCopper.getPrevious(iblockdata).ifPresent((iblockdata1) -> { +- world.setBlockAndUpdate(blockposition1, iblockdata1); ++ world.setBlockAndUpdate(blockposition1Final, iblockdata1); // CraftBukkit - decompile error }); - world.triggerEffect(3002, blockposition1, -1); + world.levelEvent(3002, blockposition1, -1); return Optional.of(blockposition1); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityLiving.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityLiving.patch index 051b8b5233..d1c122324e 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityLiving.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityLiving.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityLiving.java +++ b/net/minecraft/world/entity/EntityLiving.java -@@ -119,6 +119,30 @@ +@@ -116,6 +116,30 @@ import net.minecraft.world.scores.ScoreboardTeam; import org.apache.logging.log4j.Logger; @@ -31,7 +31,7 @@ public abstract class EntityLiving extends Entity { private static final UUID SPEED_MODIFIER_SPRINTING_UUID = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); -@@ -227,6 +251,21 @@ +@@ -224,6 +248,21 @@ private float swimAmount; private float swimAmountO; protected BehaviorController<?> brain; @@ -47,83 +47,83 @@ + + @Override + public float getBukkitYaw() { -+ return getHeadRotation(); ++ return getYHeadRot(); + } + // CraftBukkit end protected EntityLiving(EntityTypes<? extends EntityLiving> entitytypes, World world) { super(entitytypes, world); -@@ -239,7 +278,9 @@ +@@ -236,7 +275,9 @@ this.useItem = ItemStack.EMPTY; this.lastClimbablePos = Optional.empty(); - this.attributes = new AttributeMapBase(AttributeDefaults.a(entitytypes)); + 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.getAttributeInstance(GenericAttributes.MAX_HEALTH).getValue()); ++ this.entityData.set(EntityLiving.DATA_HEALTH_ID, (float) this.getAttribute(GenericAttributes.MAX_HEALTH).getValue()); this.blocksBuilding = true; this.rotA = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); - this.ah(); -@@ -306,7 +347,13 @@ + this.reapplyPosition(); +@@ -303,7 +344,13 @@ double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D); int i = (int) (150.0D * d1); -- ((WorldServer) this.level).a(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); +- ((WorldServer) this.level).sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.getX(), this.getY(), this.getZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); + // CraftBukkit start - visiblity api + if (this instanceof EntityPlayer) { -+ ((WorldServer) this.level).sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false); ++ ((WorldServer) this.level).sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), this.getX(), this.getY(), this.getZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false); + } else { -+ ((WorldServer) this.level).a(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); ++ ((WorldServer) this.level).sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.getX(), this.getY(), this.getZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); + } + // CraftBukkit end } } -@@ -566,7 +613,7 @@ +@@ -561,7 +608,7 @@ - protected void dB() { + protected void tickDeath() { ++this.deathTime; - if (this.deathTime == 20 && !this.level.isClientSide()) { + if (this.deathTime >= 20 && !this.isRemoved() && !this.level.isClientSide()) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead) - this.level.broadcastEntityEffect(this, (byte) 60); - this.a(Entity.RemovalReason.KILLED); + this.level.broadcastEntityEvent(this, (byte) 60); + this.remove(Entity.RemovalReason.KILLED); } -@@ -658,9 +705,15 @@ +@@ -653,9 +700,15 @@ } - protected void playEquipSound(ItemStack itemstack) { + protected void equipEventAndSound(ItemStack itemstack) { + // CraftBukkit start -+ this.playEquipSound(itemstack, false); ++ this.equipEventAndSound(itemstack, false); + } + -+ protected void playEquipSound(ItemStack itemstack, boolean silent) { - SoundEffect soundeffect = itemstack.M(); ++ protected void equipEventAndSound(ItemStack itemstack, boolean silent) { + SoundEffect soundeffect = itemstack.getEquipSound(); - if (!itemstack.isEmpty() && soundeffect != null && !this.isSpectator()) { + if (!itemstack.isEmpty() && soundeffect != null && !this.isSpectator() && !silent) { + // CraftBukkit end - this.a(GameEvent.EQUIP); + this.gameEvent(GameEvent.EQUIP); this.playSound(soundeffect, 1.0F, 1.0F); } -@@ -722,6 +775,17 @@ +@@ -717,6 +770,17 @@ } } + // CraftBukkit start -+ if (nbttagcompound.hasKey("Bukkit.MaxHealth")) { ++ if (nbttagcompound.contains("Bukkit.MaxHealth")) { + NBTBase nbtbase = nbttagcompound.get("Bukkit.MaxHealth"); -+ if (nbtbase.getTypeId() == 5) { -+ this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(((NBTTagFloat) nbtbase).asDouble()); -+ } else if (nbtbase.getTypeId() == 3) { -+ this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(((NBTTagInt) nbtbase).asDouble()); ++ if (nbtbase.getId() == 5) { ++ this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(((NBTTagFloat) nbtbase).getAsDouble()); ++ } else if (nbtbase.getId() == 3) { ++ this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(((NBTTagInt) nbtbase).getAsDouble()); + } + } + // CraftBukkit end + - if (nbttagcompound.hasKeyOfType("Health", 99)) { + if (nbttagcompound.contains("Health", 99)) { this.setHealth(nbttagcompound.getFloat("Health")); } -@@ -759,9 +823,32 @@ +@@ -754,9 +818,32 @@ } @@ -149,15 +149,15 @@ + } + // CraftBukkit end + - protected void tickPotionEffects() { + protected void tickEffects() { Iterator iterator = this.activeEffects.keySet().iterator(); + isTickingEffects = true; // CraftBukkit try { while (iterator.hasNext()) { MobEffectList mobeffectlist = (MobEffectList) iterator.next(); -@@ -771,6 +858,12 @@ - this.a(mobeffect, true, (Entity) null); +@@ -766,6 +853,12 @@ + this.onEffectUpdated(mobeffect, true, (Entity) null); })) { if (!this.level.isClientSide) { + // CraftBukkit start @@ -167,9 +167,9 @@ + } + // CraftBukkit end iterator.remove(); - this.a(mobeffect); + this.onEffectRemoved(mobeffect); } -@@ -781,6 +874,17 @@ +@@ -776,6 +869,17 @@ } catch (ConcurrentModificationException concurrentmodificationexception) { ; } @@ -187,7 +187,7 @@ if (this.effectsDirty) { if (!this.level.isClientSide) { -@@ -907,7 +1011,13 @@ +@@ -902,7 +1006,13 @@ this.entityData.set(EntityLiving.DATA_EFFECT_COLOR_ID, 0); } @@ -201,23 +201,23 @@ if (this.level.isClientSide) { return false; } else { -@@ -916,7 +1026,14 @@ +@@ -911,7 +1021,14 @@ boolean flag; for (flag = false; iterator.hasNext(); flag = true) { -- this.a((MobEffect) iterator.next()); +- this.onEffectRemoved((MobEffect) iterator.next()); + // CraftBukkit start + MobEffect effect = (MobEffect) iterator.next(); + EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, effect, null, cause, EntityPotionEffectEvent.Action.CLEARED); + if (event.isCancelled()) { + continue; + } -+ this.a(effect); ++ this.onEffectRemoved(effect); + // CraftBukkit end iterator.remove(); } -@@ -945,18 +1062,48 @@ +@@ -940,18 +1057,48 @@ return this.addEffect(mobeffect, (Entity) null); } @@ -237,15 +237,15 @@ + } + // CraftBukkit end + - if (!this.c(mobeffect)) { + if (!this.canBeAffected(mobeffect)) { return false; } else { - MobEffect mobeffect1 = (MobEffect) this.activeEffects.get(mobeffect.getMobEffect()); + MobEffect mobeffect1 = (MobEffect) this.activeEffects.get(mobeffect.getEffect()); + // CraftBukkit start + boolean override = false; + if (mobeffect1 != null) { -+ override = new MobEffect(mobeffect1).b(mobeffect); ++ override = new MobEffect(mobeffect1).update(mobeffect); + } + + EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, mobeffect1, mobeffect, cause, override); @@ -255,25 +255,25 @@ + // CraftBukkit end + if (mobeffect1 == null) { - this.activeEffects.put(mobeffect.getMobEffect(), mobeffect); - this.a(mobeffect, entity); + this.activeEffects.put(mobeffect.getEffect(), mobeffect); + this.onEffectAdded(mobeffect, entity); return true; -- } else if (mobeffect1.b(mobeffect)) { +- } else if (mobeffect1.update(mobeffect)) { + // CraftBukkit start + } else if (event.isOverride()) { -+ mobeffect1.b(mobeffect); - this.a(mobeffect1, true, entity); ++ mobeffect1.update(mobeffect); + this.onEffectUpdated(mobeffect1, true, entity); + // CraftBukkit end return true; } else { return false; -@@ -993,13 +1140,39 @@ - return this.getMonsterType() == EnumMonsterType.UNDEAD; +@@ -988,13 +1135,39 @@ + return this.getMobType() == EnumMonsterType.UNDEAD; } + // CraftBukkit start @Nullable - public MobEffect c(@Nullable MobEffectList mobeffectlist) { + public MobEffect removeEffectNoUpdate(@Nullable MobEffectList mobeffectlist) { + return c(mobeffectlist, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN); + } + @@ -298,7 +298,7 @@ } public boolean removeEffect(MobEffectList mobeffectlist) { -- MobEffect mobeffect = this.c(mobeffectlist); +- MobEffect mobeffect = this.removeEffectNoUpdate(mobeffectlist); + return removeEffect(mobeffectlist, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN); + } + @@ -307,8 +307,8 @@ + // CraftBukkit end if (mobeffect != null) { - this.a(mobeffect); -@@ -1036,20 +1209,55 @@ + this.onEffectRemoved(mobeffect); +@@ -1031,20 +1204,55 @@ } @@ -362,33 +362,33 @@ + return; + } + // CraftBukkit end - this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.a(f, 0.0F, this.getMaxHealth())); + this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.clamp(f, 0.0F, this.getMaxHealth())); } -@@ -1063,7 +1271,7 @@ +@@ -1058,7 +1266,7 @@ return false; } else if (this.level.isClientSide) { return false; -- } else if (this.dV()) { +- } else if (this.isDeadOrDying()) { + } else if (this.isRemoved() || this.dead || this.getHealth() <= 0.0F) { // CraftBukkit - Don't allow entities that got set to dead/killed elsewhere to get damaged and die return false; } else if (damagesource.isFire() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -1074,10 +1282,11 @@ +@@ -1069,10 +1277,11 @@ this.noActionTime = 0; float f1 = f; - boolean flag = false; -+ boolean flag = f > 0.0F && this.applyBlockingModifier(damagesource); // Copied from below ++ boolean flag = f > 0.0F && this.isDamageSourceBlocked(damagesource); // Copied from below float f2 = 0.0F; -- if (f > 0.0F && this.applyBlockingModifier(damagesource)) { +- if (f > 0.0F && this.isDamageSourceBlocked(damagesource)) { + // CraftBukkit - Moved into damageEntity0(DamageSource, float) -+ if (false && f > 0.0F && this.applyBlockingModifier(damagesource)) { - this.damageShield(f); ++ if (false && f > 0.0F && this.isDamageSourceBlocked(damagesource)) { + this.hurtCurrentlyUsedShield(f); f2 = f; f = 0.0F; -@@ -1095,27 +1304,47 @@ +@@ -1090,27 +1299,47 @@ this.animationSpeed = 1.5F; boolean flag1 = true; @@ -399,7 +399,7 @@ return false; } -- this.damageEntity0(damagesource, f - this.lastHurt); +- this.actuallyHurt(damagesource, f - this.lastHurt); + // CraftBukkit start + if (!this.damageEntity0(damagesource, f - this.lastHurt)) { + return false; @@ -414,7 +414,7 @@ + } this.lastHurt = f; - this.invulnerableTime = 20; -- this.damageEntity0(damagesource, f); +- this.actuallyHurt(damagesource, f); + this.invulnerableTime = this.invulnerableDuration; // CraftBukkit - restore use of maxNoDamageTicks + // this.damageEntity0(damagesource, f); + // CraftBukkit end @@ -422,10 +422,10 @@ this.hurtTime = this.hurtDuration; } -- if (damagesource.g() && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { +- if (damagesource.isDamageHelmet() && !this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) { + // CraftBukkit - Moved into damageEntity0(DamageSource, float) -+ if (false && damagesource.g() && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { - this.damageHelmet(damagesource, f); ++ if (false && damagesource.isDamageHelmet() && !this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) { + this.hurtHelmet(damagesource, f); f *= 0.75F; } @@ -433,7 +433,7 @@ + if (this instanceof EntityAnimal) { + ((EntityAnimal) this).resetLove(); + if (this instanceof EntityTameableAnimal) { -+ ((EntityTameableAnimal) this).setWillSit(false); ++ ((EntityTameableAnimal) this).setOrderedToSit(false); + } + } + // CraftBukkit end @@ -441,7 +441,7 @@ this.hurtDir = 0.0F; Entity entity1 = damagesource.getEntity(); -@@ -1238,19 +1467,29 @@ +@@ -1233,19 +1462,29 @@ EnumHand[] aenumhand = EnumHand.values(); int i = aenumhand.length; @@ -449,12 +449,12 @@ + ItemStack itemstack1 = ItemStack.EMPTY; for (int j = 0; j < i; ++j) { EnumHand enumhand = aenumhand[j]; -- ItemStack itemstack1 = this.b(enumhand); -+ itemstack1 = this.b(enumhand); +- ItemStack itemstack1 = this.getItemInHand(enumhand); ++ itemstack1 = this.getItemInHand(enumhand); - if (itemstack1.a(Items.TOTEM_OF_UNDYING)) { - itemstack = itemstack1.cloneItemStack(); -- itemstack1.subtract(1); + if (itemstack1.is(Items.TOTEM_OF_UNDYING)) { + itemstack = itemstack1.copy(); +- itemstack1.shrink(1); + // itemstack1.subtract(1); // CraftBukkit break; } @@ -468,14 +468,14 @@ + + if (!event.isCancelled()) { + if (!itemstack1.isEmpty()) { -+ itemstack1.subtract(1); ++ itemstack1.shrink(1); + } + if (itemstack != null && this instanceof EntityPlayer) { + // CraftBukkit end EntityPlayer entityplayer = (EntityPlayer) this; - entityplayer.b(StatisticList.ITEM_USED.b(Items.TOTEM_OF_UNDYING)); -@@ -1258,14 +1497,16 @@ + entityplayer.awardStat(StatisticList.ITEM_USED.get(Items.TOTEM_OF_UNDYING)); +@@ -1253,14 +1492,16 @@ } this.setHealth(1.0F); @@ -489,7 +489,7 @@ + this.addEffect(new MobEffect(MobEffects.ABSORPTION, 100, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); + this.addEffect(new MobEffect(MobEffects.FIRE_RESISTANCE, 800, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); + // CraftBukkit end - this.level.broadcastEntityEffect(this, (byte) 35); + this.level.broadcastEntityEvent(this, (byte) 35); } - return itemstack != null; @@ -497,11 +497,11 @@ } } -@@ -1370,14 +1611,22 @@ - IBlockData iblockdata = Blocks.WITHER_ROSE.getBlockData(); +@@ -1365,14 +1606,22 @@ + IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState(); - if (this.level.getType(blockposition).isAir() && iblockdata.canPlace(this.level, blockposition)) { -- this.level.setTypeAndData(blockposition, iblockdata, 3); + if (this.level.getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level, blockposition)) { +- this.level.setBlock(blockposition, iblockdata, 3); - flag = true; + // CraftBukkit start - call EntityBlockFormEvent for Wither Rose + flag = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level, blockposition, iblockdata, 3, this); @@ -510,7 +510,7 @@ } if (!flag) { - EntityItem entityitem = new EntityItem(this.level, this.locX(), this.locY(), this.locZ(), new ItemStack(Items.WITHER_ROSE)); + EntityItem entityitem = new EntityItem(this.level, this.getX(), this.getY(), this.getZ(), new ItemStack(Items.WITHER_ROSE)); + // CraftBukkit start + org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); @@ -519,36 +519,36 @@ + return; + } + // CraftBukkit end - this.level.addEntity(entityitem); + this.level.addFreshEntity(entityitem); } } -@@ -1397,21 +1646,40 @@ +@@ -1392,21 +1641,40 @@ boolean flag = this.lastHurtByPlayerTime > 0; -+ this.dropInventory(); // CraftBukkit - from below - if (this.dD() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { - this.a(damagesource, flag); - this.dropDeathLoot(damagesource, i, flag); ++ this.dropEquipment(); // CraftBukkit - from below + if (this.shouldDropLoot() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + this.dropFromLootTable(damagesource, flag); + this.dropCustomDeathLoot(damagesource, i, flag); } + // CraftBukkit start - Call death event + CraftEventFactory.callEntityDeathEvent(this, this.drops); + this.drops = new ArrayList<>(); + // CraftBukkit end -- this.dropInventory(); +- this.dropEquipment(); + // this.dropInventory();// CraftBukkit - moved up this.dropExperience(); } - protected void dropInventory() {} + protected void dropEquipment() {} - protected void dropExperience() { + // CraftBukkit start + public int getExpReward() { - if (this.level instanceof WorldServer && (this.alwaysGivesExp() || this.lastHurtByPlayerTime > 0 && this.isDropExperience() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) { -- EntityExperienceOrb.a((WorldServer) this.level, this.getPositionVector(), this.getExpValue(this.lastHurtByPlayer)); -+ int i = this.getExpValue(this.lastHurtByPlayer); + if (this.level instanceof WorldServer && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) { +- EntityExperienceOrb.award((WorldServer) this.level, this.position(), this.getExperienceReward(this.lastHurtByPlayer)); ++ int i = this.getExperienceReward(this.lastHurtByPlayer); + return i; + } else { + return 0; @@ -559,39 +559,39 @@ + protected void dropExperience() { + // CraftBukkit start - Update getExpReward() above if the removed if() changes! + if (true) { -+ EntityExperienceOrb.a((WorldServer) this.level, this.getPositionVector(), this.expToDrop); ++ EntityExperienceOrb.award((WorldServer) this.level, this.position(), this.expToDrop); + this.expToDrop = 0; } + // CraftBukkit end } -@@ -1527,9 +1795,14 @@ - int i = this.d(f, f1); +@@ -1526,9 +1794,14 @@ + int i = this.calculateFallDamage(f, f1); if (i > 0) { + // CraftBukkit start -+ if (!this.damageEntity(damagesource, (float) i)) { ++ if (!this.hurt(damagesource, (float) i)) { + return true; + } + // CraftBukkit end - this.playSound(this.getSoundFall(i), 1.0F, 1.0F); - this.playBlockStepSound(); -- this.damageEntity(damagesource, (float) i); + this.playSound(this.getFallDamageSound(i), 1.0F, 1.0F); + this.playBlockFallSound(); +- this.hurt(damagesource, (float) i); + // this.damageEntity(damagesource, (float) i); // CraftBukkit - moved up return true; } else { return flag; -@@ -1578,7 +1851,7 @@ +@@ -1577,7 +1850,7 @@ - protected float applyArmorModifier(DamageSource damagesource, float f) { - if (!damagesource.ignoresArmor()) { -- this.damageArmor(damagesource, f); + protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) { + if (!damagesource.isBypassArmor()) { +- this.hurtArmor(damagesource, f); + // this.damageArmor(damagesource, f); // CraftBukkit - Moved into damageEntity0(DamageSource, float) - f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.b(GenericAttributes.ARMOR_TOUGHNESS)); + f = CombatMath.getDamageAfterAbsorb(f, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS)); } -@@ -1591,7 +1864,8 @@ +@@ -1590,7 +1863,8 @@ } else { int i; @@ -601,24 +601,24 @@ i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f1 = f * (float) j; -@@ -1622,29 +1896,172 @@ +@@ -1621,29 +1895,172 @@ } } -- protected void damageEntity0(DamageSource damagesource, float f) { -- if (!this.isInvulnerable(damagesource)) { -- f = this.applyArmorModifier(damagesource, f); -- f = this.applyMagicModifier(damagesource, f); +- protected void actuallyHurt(DamageSource damagesource, float f) { +- if (!this.isInvulnerableTo(damagesource)) { +- f = this.getDamageAfterArmorAbsorb(damagesource, f); +- f = this.getDamageAfterMagicAbsorb(damagesource, f); - float f1 = f; + // CraftBukkit start + protected boolean damageEntity0(final DamageSource damagesource, float f) { // void -> boolean, add final -+ if (!this.isInvulnerable(damagesource)) { ++ if (!this.isInvulnerableTo(damagesource)) { + final boolean human = this instanceof EntityHuman; + float originalDamage = f; + Function<Double, Double> hardHat = new Function<Double, Double>() { + @Override + public Double apply(Double f) { -+ if (damagesource.g() && !EntityLiving.this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { ++ if (damagesource.isDamageHelmet() && !EntityLiving.this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) { + return -(f - (f * 0.75F)); + + } @@ -631,7 +631,7 @@ + Function<Double, Double> blocking = new Function<Double, Double>() { + @Override + public Double apply(Double f) { -+ return -((EntityLiving.this.applyBlockingModifier(damagesource)) ? f : 0.0); ++ return -((EntityLiving.this.isDamageSourceBlocked(damagesource)) ? f : 0.0); + } + }; + float blockingModifier = blocking.apply((double) f).floatValue(); @@ -640,7 +640,7 @@ + Function<Double, Double> armor = new Function<Double, Double>() { + @Override + public Double apply(Double f) { -+ return -(f - EntityLiving.this.applyArmorModifier(damagesource, f.floatValue())); ++ return -(f - EntityLiving.this.getDamageAfterArmorAbsorb(damagesource, f.floatValue())); + } + }; + float armorModifier = armor.apply((double) f).floatValue(); @@ -649,7 +649,7 @@ + Function<Double, Double> resistance = new Function<Double, Double>() { + @Override + public Double apply(Double f) { -+ if (!damagesource.isStarvation() && EntityLiving.this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { ++ if (!damagesource.isBypassMagic() && EntityLiving.this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { + int i = (EntityLiving.this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; + int j = 25 - i; + float f1 = f.floatValue() * (float) j; @@ -664,7 +664,7 @@ + Function<Double, Double> magic = new Function<Double, Double>() { + @Override + public Double apply(Double f) { -+ return -(f - EntityLiving.this.applyMagicModifier(damagesource, f.floatValue())); ++ return -(f - EntityLiving.this.getDamageAfterMagicAbsorb(damagesource, f.floatValue())); + } + }; + float magicModifier = magic.apply((double) f).floatValue(); @@ -673,104 +673,104 @@ + Function<Double, Double> absorption = new Function<Double, Double>() { + @Override + public Double apply(Double f) { -+ return -(Math.max(f - Math.max(f - EntityLiving.this.getAbsorptionHearts(), 0.0F), 0.0F)); ++ return -(Math.max(f - Math.max(f - EntityLiving.this.getAbsorptionAmount(), 0.0F), 0.0F)); + } + }; + float absorptionModifier = absorption.apply((double) f).floatValue(); + + EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption); + if (damagesource.getEntity() instanceof EntityHuman) { -+ ((EntityHuman) damagesource.getEntity()).resetAttackCooldown(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired ++ ((EntityHuman) damagesource.getEntity()).resetAttackStrengthTicker(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired + } + if (event.isCancelled()) { + return false; + } - -- f = Math.max(f - this.getAbsorptionHearts(), 0.0F); -- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f)); -- float f2 = f1 - f; ++ + f = (float) event.getFinalDamage(); - ++ + // Resistance + if (event.getDamage(DamageModifier.RESISTANCE) < 0) { + float f3 = (float) -event.getDamage(DamageModifier.RESISTANCE); + if (f3 > 0.0F && f3 < 3.4028235E37F) { + if (this instanceof EntityPlayer) { -+ ((EntityPlayer) this).a(StatisticList.DAMAGE_RESISTED, Math.round(f3 * 10.0F)); ++ ((EntityPlayer) this).awardStat(StatisticList.DAMAGE_RESISTED, Math.round(f3 * 10.0F)); + } else if (damagesource.getEntity() instanceof EntityPlayer) { -+ ((EntityPlayer) damagesource.getEntity()).a(StatisticList.DAMAGE_DEALT_RESISTED, Math.round(f3 * 10.0F)); ++ ((EntityPlayer) damagesource.getEntity()).awardStat(StatisticList.DAMAGE_DEALT_RESISTED, Math.round(f3 * 10.0F)); + } + } + } + + // Apply damage to helmet -+ if (damagesource.g() && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { -+ this.damageHelmet(damagesource, f); ++ if (damagesource.isDamageHelmet() && !this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) { ++ this.hurtHelmet(damagesource, f); + } -+ + +- f = Math.max(f - this.getAbsorptionAmount(), 0.0F); +- this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - f)); +- float f2 = f1 - f; + // Apply damage to armor -+ if (!damagesource.ignoresArmor()) { ++ if (!damagesource.isBypassArmor()) { + float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT)); -+ this.damageArmor(damagesource, armorDamage); ++ this.hurtArmor(damagesource, armorDamage); + } + + // Apply blocking code // PAIL: steal from above + if (event.getDamage(DamageModifier.BLOCKING) < 0) { -+ this.level.broadcastEntityEffect(this, (byte) 29); // SPIGOT-4635 - shield damage sound -+ this.damageShield((float) -event.getDamage(DamageModifier.BLOCKING)); -+ Entity entity = damagesource.k(); ++ this.level.broadcastEntityEvent(this, (byte) 29); // SPIGOT-4635 - shield damage sound ++ this.hurtCurrentlyUsedShield((float) -event.getDamage(DamageModifier.BLOCKING)); ++ Entity entity = damagesource.getDirectEntity(); + + if (entity instanceof EntityLiving) { -+ this.shieldBlock((EntityLiving) entity); ++ this.blockUsingShield((EntityLiving) entity); + } + } + + absorptionModifier = (float) -event.getDamage(DamageModifier.ABSORPTION); -+ this.setAbsorptionHearts(Math.max(this.getAbsorptionHearts() - absorptionModifier, 0.0F)); ++ this.setAbsorptionAmount(Math.max(this.getAbsorptionAmount() - absorptionModifier, 0.0F)); + float f2 = absorptionModifier; -+ + + if (f2 > 0.0F && f2 < 3.4028235E37F && this instanceof EntityHuman) { -+ ((EntityHuman) this).a(StatisticList.DAMAGE_ABSORBED, Math.round(f2 * 10.0F)); ++ ((EntityHuman) this).awardStat(StatisticList.DAMAGE_ABSORBED, Math.round(f2 * 10.0F)); + } if (f2 > 0.0F && f2 < 3.4028235E37F && damagesource.getEntity() instanceof EntityPlayer) { - ((EntityPlayer) damagesource.getEntity()).a(StatisticList.DAMAGE_DEALT_ABSORBED, Math.round(f2 * 10.0F)); + ((EntityPlayer) damagesource.getEntity()).awardStat(StatisticList.DAMAGE_DEALT_ABSORBED, Math.round(f2 * 10.0F)); } - if (f != 0.0F) { + if (f > 0 || !human) { + if (human) { + // PAIL: Be sure to drag all this code from the EntityHuman subclass each update. -+ ((EntityHuman) this).applyExhaustion(damagesource.getExhaustionCost(), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.DAMAGED); // CraftBukkit - EntityExhaustionEvent ++ ((EntityHuman) this).causeFoodExhaustion(damagesource.getFoodExhaustion(), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.DAMAGED); // CraftBukkit - EntityExhaustionEvent + if (f < 3.4028235E37F) { -+ ((EntityHuman) this).a(StatisticList.DAMAGE_TAKEN, Math.round(f * 10.0F)); ++ ((EntityHuman) this).awardStat(StatisticList.DAMAGE_TAKEN, Math.round(f * 10.0F)); + } + } + // CraftBukkit end float f3 = this.getHealth(); this.setHealth(f3 - f); - this.getCombatTracker().trackDamage(damagesource, f3, f); -- this.setAbsorptionHearts(this.getAbsorptionHearts() - f); + this.getCombatTracker().recordDamage(damagesource, f3, f); +- this.setAbsorptionAmount(this.getAbsorptionAmount() - f); + // CraftBukkit start + if (!human) { -+ this.setAbsorptionHearts(this.getAbsorptionHearts() - f); ++ this.setAbsorptionAmount(this.getAbsorptionAmount() - f); + } - this.a(GameEvent.ENTITY_DAMAGED, damagesource.getEntity()); + this.gameEvent(GameEvent.ENTITY_DAMAGED, damagesource.getEntity()); + + return true; + } else { + // Duplicate triggers if blocking + if (event.getDamage(DamageModifier.BLOCKING) < 0) { + if (this instanceof EntityPlayer) { -+ CriterionTriggers.ENTITY_HURT_PLAYER.a((EntityPlayer) this, damagesource, f, originalDamage, true); ++ CriterionTriggers.ENTITY_HURT_PLAYER.trigger((EntityPlayer) this, damagesource, f, originalDamage, true); + f2 = (float) -event.getDamage(DamageModifier.BLOCKING); + if (f2 > 0.0F && f2 < 3.4028235E37F) { -+ ((EntityPlayer) this).a(StatisticList.DAMAGE_BLOCKED_BY_SHIELD, Math.round(originalDamage * 10.0F)); ++ ((EntityPlayer) this).awardStat(StatisticList.DAMAGE_BLOCKED_BY_SHIELD, Math.round(originalDamage * 10.0F)); + } + } + + if (damagesource.getEntity() instanceof EntityPlayer) { -+ CriterionTriggers.PLAYER_HURT_ENTITY.a((EntityPlayer) damagesource.getEntity(), this, damagesource, f, originalDamage, true); ++ CriterionTriggers.PLAYER_HURT_ENTITY.trigger((EntityPlayer) damagesource.getEntity(), this, damagesource, f, originalDamage, true); + } + + return false; @@ -784,7 +784,7 @@ } public CombatTracker getCombatTracker() { -@@ -1665,8 +2082,18 @@ +@@ -1664,8 +2081,18 @@ } public final void setArrowCount(int i) { @@ -802,66 +802,66 @@ } + // CraftBukkit end - public final int eh() { + public final int getStingerCount() { return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID); -@@ -1962,6 +2389,12 @@ +@@ -1961,6 +2388,12 @@ - public abstract ItemStack getEquipment(EnumItemSlot enumitemslot); + public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot); + // CraftBukkit start -+ public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) { -+ this.setSlot(enumitemslot, itemstack); ++ public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) { ++ this.setItemSlot(enumitemslot, itemstack); + } + // CraftBukkit end + @Override - public abstract void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack); + public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack); -@@ -2205,6 +2638,7 @@ +@@ -2204,6 +2637,7 @@ } if (this.onGround && !this.level.isClientSide) { -+ if (getFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit - this.setFlag(7, false); ++ if (getSharedFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit + this.setSharedFlag(7, false); } } else { -@@ -2735,6 +3169,7 @@ +@@ -2734,6 +3168,7 @@ } if (!this.level.isClientSide) { -+ if (flag != this.getFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, flag).isCancelled()) // CraftBukkit - this.setFlag(7, flag); ++ if (flag != this.getSharedFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, flag).isCancelled()) // CraftBukkit + this.setSharedFlag(7, flag); } -@@ -2902,14 +3337,21 @@ +@@ -2901,14 +3336,21 @@ @Override - public boolean isInteractable() { + public boolean isPickable() { - return !this.isRemoved(); + return !this.isRemoved() && this.collides; // CraftBukkit } @Override - public boolean isCollidable() { -- return this.isAlive() && !this.isSpectator() && !this.isClimbing(); -+ return this.isAlive() && !this.isSpectator() && !this.isClimbing() && this.collides; // CraftBukkit + public boolean isPushable() { +- return this.isAlive() && !this.isSpectator() && !this.onClimbable(); ++ return this.isAlive() && !this.isSpectator() && !this.onClimbable() && this.collides; // CraftBukkit } + // CraftBukkit start - collidable API + @Override + public boolean canCollideWithBukkit(Entity entity) { -+ return isCollidable() && this.collides != this.collidableExemptions.contains(entity.getUniqueID()); ++ return isPushable() && this.collides != this.collidableExemptions.contains(entity.getUUID()); + } + // CraftBukkit end + @Override - protected void velocityChanged() { - this.hurtMarked = this.random.nextDouble() >= this.b(GenericAttributes.KNOCKBACK_RESISTANCE); -@@ -3107,7 +3549,25 @@ + protected void markHurt() { + this.hurtMarked = this.random.nextDouble() >= this.getAttributeValue(GenericAttributes.KNOCKBACK_RESISTANCE); +@@ -3106,7 +3548,25 @@ } else { - if (!this.useItem.isEmpty() && this.isHandRaised()) { - this.b(this.useItem, 16); -- ItemStack itemstack = this.useItem.a(this.level, this); + if (!this.useItem.isEmpty() && this.isUsingItem()) { + this.triggerItemUseEffects(this.useItem, 16); +- ItemStack itemstack = this.useItem.finishUsingItem(this.level, this); + // CraftBukkit start - fire PlayerItemConsumeEvent + ItemStack itemstack; + if (this instanceof EntityPlayer) { @@ -876,42 +876,42 @@ + return; + } + -+ itemstack = (craftItem.equals(event.getItem())) ? this.useItem.a(this.level, this) : CraftItemStack.asNMSCopy(event.getItem()).a(level, this); ++ itemstack = (craftItem.equals(event.getItem())) ? this.useItem.finishUsingItem(this.level, this) : CraftItemStack.asNMSCopy(event.getItem()).finishUsingItem(level, this); + } else { -+ itemstack = this.useItem.a(this.level, this); ++ itemstack = this.useItem.finishUsingItem(this.level, this); + } + // CraftBukkit end if (itemstack != this.useItem) { - this.a(enumhand, itemstack); -@@ -3179,6 +3639,12 @@ + this.setItemInHand(enumhand, itemstack); +@@ -3178,6 +3638,12 @@ } - public boolean a(double d0, double d1, double d2, boolean flag) { + public boolean randomTeleport(double d0, double d1, double d2, boolean flag) { + // CraftBukkit start -+ return safeTeleport(d0, d1, d2, flag, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN).orElse(false); ++ return randomTeleport(d0, d1, d2, flag, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN).orElse(false); + } + -+ public Optional<Boolean> safeTeleport(double d0, double d1, double d2, boolean flag, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { ++ public Optional<Boolean> randomTeleport(double d0, double d1, double d2, boolean flag, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { + // CraftBukkit end - double d3 = this.locX(); - double d4 = this.locY(); - double d5 = this.locZ(); -@@ -3203,16 +3669,41 @@ + double d3 = this.getX(); + double d4 = this.getY(); + double d5 = this.getZ(); +@@ -3202,16 +3668,41 @@ } if (flag2) { -- this.enderTeleportTo(d0, d6, d2); +- this.teleportTo(d0, d6, d2); + // CraftBukkit start - Teleport event -+ // this.enderTeleportTo(d0, d6, d2); ++ // this.teleportTo(d0, d6, d2); + + // first set position, to check if the place to teleport is valid -+ this.setPosition(d0, d6, d2); - if (world.getCubes(this) && !world.containsLiquid(this.getBoundingBox())) { ++ this.setPos(d0, d6, d2); + if (world.noCollision((Entity) this) && !world.containsAnyLiquid(this.getBoundingBox())) { flag1 = true; } + // now revert and call event if the teleport place is valid -+ this.setPosition(d3, d4, d5); ++ this.setPos(d3, d4, d5); + + if (flag1) { + if (!(this instanceof EntityPlayer)) { @@ -919,13 +919,13 @@ + this.level.getCraftServer().getPluginManager().callEvent(teleport); + if (!teleport.isCancelled()) { + Location to = teleport.getTo(); -+ this.enderTeleportTo(to.getX(), to.getY(), to.getZ()); ++ this.teleportTo(to.getX(), to.getY(), to.getZ()); + } else { + return Optional.empty(); + } + } else { + // player teleport event is called in the underlining code -+ if (((EntityPlayer) this).connection.a(d0, d6, d2, this.getYRot(), this.getXRot(), java.util.Collections.emptySet(), false, cause)) { ++ if (((EntityPlayer) this).connection.teleport(d0, d6, d2, this.getYRot(), this.getXRot(), java.util.Collections.emptySet(), false, cause)) { + return Optional.empty(); + } + } @@ -935,15 +935,15 @@ } if (!flag1) { -- this.enderTeleportTo(d3, d4, d5); +- this.teleportTo(d3, d4, d5); - return false; + // this.enderTeleportTo(d3, d4, d5); // CraftBukkit - already set the location back + return Optional.of(false); // CraftBukkit } else { if (flag) { - world.broadcastEntityEffect(this, (byte) 46); -@@ -3222,7 +3713,7 @@ - ((EntityCreature) this).getNavigation().o(); + world.broadcastEntityEvent(this, (byte) 46); +@@ -3221,7 +3712,7 @@ + ((EntityCreature) this).getNavigation().stop(); } - return true; @@ -951,25 +951,25 @@ } } -@@ -3305,7 +3796,7 @@ +@@ -3304,7 +3795,7 @@ } - public void entityWakeup() { -- Optional optional = this.getBedPosition(); -+ Optional<BlockPosition> optional = this.getBedPosition(); // CraftBukkit - decompile error + public void stopSleeping() { +- Optional optional = this.getSleepingPos(); ++ Optional<BlockPosition> optional = this.getSleepingPos(); // CraftBukkit - decompile error World world = this.level; java.util.Objects.requireNonNull(this.level); -@@ -3337,7 +3828,7 @@ +@@ -3336,7 +3827,7 @@ @Nullable - public EnumDirection eX() { -- BlockPosition blockposition = (BlockPosition) this.getBedPosition().orElse((Object) null); -+ BlockPosition blockposition = (BlockPosition) this.getBedPosition().orElse(null); // CraftBukkit - decompile error + public EnumDirection getBedOrientation() { +- BlockPosition blockposition = (BlockPosition) this.getSleepingPos().orElse((Object) null); ++ BlockPosition blockposition = (BlockPosition) this.getSleepingPos().orElse(null); // CraftBukkit - decompile error - return blockposition != null ? BlockBed.a((IBlockAccess) this.level, blockposition) : null; + return blockposition != null ? BlockBed.getBedOrientation(this.level, blockposition) : null; } -@@ -3386,7 +3877,7 @@ +@@ -3385,7 +3876,7 @@ Pair<MobEffect, Float> pair = (Pair) iterator.next(); if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) { @@ -978,3 +978,24 @@ } } } +@@ -3488,8 +3979,10 @@ + this.setDeltaMovement((double) ((float) packetplayoutspawnentityliving.getXd() / 8000.0F), (double) ((float) packetplayoutspawnentityliving.getYd() / 8000.0F), (double) ((float) packetplayoutspawnentityliving.getZd() / 8000.0F)); + } + +- public static final class a extends Record { ++ // CraftBukkit start ++ public static final record a(SoundEffect small, SoundEffect big) { + ++ /* + private final SoundEffect small; + private final SoundEffect big; + +@@ -3509,6 +4002,8 @@ + public final boolean equals(Object object) { + return this.equals<invokedynamic>(this, object); + } ++ */ ++ // CraftBukkit end + + public SoundEffect small() { + return this.small; diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityTypes.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityTypes.patch index 01c1314961..22f7d8fc2a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityTypes.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityTypes.patch @@ -4,35 +4,37 @@ private static final Logger LOGGER = LogManager.getLogger(); public static final String ENTITY_TAG = "EntityTag"; private static final float MAGIC_HORSE_WIDTH = 1.3964844F; -- public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = a("area_effect_cloud", EntityTypes.Builder.a(EntityAreaEffectCloud::new, EnumCreatureType.MISC).c().a(6.0F, 0.5F).trackingRange(10).updateInterval(Integer.MAX_VALUE)); -+ public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = a("area_effect_cloud", EntityTypes.Builder.a(EntityAreaEffectCloud::new, EnumCreatureType.MISC).c().a(6.0F, 0.5F).trackingRange(10).updateInterval(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds - public static final EntityTypes<EntityArmorStand> ARMOR_STAND = a("armor_stand", EntityTypes.Builder.a(EntityArmorStand::new, EnumCreatureType.MISC).a(0.5F, 1.975F).trackingRange(10)); - public static final EntityTypes<EntityTippedArrow> ARROW = a("arrow", EntityTypes.Builder.a(EntityTippedArrow::new, EnumCreatureType.MISC).a(0.5F, 0.5F).trackingRange(4).updateInterval(20)); - public static final EntityTypes<Axolotl> AXOLOTL = a("axolotl", EntityTypes.Builder.a(Axolotl::new, EnumCreatureType.UNDERGROUND_WATER_CREATURE).a(0.75F, 0.42F).trackingRange(10)); -@@ -282,7 +282,7 @@ +- public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(Integer.MAX_VALUE)); ++ public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds + public static final EntityTypes<EntityArmorStand> ARMOR_STAND = register("armor_stand", EntityTypes.Builder.of(EntityArmorStand::new, EnumCreatureType.MISC).sized(0.5F, 1.975F).clientTrackingRange(10)); + public static final EntityTypes<EntityTippedArrow> ARROW = register("arrow", EntityTypes.Builder.of(EntityTippedArrow::new, EnumCreatureType.MISC).sized(0.5F, 0.5F).clientTrackingRange(4).updateInterval(20)); + public static final EntityTypes<Axolotl> AXOLOTL = register("axolotl", EntityTypes.Builder.of(Axolotl::new, EnumCreatureType.AXOLOTLS).sized(0.75F, 0.42F).clientTrackingRange(10)); +@@ -282,8 +282,8 @@ private MinecraftKey lootTable; private final EntitySize dimensions; -- private static <T extends Entity> EntityTypes<T> a(String s, EntityTypes.Builder<T> entitytypes_builder) { -+ private static <T extends Entity> EntityTypes<T> a(String s, EntityTypes.Builder entitytypes_builder) { // CraftBukkit - decompile error - return (EntityTypes) IRegistry.a((IRegistry) IRegistry.ENTITY_TYPE, s, (Object) entitytypes_builder.a(s)); +- private static <T extends Entity> EntityTypes<T> register(String s, EntityTypes.Builder<T> entitytypes_builder) { +- return (EntityTypes) IRegistry.register(IRegistry.ENTITY_TYPE, s, entitytypes_builder.build(s)); ++ private static <T extends Entity> EntityTypes<T> register(String s, EntityTypes.Builder entitytypes_builder) { // CraftBukkit - decompile error ++ return (EntityTypes) IRegistry.register(IRegistry.ENTITY_TYPE, s, (EntityTypes<T>) entitytypes_builder.build(s)); // CraftBukkit - decompile error } + public static MinecraftKey getKey(EntityTypes<?> entitytypes) { @@ -314,10 +314,18 @@ @Nullable - public T spawnCreature(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) { + public T spawn(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) { + // CraftBukkit start -+ return this.spawnCreature(worldserver, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); ++ return this.spawn(worldserver, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); + } + + @Nullable -+ public T spawnCreature(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { - T t0 = this.createCreature(worldserver, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1); ++ public T spawn(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + T t0 = this.create(worldserver, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1); if (t0 != null) { -- worldserver.addAllEntities(t0); -+ worldserver.addAllEntities(t0, spawnReason); +- worldserver.addFreshEntityWithPassengers(t0); ++ worldserver.addFreshEntityWithPassengers(t0, spawnReason); + return !t0.isRemoved() ? t0 : null; // Don't return an entity when CreatureSpawnEvent is canceled + // CraftBukkit end } @@ -42,12 +44,12 @@ t0.setCustomName(ichatbasecomponent); } -- a((World) worldserver, entityhuman, t0, nbttagcompound); -+ try { a((World) worldserver, entityhuman, t0, nbttagcompound); } catch (Throwable t) { LOGGER.warn("Error loading spawn egg NBT", t); } // CraftBukkit - SPIGOT-5665 +- updateCustomEntityTag(worldserver, entityhuman, t0, nbttagcompound); ++ try { updateCustomEntityTag(worldserver, entityhuman, t0, nbttagcompound); } catch (Throwable t) { LOGGER.warn("Error loading spawn egg NBT", t); } // CraftBukkit - SPIGOT-5665 return t0; } } -@@ -512,7 +520,7 @@ +@@ -510,7 +518,7 @@ } return entity; @@ -55,22 +57,22 @@ + }).orElse(null); // CraftBukkit - decompile error } - public static Stream<Entity> a(final List<? extends NBTBase> list, final World world) { -@@ -569,7 +577,7 @@ + public static Stream<Entity> loadEntitiesRecursive(final List<? extends NBTBase> list, final World world) { +@@ -567,7 +575,7 @@ @Nullable - public T a(Entity entity) { -- return entity.getEntityType() == this ? entity : null; -+ return entity.getEntityType() == this ? (T) entity : null; // CraftBukkit - decompile error + public T tryCast(Entity entity) { +- return entity.getType() == this ? entity : null; ++ return entity.getType() == this ? (T) entity : null; // CraftBukkit - decompile error } @Override -@@ -596,7 +604,7 @@ +@@ -594,7 +602,7 @@ this.canSpawnFarFromPlayer = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC; } -- public static <T extends Entity> EntityTypes.Builder<T> a(EntityTypes.b<T> entitytypes_b, EnumCreatureType enumcreaturetype) { -+ public static <T extends Entity> EntityTypes.Builder<T> a(EntityTypes.b entitytypes_b, EnumCreatureType enumcreaturetype) { // CraftBukkit - decompile error +- public static <T extends Entity> EntityTypes.Builder<T> of(EntityTypes.b<T> entitytypes_b, EnumCreatureType enumcreaturetype) { ++ public static <T extends Entity> EntityTypes.Builder<T> of(EntityTypes.b entitytypes_b, EnumCreatureType enumcreaturetype) { // CraftBukkit - decompile error return new EntityTypes.Builder<>(entitytypes_b, enumcreaturetype); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/IEntityAngerable.patch b/paper-server/nms-patches/net/minecraft/world/entity/IEntityAngerable.patch index 2c73911e9e..902b88e16e 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/IEntityAngerable.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/IEntityAngerable.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/entity/IEntityAngerable.java +++ b/net/minecraft/world/entity/IEntityAngerable.java @@ -108,7 +108,7 @@ - default void pacify() { - this.setLastDamager((EntityLiving) null); - this.setAngerTarget((UUID) null); -- this.setGoalTarget((EntityLiving) null); -+ this.setGoalTarget((EntityLiving) null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - this.setAnger(0); + default void stopBeingAngry() { + this.setLastHurtByMob((EntityLiving) null); + this.setPersistentAngerTarget((UUID) null); +- this.setTarget((EntityLiving) null); ++ this.setTarget((EntityLiving) null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit + this.setRemainingPersistentAngerTime(0); } @@ -121,6 +121,8 @@ - void setGoalTarget(@Nullable EntityLiving entityliving); + void setTarget(@Nullable EntityLiving entityliving); -+ boolean setGoalTarget(@Nullable EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent); // CraftBukkit ++ boolean setTarget(@Nullable EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent); // CraftBukkit + - boolean c(EntityLiving entityliving); + boolean canAttack(EntityLiving entityliving); @Nullable diff --git a/paper-server/nms-patches/net/minecraft/world/entity/IEntitySelector.patch b/paper-server/nms-patches/net/minecraft/world/entity/IEntitySelector.patch index 0b5e7c7d47..72795fc389 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/IEntitySelector.patch +++ b/paper-server/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 -@@ -42,7 +42,7 @@ +@@ -43,7 +43,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) -> { -- if (!entity1.isCollidable()) { +- 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).fi())) { + } else if (entity.level.isClientSide && (!(entity1 instanceof EntityHuman) || !((EntityHuman) entity1).isLocalPlayer())) { return false; diff --git a/paper-server/nms-patches/net/minecraft/world/entity/SaddleStorage.patch b/paper-server/nms-patches/net/minecraft/world/entity/SaddleStorage.patch index 9ab005915e..996fa69bad 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/SaddleStorage.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/SaddleStorage.patch @@ -13,6 +13,6 @@ + } + // CraftBukkit end + - public void a(NBTTagCompound nbttagcompound) { - nbttagcompound.setBoolean("Saddle", this.hasSaddle()); + public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { + nbttagcompound.putBoolean("Saddle", this.hasSaddle()); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/attributes/AttributeRanged.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/attributes/AttributeRanged.patch index 9a848218ca..7d834a635d 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/attributes/AttributeRanged.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/attributes/AttributeRanged.patch @@ -3,9 +3,9 @@ @@ -30,6 +30,8 @@ @Override - public double a(double d0) { -+ if (d0 != d0) return getDefault(); // CraftBukkit + public double sanitizeValue(double d0) { ++ if (d0 != d0) return getDefaultValue(); // CraftBukkit + - d0 = MathHelper.a(d0, this.minValue, this.maxValue); + d0 = MathHelper.clamp(d0, this.minValue, this.maxValue); return d0; } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/attributes/GenericAttributes.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/attributes/GenericAttributes.patch index 1a84234afc..c44303ee46 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/attributes/GenericAttributes.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/attributes/GenericAttributes.patch @@ -5,11 +5,3 @@ package net.minecraft.world.entity.ai.attributes; import net.minecraft.core.IRegistry; -@@ -21,6 +22,6 @@ - public GenericAttributes() {} - - private static AttributeBase a(String s, AttributeBase attributebase) { -- return (AttributeBase) IRegistry.a(IRegistry.ATTRIBUTE, s, (Object) attributebase); -+ return (AttributeBase) IRegistry.a(IRegistry.ATTRIBUTE, s, attributebase); // CraftBukkit - decompile error - } - } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.patch index c7993c393c..56f8820019 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.patch @@ -16,18 +16,18 @@ @@ -77,6 +83,17 @@ } - protected void a(E e0) { + protected void clearAttackTarget(E e0) { + // CraftBukkit start -+ EntityLiving old = e0.getBehaviorController().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null); ++ EntityLiving old = e0.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null); + EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(e0, null, (old != null && !old.isAlive()) ? EntityTargetEvent.TargetReason.TARGET_DIED : EntityTargetEvent.TargetReason.FORGOT_TARGET); + if (event.isCancelled()) { + return; + } + if (event.getTarget() != null) { -+ e0.getBehaviorController().setMemory(MemoryModuleType.ATTACK_TARGET, ((CraftLivingEntity) event.getTarget()).getHandle()); ++ e0.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, ((CraftLivingEntity) event.getTarget()).getHandle()); + return; + } + // CraftBukkit end this.onTargetErased.accept(e0); - e0.getBehaviorController().removeMemory(MemoryModuleType.ATTACK_TARGET); + e0.getBrain().eraseMemory(MemoryModuleType.ATTACK_TARGET); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.patch index b48ec555b4..86964b005c 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.patch @@ -17,15 +17,15 @@ @@ -38,13 +45,21 @@ } - protected void a(WorldServer worldserver, E e0, long i) { + protected void start(WorldServer worldserver, E e0, long i) { - ((Optional) this.targetFinderFunction.apply(e0)).ifPresent((entityliving) -> { + (this.targetFinderFunction.apply(e0)).ifPresent((entityliving) -> { // CraftBukkit - decompile error - this.a(e0, entityliving); + this.setAttackTarget(e0, entityliving); }); } - private void a(E e0, EntityLiving entityliving) { -- e0.getBehaviorController().setMemory(MemoryModuleType.ATTACK_TARGET, (Object) entityliving); + private void setAttackTarget(E e0, EntityLiving entityliving) { +- e0.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, (Object) entityliving); + // CraftBukkit start + EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(e0, entityliving, (entityliving instanceof EntityPlayer) ? EntityTargetEvent.TargetReason.CLOSEST_PLAYER : EntityTargetEvent.TargetReason.CLOSEST_ENTITY); + if (event.isCancelled()) { @@ -34,7 +34,7 @@ + entityliving = (event.getTarget() != null) ? ((CraftLivingEntity) event.getTarget()).getHandle() : null; + // CraftBukkit end + -+ e0.getBehaviorController().setMemory(MemoryModuleType.ATTACK_TARGET, entityliving); // CraftBukkit - decompile error - e0.getBehaviorController().removeMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); ++ e0.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, entityliving); // CraftBukkit - decompile error + e0.getBrain().eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorCareer.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorCareer.patch index fc6da01138..251fa21d34 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorCareer.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorCareer.patch @@ -14,27 +14,27 @@ public BehaviorCareer() { @@ -29,7 +35,7 @@ - GlobalPos globalpos = (GlobalPos) entityvillager.getBehaviorController().getMemory(MemoryModuleType.POTENTIAL_JOB_SITE).get(); + GlobalPos globalpos = (GlobalPos) entityvillager.getBrain().getMemory(MemoryModuleType.POTENTIAL_JOB_SITE).get(); - entityvillager.getBehaviorController().removeMemory(MemoryModuleType.POTENTIAL_JOB_SITE); -- entityvillager.getBehaviorController().setMemory(MemoryModuleType.JOB_SITE, (Object) globalpos); -+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.JOB_SITE, globalpos); // CraftBukkit - decompile error - worldserver.broadcastEntityEffect(entityvillager, (byte) 14); + entityvillager.getBrain().eraseMemory(MemoryModuleType.POTENTIAL_JOB_SITE); +- entityvillager.getBrain().setMemory(MemoryModuleType.JOB_SITE, (Object) globalpos); ++ entityvillager.getBrain().setMemory(MemoryModuleType.JOB_SITE, globalpos); // CraftBukkit - decompile error + worldserver.broadcastEntityEvent(entityvillager, (byte) 14); if (entityvillager.getVillagerData().getProfession() == VillagerProfession.NONE) { - MinecraftServer minecraftserver = worldserver.getMinecraftServer(); + MinecraftServer minecraftserver = worldserver.getServer(); @@ -41,7 +47,14 @@ - return villagerprofession.b() == villageplacetype; + return villagerprofession.getJobPoiType() == villageplacetype; }).findFirst(); }).ifPresent((villagerprofession) -> { -- entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(villagerprofession)); +- entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(villagerprofession)); + // CraftBukkit start - Fire VillagerCareerChangeEvent where Villager gets employed + VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.nmsToBukkitProfession(villagerprofession), VillagerCareerChangeEvent.ChangeReason.EMPLOYED); + if (event.isCancelled()) { + return; + } + -+ entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(CraftVillager.bukkitToNmsProfession(event.getProfession()))); ++ entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(CraftVillager.bukkitToNmsProfession(event.getProfession()))); + // CraftBukkit end - entityvillager.c(worldserver); + entityvillager.refreshBrain(worldserver); }); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFarm.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFarm.patch index ddbbf1ee67..78c3c972e7 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFarm.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFarm.patch @@ -2,54 +2,54 @@ +++ b/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java @@ -80,8 +80,8 @@ - protected void a(WorldServer worldserver, EntityVillager entityvillager, long i) { + protected void start(WorldServer worldserver, EntityVillager entityvillager, long i) { if (i > this.nextOkStartTime && this.aboveFarmlandPos != null) { -- entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(this.aboveFarmlandPos))); -- entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(new BehaviorTarget(this.aboveFarmlandPos), 0.5F, 1))); -+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(this.aboveFarmlandPos))); // CraftBukkit - decompile error -+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(new BehaviorTarget(this.aboveFarmlandPos), 0.5F, 1))); // CraftBukkit - decompile error +- 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 } } @@ -101,7 +101,11 @@ - Block block1 = worldserver.getType(this.aboveFarmlandPos.down()).getBlock(); + Block block1 = worldserver.getBlockState(this.aboveFarmlandPos.below()).getBlock(); - if (block instanceof BlockCrops && ((BlockCrops) block).isRipe(iblockdata)) { -- worldserver.a(this.aboveFarmlandPos, true, entityvillager); + if (block instanceof BlockCrops && ((BlockCrops) block).isMaxAge(iblockdata)) { +- worldserver.destroyBlock(this.aboveFarmlandPos, true, entityvillager); + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, Blocks.AIR.getBlockData()).isCancelled()) { -+ worldserver.a(this.aboveFarmlandPos, true, entityvillager); ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, Blocks.AIR.defaultBlockState()).isCancelled()) { ++ worldserver.destroyBlock(this.aboveFarmlandPos, true, entityvillager); + } + // CraftBukkit end } - if (iblockdata.isAir() && block1 instanceof BlockSoil && entityvillager.canPlant()) { + if (iblockdata.isAir() && block1 instanceof BlockSoil && entityvillager.hasFarmSeeds()) { @@ -112,19 +116,28 @@ boolean flag = false; if (!itemstack.isEmpty()) { + // CraftBukkit start + Block planted = null; - if (itemstack.a(Items.WHEAT_SEEDS)) { -- worldserver.setTypeAndData(this.aboveFarmlandPos, Blocks.WHEAT.getBlockData(), 3); + if (itemstack.is(Items.WHEAT_SEEDS)) { +- worldserver.setBlock(this.aboveFarmlandPos, Blocks.WHEAT.defaultBlockState(), 3); + planted = Blocks.WHEAT; flag = true; - } else if (itemstack.a(Items.POTATO)) { -- worldserver.setTypeAndData(this.aboveFarmlandPos, Blocks.POTATOES.getBlockData(), 3); + } else if (itemstack.is(Items.POTATO)) { +- worldserver.setBlock(this.aboveFarmlandPos, Blocks.POTATOES.defaultBlockState(), 3); + planted = Blocks.POTATOES; flag = true; - } else if (itemstack.a(Items.CARROT)) { -- worldserver.setTypeAndData(this.aboveFarmlandPos, Blocks.CARROTS.getBlockData(), 3); + } else if (itemstack.is(Items.CARROT)) { +- worldserver.setBlock(this.aboveFarmlandPos, Blocks.CARROTS.defaultBlockState(), 3); + planted = Blocks.CARROTS; flag = true; - } else if (itemstack.a(Items.BEETROOT_SEEDS)) { -- worldserver.setTypeAndData(this.aboveFarmlandPos, Blocks.BEETROOTS.getBlockData(), 3); + } else if (itemstack.is(Items.BEETROOT_SEEDS)) { +- worldserver.setBlock(this.aboveFarmlandPos, Blocks.BEETROOTS.defaultBlockState(), 3); + planted = Blocks.BEETROOTS; flag = true; } + -+ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, planted.getBlockData()).isCancelled()) { -+ worldserver.setTypeAndData(this.aboveFarmlandPos, planted.getBlockData(), 3); ++ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, planted.defaultBlockState()).isCancelled()) { ++ worldserver.setBlock(this.aboveFarmlandPos, planted.defaultBlockState(), 3); + } else { + flag = false; + } @@ -58,13 +58,13 @@ if (flag) { @@ -143,8 +156,8 @@ - this.aboveFarmlandPos = this.a(worldserver); + this.aboveFarmlandPos = this.getValidFarmland(worldserver); if (this.aboveFarmlandPos != null) { this.nextOkStartTime = i + 20L; -- entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(new BehaviorTarget(this.aboveFarmlandPos), 0.5F, 1))); -- entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(this.aboveFarmlandPos))); -+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(new BehaviorTarget(this.aboveFarmlandPos), 0.5F, 1))); // CraftBukkit - decompile error -+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(this.aboveFarmlandPos))); // CraftBukkit - decompile error +- 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/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.patch index b5683cc349..52d6af560a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.patch @@ -3,7 +3,7 @@ @@ -69,6 +69,13 @@ BlockDoor blockdoor = (BlockDoor) iblockdata.getBlock(); - if (!blockdoor.h(iblockdata)) { + if (!blockdoor.isOpen(iblockdata)) { + // CraftBukkit start - entities opening doors + org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entityliving.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(entityliving.level, blockposition)); + entityliving.level.getCraftServer().getPluginManager().callEvent(event); @@ -11,13 +11,13 @@ + return; + } + // CraftBukkit end - blockdoor.setDoor(entityliving, worldserver, iblockdata, blockposition, true); + blockdoor.setOpen(entityliving, worldserver, iblockdata, blockposition, true); } @@ -82,6 +89,13 @@ BlockDoor blockdoor1 = (BlockDoor) iblockdata1.getBlock(); - if (!blockdoor1.h(iblockdata1)) { + if (!blockdoor1.isOpen(iblockdata1)) { + // CraftBukkit start - entities opening doors + org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entityliving.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(entityliving.level, blockposition1)); + entityliving.level.getCraftServer().getPluginManager().callEvent(event); @@ -25,18 +25,18 @@ + return; + } + // CraftBukkit end - blockdoor1.setDoor(entityliving, worldserver, iblockdata1, blockposition1, true); - this.c(worldserver, entityliving, blockposition1); + blockdoor1.setOpen(entityliving, worldserver, iblockdata1, blockposition1, true); + this.rememberDoorToClose(worldserver, entityliving, blockposition1); } @@ -130,7 +144,7 @@ - private static boolean a(WorldServer worldserver, EntityLiving entityliving, BlockPosition blockposition) { - BehaviorController<?> behaviorcontroller = entityliving.getBehaviorController(); + private static boolean areOtherMobsComingThroughDoor(WorldServer worldserver, EntityLiving entityliving, BlockPosition blockposition) { + BehaviorController<?> behaviorcontroller = entityliving.getBrain(); -- return !behaviorcontroller.hasMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES) ? false : ((List) behaviorcontroller.getMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES).get()).stream().filter((entityliving1) -> { -+ return !behaviorcontroller.hasMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES) ? false : (behaviorcontroller.getMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES).get()).stream().filter((entityliving1) -> { // CraftBukkit - decompile error - return entityliving1.getEntityType() == entityliving.getEntityType(); +- return !behaviorcontroller.hasMemoryValue(MemoryModuleType.NEAREST_LIVING_ENTITIES) ? false : ((List) behaviorcontroller.getMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES).get()).stream().filter((entityliving1) -> { ++ return !behaviorcontroller.hasMemoryValue(MemoryModuleType.NEAREST_LIVING_ENTITIES) ? false : (behaviorcontroller.getMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES).get()).stream().filter((entityliving1) -> { // CraftBukkit - decompile error + return entityliving1.getType() == entityliving.getType(); }).filter((entityliving1) -> { - return blockposition.a((IPosition) entityliving1.getPositionVector(), 2.0D); + return blockposition.closerThan((IPosition) entityliving1.position(), 2.0D); @@ -172,7 +186,7 @@ if (behaviorcontroller.getMemory(MemoryModuleType.DOORS_TO_CLOSE).isPresent()) { ((Set) behaviorcontroller.getMemory(MemoryModuleType.DOORS_TO_CLOSE).get()).add(globalpos); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.patch index 5c05098fd0..097921ca2f 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.patch @@ -4,27 +4,27 @@ if (entityvillager2 == null) { return Optional.empty(); } else { -- entityvillager.setAgeRaw(6000); -- entityvillager1.setAgeRaw(6000); +- entityvillager.setAge(6000); +- entityvillager1.setAge(6000); + // CraftBukkit start - call EntityBreedEvent - entityvillager2.setAgeRaw(-24000); - entityvillager2.setPositionRotation(entityvillager.locX(), entityvillager.locY(), entityvillager.locZ(), 0.0F, 0.0F); -- worldserver.addAllEntities(entityvillager2); + entityvillager2.setAge(-24000); + entityvillager2.moveTo(entityvillager.getX(), entityvillager.getY(), entityvillager.getZ(), 0.0F, 0.0F); +- worldserver.addFreshEntityWithPassengers(entityvillager2); + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityvillager2, entityvillager, entityvillager1, null, null, 0).isCancelled()) { + return Optional.empty(); + } + // CraftBukkit end -+ entityvillager.setAgeRaw(6000); -+ entityvillager1.setAgeRaw(6000); -+ worldserver.addAllEntities(entityvillager2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason - worldserver.broadcastEntityEffect(entityvillager2, (byte) 12); ++ entityvillager.setAge(6000); ++ entityvillager1.setAge(6000); ++ worldserver.addFreshEntityWithPassengers(entityvillager2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason + worldserver.broadcastEntityEvent(entityvillager2, (byte) 12); return Optional.of(entityvillager2); } @@ -125,6 +130,6 @@ - private void a(WorldServer worldserver, EntityVillager entityvillager, BlockPosition blockposition) { - GlobalPos globalpos = GlobalPos.create(worldserver.getDimensionKey(), blockposition); + private void giveBedToChild(WorldServer worldserver, EntityVillager entityvillager, BlockPosition blockposition) { + GlobalPos globalpos = GlobalPos.of(worldserver.dimension(), blockposition); -- entityvillager.getBehaviorController().setMemory(MemoryModuleType.HOME, (Object) globalpos); -+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.HOME, globalpos); // CraftBukkit - decompile error +- entityvillager.getBrain().setMemory(MemoryModuleType.HOME, (Object) globalpos); ++ entityvillager.getBrain().setMemory(MemoryModuleType.HOME, globalpos); // CraftBukkit - decompile error } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorProfession.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorProfession.patch index eecf2cbc82..3b30b6656f 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorProfession.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorProfession.patch @@ -16,16 +16,16 @@ @@ -21,7 +27,14 @@ } - protected void a(WorldServer worldserver, EntityVillager entityvillager, long i) { -- entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(VillagerProfession.NONE)); + protected void start(WorldServer worldserver, EntityVillager entityvillager, long i) { +- entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(VillagerProfession.NONE)); + // CraftBukkit start + VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.nmsToBukkitProfession(VillagerProfession.NONE), VillagerCareerChangeEvent.ChangeReason.EMPLOYED); + if (event.isCancelled()) { + return; + } + -+ entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(CraftVillager.bukkitToNmsProfession(event.getProfession()))); ++ entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(CraftVillager.bukkitToNmsProfession(event.getProfession()))); + // CraftBukkit end - entityvillager.c(worldserver); + entityvillager.refreshBrain(worldserver); } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorUtil.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorUtil.patch index c303647806..33e92d6990 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorUtil.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorUtil.patch @@ -1,42 +1,42 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorUtil.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorUtil.java -@@ -62,7 +62,7 @@ +@@ -61,7 +61,7 @@ } - public static void a(EntityLiving entityliving, EntityLiving entityliving1) { -- entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorPositionEntity(entityliving1, true))); -+ entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorPositionEntity(entityliving1, true))); // CraftBukkit - decompile error + 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 b(EntityLiving entityliving, EntityLiving entityliving1, float f) { -@@ -75,18 +75,19 @@ - public static void a(EntityLiving entityliving, Entity entity, float f, int i) { + private static void setWalkAndLookTargetMemoriesToEachOther(EntityLiving entityliving, EntityLiving entityliving1, float f) { +@@ -74,18 +74,19 @@ + public static void setWalkAndLookTargetMemories(EntityLiving entityliving, Entity entity, float f, int i) { MemoryTarget memorytarget = new MemoryTarget(new BehaviorPositionEntity(entity, false), f, i); -- entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorPositionEntity(entity, true))); -- entityliving.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (Object) memorytarget); -+ entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorPositionEntity(entity, true))); // CraftBukkit - decompile error -+ entityliving.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, memorytarget); // CraftBukkit - decompile error +- entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorPositionEntity(entity, true))); +- entityliving.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) memorytarget); ++ entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorPositionEntity(entity, true))); // CraftBukkit - decompile error ++ entityliving.getBrain().setMemory(MemoryModuleType.WALK_TARGET, memorytarget); // CraftBukkit - decompile error } - public static void a(EntityLiving entityliving, BlockPosition blockposition, float f, int i) { + public static void setWalkAndLookTargetMemories(EntityLiving entityliving, BlockPosition blockposition, float f, int i) { MemoryTarget memorytarget = new MemoryTarget(new BehaviorTarget(blockposition), f, i); -- entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(blockposition))); -- entityliving.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (Object) memorytarget); -+ entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(blockposition))); // CraftBukkit - decompile error -+ entityliving.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, memorytarget); // CraftBukkit - decompile error +- entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(blockposition))); +- entityliving.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) memorytarget); ++ entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(blockposition))); // CraftBukkit - decompile error ++ entityliving.getBrain().setMemory(MemoryModuleType.WALK_TARGET, memorytarget); // CraftBukkit - decompile error } - public static void a(EntityLiving entityliving, ItemStack itemstack, Vec3D vec3d) { + public static void throwItem(EntityLiving entityliving, ItemStack itemstack, Vec3D vec3d) { + if (itemstack.isEmpty()) return; // CraftBukkit - SPIGOT-4940: no empty loot - double d0 = entityliving.getHeadY() - 0.30000001192092896D; - EntityItem entityitem = new EntityItem(entityliving.level, entityliving.locX(), d0, entityliving.locZ(), itemstack); + double d0 = entityliving.getEyeY() - 0.30000001192092896D; + EntityItem entityitem = new EntityItem(entityliving.level, entityliving.getX(), d0, entityliving.getZ(), itemstack); float f = 0.3F; -@@ -95,12 +96,19 @@ - vec3d1 = vec3d1.d().a(0.30000001192092896D); - entityitem.setMot(vec3d1); - entityitem.defaultPickupDelay(); +@@ -94,12 +95,19 @@ + vec3d1 = vec3d1.normalize().scale(0.30000001192092896D); + entityitem.setDeltaMovement(vec3d1); + entityitem.setDefaultPickUpDelay(); + // CraftBukkit start + org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(entityliving.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); + entityitem.level.getCraftServer().getPluginManager().callEvent(event); @@ -44,13 +44,13 @@ + return; + } + // CraftBukkit end - entityliving.level.addEntity(entityitem); + entityliving.level.addFreshEntity(entityitem); } - public static SectionPosition a(WorldServer worldserver, SectionPosition sectionposition, int i) { - int j = worldserver.b(sectionposition); -- Stream stream = SectionPosition.a(sectionposition, i).filter((sectionposition1) -> { -+ Stream<SectionPosition> stream = SectionPosition.a(sectionposition, i).filter((sectionposition1) -> { // CraftBukkit - decompile error - return worldserver.b(sectionposition1) < j; + public static SectionPosition findSectionClosestToVillage(WorldServer worldserver, SectionPosition sectionposition, int i) { + int j = worldserver.sectionsToVillage(sectionposition); +- Stream stream = SectionPosition.cube(sectionposition, i).filter((sectionposition1) -> { ++ Stream<SectionPosition> stream = SectionPosition.cube(sectionposition, i).filter((sectionposition1) -> { // CraftBukkit - decompile error + return worldserver.sectionsToVillage(sectionposition1) < j; }); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter.patch index f84244a46a..364417de50 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter.patch @@ -1,20 +1,11 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter.java -@@ -23,7 +23,7 @@ - public BehaviorWorkComposter() {} - - @Override -- protected void a(WorldServer worldserver, EntityVillager entityvillager) { -+ protected void doWork(WorldServer worldserver, EntityVillager entityvillager) { // PAIL - Optional<GlobalPos> optional = entityvillager.getBehaviorController().getMemory(MemoryModuleType.JOB_SITE); - - if (optional.isPresent()) { @@ -42,7 +42,7 @@ - BlockPosition blockposition = globalpos.getBlockPosition(); + BlockPosition blockposition = globalpos.pos(); - if ((Integer) iblockdata.get(BlockComposter.LEVEL) == 8) { -- iblockdata = BlockComposter.d(iblockdata, worldserver, blockposition); -+ iblockdata = BlockComposter.d(iblockdata, worldserver, blockposition, entityvillager); // CraftBukkit + if ((Integer) iblockdata.getValue(BlockComposter.LEVEL) == 8) { +- iblockdata = BlockComposter.extractProduce(iblockdata, worldserver, blockposition); ++ iblockdata = BlockComposter.extractProduce(iblockdata, worldserver, blockposition, entityvillager); // CraftBukkit } int i = 20; @@ -22,8 +13,8 @@ i -= k1; for (int l1 = 0; l1 < k1; ++l1) { -- iblockdata1 = BlockComposter.a(iblockdata1, worldserver, itemstack, blockposition); -+ iblockdata1 = BlockComposter.a(iblockdata1, worldserver, itemstack, blockposition, entityvillager); // CraftBukkit - if ((Integer) iblockdata1.get(BlockComposter.LEVEL) == 7) { - this.a(worldserver, iblockdata, blockposition, iblockdata1); +- iblockdata1 = BlockComposter.insertItem(iblockdata1, worldserver, itemstack, blockposition); ++ iblockdata1 = BlockComposter.insertItem(iblockdata1, worldserver, itemstack, blockposition, entityvillager); // CraftBukkit + if ((Integer) iblockdata1.getValue(BlockComposter.LEVEL) == 7) { + this.spawnComposterFillEffects(worldserver, iblockdata, blockposition, iblockdata1); return; diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.patch index c593aaf229..efb9ab5295 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.patch @@ -3,13 +3,13 @@ @@ -72,6 +72,12 @@ } - if (this.breakTime == this.f() && this.a(this.mob.level.getDifficulty())) { + if (this.breakTime == this.getDoorBreakTime() && this.isValidDifficulty(this.mob.level.getDifficulty())) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreakDoorEvent(this.mob, this.doorPos).isCancelled()) { -+ this.c(); ++ this.start(); + return; + } + // CraftBukkit end - this.mob.level.a(this.doorPos, false); - this.mob.level.triggerEffect(1021, this.doorPos, 0); - this.mob.level.triggerEffect(2001, this.doorPos, Block.getCombinedId(this.mob.level.getType(this.doorPos))); + this.mob.level.removeBlock(this.doorPos, false); + this.mob.level.levelEvent(1021, this.doorPos, 0); + this.mob.level.levelEvent(2001, this.doorPos, Block.getId(this.mob.level.getBlockState(this.doorPos))); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.patch index 5b3f4edbaf..6b42afe55b 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.patch @@ -12,22 +12,22 @@ private static final int EAT_ANIMATION_TICKS = 40; @@ -65,7 +69,8 @@ - BlockPosition blockposition = this.mob.getChunkCoordinates(); + BlockPosition blockposition = this.mob.blockPosition(); - if (PathfinderGoalEatTile.IS_TALL_GRASS.test(this.level.getType(blockposition))) { + if (PathfinderGoalEatTile.IS_TALL_GRASS.test(this.level.getBlockState(blockposition))) { - if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + // CraftBukkit -+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.getBlockData(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) { - this.level.b(blockposition, false); ++ if (!CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.defaultBlockState(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) { + this.level.destroyBlock(blockposition, false); } @@ -75,7 +80,8 @@ - BlockPosition blockposition1 = blockposition.down(); + BlockPosition blockposition1 = blockposition.below(); - if (this.level.getType(blockposition1).a(Blocks.GRASS_BLOCK)) { + if (this.level.getBlockState(blockposition1).is(Blocks.GRASS_BLOCK)) { - if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + // CraftBukkit -+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition1, Blocks.AIR.getBlockData(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) { - this.level.triggerEffect(2001, blockposition1, Block.getCombinedId(Blocks.GRASS_BLOCK.getBlockData())); - this.level.setTypeAndData(blockposition1, Blocks.DIRT.getBlockData(), 2); ++ if (!CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition1, Blocks.AIR.defaultBlockState(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) { + this.level.levelEvent(2001, blockposition1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState())); + this.level.setBlock(blockposition1, Blocks.DIRT.defaultBlockState(), 2); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.patch index 76cc491334..432694f3aa 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.java +++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.java -@@ -15,6 +15,12 @@ +@@ -14,6 +14,12 @@ import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.level.pathfinder.PathfinderNormal; @@ -13,11 +13,11 @@ public class PathfinderGoalFollowOwner extends PathfinderGoal { public static final int TELEPORT_WHEN_DISTANCE_IS = 12; -@@ -121,7 +127,18 @@ - } else if (!this.a(new BlockPosition(i, j, k))) { +@@ -120,7 +126,18 @@ + } else if (!this.canTeleportTo(new BlockPosition(i, j, k))) { return false; } else { -- this.tamable.setPositionRotation((double) i + 0.5D, (double) j, (double) k + 0.5D, this.tamable.getYRot(), this.tamable.getXRot()); +- this.tamable.moveTo((double) i + 0.5D, (double) j, (double) k + 0.5D, this.tamable.getYRot(), this.tamable.getXRot()); + // CraftBukkit start + CraftEntity entity = this.tamable.getBukkitEntity(); + Location to = new Location(entity.getWorld(), (double) i + 0.5D, (double) j, (double) k + 0.5D, this.tamable.getYRot(), this.tamable.getXRot()); @@ -28,8 +28,8 @@ + } + to = event.getTo(); + -+ this.tamable.setPositionRotation(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch()); ++ this.tamable.moveTo(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch()); + // CraftBukkit end - this.navigation.o(); + this.navigation.stop(); return true; } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalPanic.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalPanic.patch index d16a9774f8..0c0c52b664 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalPanic.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalPanic.patch @@ -10,17 +10,25 @@ + public class PathfinderGoalPanic extends PathfinderGoal { - protected final EntityCreature mob; -@@ -76,6 +80,12 @@ + public static final int WATER_CHECK_DISTANCE_VERTICAL = 1; +@@ -77,6 +81,12 @@ @Override - public boolean b() { + public boolean canContinueToUse() { + // CraftBukkit start - introduce a temporary timeout hack until this is fixed properly + if ((this.mob.tickCount - this.mob.lastHurtByMobTimestamp) > 100) { -+ this.mob.setLastDamager((EntityLiving) null); ++ this.mob.setLastHurtByMob((EntityLiving) null); + return false; + } + // CraftBukkit end - return !this.mob.getNavigation().m(); + return !this.mob.getNavigation().isDone(); } +@@ -86,6 +96,6 @@ + + return !iblockaccess.getBlockState(blockposition).getCollisionShape(iblockaccess, blockposition).isEmpty() ? null : (BlockPosition) BlockPosition.findClosestMatch(entity.blockPosition(), i, 1, (blockposition1) -> { + return iblockaccess.getFluidState(blockposition1).is((Tag) TagsFluid.WATER); +- }).orElse((Object) null); ++ }).orElse(null); // CraftBukkit - decompile error + } + } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.patch index a4c3237d34..0611fdf552 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.patch @@ -24,6 +24,6 @@ + return; + } + // CraftBukkit end - world.a(blockposition1, false); + world.removeBlock(blockposition1, false); if (!world.isClientSide) { for (int i = 0; i < 20; ++i) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.patch index 5986cc7dcb..5dcfbc00f6 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.java @@ -22,7 +22,7 @@ @Override - public boolean a() { - if (!this.mob.isTamed()) { + public boolean canUse() { + if (!this.mob.isTame()) { - return false; -+ return this.mob.isWillSit() && this.mob.getGoalTarget() == null; // CraftBukkit - Allow sitting for wild animals - } else if (this.mob.aO()) { ++ 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.isOnGround()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.patch index 3cf9f8ebf6..1ec38c25e4 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.patch @@ -2,11 +2,11 @@ +++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.java @@ -62,7 +62,8 @@ int i = this.horse.getTemper(); - int j = this.horse.getMaxDomestication(); + int j = this.horse.getMaxTemper(); - if (j > 0 && this.horse.getRandom().nextInt(j) < i) { + // CraftBukkit - fire EntityTameEvent + if (j > 0 && this.horse.getRandom().nextInt(j) < i && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this.horse, ((org.bukkit.craftbukkit.entity.CraftHumanEntity) this.horse.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) { - this.horse.i((EntityHuman) entity); + this.horse.tameWithName((EntityHuman) entity); return; } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.patch index 25b172ad14..c6b5c45c10 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.java +++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.java -@@ -8,6 +8,13 @@ +@@ -9,6 +9,13 @@ import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.crafting.RecipeItemStack; @@ -13,20 +13,20 @@ + public class PathfinderGoalTempt extends PathfinderGoal { - private static final PathfinderTargetCondition TEMP_TARGETING = PathfinderTargetCondition.b().a(10.0D).d(); -@@ -19,7 +26,7 @@ - private double pz; + private static final PathfinderTargetCondition TEMP_TARGETING = PathfinderTargetCondition.forNonCombat().range(10.0D).ignoreLineOfSight(); +@@ -21,7 +28,7 @@ private double pRotX; private double pRotY; + @Nullable - protected EntityHuman player; + protected EntityLiving player; // CraftBukkit private int calmDown; private boolean isRunning; private final RecipeItemStack items; -@@ -41,6 +48,15 @@ +@@ -43,6 +50,15 @@ return false; } else { - this.player = this.mob.level.a(this.targetingConditions, (EntityLiving) this.mob); + this.player = this.mob.level.getNearestPlayer(this.targetingConditions, this.mob); + // CraftBukkit start + if (this.player != null) { + EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this.mob, this.player, EntityTargetEvent.TargetReason.TEMPT); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.patch index f4b9b4ac65..8e8bf5a04a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.java +++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.java -@@ -56,7 +56,7 @@ +@@ -58,7 +58,7 @@ @Override - public void c() { -- this.golem.setGoalTarget(this.potentialTarget); -+ this.golem.setGoalTarget(this.potentialTarget, org.bukkit.event.entity.EntityTargetEvent.TargetReason.DEFEND_VILLAGE, true); // CraftBukkit - reason - super.c(); + public void start() { +- this.golem.setTarget(this.potentialTarget); ++ this.golem.setTarget(this.potentialTarget, org.bukkit.event.entity.EntityTargetEvent.TargetReason.DEFEND_VILLAGE, true); // CraftBukkit - reason + super.start(); } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.patch index 6fc18e9c43..713349a4d2 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.java +++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.java -@@ -64,7 +64,7 @@ +@@ -67,7 +67,7 @@ @Override - public void c() { -- this.mob.setGoalTarget(this.mob.getLastDamager()); -+ this.mob.setGoalTarget(this.mob.getLastDamager(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason - this.targetMob = this.mob.getGoalTarget(); - this.timestamp = this.mob.dH(); + public void start() { +- this.mob.setTarget(this.mob.getLastHurtByMob()); ++ this.mob.setTarget(this.mob.getLastHurtByMob(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason + this.targetMob = this.mob.getTarget(); + this.timestamp = this.mob.getLastHurtByMobTimestamp(); this.unseenMemoryTicks = 300; -@@ -111,6 +111,6 @@ +@@ -114,6 +114,6 @@ } - protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) { -- entityinsentient.setGoalTarget(entityliving); -+ entityinsentient.setGoalTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit - reason + protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) { +- entityinsentient.setTarget(entityliving); ++ entityinsentient.setTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit - reason } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.patch index 0b2cd58b06..65145cb431 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.java +++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.java -@@ -61,7 +61,7 @@ +@@ -62,7 +62,7 @@ @Override - public void c() { -- this.mob.setGoalTarget(this.target); -+ this.mob.setGoalTarget(this.target, target instanceof EntityPlayer ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit - reason - super.c(); + public void start() { +- this.mob.setTarget(this.target); ++ this.mob.setTarget(this.target, target instanceof EntityPlayer ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit - reason + super.start(); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalOwnerHurtByTarget.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalOwnerHurtByTarget.patch index 668f83be17..4d1c071dfc 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalOwnerHurtByTarget.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalOwnerHurtByTarget.patch @@ -3,9 +3,9 @@ @@ -38,7 +38,7 @@ @Override - public void c() { -- this.mob.setGoalTarget(this.ownerLastHurtBy); -+ this.mob.setGoalTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit - reason + public void start() { +- this.mob.setTarget(this.ownerLastHurtBy); ++ this.mob.setTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit - reason EntityLiving entityliving = this.tameAnimal.getOwner(); if (entityliving != null) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalOwnerHurtTarget.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalOwnerHurtTarget.patch index e1ca9f68ae..db655681e5 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalOwnerHurtTarget.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalOwnerHurtTarget.patch @@ -3,9 +3,9 @@ @@ -38,7 +38,7 @@ @Override - public void c() { -- this.mob.setGoalTarget(this.ownerLastHurt); -+ this.mob.setGoalTarget(this.ownerLastHurt, org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit - reason + public void start() { +- this.mob.setTarget(this.ownerLastHurt); ++ this.mob.setTarget(this.ownerLastHurt, org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit - reason EntityLiving entityliving = this.tameAnimal.getOwner(); if (entityliving != null) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.patch index 58a511445d..fa99f1d618 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.patch @@ -9,21 +9,21 @@ public abstract class PathfinderGoalTarget extends PathfinderGoal { private static final int EMPTY_REACH_CACHE = 0; -@@ -68,7 +70,7 @@ +@@ -69,7 +71,7 @@ } } -- this.mob.setGoalTarget(entityliving); -+ this.mob.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit +- this.mob.setTarget(entityliving); ++ this.mob.setTarget(entityliving, EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit return true; } } -@@ -88,7 +90,7 @@ +@@ -89,7 +91,7 @@ @Override - public void d() { -- this.mob.setGoalTarget((EntityLiving) null); -+ this.mob.setGoalTarget((EntityLiving) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit + public void stop() { +- this.mob.setTarget((EntityLiving) null); ++ this.mob.setTarget((EntityLiving) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit this.targetMob = null; } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/village/VillageSiege.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/village/VillageSiege.patch index 56b6b9b8b4..59d73fb17b 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/village/VillageSiege.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/village/VillageSiege.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/ai/village/VillageSiege.java +++ b/net/minecraft/world/entity/ai/village/VillageSiege.java -@@ -123,7 +123,7 @@ +@@ -122,7 +122,7 @@ } - entityzombie.setPositionRotation(vec3d.x, vec3d.y, vec3d.z, worldserver.random.nextFloat() * 360.0F, 0.0F); -- worldserver.addAllEntities(entityzombie); -+ worldserver.addAllEntities(entityzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_INVASION); // CraftBukkit + entityzombie.moveTo(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/paper-server/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch b/paper-server/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch index a81b8ada31..e40668ff2f 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch +++ b/paper-server/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,8 @@ +@@ -29,6 +29,8 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.Vec3D; @@ -12,12 +12,12 @@ @@ -138,16 +140,24 @@ } - if (this.level.a(EntityBat.BAT_RESTING_TARGETING, (EntityLiving) this) != null) { + if (this.level.getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null) { + // CraftBukkit Start - Call BatToggleSleepEvent + if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { -+ this.setAsleep(false); ++ this.setResting(false); + if (!flag) { -+ this.level.a((EntityHuman) null, 1025, blockposition, 0); ++ this.level.levelEvent((EntityHuman) null, 1025, blockposition, 0); + } + } + // CraftBukkit End @@ -25,28 +25,28 @@ + } else { + // CraftBukkit Start - Call BatToggleSleepEvent + if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { - this.setAsleep(false); + this.setResting(false); if (!flag) { - this.level.a((EntityHuman) null, 1025, blockposition, 0); + this.level.levelEvent((EntityHuman) null, 1025, blockposition, 0); } } - } else { -- this.setAsleep(false); +- this.setResting(false); - if (!flag) { -- this.level.a((EntityHuman) null, 1025, blockposition, 0); +- this.level.levelEvent((EntityHuman) null, 1025, blockposition, 0); - } + // CraftBukkit End - Call BatToggleSleepEvent } } else { - if (this.targetPosition != null && (!this.level.isEmpty(this.targetPosition) || this.targetPosition.getY() <= this.level.getMinBuildHeight())) { + if (this.targetPosition != null && (!this.level.isEmptyBlock(this.targetPosition) || this.targetPosition.getY() <= this.level.getMinBuildHeight())) { @@ -171,7 +181,11 @@ this.zza = 0.5F; this.setYRot(this.getYRot() + f1); - if (this.random.nextInt(100) == 0 && this.level.getType(blockposition1).isOccluding(this.level, blockposition1)) { -- this.setAsleep(true); + if (this.random.nextInt(100) == 0 && this.level.getBlockState(blockposition1).isRedstoneConductor(this.level, blockposition1)) { +- this.setResting(true); + // CraftBukkit Start - Call BatToggleSleepEvent + if (CraftEventFactory.handleBatToggleSleepEvent(this, false)) { -+ this.setAsleep(true); ++ this.setResting(true); + } + // CraftBukkit End } @@ -55,13 +55,13 @@ @@ -201,7 +215,11 @@ return false; } else { - if (!this.level.isClientSide && this.isAsleep()) { -- this.setAsleep(false); + if (!this.level.isClientSide && this.isResting()) { +- this.setResting(false); + // CraftBukkit Start - Call BatToggleSleepEvent + if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { -+ this.setAsleep(false); ++ this.setResting(false); + } + // CraftBukkit End - Call BatToggleSleepEvent } - return super.damageEntity(damagesource, f); + return super.hurt(damagesource, f); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch index 82e73ce5d3..4a61216aac 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch @@ -14,28 +14,28 @@ + public interface Bucketable { - boolean isFromBucket(); + boolean fromBucket(); @@ -92,10 +100,22 @@ - ItemStack itemstack = entityhuman.b(enumhand); + ItemStack itemstack = entityhuman.getItemInHand(enumhand); if (itemstack.getItem() == Items.WATER_BUCKET && t0.isAlive()) { -- t0.playSound(((Bucketable) t0).t(), 1.0F, 1.0F); +- t0.playSound(((Bucketable) t0).getPickupSound(), 1.0F, 1.0F); + // CraftBukkit start -+ // t0.playSound(((Bucketable) t0).t(), 1.0F, 1.0F); // CraftBukkit - moved down - ItemStack itemstack1 = ((Bucketable) t0).getBucketItem(); ++ // t0.playSound(((Bucketable) t0).getPickupSound(), 1.0F, 1.0F); // CraftBukkit - moved down + ItemStack itemstack1 = ((Bucketable) t0).getBucketItemStack(); - ((Bucketable) t0).setBucketName(itemstack1); + ((Bucketable) t0).saveToBucketTag(itemstack1); + + PlayerBucketEntityEvent playerBucketFishEvent = CraftEventFactory.callPlayerFishBucketEvent(t0, entityhuman, itemstack, itemstack1); + itemstack1 = CraftItemStack.asNMSCopy(playerBucketFishEvent.getEntityBucket()); + if (playerBucketFishEvent.isCancelled()) { -+ ((EntityPlayer) entityhuman).containerMenu.updateInventory(); // We need to update inventory to resync client's bucket -+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutSpawnEntityLiving(t0)); // We need to play out these packets as the client assumes the fish is gone -+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutEntityMetadata(t0.getId(), t0.getDataWatcher(), true)); // Need to send data such as the display name to client ++ ((EntityPlayer) entityhuman).containerMenu.sendAllDataToRemote(); // We need to update inventory to resync client's bucket ++ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutSpawnEntityLiving(t0)); // We need to play out these packets as the client assumes the fish is gone ++ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutEntityMetadata(t0.getId(), t0.getEntityData(), true)); // Need to send data such as the display name to client + return Optional.of(EnumInteractionResult.FAIL); + } -+ t0.playSound(((Bucketable) t0).t(), 1.0F, 1.0F); ++ t0.playSound(((Bucketable) t0).getPickupSound(), 1.0F, 1.0F); + // CraftBukkit end - ItemStack itemstack2 = ItemLiquidUtil.a(itemstack, entityhuman, itemstack1, false); + ItemStack itemstack2 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false); - entityhuman.a(enumhand, itemstack2); + entityhuman.setItemInHand(enumhand, itemstack2); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch index 3336d8b12b..41d146e10b 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch +++ b/paper-server/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 -@@ -28,11 +28,18 @@ +@@ -31,12 +31,19 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.pathfinder.PathType; @@ -14,12 +14,13 @@ static final int PARENT_AGE_AFTER_BREEDING = 6000; public int inLove; + @Nullable public UUID loveCause; + public ItemStack breedItem; // CraftBukkit - Add breedItem variable protected EntityAnimal(EntityTypes<? extends EntityAnimal> entitytypes, World world) { super(entitytypes, world); -@@ -69,6 +76,9 @@ +@@ -73,6 +80,9 @@ } @@ -27,20 +28,20 @@ + // Function disabled as it has no special function anymore after + // setSitting is disabled. @Override - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable(damagesource)) { -@@ -78,6 +88,7 @@ - return super.damageEntity(damagesource, f); + public boolean hurt(DamageSource damagesource, float f) { + if (this.isInvulnerableTo(damagesource)) { +@@ -82,6 +92,7 @@ + return super.hurt(damagesource, f); } } + // CraftBukkit end */ @Override - public float a(BlockPosition blockposition, IWorldReader iworldreader) { -@@ -170,10 +181,17 @@ + public float getWalkTargetValue(BlockPosition blockposition, IWorldReader iworldreader) { +@@ -178,10 +189,17 @@ } - public void g(@Nullable EntityHuman entityhuman) { + public void setInLove(@Nullable EntityHuman entityhuman) { - this.inLove = 600; + // CraftBukkit start + EntityEnterLoveModeEvent entityEnterLoveModeEvent = CraftEventFactory.callEntityEnterLoveModeEvent(entityhuman, this, 600); @@ -50,29 +51,29 @@ + this.inLove = entityEnterLoveModeEvent.getTicksInLove(); + // CraftBukkit end if (entityhuman != null) { - this.loveCause = entityhuman.getUniqueID(); + this.loveCause = entityhuman.getUUID(); } -+ this.breedItem = entityhuman.getInventory().getItemInHand(); // CraftBukkit ++ this.breedItem = entityhuman.getInventory().getSelected(); // CraftBukkit - this.level.broadcastEntityEffect(this, (byte) 18); + this.level.broadcastEntityEvent(this, (byte) 18); } -@@ -213,11 +231,26 @@ - EntityAgeable entityageable = this.createChild(worldserver, entityanimal); +@@ -221,11 +239,26 @@ + EntityAgeable entityageable = this.getBreedOffspring(worldserver, entityanimal); if (entityageable != null) { + // CraftBukkit start - set persistence for tame animals -+ if (entityageable instanceof EntityTameableAnimal && ((EntityTameableAnimal) entityageable).isTamed()) { ++ if (entityageable instanceof EntityTameableAnimal && ((EntityTameableAnimal) entityageable).isTame()) { + entityageable.setPersistenceRequired(true); + } + // CraftBukkit end - EntityPlayer entityplayer = this.getBreedCause(); + EntityPlayer entityplayer = this.getLoveCause(); - if (entityplayer == null && entityanimal.getBreedCause() != null) { - entityplayer = entityanimal.getBreedCause(); + if (entityplayer == null && entityanimal.getLoveCause() != null) { + entityplayer = entityanimal.getLoveCause(); } + // CraftBukkit start - call EntityBreedEvent + entityageable.setBaby(true); -+ entityageable.setPositionRotation(this.locX(), this.locY(), this.locZ(), 0.0F, 0.0F); ++ entityageable.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F); + int experience = this.getRandom().nextInt(7) + 1; + org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityageable, this, entityanimal, entityplayer, this.breedItem, experience); + if (entityBreedEvent.isCancelled()) { @@ -82,21 +83,21 @@ + // CraftBukkit end if (entityplayer != null) { - entityplayer.a(StatisticList.ANIMALS_BRED); -@@ -228,12 +261,14 @@ - entityanimal.setAgeRaw(6000); + entityplayer.awardStat(StatisticList.ANIMALS_BRED); +@@ -236,12 +269,14 @@ + entityanimal.setAge(6000); this.resetLove(); entityanimal.resetLove(); - entityageable.setBaby(true); -- entityageable.setPositionRotation(this.locX(), this.locY(), this.locZ(), 0.0F, 0.0F); -- worldserver.addAllEntities(entityageable); -+ worldserver.addAllEntities(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason - worldserver.broadcastEntityEffect(this, (byte) 18); +- entityageable.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F); +- worldserver.addFreshEntityWithPassengers(entityageable); ++ worldserver.addFreshEntityWithPassengers(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason + worldserver.broadcastEntityEvent(this, (byte) 18); if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { -- worldserver.addEntity(new EntityExperienceOrb(worldserver, this.locX(), this.locY(), this.locZ(), this.getRandom().nextInt(7) + 1)); +- worldserver.addFreshEntity(new EntityExperienceOrb(worldserver, this.getX(), this.getY(), this.getZ(), this.getRandom().nextInt(7) + 1)); + // CraftBukkit start - use event experience + if (experience > 0) { -+ worldserver.addEntity(new EntityExperienceOrb(worldserver, this.locX(), this.locY(), this.locZ(), experience)); ++ worldserver.addFreshEntity(new EntityExperienceOrb(worldserver, this.getX(), this.getY(), this.getZ(), experience)); + } + // CraftBukkit end } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch index e368ac9425..3c52b7b2fc 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch +++ b/paper-server/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 -@@ -243,7 +243,7 @@ +@@ -244,7 +244,7 @@ } if (b0 > 0) { @@ -9,48 +9,48 @@ } } -@@ -642,11 +642,15 @@ - if (this.isInvulnerable(damagesource)) { +@@ -644,11 +644,15 @@ + if (this.isInvulnerableTo(damagesource)) { return false; } else { - if (!this.level.isClientSide) { + // CraftBukkit start -+ boolean result = super.damageEntity(damagesource, f); ++ boolean result = super.hurt(damagesource, f); + + if (result && !this.level.isClientSide) { - this.beePollinateGoal.l(); + this.beePollinateGoal.stopPollinating(); } -- return super.damageEntity(damagesource, f); +- return super.hurt(damagesource, f); + return result; + // CraftBukkit end } } -@@ -1216,7 +1220,7 @@ +@@ -1224,7 +1228,7 @@ } } - if (flag) { -+ if (flag && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityBee.this, blockposition, iblockdata.set(blockstateinteger, (Integer) iblockdata.get(blockstateinteger) + 1)).isCancelled()) { // Spigot - EntityBee.this.level.triggerEffect(2005, blockposition, 0); - EntityBee.this.level.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(blockstateinteger, (Integer) iblockdata.get(blockstateinteger) + 1)); - EntityBee.this.fS(); -@@ -1289,7 +1293,7 @@ ++ if (flag && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityBee.this, blockposition, iblockdata.setValue(blockstateinteger, (Integer) iblockdata.getValue(blockstateinteger) + 1)).isCancelled()) { // Spigot + EntityBee.this.level.levelEvent(2005, blockposition, 0); + EntityBee.this.level.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(blockstateinteger, (Integer) iblockdata.getValue(blockstateinteger) + 1)); + EntityBee.this.incrementNumCropsGrownSincePollination(); +@@ -1297,7 +1301,7 @@ @Override - protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) { + protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) { if (entityinsentient instanceof EntityBee && this.mob.hasLineOfSight(entityliving)) { -- entityinsentient.setGoalTarget(entityliving); -+ entityinsentient.setGoalTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason +- entityinsentient.setTarget(entityliving); ++ entityinsentient.setTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason } } -@@ -1298,7 +1302,7 @@ +@@ -1306,7 +1310,7 @@ private static class c extends PathfinderGoalNearestAttackableTarget<EntityHuman> { c(EntityBee entitybee) { - Objects.requireNonNull(entitybee); + // Objects.requireNonNull(entitybee); // CraftBukkit - decompile error - super(entitybee, EntityHuman.class, 10, true, false, entitybee::a_); + super(entitybee, EntityHuman.class, 10, true, false, entitybee::isAngryAt); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch index 94a223939d..87a2dd17aa 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch @@ -1,24 +1,15 @@ --- a/net/minecraft/world/entity/animal/EntityCat.java +++ b/net/minecraft/world/entity/animal/EntityCat.java -@@ -95,7 +95,7 @@ - public static final int TYPE_ALL_BLACK = 10; - private static final int NUMBER_OF_CAT_TYPES = 11; - private static final int NUMBER_OF_CAT_TYPES_EXCEPT_ALL_BLACK = 10; -- public static final Map<Integer, MinecraftKey> TEXTURE_BY_TYPE = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { -+ public static final Map<Integer, MinecraftKey> TEXTURE_BY_TYPE = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error - hashmap.put(0, new MinecraftKey("textures/entity/cat/tabby.png")); - hashmap.put(1, new MinecraftKey("textures/entity/cat/black.png")); - hashmap.put(2, new MinecraftKey("textures/entity/cat/red.png")); -@@ -433,7 +433,7 @@ +@@ -434,7 +434,7 @@ } - } else if (this.isBreedItem(itemstack)) { - this.a(entityhuman, enumhand, itemstack); + } else if (this.isFood(itemstack)) { + this.usePlayerItem(entityhuman, enumhand, itemstack); - if (this.random.nextInt(3) == 0) { + if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { // CraftBukkit this.tame(entityhuman); - this.setWillSit(true); - this.level.broadcastEntityEffect(this, (byte) 7); -@@ -490,7 +490,7 @@ + this.setOrderedToSit(true); + this.level.broadcastEntityEvent(this, (byte) 7); +@@ -491,7 +491,7 @@ private static class PathfinderGoalTemptChance extends PathfinderGoalTempt { @Nullable @@ -27,11 +18,11 @@ private final EntityCat cat; public PathfinderGoalTemptChance(EntityCat entitycat, double d0, RecipeItemStack recipeitemstack, boolean flag) { -@@ -629,7 +629,15 @@ +@@ -632,7 +632,15 @@ while (iterator.hasNext()) { ItemStack itemstack = (ItemStack) iterator.next(); -- this.cat.level.addEntity(new EntityItem(this.cat.level, (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)); +- this.cat.level.addFreshEntity(new EntityItem(this.cat.level, (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(this.cat.level, (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()); @@ -39,17 +30,17 @@ + if (event.isCancelled()) { + continue; + } -+ this.cat.level.addEntity(entityitem); ++ this.cat.level.addFreshEntity(entityitem); + // CraftBukkit end } } -@@ -661,10 +669,10 @@ +@@ -664,10 +672,10 @@ private final EntityCat cat; public a(EntityCat entitycat, Class<T> oclass, float f, double d0, double d1) { - Predicate predicate = IEntitySelector.NO_CREATIVE_OR_SPECTATOR; -+ // Predicate predicate = IEntitySelector.e; // CraftBukkit - decompile error ++ // Predicate predicate = IEntitySelector.NO_CREATIVE_OR_SPECTATOR; // CraftBukkit - decompile error - Objects.requireNonNull(predicate); - super(entitycat, oclass, f, d0, d1, predicate::test); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityChicken.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityChicken.patch index 8d8d84606a..c472672be8 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityChicken.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityChicken.patch @@ -3,13 +3,13 @@ @@ -75,6 +75,11 @@ @Override - public void movementTick() { + public void aiStep() { + // CraftBukkit start + if (this.isChickenJockey()) { -+ this.setPersistenceRequired(!this.isTypeNotPersistent(0)); ++ this.setPersistenceRequired(!this.removeWhenFarAway(0)); + } + // CraftBukkit end - super.movementTick(); + super.aiStep(); this.oFlap = this.flap; this.oFlapSpeed = this.flapSpeed; @@ -94,7 +99,9 @@ @@ -17,7 +17,7 @@ if (!this.level.isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) { this.playSound(SoundEffects.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.forceDrops = true; // CraftBukkit - this.a((IMaterial) Items.EGG); + this.spawnAtLocation((IMaterial) Items.EGG); + this.forceDrops = false; // CraftBukkit this.eggTime = this.random.nextInt(6000) + 6000; } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch index 3216fbfbd9..630d405a77 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch @@ -13,11 +13,11 @@ public EntityCow(EntityTypes<? extends EntityCow> entitytypes, World world) { @@ -82,8 +87,16 @@ - ItemStack itemstack = entityhuman.b(enumhand); + ItemStack itemstack = entityhuman.getItemInHand(enumhand); - if (itemstack.a(Items.BUCKET) && !this.isBaby()) { + if (itemstack.is(Items.BUCKET) && !this.isBaby()) { + // CraftBukkit start - Got milk? -+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level, entityhuman, this.getChunkCoordinates(), this.getChunkCoordinates(), null, itemstack, Items.MILK_BUCKET); ++ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level, entityhuman, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET); + + if (event.isCancelled()) { + return EnumInteractionResult.PASS; @@ -25,8 +25,8 @@ + // CraftBukkit end + entityhuman.playSound(SoundEffects.COW_MILK, 1.0F, 1.0F); -- ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, Items.MILK_BUCKET.createItemStack()); -+ ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit +- ItemStack itemstack1 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, Items.MILK_BUCKET.getDefaultInstance()); ++ ItemStack itemstack1 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit - entityhuman.a(enumhand, itemstack1); - return EnumInteractionResult.a(this.level.isClientSide); + entityhuman.setItemInHand(enumhand, itemstack1); + return EnumInteractionResult.sidedSuccess(this.level.isClientSide); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch index 261becc4e3..be9fb132df 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch @@ -1,46 +1,37 @@ --- a/net/minecraft/world/entity/animal/EntityDolphin.java +++ b/net/minecraft/world/entity/animal/EntityDolphin.java -@@ -176,7 +176,7 @@ - this.goalSelector.a(8, new EntityDolphin.c()); - this.goalSelector.a(8, new PathfinderGoalFollowBoat(this)); - this.goalSelector.a(9, new PathfinderGoalAvoidTarget<>(this, EntityGuardian.class, 8.0F, 1.0D, 1.0D)); -- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityGuardian.class})).a()); -+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityGuardian.class})).a(new Class[0])); // CraftBukkit - decompile error - } +@@ -233,6 +233,12 @@ + ItemStack itemstack = entityitem.getItem(); - public static AttributeProvider.Builder fw() { -@@ -243,6 +243,12 @@ - ItemStack itemstack = entityitem.getItemStack(); - - if (this.canPickup(itemstack)) { + if (this.canHoldItem(itemstack)) { + // CraftBukkit start - call EntityPickupItemEvent + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, false).isCancelled()) { + return; + } -+ itemstack = entityitem.getItemStack(); // update ItemStack from event ++ itemstack = entityitem.getItem(); // update ItemStack from event + // CraftBukkit end - this.a(entityitem); - this.setSlot(EnumItemSlot.MAINHAND, itemstack); - this.handDropChances[EnumItemSlot.MAINHAND.b()] = 2.0F; -@@ -411,7 +417,7 @@ + this.onItemPickup(entityitem); + this.setItemSlot(EnumItemSlot.MAINHAND, itemstack); + this.handDropChances[EnumItemSlot.MAINHAND.getIndex()] = 2.0F; +@@ -391,7 +397,7 @@ @Override - public boolean a() { -- return this.dolphin.gotFish() && this.dolphin.getAirTicks() >= 100; -+ return this.dolphin.gotFish() && this.dolphin.getAirTicks() >= 100 && this.dolphin.level.getWorld().canGenerateStructures(); // MC-151364, SPIGOT-5494: hangs if generate-structures=false + public boolean canUse() { +- return this.dolphin.gotFish() && this.dolphin.getAirSupply() >= 100; ++ return this.dolphin.gotFish() && this.dolphin.getAirSupply() >= 100 && this.dolphin.level.getWorld().canGenerateStructures(); // MC-151364, SPIGOT-5494: hangs if generate-structures=false } @Override -@@ -520,7 +526,7 @@ +@@ -501,7 +507,7 @@ @Override - public void c() { + public void start() { - this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin); + this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit } @Override -@@ -539,7 +545,7 @@ +@@ -520,7 +526,7 @@ } if (this.player.isSwimming() && this.player.level.random.nextInt(6) == 0) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityFish.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityFish.patch index d2555c4831..52a425c42a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityFish.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityFish.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/entity/animal/EntityFish.java +++ b/net/minecraft/world/entity/animal/EntityFish.java -@@ -68,7 +68,7 @@ +@@ -59,7 +59,7 @@ @Override - public boolean isTypeNotPersistent(double d0) { -- return !this.isFromBucket() && !this.hasCustomName(); + public boolean removeWhenFarAway(double d0) { +- return !this.fromBucket() && !this.hasCustomName(); + return true; // CraftBukkit } @Override -@@ -90,6 +90,7 @@ +@@ -81,6 +81,7 @@ @Override public void setFromBucket(boolean flag) { this.entityData.set(EntityFish.FROM_BUCKET, flag); -+ this.setPersistenceRequired(this.isPersistent()); // CraftBukkit - SPIGOT-4106 update persistence ++ this.setPersistenceRequired(this.isPersistenceRequired()); // CraftBukkit - SPIGOT-4106 update persistence } @Override diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch index 3bdcd9ed6d..6325263074 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/world/entity/animal/EntityFox.java +++ b/net/minecraft/world/entity/animal/EntityFox.java -@@ -502,7 +502,8 @@ - protected void b(EntityItem entityitem) { - ItemStack itemstack = entityitem.getItemStack(); +@@ -507,7 +507,8 @@ + protected void pickUpItem(EntityItem entityitem) { + ItemStack itemstack = entityitem.getItem(); -- if (this.canPickup(itemstack)) { -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, itemstack.getCount() - 1, !this.canPickup(itemstack)).isCancelled()) { // CraftBukkit - call EntityPickupItemEvent -+ itemstack = entityitem.getItemStack(); // CraftBukkit - update ItemStack from event +- if (this.canHoldItem(itemstack)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, itemstack.getCount() - 1, !this.canHoldItem(itemstack)).isCancelled()) { // CraftBukkit - call EntityPickupItemEvent ++ itemstack = entityitem.getItem(); // CraftBukkit - update ItemStack from event int i = itemstack.getCount(); if (i > 1) { -@@ -857,6 +858,16 @@ +@@ -862,6 +863,16 @@ if (entityplayer1 != null && entityplayer != entityplayer1) { - entityfox.b(entityplayer1.getUniqueID()); + entityfox.addTrustedUUID(entityplayer1.getUUID()); } + // CraftBukkit start - call EntityBreedEvent -+ entityfox.setAgeRaw(-24000); -+ entityfox.setPositionRotation(this.animal.locX(), this.animal.locY(), this.animal.locZ(), 0.0F, 0.0F); ++ entityfox.setAge(-24000); ++ entityfox.moveTo(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()) { @@ -26,47 +26,47 @@ + // CraftBukkit end if (entityplayer2 != null) { - entityplayer2.a(StatisticList.ANIMALS_BRED); -@@ -867,12 +878,14 @@ - this.partner.setAgeRaw(6000); + entityplayer2.awardStat(StatisticList.ANIMALS_BRED); +@@ -872,12 +883,14 @@ + this.partner.setAge(6000); this.animal.resetLove(); this.partner.resetLove(); -- entityfox.setAgeRaw(-24000); -- entityfox.setPositionRotation(this.animal.locX(), this.animal.locY(), this.animal.locZ(), 0.0F, 0.0F); -- worldserver.addAllEntities(entityfox); -+ worldserver.addAllEntities(entityfox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason - this.level.broadcastEntityEffect(this.animal, (byte) 18); +- entityfox.setAge(-24000); +- entityfox.moveTo(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); if (this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { -- this.level.addEntity(new EntityExperienceOrb(this.level, this.animal.locX(), this.animal.locY(), this.animal.locZ(), this.animal.getRandom().nextInt(7) + 1)); +- this.level.addFreshEntity(new EntityExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), this.animal.getRandom().nextInt(7) + 1)); + // CraftBukkit start - use event experience + if (experience > 0) { -+ this.level.addEntity(new EntityExperienceOrb(this.level, this.animal.locX(), this.animal.locY(), this.animal.locZ(), experience)); ++ this.level.addFreshEntity(new EntityExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), experience)); + } + // CraftBukkit end } } -@@ -1258,13 +1271,18 @@ +@@ -1268,13 +1281,18 @@ } - private void a(IBlockData iblockdata) { -- CaveVines.harvest(iblockdata, EntityFox.this.level, this.blockPos); -+ CaveVines.harvest(iblockdata, EntityFox.this.level, this.blockPos, EntityFox.this); // CraftBukkit + private void pickGlowBerry(IBlockData iblockdata) { +- CaveVines.use(iblockdata, EntityFox.this.level, this.blockPos); ++ CaveVines.use(iblockdata, EntityFox.this.level, this.blockPos, EntityFox.this); // CraftBukkit } - private void b(IBlockData iblockdata) { - int i = (Integer) iblockdata.get(BlockSweetBerryBush.AGE); + private void pickSweetBerries(IBlockData iblockdata) { + int i = (Integer) iblockdata.getValue(BlockSweetBerryBush.AGE); - iblockdata.set(BlockSweetBerryBush.AGE, 1); + iblockdata.setValue(BlockSweetBerryBush.AGE, 1); + // CraftBukkit start - call EntityChangeBlockEvent -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityFox.this, this.blockPos, iblockdata.set(BlockSweetBerryBush.AGE, 1)).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityFox.this, this.blockPos, iblockdata.setValue(BlockSweetBerryBush.AGE, 1)).isCancelled()) { + return; + } + // CraftBukkit end int j = 1 + EntityFox.this.level.random.nextInt(2) + (i == 3 ? 1 : 0); - ItemStack itemstack = EntityFox.this.getEquipment(EnumItemSlot.MAINHAND); + ItemStack itemstack = EntityFox.this.getItemBySlot(EnumItemSlot.MAINHAND); -@@ -1420,7 +1438,7 @@ +@@ -1431,7 +1449,7 @@ private EntityLiving trustedLastHurt; private int timestamp; diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityIronGolem.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityIronGolem.patch index 75546e9478..bf676631d6 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityIronGolem.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityIronGolem.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/world/entity/animal/EntityIronGolem.java @@ -106,7 +106,7 @@ @Override - protected void A(Entity entity) { + protected void doPush(Entity entity) { if (entity instanceof IMonster && !(entity instanceof EntityCreeper) && this.getRandom().nextInt(20) == 0) { -- this.setGoalTarget((EntityLiving) entity); -+ this.setGoalTarget((EntityLiving) entity, org.bukkit.event.entity.EntityTargetLivingEntityEvent.TargetReason.COLLISION, true); // CraftBukkit - set reason +- this.setTarget((EntityLiving) entity); ++ this.setTarget((EntityLiving) entity, org.bukkit.event.entity.EntityTargetLivingEntityEvent.TargetReason.COLLISION, true); // CraftBukkit - set reason } - super.A(entity); + super.doPush(entity); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch index 488d66ddf6..5ec961d58d 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch +++ b/paper-server/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 -@@ -42,6 +42,13 @@ +@@ -44,6 +44,13 @@ import net.minecraft.world.level.gameevent.GameEvent; import org.apache.commons.lang3.tuple.Pair; @@ -13,52 +13,52 @@ + public class EntityMushroomCow extends EntityCow implements IShearable { - private static final DataWatcherObject<String> DATA_TYPE = DataWatcher.a(EntityMushroomCow.class, DataWatcherRegistry.STRING); -@@ -113,6 +120,11 @@ + private static final DataWatcherObject<String> DATA_TYPE = DataWatcher.defineId(EntityMushroomCow.class, DataWatcherRegistry.STRING); +@@ -117,6 +124,11 @@ this.playSound(soundeffect, 1.0F, 1.0F); - return EnumInteractionResult.a(this.level.isClientSide); - } else if (itemstack.a(Items.SHEARS) && this.canShear()) { + return EnumInteractionResult.sidedSuccess(this.level.isClientSide); + } else if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { + // CraftBukkit start + if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { + return EnumInteractionResult.PASS; + } + // CraftBukkit end this.shear(SoundCategory.PLAYERS); - this.a(GameEvent.SHEAR, (Entity) entityhuman); + this.gameEvent(GameEvent.SHEAR, (Entity) entityhuman); if (!this.level.isClientSide) { -@@ -160,7 +172,7 @@ +@@ -164,7 +176,7 @@ this.level.playSound((EntityHuman) null, (Entity) this, SoundEffects.MOOSHROOM_SHEAR, soundcategory, 1.0F, 1.0F); if (!this.level.isClientSide()) { - ((WorldServer) this.level).a(Particles.EXPLOSION, this.locX(), this.e(0.5D), this.locZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D); -- this.die(); -+ // this.die(); // CraftBukkit - moved down - EntityCow entitycow = (EntityCow) EntityTypes.COW.a(this.level); + ((WorldServer) this.level).sendParticles(Particles.EXPLOSION, this.getX(), this.getY(0.5D), this.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D); +- this.discard(); ++ // this.discard(); // CraftBukkit - moved down + EntityCow entitycow = (EntityCow) EntityTypes.COW.create(this.level); - entitycow.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.getYRot(), this.getXRot()); -@@ -176,10 +188,25 @@ + entitycow.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); +@@ -180,10 +192,25 @@ } entitycow.setInvulnerable(this.isInvulnerable()); -- this.level.addEntity(entitycow); +- this.level.addFreshEntity(entitycow); + // CraftBukkit start + if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) { + return; + } -+ this.level.addEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); ++ this.level.addFreshEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); + -+ this.die(); // CraftBukkit - from above ++ this.discard(); // CraftBukkit - from above + // CraftBukkit end for (int i = 0; i < 5; ++i) { -- this.level.addEntity(new EntityItem(this.level, this.locX(), this.e(1.0D), this.locZ(), new ItemStack(this.getVariant().blockState.getBlock()))); +- this.level.addFreshEntity(new EntityItem(this.level, this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getMushroomType().blockState.getBlock()))); + // CraftBukkit start -+ EntityItem entityitem = new EntityItem(this.level, this.locX(), this.e(1.0D), this.locZ(), new ItemStack(this.getVariant().blockState.getBlock())); ++ EntityItem entityitem = new EntityItem(this.level, this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getMushroomType().blockState.getBlock())); + EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); + Bukkit.getPluginManager().callEvent(event); + if (event.isCancelled()) { + continue; + } -+ this.level.addEntity(entityitem); ++ this.level.addFreshEntity(entityitem); + // CraftBukkit end } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch index ec51ccbf15..0de1148380 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch @@ -1,25 +1,25 @@ --- a/net/minecraft/world/entity/animal/EntityOcelot.java +++ b/net/minecraft/world/entity/animal/EntityOcelot.java -@@ -133,7 +133,7 @@ +@@ -134,7 +134,7 @@ @Override - public boolean isTypeNotPersistent(double d0) { + public boolean removeWhenFarAway(double d0) { - return !this.isTrusting() && this.tickCount > 2400; -+ return !this.isTrusting() /*&& this.ticksLived > 2400*/; // CraftBukkit ++ return !this.isTrusting() /*&& this.tickCount > 2400*/; // CraftBukkit } - public static AttributeProvider.Builder p() { -@@ -182,7 +182,8 @@ - if ((this.temptGoal == null || this.temptGoal.h()) && !this.isTrusting() && this.isBreedItem(itemstack) && entityhuman.f((Entity) this) < 9.0D) { - this.a(entityhuman, enumhand, itemstack); + public static AttributeProvider.Builder createAttributes() { +@@ -183,7 +183,8 @@ + 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) { - if (this.random.nextInt(3) == 0) { + // CraftBukkit - added event call and isCancelled check + if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { this.setTrusting(true); - this.w(true); - this.level.broadcastEntityEffect(this, (byte) 41); -@@ -312,10 +313,10 @@ + this.spawnTrustingParticles(true); + this.level.broadcastEntityEvent(this, (byte) 41); +@@ -313,10 +314,10 @@ private final EntityOcelot ocelot; public a(EntityOcelot entityocelot, Class<T> oclass, float f, double d0, double d1) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch index 9fdb7d5123..dd39cd2dfb 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityPanda.java +++ b/net/minecraft/world/entity/animal/EntityPanda.java -@@ -65,6 +65,8 @@ +@@ -64,6 +64,8 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.Vec3D; @@ -8,17 +8,17 @@ + public class EntityPanda extends EntityAnimal { - private static final DataWatcherObject<Integer> UNHAPPY_COUNTER = DataWatcher.a(EntityPanda.class, DataWatcherRegistry.INT); -@@ -525,7 +527,7 @@ + private static final DataWatcherObject<Integer> UNHAPPY_COUNTER = DataWatcher.defineId(EntityPanda.class, DataWatcherRegistry.INT); +@@ -526,7 +528,7 @@ @Override - protected void b(EntityItem entityitem) { -- if (this.getEquipment(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PANDA_ITEMS.test(entityitem)) { -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !(this.getEquipment(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PANDA_ITEMS.test(entityitem))).isCancelled()) { // CraftBukkit - this.a(entityitem); - ItemStack itemstack = entityitem.getItemStack(); + protected void pickUpItem(EntityItem entityitem) { +- if (this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PANDA_ITEMS.test(entityitem)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !(this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PANDA_ITEMS.test(entityitem))).isCancelled()) { // CraftBukkit + this.onItemPickup(entityitem); + ItemStack itemstack = entityitem.getItem(); -@@ -881,10 +883,10 @@ +@@ -882,10 +884,10 @@ private final EntityPanda panda; public c(EntityPanda entitypanda, Class<T> oclass, float f, double d0, double d1) { @@ -32,12 +32,12 @@ this.panda = entitypanda; } -@@ -1131,7 +1133,7 @@ +@@ -1132,7 +1134,7 @@ @Override - protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) { + protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) { if (entityinsentient instanceof EntityPanda && ((EntityPanda) entityinsentient).isAggressive()) { -- entityinsentient.setGoalTarget(entityliving); -+ entityinsentient.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit +- entityinsentient.setTarget(entityliving); ++ entityinsentient.setTarget(entityliving, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch index 7c741fc951..4233be9351 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch @@ -1,47 +1,38 @@ --- a/net/minecraft/world/entity/animal/EntityParrot.java +++ b/net/minecraft/world/entity/animal/EntityParrot.java -@@ -75,7 +75,7 @@ - private static final Item POISONOUS_FOOD = Items.COOKIE; - private static final Set<Item> TAME_FOOD = Sets.newHashSet(new Item[]{Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS}); - private static final int VARIANTS = 5; -- static final Map<EntityTypes<?>, SoundEffect> MOB_SOUND_MAP = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { -+ static final Map<EntityTypes<?>, SoundEffect> MOB_SOUND_MAP = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error - hashmap.put(EntityTypes.BLAZE, SoundEffects.PARROT_IMITATE_BLAZE); - hashmap.put(EntityTypes.CAVE_SPIDER, SoundEffects.PARROT_IMITATE_SPIDER); - hashmap.put(EntityTypes.CREEPER, SoundEffects.PARROT_IMITATE_CREEPER); -@@ -253,7 +253,7 @@ +@@ -258,7 +258,7 @@ } if (!this.level.isClientSide) { - if (this.random.nextInt(10) == 0) { + if (this.random.nextInt(10) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { // CraftBukkit this.tame(entityhuman); - this.level.broadcastEntityEffect(this, (byte) 7); + this.level.broadcastEntityEvent(this, (byte) 7); } else { -@@ -267,7 +267,7 @@ - itemstack.subtract(1); +@@ -272,7 +272,7 @@ + itemstack.shrink(1); } - this.addEffect(new MobEffect(MobEffects.POISON, 900)); + this.addEffect(new MobEffect(MobEffects.POISON, 900), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit if (entityhuman.isCreative() || !this.isInvulnerable()) { - this.damageEntity(DamageSource.playerAttack(entityhuman), Float.MAX_VALUE); + this.hurt(DamageSource.playerAttack(entityhuman), Float.MAX_VALUE); } -@@ -381,7 +381,7 @@ +@@ -384,7 +384,7 @@ @Override - public boolean isCollidable() { + public boolean isPushable() { - return true; -+ return super.isCollidable(); // CraftBukkit - collidable API ++ return super.isPushable(); // CraftBukkit - collidable API } @Override -@@ -396,7 +396,7 @@ - if (this.isInvulnerable(damagesource)) { +@@ -399,7 +399,7 @@ + if (this.isInvulnerableTo(damagesource)) { return false; } else { -- this.setWillSit(false); -+ // this.setWillSit(false); // CraftBukkit - moved into EntityLiving.damageEntity(DamageSource, float) - return super.damageEntity(damagesource, f); +- this.setOrderedToSit(false); ++ // this.setOrderedToSit(false); // CraftBukkit - moved into EntityLiving.damageEntity(DamageSource, float) + return super.hurt(damagesource, f); } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch index 3f4eb2652e..99b29557d9 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch +++ b/paper-server/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,10 @@ +@@ -49,6 +49,10 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -10,19 +10,19 @@ + public class EntityPig extends EntityAnimal implements ISteerable, ISaddleable { - private static final DataWatcherObject<Boolean> DATA_SADDLE_ID = DataWatcher.a(EntityPig.class, DataWatcherRegistry.BOOLEAN); -@@ -251,7 +255,13 @@ + private static final DataWatcherObject<Boolean> DATA_SADDLE_ID = DataWatcher.defineId(EntityPig.class, DataWatcherRegistry.BOOLEAN); +@@ -250,7 +254,13 @@ } - entitypigzombie.setPersistent(); -- worldserver.addEntity(entitypigzombie); + entitypigzombie.setPersistenceRequired(); +- worldserver.addFreshEntity(entitypigzombie); + // CraftBukkit start + if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) { + return; + } + // CraftBukkit - added a reason for spawning this creature -+ worldserver.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); ++ worldserver.addFreshEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); + // CraftBukkit end - this.die(); + this.discard(); } else { - super.onLightningStrike(worldserver, entitylightning); + super.thunderHit(worldserver, entitylightning); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch index 3910bab009..c5f8c33cd3 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch @@ -3,14 +3,14 @@ @@ -144,7 +144,7 @@ int i = this.getPuffState(); - if (entityinsentient.damageEntity(DamageSource.mobAttack(this), (float) (1 + i))) { + if (entityinsentient.hurt(DamageSource.mobAttack(this), (float) (1 + i))) { - entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this); + entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit this.playSound(SoundEffects.PUFFER_FISH_STING, 1.0F, 1.0F); } @@ -159,7 +159,7 @@ - ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.PUFFER_FISH_STING, 0.0F)); + ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.PUFFER_FISH_STING, 0.0F)); } - entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch index 8bd3a7203f..d147bd4a07 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch +++ b/paper-server/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 -@@ -86,8 +86,14 @@ +@@ -88,8 +88,14 @@ super(entitytypes, world); this.jumpControl = new EntityRabbit.ControllerJumpRabbit(this); this.moveControl = new EntityRabbit.ControllerMoveRabbit(this); @@ -9,42 +9,33 @@ + + // CraftBukkit start - code from constructor + public void initializePathFinderGoals(){ - this.i(0.0D); + this.setSpeedModifier(0.0D); } + // CraftBukkit end @Override - public void initPathfinder() { -@@ -353,7 +359,7 @@ - if (i == 99) { - this.getAttributeInstance(GenericAttributes.ARMOR).setValue(8.0D); - this.goalSelector.a(4, new EntityRabbit.PathfinderGoalKillerRabbitMeleeAttack(this)); -- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a()); -+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error - this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); - this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityWolf.class, true)); - if (!this.hasCustomName()) { + public void registerGoals() { @@ -556,9 +562,23 @@ - int i = (Integer) iblockdata.get(BlockCarrots.AGE); + int i = (Integer) iblockdata.getValue(BlockCarrots.AGE); if (i == 0) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 2); - world.a(blockposition, true, this.rabbit); + world.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 2); + world.destroyBlock(blockposition, true, this.rabbit); } else { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent( + this.rabbit, + blockposition, -+ iblockdata.set(BlockCarrots.AGE, i - 1) ++ iblockdata.setValue(BlockCarrots.AGE, i - 1) + ).isCancelled()) { + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCarrots.AGE, i - 1), 2); - world.triggerEffect(2001, blockposition, Block.getCombinedId(iblockdata)); + world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockCarrots.AGE, i - 1), 2); + world.levelEvent(2001, blockposition, Block.getId(iblockdata)); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch index 0de3ebfb5c..cd1a11150a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntitySheep.java +++ b/net/minecraft/world/entity/animal/EntitySheep.java -@@ -64,11 +64,19 @@ +@@ -63,6 +63,14 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.storage.loot.LootTables; @@ -15,38 +15,32 @@ public class EntitySheep extends EntityAnimal implements IShearable { private static final int EAT_ANIMATION_TICKS = 40; - private static final DataWatcherObject<Byte> DATA_WOOL_ID = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.BYTE); -- private static final Map<EnumColor, IMaterial> ITEM_BY_DYE = (Map) SystemUtils.a((Object) Maps.newEnumMap(EnumColor.class), (enummap) -> { -+ private static final Map<EnumColor, IMaterial> ITEM_BY_DYE = (Map) SystemUtils.a(Maps.newEnumMap(EnumColor.class), (enummap) -> { // CraftBukkit - decompile error - enummap.put(EnumColor.WHITE, Blocks.WHITE_WOOL); - enummap.put(EnumColor.ORANGE, Blocks.ORANGE_WOOL); - enummap.put(EnumColor.MAGENTA, Blocks.MAGENTA_WOOL); -@@ -223,6 +231,11 @@ +@@ -222,6 +230,11 @@ - if (itemstack.a(Items.SHEARS)) { - if (!this.level.isClientSide && this.canShear()) { + if (itemstack.is(Items.SHEARS)) { + if (!this.level.isClientSide && this.readyForShearing()) { + // CraftBukkit start + if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { + return EnumInteractionResult.PASS; + } + // CraftBukkit end this.shear(SoundCategory.PLAYERS); - this.a(GameEvent.SHEAR, (Entity) entityhuman); - itemstack.damage(1, entityhuman, (entityhuman1) -> { -@@ -244,7 +257,9 @@ + this.gameEvent(GameEvent.SHEAR, (Entity) entityhuman); + itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { +@@ -243,7 +256,9 @@ int i = 1 + this.random.nextInt(3); for (int j = 0; j < i; ++j) { + this.forceDrops = true; // CraftBukkit - EntityItem entityitem = this.a((IMaterial) EntitySheep.ITEM_BY_DYE.get(this.getColor()), 1); + EntityItem entityitem = this.spawnAtLocation((IMaterial) EntitySheep.ITEM_BY_DYE.get(this.getColor()), 1); + this.forceDrops = false; // CraftBukkit if (entityitem != null) { - entityitem.setMot(entityitem.getMot().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))); -@@ -334,6 +349,12 @@ + 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))); +@@ -333,6 +348,12 @@ @Override - public void blockEaten() { + public void ate() { + // CraftBukkit start + SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity()); + this.level.getCraftServer().getPluginManager().callEvent(event); @@ -55,20 +49,18 @@ + // CraftBukkit end this.setSheared(false); if (this.isBaby()) { - this.setAge(60); -@@ -352,8 +373,8 @@ + this.ageUp(60); +@@ -351,7 +372,7 @@ EnumColor enumcolor = ((EntitySheep) entityanimal).getColor(); EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor(); - InventoryCrafting inventorycrafting = a(enumcolor, enumcolor1); -- Optional optional = this.level.getCraftingManager().craft(Recipes.CRAFTING, inventorycrafting, this.level).map((recipecrafting) -> { -- return recipecrafting.a((IInventory) inventorycrafting); -+ Optional<Item> optional = this.level.getCraftingManager().craft(Recipes.CRAFTING, inventorycrafting, this.level).map((recipecrafting) -> { // Eclipse fail -+ return recipecrafting.a(inventorycrafting); // CraftBukkit - decompile error + InventoryCrafting inventorycrafting = makeContainer(enumcolor, enumcolor1); +- Optional optional = this.level.getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level).map((recipecrafting) -> { ++ Optional<Item> optional = this.level.getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level).map((recipecrafting) -> { // CraftBukkit - decompile error + return recipecrafting.assemble(inventorycrafting); }).map(ItemStack::getItem); - Objects.requireNonNull(ItemDye.class); -@@ -370,10 +391,18 @@ - public boolean canUse(EntityHuman entityhuman) { +@@ -369,10 +390,18 @@ + public boolean stillValid(EntityHuman entityhuman) { return false; } + @@ -80,8 +72,8 @@ + // CraftBukkit end }, 2, 1); - inventorycrafting.setItem(0, new ItemStack(ItemDye.a(enumcolor))); - inventorycrafting.setItem(1, new ItemStack(ItemDye.a(enumcolor1))); + inventorycrafting.setItem(0, new ItemStack(ItemDye.byColor(enumcolor))); + inventorycrafting.setItem(1, new ItemStack(ItemDye.byColor(enumcolor1))); + inventorycrafting.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event return inventorycrafting; } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch index c3653dd448..2dcf17c91d 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch @@ -10,43 +10,43 @@ + public class EntitySnowman extends EntityGolem implements IShearable, IRangedEntity { - private static final DataWatcherObject<Byte> DATA_PUMPKIN_ID = DataWatcher.a(EntitySnowman.class, DataWatcherRegistry.BYTE); + private static final DataWatcherObject<Byte> DATA_PUMPKIN_ID = DataWatcher.defineId(EntitySnowman.class, DataWatcherRegistry.BYTE); @@ -100,7 +104,7 @@ - int k = MathHelper.floor(this.locZ()); + int k = MathHelper.floor(this.getZ()); - if (this.level.getBiome(new BlockPosition(i, 0, k)).getAdjustedTemperature(new BlockPosition(i, j, k)) > 1.0F) { -- this.damageEntity(DamageSource.ON_FIRE, 1.0F); -+ this.damageEntity(CraftEventFactory.MELTING, 1.0F); // CraftBukkit - DamageSource.BURN -> CraftEventFactory.MELTING + if (this.level.getBiome(new BlockPosition(i, 0, k)).getTemperature(new BlockPosition(i, j, k)) > 1.0F) { +- this.hurt(DamageSource.ON_FIRE, 1.0F); ++ this.hurt(CraftEventFactory.MELTING, 1.0F); // CraftBukkit - DamageSource.BURN -> CraftEventFactory.MELTING } if (!this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { @@ -116,7 +120,7 @@ BlockPosition blockposition = new BlockPosition(i, j, k); - if (this.level.getType(blockposition).isAir() && this.level.getBiome(blockposition).getAdjustedTemperature(blockposition) < 0.8F && iblockdata.canPlace(this.level, blockposition)) { -- this.level.setTypeUpdate(blockposition, iblockdata); + if (this.level.getBlockState(blockposition).isAir() && this.level.getBiome(blockposition).getTemperature(blockposition) < 0.8F && iblockdata.canSurvive(this.level, blockposition)) { +- this.level.setBlockAndUpdate(blockposition, iblockdata); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level, blockposition, iblockdata, this); // CraftBukkit } } } @@ -147,6 +151,11 @@ - ItemStack itemstack = entityhuman.b(enumhand); + ItemStack itemstack = entityhuman.getItemInHand(enumhand); - if (itemstack.a(Items.SHEARS) && this.canShear()) { + if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { + // CraftBukkit start + if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { + return EnumInteractionResult.PASS; + } + // CraftBukkit end this.shear(SoundCategory.PLAYERS); - this.a(GameEvent.SHEAR, (Entity) entityhuman); + this.gameEvent(GameEvent.SHEAR, (Entity) entityhuman); if (!this.level.isClientSide) { @@ -166,7 +175,9 @@ this.level.playSound((EntityHuman) null, (Entity) this, SoundEffects.SNOW_GOLEM_SHEAR, soundcategory, 1.0F, 1.0F); if (!this.level.isClientSide()) { - this.setHasPumpkin(false); + this.setPumpkin(false); + this.forceDrops = true; // CraftBukkit - this.a(new ItemStack(Items.CARVED_PUMPKIN), 1.7F); + this.spawnAtLocation(new ItemStack(Items.CARVED_PUMPKIN), 1.7F); + this.forceDrops = false; // CraftBukkit } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySquid.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySquid.patch index 1f845971a0..a26d7fa8ab 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySquid.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySquid.patch @@ -4,4 +4,4 @@ +// mc-dev import package net.minecraft.world.entity.animal; - import java.util.Random; + import net.minecraft.core.BlockPosition; diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch index f8e87533c2..6236a5d5b3 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch @@ -1,35 +1,35 @@ --- a/net/minecraft/world/entity/animal/EntityTurtle.java +++ b/net/minecraft/world/entity/animal/EntityTurtle.java -@@ -314,7 +314,9 @@ - protected void n() { - super.n(); +@@ -311,7 +311,9 @@ + protected void ageBoundaryReached() { + super.ageBoundaryReached(); if (!this.isBaby() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + this.forceDrops = true; // CraftBukkit - this.a((IMaterial) Items.SCUTE, 1); + this.spawnAtLocation(Items.SCUTE, 1); + this.forceDrops = false; // CraftBukkit } } -@@ -341,7 +343,9 @@ +@@ -338,7 +340,9 @@ @Override - public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) { + public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = entitylightning; // CraftBukkit - this.damageEntity(DamageSource.LIGHTNING_BOLT, Float.MAX_VALUE); + this.hurt(DamageSource.LIGHTNING_BOLT, Float.MAX_VALUE); + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = null; // CraftBukkit } private static class e extends ControllerMove { -@@ -487,8 +491,12 @@ - } else if (this.turtle.layEggCounter > 200) { +@@ -484,8 +488,12 @@ + } else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) { World world = this.turtle.level; + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.EGGS, this.turtle.random.nextInt(4) + 1)).isCancelled()) { ++ 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)).isCancelled()) { world.playSound((EntityHuman) null, blockposition, SoundEffects.TURTLE_LAY_EGG, SoundCategory.BLOCKS, 0.3F, 0.9F + world.random.nextFloat() * 0.2F); - world.setTypeAndData(this.blockPos.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.EGGS, this.turtle.random.nextInt(4) + 1), 3); + world.setBlock(this.blockPos.above(), (IBlockData) Blocks.TURTLE_EGG.defaultBlockState().setValue(BlockTurtleEgg.EGGS, this.turtle.random.nextInt(4) + 1), 3); + } + // CraftBukkit end this.turtle.setHasEgg(false); - this.turtle.w(false); - this.turtle.setLoveTicks(600); + this.turtle.setLayingEgg(false); + this.turtle.setInLoveTime(600); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch index b1226de5f2..8f9fd38688 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityWolf.java +++ b/net/minecraft/world/entity/animal/EntityWolf.java -@@ -63,6 +63,11 @@ +@@ -68,6 +68,11 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.Vec3D; @@ -11,27 +11,18 @@ + public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable { - private static final DataWatcherObject<Boolean> DATA_INTERESTED_ID = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.BOOLEAN); -@@ -104,7 +109,7 @@ - this.goalSelector.a(10, new PathfinderGoalRandomLookaround(this)); - this.targetSelector.a(1, new PathfinderGoalOwnerHurtByTarget(this)); - this.targetSelector.a(2, new PathfinderGoalOwnerHurtTarget(this)); -- this.targetSelector.a(3, (new PathfinderGoalHurtByTarget(this, new Class[0])).a()); -+ this.targetSelector.a(3, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error - this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, 10, true, false, this::a_)); - this.targetSelector.a(5, new PathfinderGoalRandomTargetNonTamed<>(this, EntityAnimal.class, false, EntityWolf.PREY_SELECTOR)); - this.targetSelector.a(6, new PathfinderGoalRandomTargetNonTamed<>(this, EntityTurtle.class, false, EntityTurtle.BABY_ON_LAND_SELECTOR)); -@@ -116,6 +121,24 @@ - return EntityInsentient.w().a(GenericAttributes.MOVEMENT_SPEED, 0.30000001192092896D).a(GenericAttributes.MAX_HEALTH, 8.0D).a(GenericAttributes.ATTACK_DAMAGE, 2.0D); + private static final DataWatcherObject<Boolean> DATA_INTERESTED_ID = DataWatcher.defineId(EntityWolf.class, DataWatcherRegistry.BOOLEAN); +@@ -122,6 +127,24 @@ + return EntityInsentient.createMobAttributes().add(GenericAttributes.MOVEMENT_SPEED, 0.30000001192092896D).add(GenericAttributes.MAX_HEALTH, 8.0D).add(GenericAttributes.ATTACK_DAMAGE, 2.0D); } + // CraftBukkit - add overriden version + @Override -+ public boolean setGoalTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fire) { -+ if (!super.setGoalTarget(entityliving, reason, fire)) { ++ public boolean setTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fire) { ++ if (!super.setTarget(entityliving, reason, fire)) { + return false; + } -+ entityliving = getGoalTarget(); ++ entityliving = getTarget(); + /* // PAIL + if (entityliving == null) { + this.setAngry(false); @@ -44,51 +35,51 @@ + // CraftBukkit end + @Override - protected void initDatawatcher() { - super.initDatawatcher(); -@@ -287,7 +310,7 @@ + protected void defineSynchedData() { + super.defineSynchedData(); +@@ -293,7 +316,7 @@ } else { Entity entity = damagesource.getEntity(); -- this.setWillSit(false); +- this.setOrderedToSit(false); + // this.setWillSit(false); // CraftBukkit - moved into EntityLiving.damageEntity(DamageSource, float) if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) { f = (f + 1.0F) / 2.0F; } -@@ -312,7 +335,7 @@ - super.setTamed(flag); +@@ -318,7 +341,7 @@ + super.setTame(flag); if (flag) { - this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(20.0D); + this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(20.0D); - this.setHealth(20.0F); + this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth() } else { - this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(8.0D); + this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(8.0D); } -@@ -336,7 +359,7 @@ - itemstack.subtract(1); +@@ -342,7 +365,7 @@ + itemstack.shrink(1); } -- this.heal((float) item.getFoodInfo().getNutrition()); -+ this.heal((float) item.getFoodInfo().getNutrition(), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit - this.a(GameEvent.MOB_INTERACT, this.cT()); +- this.heal((float) item.getFoodProperties().getNutrition()); ++ this.heal((float) item.getFoodProperties().getNutrition(), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit + this.gameEvent(GameEvent.MOB_INTERACT, this.eyeBlockPosition()); return EnumInteractionResult.SUCCESS; } -@@ -348,7 +371,7 @@ - this.setWillSit(!this.isWillSit()); +@@ -354,7 +377,7 @@ + this.setOrderedToSit(!this.isOrderedToSit()); this.jumping = false; - this.navigation.o(); -- this.setGoalTarget((EntityLiving) null); -+ this.setGoalTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason + this.navigation.stop(); +- this.setTarget((EntityLiving) null); ++ this.setTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason return EnumInteractionResult.SUCCESS; } -@@ -370,7 +393,8 @@ - itemstack.subtract(1); +@@ -376,7 +399,8 @@ + itemstack.shrink(1); } - if (this.random.nextInt(3) == 0) { + // CraftBukkit - added event call and isCancelled check. + if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { this.tame(entityhuman); - this.navigation.o(); - this.setGoalTarget((EntityLiving) null); + this.navigation.stop(); + this.setTarget((EntityLiving) null); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch index bc24c4c133..2ea3c4867a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch @@ -1,33 +1,24 @@ --- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java +++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java -@@ -68,7 +68,8 @@ +@@ -69,7 +69,8 @@ public static final int TOTAL_PLAYDEAD_TIME = 200; protected static final ImmutableList<? extends SensorType<? extends Sensor<? super Axolotl>>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_ADULT, SensorType.HURT_BY, SensorType.AXOLOTL_ATTACKABLES, SensorType.AXOLOTL_TEMPTATIONS); - protected static final ImmutableList<? extends MemoryModuleType<?>> 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}); + // CraftBukkit - decompile error + protected static final ImmutableList<? extends MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.<MemoryModuleType<?>>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}); - private static final DataWatcherObject<Integer> DATA_VARIANT = DataWatcher.a(Axolotl.class, DataWatcherRegistry.INT); - private static final DataWatcherObject<Boolean> DATA_PLAYING_DEAD = DataWatcher.a(Axolotl.class, DataWatcherRegistry.BOOLEAN); - private static final DataWatcherObject<Boolean> FROM_BUCKET = DataWatcher.a(Axolotl.class, DataWatcherRegistry.BOOLEAN); -@@ -235,6 +236,7 @@ + private static final DataWatcherObject<Integer> DATA_VARIANT = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.INT); + private static final DataWatcherObject<Boolean> DATA_PLAYING_DEAD = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN); + private static final DataWatcherObject<Boolean> FROM_BUCKET = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN); +@@ -236,6 +237,7 @@ @Override public void setFromBucket(boolean flag) { this.entityData.set(Axolotl.FROM_BUCKET, flag); -+ this.setPersistenceRequired(this.isPersistent()); // CraftBukkit - SPIGOT-4106 update persistence ++ this.setPersistenceRequired(this.isPersistenceRequired()); // CraftBukkit - SPIGOT-4106 update persistence } @Nullable -@@ -276,7 +278,7 @@ - @Override - protected void mobTick() { - this.level.getMethodProfiler().enter("axolotlBrain"); -- this.getBehaviorController().a((WorldServer) this.level, (EntityLiving) this); -+ this.getBehaviorController().a((WorldServer) this.level, this); // CraftBukkit - decompile error - this.level.getMethodProfiler().exit(); - this.level.getMethodProfiler().enter("axolotlActivityUpdate"); - AxolotlAi.a(this); -@@ -418,7 +420,7 @@ +@@ -419,7 +421,7 @@ if (i < 2400) { i = Math.min(2400, 100 + i); @@ -36,21 +27,21 @@ } entityhuman.removeEffect(MobEffects.DIG_SLOWDOWN); -@@ -468,7 +470,7 @@ +@@ -469,7 +471,7 @@ @Override - public BehaviorController<Axolotl> getBehaviorController() { -- return super.getBehaviorController(); -+ return (BehaviorController<Axolotl>) super.getBehaviorController(); // CraftBukkit - decompile error + public BehaviorController<Axolotl> getBrain() { +- return super.getBrain(); ++ return (BehaviorController<Axolotl>) super.getBrain(); // CraftBukkit - decompile error } @Override -@@ -501,7 +503,7 @@ +@@ -502,7 +504,7 @@ @Override - public boolean isTypeNotPersistent(double d0) { -- return !this.isFromBucket() && !this.hasCustomName(); + public boolean removeWhenFarAway(double d0) { +- return !this.fromBucket() && !this.hasCustomName(); + return true; // CraftBukkit } - private static class c extends SmoothSwimmingMoveControl { + public static boolean checkAxolotlSpawnRules(EntityTypes<? extends EntityLiving> entitytypes, WorldAccess worldaccess, EnumMobSpawn enummobspawn, BlockPosition blockposition, Random random) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch index a3d950aca7..04a078760c 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/goat/Goat.java +++ b/net/minecraft/world/entity/animal/goat/Goat.java -@@ -50,6 +50,11 @@ +@@ -52,6 +52,11 @@ import net.minecraft.world.level.pathfinder.Pathfinder; import net.minecraft.world.level.pathfinder.PathfinderNormal; @@ -11,37 +11,30 @@ + public class Goat extends EntityAnimal { - public static final EntitySize LONG_JUMPING_DIMENSIONS = EntitySize.b(0.9F, 1.3F).a(0.7F); -@@ -137,13 +142,13 @@ + public static final EntitySize LONG_JUMPING_DIMENSIONS = EntitySize.scalable(0.9F, 1.3F).scale(0.7F); +@@ -139,7 +144,7 @@ @Override - public BehaviorController<Goat> getBehaviorController() { -- return super.getBehaviorController(); -+ return (BehaviorController<Goat>) super.getBehaviorController(); // CraftBukkit - decompile error + public BehaviorController<Goat> getBrain() { +- return super.getBrain(); ++ return (BehaviorController<Goat>) super.getBrain(); // CraftBukkit - decompile error } @Override - protected void mobTick() { - this.level.getMethodProfiler().enter("goatBrain"); -- this.getBehaviorController().a((WorldServer) this.level, (EntityLiving) this); -+ this.getBehaviorController().a((WorldServer) this.level, this); // CraftBukkit - decompile error - this.level.getMethodProfiler().exit(); - this.level.getMethodProfiler().enter("goatActivityUpdate"); - GoatAi.b(this); -@@ -175,8 +180,15 @@ - ItemStack itemstack = entityhuman.b(enumhand); +@@ -177,8 +182,15 @@ + ItemStack itemstack = entityhuman.getItemInHand(enumhand); - if (itemstack.a(Items.BUCKET) && !this.isBaby()) { + if (itemstack.is(Items.BUCKET) && !this.isBaby()) { + // CraftBukkit start - Got milk? -+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level, entityhuman, this.getChunkCoordinates(), this.getChunkCoordinates(), null, itemstack, Items.MILK_BUCKET); ++ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level, entityhuman, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET); + + if (event.isCancelled()) { + return EnumInteractionResult.PASS; + } + // CraftBukkit end - entityhuman.playSound(this.t(), 1.0F, 1.0F); -- ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, Items.MILK_BUCKET.createItemStack()); -+ ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit + entityhuman.playSound(this.getMilkingSound(), 1.0F, 1.0F); +- ItemStack itemstack1 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, Items.MILK_BUCKET.getDefaultInstance()); ++ ItemStack itemstack1 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit - entityhuman.a(enumhand, itemstack1); - return EnumInteractionResult.a(this.level.isClientSide); + entityhuman.setItemInHand(enumhand, itemstack1); + return EnumInteractionResult.sidedSuccess(this.level.isClientSide); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch index b80880a423..78e46707e4 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java +++ b/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java -@@ -69,6 +69,8 @@ +@@ -70,6 +70,8 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -9,7 +9,7 @@ public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, IJumpable, ISaddleable { public static final int EQUIPMENT_SLOT_OFFSET = 400; -@@ -108,6 +110,7 @@ +@@ -109,6 +111,7 @@ private float mouthAnimO; protected boolean canGallop = true; protected int gallopSoundCounter; @@ -17,25 +17,25 @@ protected EntityHorseAbstract(EntityTypes<? extends EntityHorseAbstract> entitytypes, World world) { super(entitytypes, world); -@@ -292,7 +295,7 @@ - public void loadChest() { +@@ -294,7 +297,7 @@ + public void createInventory() { InventorySubcontainer inventorysubcontainer = this.inventory; -- this.inventory = new InventorySubcontainer(this.getChestSlots()); -+ this.inventory = new InventorySubcontainer(this.getChestSlots(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit +- this.inventory = new InventorySubcontainer(this.getInventorySize()); ++ this.inventory = new InventorySubcontainer(this.getInventorySize(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit if (inventorysubcontainer != null) { - inventorysubcontainer.b((IInventoryListener) this); - int i = Math.min(inventorysubcontainer.getSize(), this.inventory.getSize()); -@@ -408,7 +411,7 @@ + inventorysubcontainer.removeListener(this); + int i = Math.min(inventorysubcontainer.getContainerSize(), this.inventory.getContainerSize()); +@@ -410,7 +413,7 @@ } - public int getMaxDomestication() { + public int getMaxTemper() { - return 100; + return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100 } @Override -@@ -478,7 +481,7 @@ +@@ -480,7 +483,7 @@ } if (this.getHealth() < this.getMaxHealth() && f > 0.0F) { @@ -44,39 +44,39 @@ flag = true; } -@@ -555,7 +558,7 @@ - super.movementTick(); +@@ -557,7 +560,7 @@ + super.aiStep(); if (!this.level.isClientSide && this.isAlive()) { if (this.random.nextInt(900) == 0 && this.deathTime == 0) { - this.heal(1.0F); + this.heal(1.0F, RegainReason.REGEN); // CraftBukkit } - if (this.fV()) { -@@ -786,6 +789,7 @@ + if (this.canEatGrass()) { +@@ -788,6 +791,7 @@ if (this.getOwnerUUID() != null) { - nbttagcompound.a("Owner", this.getOwnerUUID()); + nbttagcompound.putUUID("Owner", this.getOwnerUUID()); } -+ nbttagcompound.setInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit ++ nbttagcompound.putInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit if (!this.inventory.getItem(0).isEmpty()) { - nbttagcompound.set("SaddleItem", this.inventory.getItem(0).save(new NBTTagCompound())); -@@ -813,6 +817,11 @@ + nbttagcompound.put("SaddleItem", this.inventory.getItem(0).save(new NBTTagCompound())); +@@ -815,6 +819,11 @@ if (uuid != null) { this.setOwnerUUID(uuid); } + // CraftBukkit start -+ if (nbttagcompound.hasKey("Bukkit.MaxDomestication")) { ++ if (nbttagcompound.contains("Bukkit.MaxDomestication")) { + this.maxDomestication = nbttagcompound.getInt("Bukkit.MaxDomestication"); + } + // CraftBukkit end - if (nbttagcompound.hasKeyOfType("SaddleItem", 10)) { - ItemStack itemstack = ItemStack.a(nbttagcompound.getCompound("SaddleItem")); -@@ -895,6 +904,18 @@ + if (nbttagcompound.contains("SaddleItem", 10)) { + ItemStack itemstack = ItemStack.of(nbttagcompound.getCompound("SaddleItem")); +@@ -897,6 +906,18 @@ @Override - public void b(int i) { + public void handleStartJump(int i) { + // CraftBukkit start + float power; + if (i >= 90) { @@ -90,5 +90,5 @@ + } + // CraftBukkit end this.allowStandSliding = true; - this.fE(); - this.fX(); + this.stand(); + this.playJumpSound(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch index 10f253b1a7..37ea0a4b74 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch @@ -3,9 +3,9 @@ @@ -152,7 +152,7 @@ @Override - public void c() { -- this.mob.setGoalTarget(this.ownerLastHurtBy); -+ this.mob.setGoalTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit + public void start() { +- this.mob.setTarget(this.ownerLastHurtBy); ++ this.mob.setTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit Entity entity = this.llama.getLeashHolder(); if (entity instanceof EntityVillagerTrader) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.patch index 8cc079d9ad..c346c0d693 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.patch @@ -1,28 +1,28 @@ --- a/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.java +++ b/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.java -@@ -40,19 +40,20 @@ +@@ -39,19 +39,20 @@ - entitylightning.teleportAndSync(this.horse.locX(), this.horse.locY(), this.horse.locZ()); - entitylightning.setEffect(true); -- worldserver.addEntity(entitylightning); + entitylightning.moveTo(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 - EntitySkeleton entityskeleton = this.a(difficultydamagescaler, this.horse); + EntitySkeleton entityskeleton = this.createSkeleton(difficultydamagescaler, this.horse); - entityskeleton.startRiding(this.horse); -- worldserver.addAllEntities(entityskeleton); +- worldserver.addFreshEntityWithPassengers(entityskeleton); + if (entityskeleton != null) entityskeleton.startRiding(this.horse); // CraftBukkit -+ worldserver.addAllEntities(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP); // CraftBukkit ++ worldserver.addFreshEntityWithPassengers(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP); // CraftBukkit for (int i = 0; i < 3; ++i) { - EntityHorseAbstract entityhorseabstract = this.a(difficultydamagescaler); + EntityHorseAbstract entityhorseabstract = this.createHorse(difficultydamagescaler); + if (entityhorseabstract == null) continue; // CraftBukkit - EntitySkeleton entityskeleton1 = this.a(difficultydamagescaler, entityhorseabstract); + EntitySkeleton entityskeleton1 = this.createSkeleton(difficultydamagescaler, entityhorseabstract); - entityskeleton1.startRiding(entityhorseabstract); + if (entityskeleton1 != null) entityskeleton1.startRiding(entityhorseabstract); // CraftBukkit - entityhorseabstract.i(this.horse.getRandom().nextGaussian() * 0.5D, 0.0D, this.horse.getRandom().nextGaussian() * 0.5D); -- worldserver.addAllEntities(entityhorseabstract); -+ worldserver.addAllEntities(entityhorseabstract, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit + entityhorseabstract.push(this.horse.getRandom().nextGaussian() * 0.5D, 0.0D, this.horse.getRandom().nextGaussian() * 0.5D); +- worldserver.addFreshEntityWithPassengers(entityhorseabstract); ++ worldserver.addFreshEntityWithPassengers(entityhorseabstract, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch b/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch index c2a4098cd9..de8c748517 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch +++ b/paper-server/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 -@@ -22,6 +22,11 @@ +@@ -21,6 +21,11 @@ import net.minecraft.world.level.block.BlockFireAbstract; import net.minecraft.world.level.dimension.end.EnderDragonBattle; @@ -11,21 +11,21 @@ + public class EntityEnderCrystal extends Entity { - private static final DataWatcherObject<Optional<BlockPosition>> DATA_BEAM_TARGET = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.OPTIONAL_BLOCK_POS); -@@ -57,7 +62,11 @@ - BlockPosition blockposition = this.getChunkCoordinates(); + private static final DataWatcherObject<Optional<BlockPosition>> DATA_BEAM_TARGET = DataWatcher.defineId(EntityEnderCrystal.class, DataWatcherRegistry.OPTIONAL_BLOCK_POS); +@@ -56,7 +61,11 @@ + BlockPosition blockposition = this.blockPosition(); - if (((WorldServer) this.level).getDragonBattle() != null && this.level.getType(blockposition).isAir()) { -- this.level.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) this.level, blockposition)); + if (((WorldServer) this.level).dragonFight() != null && this.level.getBlockState(blockposition).isAir()) { +- this.level.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(this.level, blockposition)); + // CraftBukkit start + if (!CraftEventFactory.callBlockIgniteEvent(this.level, blockposition, this).isCancelled()) { -+ this.level.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) this.level, blockposition)); ++ this.level.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(this.level, blockposition)); + } + // CraftBukkit end } } -@@ -97,9 +106,22 @@ +@@ -96,9 +105,22 @@ return false; } else { if (!this.isRemoved() && !this.level.isClientSide) { @@ -34,9 +34,9 @@ + return false; + } + // CraftBukkit end - this.a(Entity.RemovalReason.KILLED); + this.remove(Entity.RemovalReason.KILLED); if (!damagesource.isExplosion()) { -- this.level.explode((Entity) null, this.locX(), this.locY(), this.locZ(), 6.0F, Explosion.Effect.DESTROY); +- this.level.explode((Entity) null, this.getX(), this.getY(), this.getZ(), 6.0F, Explosion.Effect.DESTROY); + // CraftBukkit start + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 6.0F, false); + this.level.getCraftServer().getPluginManager().callEvent(event); @@ -44,8 +44,8 @@ + this.unsetRemoved(); + return false; + } -+ this.level.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), Explosion.Effect.DESTROY); ++ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Explosion.Effect.DESTROY); + // CraftBukkit end } - this.a(damagesource); + this.onDestroyedBy(damagesource); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch b/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch index 0cae384613..0a1ac9005a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch @@ -29,13 +29,13 @@ super(EntityTypes.ENDER_DRAGON, world); @@ -236,7 +249,7 @@ - Vec3D vec3d1 = idragoncontroller.g(); + Vec3D vec3d1 = idragoncontroller.getFlyTargetLocation(); - if (vec3d1 != null) { -+ if (vec3d1 != null && idragoncontroller.getControllerPhase() != DragonControllerPhase.HOVERING) { // CraftBukkit - Don't move when hovering - d0 = vec3d1.x - this.locX(); - d1 = vec3d1.y - this.locY(); - d2 = vec3d1.z - this.locZ(); ++ if (vec3d1 != null && idragoncontroller.getPhase() != DragonControllerPhase.HOVERING) { // CraftBukkit - Don't move when hovering + d0 = vec3d1.x - this.getX(); + d1 = vec3d1.y - this.getY(); + d2 = vec3d1.z - this.getZ(); @@ -378,7 +391,14 @@ if (this.nearestCrystal.isRemoved()) { this.nearestCrystal = null; @@ -65,10 +65,10 @@ @@ -462,7 +485,11 @@ if (!iblockdata.isAir() && iblockdata.getMaterial() != Material.FIRE) { - if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.a((Tag) TagsBlock.DRAGON_IMMUNE)) { -- flag1 = this.level.a(blockposition, false) || flag1; + if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.is((Tag) TagsBlock.DRAGON_IMMUNE)) { +- flag1 = this.level.removeBlock(blockposition, false) || flag1; + // CraftBukkit start - Add blocks to list rather than destroying them -+ // flag1 = this.level.a(blockposition, false) || flag1; ++ // flag1 = this.level.removeBlock(blockposition, false) || flag1; + flag1 = true; + destroyedBlocks.add(CraftBlock.at(level, blockposition)); + // CraftBukkit end @@ -95,7 +95,7 @@ + } else if (event.getYield() == 0F) { + // Yield zero ==> no drops + for (org.bukkit.block.Block block : event.blockList()) { -+ this.level.a(new BlockPosition(block.getX(), block.getY(), block.getZ()), false); ++ this.level.removeBlock(new BlockPosition(block.getX(), block.getY(), block.getZ()), false); + } + } else { + for (org.bukkit.block.Block block : event.blockList()) { @@ -108,18 +108,18 @@ + BlockPosition blockposition = craftBlock.getPosition(); + + Block nmsBlock = craftBlock.getNMS().getBlock(); -+ if (nmsBlock.a(explosionSource)) { -+ TileEntity tileentity = craftBlock.getNMS().isTileEntity() ? this.level.getTileEntity(blockposition) : null; -+ LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.level)).a(this.level.random).set(LootContextParameters.ORIGIN, Vec3D.a(blockposition)).set(LootContextParameters.TOOL, ItemStack.EMPTY).set(LootContextParameters.EXPLOSION_RADIUS, 1.0F / event.getYield()).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity); ++ if (nmsBlock.dropFromExplosion(explosionSource)) { ++ TileEntity tileentity = craftBlock.getNMS().hasBlockEntity() ? this.level.getBlockEntity(blockposition) : null; ++ LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.level)).withRandom(this.level.random).withParameter(LootContextParameters.ORIGIN, Vec3D.atCenterOf(blockposition)).withParameter(LootContextParameters.TOOL, ItemStack.EMPTY).withParameter(LootContextParameters.EXPLOSION_RADIUS, 1.0F / event.getYield()).withOptionalParameter(LootContextParameters.BLOCK_ENTITY, tileentity); + -+ craftBlock.getNMS().a(loottableinfo_builder).forEach((itemstack) -> { -+ Block.a(level, blockposition, itemstack); ++ craftBlock.getNMS().getDrops(loottableinfo_builder).forEach((itemstack) -> { ++ Block.popResource(level, blockposition, itemstack); + }); -+ craftBlock.getNMS().dropNaturally((WorldServer) level, blockposition, ItemStack.EMPTY); ++ craftBlock.getNMS().spawnAfterBreak((WorldServer) level, blockposition, ItemStack.EMPTY); + } + nmsBlock.wasExploded(level, blockposition, explosionSource); + -+ this.level.a(blockposition, false); ++ this.level.removeBlock(blockposition, false); + } + } + // CraftBukkit end diff --git a/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.patch b/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.patch index 199384d14e..c466412d1e 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.java -@@ -4,6 +4,11 @@ +@@ -5,6 +5,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -12,14 +12,14 @@ public class DragonControllerManager { private static final Logger LOGGER = LogManager.getLogger(); -@@ -22,6 +27,19 @@ - this.currentPhase.e(); +@@ -24,6 +29,19 @@ + this.currentPhase.end(); } + // CraftBukkit start - Call EnderDragonChangePhaseEvent + EnderDragonChangePhaseEvent event = new EnderDragonChangePhaseEvent( + (CraftEnderDragon) this.dragon.getBukkitEntity(), -+ (this.currentPhase == null) ? null : CraftEnderDragon.getBukkitPhase(this.currentPhase.getControllerPhase()), ++ (this.currentPhase == null) ? null : CraftEnderDragon.getBukkitPhase(this.currentPhase.getPhase()), + CraftEnderDragon.getBukkitPhase(dragoncontrollerphase) + ); + this.dragon.level.getCraftServer().getPluginManager().callEvent(event); @@ -29,11 +29,11 @@ + dragoncontrollerphase = CraftEnderDragon.getMinecraftPhase(event.getNewPhase()); + // CraftBukkit end + - this.currentPhase = this.b(dragoncontrollerphase); + this.currentPhase = this.getPhase(dragoncontrollerphase); if (!this.dragon.level.isClientSide) { - this.dragon.getDataWatcher().set(EntityEnderDragon.DATA_PHASE, dragoncontrollerphase.b()); -@@ -43,6 +61,6 @@ - this.phases[i] = dragoncontrollerphase.a(this.dragon); + this.dragon.getEntityData().set(EntityEnderDragon.DATA_PHASE, dragoncontrollerphase.getId()); +@@ -45,6 +63,6 @@ + this.phases[i] = dragoncontrollerphase.createInstance(this.dragon); } - return this.phases[i]; diff --git a/paper-server/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch b/paper-server/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch index b4d16f87fa..7a6bd39f2d 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch +++ b/paper-server/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 -@@ -54,6 +54,17 @@ +@@ -56,6 +56,17 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.Vec3D; @@ -17,72 +17,72 @@ + public class EntityWither extends EntityMonster implements PowerableMob, IRangedEntity { - private static final DataWatcherObject<Integer> DATA_TARGET_A = DataWatcher.a(EntityWither.class, DataWatcherRegistry.INT); -@@ -238,16 +249,40 @@ + private static final DataWatcherObject<Integer> DATA_TARGET_A = DataWatcher.defineId(EntityWither.class, DataWatcherRegistry.INT); +@@ -250,16 +261,40 @@ this.bossEvent.setProgress(1.0F - (float) i / 220.0F); if (i <= 0) { Explosion.Effect explosion_effect = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE; + // CraftBukkit start -+ // this.world.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), 7.0F, false, explosion_effect); ++ // this.level.explode(this, this.getX(), this.getEyeY(), this.getZ(), 7.0F, false, explosion_effect); + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false); + this.level.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ this.level.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect); ++ this.level.explode(this, this.getX(), this.getEyeY(), this.getZ(), event.getRadius(), event.getFire(), explosion_effect); + } + // CraftBukkit end -- this.level.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), 7.0F, false, explosion_effect); +- this.level.explode(this, this.getX(), this.getEyeY(), this.getZ(), 7.0F, false, explosion_effect); if (!this.isSilent()) { -- this.level.b(1023, this.getChunkCoordinates(), 0); +- this.level.globalLevelEvent(1023, this.blockPosition(), 0); + // CraftBukkit start - Use relative location for far away sounds -+ // this.world.b(1023, new BlockPosition(this), 0); ++ // this.world.globalLevelEvent(1023, new BlockPosition(this), 0); + int viewDistance = ((WorldServer) this.level).getCraftServer().getViewDistance() * 16; + for (EntityPlayer player : (List<EntityPlayer>) MinecraftServer.getServer().getPlayerList().players) { -+ double deltaX = this.locX() - player.locX(); -+ double deltaZ = this.locZ() - player.locZ(); ++ double deltaX = this.getX() - player.getX(); ++ double deltaZ = this.getZ() - player.getZ(); + double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; + if (distanceSquared > viewDistance * viewDistance) { + double deltaLength = Math.sqrt(distanceSquared); -+ double relativeX = player.locX() + (deltaX / deltaLength) * viewDistance; -+ double relativeZ = player.locZ() + (deltaZ / deltaLength) * viewDistance; -+ player.connection.sendPacket(new PacketPlayOutWorldEvent(1023, new BlockPosition((int) relativeX, (int) this.locY(), (int) relativeZ), 0, true)); ++ double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; ++ double relativeZ = player.getZ() + (deltaZ / deltaLength) * viewDistance; ++ player.connection.send(new PacketPlayOutWorldEvent(1023, new BlockPosition((int) relativeX, (int) this.getY(), (int) relativeZ), 0, true)); + } else { -+ player.connection.sendPacket(new PacketPlayOutWorldEvent(1023, this.getChunkCoordinates(), 0, true)); ++ player.connection.send(new PacketPlayOutWorldEvent(1023, this.blockPosition(), 0, true)); + } + } + // CraftBukkit end } } - this.setInvul(i); + this.setInvulnerableTicks(i); if (this.tickCount % 10 == 0) { - this.heal(10.0F); + this.heal(10.0F, EntityRegainHealthEvent.RegainReason.WITHER_SPAWN); // CraftBukkit } } else { -@@ -292,6 +327,7 @@ +@@ -304,6 +339,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.setHeadTarget(i, entityliving1.getId()); + this.setAlternativeTarget(i, entityliving1.getId()); } } -@@ -322,6 +358,11 @@ - IBlockData iblockdata = this.level.getType(blockposition); +@@ -334,6 +370,11 @@ + IBlockData iblockdata = this.level.getBlockState(blockposition); - if (c(iblockdata)) { + if (canDestroy(iblockdata)) { + // CraftBukkit start -+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { ++ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { + continue; + } + // CraftBukkit end - flag = this.level.a(blockposition, true, this) || flag; + flag = this.level.destroyBlock(blockposition, true, this) || flag; } } -@@ -335,7 +376,7 @@ +@@ -347,7 +388,7 @@ } if (this.tickCount % 20 == 0) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch index 872c6f828a..2975945ba8 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch +++ b/paper-server/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 -@@ -44,6 +44,15 @@ +@@ -43,6 +43,15 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -16,8 +16,8 @@ public class EntityArmorStand extends EntityLiving { public static final int WOBBLE_TIME = 5; -@@ -106,6 +115,13 @@ - this.setPosition(d0, d1, d2); +@@ -105,6 +114,13 @@ + this.setPos(d0, d1, d2); } + // CraftBukkit start - SPIGOT-3607, SPIGOT-3637 @@ -28,33 +28,33 @@ + // CraftBukkit end + @Override - public void updateSize() { - double d0 = this.locX(); -@@ -161,14 +177,21 @@ + public void refreshDimensions() { + double d0 = this.getX(); +@@ -160,14 +176,21 @@ @Override - public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { + public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { + // CraftBukkit start -+ this.setSlot(enumitemslot, itemstack, false); ++ this.setItemSlot(enumitemslot, itemstack, false); + } + + @Override -+ public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) { ++ public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) { + // CraftBukkit end - this.f(itemstack); - switch (enumitemslot.a()) { + this.verifyEquippedItem(itemstack); + switch (enumitemslot.getType()) { case HAND: -- this.playEquipSound(itemstack); -+ this.playEquipSound(itemstack, silent); // CraftBukkit - this.handItems.set(enumitemslot.b(), itemstack); +- this.equipEventAndSound(itemstack); ++ this.equipEventAndSound(itemstack, silent); // CraftBukkit + this.handItems.set(enumitemslot.getIndex(), itemstack); break; case ARMOR: -- this.playEquipSound(itemstack); -+ this.playEquipSound(itemstack, silent); // CraftBukkit - this.armorItems.set(enumitemslot.b(), itemstack); +- this.equipEventAndSound(itemstack); ++ this.equipEventAndSound(itemstack, silent); // CraftBukkit + this.armorItems.set(enumitemslot.getIndex(), itemstack); } -@@ -405,6 +428,21 @@ +@@ -404,6 +427,21 @@ return false; } else { ItemStack itemstack2; @@ -75,9 +75,9 @@ + // CraftBukkit end if (entityhuman.getAbilities().instabuild && itemstack1.isEmpty() && !itemstack.isEmpty()) { - itemstack2 = itemstack.cloneItemStack(); -@@ -433,9 +471,19 @@ - public boolean damageEntity(DamageSource damagesource, float f) { + itemstack2 = itemstack.copy(); +@@ -432,9 +470,19 @@ + public boolean hurt(DamageSource damagesource, float f) { if (!this.level.isClientSide && !this.isRemoved()) { if (DamageSource.OUT_OF_WORLD.equals(damagesource)) { + // CraftBukkit start @@ -85,79 +85,79 @@ + return false; + } + // CraftBukkit end - this.killEntity(); + this.kill(); return false; -- } else if (!this.isInvulnerable(damagesource) && !this.invisible && !this.isMarker()) { -+ } else if (!this.isInvulnerable(damagesource) && (true || !this.invisible) && !this.isMarker()) { // CraftBukkit +- } else if (!this.isInvulnerableTo(damagesource) && !this.invisible && !this.isMarker()) { ++ } else if (!this.isInvulnerableTo(damagesource) && (true || !this.invisible) && !this.isMarker()) { // CraftBukkit + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, true, this.invisible)) { + return false; + } + // CraftBukkit end if (damagesource.isExplosion()) { - this.h(damagesource); - this.killEntity(); -@@ -475,7 +523,7 @@ + this.brokenByAnything(damagesource); + this.kill(); +@@ -474,7 +522,7 @@ } else { - this.g(damagesource); - this.G(); -- this.killEntity(); -+ this.die(); // CraftBukkit - SPIGOT-4890: remain as this.die() since above damagesource method will call death event + this.brokenByPlayer(damagesource); + this.showBreakingParticles(); +- this.kill(); ++ this.discard(); // CraftBukkit - SPIGOT-4890: remain as this.die() since above damagesource method will call death event } return true; -@@ -536,13 +584,13 @@ +@@ -535,13 +583,13 @@ } - private void g(DamageSource damagesource) { -- Block.a(this.level, this.getChunkCoordinates(), new ItemStack(Items.ARMOR_STAND)); + private void brokenByPlayer(DamageSource damagesource) { +- Block.popResource(this.level, this.blockPosition(), new ItemStack(Items.ARMOR_STAND)); + drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(new ItemStack(Items.ARMOR_STAND))); // CraftBukkit - add to drops - this.h(damagesource); + this.brokenByAnything(damagesource); } - private void h(DamageSource damagesource) { - this.H(); -- this.f(damagesource); -+ // this.f(damagesource); // CraftBukkit - moved down + private void brokenByAnything(DamageSource damagesource) { + this.playBrokenSound(); +- this.dropAllDeathLoot(damagesource); ++ // this.dropAllDeathLoot(damagesource); // CraftBukkit - moved down ItemStack itemstack; int i; -@@ -550,7 +598,7 @@ +@@ -549,7 +597,7 @@ for (i = 0; i < this.handItems.size(); ++i) { itemstack = (ItemStack) this.handItems.get(i); if (!itemstack.isEmpty()) { -- Block.a(this.level, this.getChunkCoordinates().up(), itemstack); +- 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); } } -@@ -558,10 +606,11 @@ +@@ -557,10 +605,11 @@ for (i = 0; i < this.armorItems.size(); ++i) { itemstack = (ItemStack) this.armorItems.get(i); if (!itemstack.isEmpty()) { -- Block.a(this.level, this.getChunkCoordinates().up(), itemstack); +- 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.f(damagesource); // CraftBukkit - moved from above ++ this.dropAllDeathLoot(damagesource); // CraftBukkit - moved from above } -@@ -662,8 +711,16 @@ +@@ -661,8 +710,16 @@ return this.isSmall(); } + // CraftBukkit start + @Override -+ protected boolean isDropExperience() { ++ protected boolean shouldDropExperience() { + return true; // MC-157395, SPIGOT-5193 even baby (small) armor stands should drop + } + // CraftBukkit end + @Override - public void killEntity() { + public void kill() { + org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, drops); // CraftBukkit - call event - this.a(Entity.RemovalReason.KILLED); + this.remove(Entity.RemovalReason.KILLED); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityHanging.patch b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityHanging.patch index 54dae2d9ad..020314383e 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityHanging.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityHanging.patch @@ -17,13 +17,13 @@ protected static final Predicate<Entity> HANGING_ENTITY = (entity) -> { @@ -57,26 +65,37 @@ - protected void updateBoundingBox() { + protected void recalculateBoundingBox() { if (this.direction != null) { - double d0 = (double) this.pos.getX() + 0.5D; - double d1 = (double) this.pos.getY() + 0.5D; - double d2 = (double) this.pos.getZ() + 0.5D; + // CraftBukkit start code moved in to calculateBoundingBox -+ this.a(calculateBoundingBox(this, this.pos, this.direction, this.getHangingWidth(), this.getHangingHeight())); ++ this.setBoundingBox(calculateBoundingBox(this, this.pos, this.direction, this.getWidth(), this.getHeight())); + // CraftBukkit end + } + } @@ -35,34 +35,34 @@ + double d1 = (double) blockPosition.getY() + 0.5D; + double d2 = (double) blockPosition.getZ() + 0.5D; double d3 = 0.46875D; -- double d4 = this.a(this.getHangingWidth()); -- double d5 = this.a(this.getHangingHeight()); -+ double d4 = a(width); -+ double d5 = a(height); +- double d4 = this.offs(this.getWidth()); +- double d5 = this.offs(this.getHeight()); ++ double d4 = offs(width); ++ double d5 = offs(height); -- d0 -= (double) this.direction.getAdjacentX() * 0.46875D; -- d2 -= (double) this.direction.getAdjacentZ() * 0.46875D; -+ d0 -= (double) direction.getAdjacentX() * 0.46875D; -+ d2 -= (double) direction.getAdjacentZ() * 0.46875D; +- d0 -= (double) this.direction.getStepX() * 0.46875D; +- d2 -= (double) this.direction.getStepZ() * 0.46875D; ++ d0 -= (double) direction.getStepX() * 0.46875D; ++ d2 -= (double) direction.getStepZ() * 0.46875D; d1 += d5; -- EnumDirection enumdirection = this.direction.h(); -+ EnumDirection enumdirection = direction.h(); +- EnumDirection enumdirection = this.direction.getCounterClockWise(); ++ EnumDirection enumdirection = direction.getCounterClockWise(); - d0 += d4 * (double) enumdirection.getAdjacentX(); - d2 += d4 * (double) enumdirection.getAdjacentZ(); -- this.setPositionRaw(d0, d1, d2); -- double d6 = (double) this.getHangingWidth(); -- double d7 = (double) this.getHangingHeight(); -- double d8 = (double) this.getHangingWidth(); + d0 += d4 * (double) enumdirection.getStepX(); + d2 += d4 * (double) enumdirection.getStepZ(); +- this.setPosRaw(d0, d1, d2); +- double d6 = (double) this.getWidth(); +- double d7 = (double) this.getHeight(); +- double d8 = (double) this.getWidth(); + if (entity != null) { -+ entity.setPositionRaw(d0, d1, d2); ++ entity.setPosRaw(d0, d1, d2); + } + double d6 = (double) width; + double d7 = (double) height; + double d8 = (double) width; -- if (this.direction.n() == EnumDirection.EnumAxis.Z) { -+ if (direction.n() == EnumDirection.EnumAxis.Z) { +- if (this.direction.getAxis() == EnumDirection.EnumAxis.Z) { ++ if (direction.getAxis() == EnumDirection.EnumAxis.Z) { d8 = 1.0D; } else { d6 = 1.0D; @@ -70,14 +70,14 @@ d6 /= 32.0D; d7 /= 32.0D; d8 /= 32.0D; -- this.a(new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8)); +- this.setBoundingBox(new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8)); + return new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8); } } + // CraftBukkit end -- private double a(int i) { -+ private static double a(int i) { // CraftBukkit - static +- private double offs(int i) { ++ private static double offs(int i) { // CraftBukkit - static return i % 32 == 0 ? 0.5D : 0.0D; } @@ -86,7 +86,7 @@ this.checkInterval = 0; if (!this.isRemoved() && !this.survives()) { + // CraftBukkit start - fire break events -+ Material material = this.level.getType(this.getChunkCoordinates()).getMaterial(); ++ Material material = this.level.getBlockState(this.blockPosition()).getMaterial(); + HangingBreakEvent.RemoveCause cause; + + if (!material.equals(Material.AIR)) { @@ -103,8 +103,8 @@ + return; + } + // CraftBukkit end - this.die(); - this.a((Entity) null); + this.discard(); + this.dropItem((Entity) null); } @@ -163,6 +201,22 @@ return false; @@ -126,13 +126,13 @@ + } + // CraftBukkit end + - this.killEntity(); - this.velocityChanged(); - this.a(damagesource.getEntity()); + this.kill(); + this.markHurt(); + this.dropItem(damagesource.getEntity()); @@ -175,6 +229,18 @@ @Override public void move(EnumMoveType enummovetype, Vec3D vec3d) { - if (!this.level.isClientSide && !this.isRemoved() && vec3d.g() > 0.0D) { + if (!this.level.isClientSide && !this.isRemoved() && vec3d.lengthSqr() > 0.0D) { + if (this.isRemoved()) return; // CraftBukkit + + // CraftBukkit start - fire break events @@ -145,15 +145,15 @@ + } + // CraftBukkit end + - this.killEntity(); - this.a((Entity) null); + this.kill(); + this.dropItem((Entity) null); } @@ -183,7 +249,7 @@ @Override - public void i(double d0, double d1, double d2) { + public void push(double d0, double d1, double d2) { - if (!this.level.isClientSide && !this.isRemoved() && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { + if (false && !this.level.isClientSide && !this.isRemoved() && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { // CraftBukkit - not needed - this.killEntity(); - this.a((Entity) null); + this.kill(); + this.dropItem((Entity) null); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch index c782d10dee..7fe1e67dd8 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/world/entity/decoration/EntityItemFrame.java @@ -91,16 +91,27 @@ @Override - protected void updateBoundingBox() { + protected void recalculateBoundingBox() { if (this.direction != null) { + // CraftBukkit start code moved in to calculateBoundingBox -+ this.a(calculateBoundingBox(this, this.pos, this.direction, this.getHangingWidth(), this.getHangingHeight())); ++ this.setBoundingBox(calculateBoundingBox(this, this.pos, this.direction, this.getWidth(), this.getHeight())); + // CraftBukkit end + } + } @@ -14,26 +14,26 @@ + public static AxisAlignedBB calculateBoundingBox(@Nullable Entity entity, BlockPosition blockPosition, EnumDirection direction, int width, int height) { + { double d0 = 0.46875D; -- double d1 = (double) this.pos.getX() + 0.5D - (double) this.direction.getAdjacentX() * 0.46875D; -- double d2 = (double) this.pos.getY() + 0.5D - (double) this.direction.getAdjacentY() * 0.46875D; -- double d3 = (double) this.pos.getZ() + 0.5D - (double) this.direction.getAdjacentZ() * 0.46875D; +- double d1 = (double) this.pos.getX() + 0.5D - (double) this.direction.getStepX() * 0.46875D; +- double d2 = (double) this.pos.getY() + 0.5D - (double) this.direction.getStepY() * 0.46875D; +- double d3 = (double) this.pos.getZ() + 0.5D - (double) this.direction.getStepZ() * 0.46875D; - -- this.setPositionRaw(d1, d2, d3); -- double d4 = (double) this.getHangingWidth(); -- double d5 = (double) this.getHangingHeight(); -- double d6 = (double) this.getHangingWidth(); -- EnumDirection.EnumAxis enumdirection_enumaxis = this.direction.n(); -+ double d1 = (double) blockPosition.getX() + 0.5D - (double) direction.getAdjacentX() * 0.46875D; -+ double d2 = (double) blockPosition.getY() + 0.5D - (double) direction.getAdjacentY() * 0.46875D; -+ double d3 = (double) blockPosition.getZ() + 0.5D - (double) direction.getAdjacentZ() * 0.46875D; +- this.setPosRaw(d1, d2, d3); +- double d4 = (double) this.getWidth(); +- double d5 = (double) this.getHeight(); +- double d6 = (double) this.getWidth(); +- EnumDirection.EnumAxis enumdirection_enumaxis = this.direction.getAxis(); ++ double d1 = (double) blockPosition.getX() + 0.5D - (double) direction.getStepX() * 0.46875D; ++ double d2 = (double) blockPosition.getY() + 0.5D - (double) direction.getStepY() * 0.46875D; ++ double d3 = (double) blockPosition.getZ() + 0.5D - (double) direction.getStepZ() * 0.46875D; + + if (entity != null) { -+ entity.setPositionRaw(d1, d2, d3); ++ entity.setPosRaw(d1, d2, d3); + } + double d4 = (double) width; + double d5 = (double) height; + double d6 = (double) width; -+ EnumDirection.EnumAxis enumdirection_enumaxis = direction.n(); ++ EnumDirection.EnumAxis enumdirection_enumaxis = direction.getAxis(); switch (enumdirection_enumaxis) { case X: @@ -41,7 +41,7 @@ d4 /= 32.0D; d5 /= 32.0D; d6 /= 32.0D; -- this.a(new AxisAlignedBB(d1 - d4, d2 - d5, d3 - d6, d1 + d4, d2 + d5, d3 + d6)); +- this.setBoundingBox(new AxisAlignedBB(d1 - d4, d2 - d5, d3 - d6, d1 + d4, d2 + d5, d3 + d6)); + return new AxisAlignedBB(d1 - d4, d2 - d5, d3 - d6, d1 + d4, d2 + d5, d3 + d6); } } @@ -58,8 +58,8 @@ + return true; + } + // CraftBukkit end - this.b(damagesource.getEntity(), false); - this.playSound(this.h(), 1.0F, 1.0F); + this.dropItem(damagesource.getEntity(), false); + this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F); } @@ -277,6 +294,12 @@ } @@ -72,14 +72,14 @@ + public void setItem(ItemStack itemstack, boolean flag, boolean playSound) { + // CraftBukkit end if (!itemstack.isEmpty()) { - itemstack = itemstack.cloneItemStack(); + itemstack = itemstack.copy(); itemstack.setCount(1); @@ -284,7 +307,7 @@ } - this.getDataWatcher().set(EntityItemFrame.DATA_ITEM, itemstack); + this.getEntityData().set(EntityItemFrame.DATA_ITEM, itemstack); - if (!itemstack.isEmpty()) { + if (!itemstack.isEmpty() && playSound) { // CraftBukkit - this.playSound(this.l(), 1.0F, 1.0F); + this.playSound(this.getAddItemSound(), 1.0F, 1.0F); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch index 7db7fc2103..04dcf8b90f 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch @@ -19,20 +19,20 @@ if (entityinsentient.getLeashHolder() == entityhuman) { + // CraftBukkit start + if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman).isCancelled()) { -+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutAttachEntity(entityinsentient, entityinsentient.getLeashHolder())); ++ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(entityinsentient, entityinsentient.getLeashHolder())); + continue; + } + // CraftBukkit end - entityinsentient.setLeashHolder(this, true); + entityinsentient.setLeashedTo(this, true); flag = true; } } if (!flag) { -- this.die(); +- this.discard(); - if (entityhuman.getAbilities().instabuild) { + // CraftBukkit start - Move below -+ // this.die(); ++ // this.discard(); + boolean die = true; + // CraftBukkit end + if (true || entityhuman.getAbilities().instabuild) { // CraftBukkit - Process for non-creative as well @@ -41,19 +41,19 @@ while (iterator.hasNext()) { entityinsentient = (EntityInsentient) iterator.next(); if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == this) { -- entityinsentient.unleash(true, false); +- entityinsentient.dropLeash(true, false); + // CraftBukkit start + if (CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient, entityhuman).isCancelled()) { + die = false; + continue; + } -+ entityinsentient.unleash(true, !entityhuman.getAbilities().instabuild); // false -> survival mode boolean ++ entityinsentient.dropLeash(true, !entityhuman.getAbilities().instabuild); // false -> survival mode boolean + // CraftBukkit end } } + // CraftBukkit start + if (die) { -+ this.die(); ++ this.discard(); + } + // CraftBukkit end } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch deleted file mode 100644 index 2809bebd6e..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/world/entity/decoration/EntityPainting.java -+++ b/net/minecraft/world/entity/decoration/EntityPainting.java -@@ -27,6 +27,10 @@ - - public EntityPainting(EntityTypes<? extends EntityPainting> entitytypes, World world) { - super(entitytypes, world); -+ // CraftBukkit start - generate a non-null painting -+ List<Paintings> list = Lists.newArrayList(Paintings.KEBAB); -+ this.motive = (Paintings) list.get(this.random.nextInt(list.size())); -+ // CraftBukkit end - } - - public EntityPainting(World world, BlockPosition blockposition, EnumDirection enumdirection) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch index 673ecf6fa4..32668b61fa 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch @@ -8,30 +8,30 @@ + public class EntityFallingBlock extends Entity { - private IBlockData blockState; -@@ -114,7 +116,7 @@ + private static final int REMOVAL_DELAY_MILLIS = 50; +@@ -122,7 +124,7 @@ if (this.time++ == 0) { - blockposition = this.getChunkCoordinates(); -- if (this.level.getType(blockposition).a(block)) { -+ if (this.level.getType(blockposition).a(block) && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { - this.level.a(blockposition, false); + blockposition = this.blockPosition(); +- if (this.level.getBlockState(blockposition).is(block)) { ++ if (this.level.getBlockState(blockposition).is(block) && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { + this.level.removeBlock(blockposition, false); } else if (!this.level.isClientSide) { - this.die(); -@@ -165,6 +167,12 @@ - this.blockState = (IBlockData) this.blockState.set(BlockProperties.WATERLOGGED, true); + this.discard(); +@@ -173,6 +175,12 @@ + this.blockState = (IBlockData) this.blockState.setValue(BlockProperties.WATERLOGGED, true); } + // CraftBukkit start + if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.blockState).isCancelled()) { -+ this.die(); // SPIGOT-6586 called before the event in previous versions ++ this.discard(); // SPIGOT-6586 called before the event in previous versions + return; + } + // CraftBukkit end - if (this.level.setTypeAndData(blockposition, this.blockState, 3)) { - ((WorldServer) this.level).getChunkProvider().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level.getType(blockposition))); - this.die(); -@@ -238,7 +246,7 @@ + if (this.level.setBlock(blockposition, this.blockState, 3)) { + ((WorldServer) this.level).getChunkSource().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition))); + this.discard(); +@@ -252,7 +260,7 @@ if (i < 0) { return false; } else { @@ -40,13 +40,13 @@ DamageSource damagesource1; if (this.blockState.getBlock() instanceof Fallable) { -@@ -254,7 +262,9 @@ - float f2 = (float) Math.min(MathHelper.d((float) i * this.fallDamagePerDistance), this.fallDamageMax); +@@ -268,7 +276,9 @@ + float f2 = (float) Math.min(MathHelper.floor((float) i * this.fallDamagePerDistance), this.fallDamageMax); - this.level.getEntities(this, this.getBoundingBox(), predicate).forEach((entity) -> { + this.level.getEntities((Entity) this, this.getBoundingBox(), predicate).forEach((entity) -> { + CraftEventFactory.entityDamage = this; // CraftBukkit - entity.damageEntity(damagesource1, f2); + entity.hurt(damagesource1, f2); + CraftEventFactory.entityDamage = null; // CraftBukkit }); - boolean flag = this.blockState.a((Tag) TagsBlock.ANVIL); + boolean flag = this.blockState.is((Tag) TagsBlock.ANVIL); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityItem.patch b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityItem.patch index c08ed4d058..467f9150fe 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityItem.patch +++ b/paper-server/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 -@@ -33,6 +33,12 @@ +@@ -32,6 +32,12 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.Vec3D; @@ -12,17 +12,17 @@ + public class EntityItem extends Entity { - private static final DataWatcherObject<ItemStack> DATA_ITEM = DataWatcher.a(EntityItem.class, DataWatcherRegistry.ITEM_STACK); -@@ -45,6 +51,7 @@ - private UUID thrower; + private static final DataWatcherObject<ItemStack> DATA_ITEM = DataWatcher.defineId(EntityItem.class, DataWatcherRegistry.ITEM_STACK); +@@ -46,6 +52,7 @@ + @Nullable private UUID owner; public final float bobOffs; + private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit public EntityItem(EntityTypes<? extends EntityItem> entitytypes, World world) { super(entitytypes, world); -@@ -94,9 +101,12 @@ - this.die(); +@@ -95,9 +102,12 @@ + this.discard(); } else { super.tick(); - if (this.pickupDelay > 0 && this.pickupDelay != 32767) { @@ -35,10 +35,10 @@ + this.lastTick = MinecraftServer.currentTick; + // CraftBukkit end - this.xo = this.locX(); - this.yo = this.locY(); -@@ -148,9 +158,11 @@ - this.mergeNearby(); + this.xo = this.getX(); + this.yo = this.getY(); +@@ -147,9 +157,11 @@ + this.mergeWithNeighbours(); } + /* CraftBukkit start - moved up @@ -47,9 +47,9 @@ } + // CraftBukkit end */ - this.hasImpulse |= this.aR(); + this.hasImpulse |= this.updateInWaterStateAndDoFluidPushing(); if (!this.level.isClientSide) { -@@ -162,6 +174,12 @@ +@@ -161,6 +173,12 @@ } if (!this.level.isClientSide && this.age >= 6000) { @@ -59,24 +59,24 @@ + return; + } + // CraftBukkit end - this.die(); + this.discard(); } -@@ -237,10 +255,11 @@ - private static void a(EntityItem entityitem, ItemStack itemstack, ItemStack itemstack1) { - ItemStack itemstack2 = a(itemstack, itemstack1, 64); +@@ -236,10 +254,11 @@ + private static void merge(EntityItem entityitem, ItemStack itemstack, ItemStack itemstack1) { + ItemStack itemstack2 = merge(itemstack, itemstack1, 64); -- entityitem.setItemStack(itemstack2); -+ if (!itemstack2.isEmpty()) entityitem.setItemStack(itemstack2); // CraftBukkit - don't set empty stacks +- entityitem.setItem(itemstack2); ++ if (!itemstack2.isEmpty()) entityitem.setItem(itemstack2); // CraftBukkit - don't set empty stacks } - private static void a(EntityItem entityitem, ItemStack itemstack, EntityItem entityitem1, ItemStack itemstack1) { + private static void merge(EntityItem entityitem, ItemStack itemstack, EntityItem entityitem1, ItemStack itemstack1) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemMergeEvent(entityitem1, entityitem).isCancelled()) return; // CraftBukkit - a(entityitem, itemstack, itemstack1); + merge(entityitem, itemstack, itemstack1); entityitem.pickupDelay = Math.max(entityitem.pickupDelay, entityitem1.pickupDelay); entityitem.age = Math.min(entityitem.age, entityitem1.age); -@@ -264,6 +283,11 @@ - } else if (!this.getItemStack().getItem().a(damagesource)) { +@@ -263,6 +282,11 @@ + } else if (!this.getItem().getItem().canBeHurtBy(damagesource)) { return false; } else { + // CraftBukkit start @@ -84,10 +84,10 @@ + return false; + } + // CraftBukkit end - this.velocityChanged(); + this.markHurt(); this.health = (int) ((float) this.health - f); - this.a(GameEvent.ENTITY_DAMAGED, damagesource.getEntity()); -@@ -327,6 +351,46 @@ + this.gameEvent(GameEvent.ENTITY_DAMAGED, damagesource.getEntity()); +@@ -326,6 +350,46 @@ Item item = itemstack.getItem(); int i = itemstack.getCount(); @@ -116,7 +116,7 @@ + } + + // Update the ItemStack if it was changed in the event -+ ItemStack current = this.getItemStack(); ++ ItemStack current = this.getItem(); + if (!itemstack.equals(current)) { + itemstack = current; + } else { @@ -131,16 +131,16 @@ + } + // CraftBukkit end + - if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(entityhuman.getUniqueID())) && entityhuman.getInventory().pickup(itemstack)) { - entityhuman.receive(this, i); + if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(entityhuman.getUUID())) && entityhuman.getInventory().add(itemstack)) { + entityhuman.take(this, i); if (itemstack.isEmpty()) { -@@ -370,7 +434,9 @@ +@@ -369,7 +433,9 @@ } - public void setItemStack(ItemStack itemstack) { + public void setItem(ItemStack itemstack) { + com.google.common.base.Preconditions.checkArgument(!itemstack.isEmpty(), "Cannot drop air"); // CraftBukkit - this.getDataWatcher().set(EntityItem.DATA_ITEM, itemstack); -+ this.getDataWatcher().markDirty(EntityItem.DATA_ITEM); // CraftBukkit - SPIGOT-4591, must mark dirty + this.getEntityData().set(EntityItem.DATA_ITEM, itemstack); ++ this.getEntityData().markDirty(EntityItem.DATA_ITEM); // CraftBukkit - SPIGOT-4591, must mark dirty } @Override diff --git a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch index 2abacbb6ce..e14a4674cd 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch @@ -8,7 +8,7 @@ + public class EntityTNTPrimed extends Entity { - private static final DataWatcherObject<Integer> DATA_FUSE_ID = DataWatcher.a(EntityTNTPrimed.class, DataWatcherRegistry.INT); + private static final DataWatcherObject<Integer> DATA_FUSE_ID = DataWatcher.defineId(EntityTNTPrimed.class, DataWatcherRegistry.INT); private static final int DEFAULT_FUSE_TIME = 80; @Nullable public EntityLiving owner; @@ -19,18 +19,18 @@ super(entitytypes, world); @@ -73,10 +77,13 @@ - this.setFuseTicks(i); + this.setFuse(i); if (i <= 0) { -- this.die(); +- this.discard(); + // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event -+ // this.die(); ++ // this.discard(); if (!this.level.isClientSide) { this.explode(); } -+ this.die(); ++ this.discard(); + // CraftBukkit end } else { - this.aR(); + this.updateInWaterStateAndDoFluidPushing(); if (this.level.isClientSide) { @@ -87,9 +94,16 @@ } @@ -40,12 +40,12 @@ + // CraftBukkit start + // float f = 4.0F; -- this.level.explode(this, this.locX(), this.e(0.0625D), this.locZ(), 4.0F, Explosion.Effect.BREAK); +- this.level.explode(this, this.getX(), this.getY(0.0625D), this.getZ(), 4.0F, Explosion.Effect.BREAK); + ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); + this.level.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ this.level.createExplosion(this, this.locX(), this.e(0.0625D), this.locZ(), event.getRadius(), event.getFire(), Explosion.Effect.BREAK); ++ this.level.explode(this, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), Explosion.Effect.BREAK); + } + // CraftBukkit end } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch index 450df87b48..f12344b05b 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch @@ -12,11 +12,11 @@ + public class EntityCreeper extends EntityMonster implements PowerableMob { - private static final DataWatcherObject<Integer> DATA_SWELL_DIR = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.INT); + private static final DataWatcherObject<Integer> DATA_SWELL_DIR = DataWatcher.defineId(EntityCreeper.class, DataWatcherRegistry.INT); @@ -219,9 +225,19 @@ @Override - public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) { - super.onLightningStrike(worldserver, entitylightning); + public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { + super.thunderHit(worldserver, entitylightning); - this.entityData.set(EntityCreeper.DATA_IS_POWERED, true); + // CraftBukkit start + if (CraftEventFactory.callCreeperPowerEvent(this, entitylightning, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) { @@ -32,24 +32,24 @@ + // CraftBukkit end + @Override - protected EnumInteractionResult b(EntityHuman entityhuman, EnumHand enumhand) { - ItemStack itemstack = entityhuman.b(enumhand); + protected EnumInteractionResult mobInteract(EntityHuman entityhuman, EnumHand enumhand) { + ItemStack itemstack = entityhuman.getItemInHand(enumhand); @@ -246,10 +262,18 @@ Explosion.Effect explosion_effect = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE; float f = this.isPowered() ? 2.0F : 1.0F; - this.dead = true; -- this.level.explode(this, this.locX(), this.locY(), this.locZ(), (float) this.explosionRadius * f, explosion_effect); -- this.die(); -- this.createEffectCloud(); +- this.level.explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, explosion_effect); +- this.discard(); +- this.spawnLingeringCloud(); + // CraftBukkit start + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false); + this.level.getCraftServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { + this.dead = true; -+ this.level.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect); -+ this.die(); -+ this.createEffectCloud(); ++ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), explosion_effect); ++ this.discard(); ++ this.spawnLingeringCloud(); + } else { + swell = 0; + } @@ -59,9 +59,9 @@ } @@ -260,6 +284,7 @@ if (!collection.isEmpty()) { - EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level, this.locX(), this.locY(), this.locZ()); + EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level, this.getX(), this.getY(), this.getZ()); -+ entityareaeffectcloud.setSource(this); // CraftBukkit ++ entityareaeffectcloud.setOwner(this); // CraftBukkit entityareaeffectcloud.setRadius(2.5F); entityareaeffectcloud.setRadiusOnUse(-0.5F); entityareaeffectcloud.setWaitTime(10); @@ -69,8 +69,8 @@ entityareaeffectcloud.addEffect(new MobEffect(mobeffect)); } -- this.level.addEntity(entityareaeffectcloud); -+ this.level.addEntity(entityareaeffectcloud, CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit +- this.level.addFreshEntity(entityareaeffectcloud); ++ this.level.addFreshEntity(entityareaeffectcloud, CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch index 68d822e8b5..c7a351df53 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch @@ -1,58 +1,58 @@ --- a/net/minecraft/world/entity/monster/EntityEnderman.java +++ b/net/minecraft/world/entity/monster/EntityEnderman.java -@@ -105,7 +105,17 @@ +@@ -110,7 +110,17 @@ @Override - public void setGoalTarget(@Nullable EntityLiving entityliving) { -- super.setGoalTarget(entityliving); + public void setTarget(@Nullable EntityLiving entityliving) { +- super.setTarget(entityliving); + // CraftBukkit start - fire event -+ setGoalTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN, true); ++ setTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN, true); + } + + @Override -+ public boolean setGoalTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) { -+ if (!super.setGoalTarget(entityliving, reason, fireEvent)) { ++ public boolean setTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) { ++ if (!super.setTarget(entityliving, reason, fireEvent)) { + return false; + } -+ entityliving = getGoalTarget(); ++ entityliving = getTarget(); + // CraftBukkit end - AttributeModifiable attributemodifiable = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED); + AttributeModifiable attributemodifiable = this.getAttribute(GenericAttributes.MOVEMENT_SPEED); if (entityliving == null) { -@@ -120,6 +130,7 @@ - attributemodifiable.b(EntityEnderman.SPEED_MODIFIER_ATTACKING); +@@ -125,6 +135,7 @@ + attributemodifiable.addTransientModifier(EntityEnderman.SPEED_MODIFIER_ATTACKING); } } + return true; } -@@ -446,9 +457,13 @@ +@@ -471,9 +482,13 @@ if (iblockdata2 != null) { - iblockdata2 = Block.b(iblockdata2, (GeneratorAccess) this.enderman.level, blockposition); - if (this.a(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) { + iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level, blockposition); + if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) { + // CraftBukkit start - Place event + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, iblockdata2).isCancelled()) { - world.setTypeAndData(blockposition, iblockdata2, 3); - world.a((Entity) this.enderman, GameEvent.BLOCK_PLACE, blockposition); - this.enderman.setCarried((IBlockData) null); + world.setBlock(blockposition, iblockdata2, 3); + world.gameEvent(this.enderman, GameEvent.BLOCK_PLACE, blockposition); + this.enderman.setCarriedBlock((IBlockData) null); + } + // CraftBukkit end } } -@@ -487,9 +502,13 @@ - boolean flag = movingobjectpositionblock.getBlockPosition().equals(blockposition); +@@ -512,9 +527,13 @@ + boolean flag = movingobjectpositionblock.getBlockPos().equals(blockposition); - if (iblockdata.a((Tag) TagsBlock.ENDERMAN_HOLDABLE) && flag) { -- world.a(blockposition, false); -- world.a((Entity) this.enderman, GameEvent.BLOCK_DESTROY, blockposition); -- this.enderman.setCarried(iblockdata.getBlock().getBlockData()); + if (iblockdata.is((Tag) TagsBlock.ENDERMAN_HOLDABLE) && flag) { +- world.removeBlock(blockposition, false); +- world.gameEvent(this.enderman, GameEvent.BLOCK_DESTROY, blockposition); +- this.enderman.setCarriedBlock(iblockdata.getBlock().defaultBlockState()); + // CraftBukkit start - Pickup event -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { -+ world.a(blockposition, false); -+ world.a((Entity) this.enderman, GameEvent.BLOCK_DESTROY, blockposition); -+ this.enderman.setCarried(iblockdata.getBlock().getBlockData()); ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { ++ world.removeBlock(blockposition, false); ++ world.gameEvent(this.enderman, GameEvent.BLOCK_DESTROY, blockposition); ++ this.enderman.setCarriedBlock(iblockdata.getBlock().defaultBlockState()); + } + // CraftBukkit end } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch index aa41cb9d7d..e927c7632f 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/monster/EntityGhast.java +++ b/net/minecraft/world/entity/monster/EntityGhast.java -@@ -318,6 +318,8 @@ +@@ -330,6 +330,8 @@ - EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, d2, d3, d4, this.ghast.getPower()); + EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, d2, d3, d4, this.ghast.getExplosionPower()); -+ // CraftBukkit - set bukkitYield when setting explosionpower -+ entitylargefireball.bukkitYield = entitylargefireball.explosionPower = this.ghast.getPower(); - entitylargefireball.setPosition(this.ghast.locX() + vec3d.x * 4.0D, this.ghast.e(0.5D) + 0.5D, entitylargefireball.locZ() + vec3d.z * 4.0D); - world.addEntity(entitylargefireball); - this.chargeTime = -40; ++ // CraftBukkit - set bukkitYield when setting explosionpower ++ entitylargefireball.bukkitYield = entitylargefireball.explosionPower = this.ghast.getExplosionPower(); + entitylargefireball.setPos(this.ghast.getX() + vec3d.x * 4.0D, this.ghast.getY(0.5D) + 0.5D, entitylargefireball.getZ() + vec3d.z * 4.0D); + world.addFreshEntity(entitylargefireball); + this.chargeTime = -40; diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityGuardian.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityGuardian.patch deleted file mode 100644 index 8790c2871c..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityGuardian.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/entity/monster/EntityGuardian.java -+++ b/net/minecraft/world/entity/monster/EntityGuardian.java -@@ -123,7 +123,7 @@ - return 80; - } - -- void a(int i) { -+ public void a(int i) { // PAIL package -> public, rename setLaserTarget - this.entityData.set(EntityGuardian.DATA_ID_ATTACK_TARGET, i); - } - diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityGuardianElder.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityGuardianElder.patch index 3cf5d27230..c8c0d7da66 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityGuardianElder.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityGuardianElder.patch @@ -3,7 +3,7 @@ @@ -79,7 +79,7 @@ if (!entityplayer.hasEffect(mobeffectlist) || entityplayer.getEffect(mobeffectlist).getAmplifier() < 2 || entityplayer.getEffect(mobeffectlist).getDuration() < 1200) { - entityplayer.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.GUARDIAN_ELDER_EFFECT, this.isSilent() ? 0.0F : 1.0F)); + entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.GUARDIAN_ELDER_EFFECT, this.isSilent() ? 0.0F : 1.0F)); - entityplayer.addEffect(new MobEffect(mobeffectlist, 6000, 2), this); + entityplayer.addEffect(new MobEffect(mobeffectlist, 6000, 2), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch index d89713617b..a749b7a0e5 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch @@ -1,29 +1,20 @@ --- a/net/minecraft/world/entity/monster/EntityIllagerIllusioner.java +++ b/net/minecraft/world/entity/monster/EntityIllagerIllusioner.java -@@ -70,7 +70,7 @@ - this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D)); - this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.0F)); - this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F)); -- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a()); -+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a(new Class[0])); // CraftBukkit - decompile error - this.targetSelector.a(2, (new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)).a(300)); - this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, false)).a(300)); - this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, false)).a(300)); @@ -228,7 +228,7 @@ @Override - protected void j() { + protected void performSpellCasting() { - EntityIllagerIllusioner.this.addEffect(new MobEffect(MobEffects.INVISIBILITY, 1200)); + EntityIllagerIllusioner.this.addEffect(new MobEffect(MobEffects.INVISIBILITY, 1200), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ILLUSION); // CraftBukkit } @Nullable -@@ -274,7 +274,7 @@ +@@ -279,7 +279,7 @@ @Override - protected void j() { -- EntityIllagerIllusioner.this.getGoalTarget().addEffect(new MobEffect(MobEffects.BLINDNESS, 400), EntityIllagerIllusioner.this); -+ EntityIllagerIllusioner.this.getGoalTarget().addEffect(new MobEffect(MobEffects.BLINDNESS, 400), EntityIllagerIllusioner.this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit + protected void performSpellCasting() { +- EntityIllagerIllusioner.this.getTarget().addEffect(new MobEffect(MobEffects.BLINDNESS, 400), EntityIllagerIllusioner.this); ++ EntityIllagerIllusioner.this.getTarget().addEffect(new MobEffect(MobEffects.BLINDNESS, 400), EntityIllagerIllusioner.this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } @Override diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityIllagerWizard.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityIllagerWizard.patch index 95afeab3f7..00ed141491 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityIllagerWizard.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityIllagerWizard.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/monster/EntityIllagerWizard.java +++ b/net/minecraft/world/entity/monster/EntityIllagerWizard.java @@ -161,6 +161,11 @@ - public void e() { + public void tick() { --this.attackWarmupDelay; if (this.attackWarmupDelay == 0) { + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleEntitySpellCastEvent(EntityIllagerWizard.this, this.getCastSpell())) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleEntitySpellCastEvent(EntityIllagerWizard.this, this.getSpell())) { + return; + } + // CraftBukkit end - this.j(); - EntityIllagerWizard.this.playSound(EntityIllagerWizard.this.getSoundCastSpell(), 1.0F, 1.0F); + this.performSpellCasting(); + EntityIllagerWizard.this.playSound(EntityIllagerWizard.this.getCastingSoundEvent(), 1.0F, 1.0F); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch index fe9bab48bc..dad694faa5 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch @@ -1,11 +1,19 @@ --- a/net/minecraft/world/entity/monster/EntityPhantom.java +++ b/net/minecraft/world/entity/monster/EntityPhantom.java -@@ -529,7 +529,7 @@ +@@ -523,14 +523,14 @@ + List<EntityHuman> list = EntityPhantom.this.level.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(); - if (EntityPhantom.this.a((EntityLiving) entityhuman, PathfinderTargetCondition.DEFAULT)) { -- EntityPhantom.this.setGoalTarget(entityhuman); -+ EntityPhantom.this.setGoalTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit - reason + if (EntityPhantom.this.canAttack(entityhuman, PathfinderTargetCondition.DEFAULT)) { +- EntityPhantom.this.setTarget(entityhuman); ++ EntityPhantom.this.setTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit - reason return true; } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch index 0957d3bccd..06bc4e9b6c 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch @@ -1,53 +1,44 @@ --- a/net/minecraft/world/entity/monster/EntityPigZombie.java +++ b/net/minecraft/world/entity/monster/EntityPigZombie.java -@@ -71,7 +71,7 @@ - protected void n() { - this.goalSelector.a(2, new PathfinderGoalZombieAttack(this, 1.0D, false)); - this.goalSelector.a(7, new PathfinderGoalRandomStrollLand(this, 1.0D)); -- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a()); -+ this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this).a(new Class[0])); // CraftBukkit - decompile error - this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, 10, true, false, this::a_)); - this.targetSelector.a(3, new PathfinderGoalUniversalAngerReset<>(this, true)); - } -@@ -144,7 +144,7 @@ +@@ -145,7 +145,7 @@ }).filter((entitypigzombie) -> { - return !entitypigzombie.p(this.getGoalTarget()); + return !entitypigzombie.isAlliedTo((Entity) this.getTarget()); }).forEach((entitypigzombie) -> { -- entitypigzombie.setGoalTarget(this.getGoalTarget()); -+ entitypigzombie.setGoalTarget(this.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit +- entitypigzombie.setTarget(this.getTarget()); ++ entitypigzombie.setTarget(this.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit }); } -@@ -153,7 +153,7 @@ +@@ -154,7 +154,7 @@ } @Override -- public void setGoalTarget(@Nullable EntityLiving entityliving) { -+ public boolean setGoalTarget(@Nullable EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) { // CraftBukkit - signature - if (this.getGoalTarget() == null && entityliving != null) { - this.playFirstAngerSoundIn = EntityPigZombie.FIRST_ANGER_SOUND_DELAY.a(this.random); - this.ticksUntilNextAlert = EntityPigZombie.ALERT_INTERVAL.a(this.random); -@@ -163,12 +163,21 @@ - this.e((EntityHuman) entityliving); +- public void setTarget(@Nullable EntityLiving entityliving) { ++ public boolean setTarget(@Nullable EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) { // CraftBukkit - signature + if (this.getTarget() == null && entityliving != null) { + this.playFirstAngerSoundIn = EntityPigZombie.FIRST_ANGER_SOUND_DELAY.sample(this.random); + this.ticksUntilNextAlert = EntityPigZombie.ALERT_INTERVAL.sample(this.random); +@@ -164,12 +164,21 @@ + this.setLastHurtByPlayer((EntityHuman) entityliving); } -- super.setGoalTarget(entityliving); -+ return super.setGoalTarget(entityliving, reason, fireEvent); // CraftBukkit +- super.setTarget(entityliving); ++ return super.setTarget(entityliving, reason, fireEvent); // CraftBukkit } @Override - public void anger() { -- this.setAnger(EntityPigZombie.PERSISTENT_ANGER_TIME.a(this.random)); + public void startPersistentAngerTimer() { +- this.setRemainingPersistentAngerTime(EntityPigZombie.PERSISTENT_ANGER_TIME.sample(this.random)); + // CraftBukkit start -+ Entity entity = ((WorldServer) this.level).getEntity(getAngerTarget()); -+ org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entity == null) ? null : entity.getBukkitEntity(), EntityPigZombie.PERSISTENT_ANGER_TIME.a(this.random)); ++ Entity entity = ((WorldServer) this.level).getEntity(getPersistentAngerTarget()); ++ org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entity == null) ? null : entity.getBukkitEntity(), EntityPigZombie.PERSISTENT_ANGER_TIME.sample(this.random)); + this.level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { -+ this.setAngerTarget(null); ++ this.setPersistentAngerTarget(null); + return; + } -+ this.setAnger(event.getNewAnger()); ++ this.setRemainingPersistentAngerTime(event.getNewAnger()); + // CraftBukkit end } - public static boolean b(EntityTypes<EntityPigZombie> entitytypes, GeneratorAccess generatoraccess, EnumMobSpawn enummobspawn, BlockPosition blockposition, Random random) { + public static boolean checkZombifiedPiglinSpawnRules(EntityTypes<EntityPigZombie> entitytypes, GeneratorAccess generatoraccess, EnumMobSpawn enummobspawn, BlockPosition blockposition, Random random) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch deleted file mode 100644 index 9ab28efe50..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/entity/monster/EntityPillager.java -+++ b/net/minecraft/world/entity/monster/EntityPillager.java -@@ -75,7 +75,7 @@ - this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D)); - this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 15.0F, 1.0F)); - this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 15.0F)); -- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a()); -+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a(new Class[0])); // CraftBukkit - decompile error - this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); - this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, false)); - this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, true)); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch index 69301ac026..69cc476d84 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch @@ -1,20 +1,11 @@ --- a/net/minecraft/world/entity/monster/EntityRavager.java +++ b/net/minecraft/world/entity/monster/EntityRavager.java -@@ -78,7 +78,7 @@ - this.goalSelector.a(5, new PathfinderGoalRandomStrollLand(this, 0.4D)); - this.goalSelector.a(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F)); - this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F)); -- this.targetSelector.a(2, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a()); -+ this.targetSelector.a(2, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a(new Class[0])); // CraftBukkit - decompile error - this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); - this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, true)); - this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, true)); -@@ -169,7 +169,7 @@ - IBlockData iblockdata = this.level.getType(blockposition); +@@ -168,7 +168,7 @@ + IBlockData iblockdata = this.level.getBlockState(blockposition); Block block = iblockdata.getBlock(); - if (block instanceof BlockLeaves) { -+ if (block instanceof BlockLeaves && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, net.minecraft.world.level.block.Blocks.AIR.getBlockData()).isCancelled()) { // CraftBukkit - flag = this.level.a(blockposition, true, this) || flag; ++ if (block instanceof BlockLeaves && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState()).isCancelled()) { // CraftBukkit + flag = this.level.destroyBlock(blockposition, true, this) || flag; } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch index b0961e633d..181623efe1 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch @@ -13,17 +13,8 @@ public class EntityShulker extends EntityGolem implements IMonster { private static final UUID COVERED_ARMOR_MODIFIER_UUID = UUID.fromString("7E0292F2-9434-48D5-A29F-9583AF7DF27F"); -@@ -95,7 +101,7 @@ - this.goalSelector.a(4, new EntityShulker.a()); - this.goalSelector.a(7, new EntityShulker.f()); - this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); -- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{this.getClass()})).a()); -+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{this.getClass()})).a(new Class[0])); // CraftBukkit - decompile error - this.targetSelector.a(2, new EntityShulker.e(this)); - this.targetSelector.a(3, new EntityShulker.c(this)); - } @@ -405,6 +411,16 @@ - EnumDirection enumdirection = this.g(blockposition1); + EnumDirection enumdirection = this.findAttachableSurface(blockposition1); if (enumdirection != null) { + // CraftBukkit start @@ -36,15 +27,15 @@ + return false; + } + // CraftBukkit end - this.decouple(); + this.unRide(); this.setAttachFace(enumdirection); this.playSound(SoundEffects.SHULKER_TELEPORT, 1.0F, 1.0F); @@ -477,7 +493,7 @@ } - entityshulker.d(vec3d); -- this.level.addEntity(entityshulker); -+ this.level.addEntity(entityshulker, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - the mysteries of life + entityshulker.moveTo(vec3d); +- this.level.addFreshEntity(entityshulker); ++ this.level.addFreshEntity(entityshulker, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - the mysteries of life } } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch index 27207538d6..a67b811a1e 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch @@ -1,35 +1,26 @@ --- a/net/minecraft/world/entity/monster/EntitySilverfish.java +++ b/net/minecraft/world/entity/monster/EntitySilverfish.java -@@ -46,7 +46,7 @@ - this.goalSelector.a(3, this.friendsGoal); - this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, 1.0D, false)); - this.goalSelector.a(5, new EntitySilverfish.PathfinderGoalSilverfishHideInBlock(this)); -- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a()); -+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error - this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); - } - -@@ -171,6 +171,11 @@ +@@ -173,6 +173,11 @@ Block block = iblockdata.getBlock(); if (block instanceof BlockMonsterEggs) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1, net.minecraft.world.level.block.Blocks.AIR.getBlockData()).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState()).isCancelled()) { + continue; + } + // CraftBukkit end if (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { - world.a(blockposition1, true, this.silverfish); + world.destroyBlock(blockposition1, true, this.silverfish); } else { -@@ -239,6 +244,11 @@ - IBlockData iblockdata = world.getType(blockposition); +@@ -242,6 +247,11 @@ + IBlockData iblockdata = world.getBlockState(blockposition); - if (BlockMonsterEggs.h(iblockdata)) { + if (BlockMonsterEggs.isCompatibleHostBlock(iblockdata)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, BlockMonsterEggs.n(iblockdata)).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, BlockMonsterEggs.infestedStateByHost(iblockdata)).isCancelled()) { + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, BlockMonsterEggs.n(iblockdata), 3); - this.mob.doSpawnEffect(); - this.mob.die(); + world.setBlock(blockposition, BlockMonsterEggs.infestedStateByHost(iblockdata), 3); + this.mob.spawnAnim(); + this.mob.discard(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch index 55d842d3b4..e47e55a36c 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch @@ -3,9 +3,9 @@ @@ -86,7 +86,7 @@ } - protected void fy() { -- this.a(EntityTypes.STRAY, true); -+ this.a(EntityTypes.STRAY, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.FROZEN, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.FROZEN); // CraftBukkit - add spawn and transform reasons + protected void doFreezeConversion() { +- this.convertTo(EntityTypes.STRAY, true); ++ this.convertTo(EntityTypes.STRAY, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.FROZEN, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.FROZEN); // CraftBukkit - add spawn and transform reasons if (!this.isSilent()) { - this.level.a((EntityHuman) null, 1048, this.getChunkCoordinates(), 0); + this.level.levelEvent((EntityHuman) null, 1048, this.blockPosition(), 0); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch index bc09c257a5..4db4cf44f4 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java +++ b/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java -@@ -195,8 +195,19 @@ +@@ -194,8 +194,19 @@ double d3 = Math.sqrt(d0 * d0 + d2 * d2); - entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.level.getDifficulty().a() * 4)); + entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.level.getDifficulty().getId() * 4)); + // CraftBukkit start -+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getItemInMainHand(), null, entityarrow, net.minecraft.world.EnumHand.MAIN_HAND, 0.8F, true); ++ 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()) { + event.getProjectile().remove(); + return; + } + + if (event.getProjectile() == entityarrow.getBukkitEntity()) { -+ level.addEntity(entityarrow); ++ level.addFreshEntity(entityarrow); + } + // CraftBukkit end this.playSound(SoundEffects.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); -- this.level.addEntity(entityarrow); -+ // this.world.addEntity(entityarrow); // CraftBukkit - moved up +- this.level.addFreshEntity(entityarrow); ++ // this.level.addFreshEntity(entityarrow); // CraftBukkit - moved up } - protected EntityArrow b(ItemStack itemstack, float f) { + protected EntityArrow getArrow(ItemStack itemstack, float f) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch index 45066a8d77..9aff825e0e 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch @@ -14,13 +14,13 @@ + public class EntitySlime extends EntityInsentient implements IMonster { - private static final DataWatcherObject<Integer> ID_SIZE = DataWatcher.a(EntitySlime.class, DataWatcherRegistry.INT); + private static final DataWatcherObject<Integer> ID_SIZE = DataWatcher.defineId(EntitySlime.class, DataWatcherRegistry.INT); @@ -186,7 +194,7 @@ @Override - public EntityTypes<? extends EntitySlime> getEntityType() { -- return super.getEntityType(); -+ return (EntityTypes<? extends EntitySlime>) super.getEntityType(); // CraftBukkit - decompile error + public EntityTypes<? extends EntitySlime> getType() { +- return super.getType(); ++ return (EntityTypes<? extends EntitySlime>) super.getType(); // CraftBukkit - decompile error } @Override @@ -35,7 +35,7 @@ + if (!event.isCancelled() && event.getCount() > 0) { + k = event.getCount(); + } else { -+ super.a(entity_removalreason); ++ super.remove(entity_removalreason); + return; + } + List<EntityLiving> slimes = new ArrayList<>(j); @@ -47,20 +47,20 @@ @@ -214,8 +235,18 @@ entityslime.setInvulnerable(this.isInvulnerable()); entityslime.setSize(j, true); - entityslime.setPositionRotation(this.locX() + (double) f1, this.locY() + 0.5D, this.locZ() + (double) f2, this.random.nextFloat() * 360.0F, 0.0F); -- this.level.addEntity(entityslime); + entityslime.moveTo(this.getX() + (double) f1, this.getY() + 0.5D, this.getZ() + (double) f2, this.random.nextFloat() * 360.0F, 0.0F); +- this.level.addFreshEntity(entityslime); + slimes.add(entityslime); // CraftBukkit + } + + // CraftBukkit start + if (CraftEventFactory.callEntityTransformEvent(this, slimes, EntityTransformEvent.TransformReason.SPLIT).isCancelled()) { -+ super.a(entity_removalreason); ++ super.remove(entity_removalreason); + return; + } + for (EntityLiving living : slimes) { -+ this.level.addEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason ++ this.level.addFreshEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason } + // CraftBukkit end } - super.a(entity_removalreason); + super.remove(entity_removalreason); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch index 2239f229b8..040f9af7d5 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/entity/monster/EntityStrider.java +++ b/net/minecraft/world/entity/monster/EntityStrider.java @@ -321,7 +321,13 @@ - IBlockData iblockdata1 = this.aU(); - boolean flag = iblockdata.a((Tag) TagsBlock.STRIDER_WARM_BLOCKS) || iblockdata1.a((Tag) TagsBlock.STRIDER_WARM_BLOCKS) || this.b((Tag) TagsFluid.LAVA) > 0.0D; + IBlockData iblockdata1 = this.getBlockStateOn(); + boolean flag = iblockdata.is((Tag) TagsBlock.STRIDER_WARM_BLOCKS) || iblockdata1.is((Tag) TagsBlock.STRIDER_WARM_BLOCKS) || this.getFluidHeight(TagsFluid.LAVA) > 0.0D; -- this.setShivering(!flag); +- this.setSuffocating(!flag); + // CraftBukkit start -+ if (!flag ^ this.isShivering()) { ++ if (!flag ^ this.isSuffocating()) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callStriderTemperatureChangeEvent(this, !flag)) { -+ this.setShivering(!flag); ++ this.setSuffocating(!flag); + } + } + // CraftBukkit end super.tick(); - this.fE(); - this.checkBlockCollisions(); + this.floatStrider(); + this.checkInsideBlocks(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch index 3a46202cd3..573f6745c4 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch @@ -1,20 +1,11 @@ --- a/net/minecraft/world/entity/monster/EntityVex.java +++ b/net/minecraft/world/entity/monster/EntityVex.java -@@ -89,7 +89,7 @@ - this.goalSelector.a(8, new EntityVex.d()); - this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.0F)); - this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F)); -- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a()); -+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a(new Class[0])); // CraftBukkit - decompile error - this.targetSelector.a(2, new EntityVex.b(this)); - this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); - } -@@ -355,7 +355,7 @@ +@@ -368,7 +368,7 @@ @Override - public void c() { -- EntityVex.this.setGoalTarget(EntityVex.this.owner.getGoalTarget()); -+ EntityVex.this.setGoalTarget(EntityVex.this.owner.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit - super.c(); + public void start() { +- EntityVex.this.setTarget(EntityVex.this.owner.getTarget()); ++ EntityVex.this.setTarget(EntityVex.this.owner.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit + super.start(); } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch index e1ca8f1a91..d82ea1e0c1 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityWitch.java +++ b/net/minecraft/world/entity/monster/EntityWitch.java -@@ -132,7 +132,7 @@ +@@ -131,7 +131,7 @@ while (iterator.hasNext()) { MobEffect mobeffect = (MobEffect) iterator.next(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch index 9c329e17dc..009db0ab8a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch +++ b/paper-server/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 -@@ -70,6 +70,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 UUID SPEED_MODIFIER_BABY_UUID = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); -@@ -89,6 +98,7 @@ +@@ -85,6 +94,7 @@ private boolean canBreakDoors; private int inWaterTime; public int conversionTime; @@ -24,19 +24,19 @@ public EntityZombie(EntityTypes<? extends EntityZombie> entitytypes, World world) { super(entitytypes, world); -@@ -205,7 +215,10 @@ +@@ -201,7 +211,10 @@ public void tick() { - if (!this.level.isClientSide && this.isAlive() && !this.isNoAI()) { - if (this.isDrownConverting()) { + if (!this.level.isClientSide && this.isAlive() && !this.isNoAi()) { + if (this.isUnderWaterConverting()) { - --this.conversionTime; + // CraftBukkit start - Use wall time instead of ticks for conversion + int elapsedTicks = MinecraftServer.currentTick - this.lastTick; + this.conversionTime -= elapsedTicks; + // CraftBukkit end if (this.conversionTime < 0) { - this.fz(); + this.doUnderWaterConversion(); } -@@ -222,6 +235,7 @@ +@@ -218,6 +231,7 @@ } super.tick(); @@ -44,24 +44,24 @@ } @Override -@@ -254,6 +268,7 @@ +@@ -250,6 +264,7 @@ } - public void startDrownedConversion(int i) { + public void startUnderWaterConversion(int i) { + this.lastTick = MinecraftServer.currentTick; // CraftBukkit this.conversionTime = i; - this.getDataWatcher().set(EntityZombie.DATA_DROWNED_CONVERSION_ID, true); + this.getEntityData().set(EntityZombie.DATA_DROWNED_CONVERSION_ID, true); } -@@ -267,11 +282,15 @@ +@@ -263,11 +278,15 @@ } - protected void b(EntityTypes<? extends EntityZombie> entitytypes) { -- EntityZombie entityzombie = (EntityZombie) this.a(entitytypes, true); -+ EntityZombie entityzombie = (EntityZombie) this.a(entitytypes, true, EntityTransformEvent.TransformReason.DROWNED, CreatureSpawnEvent.SpawnReason.DROWNED); + protected void convertToZombieType(EntityTypes<? extends EntityZombie> entitytypes) { +- EntityZombie entityzombie = (EntityZombie) this.convertTo(entitytypes, true); ++ EntityZombie entityzombie = (EntityZombie) this.convertTo(entitytypes, true, EntityTransformEvent.TransformReason.DROWNED, CreatureSpawnEvent.SpawnReason.DROWNED); if (entityzombie != null) { - entityzombie.z(entityzombie.level.getDamageScaler(entityzombie.getChunkCoordinates()).d()); - entityzombie.w(entityzombie.p() && this.fE()); + entityzombie.handleAttributes(entityzombie.level.getCurrentDifficultyAt(entityzombie.blockPosition()).getSpecialMultiplier()); + entityzombie.setCanBreakDoors(entityzombie.supportsBreakDoorGoal() && this.canBreakDoors()); + // CraftBukkit start - SPIGOT-5208: End conversion to stop event spam + } else { + ((Zombie) getBukkitEntity()).setConversionTime(-1); @@ -69,54 +69,54 @@ } } -@@ -311,9 +330,9 @@ - if (SpawnerCreature.a(entitypositiontypes_surface, (IWorldReader) this.level, blockposition, entitytypes) && EntityPositionTypes.a(entitytypes, worldserver, EnumMobSpawn.REINFORCEMENT, blockposition, this.level.random)) { - entityzombie.setPosition((double) i1, (double) j1, (double) k1); - if (!this.level.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.level.f((Entity) entityzombie) && this.level.getCubes(entityzombie) && !this.level.containsLiquid(entityzombie.getBoundingBox())) { -- entityzombie.setGoalTarget(entityliving); -+ entityzombie.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit - entityzombie.prepare(worldserver, this.level.getDamageScaler(entityzombie.getChunkCoordinates()), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (NBTTagCompound) null); -- worldserver.addAllEntities(entityzombie); -+ worldserver.addAllEntities(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit - this.getAttributeInstance(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE).addModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); - entityzombie.getAttributeInstance(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE).addModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); +@@ -307,9 +326,9 @@ + if (SpawnerCreature.isSpawnPositionOk(entitypositiontypes_surface, this.level, blockposition, entitytypes) && EntityPositionTypes.checkSpawnRules(entitytypes, worldserver, EnumMobSpawn.REINFORCEMENT, blockposition, this.level.random)) { + entityzombie.setPos((double) i1, (double) j1, (double) k1); + if (!this.level.hasNearbyAlivePlayer((double) i1, (double) j1, (double) k1, 7.0D) && this.level.isUnobstructed(entityzombie) && this.level.noCollision((Entity) entityzombie) && !this.level.containsAnyLiquid(entityzombie.getBoundingBox())) { +- entityzombie.setTarget(entityliving); ++ entityzombie.setTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit + entityzombie.finalizeSpawn(worldserver, this.level.getCurrentDifficultyAt(entityzombie.blockPosition()), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (NBTTagCompound) null); +- worldserver.addFreshEntityWithPassengers(entityzombie); ++ worldserver.addFreshEntityWithPassengers(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit + this.getAttribute(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE).addPermanentModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); + entityzombie.getAttribute(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE).addPermanentModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); break; -@@ -334,7 +353,14 @@ - float f = this.level.getDamageScaler(this.getChunkCoordinates()).b(); +@@ -330,7 +349,14 @@ + float f = this.level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); - if (this.getItemInMainHand().isEmpty() && this.isBurning() && this.random.nextFloat() < f * 0.3F) { -- entity.setOnFire(2 * (int) f); + if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < f * 0.3F) { +- entity.setSecondsOnFire(2 * (int) f); + // CraftBukkit start + EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 2 * (int) f); // PAIL: fixme + this.level.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ entity.setOnFire(event.getDuration(), false); ++ entity.setSecondsOnFire(event.getDuration(), false); + } + // CraftBukkit end } } -@@ -415,7 +441,12 @@ +@@ -411,7 +437,12 @@ } EntityVillager entityvillager = (EntityVillager) entityliving; -- EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.a(EntityTypes.ZOMBIE_VILLAGER, false); +- EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false); + // CraftBukkit start -+ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.a(EntityTypes.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, CreatureSpawnEvent.SpawnReason.INFECTION); ++ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, CreatureSpawnEvent.SpawnReason.INFECTION); + if (entityzombievillager == null) { + return; + } + // CraftBukkit end - entityzombievillager.prepare(worldserver, worldserver.getDamageScaler(entityzombievillager.getChunkCoordinates()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true), (NBTTagCompound) null); + entityzombievillager.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombievillager.blockPosition()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true), (NBTTagCompound) null); entityzombievillager.setVillagerData(entityvillager.getVillagerData()); -@@ -477,7 +508,7 @@ - entitychicken1.prepare(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null); +@@ -473,7 +504,7 @@ + entitychicken1.finalizeSpawn(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null); entitychicken1.setChickenJockey(true); this.startRiding(entitychicken1); -- worldaccess.addEntity(entitychicken1); -+ worldaccess.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit +- worldaccess.addFreshEntity(entitychicken1); ++ worldaccess.addFreshEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit } } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombieHusk.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombieHusk.patch index 773810d5ce..00fdf04cfb 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombieHusk.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombieHusk.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/monster/EntityZombieHusk.java +++ b/net/minecraft/world/entity/monster/EntityZombieHusk.java @@ -58,7 +58,7 @@ - if (flag && this.getItemInMainHand().isEmpty() && entity instanceof EntityLiving) { - float f = this.level.getDamageScaler(this.getChunkCoordinates()).b(); + if (flag && this.getMainHandItem().isEmpty() && entity instanceof EntityLiving) { + float f = this.level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); - ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.HUNGER, 140 * (int) f), this); + ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.HUNGER, 140 * (int) f), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch index ef79f7d969..16481f2369 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityZombieVillager.java +++ b/net/minecraft/world/entity/monster/EntityZombieVillager.java -@@ -49,6 +49,13 @@ +@@ -47,6 +47,13 @@ import net.minecraft.world.level.gameevent.GameEvent; import org.apache.logging.log4j.Logger; @@ -13,25 +13,25 @@ + public class EntityZombieVillager extends EntityZombie implements VillagerDataHolder { - public static final DataWatcherObject<Boolean> DATA_CONVERTING_ID = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.BOOLEAN); -@@ -62,6 +69,7 @@ - private NBTBase gossips; + public static final DataWatcherObject<Boolean> DATA_CONVERTING_ID = DataWatcher.defineId(EntityZombieVillager.class, DataWatcherRegistry.BOOLEAN); +@@ -63,6 +70,7 @@ + @Nullable private NBTTagCompound tradeOffers; private int villagerXp; + private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field public EntityZombieVillager(EntityTypes<? extends EntityZombieVillager> entitytypes, World world) { super(entitytypes, world); -@@ -78,7 +86,7 @@ +@@ -79,7 +87,7 @@ @Override - public void saveData(NBTTagCompound nbttagcompound) { - super.saveData(nbttagcompound); + public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { + super.addAdditionalSaveData(nbttagcompound); - DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); + DataResult<NBTBase> dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); // CraftBukkit - decompile error Logger logger = EntityZombieVillager.LOGGER; Objects.requireNonNull(logger); -@@ -134,6 +142,10 @@ +@@ -135,6 +143,10 @@ public void tick() { if (!this.level.isClientSide && this.isAlive() && this.isConverting()) { int i = this.getConversionProgress(); @@ -42,7 +42,7 @@ this.villagerConversionTime -= i; if (this.villagerConversionTime <= 0) { -@@ -142,6 +154,7 @@ +@@ -143,6 +155,7 @@ } super.tick(); @@ -50,27 +50,27 @@ } @Override -@@ -186,8 +199,11 @@ +@@ -187,8 +200,11 @@ this.conversionStarter = uuid; this.villagerConversionTime = i; - this.getDataWatcher().set(EntityZombieVillager.DATA_CONVERTING_ID, true); + 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().a() - 1, 0))); +- this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level.getDifficulty().getId() - 1, 0))); + // CraftBukkit start + this.setPersistenceRequired(true); // CraftBukkit - SPIGOT-4684 update persistence + this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); -+ this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level.getDifficulty().a() - 1, 0)), 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); + // CraftBukkit end - this.level.broadcastEntityEffect(this, (byte) 16); + this.level.broadcastEntityEvent(this, (byte) 16); } -@@ -204,7 +220,13 @@ +@@ -205,7 +221,13 @@ } - private void c(WorldServer worldserver) { -- EntityVillager entityvillager = (EntityVillager) this.a(EntityTypes.VILLAGER, false); + private void finishConversion(WorldServer worldserver) { +- EntityVillager entityvillager = (EntityVillager) this.convertTo(EntityTypes.VILLAGER, false); + // CraftBukkit start -+ EntityVillager entityvillager = (EntityVillager) this.a(EntityTypes.VILLAGER, false, EntityTransformEvent.TransformReason.CURED, CreatureSpawnEvent.SpawnReason.CURED); ++ EntityVillager entityvillager = (EntityVillager) this.convertTo(EntityTypes.VILLAGER, false, EntityTransformEvent.TransformReason.CURED, CreatureSpawnEvent.SpawnReason.CURED); + if (entityvillager == null) { + ((ZombieVillager) getBukkitEntity()).setConversionTime(-1); // SPIGOT-5208: End conversion to stop event spam + return; @@ -79,22 +79,22 @@ EnumItemSlot[] aenumitemslot = EnumItemSlot.values(); int i = aenumitemslot.length; -@@ -219,7 +241,9 @@ - double d0 = (double) this.e(enumitemslot); +@@ -220,7 +242,9 @@ + double d0 = (double) this.getEquipmentDropChance(enumitemslot); if (d0 > 1.0D) { + this.forceDrops = true; // CraftBukkit - this.b(itemstack); + this.spawnAtLocation(itemstack); + this.forceDrops = false; // CraftBukkit } } } -@@ -245,7 +269,7 @@ +@@ -246,7 +270,7 @@ } } - entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0)); + entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit if (!this.isSilent()) { - worldserver.a((EntityHuman) null, 1027, this.getChunkCoordinates(), 0); + worldserver.levelEvent((EntityHuman) null, 1027, this.blockPosition(), 0); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch index ea2f76decd..c4e4681c8e 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/EntityPiglin.java +++ b/net/minecraft/world/entity/monster/piglin/EntityPiglin.java -@@ -56,6 +56,18 @@ +@@ -55,6 +55,18 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; @@ -18,8 +18,8 @@ + public class EntityPiglin extends EntityPiglinAbstract implements ICrossbow, InventoryCarrier { - private static final DataWatcherObject<Boolean> DATA_BABY_ID = DataWatcher.a(EntityPiglin.class, DataWatcherRegistry.BOOLEAN); -@@ -76,6 +88,10 @@ + private static final DataWatcherObject<Boolean> DATA_BABY_ID = DataWatcher.defineId(EntityPiglin.class, DataWatcherRegistry.BOOLEAN); +@@ -75,6 +87,10 @@ public boolean cannotHunt; protected static final ImmutableList<SensorType<? extends Sensor<? super EntityPiglin>>> 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<MemoryModuleType<?>> 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.HURT_BY, MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.WALK_TARGET, new MemoryModuleType[]{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}); @@ -30,76 +30,67 @@ public EntityPiglin(EntityTypes<? extends EntityPiglinAbstract> entitytypes, World world) { super(entitytypes, world); -@@ -94,6 +110,14 @@ +@@ -93,6 +109,14 @@ } - nbttagcompound.set("Inventory", this.inventory.g()); + nbttagcompound.put("Inventory", this.inventory.createTag()); + // CraftBukkit start + NBTTagList barterList = new NBTTagList(); -+ allowedBarterItems.stream().map(IRegistry.ITEM::getKey).map(MinecraftKey::toString).map(NBTTagString::a).forEach(barterList::add); -+ nbttagcompound.set("Bukkit.BarterList", barterList); ++ allowedBarterItems.stream().map(IRegistry.ITEM::getKey).map(MinecraftKey::toString).map(NBTTagString::valueOf).forEach(barterList::add); ++ nbttagcompound.put("Bukkit.BarterList", barterList); + NBTTagList interestList = new NBTTagList(); -+ interestItems.stream().map(IRegistry.ITEM::getKey).map(MinecraftKey::toString).map(NBTTagString::a).forEach(interestList::add); -+ nbttagcompound.set("Bukkit.InterestList", interestList); ++ interestItems.stream().map(IRegistry.ITEM::getKey).map(MinecraftKey::toString).map(NBTTagString::valueOf).forEach(interestList::add); ++ nbttagcompound.put("Bukkit.InterestList", interestList); + // CraftBukkit end } @Override -@@ -102,6 +126,10 @@ +@@ -101,6 +125,10 @@ this.setBaby(nbttagcompound.getBoolean("IsBaby")); - this.x(nbttagcompound.getBoolean("CannotHunt")); - this.inventory.a(nbttagcompound.getList("Inventory", 10)); + this.setCannotHunt(nbttagcompound.getBoolean("CannotHunt")); + this.inventory.fromTag(nbttagcompound.getList("Inventory", 10)); + // CraftBukkit start -+ this.allowedBarterItems = nbttagcompound.getList("Bukkit.BarterList", 8).stream().map(NBTBase::asString).map(MinecraftKey::a).map(IRegistry.ITEM::get).collect(Collectors.toCollection(HashSet::new)); -+ this.interestItems = nbttagcompound.getList("Bukkit.InterestList", 8).stream().map(NBTBase::asString).map(MinecraftKey::a).map(IRegistry.ITEM::get).collect(Collectors.toCollection(HashSet::new)); ++ this.allowedBarterItems = nbttagcompound.getList("Bukkit.BarterList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(IRegistry.ITEM::get).collect(Collectors.toCollection(HashSet::new)); ++ this.interestItems = nbttagcompound.getList("Bukkit.InterestList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(IRegistry.ITEM::get).collect(Collectors.toCollection(HashSet::new)); + // CraftBukkit end } @VisibleForDebug -@@ -206,7 +234,7 @@ +@@ -205,7 +233,7 @@ @Override - public BehaviorController<EntityPiglin> getBehaviorController() { -- return super.getBehaviorController(); -+ return (BehaviorController<EntityPiglin>) super.getBehaviorController(); // CraftBukkit - Decompile error + public BehaviorController<EntityPiglin> getBrain() { +- return super.getBrain(); ++ return (BehaviorController<EntityPiglin>) super.getBrain(); // CraftBukkit - Decompile error } @Override -@@ -265,7 +293,7 @@ - @Override - protected void mobTick() { - this.level.getMethodProfiler().enter("piglinBrain"); -- this.getBehaviorController().a((WorldServer) this.level, (EntityLiving) this); -+ this.getBehaviorController().a((WorldServer) this.level, (EntityPiglin) this); // CraftBukkit - decompile error - this.level.getMethodProfiler().exit(); - PiglinAI.b(this); - super.mobTick(); -@@ -349,7 +377,7 @@ +@@ -348,7 +376,7 @@ } - protected void p(ItemStack itemstack) { -- if (itemstack.a(PiglinAI.BARTERING_ITEM)) { -+ if (itemstack.a(PiglinAI.BARTERING_ITEM) || allowedBarterItems.contains(itemstack.getItem())) { // CraftBukkit - Changes to accept custom payment items - this.setSlot(EnumItemSlot.OFFHAND, itemstack); - this.d(EnumItemSlot.OFFHAND); + protected void holdInOffHand(ItemStack itemstack) { +- if (itemstack.is(PiglinAI.BARTERING_ITEM)) { ++ if (itemstack.is(PiglinAI.BARTERING_ITEM) || allowedBarterItems.contains(itemstack.getItem())) { // CraftBukkit - Changes to accept custom payment items + this.setItemSlot(EnumItemSlot.OFFHAND, itemstack); + this.setGuaranteedDrop(EnumItemSlot.OFFHAND); } else { -@@ -375,8 +403,8 @@ - if (EnchantmentManager.d(itemstack1)) { +@@ -374,8 +402,8 @@ + if (EnchantmentManager.hasBindingCurse(itemstack1)) { return false; } else { -- boolean flag = PiglinAI.a(itemstack) || itemstack.a(Items.CROSSBOW); -- boolean flag1 = PiglinAI.a(itemstack1) || itemstack1.a(Items.CROSSBOW); -+ boolean flag = PiglinAI.isLovedByPiglin(itemstack, this) || itemstack.a(Items.CROSSBOW); // CraftBukkit -+ boolean flag1 = PiglinAI.isLovedByPiglin(itemstack1, this) || itemstack1.a(Items.CROSSBOW); // CraftBukkit +- boolean flag = PiglinAI.isLovedItem(itemstack) || itemstack.is(Items.CROSSBOW); +- boolean flag1 = PiglinAI.isLovedItem(itemstack1) || itemstack1.is(Items.CROSSBOW); ++ boolean flag = PiglinAI.isLovedItem(itemstack, this) || itemstack.is(Items.CROSSBOW); // CraftBukkit ++ boolean flag1 = PiglinAI.isLovedItem(itemstack1, this) || itemstack1.is(Items.CROSSBOW); // CraftBukkit - return flag && !flag1 ? true : (!flag && flag1 ? false : (this.fw() && !itemstack.a(Items.CROSSBOW) && itemstack1.a(Items.CROSSBOW) ? false : super.a(itemstack, itemstack1))); + return flag && !flag1 ? true : (!flag && flag1 ? false : (this.isAdult() && !itemstack.is(Items.CROSSBOW) && itemstack1.is(Items.CROSSBOW) ? false : super.canReplaceCurrentItem(itemstack, itemstack1))); } -@@ -405,7 +433,7 @@ +@@ -404,7 +432,7 @@ @Override - protected SoundEffect getSoundAmbient() { -- return this.level.isClientSide ? null : (SoundEffect) PiglinAI.d(this).orElse((Object) null); -+ return this.level.isClientSide ? null : (SoundEffect) PiglinAI.d(this).orElse(null); // CraftBukkit - Decompile error + protected SoundEffect getAmbientSound() { +- return this.level.isClientSide ? null : (SoundEffect) PiglinAI.getSoundForCurrentActivity(this).orElse((Object) null); ++ return this.level.isClientSide ? null : (SoundEffect) PiglinAI.getSoundForCurrentActivity(this).orElse(null); // CraftBukkit - Decompile error } @Override diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.patch index 96777935b5..d362955d5a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.patch @@ -3,18 +3,18 @@ @@ -100,7 +100,7 @@ } - protected void c(WorldServer worldserver) { -- EntityPigZombie entitypigzombie = (EntityPigZombie) this.a(EntityTypes.ZOMBIFIED_PIGLIN, true); -+ EntityPigZombie entitypigzombie = (EntityPigZombie) this.a(EntityTypes.ZOMBIFIED_PIGLIN, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED); // CraftBukkit - add spawn and transform reasons + protected void finishConversion(WorldServer worldserver) { +- EntityPigZombie entitypigzombie = (EntityPigZombie) this.convertTo(EntityTypes.ZOMBIFIED_PIGLIN, true); ++ EntityPigZombie entitypigzombie = (EntityPigZombie) this.convertTo(EntityTypes.ZOMBIFIED_PIGLIN, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED); // CraftBukkit - add spawn and transform reasons if (entitypigzombie != null) { entitypigzombie.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0)); @@ -117,7 +117,7 @@ @Nullable @Override - public EntityLiving getGoalTarget() { + public EntityLiving getTarget() { - return (EntityLiving) this.brain.getMemory(MemoryModuleType.ATTACK_TARGET).orElse((Object) null); + return (EntityLiving) this.brain.getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null); // CraftBukkit - decompile error } - protected boolean fy() { + protected boolean isHoldingMeleeWeapon() { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch index 19afcd90db..e668bee77d 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch +++ b/paper-server/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 -@@ -73,6 +73,13 @@ +@@ -72,6 +72,13 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParameters; import net.minecraft.world.phys.Vec3D; @@ -14,179 +14,131 @@ public class PiglinAI { public static final int REPELLENT_DETECTION_RANGE_HORIZONTAL = 8; -@@ -145,7 +152,8 @@ - private static void b(EntityPiglin entitypiglin, BehaviorController<EntityPiglin> behaviorcontroller) { - behaviorcontroller.a(Activity.FIGHT, 10, ImmutableList.of(new BehaviorAttackTargetForget<>((entityliving) -> { - return !b(entitypiglin, entityliving); -- }), new BehaviorRunIf<>(PiglinAI::c, new BehaviorRetreat<>(5, 0.75F)), new BehaviorWalkAwayOutOfRange(1.0F), new BehaviorAttack(20), new BehaviorCrossbowAttack<>(), new BehaviorRememberHuntedHoglin<>(), new BehaviorRemoveMemory<>(PiglinAI::j, MemoryModuleType.ATTACK_TARGET)), MemoryModuleType.ATTACK_TARGET); -+ // CraftBukkit - decompile error -+ }), new BehaviorRunIf<>((l) -> PiglinAI.c((EntityLiving) l), new BehaviorRetreat<>(5, 0.75F)), new BehaviorWalkAwayOutOfRange(1.0F), new BehaviorAttack(20), new BehaviorCrossbowAttack<>(), new BehaviorRememberHuntedHoglin<>(), new BehaviorRemoveMemory<>(PiglinAI::j, MemoryModuleType.ATTACK_TARGET)), MemoryModuleType.ATTACK_TARGET); - } +@@ -187,13 +194,13 @@ - private static void c(BehaviorController<EntityPiglin> behaviorcontroller) { -@@ -163,7 +171,8 @@ - } + protected static void updateActivity(EntityPiglin entitypiglin) { + BehaviorController<EntityPiglin> behaviorcontroller = entitypiglin.getBrain(); +- Activity activity = (Activity) behaviorcontroller.getActiveNonCoreActivity().orElse((Object) null); ++ Activity activity = (Activity) behaviorcontroller.getActiveNonCoreActivity().orElse(null); // CraftBukkit - decompile error - private static void f(BehaviorController<EntityPiglin> behaviorcontroller) { -- behaviorcontroller.a(Activity.RIDE, 10, ImmutableList.of(new BehaviorStartRiding<>(0.8F), new BehaviorLookTarget(PiglinAI::b, 8.0F), new BehaviorRunIf<>(Entity::isPassenger, a()), new BehaviorStopRiding<>(8, PiglinAI::a)), MemoryModuleType.RIDE_TARGET); -+ // CraftBukkit - decompile error -+ behaviorcontroller.a(Activity.RIDE, 10, ImmutableList.of(new BehaviorStartRiding<>(0.8F), new BehaviorLookTarget(PiglinAI::b, 8.0F), new BehaviorRunIf<>(Entity::isPassenger, a()), new BehaviorStopRiding<EntityPiglin, Entity>(8, PiglinAI::a)), MemoryModuleType.RIDE_TARGET); - } - - private static BehaviorGateSingle<EntityPiglin> a() { -@@ -171,7 +180,8 @@ - } - - private static BehaviorGateSingle<EntityPiglin> b() { -- return new BehaviorGateSingle<>(ImmutableList.of(Pair.of(new BehaviorStrollRandomUnconstrained(0.6F), 2), Pair.of(BehaviorInteract.a(EntityTypes.PIGLIN, 8, MemoryModuleType.INTERACTION_TARGET, 0.6F, 2), 2), Pair.of(new BehaviorRunIf<>(PiglinAI::f, new BehaviorLookWalk(0.6F, 3)), 2), Pair.of(new BehaviorNop(30, 60), 1))); -+ // CraftBukkit - decompile error -+ return new BehaviorGateSingle<>(ImmutableList.of(Pair.of(new BehaviorStrollRandomUnconstrained(0.6F), 2), Pair.of(BehaviorInteract.a(EntityTypes.PIGLIN, 8, MemoryModuleType.INTERACTION_TARGET, 0.6F, 2), 2), Pair.of(new BehaviorRunIf<>((java.util.function.Predicate<EntityLiving>) PiglinAI::f, new BehaviorLookWalk(0.6F, 3)), 2), Pair.of(new BehaviorNop(30, 60), 1))); - } - - private static BehaviorWalkAway<BlockPosition> c() { -@@ -188,13 +198,13 @@ - - protected static void b(EntityPiglin entitypiglin) { - BehaviorController<EntityPiglin> behaviorcontroller = entitypiglin.getBehaviorController(); -- Activity activity = (Activity) behaviorcontroller.f().orElse((Object) null); -+ Activity activity = (Activity) behaviorcontroller.f().orElse(null); // CraftBukkit - decompile error - - behaviorcontroller.a((List) ImmutableList.of(Activity.ADMIRE_ITEM, Activity.FIGHT, Activity.AVOID, Activity.CELEBRATE, Activity.RIDE, Activity.IDLE)); -- Activity activity1 = (Activity) behaviorcontroller.f().orElse((Object) null); -+ Activity activity1 = (Activity) behaviorcontroller.f().orElse(null); // CraftBukkit - decompile error + behaviorcontroller.setActiveActivityToFirstValid(ImmutableList.of(Activity.ADMIRE_ITEM, Activity.FIGHT, Activity.AVOID, Activity.CELEBRATE, Activity.RIDE, Activity.IDLE)); +- Activity activity1 = (Activity) behaviorcontroller.getActiveNonCoreActivity().orElse((Object) null); ++ Activity activity1 = (Activity) behaviorcontroller.getActiveNonCoreActivity().orElse(null); // CraftBukkit - decompile error if (activity != activity1) { -- Optional optional = d(entitypiglin); -+ Optional<SoundEffect> optional = d(entitypiglin); // CraftBukkit - decompile error +- Optional optional = getSoundForCurrentActivity(entitypiglin); ++ Optional<SoundEffect> optional = getSoundForCurrentActivity(entitypiglin); // CraftBukkit - decompile error Objects.requireNonNull(entitypiglin); - optional.ifPresent(entitypiglin::a); -@@ -226,23 +236,27 @@ - n(entitypiglin); + optional.ifPresent(entitypiglin::playSound); +@@ -225,23 +232,27 @@ + stopWalking(entitypiglin); ItemStack itemstack; -- if (entityitem.getItemStack().a(Items.GOLD_NUGGET)) { +- if (entityitem.getItem().is(Items.GOLD_NUGGET)) { + // CraftBukkit start -+ if (entityitem.getItemStack().a(Items.GOLD_NUGGET) && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(entitypiglin, entityitem, 0, false).isCancelled()) { - entitypiglin.receive(entityitem, entityitem.getItemStack().getCount()); - itemstack = entityitem.getItemStack(); - entityitem.die(); ++ if (entityitem.getItem().is(Items.GOLD_NUGGET) && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(entitypiglin, entityitem, 0, false).isCancelled()) { + entitypiglin.take(entityitem, entityitem.getItem().getCount()); + itemstack = entityitem.getItem(); + entityitem.discard(); - } else { -+ } else if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(entitypiglin, entityitem, entityitem.getItemStack().getCount() - 1, false).isCancelled()) { - entitypiglin.receive(entityitem, 1); - itemstack = a(entityitem); ++ } else if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(entitypiglin, entityitem, entityitem.getItem().getCount() - 1, false).isCancelled()) { + entitypiglin.take(entityitem, 1); + itemstack = removeOneItemFromItemEntity(entityitem); + } else { + return; } + // CraftBukkit end -- if (a(itemstack)) { -+ if (isLovedByPiglin(itemstack, entitypiglin)) { // CraftBukkit - Changes to allow for custom payment in bartering - entitypiglin.getBehaviorController().removeMemory(MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM); - c(entitypiglin, itemstack); - d((EntityLiving) entitypiglin); - } else if (c(itemstack) && !u(entitypiglin)) { - s(entitypiglin); +- if (isLovedItem(itemstack)) { ++ if (isLovedItem(itemstack, entitypiglin)) { // CraftBukkit - Changes to allow for custom payment in bartering + entitypiglin.getBrain().eraseMemory(MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM); + holdInOffhand(entitypiglin, itemstack); + admireGoldItem(entitypiglin); + } else if (isFood(itemstack) && !hasEatenRecently(entitypiglin)) { + eat(entitypiglin); } else { -- boolean flag = entitypiglin.j(itemstack); -+ boolean flag = entitypiglin.j(itemstack, entityitem); // CraftBukkit +- boolean flag = entitypiglin.equipItemIfPossible(itemstack); ++ boolean flag = entitypiglin.equipItemIfPossible(itemstack, entityitem); // CraftBukkit if (!flag) { - d(entitypiglin, itemstack); -@@ -278,9 +292,14 @@ + putInInventory(entitypiglin, itemstack); +@@ -277,9 +288,14 @@ boolean flag1; - if (entitypiglin.fw()) { -- flag1 = b(itemstack); -+ flag1 = isBarterItem(itemstack, entitypiglin); // CraftBukkit - Changes to allow custom payment for bartering + if (entitypiglin.isAdult()) { +- flag1 = isBarterCurrency(itemstack); ++ flag1 = isBarterCurrency(itemstack, entitypiglin); // CraftBukkit - Changes to allow custom payment for bartering if (flag && flag1) { -- a(entitypiglin, i(entitypiglin)); +- throwItems(entitypiglin, getBarterResponseItems(entitypiglin)); + // CraftBukkit start -+ PiglinBarterEvent event = CraftEventFactory.callPiglinBarterEvent(entitypiglin, i(entitypiglin), itemstack); ++ PiglinBarterEvent event = CraftEventFactory.callPiglinBarterEvent(entitypiglin, getBarterResponseItems(entitypiglin), itemstack); + if (!event.isCancelled()) { -+ a(entitypiglin, event.getOutcome().stream().map(CraftItemStack::asNMSCopy).collect(Collectors.toList())); ++ throwItems(entitypiglin, event.getOutcome().stream().map(CraftItemStack::asNMSCopy).collect(Collectors.toList())); + } + // CraftBukkit end } else if (!flag1) { - boolean flag2 = entitypiglin.j(itemstack); + boolean flag2 = entitypiglin.equipItemIfPossible(itemstack); -@@ -293,7 +312,7 @@ +@@ -292,7 +308,7 @@ if (!flag1) { - ItemStack itemstack1 = entitypiglin.getItemInMainHand(); + ItemStack itemstack1 = entitypiglin.getMainHandItem(); -- if (a(itemstack1)) { -+ if (isLovedByPiglin(itemstack1, entitypiglin)) { // CraftBukkit - Changes to allow for custom payment in bartering - d(entitypiglin, itemstack1); +- if (isLovedItem(itemstack1)) { ++ if (isLovedItem(itemstack1, entitypiglin)) { // CraftBukkit - Changes to allow for custom payment in bartering + putInInventory(entitypiglin, itemstack1); } else { - a(entitypiglin, Collections.singletonList(itemstack1)); -@@ -370,7 +389,7 @@ + throwItems(entitypiglin, Collections.singletonList(itemstack1)); +@@ -369,7 +385,7 @@ return false; - } else if (x(entitypiglin) && entitypiglin.getBehaviorController().hasMemory(MemoryModuleType.ATTACK_TARGET)) { + } else if (isAdmiringDisabled(entitypiglin) && entitypiglin.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET)) { return false; -- } else if (b(itemstack)) { -+ } else if (isBarterItem(itemstack, entitypiglin)) { // CraftBukkit - return z(entitypiglin); +- } else if (isBarterCurrency(itemstack)) { ++ } else if (isBarterCurrency(itemstack, entitypiglin)) { // CraftBukkit + return isNotHoldingLovedItemInOffHand(entitypiglin); } else { - boolean flag = entitypiglin.n(itemstack); -@@ -379,6 +398,12 @@ + boolean flag = entitypiglin.canAddToInventory(itemstack); +@@ -378,6 +394,12 @@ } } + // CraftBukkit start - Added method to allow checking for custom payment items -+ protected static boolean isLovedByPiglin(ItemStack itemstack, EntityPiglin piglin) { -+ return a(itemstack) || (piglin.interestItems.contains(itemstack.getItem()) || piglin.allowedBarterItems.contains(itemstack.getItem())); ++ protected static boolean isLovedItem(ItemStack itemstack, EntityPiglin piglin) { ++ return isLovedItem(itemstack) || (piglin.interestItems.contains(itemstack.getItem()) || piglin.allowedBarterItems.contains(itemstack.getItem())); + } + // CraftBukkit end + - protected static boolean a(ItemStack itemstack) { - return itemstack.a((Tag) TagsItem.PIGLIN_LOVED); + protected static boolean isLovedItem(ItemStack itemstack) { + return itemstack.is((Tag) TagsItem.PIGLIN_LOVED); } -@@ -444,7 +469,7 @@ +@@ -473,7 +495,7 @@ } - public static void a(EntityHuman entityhuman, boolean flag) { -- List<EntityPiglin> list = entityhuman.level.a(EntityPiglin.class, entityhuman.getBoundingBox().g(16.0D)); -+ List<EntityPiglinAbstract> list = (List) entityhuman.level.a(EntityPiglin.class, entityhuman.getBoundingBox().g(16.0D)); // CraftBukkit - decompile error - - list.stream().filter(PiglinAI::d).filter((entitypiglin) -> { - return !flag || BehaviorUtil.b((EntityLiving) entitypiglin, entityhuman); -@@ -474,7 +499,7 @@ + protected static boolean canAdmire(EntityPiglin entitypiglin, ItemStack itemstack) { +- return !isAdmiringDisabled(entitypiglin) && !isAdmiringItem(entitypiglin) && entitypiglin.isAdult() && isBarterCurrency(itemstack); ++ return !isAdmiringDisabled(entitypiglin) && !isAdmiringItem(entitypiglin) && entitypiglin.isAdult() && isBarterCurrency(itemstack, entitypiglin); // CraftBukkit } - protected static boolean b(EntityPiglin entitypiglin, ItemStack itemstack) { -- return !x(entitypiglin) && !v(entitypiglin) && entitypiglin.fw() && b(itemstack); -+ return !x(entitypiglin) && !v(entitypiglin) && entitypiglin.fw() && isBarterItem(itemstack, entitypiglin); // CraftBukkit - } - - protected static void a(EntityPiglin entitypiglin, EntityLiving entityliving) { -@@ -680,7 +705,7 @@ - EntityLiving entityliving = (EntityLiving) behaviorcontroller.getMemory(MemoryModuleType.AVOID_TARGET).get(); - EntityTypes<?> entitytypes = entityliving.getEntityType(); - -- return entitytypes == EntityTypes.HOGLIN ? p(entitypiglin) : (a(entitytypes) ? !behaviorcontroller.b(MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, (Object) entityliving) : false); -+ return entitytypes == EntityTypes.HOGLIN ? p(entitypiglin) : (a(entitytypes) ? !behaviorcontroller.b(MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, entityliving) : false); // CraftBukkit - decompile error - } - } - -@@ -741,6 +766,12 @@ - return entitypiglin.getBehaviorController().hasMemory(MemoryModuleType.ADMIRING_ITEM); + protected static void wasHurtBy(EntityPiglin entitypiglin, EntityLiving entityliving) { +@@ -740,6 +762,12 @@ + return entitypiglin.getBrain().hasMemoryValue(MemoryModuleType.ADMIRING_ITEM); } + // CraftBukkit start - Changes to allow custom payment for bartering -+ private static boolean isBarterItem(ItemStack itemstack, EntityPiglin piglin) { -+ return b(itemstack) || piglin.allowedBarterItems.contains(itemstack.getItem()); ++ private static boolean isBarterCurrency(ItemStack itemstack, EntityPiglin piglin) { ++ return isBarterCurrency(itemstack) || piglin.allowedBarterItems.contains(itemstack.getItem()); + } + // CraftBukkit end + - private static boolean b(ItemStack itemstack) { - return itemstack.a(PiglinAI.BARTERING_ITEM); + private static boolean isBarterCurrency(ItemStack itemstack) { + return itemstack.is(PiglinAI.BARTERING_ITEM); } -@@ -778,7 +809,7 @@ +@@ -777,7 +805,7 @@ } - private static boolean z(EntityPiglin entitypiglin) { -- return entitypiglin.getItemInOffHand().isEmpty() || !a(entitypiglin.getItemInOffHand()); -+ return entitypiglin.getItemInOffHand().isEmpty() || !isLovedByPiglin(entitypiglin.getItemInOffHand(), entitypiglin); // CraftBukkit - Changes to allow custom payment for bartering + private static boolean isNotHoldingLovedItemInOffHand(EntityPiglin entitypiglin) { +- return entitypiglin.getOffhandItem().isEmpty() || !isLovedItem(entitypiglin.getOffhandItem()); ++ return entitypiglin.getOffhandItem().isEmpty() || !isLovedItem(entitypiglin.getOffhandItem(), entitypiglin); // CraftBukkit - Changes to allow custom payment for bartering } - public static boolean a(EntityTypes<?> entitytypes) { + public static boolean isZombified(EntityTypes<?> entitytypes) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch b/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch index e9262ba6f0..fd8b3f2af5 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch +++ b/paper-server/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,14 @@ +@@ -89,6 +89,14 @@ import net.minecraft.world.phys.AxisAlignedBB; import org.apache.logging.log4j.Logger; @@ -14,35 +14,17 @@ + public class EntityVillager extends EntityVillagerAbstract implements ReputationHandler, VillagerDataHolder { - private static final DataWatcherObject<VillagerData> DATA_VILLAGER_DATA = DataWatcher.a(EntityVillager.class, DataWatcherRegistry.VILLAGER_DATA); -@@ -150,7 +158,7 @@ + private static final DataWatcherObject<VillagerData> DATA_VILLAGER_DATA = DataWatcher.defineId(EntityVillager.class, DataWatcherRegistry.VILLAGER_DATA); +@@ -146,7 +154,7 @@ @Override - public BehaviorController<EntityVillager> getBehaviorController() { -- return super.getBehaviorController(); -+ return (BehaviorController<EntityVillager>) super.getBehaviorController(); // CraftBukkit - decompile error + public BehaviorController<EntityVillager> getBrain() { +- return super.getBrain(); ++ return (BehaviorController<EntityVillager>) super.getBrain(); // CraftBukkit - decompile error } @Override -@@ -169,7 +177,7 @@ - public void c(WorldServer worldserver) { - BehaviorController<EntityVillager> behaviorcontroller = this.getBehaviorController(); - -- behaviorcontroller.b(worldserver, (EntityLiving) this); -+ behaviorcontroller.b(worldserver, this); // CraftBukkit - decompile error - this.brain = behaviorcontroller.h(); - this.a(this.getBehaviorController()); - } -@@ -219,7 +227,7 @@ - @Override - protected void mobTick() { - this.level.getMethodProfiler().enter("villagerBrain"); -- this.getBehaviorController().a((WorldServer) this.level, (EntityLiving) this); -+ this.getBehaviorController().a((WorldServer) this.level, this); // CraftBukkit - decompile error - this.level.getMethodProfiler().exit(); - if (this.assignProfessionWhenSpawned) { - this.assignProfessionWhenSpawned = false; -@@ -233,7 +241,7 @@ +@@ -229,7 +237,7 @@ this.increaseProfessionLevelOnUpdate = false; } @@ -51,83 +33,83 @@ } } -@@ -444,7 +452,14 @@ +@@ -445,7 +453,14 @@ while (iterator.hasNext()) { MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next(); -- merchantrecipe.increaseSpecialPrice(-MathHelper.d((float) i * merchantrecipe.getPriceMultiplier())); +- merchantrecipe.addToSpecialPriceDiff(-MathHelper.floor((float) i * merchantrecipe.getPriceMultiplier())); + // CraftBukkit start -+ int bonus = -MathHelper.d((float) i * merchantrecipe.getPriceMultiplier()); ++ int bonus = -MathHelper.floor((float) i * merchantrecipe.getPriceMultiplier()); + VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit(), bonus); + Bukkit.getPluginManager().callEvent(event); + if (!event.isCancelled()) { -+ merchantrecipe.increaseSpecialPrice(event.getBonus()); ++ merchantrecipe.addToSpecialPriceDiff(event.getBonus()); + } + // CraftBukkit end } } -@@ -473,7 +488,7 @@ +@@ -474,7 +489,7 @@ @Override - public void saveData(NBTTagCompound nbttagcompound) { - super.saveData(nbttagcompound); + public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { + super.addAdditionalSaveData(nbttagcompound); - DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); + DataResult<NBTBase> dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); // CraftBukkit - decompile error Logger logger = EntityVillager.LOGGER; Objects.requireNonNull(logger); -@@ -813,7 +828,12 @@ +@@ -816,7 +831,12 @@ } - entitywitch.setPersistent(); -- worldserver.addAllEntities(entitywitch); + entitywitch.setPersistenceRequired(); +- worldserver.addFreshEntityWithPassengers(entitywitch); + // CraftBukkit start + if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) { + return; + } -+ worldserver.addAllEntities(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); ++ worldserver.addFreshEntityWithPassengers(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); + // CraftBukkit end - this.ga(); - this.die(); + this.releaseAllPois(); + this.discard(); } else { -@@ -834,6 +854,13 @@ +@@ -837,6 +857,13 @@ return; } + // CraftBukkit start -+ ItemStack remaining = new InventorySubcontainer(inventorysubcontainer).a(itemstack); ++ ItemStack remaining = new InventorySubcontainer(inventorysubcontainer).addItem(itemstack); + if (CraftEventFactory.callEntityPickupItemEvent(this, entityitem, remaining.getCount(), false).isCancelled()) { + return; + } + // CraftBukkit end + - this.a(entityitem); - this.receive(entityitem, itemstack.getCount()); - ItemStack itemstack1 = inventorysubcontainer.a(itemstack); -@@ -946,7 +973,7 @@ + this.onItemPickup(entityitem); + this.take(entityitem, itemstack.getCount()); + ItemStack itemstack1 = inventorysubcontainer.addItem(itemstack); +@@ -949,7 +976,7 @@ if (entityirongolem != null) { - if (entityirongolem.a((GeneratorAccess) worldserver, EnumMobSpawn.MOB_SUMMONED) && entityirongolem.a((IWorldReader) worldserver)) { -- worldserver.addAllEntities(entityirongolem); -+ worldserver.addAllEntities(entityirongolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE); // CraftBukkit + if (entityirongolem.checkSpawnRules(worldserver, EnumMobSpawn.MOB_SUMMONED) && entityirongolem.checkSpawnObstruction(worldserver)) { +- worldserver.addFreshEntityWithPassengers(entityirongolem); ++ worldserver.addFreshEntityWithPassengers(entityirongolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE); // CraftBukkit return entityirongolem; } -@@ -1024,7 +1051,7 @@ +@@ -1027,7 +1054,7 @@ @Override - public void entitySleep(BlockPosition blockposition) { - super.entitySleep(blockposition); -- this.brain.setMemory(MemoryModuleType.LAST_SLEPT, (Object) this.level.getTime()); -+ this.brain.setMemory(MemoryModuleType.LAST_SLEPT, this.level.getTime()); // CraftBukkit - decompile error - this.brain.removeMemory(MemoryModuleType.WALK_TARGET); - this.brain.removeMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); + 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); } -@@ -1032,7 +1059,7 @@ +@@ -1035,7 +1062,7 @@ @Override - public void entityWakeup() { - super.entityWakeup(); -- this.brain.setMemory(MemoryModuleType.LAST_WOKEN, (Object) this.level.getTime()); -+ this.brain.setMemory(MemoryModuleType.LAST_WOKEN, this.level.getTime()); // CraftBukkit - decompile error + 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 b(long i) { + private boolean golemSpawnConditionsMet(long i) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch b/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch index d877b16335..b9dc5cb26f 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch @@ -22,7 +22,7 @@ + return (craftMerchant == null) ? craftMerchant = new CraftMerchant(this) : craftMerchant; + } + // CraftBukkit end - private static final DataWatcherObject<Integer> DATA_UNHAPPY_COUNTER = DataWatcher.a(EntityVillagerAbstract.class, DataWatcherRegistry.INT); + private static final DataWatcherObject<Integer> DATA_UNHAPPY_COUNTER = DataWatcher.defineId(EntityVillagerAbstract.class, DataWatcherRegistry.INT); public static final int VILLAGER_SLOT_OFFSET = 300; private static final int VILLAGER_INVENTORY_SIZE = 8; @@ -45,7 +61,7 @@ @@ -34,8 +34,8 @@ public EntityVillagerAbstract(EntityTypes<? extends EntityVillagerAbstract> entitytypes, World world) { super(entitytypes, world); -@@ -252,7 +268,16 @@ - MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.a(this, this.random); +@@ -247,7 +263,16 @@ + MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.getOffer(this, this.random); if (merchantrecipe != null) { - merchantrecipelist.add(merchantrecipe); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch b/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch index 9a00ef8182..7f24796b1e 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch @@ -23,7 +23,7 @@ @Override @@ -131,7 +139,16 @@ - MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.a(this, this.random); + MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.getOffer(this, this.random); if (merchantrecipe != null) { - merchantrecipelist.add(merchantrecipe); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch b/paper-server/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch index 1f64b55abd..c5987339c5 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch @@ -4,26 +4,26 @@ return false; } -- EntityVillagerTrader entityvillagertrader = (EntityVillagerTrader) EntityTypes.WANDERING_TRADER.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition2, EnumMobSpawn.EVENT, false, false); -+ EntityVillagerTrader entityvillagertrader = (EntityVillagerTrader) EntityTypes.WANDERING_TRADER.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition2, EnumMobSpawn.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit +- EntityVillagerTrader entityvillagertrader = (EntityVillagerTrader) EntityTypes.WANDERING_TRADER.spawn(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition2, EnumMobSpawn.EVENT, false, false); ++ EntityVillagerTrader entityvillagertrader = (EntityVillagerTrader) EntityTypes.WANDERING_TRADER.spawn(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition2, EnumMobSpawn.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit if (entityvillagertrader != null) { for (int i = 0; i < 2; ++i) { @@ -119,7 +119,7 @@ } - this.serverLevelData.a(entityvillagertrader.getUniqueID()); + this.serverLevelData.setWanderingTraderId(entityvillagertrader.getUUID()); - entityvillagertrader.setDespawnDelay(48000); + // entityvillagertrader.setDespawnDelay(48000); // CraftBukkit - moved to EntityVillagerTrader constructor. This lets the value be modified by plugins on CreatureSpawnEvent - entityvillagertrader.g(blockposition1); - entityvillagertrader.a(blockposition1, 16); + entityvillagertrader.setWanderTarget(blockposition1); + entityvillagertrader.restrictTo(blockposition1, 16); return true; @@ -134,7 +134,7 @@ - BlockPosition blockposition = this.a((IWorldReader) worldserver, entityvillagertrader.getChunkCoordinates(), i); + BlockPosition blockposition = this.findSpawnPositionNear(worldserver, entityvillagertrader.blockPosition(), i); if (blockposition != null) { -- EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition, EnumMobSpawn.EVENT, false, false); -+ EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition, EnumMobSpawn.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit +- EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawn(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition, EnumMobSpawn.EVENT, false, false); ++ EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawn(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition, EnumMobSpawn.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit if (entityllamatrader != null) { - entityllamatrader.setLeashHolder(entityvillagertrader, true); + entityllamatrader.setLeashedTo(entityvillagertrader, true); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch b/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch index 965c597305..3bf2621093 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/EntityHuman.java +++ b/net/minecraft/world/entity/player/EntityHuman.java -@@ -113,6 +113,19 @@ +@@ -111,6 +111,19 @@ import net.minecraft.world.scores.ScoreboardTeam; import net.minecraft.world.scores.ScoreboardTeamBase; @@ -20,18 +20,18 @@ public abstract class EntityHuman extends EntityLiving { public static final String UUID_PREFIX_OFFLINE_PLAYER = "OfflinePlayer:"; -@@ -126,7 +139,8 @@ +@@ -124,7 +137,8 @@ public static final float SWIMMING_BB_HEIGHT = 0.6F; public static final float DEFAULT_EYE_HEIGHT = 1.62F; - public static final EntitySize STANDING_DIMENSIONS = EntitySize.b(0.6F, 1.8F); -- private static final Map<EntityPose, EntitySize> POSES = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.STANDING_DIMENSIONS).put(EntityPose.SLEEPING, EntityHuman.SLEEPING_DIMENSIONS).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build(); + public static final EntitySize STANDING_DIMENSIONS = EntitySize.scalable(0.6F, 1.8F); +- private static final Map<EntityPose, EntitySize> 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)).put(EntityPose.SWIMMING, EntitySize.scalable(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.scalable(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.scalable(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.fixed(0.2F, 0.2F)).build(); + // CraftBukkit - decompile error -+ private static final Map<EntityPose, EntitySize> POSES = ImmutableMap.<EntityPose, EntitySize>builder().put(EntityPose.STANDING, EntityHuman.STANDING_DIMENSIONS).put(EntityPose.SLEEPING, EntityHuman.SLEEPING_DIMENSIONS).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build(); ++ private static final Map<EntityPose, EntitySize> POSES = ImmutableMap.<EntityPose, EntitySize>builder().put(EntityPose.STANDING, EntityHuman.STANDING_DIMENSIONS).put(EntityPose.SLEEPING, EntityHuman.SLEEPING_DIMENSIONS).put(EntityPose.FALL_FLYING, EntitySize.scalable(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.scalable(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.scalable(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.scalable(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.fixed(0.2F, 0.2F)).build(); private static final int FLY_ACHIEVEMENT_SPEED = 25; - private static final DataWatcherObject<Float> DATA_PLAYER_ABSORPTION_ID = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.FLOAT); - private static final DataWatcherObject<Integer> DATA_SCORE_ID = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.INT); -@@ -136,10 +150,10 @@ - protected static final DataWatcherObject<NBTTagCompound> DATA_SHOULDER_RIGHT = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.COMPOUND_TAG); + private static final DataWatcherObject<Float> DATA_PLAYER_ABSORPTION_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.FLOAT); + private static final DataWatcherObject<Integer> DATA_SCORE_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.INT); +@@ -134,10 +148,10 @@ + protected static final DataWatcherObject<NBTTagCompound> DATA_SHOULDER_RIGHT = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.COMPOUND_TAG); private long timeEntitySatOnShoulder; private final PlayerInventory inventory = new PlayerInventory(this); - protected InventoryEnderChest enderChestInventory = new InventoryEnderChest(); @@ -43,7 +43,7 @@ protected int jumpTriggerTime; public float oBob; public float bob; -@@ -166,6 +180,16 @@ +@@ -164,6 +178,16 @@ @Nullable public EntityFishingHook fishing; @@ -60,16 +60,16 @@ public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile) { super(EntityTypes.PLAYER, world); this.lastItemInMainHand = ItemStack.EMPTY; -@@ -304,7 +328,7 @@ - ItemStack itemstack = this.getEquipment(EnumItemSlot.HEAD); +@@ -302,7 +326,7 @@ + ItemStack itemstack = this.getItemBySlot(EnumItemSlot.HEAD); - if (itemstack.a(Items.TURTLE_HELMET) && !this.a((Tag) TagsFluid.WATER)) { + if (itemstack.is(Items.TURTLE_HELMET) && !this.isEyeInFluid(TagsFluid.WATER)) { - this.addEffect(new MobEffect(MobEffects.WATER_BREATHING, 200, 0, false, false, true)); + this.addEffect(new MobEffect(MobEffects.WATER_BREATHING, 200, 0, false, false, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TURTLE_HELMET); // CraftBukkit } } -@@ -496,7 +520,8 @@ +@@ -494,7 +518,8 @@ if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL && this.level.getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { if (this.getHealth() < this.getMaxHealth() && this.tickCount % 20 == 0) { @@ -78,18 +78,9 @@ + this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); } - if (this.foodData.c() && this.tickCount % 10 == 0) { -@@ -545,7 +570,7 @@ - } - - if (!list1.isEmpty()) { -- this.c((Entity) SystemUtils.a((List) list1, this.random)); -+ this.c((Entity) SystemUtils.a(list1, this.random)); // CraftBukkit - decompile error - } - } - -@@ -684,6 +709,30 @@ - entityitem.setMot((double) (-f3 * f2 * 0.3F) + Math.cos((double) f5) * (double) f6, (double) (-f1 * 0.3F + 0.1F + (this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (f4 * f2 * 0.3F) + Math.sin((double) f5) * (double) f6); + if (this.foodData.needsFood() && this.tickCount % 10 == 0) { +@@ -682,6 +707,30 @@ + entityitem.setDeltaMovement((double) (-f3 * f2 * 0.3F) + Math.cos((double) f5) * (double) f6, (double) (-f1 * 0.3F + 0.1F + (this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (f4 * f2 * 0.3F) + Math.sin((double) f5) * (double) f6); } + // CraftBukkit start - fire PlayerDropItemEvent @@ -119,47 +110,47 @@ return entityitem; } } -@@ -810,16 +859,17 @@ - if (this.isInvulnerable(damagesource)) { +@@ -808,16 +857,17 @@ + if (this.isInvulnerableTo(damagesource)) { return false; - } else if (this.abilities.invulnerable && !damagesource.ignoresInvulnerability()) { + } else if (this.abilities.invulnerable && !damagesource.isBypassInvul()) { + this.forceExplosionKnockback = true; // SPIGOT-5258 - Make invulnerable players get knockback from explosions return false; } else { this.noActionTime = 0; - if (this.dV()) { + if (this.isDeadOrDying()) { return false; } else { -- this.releaseShoulderEntities(); +- this.removeEntitiesOnShoulder(); + // this.releaseShoulderEntities(); // CraftBukkit - moved down - if (damagesource.w()) { + if (damagesource.scalesWithDifficulty()) { if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL) { - f = 0.0F; + return false; // CraftBukkit - f = 0.0f -> return false } if (this.level.getDifficulty() == EnumDifficulty.EASY) { -@@ -831,7 +881,13 @@ +@@ -829,7 +879,13 @@ } } -- return f == 0.0F ? false : super.damageEntity(damagesource, f); +- return f == 0.0F ? false : super.hurt(damagesource, f); + // CraftBukkit start - Don't filter out 0 damage -+ boolean damaged = super.damageEntity(damagesource, f); ++ boolean damaged = super.hurt(damagesource, f); + if (damaged) { -+ this.releaseShoulderEntities(); ++ this.removeEntitiesOnShoulder(); + } + return damaged; + // CraftBukkit end } } } -@@ -851,10 +907,29 @@ +@@ -849,10 +905,29 @@ } - public boolean a(EntityHuman entityhuman) { -- ScoreboardTeamBase scoreboardteambase = this.getScoreboardTeam(); -- ScoreboardTeamBase scoreboardteambase1 = entityhuman.getScoreboardTeam(); + public boolean canHarmPlayer(EntityHuman entityhuman) { +- 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; @@ -171,47 +162,47 @@ + } + } else { + // This should never be called, but is implemented anyway -+ org.bukkit.OfflinePlayer thisPlayer = entityhuman.level.getCraftServer().getOfflinePlayer(entityhuman.getName()); ++ org.bukkit.OfflinePlayer thisPlayer = entityhuman.level.getCraftServer().getOfflinePlayer(entityhuman.getScoreboardName()); + team = entityhuman.level.getCraftServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer); + if (team == null || team.allowFriendlyFire()) { + return true; + } + } -- return scoreboardteambase == null ? true : (!scoreboardteambase.isAlly(scoreboardteambase1) ? true : scoreboardteambase.allowFriendlyFire()); +- return scoreboardteambase == null ? true : (!scoreboardteambase.isAlliedTo(scoreboardteambase1) ? true : scoreboardteambase.isAllowFriendlyFire()); + if (this instanceof EntityPlayer) { + return !team.hasPlayer(((EntityPlayer) this).getBukkitEntity()); + } -+ return !team.hasPlayer(this.level.getCraftServer().getOfflinePlayer(this.getName())); ++ return !team.hasPlayer(this.level.getCraftServer().getOfflinePlayer(this.getScoreboardName())); + // CraftBukkit end } @Override -@@ -896,8 +971,13 @@ +@@ -894,8 +969,13 @@ } } + // CraftBukkit start @Override -- protected void damageEntity0(DamageSource damagesource, float f) { +- protected void actuallyHurt(DamageSource damagesource, float f) { + protected boolean damageEntity0(DamageSource damagesource, float f) { // void -> boolean + if (true) { + return super.damageEntity0(damagesource, f); + } + // CraftBukkit end - if (!this.isInvulnerable(damagesource)) { - f = this.applyArmorModifier(damagesource, f); - f = this.applyMagicModifier(damagesource, f); -@@ -912,7 +992,7 @@ + if (!this.isInvulnerableTo(damagesource)) { + f = this.getDamageAfterArmorAbsorb(damagesource, f); + f = this.getDamageAfterMagicAbsorb(damagesource, f); +@@ -910,7 +990,7 @@ } if (f != 0.0F) { -- this.applyExhaustion(damagesource.getExhaustionCost()); -+ this.applyExhaustion(damagesource.getExhaustionCost(), EntityExhaustionEvent.ExhaustionReason.DAMAGED); // CraftBukkit - EntityExhaustionEvent +- this.causeFoodExhaustion(damagesource.getFoodExhaustion()); ++ this.causeFoodExhaustion(damagesource.getFoodExhaustion(), EntityExhaustionEvent.ExhaustionReason.DAMAGED); // CraftBukkit - EntityExhaustionEvent float f3 = this.getHealth(); this.setHealth(this.getHealth() - f); -@@ -923,6 +1003,7 @@ +@@ -921,6 +1001,7 @@ } } @@ -219,47 +210,47 @@ } @Override -@@ -1082,7 +1163,7 @@ +@@ -1080,7 +1161,7 @@ f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; -- this.resetAttackCooldown(); +- this.resetAttackStrengthTicker(); + // this.resetAttackCooldown(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt if (f > 0.0F || f1 > 0.0F) { boolean flag = f2 > 0.9F; boolean flag1 = false; -@@ -1121,8 +1202,15 @@ +@@ -1119,8 +1200,15 @@ if (entity instanceof EntityLiving) { f3 = ((EntityLiving) entity).getHealth(); - if (j > 0 && !entity.isBurning()) { + if (j > 0 && !entity.isOnFire()) { - flag4 = true; -- entity.setOnFire(1); +- entity.setSecondsOnFire(1); + // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item + EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 1); + org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); + + if (!combustEvent.isCancelled()) { + flag4 = true; -+ entity.setOnFire(combustEvent.getDuration(), false); ++ entity.setSecondsOnFire(combustEvent.getDuration(), false); + } + // CraftBukkit end } } -@@ -1150,8 +1238,11 @@ +@@ -1148,8 +1236,11 @@ EntityLiving entityliving = (EntityLiving) iterator.next(); - if (entityliving != this && entityliving != entity && !this.p(entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.f((Entity) entityliving) < 9.0D) { + if (entityliving != this && entityliving != entity && !this.isAlliedTo((Entity) entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) { + // CraftBukkit start - Only apply knockback if the damage hits -+ if (entityliving.damageEntity(DamageSource.playerAttack(this).sweep(), f4)) { - entityliving.p(0.4000000059604645D, (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F))); -- entityliving.damageEntity(DamageSource.playerAttack(this), f4); ++ if (entityliving.hurt(DamageSource.playerAttack(this).sweep(), f4)) { + entityliving.knockback(0.4000000059604645D, (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F))); +- entityliving.hurt(DamageSource.playerAttack(this), f4); + } + // CraftBukkit end } } -@@ -1160,9 +1251,26 @@ +@@ -1158,9 +1249,26 @@ } if (entity instanceof EntityPlayer && entity.hurtMarked) { @@ -278,40 +269,40 @@ + } + + if (!cancelled) { - ((EntityPlayer) entity).connection.sendPacket(new PacketPlayOutEntityVelocity(entity)); + ((EntityPlayer) entity).connection.send(new PacketPlayOutEntityVelocity(entity)); entity.hurtMarked = false; - entity.setMot(vec3d); + entity.setDeltaMovement(vec3d); + } + // CraftBukkit end } if (flag2) { -@@ -1207,7 +1315,14 @@ +@@ -1205,7 +1313,14 @@ - this.a(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F)); + this.awardStat(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F)); if (j > 0) { -- entity.setOnFire(j * 4); +- entity.setSecondsOnFire(j * 4); + // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item + EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), j * 4); + org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); + + if (!combustEvent.isCancelled()) { -+ entity.setOnFire(combustEvent.getDuration(), false); ++ entity.setSecondsOnFire(combustEvent.getDuration(), false); + } + // CraftBukkit end } if (this.level instanceof WorldServer && f5 > 2.0F) { -@@ -1217,12 +1332,17 @@ +@@ -1215,12 +1330,17 @@ } } -- this.applyExhaustion(0.1F); -+ this.applyExhaustion(0.1F, EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent +- this.causeFoodExhaustion(0.1F); ++ this.causeFoodExhaustion(0.1F, EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent } else { - this.level.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.PLAYER_ATTACK_NODAMAGE, this.getSoundCategory(), 1.0F, 1.0F); + this.level.playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); if (flag4) { - entity.extinguish(); + entity.clearFire(); } + // CraftBukkit start - resync on cancelled event + if (this instanceof EntityPlayer) { @@ -321,166 +312,166 @@ } } -@@ -1295,6 +1415,12 @@ - public void a(ItemStack itemstack, ItemStack itemstack1, ClickAction clickaction) {} +@@ -1293,6 +1413,12 @@ + public void updateTutorialInventoryAction(ItemStack itemstack, ItemStack itemstack1, ClickAction clickaction) {} - public Either<EntityHuman.EnumBedResult, Unit> sleep(BlockPosition blockposition) { + public Either<EntityHuman.EnumBedResult, Unit> startSleepInBed(BlockPosition blockposition) { + // CraftBukkit start -+ return this.sleep(blockposition, false); ++ return this.startSleepInBed(blockposition, false); + } + -+ public Either<EntityHuman.EnumBedResult, Unit> sleep(BlockPosition blockposition, boolean force) { ++ public Either<EntityHuman.EnumBedResult, Unit> startSleepInBed(BlockPosition blockposition, boolean force) { + // CraftBukkit end - this.entitySleep(blockposition); + this.startSleeping(blockposition); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1379,9 +1505,9 @@ - super.jump(); - this.a(StatisticList.JUMP); +@@ -1377,9 +1503,9 @@ + super.jumpFromGround(); + this.awardStat(StatisticList.JUMP); if (this.isSprinting()) { -- this.applyExhaustion(0.2F); -+ this.applyExhaustion(0.2F, EntityExhaustionEvent.ExhaustionReason.JUMP_SPRINT); // CraftBukkit - EntityExhaustionEvent +- this.causeFoodExhaustion(0.2F); ++ this.causeFoodExhaustion(0.2F, EntityExhaustionEvent.ExhaustionReason.JUMP_SPRINT); // CraftBukkit - EntityExhaustionEvent } else { -- this.applyExhaustion(0.05F); -+ this.applyExhaustion(0.05F, EntityExhaustionEvent.ExhaustionReason.JUMP); // CraftBukkit - EntityExhaustionEvent +- this.causeFoodExhaustion(0.05F); ++ this.causeFoodExhaustion(0.05F, EntityExhaustionEvent.ExhaustionReason.JUMP); // CraftBukkit - EntityExhaustionEvent } } -@@ -1415,7 +1541,11 @@ - this.setMot(vec3d2.x, d3 * 0.6D, vec3d2.z); +@@ -1413,7 +1539,11 @@ + this.setDeltaMovement(vec3d2.x, d3 * 0.6D, vec3d2.z); this.flyingSpeed = f; - this.fallDistance = 0.0F; -- this.setFlag(7, false); + this.resetFallDistance(); +- this.setSharedFlag(7, false); + // CraftBukkit start -+ if (getFlag(7) && !org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) { -+ this.setFlag(7, false); ++ if (getSharedFlag(7) && !org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) { ++ this.setSharedFlag(7, false); + } + // CraftBukkit end } else { - super.g(vec3d); + super.travel(vec3d); } -@@ -1450,19 +1580,19 @@ +@@ -1448,19 +1578,19 @@ i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); if (i > 0) { - this.a(StatisticList.SWIM_ONE_CM, i); -- this.applyExhaustion(0.01F * (float) i * 0.01F); -+ this.applyExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.SWIM); // CraftBukkit - EntityExhaustionEvent + 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.a((Tag) TagsFluid.WATER)) { + } else if (this.isEyeInFluid(TagsFluid.WATER)) { i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); if (i > 0) { - this.a(StatisticList.WALK_UNDER_WATER_ONE_CM, i); -- this.applyExhaustion(0.01F * (float) i * 0.01F); -+ this.applyExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_UNDERWATER); // CraftBukkit - EntityExhaustionEvent + 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 } } else if (this.isInWater()) { i = Math.round((float) Math.sqrt(d0 * d0 + d2 * d2) * 100.0F); if (i > 0) { - this.a(StatisticList.WALK_ON_WATER_ONE_CM, i); -- this.applyExhaustion(0.01F * (float) i * 0.01F); -+ this.applyExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_ON_WATER); // CraftBukkit - EntityExhaustionEvent + 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 } - } else if (this.isClimbing()) { + } else if (this.onClimbable()) { if (d1 > 0.0D) { -@@ -1473,13 +1603,13 @@ +@@ -1471,13 +1601,13 @@ if (i > 0) { if (this.isSprinting()) { - this.a(StatisticList.SPRINT_ONE_CM, i); -- this.applyExhaustion(0.1F * (float) i * 0.01F); -+ this.applyExhaustion(0.1F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.SPRINT); // CraftBukkit - EntityExhaustionEvent + 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 } else if (this.isCrouching()) { - this.a(StatisticList.CROUCH_ONE_CM, i); -- this.applyExhaustion(0.0F * (float) i * 0.01F); -+ this.applyExhaustion(0.0F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.CROUCH); // CraftBukkit - EntityExhaustionEvent + 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 } else { - this.a(StatisticList.WALK_ONE_CM, i); -- this.applyExhaustion(0.0F * (float) i * 0.01F); -+ this.applyExhaustion(0.0F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK); // CraftBukkit - EntityExhaustionEvent + 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 } } - } else if (this.isGliding()) { -@@ -1545,12 +1675,24 @@ + } else if (this.isFallFlying()) { +@@ -1543,12 +1673,24 @@ } - public void startGliding() { -- this.setFlag(7, true); + public void startFallFlying() { +- this.setSharedFlag(7, true); + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, true).isCancelled()) { -+ this.setFlag(7, true); ++ this.setSharedFlag(7, true); + } else { + // SPIGOT-5542: must toggle like below -+ this.setFlag(7, true); -+ this.setFlag(7, false); ++ this.setSharedFlag(7, true); ++ this.setSharedFlag(7, false); + } + // CraftBukkit end } - public void stopGliding() { + public void stopFallFlying() { + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) { - this.setFlag(7, true); - this.setFlag(7, false); + this.setSharedFlag(7, true); + this.setSharedFlag(7, false); + } + // CraftBukkit end } @Override -@@ -1640,10 +1782,21 @@ +@@ -1638,10 +1780,21 @@ return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2); } + // CraftBukkit start - public void applyExhaustion(float f) { -+ this.applyExhaustion(f, EntityExhaustionEvent.ExhaustionReason.UNKNOWN); + public void causeFoodExhaustion(float f) { ++ this.causeFoodExhaustion(f, EntityExhaustionEvent.ExhaustionReason.UNKNOWN); + } + -+ public void applyExhaustion(float f, EntityExhaustionEvent.ExhaustionReason reason) { ++ public void causeFoodExhaustion(float f, EntityExhaustionEvent.ExhaustionReason reason) { + // CraftBukkit end if (!this.abilities.invulnerable) { if (!this.level.isClientSide) { -- this.foodData.a(f); +- this.foodData.addExhaustion(f); + // CraftBukkit start + EntityExhaustionEvent event = CraftEventFactory.callPlayerExhaustionEvent(this, reason, f); + if (!event.isCancelled()) { -+ this.foodData.a(event.getExhaustion()); // PAIL rename addExhaustion ++ this.foodData.addExhaustion(event.getExhaustion()); + } + // CraftBukkit end } } -@@ -1720,15 +1873,22 @@ +@@ -1718,15 +1871,22 @@ @Override - public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { + public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { + // CraftBukkit start -+ this.setSlot(enumitemslot, itemstack, false); ++ this.setItemSlot(enumitemslot, itemstack, false); + } + + @Override -+ public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) { ++ public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) { + // CraftBukkit end - this.f(itemstack); + this.verifyEquippedItem(itemstack); if (enumitemslot == EnumItemSlot.MAINHAND) { -- this.playEquipSound(itemstack); -+ this.playEquipSound(itemstack, silent); // CraftBukkit +- this.equipEventAndSound(itemstack); ++ this.equipEventAndSound(itemstack, silent); // CraftBukkit this.inventory.items.set(this.inventory.selected, itemstack); } else if (enumitemslot == EnumItemSlot.OFFHAND) { -- this.playEquipSound(itemstack); -+ this.playEquipSound(itemstack, silent); // CraftBukkit +- this.equipEventAndSound(itemstack); ++ this.equipEventAndSound(itemstack, silent); // CraftBukkit this.inventory.offhand.set(0, itemstack); - } else if (enumitemslot.a() == EnumItemSlot.Function.ARMOR) { -- this.playEquipSound(itemstack); -+ this.playEquipSound(itemstack, silent); // CraftBukkit - this.inventory.armor.set(enumitemslot.b(), itemstack); + } else if (enumitemslot.getType() == EnumItemSlot.Function.ARMOR) { +- this.equipEventAndSound(itemstack); ++ this.equipEventAndSound(itemstack, silent); // CraftBukkit + this.inventory.armor.set(enumitemslot.getIndex(), itemstack); } -@@ -1769,26 +1929,31 @@ +@@ -1767,26 +1927,31 @@ - protected void releaseShoulderEntities() { - if (this.timeEntitySatOnShoulder + 20L < this.level.getTime()) { -- this.spawnEntityFromShoulder(this.getShoulderEntityLeft()); + protected void removeEntitiesOnShoulder() { + if (this.timeEntitySatOnShoulder + 20L < this.level.getGameTime()) { +- this.respawnEntityOnShoulder(this.getShoulderEntityLeft()); - this.setShoulderEntityLeft(new NBTTagCompound()); -- this.spawnEntityFromShoulder(this.getShoulderEntityRight()); +- this.respawnEntityOnShoulder(this.getShoulderEntityRight()); - this.setShoulderEntityRight(new NBTTagCompound()); + // CraftBukkit start + if (this.spawnEntityFromShoulder(this.getShoulderEntityLeft())) { @@ -494,19 +485,19 @@ } -- private void spawnEntityFromShoulder(NBTTagCompound nbttagcompound) { +- private void respawnEntityOnShoulder(NBTTagCompound nbttagcompound) { + private boolean spawnEntityFromShoulder(NBTTagCompound nbttagcompound) { // CraftBukkit void->boolean if (!this.level.isClientSide && !nbttagcompound.isEmpty()) { -- EntityTypes.a(nbttagcompound, this.level).ifPresent((entity) -> { -+ return EntityTypes.a(nbttagcompound, this.level).map((entity) -> { // CraftBukkit +- EntityTypes.create(nbttagcompound, this.level).ifPresent((entity) -> { ++ return EntityTypes.create(nbttagcompound, this.level).map((entity) -> { // CraftBukkit if (entity instanceof EntityTameableAnimal) { ((EntityTameableAnimal) entity).setOwnerUUID(this.uuid); } - entity.setPosition(this.locX(), this.locY() + 0.699999988079071D, this.locZ()); -- ((WorldServer) this.level).addEntitySerialized(entity); + entity.setPos(this.getX(), this.getY() + 0.699999988079071D, this.getZ()); +- ((WorldServer) this.level).addWithUUID(entity); - }); -+ return ((WorldServer) this.level).addEntitySerialized(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit ++ return ((WorldServer) this.level).addWithUUID(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit + }).orElse(true); // CraftBukkit } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch b/paper-server/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch index c0c2efa699..b579293e22 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch @@ -67,10 +67,10 @@ + // CraftBukkit end + public PlayerInventory(EntityHuman entityhuman) { - this.items = NonNullList.a(36, ItemStack.EMPTY); - this.armor = NonNullList.a(4, ItemStack.EMPTY); + this.items = NonNullList.withSize(36, ItemStack.EMPTY); + this.armor = NonNullList.withSize(4, ItemStack.EMPTY); @@ -63,6 +118,28 @@ - return !itemstack.isEmpty() && ItemStack.e(itemstack, itemstack1) && itemstack.isStackable() && itemstack.getCount() < itemstack.getMaxStackSize() && itemstack.getCount() < this.getMaxStackSize(); + return !itemstack.isEmpty() && ItemStack.isSameItemSameTags(itemstack, itemstack1) && itemstack.isStackable() && itemstack.getCount() < itemstack.getMaxStackSize() && itemstack.getCount() < this.getMaxStackSize(); } + // CraftBukkit start - Watch method above! :D @@ -80,13 +80,13 @@ + ItemStack itemstack1 = this.getItem(i); + if (itemstack1.isEmpty()) return itemstack.getCount(); + -+ if (this.isSimilarAndNotFull(itemstack1, itemstack)) { ++ if (this.hasRemainingSpaceForItem(itemstack1, itemstack)) { + remains -= (itemstack1.getMaxStackSize() < this.getMaxStackSize() ? itemstack1.getMaxStackSize() : this.getMaxStackSize()) - itemstack1.getCount(); + } + if (remains <= 0) return itemstack.getCount(); + } + ItemStack offhandItemStack = this.getItem(this.items.size() + this.armor.size()); -+ if (this.isSimilarAndNotFull(offhandItemStack, itemstack)) { ++ if (this.hasRemainingSpaceForItem(offhandItemStack, itemstack)) { + remains -= (offhandItemStack.getMaxStackSize() < this.getMaxStackSize() ? offhandItemStack.getMaxStackSize() : this.getMaxStackSize()) - offhandItemStack.getCount(); + } + if (remains <= 0) return itemstack.getCount(); @@ -95,6 +95,6 @@ + } + // CraftBukkit end + - public int getFirstEmptySlotIndex() { + public int getFreeSlot() { for (int i = 0; i < this.items.size(); ++i) { if (((ItemStack) this.items.get(i)).isEmpty()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch index 03401f5b46..3406641de9 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch @@ -17,35 +17,35 @@ } if (object != null && !flag) { -- this.a((MovingObjectPosition) object); +- this.onHit((MovingObjectPosition) object); + this.preOnHit((MovingObjectPosition) object); // CraftBukkit - projectile hit event this.hasImpulse = true; } @@ -357,7 +363,13 @@ - int k = entity.getFireTicks(); + int k = entity.getRemainingFireTicks(); - if (this.isBurning() && !flag) { -- entity.setOnFire(5); + if (this.isOnFire() && !flag) { +- entity.setSecondsOnFire(5); + // CraftBukkit start + EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 5); + org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); + if (!combustEvent.isCancelled()) { -+ entity.setOnFire(combustEvent.getDuration(), false); ++ entity.setSecondsOnFire(combustEvent.getDuration(), false); + } + // CraftBukkit end } - if (entity.damageEntity(damagesource, (float) i)) { + if (entity.hurt(damagesource, (float) i)) { @@ -519,7 +531,22 @@ @Override - public void pickup(EntityHuman entityhuman) { - if (!this.level.isClientSide && (this.inGround || this.t()) && this.shakeTime <= 0) { -- if (this.a(entityhuman)) { + public void playerTouch(EntityHuman entityhuman) { + if (!this.level.isClientSide && (this.inGround || this.isNoPhysics()) && this.shakeTime <= 0) { +- if (this.tryPickup(entityhuman)) { + // CraftBukkit start -+ ItemStack itemstack = this.getItemStack(); ++ ItemStack itemstack = this.getPickupItem(); + if (this.pickup == PickupStatus.ALLOWED && !itemstack.isEmpty() && entityhuman.getInventory().canHold(itemstack) > 0) { -+ EntityItem item = new EntityItem(this.level, this.locX(), this.locY(), this.locZ(), itemstack); ++ EntityItem item = new EntityItem(this.level, this.getX(), this.getY(), this.getZ(), itemstack); + PlayerPickupArrowEvent event = new PlayerPickupArrowEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.level.getCraftServer(), this, item), (org.bukkit.entity.AbstractArrow) this.getBukkitEntity()); + // event.setCancelled(!entityhuman.canPickUpLoot); TODO + this.level.getCraftServer().getPluginManager().callEvent(event); @@ -53,11 +53,11 @@ + if (event.isCancelled()) { + return; + } -+ itemstack = item.getItemStack(); ++ itemstack = item.getItem(); + } + -+ if ((this.pickup == EntityArrow.PickupStatus.ALLOWED && entityhuman.getInventory().pickup(itemstack)) || (this.pickup == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.getAbilities().instabuild)) { ++ if ((this.pickup == EntityArrow.PickupStatus.ALLOWED && entityhuman.getInventory().add(itemstack)) || (this.pickup == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.getAbilities().instabuild)) { + // CraftBukkit end - entityhuman.receive(this, 1); - this.die(); + entityhuman.take(this, 1); + this.discard(); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch index 2a6ea1b96f..9ae1ff9191 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch @@ -17,8 +17,8 @@ public EntityEgg(EntityTypes<? extends EntityEgg> entitytypes, World world) { @@ -48,20 +57,40 @@ - protected void a(MovingObjectPosition movingobjectposition) { - super.a(movingobjectposition); + protected void onHit(MovingObjectPosition movingobjectposition) { + super.onHit(movingobjectposition); if (!this.level.isClientSide) { - if (this.random.nextInt(8) == 0) { + boolean hatching = this.random.nextInt(8) == 0; // CraftBukkit @@ -30,14 +30,14 @@ } - for (int i = 0; i < b0; ++i) { -- EntityChicken entitychicken = (EntityChicken) EntityTypes.CHICKEN.a(this.level); +- EntityChicken entitychicken = (EntityChicken) EntityTypes.CHICKEN.create(this.level); + // CraftBukkit start + if (!hatching) { + b0 = 0; + } + EntityType hatchingType = EntityType.CHICKEN; + -+ Entity shooter = this.getShooter(); ++ Entity shooter = this.getOwner(); + if (shooter instanceof EntityPlayer) { + PlayerEggThrowEvent event = new PlayerEggThrowEvent((Player) shooter.getBukkitEntity(), (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, b0, hatchingType); + this.level.getCraftServer().getPluginManager().callEvent(event); @@ -47,12 +47,12 @@ + hatchingType = event.getHatchingType(); + } -- entitychicken.setAgeRaw(-24000); -- entitychicken.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.getYRot(), 0.0F); -- this.level.addEntity(entitychicken); +- entitychicken.setAge(-24000); +- entitychicken.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F); +- this.level.addFreshEntity(entitychicken); + if (hatching) { + for (int i = 0; i < b0; ++i) { -+ Entity entity = level.getWorld().createEntity(new org.bukkit.Location(level.getWorld(), this.locX(), this.locY(), this.locZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass()); ++ Entity entity = level.getWorld().createEntity(new org.bukkit.Location(level.getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass()); + if (entity.getBukkitEntity() instanceof Ageable) { + ((Ageable) entity.getBukkitEntity()).setBaby(); + } @@ -62,4 +62,4 @@ + // CraftBukkit end } - this.level.broadcastEntityEffect(this, (byte) 3); + this.level.broadcastEntityEvent(this, (byte) 3); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch index 8be5e916f7..a9d191d1c4 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch @@ -17,12 +17,12 @@ @@ -53,21 +60,34 @@ EntityPlayer entityplayer = (EntityPlayer) entity; - if (entityplayer.connection.a().isConnected() && entityplayer.level == this.level && !entityplayer.isSleeping()) { + if (entityplayer.connection.getConnection().isConnected() && entityplayer.level == this.level && !entityplayer.isSleeping()) { - if (this.random.nextFloat() < 0.05F && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { -- EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.a(this.level); +- EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(this.level); - -- entityendermite.setPositionRotation(entity.locX(), entity.locY(), entity.locZ(), entity.getYRot(), entity.getXRot()); -- this.level.addEntity(entityendermite); +- entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); +- this.level.addFreshEntity(entityendermite); + // CraftBukkit start - Fire PlayerTeleportEvent + org.bukkit.craftbukkit.entity.CraftPlayer player = entityplayer.getBukkitEntity(); + org.bukkit.Location location = getBukkitEntity().getLocation(); @@ -34,10 +34,10 @@ + + if (!teleEvent.isCancelled() && !entityplayer.connection.isDisconnected()) { + if (this.random.nextFloat() < 0.05F && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { -+ EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.a(this.level); ++ EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(this.level); + -+ entityendermite.setPositionRotation(entity.locX(), entity.locY(), entity.locZ(), entity.getYRot(), entity.getXRot()); -+ this.level.addEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL); ++ entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); ++ this.level.addFreshEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL); + } + + if (entity.isPassenger()) { @@ -45,30 +45,30 @@ + } + + entityplayer.connection.teleport(teleEvent.getTo()); -+ entity.fallDistance = 0.0F; ++ entity.resetFallDistance(); + CraftEventFactory.entityDamage = this; -+ entity.damageEntity(DamageSource.FALL, 5.0F); ++ entity.hurt(DamageSource.FALL, 5.0F); + CraftEventFactory.entityDamage = null; } - - if (entity.isPassenger()) { -- entityplayer.a(this.locX(), this.locY(), this.locZ()); +- entityplayer.dismountTo(this.getX(), this.getY(), this.getZ()); - } else { -- entity.enderTeleportTo(this.locX(), this.locY(), this.locZ()); +- entity.teleportTo(this.getX(), this.getY(), this.getZ()); - } - -- entity.fallDistance = 0.0F; -- entity.damageEntity(DamageSource.FALL, 5.0F); +- entity.resetFallDistance(); +- entity.hurt(DamageSource.FALL, 5.0F); + // CraftBukkit end } } else if (entity != null) { - entity.enderTeleportTo(this.locX(), this.locY(), this.locZ()); + entity.teleportTo(this.getX(), this.getY(), this.getZ()); @@ -96,7 +116,7 @@ - public Entity b(WorldServer worldserver) { - Entity entity = this.getShooter(); + public Entity changeDimension(WorldServer worldserver) { + Entity entity = this.getOwner(); -- if (entity != null && entity.level.getDimensionKey() != worldserver.getDimensionKey()) { -+ if (entity != null && worldserver != null && entity.level.getDimensionKey() != worldserver.getDimensionKey()) { // CraftBukkit - SPIGOT-6113 - this.setShooter((Entity) null); +- if (entity != null && entity.level.dimension() != worldserver.dimension()) { ++ if (entity != null && worldserver != null && entity.level.dimension() != worldserver.dimension()) { // CraftBukkit - SPIGOT-6113 + this.setOwner((Entity) null); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEnderSignal.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEnderSignal.patch index 23f6951e0e..c6c2cbd0cb 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEnderSignal.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEnderSignal.patch @@ -1,19 +1,17 @@ --- a/net/minecraft/world/entity/projectile/EntityEnderSignal.java +++ b/net/minecraft/world/entity/projectile/EntityEnderSignal.java -@@ -38,8 +38,8 @@ +@@ -38,7 +38,7 @@ } public void setItem(ItemStack itemstack) { -- if (!itemstack.a(Items.ENDER_EYE) || itemstack.hasTag()) { -- this.getDataWatcher().set(EntityEnderSignal.DATA_ITEM_STACK, (ItemStack) SystemUtils.a((Object) itemstack.cloneItemStack(), (itemstack1) -> { -+ if (true || !itemstack.a(Items.ENDER_EYE) || itemstack.hasTag()) { // CraftBukkit - always allow item changing -+ this.getDataWatcher().set(EntityEnderSignal.DATA_ITEM_STACK, (ItemStack) SystemUtils.a(itemstack.cloneItemStack(), (itemstack1) -> { // CraftBukkit - decompile error +- if (!itemstack.is(Items.ENDER_EYE) || itemstack.hasTag()) { ++ if (true || !itemstack.is(Items.ENDER_EYE) || itemstack.hasTag()) { // CraftBukkit - always allow item changing + this.getEntityData().set(EntityEnderSignal.DATA_ITEM_STACK, (ItemStack) SystemUtils.make(itemstack.copy(), (itemstack1) -> { itemstack1.setCount(1); })); - } @@ -182,7 +182,7 @@ - public void loadData(NBTTagCompound nbttagcompound) { - ItemStack itemstack = ItemStack.a(nbttagcompound.getCompound("Item")); + public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { + ItemStack itemstack = ItemStack.of(nbttagcompound.getCompound("Item")); - this.setItem(itemstack); + if (!itemstack.isEmpty()) this.setItem(itemstack); // CraftBukkit - SPIGOT-6103 summon, see also SPIGOT-5474 diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch index 0cf621ef73..3dd3b632d5 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch @@ -5,8 +5,8 @@ if (entityliving.isAlive() && !entityliving.isInvulnerable() && entityliving != entityliving1) { if (entityliving1 == null) { + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = this; // CraftBukkit - entityliving.damageEntity(DamageSource.MAGIC, 6.0F); + entityliving.hurt(DamageSource.MAGIC, 6.0F); + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = null; // CraftBukkit } else { - if (entityliving1.p(entityliving)) { + if (entityliving1.isAlliedTo((Entity) entityliving)) { return; diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch index d257920a15..03c3772dcd 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch @@ -18,8 +18,8 @@ super(entitytypes, world); @@ -28,6 +32,12 @@ this(entitytypes, world); - this.setPositionRotation(d0, d1, d2, this.getYRot(), this.getXRot()); - this.ah(); + this.moveTo(d0, d1, d2, this.getYRot(), this.getXRot()); + this.reapplyPosition(); + // CraftBukkit start - Added setDirection method + this.setDirection(d3, d4, d5); + } @@ -30,10 +30,10 @@ if (d6 != 0.0D) { @@ -74,7 +84,13 @@ - MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a); + MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity); if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { -- this.a(movingobjectposition); +- this.onHit(movingobjectposition); + this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event + + // CraftBukkit start - Fire ProjectileHitEvent @@ -43,7 +43,7 @@ + // CraftBukkit end } - this.checkBlockCollisions(); + this.checkInsideBlocks(); @@ -159,6 +175,11 @@ Entity entity = damagesource.getEntity(); @@ -53,6 +53,6 @@ + return false; + } + // CraftBukkit end - Vec3D vec3d = entity.getLookDirection(); + Vec3D vec3d = entity.getLookAngle(); - this.setMot(vec3d); + this.setDeltaMovement(vec3d); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch index be69451da7..cd494a2b34 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch @@ -1,17 +1,8 @@ --- a/net/minecraft/world/entity/projectile/EntityFireballFireball.java +++ b/net/minecraft/world/entity/projectile/EntityFireballFireball.java -@@ -29,7 +29,7 @@ - - public void setItem(ItemStack itemstack) { - if (!itemstack.a(Items.FIRE_CHARGE) || itemstack.hasTag()) { -- this.getDataWatcher().set(EntityFireballFireball.DATA_ITEM_STACK, (ItemStack) SystemUtils.a((Object) itemstack.cloneItemStack(), (itemstack1) -> { -+ this.getDataWatcher().set(EntityFireballFireball.DATA_ITEM_STACK, (ItemStack) SystemUtils.a(itemstack.cloneItemStack(), (itemstack1) -> { // CraftBukkit - decompile error - itemstack1.setCount(1); - })); - } @@ -68,6 +68,6 @@ - super.loadData(nbttagcompound); - ItemStack itemstack = ItemStack.a(nbttagcompound.getCompound("Item")); + super.readAdditionalSaveData(nbttagcompound); + ItemStack itemstack = ItemStack.of(nbttagcompound.getCompound("Item")); - this.setItem(itemstack); + if (!itemstack.isEmpty()) this.setItem(itemstack); // CraftBukkit - SPIGOT-5474 probably came from bugged earlier versions diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch index 96e6ee9d8b..94cd2d75ac 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch @@ -8,12 +8,12 @@ + public class EntityFireworks extends IProjectile implements ItemSupplier { - public static final DataWatcherObject<ItemStack> DATA_ID_FIREWORKS_ITEM = DataWatcher.a(EntityFireworks.class, DataWatcherRegistry.ITEM_STACK); + public static final DataWatcherObject<ItemStack> DATA_ID_FIREWORKS_ITEM = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.ITEM_STACK); @@ -141,7 +143,7 @@ - MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a); + MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity); if (!this.noPhysics) { -- this.a(movingobjectposition); +- this.onHit(movingobjectposition); + this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event this.hasImpulse = true; } @@ -32,8 +32,8 @@ } @@ -172,7 +178,11 @@ - protected void a(MovingObjectPositionEntity movingobjectpositionentity) { - super.a(movingobjectpositionentity); + protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) { + super.onHitEntity(movingobjectpositionentity); if (!this.level.isClientSide) { - this.explode(); + // CraftBukkit start @@ -46,8 +46,8 @@ @@ -182,7 +192,11 @@ - this.level.getType(blockposition).a(this.level, blockposition, (Entity) this); - if (!this.level.isClientSide() && this.hasExplosions()) { + this.level.getBlockState(blockposition).entityInside(this.level, blockposition, this); + if (!this.level.isClientSide() && this.hasExplosion()) { - this.explode(); + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { @@ -56,23 +56,23 @@ + // CraftBukkit end } - super.a(movingobjectpositionblock); + super.onHitBlock(movingobjectpositionblock); @@ -208,7 +222,9 @@ if (f > 0.0F) { if (this.attachedToEntity != null) { + CraftEventFactory.entityDamage = this; // CraftBukkit - this.attachedToEntity.damageEntity(DamageSource.a(this, this.getShooter()), 5.0F + (float) (nbttaglist.size() * 2)); + this.attachedToEntity.hurt(DamageSource.fireworks(this, this.getOwner()), 5.0F + (float) (nbttaglist.size() * 2)); + CraftEventFactory.entityDamage = null; // CraftBukkit } double d0 = 5.0D; @@ -235,7 +251,9 @@ if (flag) { - float f1 = f * (float) Math.sqrt((5.0D - (double) this.e((Entity) entityliving)) / 5.0D); + float f1 = f * (float) Math.sqrt((5.0D - (double) this.distanceTo(entityliving)) / 5.0D); + CraftEventFactory.entityDamage = this; // CraftBukkit - entityliving.damageEntity(DamageSource.a(this, this.getShooter()), f1); + entityliving.hurt(DamageSource.fireworks(this, this.getOwner()), f1); + CraftEventFactory.entityDamage = null; // CraftBukkit } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch index 7323abaef8..31c61c199a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch +++ b/paper-server/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 -@@ -45,6 +45,12 @@ +@@ -44,6 +44,12 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -13,7 +13,7 @@ public class EntityFishingHook extends IProjectile { private final Random syncronizedRandom; -@@ -65,6 +71,12 @@ +@@ -64,6 +70,12 @@ private final int luck; private final int lureSpeed; @@ -26,41 +26,41 @@ private EntityFishingHook(EntityTypes<? extends EntityFishingHook> entitytypes, World world, int i, int j) { super(entitytypes, world); this.syncronizedRandom = new Random(); -@@ -259,7 +271,7 @@ - private void l() { - MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a); +@@ -258,7 +270,7 @@ + private void checkCollision() { + MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity); -- this.a(movingobjectposition); +- this.onHit(movingobjectposition); + this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event } @Override -@@ -306,6 +318,10 @@ +@@ -305,6 +317,10 @@ this.timeUntilLured = 0; this.timeUntilHooked = 0; - this.getDataWatcher().set(EntityFishingHook.DATA_BITING, false); + this.getEntityData().set(EntityFishingHook.DATA_BITING, false); + // CraftBukkit start -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.getOwner().getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT); ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.getPlayerOwner().getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT); + this.level.getCraftServer().getPluginManager().callEvent(playerFishEvent); + // CraftBukkit end } } else { float f; -@@ -339,6 +355,13 @@ - worldserver.a(Particles.FISHING, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D); +@@ -338,6 +354,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.getOwner().getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.BITE); ++ 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.locY() + 0.5D; + double d3 = this.getY() + 0.5D; -@@ -375,8 +398,10 @@ +@@ -374,8 +397,10 @@ this.timeUntilHooked = MathHelper.nextInt(this.random, 20, 80); } } else { @@ -73,7 +73,7 @@ } } -@@ -443,6 +468,14 @@ +@@ -442,6 +467,14 @@ int i = 0; if (this.hookedIn != null) { @@ -85,13 +85,13 @@ + return 0; + } + // CraftBukkit end - this.reel(this.hookedIn); - CriterionTriggers.FISHING_ROD_HOOKED.a((EntityPlayer) entityhuman, itemstack, this, (Collection) Collections.emptyList()); - this.level.broadcastEntityEffect(this, (byte) 31); -@@ -458,6 +491,15 @@ + this.pullEntity(this.hookedIn); + CriterionTriggers.FISHING_ROD_HOOKED.trigger((EntityPlayer) entityhuman, itemstack, this, Collections.emptyList()); + this.level.broadcastEntityEvent(this, (byte) 31); +@@ -457,6 +490,15 @@ while (iterator.hasNext()) { ItemStack itemstack1 = (ItemStack) iterator.next(); - EntityItem entityitem = new EntityItem(this.level, this.locX(), this.locY(), this.locZ(), itemstack1); + 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); + playerFishEvent.setExpToDrop(this.random.nextInt(6) + 1); @@ -101,23 +101,23 @@ + return 0; + } + // CraftBukkit end - double d0 = entityhuman.locX() - this.locX(); - double d1 = entityhuman.locY() - this.locY(); - double d2 = entityhuman.locZ() - this.locZ(); -@@ -465,7 +507,11 @@ + double d0 = entityhuman.getX() - this.getX(); + double d1 = entityhuman.getY() - this.getY(); + double d2 = entityhuman.getZ() - this.getZ(); +@@ -464,7 +506,11 @@ - entityitem.setMot(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D); - this.level.addEntity(entityitem); -- entityhuman.level.addEntity(new EntityExperienceOrb(entityhuman.level, entityhuman.locX(), entityhuman.locY() + 0.5D, entityhuman.locZ() + 0.5D, this.random.nextInt(6) + 1)); + 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); +- entityhuman.level.addFreshEntity(new EntityExperienceOrb(entityhuman.level, entityhuman.getX(), entityhuman.getY() + 0.5D, entityhuman.getZ() + 0.5D, this.random.nextInt(6) + 1)); + // CraftBukkit start - this.random.nextInt(6) + 1 -> playerFishEvent.getExpToDrop() + if (playerFishEvent.getExpToDrop() > 0) { -+ entityhuman.level.addEntity(new EntityExperienceOrb(entityhuman.level, entityhuman.locX(), entityhuman.locY() + 0.5D, entityhuman.locZ() + 0.5D, playerFishEvent.getExpToDrop())); ++ entityhuman.level.addFreshEntity(new EntityExperienceOrb(entityhuman.level, entityhuman.getX(), entityhuman.getY() + 0.5D, entityhuman.getZ() + 0.5D, playerFishEvent.getExpToDrop())); + } + // CraftBukkit end - if (itemstack1.a((Tag) TagsItem.FISHES)) { - entityhuman.a(StatisticList.FISH_CAUGHT, 1); + if (itemstack1.is((Tag) TagsItem.FISHES)) { + entityhuman.awardStat(StatisticList.FISH_CAUGHT, 1); } -@@ -475,8 +521,25 @@ +@@ -474,8 +520,25 @@ } if (this.onGround) { @@ -141,5 +141,5 @@ + } + // CraftBukkit end - this.die(); + this.discard(); return i; diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch index b55bc1c47b..9cad1f9bc9 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch @@ -26,23 +26,23 @@ if (!this.level.isClientSide) { boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); -- this.level.createExplosion((Entity) null, this.locX(), this.locY(), this.locZ(), (float) this.explosionPower, flag, flag ? Explosion.Effect.DESTROY : Explosion.Effect.NONE); +- this.level.explode((Entity) null, this.getX(), this.getY(), this.getZ(), (float) this.explosionPower, flag, flag ? Explosion.Effect.DESTROY : Explosion.Effect.NONE); + // CraftBukkit start - fire ExplosionPrimeEvent + ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); + this.level.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + // give 'this' instead of (Entity) null so we know what causes the damage -+ this.level.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), flag ? Explosion.Effect.DESTROY : Explosion.Effect.NONE); ++ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), flag ? Explosion.Effect.DESTROY : Explosion.Effect.NONE); + } + // CraftBukkit end - this.die(); + this.discard(); } @@ -61,7 +73,8 @@ - public void loadData(NBTTagCompound nbttagcompound) { - super.loadData(nbttagcompound); - if (nbttagcompound.hasKeyOfType("ExplosionPower", 99)) { + 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"); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch index 10ba71ae90..4bc2d3b3fb 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/EntityLlamaSpit.java +++ b/net/minecraft/world/entity/projectile/EntityLlamaSpit.java @@ -33,7 +33,7 @@ - Vec3D vec3d = this.getMot(); - MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a); + Vec3D vec3d = this.getDeltaMovement(); + MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity); -- this.a(movingobjectposition); +- this.onHit(movingobjectposition); + this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event - double d0 = this.locX() + vec3d.x; - double d1 = this.locY() + vec3d.y; - double d2 = this.locZ() + vec3d.z; + double d0 = this.getX() + vec3d.x; + double d1 = this.getY() + vec3d.y; + double d2 = this.getZ() + vec3d.z; diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch index 5f7d0a9712..d16d6d4aea 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch +++ b/paper-server/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 -@@ -34,6 +34,16 @@ +@@ -33,6 +33,16 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.MovingObjectPositionEntity; @@ -17,24 +17,24 @@ public class EntityPotion extends EntityProjectileThrowable implements ItemSupplier { public static final double SPLASH_RANGE = 4.0D; -@@ -100,7 +110,7 @@ +@@ -99,7 +109,7 @@ if (flag) { - this.splash(); + this.applyWater(); - } else if (!list.isEmpty()) { + } else if (true || !list.isEmpty()) { // CraftBukkit - Call event even if no effects to apply if (this.isLingering()) { - this.a(itemstack, potionregistry); + this.makeAreaOfEffectCloud(itemstack, potionregistry); } else { -@@ -146,6 +156,7 @@ - private void a(List<MobEffect> list, @Nullable Entity entity) { - AxisAlignedBB axisalignedbb = this.getBoundingBox().grow(4.0D, 2.0D, 4.0D); - List<EntityLiving> list1 = this.level.a(EntityLiving.class, axisalignedbb); +@@ -145,6 +155,7 @@ + private void applySplash(List<MobEffect> list, @Nullable Entity entity) { + AxisAlignedBB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D); + List<EntityLiving> list1 = this.level.getEntitiesOfClass(EntityLiving.class, axisalignedbb); + Map<LivingEntity, Double> affected = new HashMap<LivingEntity, Double>(); // CraftBukkit if (!list1.isEmpty()) { - Entity entity1 = this.x(); -@@ -164,21 +175,47 @@ + Entity entity1 = this.getEffectSource(); +@@ -163,21 +174,47 @@ d1 = 1.0D; } @@ -48,7 +48,7 @@ + + org.bukkit.event.entity.PotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPotionSplashEvent(this, affected); + if (!event.isCancelled() && list != null && !list.isEmpty()) { // do not process effects if there are no effects to process -+ Entity entity1 = this.x(); ++ Entity entity1 = this.getEffectSource(); + for (LivingEntity victim : event.getAffectedEntities()) { + if (!(victim instanceof CraftLivingEntity)) { + continue; @@ -62,9 +62,9 @@ + + while (iterator1.hasNext()) { + MobEffect mobeffect = (MobEffect) iterator1.next(); -+ MobEffectList mobeffectlist = mobeffect.getMobEffect(); ++ MobEffectList mobeffectlist = mobeffect.getEffect(); + // CraftBukkit start - Abide by PVP settings - for players only! -+ if (!this.level.pvpMode && this.getShooter() instanceof EntityPlayer && entityliving instanceof EntityPlayer && entityliving != this.getShooter()) { ++ if (!this.level.pvpMode && this.getOwner() instanceof EntityPlayer && entityliving instanceof EntityPlayer && entityliving != this.getOwner()) { + int i = MobEffectList.getId(mobeffectlist); + // Block SLOWER_MOVEMENT, SLOWER_DIG, HARM, BLINDNESS, HUNGER, WEAKNESS and POISON potions + if (i == 2 || i == 4 || i == 7 || i == 15 || i == 17 || i == 18 || i == 19) { @@ -73,71 +73,71 @@ + } + // CraftBukkit end + -+ if (mobeffectlist.isInstant()) { -+ mobeffectlist.applyInstantEffect(this, this.getShooter(), entityliving, mobeffect.getAmplifier(), d1); ++ if (mobeffectlist.isInstantenous()) { ++ mobeffectlist.applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect.getAmplifier(), d1); + } else { + int i = (int) (d1 * (double) mobeffect.getDuration() + 0.5D); - while (iterator1.hasNext()) { - MobEffect mobeffect = (MobEffect) iterator1.next(); -- MobEffectList mobeffectlist = mobeffect.getMobEffect(); +- MobEffectList mobeffectlist = mobeffect.getEffect(); - -- if (mobeffectlist.isInstant()) { -- mobeffectlist.applyInstantEffect(this, this.getShooter(), entityliving, mobeffect.getAmplifier(), d1); +- if (mobeffectlist.isInstantenous()) { +- mobeffectlist.applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect.getAmplifier(), d1); - } else { - int i = (int) (d1 * (double) mobeffect.getDuration() + 0.5D); - - if (i > 20) { -- entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isShowParticles()), entity1); +- entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible()), entity1); - } - } + if (i > 20) { -+ entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isShowParticles()), entity1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_SPLASH); // CraftBukkit ++ entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible()), entity1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_SPLASH); // CraftBukkit } } } -@@ -214,7 +251,14 @@ - entityareaeffectcloud.setColor(nbttagcompound.getInt("CustomPotionColor")); +@@ -213,7 +250,14 @@ + entityareaeffectcloud.setFixedColor(nbttagcompound.getInt("CustomPotionColor")); } -- this.level.addEntity(entityareaeffectcloud); +- this.level.addFreshEntity(entityareaeffectcloud); + // CraftBukkit start + org.bukkit.event.entity.LingeringPotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callLingeringPotionSplashEvent(this, entityareaeffectcloud); + if (!(event.isCancelled() || entityareaeffectcloud.isRemoved())) { -+ this.level.addEntity(entityareaeffectcloud); ++ this.level.addFreshEntity(entityareaeffectcloud); + } else { -+ entityareaeffectcloud.die(); ++ entityareaeffectcloud.discard(); + } + // CraftBukkit end } public boolean isLingering() { -@@ -225,13 +269,25 @@ - IBlockData iblockdata = this.level.getType(blockposition); +@@ -224,13 +268,25 @@ + IBlockData iblockdata = this.level.getBlockState(blockposition); - if (iblockdata.a((Tag) TagsBlock.FIRE)) { -- this.level.a(blockposition, false); + if (iblockdata.is((Tag) TagsBlock.FIRE)) { +- this.level.removeBlock(blockposition, false); + // CraftBukkit start -+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { -+ this.level.a(blockposition, false); ++ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { ++ this.level.removeBlock(blockposition, false); + } + // CraftBukkit end - } else if (AbstractCandleBlock.b(iblockdata)) { -- AbstractCandleBlock.a((EntityHuman) null, iblockdata, (GeneratorAccess) this.level, blockposition); + } else if (AbstractCandleBlock.isLit(iblockdata)) { +- AbstractCandleBlock.extinguish((EntityHuman) null, iblockdata, this.level, blockposition); + // CraftBukkit start -+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.set(AbstractCandleBlock.LIT, false)).isCancelled()) { -+ AbstractCandleBlock.a((EntityHuman) null, iblockdata, (GeneratorAccess) this.level, blockposition); ++ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.setValue(AbstractCandleBlock.LIT, false)).isCancelled()) { ++ AbstractCandleBlock.extinguish((EntityHuman) null, iblockdata, this.level, blockposition); + } + // CraftBukkit end - } else if (BlockCampfire.g(iblockdata)) { -- this.level.a((EntityHuman) null, 1009, blockposition, 0); -- BlockCampfire.a(this.getShooter(), (GeneratorAccess) this.level, blockposition, iblockdata); -- this.level.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockCampfire.LIT, false)); + } else if (BlockCampfire.isLitCampfire(iblockdata)) { +- this.level.levelEvent((EntityHuman) 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.set(BlockCampfire.LIT, false)).isCancelled()) { -+ this.level.a((EntityHuman) null, 1009, blockposition, 0); -+ BlockCampfire.a(this.getShooter(), (GeneratorAccess) this.level, blockposition, iblockdata); -+ this.level.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockCampfire.LIT, false)); ++ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.setValue(BlockCampfire.LIT, false)).isCancelled()) { ++ this.level.levelEvent((EntityHuman) null, 1009, blockposition, 0); ++ BlockCampfire.dowse(this.getOwner(), this.level, blockposition, iblockdata); ++ this.level.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(BlockCampfire.LIT, false)); + } + // CraftBukkit end } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch index 152dc67986..eacc230d95 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/EntityProjectile.java +++ b/net/minecraft/world/entity/projectile/EntityProjectile.java -@@ -67,7 +67,7 @@ +@@ -66,7 +66,7 @@ } if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS && !flag) { -- this.a(movingobjectposition); +- this.onHit(movingobjectposition); + this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event } - this.checkBlockCollisions(); + this.checkInsideBlocks(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityProjectileThrowable.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityProjectileThrowable.patch index 04863418ed..2fc626827a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityProjectileThrowable.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityProjectileThrowable.patch @@ -1,12 +1,10 @@ --- a/net/minecraft/world/entity/projectile/EntityProjectileThrowable.java +++ b/net/minecraft/world/entity/projectile/EntityProjectileThrowable.java -@@ -29,8 +29,8 @@ - +@@ -30,7 +30,7 @@ public void setItem(ItemStack itemstack) { - if (!itemstack.a(this.getDefaultItem()) || itemstack.hasTag()) { -- this.getDataWatcher().set(EntityProjectileThrowable.DATA_ITEM_STACK, (ItemStack) SystemUtils.a((Object) itemstack.cloneItemStack(), (itemstack1) -> { + if (!itemstack.is(this.getDefaultItem()) || itemstack.hasTag()) { + this.getEntityData().set(EntityProjectileThrowable.DATA_ITEM_STACK, (ItemStack) SystemUtils.make(itemstack.copy(), (itemstack1) -> { - itemstack1.setCount(1); -+ this.getDataWatcher().set(EntityProjectileThrowable.DATA_ITEM_STACK, (ItemStack) SystemUtils.a(itemstack.cloneItemStack(), (itemstack1) -> { // CraftBukkit - decompile error + if (!itemstack1.isEmpty()) itemstack1.setCount(1); // CraftBukkit })); } @@ -21,6 +19,6 @@ + } + // CraftBukkit end + - public ItemStack getItem() { - return (ItemStack) this.getDataWatcher().get(EntityProjectileThrowable.DATA_ITEM_STACK); + public ItemStack getItemRaw() { + return (ItemStack) this.getEntityData().get(EntityProjectileThrowable.DATA_ITEM_STACK); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch index 6a0ccc5152..fc6bd22f7c 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch @@ -3,7 +3,7 @@ @@ -60,8 +60,21 @@ this.finalTarget = entity; this.currentMoveDirection = EnumDirection.UP; - this.a(enumdirection_enumaxis); + this.selectNextMoveDirection(enumdirection_enumaxis); + projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit } @@ -15,25 +15,25 @@ + public void setTarget(Entity e) { + this.finalTarget = e; + this.currentMoveDirection = EnumDirection.UP; -+ this.a(EnumDirection.EnumAxis.X); ++ this.selectNextMoveDirection(EnumDirection.EnumAxis.X); + } + // CraftBukkit end + @Override - public SoundCategory getSoundCategory() { + public SoundCategory getSoundSource() { return SoundCategory.HOSTILE; @@ -225,7 +238,7 @@ - MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a); + MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity); if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { -- this.a(movingobjectposition); +- this.onHit(movingobjectposition); + this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event } } @@ -292,7 +305,7 @@ if (flag) { - this.a(entityliving, entity); + this.doEnchantDamageEffects(entityliving, entity); if (entity instanceof EntityLiving) { - ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.LEVITATION, 200), (Entity) MoreObjects.firstNonNull(entity1, this)); + ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.LEVITATION, 200), (Entity) MoreObjects.firstNonNull(entity1, this), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit @@ -43,7 +43,7 @@ @@ -318,6 +331,11 @@ @Override - public boolean damageEntity(DamageSource damagesource, float f) { + public boolean hurt(DamageSource damagesource, float f) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false)) { + return false; @@ -51,4 +51,4 @@ + // CraftBukkit end if (!this.level.isClientSide) { this.playSound(SoundEffects.SHULKER_BULLET_HURT, 1.0F, 1.0F); - ((WorldServer) this.level).a(Particles.CRIT, this.locX(), this.locY(), this.locZ(), 15, 0.2D, 0.2D, 0.2D, 0.0D); + ((WorldServer) this.level).sendParticles(Particles.CRIT, this.getX(), this.getY(), this.getZ(), 15, 0.2D, 0.2D, 0.2D, 0.0D); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch index c74e8fdc4e..794a283066 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntitySmallFireball.java +++ b/net/minecraft/world/entity/projectile/EntitySmallFireball.java -@@ -14,6 +14,8 @@ +@@ -13,6 +13,8 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.MovingObjectPositionEntity; @@ -9,44 +9,44 @@ public class EntitySmallFireball extends EntityFireballFireball { public EntitySmallFireball(EntityTypes<? extends EntitySmallFireball> entitytypes, World world) { -@@ -22,6 +24,11 @@ +@@ -21,6 +23,11 @@ public EntitySmallFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) { super(EntityTypes.SMALL_FIREBALL, entityliving, d0, d1, d2, world); + // CraftBukkit start -+ if (this.getShooter() != null && this.getShooter() instanceof EntityInsentient) { ++ if (this.getOwner() != null && this.getOwner() instanceof EntityInsentient) { + isIncendiary = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); + } + // CraftBukkit end } public EntitySmallFireball(World world, double d0, double d1, double d2, double d3, double d4, double d5) { -@@ -38,7 +45,14 @@ - Entity entity1 = this.getShooter(); - int i = entity.getFireTicks(); +@@ -37,7 +44,14 @@ + Entity entity1 = this.getOwner(); + int i = entity.getRemainingFireTicks(); -- entity.setOnFire(5); +- entity.setSecondsOnFire(5); + // CraftBukkit start - Entity damage by entity event + combust event + EntityCombustByEntityEvent event = new EntityCombustByEntityEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), entity.getBukkitEntity(), 5); + entity.level.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ entity.setOnFire(event.getDuration(), false); ++ entity.setSecondsOnFire(event.getDuration(), false); + } + // CraftBukkit end - boolean flag = entity.damageEntity(DamageSource.fireball(this, entity1), 5.0F); + boolean flag = entity.hurt(DamageSource.fireball(this, entity1), 5.0F); if (!flag) { -@@ -57,10 +71,10 @@ +@@ -56,10 +70,10 @@ if (!this.level.isClientSide) { - Entity entity = this.getShooter(); + Entity entity = this.getOwner(); - if (!(entity instanceof EntityInsentient) || this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (isIncendiary) { // CraftBukkit - BlockPosition blockposition = movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()); + BlockPosition blockposition = movingobjectpositionblock.getBlockPos().relative(movingobjectpositionblock.getDirection()); -- if (this.level.isEmpty(blockposition)) { -+ if (this.level.isEmpty(blockposition) && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, blockposition, this).isCancelled()) { // CraftBukkit - this.level.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) this.level, blockposition)); +- if (this.level.isEmptyBlock(blockposition)) { ++ if (this.level.isEmptyBlock(blockposition) && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, blockposition, this).isCancelled()) { // CraftBukkit + this.level.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(this.level, blockposition)); } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySpectralArrow.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySpectralArrow.patch index 9c60ba9300..606e0d004c 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySpectralArrow.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySpectralArrow.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/EntitySpectralArrow.java +++ b/net/minecraft/world/entity/projectile/EntitySpectralArrow.java @@ -45,7 +45,7 @@ - super.a(entityliving); + super.doPostHurtEffects(entityliving); MobEffect mobeffect = new MobEffect(MobEffects.GLOWING, this.duration, 0); -- entityliving.addEffect(mobeffect, this.x()); -+ entityliving.addEffect(mobeffect, this.x(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit +- entityliving.addEffect(mobeffect, this.getEffectSource()); ++ entityliving.addEffect(mobeffect, this.getEffectSource(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit } @Override diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch index 0c60c6e8a2..bc5ff7b9d5 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/world/entity/projectile/EntityThrownExpBottle.java +++ b/net/minecraft/world/entity/projectile/EntityThrownExpBottle.java @@ -39,9 +39,18 @@ - protected void a(MovingObjectPosition movingobjectposition) { - super.a(movingobjectposition); + protected void onHit(MovingObjectPosition movingobjectposition) { + super.onHit(movingobjectposition); if (this.level instanceof WorldServer) { -- this.level.triggerEffect(2002, this.getChunkCoordinates(), PotionUtil.a(Potions.WATER)); +- this.level.levelEvent(2002, this.blockPosition(), PotionUtil.getColor(Potions.WATER)); + // CraftBukkit - moved to after event -+ // this.level.triggerEffect(2002, this.getChunkCoordinates(), PotionUtil.a(Potions.WATER)); ++ // this.level.levelEvent(2002, this.blockPosition(), PotionUtil.getColor(Potions.WATER)); int i = 3 + this.level.random.nextInt(5) + this.level.random.nextInt(5); + // CraftBukkit start + org.bukkit.event.entity.ExpBottleEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callExpBottleEvent(this, i); + i = event.getExperience(); + if (event.getShowEffect()) { -+ this.level.triggerEffect(2002, this.getChunkCoordinates(), PotionUtil.a(Potions.WATER)); ++ this.level.levelEvent(2002, this.blockPosition(), PotionUtil.getColor(Potions.WATER)); + } + // CraftBukkit end + - EntityExperienceOrb.a((WorldServer) this.level, this.getPositionVector(), i); - this.die(); + EntityExperienceOrb.award((WorldServer) this.level, this.position(), i); + this.discard(); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch index 82a873c7aa..a5f75dd8c3 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/entity/projectile/EntityThrownTrident.java +++ b/net/minecraft/world/entity/projectile/EntityThrownTrident.java -@@ -157,7 +157,7 @@ +@@ -156,7 +156,7 @@ - entitylightning.d(Vec3D.c((BaseBlockPosition) blockposition)); - entitylightning.b(entity1 instanceof EntityPlayer ? (EntityPlayer) entity1 : null); -- this.level.addEntity(entitylightning); + entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition)); + entitylightning.setCause(entity1 instanceof EntityPlayer ? (EntityPlayer) entity1 : null); +- this.level.addFreshEntity(entitylightning); + ((WorldServer) this.level).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit soundeffect = SoundEffects.TRIDENT_THUNDER; f1 = 5.0F; diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch index 0ea168a49f..709a78c882 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch @@ -6,16 +6,16 @@ + // CraftBukkit start accessor methods + public void refreshEffects() { -+ this.getDataWatcher().set(EntityTippedArrow.ID_EFFECT_COLOR, PotionUtil.a((Collection) PotionUtil.a(this.potion, (Collection) this.effects))); ++ this.getEntityData().set(EntityTippedArrow.ID_EFFECT_COLOR, PotionUtil.getColor((Collection) PotionUtil.getAllEffects(this.potion, (Collection) this.effects))); + } + -+ public String getType() { ++ public String getPotionType() { + return IRegistry.POTION.getKey(this.potion).toString(); + } + -+ public void setType(String string) { ++ public void setPotionType(String string) { + this.potion = IRegistry.POTION.get(new net.minecraft.resources.MinecraftKey(string)); -+ this.getDataWatcher().set(EntityTippedArrow.ID_EFFECT_COLOR, PotionUtil.a((Collection) PotionUtil.a(this.potion, (Collection) this.effects))); ++ this.getEntityData().set(EntityTippedArrow.ID_EFFECT_COLOR, PotionUtil.getColor((Collection) PotionUtil.getAllEffects(this.potion, (Collection) this.effects))); + } + + public boolean isTipped() { @@ -30,8 +30,8 @@ while (iterator.hasNext()) { mobeffect = (MobEffect) iterator.next(); -- entityliving.addEffect(new MobEffect(mobeffect.getMobEffect(), Math.max(mobeffect.getDuration() / 8, 1), mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isShowParticles()), entity); -+ entityliving.addEffect(new MobEffect(mobeffect.getMobEffect(), Math.max(mobeffect.getDuration() / 8, 1), mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isShowParticles()), entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit +- entityliving.addEffect(new MobEffect(mobeffect.getEffect(), Math.max(mobeffect.getDuration() / 8, 1), mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible()), entity); ++ entityliving.addEffect(new MobEffect(mobeffect.getEffect(), Math.max(mobeffect.getDuration() / 8, 1), mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible()), entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit } if (!this.effects.isEmpty()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch index b4d1a985f7..bf24ae7dfa 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch @@ -8,10 +8,10 @@ + public class EntityWitherSkull extends EntityFireball { - private static final DataWatcherObject<Boolean> DATA_DANGEROUS = DataWatcher.a(EntityWitherSkull.class, DataWatcherRegistry.BOOLEAN); + private static final DataWatcherObject<Boolean> DATA_DANGEROUS = DataWatcher.defineId(EntityWitherSkull.class, DataWatcherRegistry.BOOLEAN); @@ -64,7 +66,7 @@ if (entity.isAlive()) { - this.a(entityliving, entity); + this.doEnchantDamageEffects(entityliving, entity); } else { - entityliving.heal(5.0F); + entityliving.heal(5.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.WITHER); // CraftBukkit @@ -22,8 +22,8 @@ } if (b0 > 0) { -- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1), this.x()); -+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1), this.x(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit +- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1), this.getEffectSource()); ++ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1), this.getEffectSource(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } } @@ -31,16 +31,16 @@ if (!this.level.isClientSide) { Explosion.Effect explosion_effect = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE; -- this.level.createExplosion(this, this.locX(), this.locY(), this.locZ(), 1.0F, false, explosion_effect); +- this.level.explode(this, this.getX(), this.getY(), this.getZ(), 1.0F, false, explosion_effect); + // CraftBukkit start + // this.level.createExplosion(this, this.locX(), this.locY(), this.locZ(), 1.0F, false, explosion_effect); + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 1.0F, false); + this.level.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ this.level.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect); ++ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), explosion_effect); + } + // CraftBukkit end - this.die(); + this.discard(); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch index f3ac513e9c..f1431303f6 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch @@ -23,7 +23,7 @@ super(entitytypes, world); } @@ -40,6 +48,7 @@ - this.ownerUUID = entity.getUniqueID(); + this.ownerUUID = entity.getUUID(); this.cachedOwner = entity; } + this.projectileSource = (entity != null && entity.getBukkitEntity() instanceof ProjectileSource) ? (ProjectileSource) entity.getBukkitEntity() : null; // CraftBukkit @@ -31,7 +31,7 @@ } @@ -143,6 +152,16 @@ - this.setMot(this.getMot().add(vec3d.x, entity.isOnGround() ? 0.0D : vec3d.y, vec3d.z)); + this.setDeltaMovement(this.getDeltaMovement().add(vec3d.x, entity.isOnGround() ? 0.0D : vec3d.y, vec3d.z)); } + // CraftBukkit start - call projectile hit event @@ -39,23 +39,23 @@ + org.bukkit.event.entity.ProjectileHitEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); + this.hitCancelled = event != null && event.isCancelled(); + if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK || !this.hitCancelled) { -+ this.a(movingobjectposition); // PAIL rename onHit ++ this.onHit(movingobjectposition); + } + } + // CraftBukkit end + - protected void a(MovingObjectPosition movingobjectposition) { + protected void onHit(MovingObjectPosition movingobjectposition) { MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType(); @@ -161,6 +180,11 @@ - protected void a(MovingObjectPositionEntity movingobjectpositionentity) {} + protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) {} - protected void a(MovingObjectPositionBlock movingobjectpositionblock) { + protected void onHitBlock(MovingObjectPositionBlock movingobjectpositionblock) { + // CraftBukkit start - cancellable hit event + if (hitCancelled) { + return; + } + // CraftBukkit end - IBlockData iblockdata = this.level.getType(movingobjectpositionblock.getBlockPosition()); + IBlockData iblockdata = this.level.getBlockState(movingobjectpositionblock.getBlockPos()); - iblockdata.a(this.level, iblockdata, movingobjectpositionblock, this); + iblockdata.onProjectileHit(this.level, iblockdata, movingobjectpositionblock, this); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch b/paper-server/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch index c779f35ddd..e9e80c602d 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch +++ b/paper-server/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 -@@ -167,7 +167,7 @@ +@@ -166,7 +166,7 @@ MobEffect mobeffect1 = new MobEffect(MobEffects.BAD_OMEN, 120000, i, false, false, true); if (!this.level.getGameRules().getBoolean(GameRules.RULE_DISABLE_RAIDS)) { @@ -9,30 +9,30 @@ } } } -@@ -307,7 +307,7 @@ +@@ -306,7 +306,7 @@ private final T mob; - public b(EntityRaider entityraider) { + public b(T entityraider) { // CraftBukkit - decompile error this.mob = entityraider; - this.a(EnumSet.of(PathfinderGoal.Type.MOVE)); + this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE)); } -@@ -523,7 +523,7 @@ +@@ -522,7 +522,7 @@ while (iterator.hasNext()) { EntityRaider entityraider = (EntityRaider) iterator.next(); -- entityraider.setGoalTarget(this.mob.getGoalTarget()); -+ entityraider.setGoalTarget(this.mob.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit +- entityraider.setTarget(this.mob.getTarget()); ++ entityraider.setTarget(this.mob.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit } } -@@ -540,7 +540,7 @@ +@@ -539,7 +539,7 @@ while (iterator.hasNext()) { EntityRaider entityraider = (EntityRaider) iterator.next(); -- entityraider.setGoalTarget(entityliving); -+ entityraider.setGoalTarget(this.mob.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit +- entityraider.setTarget(entityliving); ++ entityraider.setTarget(this.mob.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit entityraider.setAggressive(true); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/raid/PersistentRaid.patch b/paper-server/nms-patches/net/minecraft/world/entity/raid/PersistentRaid.patch index df5d84d09f..0dbcef7602 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/raid/PersistentRaid.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/raid/PersistentRaid.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/PersistentRaid.java +++ b/net/minecraft/world/entity/raid/PersistentRaid.java -@@ -110,19 +110,33 @@ +@@ -109,19 +109,33 @@ boolean flag = false; if (!raid.isStarted()) { @@ -18,7 +18,7 @@ + // CraftBukkit end } else { entityplayer.removeEffect(MobEffects.BAD_OMEN); - entityplayer.connection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) 43)); + entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, (byte) 43)); } if (flag) { @@ -32,6 +32,6 @@ + this.raidMap.put(raid.getId(), raid); + } + // CraftBukkit end - raid.a((EntityHuman) entityplayer); - entityplayer.connection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) 43)); - if (!raid.c()) { + raid.absorbBadOmen(entityplayer); + entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, (byte) 43)); + if (!raid.hasFirstWaveSpawned()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/raid/Raid.patch b/paper-server/nms-patches/net/minecraft/world/entity/raid/Raid.patch index 5c15ab1724..b3f6cf1a5a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/raid/Raid.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/raid/Raid.patch @@ -10,19 +10,19 @@ + } + // CraftBukkit end + - public float g() { + public float getTotalHealth() { return this.totalHealth; } @@ -270,6 +276,7 @@ - this.active = this.level.isLoaded(this.center); + 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.stop(); return; } @@ -289,13 +296,16 @@ - if (!this.level.b(this.center)) { + if (!this.level.isVillage(this.center)) { if (this.groupsSpawned > 0) { this.status = Raid.Status.LOSS; + org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(this, new java.util.ArrayList<>()); // CraftBukkit @@ -56,8 +56,8 @@ Entity entity = this.level.getEntity(uuid); @@ -394,9 +406,11 @@ - entityplayer.a(StatisticList.RAID_WIN); - CriterionTriggers.RAID_WIN.a(entityplayer); + entityplayer.awardStat(StatisticList.RAID_WIN); + CriterionTriggers.RAID_WIN.trigger(entityplayer); + winners.add(entityplayer.getBukkitEntity()); // CraftBukkit } } @@ -67,7 +67,7 @@ } @@ -404,6 +418,7 @@ - } else if (this.a()) { + } 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 @@ -84,22 +84,22 @@ + // CraftBukkit end for (int k = 0; k < j; ++k) { Raid.Wave raid_wave = araid_wave[k]; - int l = this.a(raid_wave, i, flag1) + this.a(raid_wave, this.random, i, difficultydamagescaler, flag1); + int l = this.getDefaultNumSpawns(raid_wave, i, flag1) + this.getPotentialBonusSpawns(raid_wave, this.random, i, difficultydamagescaler, flag1); @@ -550,9 +569,11 @@ entityraider.setPatrolLeader(true); - this.a(i, entityraider); + this.setLeader(i, entityraider); flag = true; + leader = entityraider; // CraftBukkit } - this.a(i, entityraider, blockposition, false); + this.joinRaid(i, entityraider, blockposition, false); + raiders.add(entityraider); // CraftBukkit if (raid_wave.entityType == EntityTypes.RAVAGER) { EntityRaider entityraider1 = null; @@ -571,6 +592,7 @@ - this.a(i, entityraider1, blockposition, false); - entityraider1.setPositionRotation(blockposition, 0.0F, 0.0F); + this.joinRaid(i, entityraider1, blockposition, false); + entityraider1.moveTo(blockposition, 0.0F, 0.0F); entityraider1.startRiding(entityraider); + raiders.add(entityraider); // CraftBukkit } @@ -107,23 +107,23 @@ } @@ -580,6 +602,7 @@ ++this.groupsSpawned; - this.updateProgress(); - this.H(); + this.updateBossbar(); + this.setDirty(); + org.bukkit.craftbukkit.event.CraftEventFactory.callRaidSpawnWaveEvent(this, leader, raiders); // CraftBukkit } - public void a(int i, EntityRaider entityraider, @Nullable BlockPosition blockposition, boolean flag) { + public void joinRaid(int i, EntityRaider entityraider, @Nullable BlockPosition blockposition, boolean flag) { @@ -595,7 +618,7 @@ - entityraider.prepare(this.level, this.level.getDamageScaler(blockposition), EnumMobSpawn.EVENT, (GroupDataEntity) null, (NBTTagCompound) null); - entityraider.a(i, false); + entityraider.finalizeSpawn(this.level, this.level.getCurrentDifficultyAt(blockposition), EnumMobSpawn.EVENT, (GroupDataEntity) null, (NBTTagCompound) null); + entityraider.applyRaidBuffs(i, false); entityraider.setOnGround(true); -- this.level.addAllEntities(entityraider); -+ this.level.addAllEntities(entityraider, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); // CraftBukkit +- this.level.addFreshEntityWithPassengers(entityraider); ++ this.level.addFreshEntityWithPassengers(entityraider, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); // CraftBukkit } } -@@ -844,6 +867,12 @@ - this.heroesOfTheVillage.add(entity.getUniqueID()); +@@ -845,6 +868,12 @@ + this.heroesOfTheVillage.add(entity.getUUID()); } + // CraftBukkit start - a method to get all raiders diff --git a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch index 07d2a88a13..4240b2d613 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch @@ -15,7 +15,7 @@ + public class EntityBoat extends Entity { - private static final DataWatcherObject<Integer> DATA_ID_HURT = DataWatcher.a(EntityBoat.class, DataWatcherRegistry.INT); + private static final DataWatcherObject<Integer> DATA_ID_HURT = DataWatcher.defineId(EntityBoat.class, DataWatcherRegistry.INT); @@ -92,6 +101,14 @@ private float bubbleAngle; private float bubbleAngleO; @@ -32,7 +32,7 @@ super(entitytypes, world); this.paddlePositions = new float[2]; @@ -161,6 +178,19 @@ - if (this.isInvulnerable(damagesource)) { + if (this.isInvulnerableTo(damagesource)) { return false; } else if (!this.level.isClientSide && !this.isRemoved()) { + // CraftBukkit start @@ -48,8 +48,8 @@ + // f = event.getDamage(); // TODO Why don't we do this? + // CraftBukkit end + - this.c(-this.p()); - this.b(10); + this.setHurtDir(-this.getHurtDir()); + this.setHurtTime(10); this.setDamage(this.getDamage() + f * 10.0F); @@ -169,6 +199,15 @@ boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).getAbilities().instabuild; @@ -65,14 +65,14 @@ + } + // CraftBukkit end if (!flag && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { - this.a((IMaterial) this.h()); + this.spawnAtLocation((IMaterial) this.getDropItem()); } @@ -204,9 +243,29 @@ - public void collide(Entity entity) { + public void push(Entity entity) { if (entity instanceof EntityBoat) { if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) { + // CraftBukkit start -+ if (!this.isSameVehicle(entity)) { ++ if (!this.isPassengerOfSameVehicle(entity)) { + VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity()); + this.level.getCraftServer().getPluginManager().callEvent(event); + @@ -81,11 +81,11 @@ + } + } + // CraftBukkit end - super.collide(entity); + super.push(entity); } } else if (entity.getBoundingBox().minY <= this.getBoundingBox().minY) { + // CraftBukkit start -+ if (!this.isSameVehicle(entity)) { ++ if (!this.isPassengerOfSameVehicle(entity)) { + VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity()); + this.level.getCraftServer().getPluginManager().callEvent(event); + @@ -94,11 +94,11 @@ + } + } + // CraftBukkit end - super.collide(entity); + super.push(entity); } @@ -257,6 +316,7 @@ - return this.getDirection().g(); + return this.getDirection().getClockWise(); } + private Location lastLocation; // CraftBukkit @@ -106,14 +106,14 @@ public void tick() { this.oldStatus = this.status; @@ -297,6 +357,22 @@ - this.setMot(Vec3D.ZERO); + this.setDeltaMovement(Vec3D.ZERO); } + // CraftBukkit start + org.bukkit.Server server = this.level.getCraftServer(); + org.bukkit.World bworld = this.level.getWorld(); + -+ Location to = new Location(bworld, this.locX(), this.locY(), this.locZ(), this.getYRot(), this.getXRot()); ++ Location to = new Location(bworld, this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); + Vehicle vehicle = (Vehicle) this.getBukkitEntity(); + + server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle)); @@ -125,19 +125,19 @@ + lastLocation = vehicle.getLocation(); + // CraftBukkit end + - this.r(); + this.tickBubbleColumn(); for (int i = 0; i <= 1; ++i) { @@ -801,6 +877,11 @@ - this.a(this.fallDistance, 1.0F, DamageSource.FALL); + this.causeFallDamage(this.fallDistance, 1.0F, DamageSource.FALL); if (!this.level.isClientSide && !this.isRemoved()) { + // CraftBukkit start + Vehicle vehicle = (Vehicle) this.getBukkitEntity(); + VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null); + this.level.getCraftServer().getPluginManager().callEvent(destroyEvent); + if (!destroyEvent.isCancelled()) { - this.killEntity(); + this.kill(); if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { int i; @@ -814,6 +895,7 @@ @@ -147,4 +147,4 @@ + } // CraftBukkit end } - this.fallDistance = 0.0F; + this.resetFallDistance(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch index 9acabb85da..e11804f78a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch +++ b/paper-server/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 -@@ -50,6 +50,15 @@ +@@ -49,6 +49,15 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -15,17 +15,8 @@ + public abstract class EntityMinecartAbstract extends Entity { - private static final DataWatcherObject<Integer> DATA_ID_HURT = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.INT); -@@ -61,7 +70,7 @@ - private static final ImmutableMap<EntityPose, ImmutableList<Integer>> POSE_DISMOUNT_HEIGHTS = ImmutableMap.of(EntityPose.STANDING, ImmutableList.of(0, 1, -1), EntityPose.CROUCHING, ImmutableList.of(0, 1, -1), EntityPose.SWIMMING, ImmutableList.of(0, 1)); - protected static final float WATER_SLOWDOWN_FACTOR = 0.95F; - private boolean flipped; -- private static final Map<BlockPropertyTrackPosition, Pair<BaseBlockPosition, BaseBlockPosition>> EXITS = (Map) SystemUtils.a((Object) Maps.newEnumMap(BlockPropertyTrackPosition.class), (enummap) -> { -+ private static final Map<BlockPropertyTrackPosition, Pair<BaseBlockPosition, BaseBlockPosition>> EXITS = (Map) SystemUtils.a(Maps.newEnumMap(BlockPropertyTrackPosition.class), (enummap) -> { // CraftBukkit - decompile error - BaseBlockPosition baseblockposition = EnumDirection.WEST.p(); - BaseBlockPosition baseblockposition1 = EnumDirection.EAST.p(); - BaseBlockPosition baseblockposition2 = EnumDirection.NORTH.p(); -@@ -92,6 +101,17 @@ + private static final DataWatcherObject<Integer> DATA_ID_HURT = DataWatcher.defineId(EntityMinecartAbstract.class, DataWatcherRegistry.INT); +@@ -91,6 +100,17 @@ private double lyd; private double lzd; @@ -43,8 +34,8 @@ protected EntityMinecartAbstract(EntityTypes<?> entitytypes, World world) { super(entitytypes, world); this.blocksBuilding = true; -@@ -218,6 +238,19 @@ - if (this.isInvulnerable(damagesource)) { +@@ -217,6 +237,19 @@ + if (this.isInvulnerableTo(damagesource)) { return false; } else { + // CraftBukkit start - fire VehicleDamageEvent @@ -60,10 +51,10 @@ + + f = (float) event.getDamage(); + // CraftBukkit end - this.d(-this.o()); - this.c(10); - this.velocityChanged(); -@@ -226,6 +259,15 @@ + this.setHurtDir(-this.getHurtDir()); + this.setHurtTime(10); + this.markHurt(); +@@ -225,6 +258,15 @@ boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).getAbilities().instabuild; if (flag || this.getDamage() > 40.0F) { @@ -78,39 +69,39 @@ + // CraftBukkit end this.ejectPassengers(); if (flag && !this.hasCustomName()) { - this.die(); -@@ -285,6 +327,14 @@ + this.discard(); +@@ -284,6 +326,14 @@ @Override public void tick() { + // CraftBukkit start -+ double prevX = this.locX(); -+ double prevY = this.locY(); -+ double prevZ = this.locZ(); ++ double prevX = this.getX(); ++ double prevY = this.getY(); ++ double prevZ = this.getZ(); + float prevYaw = this.getYRot(); + float prevPitch = this.getXRot(); + // CraftBukkit end + - if (this.getType() > 0) { - this.c(this.getType() - 1); + if (this.getHurtTime() > 0) { + this.setHurtTime(this.getHurtTime() - 1); } -@@ -294,7 +344,7 @@ +@@ -293,7 +343,7 @@ } - this.aj(); -- this.doPortalTick(); -+ // this.doPortalTick(); // CraftBukkit - handled in postTick + this.checkOutOfWorld(); +- this.handleNetherPortal(); ++ // this.handleNetherPortal(); // CraftBukkit - handled in postTick double d0; if (this.level.isClientSide) { -@@ -360,6 +410,18 @@ +@@ -359,6 +409,18 @@ } - this.setYawPitch(this.getYRot(), this.getXRot()); + this.setRot(this.getYRot(), this.getXRot()); + // CraftBukkit start + org.bukkit.World bworld = this.level.getWorld(); + Location from = new Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch); -+ Location to = new Location(bworld, this.locX(), this.locY(), this.locZ(), this.getYRot(), this.getXRot()); ++ Location to = new Location(bworld, this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); + Vehicle vehicle = (Vehicle) this.getBukkitEntity(); + + this.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle)); @@ -119,10 +110,10 @@ + this.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to)); + } + // CraftBukkit end - if (this.getMinecartType() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && this.getMot().i() > 0.01D) { - List<Entity> list = this.level.getEntities(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D), IEntitySelector.a(this)); + if (this.getMinecartType() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) { + List<Entity> list = this.level.getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), IEntitySelector.pushableBy(this)); -@@ -368,8 +430,26 @@ +@@ -367,8 +429,26 @@ Entity entity = (Entity) list.get(l); if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.isVehicle() && !entity.isPassenger()) { @@ -137,7 +128,7 @@ entity.startRiding(this); } else { + // CraftBukkit start -+ if (!this.isSameVehicle(entity)) { ++ if (!this.isPassengerOfSameVehicle(entity)) { + VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity.getBukkitEntity()); + this.level.getCraftServer().getPluginManager().callEvent(collisionEvent); + @@ -146,13 +137,13 @@ + } + } + // CraftBukkit end - entity.collide(this); + entity.push(this); } } -@@ -381,6 +461,14 @@ +@@ -380,6 +460,14 @@ Entity entity1 = (Entity) iterator.next(); - if (!this.u(entity1) && entity1.isCollidable() && entity1 instanceof EntityMinecartAbstract) { + if (!this.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof EntityMinecartAbstract) { + // CraftBukkit start + VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity1.getBukkitEntity()); + this.level.getCraftServer().getPluginManager().callEvent(collisionEvent); @@ -161,10 +152,10 @@ + continue; + } + // CraftBukkit end - entity1.collide(this); + entity1.push(this); } } -@@ -397,7 +485,7 @@ +@@ -396,7 +484,7 @@ } protected double getMaxSpeed() { @@ -172,39 +163,39 @@ + return (this.isInWater() ? this.maxSpeed / 2.0D: this.maxSpeed); // CraftBukkit } - public void a(int i, int j, int k, boolean flag) {} -@@ -408,12 +496,16 @@ + public void activateMinecart(int i, int j, int k, boolean flag) {} +@@ -407,12 +495,16 @@ - this.setMot(MathHelper.a(vec3d.x, -d0, d0), vec3d.y, MathHelper.a(vec3d.z, -d0, d0)); + this.setDeltaMovement(MathHelper.clamp(vec3d.x, -d0, d0), vec3d.y, MathHelper.clamp(vec3d.z, -d0, d0)); if (this.onGround) { -- this.setMot(this.getMot().a(0.5D)); +- this.setDeltaMovement(this.getDeltaMovement().scale(0.5D)); + // CraftBukkit start - replace magic numbers with our variables -+ this.setMot(new Vec3D(this.getMot().x * this.derailedX, this.getMot().y * this.derailedY, this.getMot().z * this.derailedZ)); ++ this.setDeltaMovement(new Vec3D(this.getDeltaMovement().x * this.derailedX, this.getDeltaMovement().y * this.derailedY, this.getDeltaMovement().z * this.derailedZ)); + // CraftBukkit end } - this.move(EnumMoveType.SELF, this.getMot()); + this.move(EnumMoveType.SELF, this.getDeltaMovement()); if (!this.onGround) { -- this.setMot(this.getMot().a(0.95D)); +- this.setDeltaMovement(this.getDeltaMovement().scale(0.95D)); + // CraftBukkit start - replace magic numbers with our variables -+ this.setMot(new Vec3D(this.getMot().x * this.flyingX, this.getMot().y * this.flyingY, this.getMot().z * this.flyingZ)); ++ this.setDeltaMovement(new Vec3D(this.getDeltaMovement().x * this.flyingX, this.getDeltaMovement().y * this.flyingY, this.getDeltaMovement().z * this.flyingZ)); + // CraftBukkit end } } -@@ -604,7 +696,7 @@ +@@ -603,7 +695,7 @@ } - protected void decelerate() { + protected void applyNaturalSlowdown() { - double d0 = this.isVehicle() ? 0.997D : 0.96D; + double d0 = this.isVehicle() || !this.slowWhenEmpty ? 0.997D : 0.96D; // CraftBukkit - add !this.slowWhenEmpty - Vec3D vec3d = this.getMot(); + Vec3D vec3d = this.getDeltaMovement(); - vec3d = vec3d.d(d0, 0.0D, d0); -@@ -743,6 +835,14 @@ + vec3d = vec3d.multiply(d0, 0.0D, d0); +@@ -742,6 +834,14 @@ if (!this.level.isClientSide) { if (!entity.noPhysics && !this.noPhysics) { - if (!this.u(entity)) { + if (!this.hasPassenger(entity)) { + // CraftBukkit start + VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity()); + this.level.getCraftServer().getPluginManager().callEvent(collisionEvent); @@ -213,10 +204,10 @@ + return; + } + // CraftBukkit end - double d0 = entity.locX() - this.locX(); - double d1 = entity.locZ() - this.locZ(); + double d0 = entity.getX() - this.getX(); + double d1 = entity.getZ() - this.getZ(); double d2 = d0 * d0 + d1 * d1; -@@ -922,4 +1022,26 @@ +@@ -921,4 +1021,26 @@ private EnumMinecartType() {} } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.patch b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.patch index 4a1896e999..a88d033ee7 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.java +++ b/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.java @@ -131,5 +131,12 @@ - public CommandListenerWrapper getWrapper() { - return new CommandListenerWrapper(this, EntityMinecartCommandBlock.this.getPositionVector(), EntityMinecartCommandBlock.this.br(), this.e(), 2, this.getName().getString(), EntityMinecartCommandBlock.this.getScoreboardDisplayName(), this.e().getMinecraftServer(), EntityMinecartCommandBlock.this); + public CommandListenerWrapper createCommandSourceStack() { + return new CommandListenerWrapper(this, EntityMinecartCommandBlock.this.position(), EntityMinecartCommandBlock.this.getRotationVector(), this.getLevel(), 2, this.getName().getString(), EntityMinecartCommandBlock.this.getDisplayName(), this.getLevel().getServer(), EntityMinecartCommandBlock.this); } + + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartContainer.patch b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartContainer.patch index 9764265150..9408e1032a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartContainer.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartContainer.patch @@ -62,14 +62,14 @@ + protected EntityMinecartContainer(EntityTypes<?> entitytypes, World world) { super(entitytypes, world); -- this.itemStacks = NonNullList.a(36, ItemStack.EMPTY); -+ this.itemStacks = NonNullList.a(this.getSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513 +- this.itemStacks = NonNullList.withSize(36, ItemStack.EMPTY); ++ this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513 } protected EntityMinecartContainer(EntityTypes<?> entitytypes, double d0, double d1, double d2, World world) { super(entitytypes, world, d0, d1, d2); -- this.itemStacks = NonNullList.a(36, ItemStack.EMPTY); -+ this.itemStacks = NonNullList.a(this.getSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513 +- this.itemStacks = NonNullList.withSize(36, ItemStack.EMPTY); ++ this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513 } @Override diff --git a/paper-server/nms-patches/net/minecraft/world/food/FoodMetaData.patch b/paper-server/nms-patches/net/minecraft/world/food/FoodMetaData.patch index 81911a86ce..5045ecd2bc 100644 --- a/paper-server/nms-patches/net/minecraft/world/food/FoodMetaData.patch +++ b/paper-server/nms-patches/net/minecraft/world/food/FoodMetaData.patch @@ -36,9 +36,9 @@ public void eat(int i, float f) { this.foodLevel = Math.min(i + this.foodLevel, 20); @@ -26,8 +44,17 @@ - public void a(Item item, ItemStack itemstack) { - if (item.isFood()) { - FoodInfo foodinfo = item.getFoodInfo(); + public void eat(Item item, ItemStack itemstack) { + if (item.isEdible()) { + FoodInfo foodinfo = item.getFoodProperties(); + // CraftBukkit start + int oldFoodLevel = foodLevel; @@ -66,35 +66,35 @@ + this.foodLevel = event.getFoodLevel(); + } + -+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), this.foodLevel, this.saturationLevel)); ++ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), this.foodLevel, this.saturationLevel)); + // CraftBukkit end } } @@ -49,23 +84,25 @@ - if (flag && this.saturationLevel > 0.0F && entityhuman.fu() && this.foodLevel >= 20) { + if (flag && this.saturationLevel > 0.0F && entityhuman.isHurt() && this.foodLevel >= 20) { ++this.tickTimer; - if (this.tickTimer >= 10) { + if (this.tickTimer >= this.saturatedRegenRate) { // CraftBukkit float f = Math.min(this.saturationLevel, 6.0F); - entityhuman.heal(f / 6.0F); -- this.a(f); +- this.addExhaustion(f); + entityhuman.heal(f / 6.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); // CraftBukkit - added RegainReason -+ // this.a(f); CraftBukkit - EntityExhaustionEvent -+ entityhuman.applyExhaustion(f, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.REGEN); // CraftBukkit - EntityExhaustionEvent ++ // this.addExhaustion(f); CraftBukkit - EntityExhaustionEvent ++ entityhuman.causeFoodExhaustion(f, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.REGEN); // CraftBukkit - EntityExhaustionEvent this.tickTimer = 0; } - } else if (flag && this.foodLevel >= 18 && entityhuman.fu()) { + } else if (flag && this.foodLevel >= 18 && entityhuman.isHurt()) { ++this.tickTimer; - if (this.tickTimer >= 80) { - entityhuman.heal(1.0F); -- this.a(6.0F); +- this.addExhaustion(6.0F); + if (this.tickTimer >= this.unsaturatedRegenRate) { // CraftBukkit - add regen rate manipulation + entityhuman.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); // CraftBukkit - added RegainReason + // this.a(6.0F); CraftBukkit - EntityExhaustionEvent -+ entityhuman.applyExhaustion(6.0f, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.REGEN); // CraftBukkit - EntityExhaustionEvent ++ entityhuman.causeFoodExhaustion(6.0f, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.REGEN); // CraftBukkit - EntityExhaustionEvent this.tickTimer = 0; } } else if (this.foodLevel <= 0) { @@ -102,5 +102,5 @@ - if (this.tickTimer >= 80) { + if (this.tickTimer >= this.starvationRate) { // CraftBukkit - add regen rate manipulation if (entityhuman.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || entityhuman.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL) { - entityhuman.damageEntity(DamageSource.STARVE, 1.0F); + entityhuman.hurt(DamageSource.STARVE, 1.0F); } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/Container.patch b/paper-server/nms-patches/net/minecraft/world/inventory/Container.patch index 79a2a921ac..6ab716fd38 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/Container.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/Container.patch @@ -48,21 +48,21 @@ + protected Container(@Nullable Containers<?> containers, int i) { this.carried = ItemStack.EMPTY; - this.remoteSlots = NonNullList.a(); + this.remoteSlots = NonNullList.create(); @@ -156,6 +191,15 @@ } + // CraftBukkit start + public void broadcastCarriedItem() { -+ this.remoteCarried = this.getCarried().cloneItemStack(); ++ this.remoteCarried = this.getCarried().copy(); + if (this.synchronizer != null) { + this.synchronizer.sendCarriedChange(this, this.remoteCarried); + } + } + // CraftBukkit end + - public void b(ICrafting icrafting) { + public void removeSlotListener(ICrafting icrafting) { this.containerListeners.remove(icrafting); } @@ -370,7 +414,7 @@ @@ -72,8 +72,8 @@ - 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.f(); - this.b(k, this.quickcraftType, InventoryClickType.PICKUP, entityhuman); + this.resetQuickCraft(); + this.doClick(k, this.quickcraftType, InventoryClickType.PICKUP, entityhuman); @@ -381,6 +425,7 @@ l = this.getCarried().getCount(); Iterator iterator = this.quickcraftSlots.iterator(); @@ -128,12 +128,12 @@ + } + + if (needsUpdate && entityhuman instanceof EntityPlayer) { -+ this.updateInventory(); ++ this.sendAllDataToRemote(); + } + // CraftBukkit end } - this.f(); + this.resetQuickCraft(); @@ -420,8 +501,11 @@ if (i == -999) { if (!this.getCarried().isEmpty()) { @@ -145,18 +145,18 @@ + entityhuman.drop(carried, true); + // CraftBukkit start } else { - entityhuman.drop(this.getCarried().cloneAndSubtract(1), true); + entityhuman.drop(this.getCarried().split(1), true); } @@ -484,6 +568,15 @@ } - slot.d(); + slot.setChanged(); + // CraftBukkit start - Make sure the client has the right slot contents + if (entityhuman instanceof EntityPlayer && slot.getMaxStackSize() != 64) { -+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutSetSlot(this.containerId, this.incrementStateId(), slot.index, slot.getItem())); ++ ((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.sendPacket(new PacketPlayOutSetSlot(this.containerId, this.incrementStateId(), 0, this.getSlot(0).getItem())); ++ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutSetSlot(this.containerId, this.incrementStateId(), 0, this.getSlot(0).getItem())); + } + } + // CraftBukkit end @@ -168,8 +168,8 @@ if (!itemstack.isEmpty()) { + this.setCarried(ItemStack.EMPTY); // CraftBukkit - SPIGOT-4556 - from below - if (entityhuman.isAlive() && !((EntityPlayer) entityhuman).q()) { - entityhuman.getInventory().f(itemstack); + if (entityhuman.isAlive() && !((EntityPlayer) entityhuman).hasDisconnected()) { + entityhuman.getInventory().placeItemBackInInventory(itemstack); } else { entityhuman.drop(itemstack, false); } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAccess.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAccess.patch index f799ab8504..72e419a336 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAccess.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAccess.patch @@ -20,10 +20,10 @@ + ContainerAccess NULL = new ContainerAccess() { @Override - public <T> Optional<T> a(BiFunction<World, BlockPosition, T> bifunction) { + public <T> Optional<T> evaluate(BiFunction<World, BlockPosition, T> bifunction) { @@ -17,6 +31,18 @@ - static ContainerAccess at(final World world, final BlockPosition blockposition) { + static ContainerAccess create(final World world, final BlockPosition blockposition) { return new ContainerAccess() { + // CraftBukkit start + @Override @@ -38,5 +38,5 @@ + // CraftBukkit end + @Override - public <T> Optional<T> a(BiFunction<World, BlockPosition, T> bifunction) { + public <T> Optional<T> evaluate(BiFunction<World, BlockPosition, T> bifunction) { return Optional.of(bifunction.apply(world, blockposition)); diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch index 5dba39918b..6cc9ed9fd6 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch +++ b/paper-server/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 -@@ -19,6 +19,10 @@ +@@ -18,6 +18,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -11,7 +11,7 @@ public class ContainerAnvil extends ContainerAnvilAbstract { private static final Logger LOGGER = LogManager.getLogger(); -@@ -34,6 +38,10 @@ +@@ -33,6 +37,10 @@ private static final int COST_REPAIR_SACRIFICE = 2; private static final int COST_INCOMPATIBLE_PENALTY = 1; private static final int COST_RENAME = 1; @@ -22,7 +22,7 @@ public ContainerAnvil(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); -@@ -106,7 +114,7 @@ +@@ -105,7 +113,7 @@ byte b1 = 0; if (itemstack.isEmpty()) { @@ -30,26 +30,26 @@ + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit this.cost.set(0); } else { - ItemStack itemstack1 = itemstack.cloneItemStack(); -@@ -124,7 +132,7 @@ - if (itemstack1.f() && itemstack1.getItem().a(itemstack, itemstack2)) { - k = Math.min(itemstack1.getDamage(), itemstack1.i() / 4); + ItemStack itemstack1 = itemstack.copy(); +@@ -123,7 +131,7 @@ + if (itemstack1.isDamageableItem() && itemstack1.getItem().isValidRepairItem(itemstack, itemstack2)) { + k = Math.min(itemstack1.getDamageValue(), itemstack1.getMaxDamage() / 4); if (k <= 0) { - this.resultSlots.setItem(0, ItemStack.EMPTY); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit this.cost.set(0); return; } -@@ -139,7 +147,7 @@ +@@ -138,7 +146,7 @@ this.repairItemCountCost = i1; } else { - if (!flag && (!itemstack1.a(itemstack2.getItem()) || !itemstack1.f())) { + if (!flag && (!itemstack1.is(itemstack2.getItem()) || !itemstack1.isDamageableItem())) { - this.resultSlots.setItem(0, ItemStack.EMPTY); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit this.cost.set(0); return; } -@@ -229,7 +237,7 @@ +@@ -228,7 +236,7 @@ } if (flag2 && !flag1) { @@ -58,7 +58,7 @@ this.cost.set(0); return; } -@@ -253,11 +261,11 @@ +@@ -252,11 +260,11 @@ itemstack1 = ItemStack.EMPTY; } @@ -73,18 +73,18 @@ itemstack1 = ItemStack.EMPTY; } -@@ -276,7 +284,8 @@ - EnchantmentManager.a(map, itemstack1); +@@ -275,7 +283,8 @@ + EnchantmentManager.setEnchantments(map, itemstack1); } - this.resultSlots.setItem(0, itemstack1); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), itemstack1); // CraftBukkit -+ updateInventory(); // CraftBukkit - SPIGOT-6686: Always send completed inventory to stay in sync with client - this.d(); ++ sendAllDataToRemote(); // CraftBukkit - SPIGOT-6686: Always send completed inventory to stay in sync with client + this.broadcastChanges(); } } -@@ -303,4 +312,18 @@ - public int m() { +@@ -302,4 +311,18 @@ + public int getCost() { return this.cost.get(); } + diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch index 3255bc5b3d..29007cd3bf 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch @@ -3,8 +3,8 @@ @@ -92,6 +92,7 @@ @Override - public boolean canUse(EntityHuman entityhuman) { + public boolean stillValid(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return (Boolean) this.access.a((world, blockposition) -> { - return !this.a(world.getType(blockposition)) ? false : entityhuman.h((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) <= 64.0D; + return (Boolean) this.access.evaluate((world, blockposition) -> { + return !this.isValidBlock(world.getBlockState(blockposition)) ? false : entityhuman.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) <= 64.0D; }, true); diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch index 95e1569120..343984bf4f 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch @@ -30,13 +30,13 @@ + player = (PlayerInventory) iinventory; // CraftBukkit - TODO: check this this.beacon = new InventorySubcontainer(1) { @Override - public boolean b(int j, ItemStack itemstack) { + public boolean canPlaceItem(int j, ItemStack itemstack) { @@ -79,6 +89,7 @@ @Override - public boolean canUse(EntityHuman entityhuman) { + public boolean stillValid(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return a(this.access, entityhuman, Blocks.BEACON); + return stillValid(this.access, entityhuman, Blocks.BEACON); } @@ -178,4 +189,17 @@ diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerBrewingStand.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerBrewingStand.patch index fb3cdf6ed4..0c106756c8 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerBrewingStand.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerBrewingStand.patch @@ -28,15 +28,15 @@ public ContainerBrewingStand(int i, PlayerInventory playerinventory, IInventory iinventory, IContainerProperties icontainerproperties) { super(Containers.BREWING_STAND, i); + player = playerinventory; // CraftBukkit - a(iinventory, 5); - a(icontainerproperties, 2); + checkContainerSize(iinventory, 5); + checkContainerDataCount(icontainerproperties, 2); this.brewingStand = iinventory; @@ -61,6 +72,7 @@ @Override - public boolean canUse(EntityHuman entityhuman) { + public boolean stillValid(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return this.brewingStand.a(entityhuman); + return this.brewingStand.stillValid(entityhuman); } @@ -198,4 +210,17 @@ diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerCartography.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerCartography.patch index 2ecb6f5285..0a48c9eda0 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerCartography.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerCartography.patch @@ -32,8 +32,8 @@ public static final int ADDITIONAL_SLOT = 1; public static final int RESULT_SLOT = 2; @@ -38,6 +60,13 @@ - ContainerCartography.this.a((IInventory) this); - super.update(); + ContainerCartography.this.slotsChanged(this); + super.setChanged(); } + + // CraftBukkit start @@ -46,8 +46,8 @@ this.resultContainer = new InventoryCraftResult() { @Override @@ -45,6 +74,13 @@ - ContainerCartography.this.a((IInventory) this); - super.update(); + ContainerCartography.this.slotsChanged(this); + super.setChanged(); } + + // CraftBukkit start @@ -58,17 +58,17 @@ + // CraftBukkit end }; this.access = containeraccess; - this.a(new Slot(this.container, 0, 15, 15) { + this.addSlot(new Slot(this.container, 0, 15, 15) { @@ -95,10 +131,12 @@ - this.a(new Slot(playerinventory, j, 8 + j * 18, 142)); + this.addSlot(new Slot(playerinventory, j, 8 + j * 18, 142)); } + player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit } @Override - public boolean canUse(EntityHuman entityhuman) { + public boolean stillValid(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return a(this.access, entityhuman, Blocks.CARTOGRAPHY_TABLE); + return stillValid(this.access, entityhuman, Blocks.CARTOGRAPHY_TABLE); } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerChest.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerChest.patch index 8eba2155f3..e955215fd1 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerChest.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerChest.patch @@ -55,8 +55,8 @@ @@ -79,6 +112,7 @@ @Override - public boolean canUse(EntityHuman entityhuman) { + public boolean stillValid(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return this.container.a(entityhuman); + return this.container.stillValid(entityhuman); } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerDispenser.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerDispenser.patch index 9bc60f9868..a678f092ce 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerDispenser.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerDispenser.patch @@ -31,20 +31,20 @@ + this.player = playerinventory; + // CraftBukkit end + - a(iinventory, 9); + checkContainerSize(iinventory, 9); this.dispenser = iinventory; iinventory.startOpen(playerinventory.player); @@ -48,6 +61,7 @@ @Override - public boolean canUse(EntityHuman entityhuman) { + public boolean stillValid(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return this.dispenser.a(entityhuman); + return this.dispenser.stillValid(entityhuman); } @@ -89,4 +103,17 @@ - super.b(entityhuman); - this.dispenser.closeContainer(entityhuman); + super.removed(entityhuman); + this.dispenser.stopOpen(entityhuman); } + + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch index f82eae484e..36c5c4cc3a 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch @@ -34,8 +34,8 @@ public ContainerEnchantTable(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); @@ -42,6 +61,13 @@ - super.update(); - ContainerEnchantTable.this.a((IInventory) this); + super.setChanged(); + ContainerEnchantTable.this.slotsChanged(this); } + + // CraftBukkit start @@ -46,11 +46,11 @@ + // CraftBukkit end }; this.random = new Random(); - this.enchantmentSeed = ContainerProperty.a(); + this.enchantmentSeed = ContainerProperty.standalone(); @@ -89,6 +115,9 @@ - this.a(ContainerProperty.a(this.levelClue, 0)); - this.a(ContainerProperty.a(this.levelClue, 1)); - this.a(ContainerProperty.a(this.levelClue, 2)); + this.addDataSlot(ContainerProperty.shared(this.levelClue, 0)); + this.addDataSlot(ContainerProperty.shared(this.levelClue, 1)); + this.addDataSlot(ContainerProperty.shared(this.levelClue, 2)); + // CraftBukkit start + player = (Player) playerinventory.player.getBukkitEntity(); + // CraftBukkit end @@ -61,9 +61,9 @@ if (iinventory == this.enchantSlots) { ItemStack itemstack = iinventory.getItem(0); -- if (!itemstack.isEmpty() && itemstack.canEnchant()) { +- if (!itemstack.isEmpty() && itemstack.isEnchantable()) { + if (!itemstack.isEmpty()) { // CraftBukkit - relax condition - this.access.a((world, blockposition) -> { + this.access.execute((world, blockposition) -> { int i = 0; @@ -158,6 +187,41 @@ @@ -74,12 +74,12 @@ + CraftItemStack item = CraftItemStack.asCraftMirror(itemstack); + org.bukkit.enchantments.EnchantmentOffer[] offers = new EnchantmentOffer[3]; + for (j = 0; j < 3; ++j) { -+ org.bukkit.enchantments.Enchantment enchantment = (this.enchantClue[j] >= 0) ? org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.ENCHANTMENT.getKey(IRegistry.ENCHANTMENT.fromId(this.enchantClue[j])))) : null; ++ org.bukkit.enchantments.Enchantment enchantment = (this.enchantClue[j] >= 0) ? org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.ENCHANTMENT.getKey(IRegistry.ENCHANTMENT.byId(this.enchantClue[j])))) : null; + offers[j] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.levelClue[j], this.costs[j]) : null; + } + + PrepareItemEnchantEvent event = new PrepareItemEnchantEvent(player, this.getBukkitView(), access.getLocation().getBlock(), item, offers, i); -+ event.setCancelled(!itemstack.canEnchant()); ++ event.setCancelled(!itemstack.isEnchantable()); + world.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { @@ -105,19 +105,19 @@ + } + // CraftBukkit end + - this.d(); + this.broadcastChanges(); }); } else { @@ -184,9 +248,24 @@ ItemStack itemstack2 = itemstack; - List<WeightedRandomEnchant> list = this.a(itemstack, i, this.costs[i]); + List<WeightedRandomEnchant> list = this.getEnchantmentList(itemstack, i, this.costs[i]); - if (!list.isEmpty()) { -- entityhuman.enchantDone(itemstack, j); +- entityhuman.onEnchantmentPerformed(itemstack, j); + // CraftBukkit start + if (true || !list.isEmpty()) { -+ // entityhuman.enchantDone(itemstack, j); // Moved down - boolean flag = itemstack.a(Items.BOOK); ++ // entityhuman.onEnchantmentPerformed(itemstack, j); // Moved down + boolean flag = itemstack.is(Items.BOOK); + Map<org.bukkit.enchantments.Enchantment, Integer> enchants = new java.util.HashMap<org.bukkit.enchantments.Enchantment, Integer>(); + for (Object obj : list) { + WeightedRandomEnchant instance = (WeightedRandomEnchant) obj; @@ -151,11 +151,11 @@ + } - if (flag) { -- ItemEnchantedBook.a(itemstack2, weightedrandomenchant); +- ItemEnchantedBook.addEnchantment(itemstack2, weightedrandomenchant); - } else { -- itemstack2.addEnchantment(weightedrandomenchant.enchantment, weightedrandomenchant.level); +- itemstack2.enchant(weightedrandomenchant.enchantment, weightedrandomenchant.level); + WeightedRandomEnchant weightedrandomenchant = new WeightedRandomEnchant(nms, entry.getValue()); -+ ItemEnchantedBook.a(itemstack2, weightedrandomenchant); ++ ItemEnchantedBook.addEnchantment(itemstack2, weightedrandomenchant); + } else { + item.addUnsafeEnchantment(entry.getKey(), entry.getValue()); + } @@ -164,19 +164,19 @@ } } -+ entityhuman.enchantDone(itemstack, j); ++ entityhuman.onEnchantmentPerformed(itemstack, j); + // CraftBukkit end + + // CraftBukkit - TODO: let plugins change this if (!entityhuman.getAbilities().instabuild) { - itemstack1.subtract(j); + itemstack1.shrink(j); if (itemstack1.isEmpty()) { @@ -265,6 +357,7 @@ @Override - public boolean canUse(EntityHuman entityhuman) { + public boolean stillValid(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return a(this.access, entityhuman, Blocks.ENCHANTING_TABLE); + return stillValid(this.access, entityhuman, Blocks.ENCHANTING_TABLE); } @@ -316,4 +409,17 @@ diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerFurnace.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerFurnace.patch index a33a4458cf..b9cf966714 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerFurnace.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerFurnace.patch @@ -36,9 +36,9 @@ this(containers, recipes, recipebooktype, i, playerinventory, new InventorySubcontainer(3), new ContainerProperties(4)); } @@ -45,6 +66,7 @@ - this.a(new Slot(iinventory, 0, 56, 17)); - this.a((Slot) (new SlotFurnaceFuel(this, iinventory, 1, 56, 53))); - this.a((Slot) (new SlotFurnaceResult(playerinventory.player, iinventory, 2, 116, 35))); + this.addSlot(new Slot(iinventory, 0, 56, 17)); + this.addSlot(new SlotFurnaceFuel(this, iinventory, 1, 56, 53)); + this.addSlot(new SlotFurnaceResult(playerinventory.player, iinventory, 2, 116, 35)); + this.player = playerinventory; // CraftBukkit - save player int j; @@ -46,17 +46,17 @@ @@ -102,6 +124,7 @@ @Override - public boolean canUse(EntityHuman entityhuman) { + public boolean stillValid(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return this.container.a(entityhuman); + return this.container.stillValid(entityhuman); } @@ -157,7 +180,7 @@ } - protected boolean c(ItemStack itemstack) { -- return this.level.getCraftingManager().craft(this.recipeType, new InventorySubcontainer(new ItemStack[]{itemstack}), this.level).isPresent(); -+ return this.level.getCraftingManager().craft((Recipes<RecipeCooking>) this.recipeType, new InventorySubcontainer(new ItemStack[]{itemstack}), this.level).isPresent(); // Eclipse fail + protected boolean canSmelt(ItemStack itemstack) { +- return this.level.getRecipeManager().getRecipeFor(this.recipeType, new InventorySubcontainer(new ItemStack[]{itemstack}), this.level).isPresent(); ++ return this.level.getRecipeManager().getRecipeFor((Recipes<RecipeCooking>) this.recipeType, new InventorySubcontainer(new ItemStack[]{itemstack}), this.level).isPresent(); // Eclipse fail } - protected boolean d(ItemStack itemstack) { + protected boolean isFuel(ItemStack itemstack) { diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch index eeca14727f..fb8544b760 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch +++ b/paper-server/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,9 +31,9 @@ public static final int MAX_NAME_LENGTH = 35; public static final int INPUT_SLOT = 0; public static final int ADDITIONAL_SLOT = 1; -@@ -47,6 +69,13 @@ - super.update(); - ContainerGrindstone.this.a((IInventory) this); +@@ -46,6 +68,13 @@ + super.setChanged(); + ContainerGrindstone.this.slotsChanged(this); } + + // CraftBukkit start @@ -44,20 +44,20 @@ + // CraftBukkit end }; this.access = containeraccess; - this.a(new Slot(this.repairSlots, 0, 49, 19) { -@@ -125,6 +154,7 @@ - this.a(new Slot(playerinventory, j, 8 + j * 18, 142)); + this.addSlot(new Slot(this.repairSlots, 0, 49, 19) { +@@ -124,6 +153,7 @@ + this.addSlot(new Slot(playerinventory, j, 8 + j * 18, 142)); } + player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit } @Override -@@ -252,6 +282,7 @@ +@@ -251,6 +281,7 @@ @Override - public boolean canUse(EntityHuman entityhuman) { + public boolean stillValid(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return a(this.access, entityhuman, Blocks.GRINDSTONE); + return stillValid(this.access, entityhuman, Blocks.GRINDSTONE); } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerHopper.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerHopper.patch index d2304db8d0..1a6a55058d 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerHopper.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerHopper.patch @@ -38,14 +38,14 @@ super(Containers.HOPPER, i); this.hopper = iinventory; + this.player = playerinventory; // CraftBukkit - save player - a(iinventory, 5); + checkContainerSize(iinventory, 5); iinventory.startOpen(playerinventory.player); boolean flag = true; @@ -42,6 +64,7 @@ @Override - public boolean canUse(EntityHuman entityhuman) { + public boolean stillValid(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return this.hopper.a(entityhuman); + return this.hopper.stillValid(entityhuman); } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch index c168982e48..062a5c8d6d 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerHorse.java +++ b/net/minecraft/world/inventory/ContainerHorse.java -@@ -9,13 +9,33 @@ +@@ -8,13 +8,33 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerLectern.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerLectern.patch index e17570cca1..3bd8b745af 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerLectern.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerLectern.patch @@ -49,12 +49,12 @@ + public ContainerLectern(int i, IInventory iinventory, IContainerProperties icontainerproperties, PlayerInventory playerinventory) { + // CraftBukkit end super(Containers.LECTERN, i); - a(iinventory, 1); - a(icontainerproperties, 1); + checkContainerSize(iinventory, 1); + checkContainerDataCount(icontainerproperties, 1); @@ -34,6 +61,7 @@ } }); - this.a(icontainerproperties); + this.addDataSlots(icontainerproperties); + player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit } @@ -70,15 +70,15 @@ + return false; + } + // CraftBukkit end - ItemStack itemstack = this.lectern.splitWithoutUpdate(0); + ItemStack itemstack = this.lectern.removeItemNoUpdate(0); - this.lectern.update(); + this.lectern.setChanged(); @@ -81,6 +116,8 @@ @Override - public boolean canUse(EntityHuman entityhuman) { + public boolean stillValid(EntityHuman entityhuman) { + if (lectern instanceof LecternInventory && !((LecternInventory) lectern).getLectern().hasBook()) return false; // CraftBukkit + if (!this.checkReachable) return true; // CraftBukkit - return this.lectern.a(entityhuman); + return this.lectern.stillValid(entityhuman); } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerLoom.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerLoom.patch index c3271ac1bd..b0c3dd848c 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerLoom.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerLoom.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/ContainerLoom.java +++ b/net/minecraft/world/inventory/ContainerLoom.java -@@ -16,8 +16,30 @@ - import net.minecraft.world.level.block.Blocks; +@@ -18,8 +18,30 @@ import net.minecraft.world.level.block.entity.EnumBannerPatternType; + import net.minecraft.world.level.block.entity.TileEntityTypes; +// CraftBukkit start +import org.bukkit.Location; @@ -31,8 +31,8 @@ private static final int INV_SLOT_START = 4; private static final int INV_SLOT_END = 31; private static final int USE_ROW_SLOT_START = 31; -@@ -49,6 +71,13 @@ - ContainerLoom.this.a((IInventory) this); +@@ -51,6 +73,13 @@ + ContainerLoom.this.slotsChanged(this); ContainerLoom.this.slotUpdateListener.run(); } + @@ -45,8 +45,8 @@ }; this.outputContainer = new InventorySubcontainer(1) { @Override -@@ -56,6 +85,13 @@ - super.update(); +@@ -58,6 +87,13 @@ + super.setChanged(); ContainerLoom.this.slotUpdateListener.run(); } + @@ -58,26 +58,26 @@ + // CraftBukkit end }; this.access = containeraccess; - this.bannerSlot = this.a(new Slot(this.inputContainer, 0, 13, 26) { -@@ -116,6 +152,7 @@ + this.bannerSlot = this.addSlot(new Slot(this.inputContainer, 0, 13, 26) { +@@ -118,6 +154,7 @@ } - this.a(this.selectedBannerPatternIndex); + this.addDataSlot(this.selectedBannerPatternIndex); + player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit } - public int l() { -@@ -124,6 +161,7 @@ + public int getSelectedBannerPatternIndex() { +@@ -126,6 +163,7 @@ @Override - public boolean canUse(EntityHuman entityhuman) { + public boolean stillValid(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return a(this.access, entityhuman, Blocks.LOOM); + return stillValid(this.access, entityhuman, Blocks.LOOM); } -@@ -246,6 +284,11 @@ +@@ -248,6 +286,11 @@ - if (nbttagcompound.hasKeyOfType("Patterns", 9)) { + if (nbttagcompound != null && nbttagcompound.contains("Patterns", 9)) { nbttaglist = nbttagcompound.getList("Patterns", 10); + // CraftBukkit start + while (nbttaglist.size() > 20) { @@ -86,4 +86,4 @@ + // CraftBukkit end } else { nbttaglist = new NBTTagList(); - nbttagcompound.set("Patterns", nbttaglist); + if (nbttagcompound == null) { diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerMerchant.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerMerchant.patch index c60de9ef25..e55d226afe 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerMerchant.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerMerchant.patch @@ -30,9 +30,9 @@ this(i, playerinventory, new MerchantWrapper(playerinventory.player)); } @@ -42,6 +57,7 @@ - this.a(new Slot(this.tradeContainer, 0, 136, 37)); - this.a(new Slot(this.tradeContainer, 1, 162, 37)); - this.a((Slot) (new SlotMerchantResult(playerinventory.player, imerchant, this.tradeContainer, 2, 220, 37))); + this.addSlot(new Slot(this.tradeContainer, 0, 136, 37)); + this.addSlot(new Slot(this.tradeContainer, 1, 162, 37)); + this.addSlot(new SlotMerchantResult(playerinventory.player, imerchant, this.tradeContainer, 2, 220, 37)); + this.player = playerinventory; // CraftBukkit - save player int j; @@ -40,9 +40,9 @@ @@ -154,7 +170,7 @@ } - private void r() { -- if (!this.trader.getWorld().isClientSide) { -+ if (!this.trader.getWorld().isClientSide && this.trader instanceof Entity) { // CraftBukkit - SPIGOT-5035 + private void playTradeSound() { +- if (!this.trader.isClientSide()) { ++ if (!this.trader.isClientSide() && this.trader instanceof Entity) { // CraftBukkit - SPIGOT-5035 Entity entity = (Entity) this.trader; - this.trader.getWorld().a(entity.locX(), entity.locY(), entity.locZ(), this.trader.getTradeSound(), SoundCategory.NEUTRAL, 1.0F, 1.0F, false); + entity.getLevel().playLocalSound(entity.getX(), entity.getY(), entity.getZ(), this.trader.getNotifyTradeSound(), SoundCategory.NEUTRAL, 1.0F, 1.0F, false); diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch index c700e007c0..7ddaf86ed3 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch @@ -41,12 +41,12 @@ + this.player = playerinventory; // CraftBukkit - save player + setTitle(new ChatMessage("container.crafting")); // SPIGOT-4722: Allocate title for player inventory + // CraftBukkit end - this.a((Slot) (new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 154, 28))); + this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 154, 28)); int i; @@ -242,4 +261,17 @@ - public boolean d(int i) { - return i != this.m(); + public boolean shouldMoveToInventory(int i) { + return i != this.getResultSlotIndex(); } + + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerShulkerBox.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerShulkerBox.patch index 42f8ac7e94..a1a1a34747 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerShulkerBox.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerShulkerBox.patch @@ -32,7 +32,7 @@ this(i, playerinventory, new InventorySubcontainer(27)); @@ -19,6 +38,7 @@ super(Containers.SHULKER_BOX, i); - a(iinventory, 27); + checkContainerSize(iinventory, 27); this.container = iinventory; + this.player = playerinventory; // CraftBukkit - save player iinventory.startOpen(playerinventory.player); diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch index 30d927fca1..dbc4ee2cff 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch @@ -19,14 +19,14 @@ public ContainerSmithing(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); @@ -61,13 +66,15 @@ - List<RecipeSmithing> list = this.level.getCraftingManager().b(Recipes.SMITHING, this.inputSlots, this.level); + List<RecipeSmithing> list = this.level.getRecipeManager().getRecipesFor(Recipes.SMITHING, this.inputSlots, this.level); if (list.isEmpty()) { - this.resultSlots.setItem(0, ItemStack.EMPTY); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit } else { this.selectedRecipe = (RecipeSmithing) list.get(0); - ItemStack itemstack = this.selectedRecipe.a(this.inputSlots); + ItemStack itemstack = this.selectedRecipe.assemble(this.inputSlots); this.resultSlots.setRecipeUsed(this.selectedRecipe); - this.resultSlots.setItem(0, itemstack); @@ -37,8 +37,8 @@ } @@ -83,4 +90,18 @@ - public boolean a(ItemStack itemstack, Slot slot) { - return slot.container != this.resultSlots && super.a(itemstack, slot); + public boolean canTakeItemForPickAll(ItemStack itemstack, Slot slot) { + return slot.container != this.resultSlots && super.canTakeItemForPickAll(itemstack, slot); } + + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch index 1bf0611059..65a1ab1257 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch @@ -37,7 +37,7 @@ public ContainerStonecutter(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); @@ -53,6 +75,13 @@ - ContainerStonecutter.this.a((IInventory) this); + ContainerStonecutter.this.slotsChanged(this); ContainerStonecutter.this.slotUpdateListener.run(); } + @@ -53,16 +53,16 @@ @@ -100,6 +129,7 @@ } - this.a(this.selectedRecipeIndex); + this.addDataSlot(this.selectedRecipeIndex); + player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit } - public int l() { + public int getSelectedRecipeIndex() { @@ -120,6 +150,7 @@ @Override - public boolean canUse(EntityHuman entityhuman) { + public boolean stillValid(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return a(this.access, entityhuman, Blocks.STONECUTTER); + return stillValid(this.access, entityhuman, Blocks.STONECUTTER); } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch index 6734807c84..69f5242da1 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch @@ -13,14 +13,8 @@ public class ContainerWorkbench extends ContainerRecipeBook<InventoryCrafting> { public static final int RESULT_SLOT = 0; -@@ -23,10 +29,13 @@ - private static final int INV_SLOT_END = 37; - private static final int USE_ROW_SLOT_START = 37; - private static final int USE_ROW_SLOT_END = 46; -- private final InventoryCrafting craftSlots; -- private final InventoryCraftResult resultSlots; -+ public final InventoryCrafting craftSlots; // PAIL private -> public -+ public final InventoryCraftResult resultSlots; // PAIL private -> public +@@ -27,6 +33,9 @@ + public final InventoryCraftResult resultSlots; public final ContainerAccess access; private final EntityHuman player; + // CraftBukkit start @@ -41,30 +35,26 @@ + // CraftBukkit end this.access = containeraccess; this.player = playerinventory.player; - this.a((Slot) (new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 124, 35))); -@@ -71,9 +83,10 @@ - RecipeCrafting recipecrafting = (RecipeCrafting) optional.get(); - - if (inventorycraftresult.setRecipeUsed(world, entityplayer, recipecrafting)) { -- itemstack = recipecrafting.a((IInventory) inventorycrafting); -+ itemstack = recipecrafting.a(inventorycrafting); // CraftBukkit - decompile error + this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 124, 35)); +@@ -74,6 +86,7 @@ + itemstack = recipecrafting.assemble(inventorycrafting); } } + itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, inventorycraftresult, itemstack, container.getBukkitView(), optional.orElse(null) instanceof RecipeRepair); // CraftBukkit inventorycraftresult.setItem(0, itemstack); - container.a(0, itemstack); + container.setRemoteSlot(0, itemstack); @@ -114,6 +127,7 @@ @Override - public boolean canUse(EntityHuman entityhuman) { + public boolean stillValid(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return a(this.access, entityhuman, Blocks.CRAFTING_TABLE); + return stillValid(this.access, entityhuman, Blocks.CRAFTING_TABLE); } @@ -202,4 +216,17 @@ - public boolean d(int i) { - return i != this.m(); + public boolean shouldMoveToInventory(int i) { + return i != this.getResultSlotIndex(); } + + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/Containers.patch b/paper-server/nms-patches/net/minecraft/world/inventory/Containers.patch index 06b80e5095..eb322eead2 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/Containers.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/Containers.patch @@ -10,22 +10,13 @@ + public class Containers<T extends Container> { - public static final Containers<ContainerChest> GENERIC_9x1 = a("generic_9x1", ContainerChest::a); + public static final Containers<ContainerChest> GENERIC_9x1 = register("generic_9x1", ContainerChest::oneRow); @@ -22,7 +26,7 @@ - public static final Containers<ContainerGrindstone> GRINDSTONE = a("grindstone", ContainerGrindstone::new); - public static final Containers<ContainerHopper> HOPPER = a("hopper", ContainerHopper::new); - public static final Containers<ContainerLectern> LECTERN = a("lectern", (i, playerinventory) -> { + public static final Containers<ContainerGrindstone> GRINDSTONE = register("grindstone", ContainerGrindstone::new); + public static final Containers<ContainerHopper> HOPPER = register("hopper", ContainerHopper::new); + public static final Containers<ContainerLectern> LECTERN = register("lectern", (i, playerinventory) -> { - return new ContainerLectern(i); + return new ContainerLectern(i, playerinventory); // CraftBukkit }); - public static final Containers<ContainerLoom> LOOM = a("loom", ContainerLoom::new); - public static final Containers<ContainerMerchant> MERCHANT = a("merchant", ContainerMerchant::new); -@@ -34,7 +38,7 @@ - private final Containers.Supplier<T> constructor; - - private static <T extends Container> Containers<T> a(String s, Containers.Supplier<T> containers_supplier) { -- return (Containers) IRegistry.a(IRegistry.MENU, s, (Object) (new Containers<>(containers_supplier))); -+ return (Containers) IRegistry.a(IRegistry.MENU, s, (new Containers<>(containers_supplier))); // CraftBukkit - decompile error - } - - private Containers(Containers.Supplier<T> containers_supplier) { + public static final Containers<ContainerLoom> LOOM = register("loom", ContainerLoom::new); + public static final Containers<ContainerMerchant> MERCHANT = register("merchant", ContainerMerchant::new); diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/InventoryCraftResult.patch b/paper-server/nms-patches/net/minecraft/world/inventory/InventoryCraftResult.patch index 55322ce045..0a95d8ce79 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/InventoryCraftResult.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/InventoryCraftResult.patch @@ -50,5 +50,5 @@ + // CraftBukkit end + public InventoryCraftResult() { - this.itemStacks = NonNullList.a(1, ItemStack.EMPTY); + this.itemStacks = NonNullList.withSize(1, ItemStack.EMPTY); } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/InventoryCrafting.patch b/paper-server/nms-patches/net/minecraft/world/inventory/InventoryCrafting.patch index 2808a16839..2e20505b00 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/InventoryCrafting.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/InventoryCrafting.patch @@ -83,5 +83,5 @@ + // CraftBukkit end + public InventoryCrafting(Container container, int i, int j) { - this.items = NonNullList.a(i * j, ItemStack.EMPTY); + this.items = NonNullList.withSize(i * j, ItemStack.EMPTY); this.menu = container; diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/InventoryEnderChest.patch b/paper-server/nms-patches/net/minecraft/world/inventory/InventoryEnderChest.patch index b89af3ab90..97dda208e5 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/InventoryEnderChest.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/InventoryEnderChest.patch @@ -22,7 +22,7 @@ + + @Override + public Location getLocation() { -+ return this.activeChest != null ? new Location(this.activeChest.getWorld().getWorld(), this.activeChest.getPosition().getX(), this.activeChest.getPosition().getY(), this.activeChest.getPosition().getZ()) : null; ++ return this.activeChest != null ? new Location(this.activeChest.getLevel().getWorld(), this.activeChest.getBlockPos().getX(), this.activeChest.getBlockPos().getY(), this.activeChest.getBlockPos().getZ()) : null; + } - public InventoryEnderChest() { @@ -32,4 +32,4 @@ + // CraftBukkit end } - public void a(TileEntityEnderChest tileentityenderchest) { + public void setActiveChest(TileEntityEnderChest tileentityenderchest) { diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/InventoryMerchant.patch b/paper-server/nms-patches/net/minecraft/world/inventory/InventoryMerchant.patch index e2a058c4d8..a2dec8965d 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/InventoryMerchant.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/InventoryMerchant.patch @@ -62,5 +62,5 @@ + // CraftBukkit end + public InventoryMerchant(IMerchant imerchant) { - this.itemStacks = NonNullList.a(3, ItemStack.EMPTY); + this.itemStacks = NonNullList.withSize(3, ItemStack.EMPTY); this.merchant = imerchant; diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/SlotFurnaceResult.patch b/paper-server/nms-patches/net/minecraft/world/inventory/SlotFurnaceResult.patch index 0d556d1acf..26c7ac041d 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/SlotFurnaceResult.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/SlotFurnaceResult.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/inventory/SlotFurnaceResult.java +++ b/net/minecraft/world/inventory/SlotFurnaceResult.java @@ -46,7 +46,7 @@ - protected void b_(ItemStack itemstack) { - itemstack.a(this.player.level, this.player, this.removeCount); + protected void checkTakeAchievements(ItemStack itemstack) { + itemstack.onCraftedBy(this.player.level, this.player, this.removeCount); if (this.player instanceof EntityPlayer && this.container instanceof TileEntityFurnace) { -- ((TileEntityFurnace) this.container).a((EntityPlayer) this.player); -+ ((TileEntityFurnace) this.container).a((EntityPlayer) this.player, itemstack, this.removeCount); // CraftBukkit +- ((TileEntityFurnace) this.container).awardUsedRecipesAndPopExperience((EntityPlayer) this.player); ++ ((TileEntityFurnace) this.container).awardUsedRecipesAndPopExperience((EntityPlayer) this.player, itemstack, this.removeCount); // CraftBukkit } this.removeCount = 0; diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemArmor.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemArmor.patch index 33c3db77aa..999c1df653 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemArmor.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemArmor.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemArmor.java +++ b/net/minecraft/world/item/ItemArmor.java -@@ -28,6 +28,11 @@ +@@ -27,6 +27,11 @@ import net.minecraft.world.level.block.BlockDispenser; import net.minecraft.world.phys.AxisAlignedBB; @@ -12,13 +12,13 @@ public class ItemArmor extends Item implements ItemWearable { private static final UUID[] ARMOR_MODIFIER_UUID_PER_SLOT = new UUID[]{UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")}; -@@ -54,8 +59,34 @@ +@@ -53,8 +58,34 @@ EntityLiving entityliving = (EntityLiving) list.get(0); EnumItemSlot enumitemslot = EntityInsentient.getEquipmentSlotForItem(itemstack); - ItemStack itemstack1 = itemstack.cloneAndSubtract(1); + ItemStack itemstack1 = itemstack.split(1); + // CraftBukkit start -+ World world = isourceblock.getWorld(); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ World world = isourceblock.getLevel(); ++ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityliving.getBukkitEntity()); @@ -27,12 +27,12 @@ + } + + if (event.isCancelled()) { -+ itemstack.add(1); ++ itemstack.grow(1); + return false; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.add(1); ++ itemstack.grow(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); @@ -42,9 +42,9 @@ + } + } -- entityliving.setSlot(enumitemslot, itemstack1); -+ entityliving.setSlot(enumitemslot, CraftItemStack.asNMSCopy(event.getItem())); +- entityliving.setItemSlot(enumitemslot, itemstack1); ++ entityliving.setItemSlot(enumitemslot, CraftItemStack.asNMSCopy(event.getItem())); + // CraftBukkit end if (entityliving instanceof EntityInsentient) { - ((EntityInsentient) entityliving).a(enumitemslot, 2.0F); - ((EntityInsentient) entityliving).setPersistent(); + ((EntityInsentient) entityliving).setDropChance(enumitemslot, 2.0F); + ((EntityInsentient) entityliving).setPersistenceRequired(); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemArmorStand.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemArmorStand.patch index d1dee715e5..d097fa5062 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemArmorStand.patch +++ b/paper-server/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 -@@ -58,6 +58,11 @@ +@@ -55,6 +55,11 @@ - entityarmorstand.setPositionRotation(entityarmorstand.locX(), entityarmorstand.locY(), entityarmorstand.locZ(), f, 0.0F); - this.a(entityarmorstand, world.random); + entityarmorstand.moveTo(entityarmorstand.getX(), entityarmorstand.getY(), entityarmorstand.getZ(), f, 0.0F); + this.randomizePose(entityarmorstand, world.random); + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(itemactioncontext, entityarmorstand).isCancelled()) { + return EnumInteractionResult.FAIL; + } + // CraftBukkit end - worldserver.addAllEntities(entityarmorstand); - world.playSound((EntityHuman) null, entityarmorstand.locX(), entityarmorstand.locY(), entityarmorstand.locZ(), SoundEffects.ARMOR_STAND_PLACE, SoundCategory.BLOCKS, 0.75F, 0.8F); - world.a((Entity) itemactioncontext.getEntity(), GameEvent.ENTITY_PLACE, (Entity) entityarmorstand); + worldserver.addFreshEntityWithPassengers(entityarmorstand); + world.playSound((EntityHuman) null, entityarmorstand.getX(), entityarmorstand.getY(), entityarmorstand.getZ(), SoundEffects.ARMOR_STAND_PLACE, SoundCategory.BLOCKS, 0.75F, 0.8F); + world.gameEvent(itemactioncontext.getPlayer(), GameEvent.ENTITY_PLACE, (Entity) entityarmorstand); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemBlock.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemBlock.patch index d7f9148db8..6f3444b523 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemBlock.patch +++ b/paper-server/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 -@@ -34,6 +34,13 @@ +@@ -33,6 +33,13 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -13,24 +13,24 @@ + public class ItemBlock extends Item { - public static final String BLOCK_ENTITY_TAG = "BlockEntityTag"; -@@ -69,6 +76,12 @@ + private static final String BLOCK_ENTITY_TAG = "BlockEntityTag"; +@@ -68,6 +75,12 @@ return EnumInteractionResult.FAIL; } else { - IBlockData iblockdata = this.c(blockactioncontext1); + IBlockData iblockdata = this.getPlacementState(blockactioncontext1); + // CraftBukkit start - special case for handling block placement with water lilies and snow buckets + org.bukkit.block.BlockState blockstate = null; + if (this instanceof ItemWaterLily || this instanceof SolidBucketItem) { -+ blockstate = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(blockactioncontext1.getWorld(), blockactioncontext1.getClickPosition()); ++ blockstate = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(blockactioncontext1.getLevel(), blockactioncontext1.getClickedPos()); + } + // CraftBukkit end if (iblockdata == null) { return EnumInteractionResult.FAIL; -@@ -85,6 +98,19 @@ - iblockdata1 = this.a(blockposition, world, itemstack, iblockdata1); - this.a(blockposition, world, entityhuman, itemstack, iblockdata1); - iblockdata1.getBlock().postPlace(world, blockposition, iblockdata1, entityhuman, itemstack); +@@ -84,6 +97,19 @@ + iblockdata1 = this.updateBlockStateFromTag(blockposition, world, itemstack, iblockdata1); + this.updateCustomBlockEntityTag(blockposition, world, entityhuman, itemstack, iblockdata1); + iblockdata1.getBlock().setPlacedBy(world, blockposition, iblockdata1, entityhuman, itemstack); + // CraftBukkit start + if (blockstate != null) { + org.bukkit.event.block.BlockPlaceEvent placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent((WorldServer) world, entityhuman, blockactioncontext1.getHand(), blockstate, blockposition.getX(), blockposition.getY(), blockposition.getZ()); @@ -45,21 +45,21 @@ + } + // CraftBukkit end if (entityhuman instanceof EntityPlayer) { - CriterionTriggers.PLACED_BLOCK.a((EntityPlayer) entityhuman, blockposition, itemstack); + CriterionTriggers.PLACED_BLOCK.trigger((EntityPlayer) entityhuman, blockposition, itemstack); } -@@ -92,9 +118,9 @@ +@@ -91,9 +117,9 @@ - SoundEffectType soundeffecttype = iblockdata1.getStepSound(); + SoundEffectType soundeffecttype = iblockdata1.getSoundType(); -- world.playSound(entityhuman, blockposition, this.a(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); -+ // world.playSound(entityhuman, blockposition, this.a(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); - world.a((Entity) entityhuman, GameEvent.BLOCK_PLACE, blockposition); +- 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(entityhuman, GameEvent.BLOCK_PLACE, blockposition); - if (entityhuman == null || !entityhuman.getAbilities().instabuild) { + if ((entityhuman == null || !entityhuman.getAbilities().instabuild) && itemstack != ItemStack.EMPTY) { // CraftBukkit - itemstack.subtract(1); + itemstack.shrink(1); } -@@ -130,6 +156,21 @@ +@@ -129,6 +155,21 @@ if (nbttagcompound != null) { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("BlockStateTag"); @@ -68,7 +68,7 @@ + } + + if (iblockdata1 != iblockdata) { -+ world.setTypeAndData(blockposition, iblockdata1, 2); ++ world.setBlock(blockposition, iblockdata1, 2); + } + + return iblockdata1; @@ -78,44 +78,44 @@ + IBlockData iblockdata1 = iblockdata; + { + // CraftBukkit end - BlockStateList<Block, IBlockData> blockstatelist = iblockdata.getBlock().getStates(); - Iterator iterator = nbttagcompound1.getKeys().iterator(); + BlockStateList<Block, IBlockData> blockstatelist = iblockdata.getBlock().getStateDefinition(); + Iterator iterator = nbttagcompound1.getAllKeys().iterator(); -@@ -144,11 +185,6 @@ +@@ -143,11 +184,6 @@ } } } - - if (iblockdata1 != iblockdata) { -- world.setTypeAndData(blockposition, iblockdata1, 2); +- world.setBlock(blockposition, iblockdata1, 2); - } - return iblockdata1; } -@@ -161,8 +197,15 @@ - protected boolean b(BlockActionContext blockactioncontext, IBlockData iblockdata) { - EntityHuman entityhuman = blockactioncontext.getEntity(); - VoxelShapeCollision voxelshapecollision = entityhuman == null ? VoxelShapeCollision.a() : VoxelShapeCollision.a((Entity) entityhuman); +@@ -160,8 +196,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.isCheckCollisions() || iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition())) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition(), voxelshapecollision); -+ org.bukkit.entity.Player player = (blockactioncontext.getEntity() instanceof EntityPlayer) ? (org.bukkit.entity.Player) blockactioncontext.getEntity().getBukkitEntity() : null; ++ 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; + -+ BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()), player, CraftBlockData.fromData(iblockdata), defaultReturn); -+ blockactioncontext.getWorld().getCraftServer().getPluginManager().callEvent(event); ++ BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(blockactioncontext.getLevel(), blockactioncontext.getClickedPos()), player, CraftBlockData.fromData(iblockdata), defaultReturn); ++ blockactioncontext.getLevel().getCraftServer().getPluginManager().callEvent(event); -- return (!this.isCheckCollisions() || iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition())) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition(), voxelshapecollision); +- return (!this.mustSurvive() || iblockdata.canSurvive(blockactioncontext.getLevel(), blockactioncontext.getClickedPos())) && blockactioncontext.getLevel().isUnobstructed(iblockdata, blockactioncontext.getClickedPos(), voxelshapecollision); + return event.isBuildable(); + // CraftBukkit end } - protected boolean isCheckCollisions() { -@@ -247,7 +290,7 @@ + protected boolean mustSurvive() { +@@ -244,7 +287,7 @@ - if (nbttagcompound != null) { - NBTTagList nbttaglist = nbttagcompound.getCompound("BlockEntityTag").getList("Items", 10); + if (nbttagcompound != null && nbttagcompound.contains("Items", 9)) { + NBTTagList nbttaglist = nbttagcompound.getList("Items", 10); - Stream stream = nbttaglist.stream(); + Stream<net.minecraft.nbt.NBTBase> stream = nbttaglist.stream(); // CraftBukkit - decompile error Objects.requireNonNull(NBTTagCompound.class); - ItemLiquidUtil.a(entityitem, stream.map(NBTTagCompound.class::cast).map(ItemStack::a)); + ItemLiquidUtil.onContainerDestroyed(entityitem, stream.map(NBTTagCompound.class::cast).map(ItemStack::of)); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemBoat.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemBoat.patch index 40ed842258..8d1df8bb7b 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemBoat.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemBoat.patch @@ -5,29 +5,29 @@ if (movingobjectpositionblock.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.getBlockPosition(), movingobjectpositionblock.getDirection(), itemstack, enumhand); ++ 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, enumhand); + + if (event.isCancelled()) { + return InteractionResultWrapper.pass(itemstack); + } + // CraftBukkit end - EntityBoat entityboat = new EntityBoat(world, movingobjectpositionblock.getPos().x, movingobjectpositionblock.getPos().y, movingobjectpositionblock.getPos().z); + EntityBoat entityboat = new EntityBoat(world, movingobjectpositionblock.getLocation().x, movingobjectpositionblock.getLocation().y, movingobjectpositionblock.getLocation().z); entityboat.setType(this.type); @@ -64,7 +71,15 @@ return InteractionResultWrapper.fail(itemstack); } else { if (!world.isClientSide) { -- world.addEntity(entityboat); +- world.addFreshEntity(entityboat); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(world, movingobjectpositionblock.getBlockPosition(), movingobjectpositionblock.getDirection(), entityhuman, entityboat).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(world, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), entityhuman, entityboat).isCancelled()) { + return InteractionResultWrapper.fail(itemstack); + } + -+ if (!world.addEntity(entityboat)) { ++ if (!world.addFreshEntity(entityboat)) { + return InteractionResultWrapper.pass(itemstack); + } + // CraftBukkit end - world.a((Entity) entityhuman, GameEvent.ENTITY_PLACE, new BlockPosition(movingobjectpositionblock.getPos())); + world.gameEvent(entityhuman, GameEvent.ENTITY_PLACE, new BlockPosition(movingobjectpositionblock.getLocation())); if (!entityhuman.getAbilities().instabuild) { - itemstack.subtract(1); + itemstack.shrink(1); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemBoneMeal.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemBoneMeal.patch index e42030e134..79a8ebdc9a 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemBoneMeal.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemBoneMeal.patch @@ -3,13 +3,13 @@ @@ -35,6 +35,12 @@ @Override - public EnumInteractionResult a(ItemActionContext itemactioncontext) { + public EnumInteractionResult useOn(ItemActionContext itemactioncontext) { + // CraftBukkit start - extract bonemeal application logic to separate, static method + return applyBonemeal(itemactioncontext); + } + + public static EnumInteractionResult applyBonemeal(ItemActionContext itemactioncontext) { + // CraftBukkit end - World world = itemactioncontext.getWorld(); - BlockPosition blockposition = itemactioncontext.getClickPosition(); - BlockPosition blockposition1 = blockposition.shift(itemactioncontext.getClickedFace()); + World world = itemactioncontext.getLevel(); + BlockPosition blockposition = itemactioncontext.getClickedPos(); + BlockPosition blockposition1 = blockposition.relative(itemactioncontext.getClickedFace()); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemBow.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemBow.patch index d5075ad755..44da9e2cbf 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemBow.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemBow.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/item/ItemBow.java +++ b/net/minecraft/world/item/ItemBow.java @@ -64,6 +64,14 @@ - if (EnchantmentManager.getEnchantmentLevel(Enchantments.FLAMING_ARROWS, itemstack) > 0) { - entityarrow.setOnFire(100); + if (EnchantmentManager.getItemEnchantmentLevel(Enchantments.FLAMING_ARROWS, itemstack) > 0) { + entityarrow.setSecondsOnFire(100); } + // CraftBukkit start -+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityhuman, itemstack, itemstack1, entityarrow, entityhuman.getRaisedHand(), f, !flag1); ++ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityhuman, itemstack, itemstack1, entityarrow, entityhuman.getUsedItemHand(), f, !flag1); + if (event.isCancelled()) { + event.getProjectile().remove(); + return; @@ -13,16 +13,16 @@ + flag1 = !event.shouldConsumeItem(); + // CraftBukkit end - itemstack.damage(1, entityhuman, (entityhuman1) -> { - entityhuman1.broadcastItemBreak(entityhuman.getRaisedHand()); + itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { + entityhuman1.broadcastBreakEvent(entityhuman.getUsedItemHand()); @@ -72,7 +80,16 @@ entityarrow.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY; } -- world.addEntity(entityarrow); +- world.addFreshEntity(entityarrow); + // CraftBukkit start + if (event.getProjectile() == entityarrow.getBukkitEntity()) { -+ if (!world.addEntity(entityarrow)) { ++ if (!world.addFreshEntity(entityarrow)) { + if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { + ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); + } @@ -32,4 +32,4 @@ + // CraftBukkit end } - world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (world.getRandom().nextFloat() * 0.4F + 1.2F) + f * 0.5F); + world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (world.getRandom().nextFloat() * 0.4F + 1.2F) + f * 0.5F); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemBucket.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemBucket.patch index e5c2339eb7..24b8c7a548 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemBucket.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemBucket.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemBucket.java +++ b/net/minecraft/world/item/ItemBucket.java -@@ -31,6 +31,16 @@ +@@ -29,6 +29,16 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.MovingObjectPositionBlock; @@ -17,71 +17,71 @@ public class ItemBucket extends Item implements DispensibleContainerItem { public final FluidType content; -@@ -61,6 +71,17 @@ - iblockdata = world.getType(blockposition); +@@ -59,6 +69,17 @@ + iblockdata = world.getBlockState(blockposition); if (iblockdata.getBlock() instanceof IFluidSource) { IFluidSource ifluidsource = (IFluidSource) iblockdata.getBlock(); + // CraftBukkit start -+ ItemStack dummyFluid = ifluidsource.removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); ++ ItemStack dummyFluid = ifluidsource.pickupBlock(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); + if (dummyFluid.isEmpty()) return InteractionResultWrapper.fail(itemstack); // Don't fire event if the bucket won't be filled. + PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) world, entityhuman, blockposition, blockposition, movingobjectpositionblock.getDirection(), itemstack, dummyFluid.getItem()); + + if (event.isCancelled()) { -+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-5163 (see PlayerInteractManager) ++ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-5163 (see PlayerInteractManager) + ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541 + return InteractionResultWrapper.fail(itemstack); + } + // CraftBukkit end - ItemStack itemstack1 = ifluidsource.removeFluid(world, blockposition, iblockdata); + ItemStack itemstack1 = ifluidsource.pickupBlock(world, blockposition, iblockdata); if (!itemstack1.isEmpty()) { -@@ -69,7 +90,7 @@ +@@ -67,7 +88,7 @@ entityhuman.playSound(soundeffect, 1.0F, 1.0F); }); - world.a((Entity) entityhuman, GameEvent.FLUID_PICKUP, blockposition); -- ItemStack itemstack2 = ItemLiquidUtil.a(itemstack, entityhuman, itemstack1); -+ ItemStack itemstack2 = ItemLiquidUtil.a(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit + world.gameEvent(entityhuman, 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.a((EntityPlayer) entityhuman, itemstack1); -@@ -84,7 +105,7 @@ - iblockdata = world.getType(blockposition); + CriterionTriggers.FILLED_BUCKET.trigger((EntityPlayer) entityhuman, itemstack1); +@@ -82,7 +103,7 @@ + iblockdata = world.getBlockState(blockposition); BlockPosition blockposition2 = iblockdata.getBlock() instanceof IFluidContainer && this.content == FluidTypes.WATER ? blockposition : blockposition1; -- if (this.a(entityhuman, world, blockposition2, movingobjectpositionblock)) { -+ if (this.a(entityhuman, world, blockposition2, movingobjectpositionblock, movingobjectpositionblock.getDirection(), blockposition, itemstack)) { // CraftBukkit - this.a(entityhuman, world, itemstack, blockposition2); +- if (this.emptyContents(entityhuman, world, blockposition2, movingobjectpositionblock)) { ++ if (this.emptyContents(entityhuman, world, blockposition2, movingobjectpositionblock, movingobjectpositionblock.getDirection(), blockposition, itemstack)) { // CraftBukkit + this.checkExtraContent(entityhuman, world, itemstack, blockposition2); if (entityhuman instanceof EntityPlayer) { - CriterionTriggers.PLACED_BLOCK.a((EntityPlayer) entityhuman, blockposition2, itemstack); -@@ -111,6 +132,11 @@ + CriterionTriggers.PLACED_BLOCK.trigger((EntityPlayer) entityhuman, blockposition2, itemstack); +@@ -109,6 +130,11 @@ @Override - public boolean a(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock) { -+ return a(entityhuman, world, blockposition, movingobjectpositionblock, null, null, null); + public boolean emptyContents(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock) { ++ return emptyContents(entityhuman, world, blockposition, movingobjectpositionblock, null, null, null); + } + -+ public boolean a(EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock, EnumDirection enumdirection, BlockPosition clicked, ItemStack itemstack) { ++ public boolean emptyContents(EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock, EnumDirection enumdirection, BlockPosition clicked, ItemStack itemstack) { + // CraftBukkit end if (!(this.content instanceof FluidTypeFlowing)) { return false; } else { -@@ -120,8 +146,18 @@ - boolean flag = iblockdata.a(this.content); - boolean flag1 = iblockdata.isAir() || flag || block instanceof IFluidContainer && ((IFluidContainer) block).canPlace(world, blockposition, iblockdata, this.content); +@@ -118,8 +144,18 @@ + boolean flag = iblockdata.canBeReplaced(this.content); + boolean flag1 = iblockdata.isAir() || flag || block instanceof IFluidContainer && ((IFluidContainer) block).canPlaceLiquid(world, blockposition, iblockdata, this.content); + // CraftBukkit start + if (flag1 && entityhuman != null) { + PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent((WorldServer) world, entityhuman, blockposition, clicked, enumdirection, itemstack); + if (event.isCancelled()) { -+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-4238: needed when looking through entity ++ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-4238: needed when looking through entity + ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541 + return false; + } + } + // CraftBukkit end if (!flag1) { -- return movingobjectpositionblock != null && this.a(entityhuman, world, movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null); -+ return movingobjectpositionblock != null && this.a(entityhuman, world, movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null, enumdirection, clicked, itemstack); // CraftBukkit - } else if (world.getDimensionManager().isNether() && this.content.a((Tag) TagsFluid.WATER)) { +- 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); // CraftBukkit + } else if (world.dimensionType().ultraWarm() && this.content.is(TagsFluid.WATER)) { int i = blockposition.getX(); int j = blockposition.getY(); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemChorusFruit.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemChorusFruit.patch index 401a52084d..d0deee1403 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemChorusFruit.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemChorusFruit.patch @@ -4,9 +4,9 @@ entityliving.stopRiding(); } -- if (entityliving.a(d3, d4, d5, true)) { +- if (entityliving.randomTeleport(d3, d4, d5, true)) { + // CraftBukkit start - handle canceled status of teleport event -+ java.util.Optional<Boolean> status = entityliving.safeTeleport(d3, d4, d5, true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT); ++ java.util.Optional<Boolean> status = entityliving.randomTeleport(d3, d4, d5, true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT); + + if (!status.isPresent()) { + // teleport event was canceled, no more tries diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemCrossbow.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemCrossbow.patch index c92cbc5b71..ebf9ea35fd 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemCrossbow.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemCrossbow.patch @@ -3,33 +3,33 @@ @@ -114,6 +114,10 @@ if (itemstack1.isEmpty() && flag) { itemstack1 = new ItemStack(Items.ARROW); - itemstack2 = itemstack1.cloneItemStack(); + itemstack2 = itemstack1.copy(); + // CraftBukkit start - SPIGOT-4870, MC-150847 + } else if (itemstack1.isEmpty()) { + return false; + // CraftBukkit end } - if (!a(entityliving, itemstack, itemstack1, k > 0, flag)) { + if (!loadProjectile(entityliving, itemstack, itemstack1, k > 0, flag)) { @@ -238,11 +242,27 @@ - vector3fa.a(quaternion); - ((IProjectile) object).shoot((double) vector3fa.a(), (double) vector3fa.b(), (double) vector3fa.c(), f1, f2); + vector3fa.transform(quaternion); + ((IProjectile) object).shoot((double) vector3fa.x(), (double) vector3fa.y(), (double) vector3fa.z(), f1, f2); } + // CraftBukkit start -+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityliving, itemstack, itemstack1, (Entity) object, entityliving.getRaisedHand(), f, true); ++ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityliving, itemstack, itemstack1, (Entity) object, entityliving.getUsedItemHand(), f, true); + if (event.isCancelled()) { + event.getProjectile().remove(); + return; + } + // CraftBukkit end - itemstack.damage(flag1 ? 3 : 1, entityliving, (entityliving1) -> { - entityliving1.broadcastItemBreak(enumhand); + itemstack.hurtAndBreak(flag1 ? 3 : 1, entityliving, (entityliving1) -> { + entityliving1.broadcastBreakEvent(enumhand); }); -- world.addEntity((Entity) object); +- world.addFreshEntity((Entity) object); + // CraftBukkit start + if (event.getProjectile() == ((Entity) object).getBukkitEntity()) { -+ if (!world.addEntity((Entity) object)) { ++ if (!world.addFreshEntity((Entity) object)) { + if (entityliving instanceof EntityPlayer) { + ((EntityPlayer) entityliving).getBukkitEntity().updateInventory(); + } @@ -37,6 +37,6 @@ + } + } + // CraftBukkit end - world.playSound((EntityHuman) null, entityliving.locX(), entityliving.locY(), entityliving.locZ(), SoundEffects.CROSSBOW_SHOOT, SoundCategory.PLAYERS, 1.0F, f); + world.playSound((EntityHuman) null, entityliving.getX(), entityliving.getY(), entityliving.getZ(), SoundEffects.CROSSBOW_SHOOT, SoundCategory.PLAYERS, 1.0F, f); } } diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemDebugStick.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemDebugStick.patch index 0f090a31d0..13e7e335ae 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemDebugStick.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemDebugStick.patch @@ -8,9 +8,9 @@ @@ -97,7 +98,7 @@ } - private static <T extends Comparable<T>> IBlockData a(IBlockData iblockdata, IBlockState<T> iblockstate, boolean flag) { -- return (IBlockData) iblockdata.set(iblockstate, (Comparable) a((Iterable) iblockstate.getValues(), (Object) iblockdata.get(iblockstate), flag)); -+ return (IBlockData) iblockdata.set(iblockstate, a(iblockstate.getValues(), iblockdata.get(iblockstate), flag)); // CraftBukkit - decompile error + private static <T extends Comparable<T>> IBlockData cycleState(IBlockData iblockdata, IBlockState<T> iblockstate, boolean flag) { +- return (IBlockData) iblockdata.setValue(iblockstate, (Comparable) getRelative(iblockstate.getPossibleValues(), iblockdata.getValue(iblockstate), flag)); ++ return (IBlockData) iblockdata.setValue(iblockstate, getRelative(iblockstate.getPossibleValues(), iblockdata.getValue(iblockstate), flag)); // CraftBukkit - decompile error } - private static <T> T a(Iterable<T> iterable, @Nullable T t0, boolean flag) { + private static <T> T getRelative(Iterable<T> iterable, @Nullable T t0, boolean flag) { diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemDye.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemDye.patch index 193ba8fe27..91a7169386 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemDye.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemDye.patch @@ -15,7 +15,7 @@ if (!entityhuman.level.isClientSide) { - entitysheep.setColor(this.dyeColor); + // CraftBukkit start -+ byte bColor = (byte) this.dyeColor.getColorIndex(); ++ byte bColor = (byte) this.dyeColor.getId(); + SheepDyeWoolEvent event = new SheepDyeWoolEvent((org.bukkit.entity.Sheep) entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByWoolData(bColor), (org.bukkit.entity.Player) entityhuman.getBukkitEntity()); + entitysheep.level.getCraftServer().getPluginManager().callEvent(event); + @@ -23,8 +23,8 @@ + return EnumInteractionResult.PASS; + } + -+ entitysheep.setColor(EnumColor.fromColorIndex((byte) event.getColor().getWoolData())); ++ entitysheep.setColor(EnumColor.byId((byte) event.getColor().getWoolData())); + // CraftBukkit end - itemstack.subtract(1); + itemstack.shrink(1); } diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemEgg.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemEgg.patch index 80b3634faf..40f4faa8e8 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemEgg.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemEgg.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/item/ItemEgg.java +++ b/net/minecraft/world/item/ItemEgg.java @@ -19,14 +19,22 @@ - public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) { - ItemStack itemstack = entityhuman.b(enumhand); + public InteractionResultWrapper<ItemStack> use(World world, EntityHuman entityhuman, EnumHand enumhand) { + ItemStack itemstack = entityhuman.getItemInHand(enumhand); -- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); -+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down +- 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 if (!world.isClientSide) { EntityEgg entityegg = new EntityEgg(world, entityhuman); entityegg.setItem(itemstack); - entityegg.a(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F); -- world.addEntity(entityegg); + entityegg.shootFromRotation(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F); +- world.addFreshEntity(entityegg); + // CraftBukkit start -+ if (!world.addEntity(entityegg)) { ++ if (!world.addFreshEntity(entityegg)) { + if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { + ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); + } @@ -21,7 +21,7 @@ + } + // CraftBukkit end } -+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), 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)); - entityhuman.b(StatisticList.ITEM_USED.b(this)); + entityhuman.awardStat(StatisticList.ITEM_USED.get(this)); if (!entityhuman.getAbilities().instabuild) { diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemEndCrystal.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemEndCrystal.patch index 5e61434a74..6f31b1a871 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemEndCrystal.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemEndCrystal.patch @@ -3,12 +3,12 @@ @@ -46,6 +46,11 @@ EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(world, d0 + 0.5D, d1, d2 + 0.5D); - entityendercrystal.setShowingBottom(false); + entityendercrystal.setShowBottom(false); + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(itemactioncontext, entityendercrystal).isCancelled()) { + return EnumInteractionResult.FAIL; + } + // CraftBukkit end - world.addEntity(entityendercrystal); - world.a((Entity) itemactioncontext.getEntity(), GameEvent.ENTITY_PLACE, blockposition1); - EnderDragonBattle enderdragonbattle = ((WorldServer) world).getDragonBattle(); + world.addFreshEntity(entityendercrystal); + world.gameEvent(itemactioncontext.getPlayer(), GameEvent.ENTITY_PLACE, blockposition1); + EnderDragonBattle enderdragonbattle = ((WorldServer) world).dragonFight(); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemEnderEye.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemEnderEye.patch index faeb51ef47..c5ee54054f 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemEnderEye.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemEnderEye.patch @@ -3,13 +3,13 @@ @@ -85,7 +85,11 @@ entityendersignal.setItem(itemstack); - entityendersignal.a(blockposition); -- world.addEntity(entityendersignal); + entityendersignal.signalTo(blockposition); +- world.addFreshEntity(entityendersignal); + // CraftBukkit start -+ if (!world.addEntity(entityendersignal)) { ++ if (!world.addFreshEntity(entityendersignal)) { + return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack); + } + // CraftBukkit end if (entityhuman instanceof EntityPlayer) { - CriterionTriggers.USED_ENDER_EYE.a((EntityPlayer) entityhuman, blockposition); + CriterionTriggers.USED_ENDER_EYE.trigger((EntityPlayer) entityhuman, blockposition); } diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch index fec4ced19d..8ec7abc437 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/item/ItemEnderPearl.java +++ b/net/minecraft/world/item/ItemEnderPearl.java @@ -19,16 +19,24 @@ - public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) { - ItemStack itemstack = entityhuman.b(enumhand); + public InteractionResultWrapper<ItemStack> use(World world, EntityHuman entityhuman, EnumHand enumhand) { + ItemStack itemstack = entityhuman.getItemInHand(enumhand); -- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); -- entityhuman.getCooldownTracker().setCooldown(this, 20); +- 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)); +- entityhuman.getCooldowns().addCooldown(this, 20); + // CraftBukkit start - change order if (!world.isClientSide) { EntityEnderPearl entityenderpearl = new EntityEnderPearl(world, entityhuman); entityenderpearl.setItem(itemstack); - entityenderpearl.a(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F); -- world.addEntity(entityenderpearl); -+ if (!world.addEntity(entityenderpearl)) { + entityenderpearl.shootFromRotation(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F); +- world.addFreshEntity(entityenderpearl); ++ if (!world.addFreshEntity(entityenderpearl)) { + if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { + ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); + } @@ -21,10 +21,10 @@ + } } -+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); -+ entityhuman.getCooldownTracker().setCooldown(this, 20); ++ 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)); ++ entityhuman.getCooldowns().addCooldown(this, 20); + // CraftBukkit end + - entityhuman.b(StatisticList.ITEM_USED.b(this)); + entityhuman.awardStat(StatisticList.ITEM_USED.get(this)); if (!entityhuman.getAbilities().instabuild) { - itemstack.subtract(1); + itemstack.shrink(1); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemFireball.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemFireball.patch index 11a75bc982..4360d50ca6 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemFireball.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemFireball.patch @@ -1,31 +1,31 @@ --- a/net/minecraft/world/item/ItemFireball.java +++ b/net/minecraft/world/item/ItemFireball.java -@@ -34,12 +34,28 @@ - if (!BlockCampfire.h(iblockdata) && !CandleBlock.g(iblockdata) && !CandleCakeBlock.g(iblockdata)) { - blockposition = blockposition.shift(itemactioncontext.getClickedFace()); - if (BlockFireAbstract.a(world, blockposition, itemactioncontext.g())) { +@@ -32,12 +32,28 @@ + if (!BlockCampfire.canLight(iblockdata) && !CandleBlock.canLight(iblockdata) && !CandleCakeBlock.canLight(iblockdata)) { + blockposition = blockposition.relative(itemactioncontext.getClickedFace()); + if (BlockFireAbstract.canBePlacedAt(world, blockposition, itemactioncontext.getHorizontalDirection())) { + // CraftBukkit start - fire BlockIgniteEvent -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, itemactioncontext.getEntity()).isCancelled()) { -+ if (!itemactioncontext.getEntity().getAbilities().instabuild) { -+ itemactioncontext.getItemStack().subtract(1); ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, itemactioncontext.getPlayer()).isCancelled()) { ++ if (!itemactioncontext.getPlayer().getAbilities().instabuild) { ++ itemactioncontext.getItemInHand().shrink(1); + } + return EnumInteractionResult.PASS; + } + // CraftBukkit end - this.a(world, blockposition); - world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) world, blockposition)); - world.a((Entity) itemactioncontext.getEntity(), GameEvent.BLOCK_PLACE, blockposition); + this.playSound(world, blockposition); + world.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(world, blockposition)); + world.gameEvent(itemactioncontext.getPlayer(), GameEvent.BLOCK_PLACE, blockposition); flag = true; } } else { + // CraftBukkit start - fire BlockIgniteEvent -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, itemactioncontext.getEntity()).isCancelled()) { -+ if (!itemactioncontext.getEntity().getAbilities().instabuild) { -+ itemactioncontext.getItemStack().subtract(1); ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, itemactioncontext.getPlayer()).isCancelled()) { ++ if (!itemactioncontext.getPlayer().getAbilities().instabuild) { ++ itemactioncontext.getItemInHand().shrink(1); + } + return EnumInteractionResult.PASS; + } + // CraftBukkit end - this.a(world, blockposition); - world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockProperties.LIT, true)); - world.a((Entity) itemactioncontext.getEntity(), GameEvent.BLOCK_PLACE, blockposition); + this.playSound(world, blockposition); + world.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(BlockProperties.LIT, true)); + world.gameEvent(itemactioncontext.getPlayer(), GameEvent.BLOCK_PLACE, blockposition); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemFishingRod.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemFishingRod.patch index e9e890279d..b54fd2820f 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemFishingRod.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemFishingRod.patch @@ -10,16 +10,16 @@ public ItemFishingRod(Item.Info item_info) { @@ -34,12 +36,23 @@ - world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); - world.a((Entity) entityhuman, GameEvent.FISHING_ROD_REEL_IN, (Entity) entityhuman); + 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)); + world.gameEvent(entityhuman, GameEvent.FISHING_ROD_REEL_IN, (Entity) entityhuman); } else { -- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); -+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), 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((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)); if (!world.isClientSide) { - i = EnchantmentManager.c(itemstack); - int j = EnchantmentManager.b(itemstack); + i = EnchantmentManager.getFishingSpeedBonus(itemstack); + int j = EnchantmentManager.getFishingLuckBonus(itemstack); -- world.addEntity(new EntityFishingHook(entityhuman, world, j, i)); +- world.addFreshEntity(new EntityFishingHook(entityhuman, world, j, i)); + // CraftBukkit start + EntityFishingHook entityfishinghook = new EntityFishingHook(entityhuman, world, j, i); + PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.FishHook) entityfishinghook.getBukkitEntity(), PlayerFishEvent.State.FISHING); @@ -29,9 +29,9 @@ + entityhuman.fishing = null; + return InteractionResultWrapper.pass(itemstack); + } -+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); -+ world.addEntity(entityfishinghook); ++ 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.addFreshEntity(entityfishinghook); + // CraftBukkit end } - entityhuman.b(StatisticList.ITEM_USED.b(this)); + entityhuman.awardStat(StatisticList.ITEM_USED.get(this)); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemFlintAndSteel.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemFlintAndSteel.patch index 45d8083afc..f2dcd82d91 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemFlintAndSteel.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemFlintAndSteel.patch @@ -1,32 +1,32 @@ --- a/net/minecraft/world/item/ItemFlintAndSteel.java +++ b/net/minecraft/world/item/ItemFlintAndSteel.java -@@ -36,6 +36,14 @@ - BlockPosition blockposition1 = blockposition.shift(itemactioncontext.getClickedFace()); +@@ -34,6 +34,14 @@ + BlockPosition blockposition1 = blockposition.relative(itemactioncontext.getClickedFace()); - if (BlockFireAbstract.a(world, blockposition1, itemactioncontext.g())) { + if (BlockFireAbstract.canBePlacedAt(world, blockposition1, itemactioncontext.getHorizontalDirection())) { + // CraftBukkit start - Store the clicked block + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition1, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) { -+ itemactioncontext.getItemStack().damage(1, entityhuman, (entityhuman1) -> { -+ entityhuman1.broadcastItemBreak(itemactioncontext.getHand()); ++ itemactioncontext.getItemInHand().hurtAndBreak(1, entityhuman, (entityhuman1) -> { ++ entityhuman1.broadcastBreakEvent(itemactioncontext.getHand()); + }); + return EnumInteractionResult.PASS; + } + // CraftBukkit end world.playSound(entityhuman, blockposition1, SoundEffects.FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, world.getRandom().nextFloat() * 0.4F + 0.8F); - IBlockData iblockdata1 = BlockFireAbstract.a((IBlockAccess) world, blockposition1); + IBlockData iblockdata1 = BlockFireAbstract.getState(world, blockposition1); -@@ -55,6 +63,14 @@ +@@ -53,6 +61,14 @@ return EnumInteractionResult.FAIL; } } else { + // CraftBukkit start - Store the clicked block + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) { -+ itemactioncontext.getItemStack().damage(1, entityhuman, (entityhuman1) -> { -+ entityhuman1.broadcastItemBreak(itemactioncontext.getHand()); ++ itemactioncontext.getItemInHand().hurtAndBreak(1, entityhuman, (entityhuman1) -> { ++ entityhuman1.broadcastBreakEvent(itemactioncontext.getHand()); + }); + return EnumInteractionResult.PASS; + } + // CraftBukkit end world.playSound(entityhuman, blockposition, SoundEffects.FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, world.getRandom().nextFloat() * 0.4F + 0.8F); - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockProperties.LIT, true), 11); - world.a((Entity) entityhuman, GameEvent.BLOCK_PLACE, blockposition); + world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockProperties.LIT, true), 11); + world.gameEvent(entityhuman, GameEvent.BLOCK_PLACE, blockposition); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemHanging.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemHanging.patch index bf29dfed09..6a02560e64 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemHanging.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemHanging.patch @@ -17,7 +17,7 @@ if (((EntityHanging) object).survives()) { if (!world.isClientSide) { + // CraftBukkit start - fire HangingPlaceEvent -+ Player who = (itemactioncontext.getEntity() == null) ? null : (Player) itemactioncontext.getEntity().getBukkitEntity(); ++ Player who = (itemactioncontext.getPlayer() == null) ? null : (Player) itemactioncontext.getPlayer().getBukkitEntity(); + org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection); + @@ -28,6 +28,6 @@ + return EnumInteractionResult.FAIL; + } + // CraftBukkit end - ((EntityHanging) object).playPlaceSound(); - world.a((Entity) entityhuman, GameEvent.ENTITY_PLACE, blockposition); - world.addEntity((Entity) object); + ((EntityHanging) object).playPlacementSound(); + world.gameEvent(entityhuman, GameEvent.ENTITY_PLACE, blockposition); + world.addFreshEntity((Entity) object); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemLeash.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemLeash.patch index 81a45928da..594d080937 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemLeash.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemLeash.patch @@ -12,18 +12,18 @@ @@ -55,9 +57,25 @@ if (entityinsentient.getLeashHolder() == entityhuman) { if (entityleash == null) { - entityleash = EntityLeash.b(world, blockposition); + entityleash = EntityLeash.getOrCreateKnot(world, blockposition); + + // CraftBukkit start - fire HangingPlaceEvent + HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityleash.getBukkitEntity(), entityhuman != null ? (org.bukkit.entity.Player) entityhuman.getBukkitEntity() : null, world.getWorld().getBlockAt(i, j, k), org.bukkit.block.BlockFace.SELF); + world.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { -+ entityleash.die(); ++ entityleash.discard(); + return EnumInteractionResult.PASS; + } + // CraftBukkit end - entityleash.playPlaceSound(); + entityleash.playPlacementSound(); } + // CraftBukkit start @@ -32,6 +32,6 @@ + } + // CraftBukkit end + - entityinsentient.setLeashHolder(entityleash, true); + entityinsentient.setLeashedTo(entityleash, true); flag = true; } diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemMinecart.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemMinecart.patch index 9a6b82a158..4eea6ac4b5 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemMinecart.patch +++ b/paper-server/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 -@@ -20,6 +20,11 @@ +@@ -18,6 +18,11 @@ import net.minecraft.world.level.block.state.properties.BlockPropertyTrackPosition; import net.minecraft.world.level.gameevent.GameEvent; @@ -12,15 +12,15 @@ public class ItemMinecart extends Item { private static final IDispenseBehavior DISPENSE_ITEM_BEHAVIOR = new DispenseBehaviorItem() { -@@ -58,14 +63,43 @@ +@@ -56,14 +61,43 @@ } } -- EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(worldserver, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).type); +- EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).type); + // CraftBukkit start -+ // EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(world, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).b); -+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block2 = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ // EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).type); ++ ItemStack itemstack1 = itemstack.split(1); ++ org.bukkit.block.Block block2 = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseEvent event = new BlockDispenseEvent(block2, craftItem.clone(), new org.bukkit.util.Vector(d0, d1 + d3, d2)); @@ -29,12 +29,12 @@ + } + + if (event.isCancelled()) { -+ itemstack.add(1); ++ itemstack.grow(1); + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.add(1); ++ itemstack.grow(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); @@ -45,31 +45,31 @@ + } + + itemstack1 = CraftItemStack.asNMSCopy(event.getItem()); -+ EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ((ItemMinecart) itemstack1.getItem()).type); ++ EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ((ItemMinecart) itemstack1.getItem()).type); - if (itemstack.hasName()) { - entityminecartabstract.setCustomName(itemstack.getName()); + if (itemstack.hasCustomHoverName()) { + entityminecartabstract.setCustomName(itemstack.getHoverName()); } -- worldserver.addEntity(entityminecartabstract); -- itemstack.subtract(1); -+ if (!worldserver.addEntity(entityminecartabstract)) itemstack.add(1); -+ // itemstack.subtract(1); // CraftBukkit - handled during event processing +- worldserver.addFreshEntity(entityminecartabstract); +- itemstack.shrink(1); ++ if (!worldserver.addFreshEntity(entityminecartabstract)) itemstack.grow(1); ++ // itemstack.shrink(1); // CraftBukkit - handled during event processing + // CraftBukkit end return itemstack; } -@@ -107,7 +141,12 @@ - entityminecartabstract.setCustomName(itemstack.getName()); +@@ -105,7 +139,12 @@ + entityminecartabstract.setCustomName(itemstack.getHoverName()); } -- world.addEntity(entityminecartabstract); +- world.addFreshEntity(entityminecartabstract); + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(itemactioncontext, entityminecartabstract).isCancelled()) { + return EnumInteractionResult.FAIL; + } + // CraftBukkit end -+ if (!world.addEntity(entityminecartabstract)) return EnumInteractionResult.PASS; // CraftBukkit - world.a((Entity) itemactioncontext.getEntity(), GameEvent.ENTITY_PLACE, blockposition); ++ if (!world.addFreshEntity(entityminecartabstract)) return EnumInteractionResult.PASS; // CraftBukkit + world.gameEvent(itemactioncontext.getPlayer(), GameEvent.ENTITY_PLACE, blockposition); } diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemMonsterEgg.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemMonsterEgg.patch index 9e020d372d..ce70b724cd 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemMonsterEgg.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemMonsterEgg.patch @@ -3,14 +3,14 @@ @@ -179,7 +179,7 @@ return Optional.empty(); } else { - ((EntityInsentient) object).setPositionRotation(vec3d.getX(), vec3d.getY(), vec3d.getZ(), 0.0F, 0.0F); -- worldserver.addAllEntities((Entity) object); -+ worldserver.addAllEntities((Entity) object, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit - if (itemstack.hasName()) { - ((EntityInsentient) object).setCustomName(itemstack.getName()); + ((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 + if (itemstack.hasCustomHoverName()) { + ((EntityInsentient) object).setCustomName(itemstack.getHoverName()); } @@ -188,7 +188,7 @@ - itemstack.subtract(1); + itemstack.shrink(1); } - return Optional.of(object); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemPotion.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemPotion.patch index 8983ad4d62..8538affad4 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemPotion.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemPotion.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/ItemPotion.java +++ b/net/minecraft/world/item/ItemPotion.java -@@ -52,7 +52,7 @@ - if (mobeffect.getMobEffect().isInstant()) { - mobeffect.getMobEffect().applyInstantEffect(entityhuman, entityhuman, entityliving, mobeffect.getAmplifier(), 1.0D); +@@ -51,7 +51,7 @@ + if (mobeffect.getEffect().isInstantenous()) { + mobeffect.getEffect().applyInstantenousEffect(entityhuman, entityhuman, entityliving, mobeffect.getAmplifier(), 1.0D); } else { - entityliving.addEffect(new MobEffect(mobeffect)); + entityliving.addEffect(new MobEffect(mobeffect), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_DRINK); // CraftBukkit diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemRecord.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemRecord.patch index a8f658d2cc..d3d3a90fab 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemRecord.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemRecord.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/item/ItemRecord.java +++ b/net/minecraft/world/item/ItemRecord.java -@@ -43,6 +43,7 @@ - ItemStack itemstack = itemactioncontext.getItemStack(); +@@ -42,6 +42,7 @@ + ItemStack itemstack = itemactioncontext.getItemInHand(); if (!world.isClientSide) { + if (true) return EnumInteractionResult.SUCCESS; // CraftBukkit - handled in ItemStack - ((BlockJukeBox) Blocks.JUKEBOX).a((GeneratorAccess) world, blockposition, iblockdata, itemstack); - world.a((EntityHuman) null, 1010, blockposition, Item.getId(this)); - itemstack.subtract(1); + ((BlockJukeBox) Blocks.JUKEBOX).setRecord(world, blockposition, iblockdata, itemstack); + world.levelEvent((EntityHuman) null, 1010, blockposition, Item.getId(this)); + itemstack.shrink(1); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemSign.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemSign.patch index 77bbfd61ff..be83c5d260 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemSign.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemSign.patch @@ -10,12 +10,12 @@ super(block, block1, item_info); } @@ -19,7 +21,10 @@ - boolean flag = super.a(blockposition, world, entityhuman, itemstack, iblockdata); + boolean flag = super.updateCustomBlockEntityTag(blockposition, world, entityhuman, itemstack, iblockdata); if (!world.isClientSide && !flag && entityhuman != null) { -- entityhuman.openSign((TileEntitySign) world.getTileEntity(blockposition)); +- entityhuman.openTextEdit((TileEntitySign) world.getBlockEntity(blockposition)); + // CraftBukkit start - SPIGOT-4678 -+ // entityhuman.openSign((TileEntitySign) world.getTileEntity(blockposition)); ++ // entityhuman.openTextEdit((TileEntitySign) world.getBlockEntity(blockposition)); + ItemSign.openSign = blockposition; + // CraftBukkit end } diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemSkullPlayer.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemSkullPlayer.patch index a7fd3d12ed..7578b47a4a 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemSkullPlayer.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemSkullPlayer.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/item/ItemSkullPlayer.java +++ b/net/minecraft/world/item/ItemSkullPlayer.java @@ -51,6 +51,16 @@ - TileEntitySkull.a(gameprofile, (gameprofile1) -> { - nbttagcompound.set("SkullOwner", GameProfileSerializer.serialize(new NBTTagCompound(), gameprofile1)); + TileEntitySkull.updateGameprofile(gameprofile, (gameprofile1) -> { + nbttagcompound.put("SkullOwner", GameProfileSerializer.writeGameProfile(new NBTTagCompound(), gameprofile1)); }); + // CraftBukkit start + } else { + net.minecraft.nbt.NBTTagList textures = nbttagcompound.getCompound("SkullOwner").getCompound("Properties").getList("textures", 10); // Safe due to method contracts + for (int i = 0; i < textures.size(); i++) { -+ if (textures.get(i) instanceof NBTTagCompound && !((NBTTagCompound) textures.get(i)).hasKeyOfType("Signature", 8) && ((NBTTagCompound) textures.get(i)).getString("Value").trim().isEmpty()) { ++ if (textures.get(i) instanceof NBTTagCompound && !((NBTTagCompound) textures.get(i)).contains("Signature", 8) && ((NBTTagCompound) textures.get(i)).getString("Value").trim().isEmpty()) { + nbttagcompound.remove("SkullOwner"); + break; + } diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemSnowball.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemSnowball.patch index 16355ba5a5..84f81c9d47 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemSnowball.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemSnowball.patch @@ -1,37 +1,37 @@ --- a/net/minecraft/world/item/ItemSnowball.java +++ b/net/minecraft/world/item/ItemSnowball.java @@ -19,19 +19,32 @@ - public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) { - ItemStack itemstack = entityhuman.b(enumhand); + public InteractionResultWrapper<ItemStack> use(World world, EntityHuman entityhuman, EnumHand enumhand) { + ItemStack itemstack = entityhuman.getItemInHand(enumhand); -- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.SNOWBALL_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.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); + // CraftBukkit - moved down -+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.SNOWBALL_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.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); if (!world.isClientSide) { EntitySnowball entitysnowball = new EntitySnowball(world, entityhuman); entitysnowball.setItem(itemstack); - entitysnowball.a(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F); -- world.addEntity(entitysnowball); -+ if (world.addEntity(entitysnowball)) { + entitysnowball.shootFromRotation(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F); +- world.addFreshEntity(entitysnowball); ++ if (world.addFreshEntity(entitysnowball)) { + if (!entityhuman.getAbilities().instabuild) { -+ itemstack.subtract(1); ++ itemstack.shrink(1); + } + -+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.SNOWBALL_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.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(); + } } + // CraftBukkit end - entityhuman.b(StatisticList.ITEM_USED.b(this)); + entityhuman.awardStat(StatisticList.ITEM_USED.get(this)); + // CraftBukkit start - moved up + /* if (!entityhuman.getAbilities().instabuild) { - itemstack.subtract(1); + itemstack.shrink(1); } + */ - return InteractionResultWrapper.a(itemstack, world.isClientSide()); + return InteractionResultWrapper.sidedSuccess(itemstack, world.isClientSide()); } diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemStack.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemStack.patch index 4ab296dfbd..f7bc08e8ea 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemStack.patch +++ b/paper-server/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 -@@ -76,6 +76,39 @@ +@@ -73,6 +73,40 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -8,6 +8,7 @@ +import com.mojang.serialization.Dynamic; +import java.util.List; +import java.util.Map; ++import java.util.Objects; +import net.minecraft.core.EnumDirection; +import net.minecraft.nbt.DynamicOpsNBT; +import net.minecraft.network.protocol.game.PacketPlayOutBlockChange; @@ -40,17 +41,8 @@ public final class ItemStack { public static final Codec<ItemStack> CODEC = RecordCodecBuilder.create((instance) -> { -@@ -89,7 +122,7 @@ - }); - private static final Logger LOGGER = LogManager.getLogger(); - public static final ItemStack EMPTY = new ItemStack((Item) null); -- public static final DecimalFormat ATTRIBUTE_MODIFIER_FORMAT = (DecimalFormat) SystemUtils.a((Object) (new DecimalFormat("#.##")), (decimalformat) -> { -+ public static final DecimalFormat ATTRIBUTE_MODIFIER_FORMAT = (DecimalFormat) SystemUtils.a((new DecimalFormat("#.##")), (decimalformat) -> { // CraftBukkit - decompile error - decimalformat.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ROOT)); - }); - public static final String TAG_ENCH = "Enchantments"; -@@ -140,16 +173,30 @@ - this.checkEmpty(); +@@ -139,16 +173,30 @@ + this.updateEmptyCacheFlag(); } + // Called to run this stack through the data converter to handle older storage methods and serialized items @@ -63,7 +55,7 @@ + } + } + - private void checkEmpty() { + private void updateEmptyCacheFlag() { + if (this.emptyCacheFlag && this == ItemStack.EMPTY) throw new AssertionError("TRAP"); // CraftBukkit this.emptyCacheFlag = false; this.emptyCacheFlag = this.isEmpty(); @@ -74,16 +66,16 @@ + private void load(NBTTagCompound nbttagcompound) { this.item = (Item) IRegistry.ITEM.get(new MinecraftKey(nbttagcompound.getString("id"))); this.count = nbttagcompound.getByte("Count"); - if (nbttagcompound.hasKeyOfType("tag", 10)) { + if (nbttagcompound.contains("tag", 10)) { - this.tag = nbttagcompound.getCompound("tag"); + // CraftBukkit start - make defensive copy as this data may be coming from the save thread -+ this.tag = (NBTTagCompound) nbttagcompound.getCompound("tag").clone(); ++ this.tag = nbttagcompound.getCompound("tag").copy(); + // CraftBukkit end - this.getItem().b(this.tag); + this.getItem().verifyTagAfterLoad(this.tag); } -@@ -157,6 +204,11 @@ - this.setDamage(this.getDamage()); +@@ -156,6 +204,11 @@ + this.setDamageValue(this.getDamageValue()); } + } @@ -91,26 +83,26 @@ + private ItemStack(NBTTagCompound nbttagcompound) { + this.load(nbttagcompound); + // CraftBukkit end - this.checkEmpty(); + this.updateEmptyCacheFlag(); } -@@ -194,7 +246,7 @@ +@@ -193,7 +246,7 @@ return this.getItem() == item; } -- public EnumInteractionResult placeItem(ItemActionContext itemactioncontext) { -+ public EnumInteractionResult placeItem(ItemActionContext itemactioncontext, EnumHand enumhand) { // CraftBukkit - add hand - EntityHuman entityhuman = itemactioncontext.getEntity(); - BlockPosition blockposition = itemactioncontext.getClickPosition(); - ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getWorld(), blockposition, false); -@@ -202,12 +254,157 @@ - if (entityhuman != null && !entityhuman.getAbilities().mayBuild && !this.b(itemactioncontext.getWorld().r(), shapedetectorblock)) { +- public EnumInteractionResult useOn(ItemActionContext itemactioncontext) { ++ public EnumInteractionResult useOn(ItemActionContext itemactioncontext, EnumHand enumhand) { // CraftBukkit - add hand + EntityHuman entityhuman = itemactioncontext.getPlayer(); + BlockPosition blockposition = itemactioncontext.getClickedPos(); + ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getLevel(), blockposition, false); +@@ -201,12 +254,157 @@ + if (entityhuman != null && !entityhuman.getAbilities().mayBuild && !this.hasAdventureModePlaceTagForBlock(itemactioncontext.getLevel().getTagManager(), shapedetectorblock)) { return EnumInteractionResult.PASS; } else { + // CraftBukkit start - handle all block place event logic here + NBTTagCompound oldData = this.getTagClone(); + int oldCount = this.getCount(); -+ WorldServer world = (WorldServer) itemactioncontext.getWorld(); ++ WorldServer world = (WorldServer) itemactioncontext.getLevel(); + + if (!(this.getItem() instanceof ItemBucket || this.getItem() instanceof SolidBucketItem)) { // if not bucket + world.captureBlockStates = true; @@ -120,13 +112,13 @@ + } + } Item item = this.getItem(); - EnumInteractionResult enuminteractionresult = item.a(itemactioncontext); + EnumInteractionResult enuminteractionresult = item.useOn(itemactioncontext); + NBTTagCompound newData = this.getTagClone(); + int newCount = this.getCount(); + this.setCount(oldCount); + this.setTagClone(oldData); + world.captureBlockStates = false; -+ if (enuminteractionresult.a() && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) { ++ if (enuminteractionresult.consumesAction() && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) { + world.captureTreeGeneration = false; + Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); + TreeType treeType = BlockSapling.treeType; @@ -160,8 +152,8 @@ + } + world.captureTreeGeneration = false; - if (entityhuman != null && enuminteractionresult.c()) { -- entityhuman.b(StatisticList.ITEM_USED.b(item)); + if (entityhuman != null && enuminteractionresult.shouldAwardStats()) { +- entityhuman.awardStat(StatisticList.ITEM_USED.get(item)); + org.bukkit.event.block.BlockPlaceEvent placeEvent = null; + List<BlockState> blocks = new java.util.ArrayList<>(world.capturedBlockStates.values()); + world.capturedBlockStates.clear(); @@ -185,7 +177,7 @@ + // Brute force all possible updates + BlockPosition placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition(); + for (EnumDirection dir : EnumDirection.values()) { -+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutBlockChange(world, placedPos.shift(dir))); ++ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutBlockChange(world, placedPos.relative(dir))); + } + ItemSign.openSign = null; // SPIGOT-6758 - Reset on early return + } else { @@ -196,44 +188,44 @@ + } + + for (Map.Entry<BlockPosition, TileEntity> e : world.capturedTileEntities.entrySet()) { -+ world.setTileEntity(e.getValue()); ++ world.setBlockEntity(e.getValue()); + } + + for (BlockState blockstate : blocks) { + int updateFlag = ((CraftBlockState) blockstate).getFlag(); + IBlockData oldBlock = ((CraftBlockState) blockstate).getHandle(); + BlockPosition newblockposition = ((CraftBlockState) blockstate).getPosition(); -+ IBlockData block = world.getType(newblockposition); ++ IBlockData block = world.getBlockState(newblockposition); + + if (!(block.getBlock() instanceof BlockTileEntity)) { // Containers get placed automatically + block.getBlock().onPlace(block, world, newblockposition, oldBlock, true); + } + -+ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getType(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point ++ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getBlockState(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point + } + + // Special case juke boxes as they update their tile entity. Copied from ItemRecord. + // PAIL: checkme on updates. + if (this.item instanceof ItemRecord) { -+ ((BlockJukeBox) Blocks.JUKEBOX).a(world, blockposition, world.getType(blockposition), this); -+ world.a((EntityHuman) null, 1010, blockposition, Item.getId(this.item)); -+ this.subtract(1); -+ entityhuman.a(StatisticList.PLAY_RECORD); ++ ((BlockJukeBox) Blocks.JUKEBOX).setRecord(world, blockposition, world.getBlockState(blockposition), this); ++ world.levelEvent((EntityHuman) null, 1010, blockposition, Item.getId(this.item)); ++ this.shrink(1); ++ entityhuman.awardStat(StatisticList.PLAY_RECORD); + } + + if (this.item == Items.WITHER_SKELETON_SKULL) { // Special case skulls to allow wither spawns to be cancelled + BlockPosition bp = blockposition; -+ if (!world.getType(blockposition).getMaterial().isReplaceable()) { -+ if (!world.getType(blockposition).getMaterial().isBuildable()) { ++ if (!world.getBlockState(blockposition).getMaterial().isReplaceable()) { ++ if (!world.getBlockState(blockposition).getMaterial().isSolid()) { + bp = null; + } else { -+ bp = bp.shift(itemactioncontext.getClickedFace()); ++ bp = bp.relative(itemactioncontext.getClickedFace()); + } + } + if (bp != null) { -+ TileEntity te = world.getTileEntity(bp); ++ TileEntity te = world.getBlockEntity(bp); + if (te instanceof TileEntitySkull) { -+ BlockWitherSkull.a(world, bp, (TileEntitySkull) te); ++ BlockWitherSkull.checkSpawn(world, bp, (TileEntitySkull) te); + } + } + } @@ -241,7 +233,7 @@ + // SPIGOT-4678 + if (this.item instanceof ItemSign && ItemSign.openSign != null) { + try { -+ entityhuman.openSign((TileEntitySign) world.getTileEntity(ItemSign.openSign)); ++ entityhuman.openTextEdit((TileEntitySign) world.getBlockEntity(ItemSign.openSign)); + } finally { + ItemSign.openSign = null; + } @@ -249,11 +241,11 @@ + + // SPIGOT-1288 - play sound stripped from ItemBlock + if (this.item instanceof ItemBlock) { -+ SoundEffectType soundeffecttype = ((ItemBlock) this.item).getBlock().getStepSound(null); ++ SoundEffectType soundeffecttype = ((ItemBlock) this.item).getBlock().getSoundType(null); + world.playSound(entityhuman, blockposition, soundeffecttype.getPlaceSound(), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); + } + -+ entityhuman.b(StatisticList.ITEM_USED.b(item)); ++ entityhuman.awardStat(StatisticList.ITEM_USED.get(item)); + } } + world.capturedTileEntities.clear(); @@ -262,7 +254,7 @@ return enuminteractionresult; } -@@ -288,6 +485,21 @@ +@@ -287,6 +485,21 @@ } i -= k; @@ -284,8 +276,8 @@ if (i <= 0) { return false; } -@@ -309,6 +521,11 @@ - if (this.isDamaged(i, t0.getRandom(), t0 instanceof EntityPlayer ? (EntityPlayer) t0 : null)) { +@@ -308,6 +521,11 @@ + if (this.hurt(i, t0.getRandom(), t0 instanceof EntityPlayer ? (EntityPlayer) t0 : null)) { consumer.accept(t0); Item item = this.getItem(); + // CraftBukkit start - Check for item breaking @@ -294,40 +286,40 @@ + } + // CraftBukkit end - this.subtract(1); + this.shrink(1); if (t0 instanceof EntityHuman) { -@@ -464,6 +681,17 @@ +@@ -463,6 +681,17 @@ return this.tag; } + // CraftBukkit start + @Nullable + private NBTTagCompound getTagClone() { -+ return this.tag == null ? null : this.tag.clone(); ++ return this.tag == null ? null : this.tag.copy(); + } + + private void setTagClone(@Nullable NBTTagCompound nbtttagcompound) { -+ this.setTag(nbtttagcompound == null ? null : nbtttagcompound.clone()); ++ this.setTag(nbtttagcompound == null ? null : nbtttagcompound.copy()); + } + // CraftBukkit end + public NBTTagCompound getOrCreateTag() { if (this.tag == null) { this.setTag(new NBTTagCompound()); -@@ -844,6 +1072,12 @@ +@@ -843,6 +1072,12 @@ } public void setRepairCost(int i) { + // CraftBukkit start - remove RepairCost tag when 0 (SPIGOT-3945) + if (i == 0) { -+ this.removeTag("RepairCost"); ++ this.removeTagKey("RepairCost"); + return; + } + // CraftBukkit end - this.getOrCreateTag().setInt("RepairCost", i); + this.getOrCreateTag().putInt("RepairCost", i); } -@@ -893,6 +1127,13 @@ +@@ -892,6 +1127,13 @@ nbttaglist.add(nbttagcompound); } @@ -338,6 +330,6 @@ + } + // CraftBukkit end + - public IChatBaseComponent G() { - IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).addSibling(this.getName()); + public IChatBaseComponent getDisplayName() { + IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).append(this.getHoverName()); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemTrident.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemTrident.patch index bc605e877d..ac283b1886 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemTrident.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemTrident.patch @@ -6,8 +6,8 @@ if (!world.isClientSide) { + // CraftBukkit - moved down + /* - itemstack.damage(1, entityhuman, (entityhuman1) -> { - entityhuman1.broadcastItemBreak(entityliving.getRaisedHand()); + itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { + entityhuman1.broadcastBreakEvent(entityliving.getUsedItemHand()); }); + */ if (k == 0) { @@ -17,35 +17,35 @@ entitythrowntrident.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY; } -- world.addEntity(entitythrowntrident); +- world.addFreshEntity(entitythrowntrident); + // CraftBukkit start -+ if (!world.addEntity(entitythrowntrident)) { ++ if (!world.addFreshEntity(entitythrowntrident)) { + if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { + ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); + } + return; + } + -+ itemstack.damage(1, entityhuman, (entityhuman1) -> { -+ entityhuman1.broadcastItemBreak(entityliving.getRaisedHand()); ++ itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { ++ entityhuman1.broadcastBreakEvent(entityliving.getUsedItemHand()); + }); -+ entitythrowntrident.tridentItem = itemstack.cloneItemStack(); // SPIGOT-4511 update since damage call moved ++ entitythrowntrident.tridentItem = itemstack.copy(); // SPIGOT-4511 update since damage call moved + // CraftBukkit end + world.playSound((EntityHuman) null, (Entity) entitythrowntrident, SoundEffects.TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F); if (!entityhuman.getAbilities().instabuild) { - entityhuman.getInventory().g(itemstack); + entityhuman.getInventory().removeItem(itemstack); } + // CraftBukkit start - SPIGOT-5458 also need in this branch :( + } else { -+ itemstack.damage(1, entityhuman, (entityhuman1) -> { -+ entityhuman1.broadcastItemBreak(entityliving.getRaisedHand()); ++ itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { ++ entityhuman1.broadcastBreakEvent(entityliving.getUsedItemHand()); + }); + // CraftBukkkit end } } - entityhuman.b(StatisticList.ITEM_USED.b(this)); + entityhuman.awardStat(StatisticList.ITEM_USED.get(this)); if (k > 0) { + // CraftBukkit start + org.bukkit.event.player.PlayerRiptideEvent event = new org.bukkit.event.player.PlayerRiptideEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemWorldMap.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemWorldMap.patch index 7c79815a78..8f18294a56 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemWorldMap.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemWorldMap.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemWorldMap.java +++ b/net/minecraft/world/item/ItemWorldMap.java -@@ -34,6 +34,11 @@ +@@ -33,6 +33,11 @@ import net.minecraft.world.level.material.MaterialMapColor; import net.minecraft.world.level.saveddata.maps.WorldMap; @@ -12,19 +12,19 @@ public class ItemWorldMap extends ItemWorldMapBase { public static final int IMAGE_WIDTH = 128; -@@ -68,7 +73,7 @@ - public static Integer d(ItemStack itemstack) { +@@ -67,7 +72,7 @@ + public static Integer getMapId(ItemStack itemstack) { NBTTagCompound nbttagcompound = itemstack.getTag(); -- return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : null; -+ return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : -1; // CraftBukkit - make new maps for no tag +- return nbttagcompound != null && nbttagcompound.contains("map", 99) ? nbttagcompound.getInt("map") : null; ++ return nbttagcompound != null && nbttagcompound.contains("map", 99) ? nbttagcompound.getInt("map") : -1; // CraftBukkit - make new maps for no tag } public static int createNewSavedData(World world, int i, int j, int k, boolean flag, boolean flag1, ResourceKey<World> resourcekey) { -@@ -76,6 +81,10 @@ - int l = world.getWorldMapCount(); +@@ -75,6 +80,10 @@ + int l = world.getFreeMapId(); - world.a(a(l), worldmap); + world.setMapData(makeKey(l), worldmap); + // CraftBukkit start + MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView); + Bukkit.getServer().getPluginManager().callEvent(event); diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch index 4be981a3d5..6c7a2f3a24 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch @@ -17,7 +17,7 @@ public CraftingManager() { @@ -47,7 +49,12 @@ - protected void a(Map<MinecraftKey, JsonElement> map, IResourceManager iresourcemanager, GameProfilerFiller gameprofilerfiller) { + protected void apply(Map<MinecraftKey, JsonElement> map, IResourceManager iresourcemanager, GameProfilerFiller gameprofilerfiller) { this.hasErrors = false; - Map<Recipes<?>, Builder<MinecraftKey, IRecipe<?>>> map1 = Maps.newHashMap(); + // CraftBukkit start - SPIGOT-5667 make sure all types are populated and mutable @@ -31,12 +31,12 @@ while (iterator.hasNext()) { @@ -57,8 +64,10 @@ try { - IRecipe<?> irecipe = a(minecraftkey, ChatDeserializer.m((JsonElement) entry.getValue(), "top element")); + IRecipe<?> irecipe = fromJson(minecraftkey, ChatDeserializer.convertToJsonObject((JsonElement) entry.getValue(), "top element")); -- ((Builder) map1.computeIfAbsent(irecipe.g(), (recipes) -> { +- ((Builder) map1.computeIfAbsent(irecipe.getType(), (recipes) -> { - return ImmutableMap.builder(); + // CraftBukkit start -+ (map1.computeIfAbsent(irecipe.g(), (recipes) -> { ++ (map1.computeIfAbsent(irecipe.getType(), (recipes) -> { + return new Object2ObjectLinkedOpenHashMap<>(); + // CraftBukkit end })).put(minecraftkey, irecipe); @@ -54,44 +54,44 @@ + // CraftBukkit start + public void addRecipe(IRecipe<?> irecipe) { -+ Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>> map = this.recipes.get(irecipe.g()); // CraftBukkit ++ Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>> map = this.recipes.get(irecipe.getType()); // CraftBukkit + -+ if (map.containsKey(irecipe.getKey())) { -+ throw new IllegalStateException("Duplicate recipe ignored with ID " + irecipe.getKey()); ++ if (map.containsKey(irecipe.getId())) { ++ throw new IllegalStateException("Duplicate recipe ignored with ID " + irecipe.getId()); + } else { -+ map.putAndMoveToFirst(irecipe.getKey(), irecipe); // CraftBukkit - SPIGOT-4638: last recipe gets priority ++ map.putAndMoveToFirst(irecipe.getId(), irecipe); // CraftBukkit - SPIGOT-4638: last recipe gets priority + } + } + // CraftBukkit end + - public boolean a() { + public boolean hadErrorsLoading() { return this.hasErrors; } - public <C extends IInventory, T extends IRecipe<C>> Optional<T> craft(Recipes<T> recipes, C c0, World world) { -- return this.b(recipes).values().stream().flatMap((irecipe) -> { + public <C extends IInventory, T extends IRecipe<C>> Optional<T> getRecipeFor(Recipes<T> recipes, C c0, World world) { +- return this.byType(recipes).values().stream().flatMap((irecipe) -> { + // CraftBukkit start -+ Optional<T> recipe = this.b(recipes).values().stream().flatMap((irecipe) -> { - return SystemUtils.a(recipes.a(irecipe, world, c0)); ++ Optional<T> recipe = this.byType(recipes).values().stream().flatMap((irecipe) -> { + return SystemUtils.toStream(recipes.tryMatch(irecipe, world, c0)); }).findFirst(); + c0.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found + // CraftBukkit end + return recipe; } - public <C extends IInventory, T extends IRecipe<C>> List<T> a(Recipes<T> recipes) { + public <C extends IInventory, T extends IRecipe<C>> List<T> getAllRecipesFor(Recipes<T> recipes) { @@ -96,7 +121,7 @@ } - private <C extends IInventory, T extends IRecipe<C>> Map<MinecraftKey, IRecipe<C>> b(Recipes<T> recipes) { + private <C extends IInventory, T extends IRecipe<C>> Map<MinecraftKey, IRecipe<C>> byType(Recipes<T> recipes) { - return (Map) this.recipes.getOrDefault(recipes, Collections.emptyMap()); + return (Map) this.recipes.getOrDefault(recipes, new Object2ObjectLinkedOpenHashMap<>()); // CraftBukkit } - public <C extends IInventory, T extends IRecipe<C>> NonNullList<ItemStack> c(Recipes<T> recipes, C c0, World world) { + public <C extends IInventory, T extends IRecipe<C>> NonNullList<ItemStack> getRemainingItemsFor(Recipes<T> recipes, C c0, World world) { @@ -117,7 +142,7 @@ - public Optional<? extends IRecipe<?>> getRecipe(MinecraftKey minecraftkey) { + public Optional<? extends IRecipe<?>> byKey(MinecraftKey minecraftkey) { return this.recipes.values().stream().map((map) -> { - return (IRecipe) map.get(minecraftkey); + return map.get(minecraftkey); // CraftBukkit - decompile error @@ -100,17 +100,17 @@ @@ -143,11 +168,11 @@ - public void a(Iterable<IRecipe<?>> iterable) { + public void replaceRecipes(Iterable<IRecipe<?>> iterable) { this.hasErrors = false; - Map<Recipes<?>, Map<MinecraftKey, IRecipe<?>>> map = Maps.newHashMap(); + Map<Recipes<?>, Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>>> map = Maps.newHashMap(); // CraftBukkit iterable.forEach((irecipe) -> { - Map<MinecraftKey, IRecipe<?>> map1 = (Map) map.computeIfAbsent(irecipe.g(), (recipes) -> { + Map<MinecraftKey, IRecipe<?>> map1 = (Map) map.computeIfAbsent(irecipe.getType(), (recipes) -> { - return Maps.newHashMap(); + return new Object2ObjectLinkedOpenHashMap<>(); // CraftBukkit }); - IRecipe<?> irecipe1 = (IRecipe) map1.put(irecipe.getKey(), irecipe); + IRecipe<?> irecipe1 = (IRecipe) map1.put(irecipe.getId(), irecipe); @@ -157,4 +182,14 @@ }); diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/FurnaceRecipe.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/FurnaceRecipe.patch index 722ddeae66..83e292a0b2 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/FurnaceRecipe.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/FurnaceRecipe.patch @@ -16,7 +16,7 @@ public FurnaceRecipe(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { @@ -19,4 +27,14 @@ - public RecipeSerializer<?> getRecipeSerializer() { + public RecipeSerializer<?> getSerializer() { return RecipeSerializer.SMELTING_RECIPE; } + diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch index 117f8dcd50..c48e8af360 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/crafting/IRecipe.java +++ b/net/minecraft/world/item/crafting/IRecipe.java @@ -61,4 +61,6 @@ - return recipeitemstack.a().length == 0; + return recipeitemstack.getItems().length == 0; }); } + diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch index 5923a75e62..9265a4bc9c 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/crafting/IRecipeComplex.java +++ b/net/minecraft/world/item/crafting/IRecipeComplex.java @@ -25,4 +25,11 @@ - public ItemStack getResult() { + public ItemStack getResultItem() { return ItemStack.EMPTY; } + diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeBlasting.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeBlasting.patch index 3ed5e62ada..7258d4f4ba 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeBlasting.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeBlasting.patch @@ -16,7 +16,7 @@ public RecipeBlasting(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { @@ -19,4 +27,16 @@ - public RecipeSerializer<?> getRecipeSerializer() { + public RecipeSerializer<?> getSerializer() { return RecipeSerializer.BLASTING_RECIPE; } + diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeCampfire.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeCampfire.patch index 9c7cfcb8e1..89d3b558ea 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeCampfire.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeCampfire.patch @@ -16,7 +16,7 @@ public RecipeCampfire(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { @@ -19,4 +27,16 @@ - public RecipeSerializer<?> getRecipeSerializer() { + public RecipeSerializer<?> getSerializer() { return RecipeSerializer.CAMPFIRE_COOKING_RECIPE; } + diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch index 7ed9bf66c5..8cc045fc96 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch @@ -1,35 +1,26 @@ --- a/net/minecraft/world/item/crafting/RecipeItemStack.java +++ b/net/minecraft/world/item/crafting/RecipeItemStack.java -@@ -35,6 +35,7 @@ - private final RecipeItemStack.Provider[] values; +@@ -37,6 +37,7 @@ public ItemStack[] itemStacks; + @Nullable private IntList stackingIds; + public boolean exact; // CraftBukkit public RecipeItemStack(Stream<? extends RecipeItemStack.Provider> stream) { this.values = (RecipeItemStack.Provider[]) stream.toArray((i) -> { -@@ -72,6 +73,15 @@ +@@ -74,6 +75,15 @@ for (int j = 0; j < i; ++j) { ItemStack itemstack1 = aitemstack[j]; + // CraftBukkit start + if (exact) { -+ if (itemstack1.getItem() == itemstack.getItem() && ItemStack.equals(itemstack, itemstack1)) { ++ if (itemstack1.getItem() == itemstack.getItem() && ItemStack.tagMatches(itemstack, itemstack1)) { + return true; + } + + continue; + } + // CraftBukkit end - if (itemstack1.a(itemstack.getItem())) { + if (itemstack1.is(itemstack.getItem())) { return true; } -@@ -103,7 +113,7 @@ - - public void a(PacketDataSerializer packetdataserializer) { - this.buildChoices(); -- packetdataserializer.a((Collection) Arrays.asList(this.itemStacks), PacketDataSerializer::a); -+ packetdataserializer.a(Arrays.asList(this.itemStacks), PacketDataSerializer::a); // CraftBukkit - decompile error - } - - public JsonElement c() { diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeSmithing.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeSmithing.patch index 632e74c8ac..eec286af8a 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeSmithing.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeSmithing.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/RecipeSmithing.java +++ b/net/minecraft/world/item/crafting/RecipeSmithing.java -@@ -12,6 +12,14 @@ +@@ -11,6 +11,14 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.block.Blocks; @@ -15,7 +15,7 @@ public class RecipeSmithing implements IRecipe<IInventory> { final RecipeItemStack base; -@@ -84,6 +92,17 @@ +@@ -83,6 +91,17 @@ }); } diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeSmoking.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeSmoking.patch index 147979a561..5797547275 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeSmoking.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeSmoking.patch @@ -16,7 +16,7 @@ public RecipeSmoking(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { @@ -19,4 +27,16 @@ - public RecipeSerializer<?> getRecipeSerializer() { + public RecipeSerializer<?> getSerializer() { return RecipeSerializer.SMOKING_RECIPE; } + diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeStonecutting.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeStonecutting.patch index 5f64088fec..6a1389a8bd 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeStonecutting.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeStonecutting.patch @@ -16,7 +16,7 @@ public RecipeStonecutting(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack) { @@ -21,4 +29,16 @@ - public ItemStack h() { + public ItemStack getToastSymbol() { return new ItemStack(Blocks.STONECUTTER); } + diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch index c1d9aafa42..c58965ff43 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch @@ -79,5 +79,5 @@ + // CraftBukkit end + @Override - public MinecraftKey getKey() { + public MinecraftKey getId() { return this.id; diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch index 68cd5d8cbb..aea76f6233 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch @@ -32,5 +32,5 @@ + // CraftBukkit end + @Override - public MinecraftKey getKey() { + public MinecraftKey getId() { return this.id; diff --git a/paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.patch b/paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.patch index 8d5271751e..b52779d4cd 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.java +++ b/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.java @@ -57,8 +57,11 @@ - IBlockData iblockdata2 = world.getType(blockposition1); + IBlockData iblockdata2 = world.getBlockState(blockposition1); - if (iblockdata2.getMaterial() == Material.WATER && (Integer) iblockdata2.get(BlockFluids.LEVEL) == 0 && iblockdata.canPlace(world, blockposition1) && world.a(iblockdata, blockposition1, VoxelShapeCollision.a())) { -- world.setTypeUpdate(blockposition1, iblockdata); -- world.getBlockTickList().a(blockposition1, Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120)); + if (iblockdata2.getMaterial() == Material.WATER && (Integer) iblockdata2.getValue(BlockFluids.LEVEL) == 0 && iblockdata.canSurvive(world, blockposition1) && world.isUnobstructed(iblockdata, blockposition1, VoxelShapeCollision.empty())) { +- world.setBlockAndUpdate(blockposition1, iblockdata); +- world.scheduleTick(blockposition1, Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120)); + // CraftBukkit Start - Call EntityBlockFormEvent for Frost Walker + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition1, iblockdata, entityliving)) { -+ world.getBlockTickList().a(blockposition1, Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120)); ++ world.scheduleTick(blockposition1, Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120)); + } + // CraftBukkit End } diff --git a/paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.patch b/paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.patch index 20756e31eb..d637e8fc60 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.java +++ b/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.java @@ -63,7 +63,7 @@ - if (this.type == 2 && i > 0 && entityliving1.getMonsterType() == EnumMonsterType.ARTHROPOD) { + if (this.type == 2 && i > 0 && entityliving1.getMobType() == EnumMonsterType.ARTHROPOD) { int j = 20 + entityliving.getRandom().nextInt(10 * i); - entityliving1.addEffect(new MobEffect(MobEffects.MOVEMENT_SLOWDOWN, j, 3)); diff --git a/paper-server/nms-patches/net/minecraft/world/item/enchantment/Enchantments.patch b/paper-server/nms-patches/net/minecraft/world/item/enchantment/Enchantments.patch index 6ebf475182..1d8ef16979 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/enchantment/Enchantments.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/enchantment/Enchantments.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/enchantment/Enchantments.java +++ b/net/minecraft/world/item/enchantment/Enchantments.java -@@ -45,9 +45,17 @@ - public static final Enchantment MENDING = a("mending", new EnchantmentMending(Enchantment.Rarity.RARE, EnumItemSlot.values())); - public static final Enchantment VANISHING_CURSE = a("vanishing_curse", new EnchantmentVanishing(Enchantment.Rarity.VERY_RARE, EnumItemSlot.values())); +@@ -45,6 +45,14 @@ + public static final Enchantment MENDING = register("mending", new EnchantmentMending(Enchantment.Rarity.RARE, EnumItemSlot.values())); + public static final Enchantment VANISHING_CURSE = register("vanishing_curse", new EnchantmentVanishing(Enchantment.Rarity.VERY_RARE, EnumItemSlot.values())); + // CraftBukkit start + static { @@ -14,8 +14,4 @@ + public Enchantments() {} - private static Enchantment a(String s, Enchantment enchantment) { -- return (Enchantment) IRegistry.a(IRegistry.ENCHANTMENT, s, (Object) enchantment); -+ return (Enchantment) IRegistry.a(IRegistry.ENCHANTMENT, s, enchantment); // CraftBukkit - decompile error - } - } + private static Enchantment register(String s, Enchantment enchantment) { diff --git a/paper-server/nms-patches/net/minecraft/world/item/trading/IMerchant.patch b/paper-server/nms-patches/net/minecraft/world/item/trading/IMerchant.patch index decc754b36..0ea0e940d0 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/trading/IMerchant.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/trading/IMerchant.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/item/trading/IMerchant.java +++ b/net/minecraft/world/item/trading/IMerchant.java -@@ -53,4 +53,6 @@ - } - +@@ -52,4 +52,6 @@ } + + boolean isClientSide(); + + org.bukkit.craftbukkit.inventory.CraftMerchant getCraftMerchant(); // CraftBukkit } diff --git a/paper-server/nms-patches/net/minecraft/world/item/trading/MerchantRecipe.patch b/paper-server/nms-patches/net/minecraft/world/item/trading/MerchantRecipe.patch index ba18889807..3652bc29f6 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/trading/MerchantRecipe.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/trading/MerchantRecipe.patch @@ -30,9 +30,9 @@ this.rewardExp = true; @@ -78,6 +92,7 @@ - public ItemStack getBuyItem1() { + public ItemStack getCostA() { int i = this.baseCostA.getCount(); + if (i <= 0) return ItemStack.EMPTY; // CraftBukkit - SPIGOT-5476 - ItemStack itemstack = this.baseCostA.cloneItemStack(); - int j = Math.max(0, MathHelper.d((float) (i * this.demand) * this.priceMultiplier)); + ItemStack itemstack = this.baseCostA.copy(); + int j = Math.max(0, MathHelper.floor((float) (i * this.demand) * this.priceMultiplier)); diff --git a/paper-server/nms-patches/net/minecraft/world/level/CommandBlockListenerAbstract.patch b/paper-server/nms-patches/net/minecraft/world/level/CommandBlockListenerAbstract.patch index 75efcf6e1f..5dd21c1235 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/CommandBlockListenerAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/CommandBlockListenerAbstract.patch @@ -15,8 +15,8 @@ }); -- minecraftserver.getCommandDispatcher().a(commandlistenerwrapper, this.command); -+ minecraftserver.getCommandDispatcher().dispatchServerCommand(commandlistenerwrapper, this.command); // CraftBukkit +- minecraftserver.getCommands().performCommand(commandlistenerwrapper, this.command); ++ minecraftserver.getCommands().dispatchServerCommand(commandlistenerwrapper, this.command); // CraftBukkit } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Executing command block"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed"); + CrashReport crashreport = CrashReport.forThrowable(throwable, "Executing command block"); + CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Command to be executed"); diff --git a/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch b/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch index 49e4eb73c4..eabf743829 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/Explosion.java +++ b/net/minecraft/world/level/Explosion.java -@@ -43,6 +43,14 @@ +@@ -42,6 +42,14 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.Vec3D; @@ -15,7 +15,7 @@ public class Explosion { private static final ExplosionDamageCalculator EXPLOSION_DAMAGE_CALCULATOR = new ExplosionDamageCalculator(); -@@ -61,6 +69,7 @@ +@@ -60,6 +68,7 @@ private final ExplosionDamageCalculator damageCalculator; private final List<BlockPosition> toBlow; private final Map<EntityHuman, Vec3D> hitPlayers; @@ -23,7 +23,7 @@ public Explosion(World world, @Nullable Entity entity, double d0, double d1, double d2, float f) { this(world, entity, d0, d1, d2, f, false, Explosion.Effect.DESTROY); -@@ -85,7 +94,7 @@ +@@ -84,7 +93,7 @@ this.hitPlayers = Maps.newHashMap(); this.level = world; this.source = entity; @@ -32,28 +32,27 @@ this.x = d0; this.y = d1; this.z = d2; -@@ -135,6 +144,11 @@ +@@ -134,6 +143,11 @@ } - public void a() { + public void explode() { + // CraftBukkit start + if (this.radius < 0.1F) { + return; + } + // CraftBukkit end - this.level.a(this.source, GameEvent.EXPLODE, new BlockPosition(this.x, this.y, this.z)); + this.level.gameEvent(this.source, GameEvent.EXPLODE, new BlockPosition(this.x, this.y, this.z)); Set<BlockPosition> set = Sets.newHashSet(); boolean flag = true; -@@ -218,7 +232,16 @@ - double d12 = (double) a(vec3d, entity); +@@ -217,7 +231,15 @@ + double d12 = (double) getSeenPercent(vec3d, entity); double d13 = (1.0D - d7) * d12; -- entity.damageEntity(this.b(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f2 + 1.0D))); +- entity.hurt(this.getDamageSource(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f2 + 1.0D))); + // CraftBukkit start -+ // entity.damageEntity(this.b(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f2 + 1.0D))); + CraftEventFactory.entityDamage = source; + entity.forceExplosionKnockback = false; -+ boolean wasDamaged = entity.damageEntity(this.b(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f2 + 1.0D))); ++ boolean wasDamaged = entity.hurt(this.getDamageSource(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f2 + 1.0D))); + CraftEventFactory.entityDamage = null; + if (!wasDamaged && !(entity instanceof EntityTNTPrimed || entity instanceof EntityFallingBlock) && !entity.forceExplosionKnockback) { + continue; @@ -62,7 +61,7 @@ double d14 = d13; if (entity instanceof EntityLiving) { -@@ -260,6 +283,51 @@ +@@ -259,6 +281,51 @@ Collections.shuffle(this.toBlow, this.level.random); Iterator iterator = this.toBlow.iterator(); @@ -114,34 +113,34 @@ while (iterator.hasNext()) { BlockPosition blockposition = (BlockPosition) iterator.next(); -@@ -274,8 +342,8 @@ - TileEntity tileentity = iblockdata.isTileEntity() ? this.level.getTileEntity(blockposition) : null; - LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.level)).a(this.level.random).set(LootContextParameters.ORIGIN, Vec3D.a((BaseBlockPosition) blockposition)).set(LootContextParameters.TOOL, ItemStack.EMPTY).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity).setOptional(LootContextParameters.THIS_ENTITY, this.source); +@@ -273,8 +340,8 @@ + TileEntity tileentity = iblockdata.hasBlockEntity() ? this.level.getBlockEntity(blockposition) : null; + LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.level)).withRandom(this.level.random).withParameter(LootContextParameters.ORIGIN, Vec3D.atCenterOf(blockposition)).withParameter(LootContextParameters.TOOL, ItemStack.EMPTY).withOptionalParameter(LootContextParameters.BLOCK_ENTITY, tileentity).withOptionalParameter(LootContextParameters.THIS_ENTITY, this.source); - if (this.blockInteraction == Explosion.Effect.DESTROY) { -- loottableinfo_builder.set(LootContextParameters.EXPLOSION_RADIUS, this.radius); +- loottableinfo_builder.withParameter(LootContextParameters.EXPLOSION_RADIUS, this.radius); + if (this.blockInteraction == Explosion.Effect.DESTROY || yield < 1.0F) { // CraftBukkit - add yield -+ loottableinfo_builder.set(LootContextParameters.EXPLOSION_RADIUS, 1.0F / yield); // CraftBukkit - add yield ++ loottableinfo_builder.withParameter(LootContextParameters.EXPLOSION_RADIUS, 1.0F / yield); // CraftBukkit - add yield } - iblockdata.a(loottableinfo_builder).forEach((itemstack) -> { -@@ -305,7 +373,11 @@ + iblockdata.getDrops(loottableinfo_builder).forEach((itemstack) -> { +@@ -304,7 +371,11 @@ BlockPosition blockposition2 = (BlockPosition) iterator1.next(); - if (this.random.nextInt(3) == 0 && this.level.getType(blockposition2).isAir() && this.level.getType(blockposition2.down()).i(this.level, blockposition2.down())) { -- this.level.setTypeUpdate(blockposition2, BlockFireAbstract.a((IBlockAccess) this.level, blockposition2)); + if (this.random.nextInt(3) == 0 && this.level.getBlockState(blockposition2).isAir() && this.level.getBlockState(blockposition2.below()).isSolidRender(this.level, blockposition2.below())) { +- this.level.setBlockAndUpdate(blockposition2, BlockFireAbstract.getState(this.level, blockposition2)); + // CraftBukkit start - Ignition by explosion + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level, blockposition2.getX(), blockposition2.getY(), blockposition2.getZ(), this).isCancelled()) { -+ this.level.setTypeUpdate(blockposition2, BlockFireAbstract.a((IBlockAccess) this.level, blockposition2)); ++ this.level.setBlockAndUpdate(blockposition2, BlockFireAbstract.getState(this.level, blockposition2)); + } + // CraftBukkit end } } } -@@ -313,6 +385,7 @@ +@@ -312,6 +383,7 @@ } - private static void a(ObjectArrayList<Pair<ItemStack, BlockPosition>> objectarraylist, ItemStack itemstack, BlockPosition blockposition) { + private static void addBlockDrops(ObjectArrayList<Pair<ItemStack, BlockPosition>> objectarraylist, ItemStack itemstack, BlockPosition blockposition) { + if (itemstack.isEmpty()) return; // CraftBukkit - SPIGOT-5425 int i = objectarraylist.size(); diff --git a/paper-server/nms-patches/net/minecraft/world/level/GameRules.patch b/paper-server/nms-patches/net/minecraft/world/level/GameRules.patch index 909345c313..b45a15b28d 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/GameRules.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/GameRules.patch @@ -3,56 +3,56 @@ @@ -118,7 +118,7 @@ } - public <T extends GameRules.GameRuleValue<T>> T get(GameRules.GameRuleKey<T> gamerules_gamerulekey) { + public <T extends GameRules.GameRuleValue<T>> T getRule(GameRules.GameRuleKey<T> gamerules_gamerulekey) { - return (GameRules.GameRuleValue) this.rules.get(gamerules_gamerulekey); + return (T) this.rules.get(gamerules_gamerulekey); // CraftBukkit - decompile error } - public NBTTagCompound a() { + public NBTTagCompound createTag() { @@ -132,7 +132,7 @@ - private void a(DynamicLike<?> dynamiclike) { + private void loadFromTag(DynamicLike<?> dynamiclike) { this.rules.forEach((gamerules_gamerulekey, gamerules_gamerulevalue) -> { - Optional optional = dynamiclike.get(gamerules_gamerulekey.id).asString().result(); + Optional<String> optional = dynamiclike.get(gamerules_gamerulekey.id).asString().result(); // CraftBukkit - decompile error Objects.requireNonNull(gamerules_gamerulevalue); - optional.ifPresent(gamerules_gamerulevalue::setValue); + optional.ifPresent(gamerules_gamerulevalue::deserialize); @@ -152,8 +152,8 @@ } - private static <T extends GameRules.GameRuleValue<T>> void a(GameRules.GameRuleVisitor gamerules_gamerulevisitor, GameRules.GameRuleKey<?> gamerules_gamerulekey, GameRules.GameRuleDefinition<?> gamerules_gameruledefinition) { -- gamerules_gamerulevisitor.a(gamerules_gamerulekey, gamerules_gameruledefinition); -- gamerules_gameruledefinition.a(gamerules_gamerulevisitor, gamerules_gamerulekey); -+ gamerules_gamerulevisitor.a((GameRules.GameRuleKey<T>) gamerules_gamerulekey, (GameRules.GameRuleDefinition<T>) gamerules_gameruledefinition); // CraftBukkit - decompile error -+ ((GameRules.GameRuleDefinition<T>) gamerules_gameruledefinition).a(gamerules_gamerulevisitor, (GameRules.GameRuleKey<T>) gamerules_gamerulekey); // CraftBukkit - decompile error + private static <T extends GameRules.GameRuleValue<T>> void callVisitorCap(GameRules.GameRuleVisitor gamerules_gamerulevisitor, GameRules.GameRuleKey<?> gamerules_gamerulekey, GameRules.GameRuleDefinition<?> gamerules_gameruledefinition) { +- gamerules_gamerulevisitor.visit(gamerules_gamerulekey, gamerules_gameruledefinition); +- gamerules_gameruledefinition.callVisitor(gamerules_gamerulevisitor, gamerules_gamerulekey); ++ gamerules_gamerulevisitor.visit((GameRules.GameRuleKey<T>) gamerules_gamerulekey, (GameRules.GameRuleDefinition<T>) gamerules_gameruledefinition); // CraftBukkit - decompile error ++ ((GameRules.GameRuleDefinition<T>) gamerules_gameruledefinition).callVisitor(gamerules_gamerulevisitor, (GameRules.GameRuleKey<T>) gamerules_gamerulekey); // CraftBukkit - decompile error } - public void a(GameRules gamerules, @Nullable MinecraftServer minecraftserver) { + public void assignFrom(GameRules gamerules, @Nullable MinecraftServer minecraftserver) { @@ -245,7 +245,7 @@ } - public T getValue() { + public T createRule() { - return (GameRules.GameRuleValue) this.constructor.apply(this); + return this.constructor.apply(this); // CraftBukkit - decompile error } - public void a(GameRules.GameRuleVisitor gamerules_gamerulevisitor, GameRules.GameRuleKey<T> gamerules_gamerulekey) { + public void callVisitor(GameRules.GameRuleVisitor gamerules_gamerulevisitor, GameRules.GameRuleKey<T> gamerules_gamerulekey) { @@ -275,7 +275,7 @@ } -- protected abstract void setValue(String s); -+ public abstract void setValue(String s); // PAIL - private->public +- protected abstract void deserialize(String s); ++ public abstract void deserialize(String s); // PAIL - private->public - public abstract String getValue(); + public abstract String serialize(); @@ -341,7 +341,7 @@ } @Override -- protected void setValue(String s) { -+ public void setValue(String s) { // PAIL - protected->public +- protected void deserialize(String s) { ++ public void deserialize(String s) { // PAIL - protected->public this.value = Boolean.parseBoolean(s); } @@ -60,8 +60,8 @@ } @Override -- protected void setValue(String s) { -+ public void setValue(String s) { // PAIL - protected->public - this.value = c(s); +- protected void deserialize(String s) { ++ public void deserialize(String s) { // PAIL - protected->public + this.value = safeParse(s); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/GeneratorAccess.patch b/paper-server/nms-patches/net/minecraft/world/level/GeneratorAccess.patch index 7a933272c0..b928def0b7 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/GeneratorAccess.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/GeneratorAccess.patch @@ -1,8 +1,22 @@ --- a/net/minecraft/world/level/GeneratorAccess.java +++ b/net/minecraft/world/level/GeneratorAccess.java -@@ -77,4 +77,6 @@ - default void a(@Nullable Entity entity, GameEvent gameevent, Entity entity1) { - this.a(entity, gameevent, entity1.getChunkCoordinates()); +@@ -31,11 +31,11 @@ + + LevelTickAccess<Block> getBlockTicks(); + +- private default <T> NextTickListEntry<T> createTick(BlockPosition blockposition, T t0, int i, TickListPriority ticklistpriority) { ++ default <T> NextTickListEntry<T> createTick(BlockPosition blockposition, T t0, int i, TickListPriority ticklistpriority) { // CraftBukkit - decompile error + return new NextTickListEntry(t0, blockposition, this.getLevelData().getGameTime() + (long) i, ticklistpriority, this.nextSubTickCount()); + } + +- private default <T> NextTickListEntry<T> createTick(BlockPosition blockposition, T t0, int i) { ++ default <T> NextTickListEntry<T> createTick(BlockPosition blockposition, T t0, int i) { // CraftBukkit - decompile error + return new NextTickListEntry(t0, blockposition, this.getLevelData().getGameTime() + (long) i, this.nextSubTickCount()); + } + +@@ -102,4 +102,6 @@ + default void gameEvent(@Nullable Entity entity, GameEvent gameevent, Entity entity1) { + this.gameEvent(entity, gameevent, entity1.blockPosition()); } + + net.minecraft.server.level.WorldServer getMinecraftWorld(); // CraftBukkit diff --git a/paper-server/nms-patches/net/minecraft/world/level/IBlockAccess.patch b/paper-server/nms-patches/net/minecraft/world/level/IBlockAccess.patch index 7b8f505ffa..15e1b1d7c4 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/IBlockAccess.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/IBlockAccess.patch @@ -1,41 +1,41 @@ --- a/net/minecraft/world/level/IBlockAccess.java +++ b/net/minecraft/world/level/IBlockAccess.java @@ -26,7 +26,7 @@ - default <T extends TileEntity> Optional<T> a(BlockPosition blockposition, TileEntityTypes<T> tileentitytypes) { - TileEntity tileentity = this.getTileEntity(blockposition); + default <T extends TileEntity> Optional<T> getBlockEntity(BlockPosition blockposition, TileEntityTypes<T> tileentitytypes) { + TileEntity tileentity = this.getBlockEntity(blockposition); -- return tileentity != null && tileentity.getTileType() == tileentitytypes ? Optional.of(tileentity) : Optional.empty(); -+ return tileentity != null && tileentity.getTileType() == tileentitytypes ? (Optional<T>) Optional.of(tileentity) : Optional.empty(); // CraftBukkit - decompile error +- return tileentity != null && tileentity.getType() == tileentitytypes ? Optional.of(tileentity) : Optional.empty(); ++ return tileentity != null && tileentity.getType() == tileentitytypes ? (Optional<T>) Optional.of(tileentity) : Optional.empty(); // CraftBukkit - decompile error } - IBlockData getType(BlockPosition blockposition); + IBlockData getBlockState(BlockPosition blockposition); @@ -58,8 +58,8 @@ }); } -- default MovingObjectPositionBlock rayTrace(RayTrace raytrace) { -- return (MovingObjectPositionBlock) a(raytrace.b(), raytrace.a(), raytrace, (raytrace1, blockposition) -> { +- default MovingObjectPositionBlock clip(RayTrace raytrace) { +- return (MovingObjectPositionBlock) traverseBlocks(raytrace.getFrom(), raytrace.getTo(), raytrace, (raytrace1, blockposition) -> { + // CraftBukkit start - moved block handling into separate method for use by Block#rayTrace -+ default MovingObjectPositionBlock rayTraceBlock(RayTrace raytrace1, BlockPosition blockposition) { - IBlockData iblockdata = this.getType(blockposition); - Fluid fluid = this.getFluid(blockposition); - Vec3D vec3d = raytrace1.b(); ++ default MovingObjectPositionBlock clip(RayTrace raytrace1, BlockPosition blockposition) { + IBlockData iblockdata = this.getBlockState(blockposition); + Fluid fluid = this.getFluidState(blockposition); + Vec3D vec3d = raytrace1.getFrom(); @@ -72,6 +72,12 @@ - double d1 = movingobjectpositionblock1 == null ? Double.MAX_VALUE : raytrace1.b().distanceSquared(movingobjectpositionblock1.getPos()); + double d1 = movingobjectpositionblock1 == null ? Double.MAX_VALUE : raytrace1.getFrom().distanceToSqr(movingobjectpositionblock1.getLocation()); return d0 <= d1 ? movingobjectpositionblock : movingobjectpositionblock1; + } + // CraftBukkit end + -+ default MovingObjectPositionBlock rayTrace(RayTrace raytrace) { -+ return (MovingObjectPositionBlock) a(raytrace.b(), raytrace.a(), raytrace, (raytrace1, blockposition) -> { -+ return this.rayTraceBlock(raytrace1, blockposition); // CraftBukkit - moved into separate method ++ default MovingObjectPositionBlock clip(RayTrace raytrace) { ++ return (MovingObjectPositionBlock) traverseBlocks(raytrace.getFrom(), raytrace.getTo(), raytrace, (raytrace1, blockposition) -> { ++ return this.clip(raytrace1, blockposition); // CraftBukkit - moved into separate method }, (raytrace1) -> { - Vec3D vec3d = raytrace1.b().d(raytrace1.a()); + Vec3D vec3d = raytrace1.getFrom().subtract(raytrace1.getTo()); @@ -144,7 +150,7 @@ - double d13 = d10 * (i1 > 0 ? 1.0D - MathHelper.g(d4) : MathHelper.g(d4)); - double d14 = d11 * (j1 > 0 ? 1.0D - MathHelper.g(d5) : MathHelper.g(d5)); + 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 diff --git a/paper-server/nms-patches/net/minecraft/world/level/IWorldWriter.patch b/paper-server/nms-patches/net/minecraft/world/level/IWorldWriter.patch index dbd5bdf328..29fe1cde21 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/IWorldWriter.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/IWorldWriter.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/IWorldWriter.java +++ b/net/minecraft/world/level/IWorldWriter.java @@ -28,4 +28,10 @@ - default boolean addEntity(Entity entity) { + default boolean addFreshEntity(Entity entity) { return false; } + + // CraftBukkit start -+ default boolean addEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ default boolean addFreshEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + return false; + } + // CraftBukkit end diff --git a/paper-server/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch b/paper-server/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch index 81924a8a1b..b4f040ea13 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/level/MobSpawnerAbstract.java +++ b/net/minecraft/world/level/MobSpawnerAbstract.java -@@ -73,6 +73,7 @@ +@@ -47,6 +47,7 @@ - public void setMobName(EntityTypes<?> entitytypes) { - this.nextSpawnData.getEntity().setString("id", IRegistry.ENTITY_TYPE.getKey(entitytypes).toString()); -+ this.spawnPotentials = MobSpawnerAbstract.EMPTY_POTENTIALS; // CraftBukkit - SPIGOT-3496, MC-92282 + public void setEntityId(EntityTypes<?> entitytypes) { + this.nextSpawnData.getEntityToSpawn().putString("id", IRegistry.ENTITY_TYPE.getKey(entitytypes).toString()); ++ this.spawnPotentials = SimpleWeightedRandomList.empty(); // CraftBukkit - SPIGOT-3496, MC-92282 } - private boolean c(World world, BlockPosition blockposition) { -@@ -156,7 +157,7 @@ + private boolean isNearPlayer(World world, BlockPosition blockposition) { +@@ -146,7 +147,7 @@ } } -- if (!worldserver.addAllEntitiesSafely(entity)) { -+ if (!worldserver.addAllEntitiesSafely(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER)) { // CraftBukkit - this.d(worldserver, blockposition); +- if (!worldserver.tryAddFreshEntityWithPassengers(entity)) { ++ if (!worldserver.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER)) { // CraftBukkit + this.delay(worldserver, blockposition); return; } diff --git a/paper-server/nms-patches/net/minecraft/world/level/RayTrace.patch b/paper-server/nms-patches/net/minecraft/world/level/RayTrace.patch index 79b5b9d4b5..d24ba0439c 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/RayTrace.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/RayTrace.patch @@ -4,11 +4,11 @@ this.to = vec3d1; this.block = raytrace_blockcollisionoption; this.fluid = raytrace_fluidcollisionoption; -- this.collisionContext = VoxelShapeCollision.a(entity); -+ this.collisionContext = (entity == null) ? VoxelShapeCollision.a() : VoxelShapeCollision.a(entity); // CraftBukkit +- this.collisionContext = VoxelShapeCollision.of(entity); ++ this.collisionContext = (entity == null) ? VoxelShapeCollision.empty() : VoxelShapeCollision.of(entity); // CraftBukkit } - public Vec3D a() { + public Vec3D getTo() { @@ -69,7 +69,7 @@ private final Predicate<Fluid> canPick; diff --git a/paper-server/nms-patches/net/minecraft/world/level/SpawnerCreature.patch b/paper-server/nms-patches/net/minecraft/world/level/SpawnerCreature.patch index c73d364c27..5d81d866c5 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/SpawnerCreature.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/SpawnerCreature.patch @@ -16,31 +16,31 @@ if (entity instanceof EntityInsentient) { EntityInsentient entityinsentient = (EntityInsentient) entity; -- if (entityinsentient.isPersistent() || entityinsentient.isSpecialPersistence()) { +- if (entityinsentient.isPersistenceRequired() || entityinsentient.requiresCustomPersistence()) { + // CraftBukkit - Split out persistent check, don't apply it to special persistent mobs -+ if (entityinsentient.isTypeNotPersistent(0) && entityinsentient.isPersistent()) { ++ if (entityinsentient.removeWhenFarAway(0) && entityinsentient.isPersistenceRequired()) { continue; } } -@@ -108,10 +114,54 @@ +@@ -111,10 +117,54 @@ EnumCreatureType[] aenumcreaturetype = SpawnerCreature.SPAWNING_CATEGORIES; int i = aenumcreaturetype.length; + // CraftBukkit start - Other mob type spawn tick rate -+ WorldData worlddata = worldserver.getWorldData(); -+ boolean spawnAnimalThisTick = worldserver.ticksPerAnimalSpawns != 0L && worlddata.getTime() % worldserver.ticksPerAnimalSpawns == 0L; -+ boolean spawnMonsterThisTick = worldserver.ticksPerMonsterSpawns != 0L && worlddata.getTime() % worldserver.ticksPerMonsterSpawns == 0L; -+ boolean spawnWaterThisTick = worldserver.ticksPerWaterSpawns != 0L && worlddata.getTime() % worldserver.ticksPerWaterSpawns == 0L; -+ boolean spawnAmbientThisTick = worldserver.ticksPerAmbientSpawns != 0L && worlddata.getTime() % worldserver.ticksPerAmbientSpawns == 0L; -+ boolean spawnWaterAmbientThisTick = worldserver.ticksPerWaterAmbientSpawns != 0L && worlddata.getTime() % worldserver.ticksPerWaterAmbientSpawns == 0L; -+ boolean spawnWaterUndergroundCreatureThisTick = worldserver.ticksPerWaterUndergroundCreatureSpawns != 0L && worlddata.getTime() % worldserver.ticksPerWaterUndergroundCreatureSpawns == 0L; ++ WorldData worlddata = worldserver.getLevelData(); ++ boolean spawnAnimalThisTick = worldserver.ticksPerAnimalSpawns != 0L && worlddata.getGameTime() % worldserver.ticksPerAnimalSpawns == 0L; ++ boolean spawnMonsterThisTick = worldserver.ticksPerMonsterSpawns != 0L && worlddata.getGameTime() % worldserver.ticksPerMonsterSpawns == 0L; ++ boolean spawnWaterThisTick = worldserver.ticksPerWaterSpawns != 0L && worlddata.getGameTime() % worldserver.ticksPerWaterSpawns == 0L; ++ boolean spawnAmbientThisTick = worldserver.ticksPerAmbientSpawns != 0L && worlddata.getGameTime() % worldserver.ticksPerAmbientSpawns == 0L; ++ boolean spawnWaterAmbientThisTick = worldserver.ticksPerWaterAmbientSpawns != 0L && worlddata.getGameTime() % worldserver.ticksPerWaterAmbientSpawns == 0L; ++ boolean spawnWaterUndergroundCreatureThisTick = worldserver.ticksPerWaterUndergroundCreatureSpawns != 0L && worlddata.getGameTime() % worldserver.ticksPerWaterUndergroundCreatureSpawns == 0L; + // CraftBukkit end + for (int j = 0; j < i; ++j) { EnumCreatureType enumcreaturetype = aenumcreaturetype[j]; + // CraftBukkit start - Use per-world spawn limits + boolean spawnThisTick = true; -+ int limit = enumcreaturetype.b(); ++ int limit = enumcreaturetype.getMaxInstancesPerChunk(); + switch (enumcreaturetype) { + case MONSTER: + spawnThisTick = spawnMonsterThisTick; @@ -68,54 +68,54 @@ + break; + } -- if ((flag || !enumcreaturetype.d()) && (flag1 || enumcreaturetype.d()) && (flag2 || !enumcreaturetype.e()) && spawnercreature_d.a(enumcreaturetype)) { +- if ((flag || !enumcreaturetype.isFriendly()) && (flag1 || enumcreaturetype.isFriendly()) && (flag2 || !enumcreaturetype.isPersistent()) && spawnercreature_d.canSpawnForCategory(enumcreaturetype, chunk.getPos())) { + if (!spawnThisTick || limit == 0) { + continue; + } + -+ if ((flag || !enumcreaturetype.d()) && (flag1 || enumcreaturetype.d()) && (flag2 || !enumcreaturetype.e()) && spawnercreature_d.a(enumcreaturetype, limit)) { ++ if ((flag || !enumcreaturetype.isFriendly()) && (flag1 || enumcreaturetype.isFriendly()) && (flag2 || !enumcreaturetype.isPersistent()) && spawnercreature_d.canSpawnForCategory(enumcreaturetype, chunk.getPos(), limit)) { + // CraftBukkit end Objects.requireNonNull(spawnercreature_d); - SpawnerCreature.c spawnercreature_c = spawnercreature_d::a; + SpawnerCreature.c spawnercreature_c = spawnercreature_d::canSpawn; -@@ -196,10 +246,14 @@ - entityinsentient.setPositionRotation(d0, (double) i, d1, worldserver.random.nextFloat() * 360.0F, 0.0F); - if (a(worldserver, entityinsentient, d2)) { - groupdataentity = entityinsentient.prepare(worldserver, worldserver.getDamageScaler(entityinsentient.getChunkCoordinates()), EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null); +@@ -199,10 +249,14 @@ + 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()), EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null); - ++j; - ++k1; -- worldserver.addAllEntities(entityinsentient); +- worldserver.addFreshEntityWithPassengers(entityinsentient); - spawnercreature_a.run(entityinsentient, ichunkaccess); + // CraftBukkit start -+ worldserver.addAllEntities(entityinsentient, SpawnReason.NATURAL); ++ worldserver.addFreshEntityWithPassengers(entityinsentient, SpawnReason.NATURAL); + if (!entityinsentient.isRemoved()) { + ++j; + ++k1; + spawnercreature_a.run(entityinsentient, ichunkaccess); + } + // CraftBukkit end - if (j >= entityinsentient.getMaxSpawnGroup()) { + if (j >= entityinsentient.getMaxSpawnClusterSize()) { return; } -@@ -370,7 +424,7 @@ +@@ -377,7 +431,7 @@ - if (entityinsentient.a((GeneratorAccess) worldaccess, EnumMobSpawn.CHUNK_GENERATION) && entityinsentient.a((IWorldReader) worldaccess)) { - groupdataentity = entityinsentient.prepare(worldaccess, worldaccess.getDamageScaler(entityinsentient.getChunkCoordinates()), EnumMobSpawn.CHUNK_GENERATION, groupdataentity, (NBTTagCompound) null); -- worldaccess.addAllEntities(entityinsentient); -+ worldaccess.addAllEntities(entityinsentient, SpawnReason.CHUNK_GEN); // CraftBukkit + if (entityinsentient.checkSpawnRules(worldaccess, EnumMobSpawn.CHUNK_GENERATION) && entityinsentient.checkSpawnObstruction(worldaccess)) { + groupdataentity = entityinsentient.finalizeSpawn(worldaccess, worldaccess.getCurrentDifficultyAt(entityinsentient.blockPosition()), EnumMobSpawn.CHUNK_GENERATION, groupdataentity, (NBTTagCompound) null); +- worldaccess.addFreshEntityWithPassengers(entityinsentient); ++ worldaccess.addFreshEntityWithPassengers(entityinsentient, SpawnReason.CHUNK_GEN); // CraftBukkit flag = true; } } -@@ -486,8 +540,10 @@ +@@ -498,8 +552,10 @@ return this.unmodifiableMobCategoryCounts; } -- boolean a(EnumCreatureType enumcreaturetype) { -- int i = enumcreaturetype.b() * this.spawnableChunkCount / SpawnerCreature.MAGIC_NUMBER; +- boolean canSpawnForCategory(EnumCreatureType enumcreaturetype, ChunkCoordIntPair chunkcoordintpair) { +- int i = enumcreaturetype.getMaxInstancesPerChunk() * this.spawnableChunkCount / SpawnerCreature.MAGIC_NUMBER; + // CraftBukkit start -+ boolean a(EnumCreatureType enumcreaturetype, int limit) { ++ boolean canSpawnForCategory(EnumCreatureType enumcreaturetype, ChunkCoordIntPair chunkcoordintpair, int limit) { + int i = limit * this.spawnableChunkCount / SpawnerCreature.MAGIC_NUMBER; + // CraftBukkit end - return this.mobCategoryCounts.getInt(enumcreaturetype) < i; + return this.mobCategoryCounts.getInt(enumcreaturetype) >= i ? false : this.localMobCapCalculator.canSpawn(enumcreaturetype, chunkcoordintpair); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/StructureManager.patch b/paper-server/nms-patches/net/minecraft/world/level/StructureManager.patch index 632914fc05..3730eb8b0b 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/StructureManager.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/StructureManager.patch @@ -4,4 +4,4 @@ +// mc-dev import package net.minecraft.world.level; - import com.mojang.datafixers.DataFixUtils; + import com.google.common.collect.ImmutableList; diff --git a/paper-server/nms-patches/net/minecraft/world/level/TickListServer.patch b/paper-server/nms-patches/net/minecraft/world/level/TickListServer.patch deleted file mode 100644 index 213d7c69a1..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/level/TickListServer.patch +++ /dev/null @@ -1,31 +0,0 @@ ---- a/net/minecraft/world/level/TickListServer.java -+++ b/net/minecraft/world/level/TickListServer.java -@@ -47,11 +47,17 @@ - public void b() { - int i = this.tickNextTickList.size(); - -- if (i != this.tickNextTickSet.size()) { -+ if (false) { // CraftBukkit - throw new IllegalStateException("TickNextTick list out of synch"); - } else { - if (i > 65536) { -- i = 65536; -+ // CraftBukkit start - If the server has too much to process over time, try to alleviate that -+ if (i > 20 * 65536) { -+ i = i / 20; -+ } else { -+ i = 65536; -+ } -+ // CraftBukkit end - } - - Iterator<NextTickListEntry<T>> iterator = this.tickNextTickList.iterator(); -@@ -89,7 +95,7 @@ - throw new ReportedException(crashreport); - } - } else { -- this.a(nextticklistentry.pos, nextticklistentry.b(), 0); -+ this.a(nextticklistentry.pos, (T) nextticklistentry.b(), 0); // CraftBukkit - decompile error - } - } - diff --git a/paper-server/nms-patches/net/minecraft/world/level/World.patch b/paper-server/nms-patches/net/minecraft/world/level/World.patch index da7951823c..3b025c4745 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/World.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/World.patch @@ -29,9 +29,9 @@ public abstract class World implements GeneratorAccess, AutoCloseable { protected static final Logger LOGGER = LogManager.getLogger(); -@@ -103,7 +125,52 @@ - private final BiomeManager biomeManager; +@@ -104,7 +126,52 @@ private final ResourceKey<World> dimension; + private long subTickCount; - protected World(WorldDataMutable worlddatamutable, ResourceKey<World> resourcekey, final DimensionManager dimensionmanager, Supplier<GameProfilerFiller> supplier, boolean flag, boolean flag1, long i) { + // CraftBukkit start Added the following @@ -76,98 +76,105 @@ + this.ticksPerWaterAmbientSpawns = this.getCraftServer().getTicksPerWaterAmbientSpawns(); // CraftBukkit + this.ticksPerWaterUndergroundCreatureSpawns = this.getCraftServer().getTicksPerWaterUndergroundCreatureSpawns(); // CraftBukkit + this.ticksPerAmbientSpawns = this.getCraftServer().getTicksPerAmbientSpawns(); // CraftBukkit -+ this.typeKey = (ResourceKey) this.getCraftServer().getHandle().getServer().registryHolder.d(IRegistry.DIMENSION_TYPE_REGISTRY).c(dimensionmanager).orElseThrow(() -> { ++ this.typeKey = (ResourceKey) this.getCraftServer().getHandle().getServer().registryHolder.registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getResourceKey(dimensionmanager).orElseThrow(() -> { + return new IllegalStateException("Unregistered dimension type: " + dimensionmanager); + }); + // CraftBukkit end this.profiler = supplier; this.levelData = worlddatamutable; this.dimensionType = dimensionmanager; -@@ -113,12 +180,12 @@ +@@ -114,12 +181,12 @@ this.worldBorder = new WorldBorder() { @Override public double getCenterX() { -- return super.getCenterX() / dimensionmanager.getCoordinateScale(); +- return super.getCenterX() / dimensionmanager.coordinateScale(); + return super.getCenterX(); // CraftBukkit } @Override public double getCenterZ() { -- return super.getCenterZ() / dimensionmanager.getCoordinateScale(); +- return super.getCenterZ() / dimensionmanager.coordinateScale(); + return super.getCenterZ(); // CraftBukkit } }; } else { -@@ -128,6 +195,35 @@ +@@ -129,6 +196,42 @@ this.thread = Thread.currentThread(); - this.biomeManager = new BiomeManager(this, i, dimensionmanager.getGenLayerZoomer()); + this.biomeManager = new BiomeManager(this, i); this.isDebug = flag1; + // CraftBukkit start + getWorldBorder().world = (WorldServer) this; + // From PlayerList.setPlayerFileData -+ getWorldBorder().a(new IWorldBorderListener() { -+ public void a(WorldBorder worldborder, double d0) { -+ getCraftServer().getHandle().sendAll(new ClientboundSetBorderSizePacket(worldborder), worldborder.world); ++ getWorldBorder().addListener(new IWorldBorderListener() { ++ @Override ++ public void onBorderSizeSet(WorldBorder worldborder, double d0) { ++ getCraftServer().getHandle().broadcastAll(new ClientboundSetBorderSizePacket(worldborder), worldborder.world); + } + -+ public void a(WorldBorder worldborder, double d0, double d1, long i) { -+ getCraftServer().getHandle().sendAll(new ClientboundSetBorderLerpSizePacket(worldborder), worldborder.world); ++ @Override ++ public void onBorderSizeLerping(WorldBorder worldborder, double d0, double d1, long i) { ++ getCraftServer().getHandle().broadcastAll(new ClientboundSetBorderLerpSizePacket(worldborder), worldborder.world); + } + -+ public void a(WorldBorder worldborder, double d0, double d1) { -+ getCraftServer().getHandle().sendAll(new ClientboundSetBorderCenterPacket(worldborder), worldborder.world); ++ @Override ++ public void onBorderCenterSet(WorldBorder worldborder, double d0, double d1) { ++ getCraftServer().getHandle().broadcastAll(new ClientboundSetBorderCenterPacket(worldborder), worldborder.world); + } + -+ public void a(WorldBorder worldborder, int i) { -+ getCraftServer().getHandle().sendAll(new ClientboundSetBorderWarningDelayPacket(worldborder), worldborder.world); ++ @Override ++ public void onBorderSetWarningTime(WorldBorder worldborder, int i) { ++ getCraftServer().getHandle().broadcastAll(new ClientboundSetBorderWarningDelayPacket(worldborder), worldborder.world); + } + -+ public void b(WorldBorder worldborder, int i) { -+ getCraftServer().getHandle().sendAll(new ClientboundSetBorderWarningDistancePacket(worldborder), worldborder.world); ++ @Override ++ public void onBorderSetWarningBlocks(WorldBorder worldborder, int i) { ++ getCraftServer().getHandle().broadcastAll(new ClientboundSetBorderWarningDistancePacket(worldborder), worldborder.world); + } + -+ public void b(WorldBorder worldborder, double d0) {} ++ @Override ++ public void onBorderSetDamagePerBlock(WorldBorder worldborder, double d0) {} + -+ public void c(WorldBorder worldborder, double d0) {} ++ @Override ++ public void onBorderSetDamageSafeZOne(WorldBorder worldborder, double d0) {} + }); + // CraftBukkit end } @Override -@@ -185,6 +281,17 @@ +@@ -186,6 +289,17 @@ @Override - public boolean a(BlockPosition blockposition, IBlockData iblockdata, int i, int j) { + public boolean setBlock(BlockPosition blockposition, IBlockData iblockdata, int i, int j) { + // CraftBukkit start - tree generation + if (this.captureTreeGeneration) { + CapturedBlockState blockstate = capturedBlockStates.get(blockposition); + if (blockstate == null) { + blockstate = CapturedBlockState.getTreeBlockState(this, blockposition, i); -+ this.capturedBlockStates.put(blockposition.immutableCopy(), blockstate); ++ this.capturedBlockStates.put(blockposition.immutable(), blockstate); + } + blockstate.setData(iblockdata); + return true; + } + // CraftBukkit end - if (this.isOutsideWorld(blockposition)) { + if (this.isOutsideBuildHeight(blockposition)) { return false; - } else if (!this.isClientSide && this.isDebugWorld()) { -@@ -192,9 +299,24 @@ + } else if (!this.isClientSide && this.isDebug()) { +@@ -193,9 +307,24 @@ } else { - Chunk chunk = this.getChunkAtWorldCoords(blockposition); + Chunk chunk = this.getChunkAt(blockposition); Block block = iblockdata.getBlock(); -- IBlockData iblockdata1 = chunk.setType(blockposition, iblockdata, (i & 64) != 0); +- IBlockData iblockdata1 = chunk.setBlockState(blockposition, iblockdata, (i & 64) != 0); + + // CraftBukkit start - capture blockstates + boolean captured = false; + if (this.captureBlockStates && !this.capturedBlockStates.containsKey(blockposition)) { + CapturedBlockState blockstate = CapturedBlockState.getBlockState(this, blockposition, i); -+ this.capturedBlockStates.put(blockposition.immutableCopy(), blockstate); ++ this.capturedBlockStates.put(blockposition.immutable(), blockstate); + captured = true; + } + // CraftBukkit end + -+ IBlockData iblockdata1 = chunk.setType(blockposition, iblockdata, (i & 64) != 0, (i & 1024) == 0); // CraftBukkit custom NO_PLACE flag ++ IBlockData iblockdata1 = chunk.setBlockState(blockposition, iblockdata, (i & 64) != 0, (i & 1024) == 0); // CraftBukkit custom NO_PLACE flag if (iblockdata1 == null) { + // CraftBukkit start - remove blockstate if failed (or the same) @@ -177,18 +184,18 @@ + // CraftBukkit end return false; } else { - IBlockData iblockdata2 = this.getType(blockposition); -@@ -205,6 +327,7 @@ - this.getMethodProfiler().exit(); + IBlockData iblockdata2 = this.getBlockState(blockposition); +@@ -206,6 +335,7 @@ + this.getProfiler().pop(); } + /* if (iblockdata2 == iblockdata) { if (iblockdata1 != iblockdata2) { - this.b(blockposition, iblockdata1, iblockdata2); -@@ -231,12 +354,69 @@ + this.setBlocksDirty(blockposition, iblockdata1, iblockdata2); +@@ -232,12 +362,69 @@ - this.a(blockposition, iblockdata1, iblockdata2); + this.onBlockStateChange(blockposition, iblockdata1, iblockdata2); } + */ + @@ -211,17 +218,17 @@ + IBlockData iblockdata2 = actualBlock; + if (iblockdata2 == iblockdata) { + if (iblockdata1 != iblockdata2) { -+ this.b(blockposition, iblockdata1, iblockdata2); ++ this.setBlocksDirty(blockposition, iblockdata1, iblockdata2); + } + -+ if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (this.isClientSide || chunk == null || (chunk.getState() != null && chunk.getState().isAtLeast(PlayerChunk.State.TICKING)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement -+ this.notify(blockposition, iblockdata1, iblockdata, i); ++ if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (this.isClientSide || chunk == null || (chunk.getFullStatus() != null && chunk.getFullStatus().isOrAfter(PlayerChunk.State.TICKING)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement ++ this.sendBlockUpdated(blockposition, iblockdata1, iblockdata, i); + } + + if ((i & 1) != 0) { -+ this.update(blockposition, iblockdata1.getBlock()); -+ if (!this.isClientSide && iblockdata.isComplexRedstone()) { -+ this.updateAdjacentComparators(blockposition, newBlock.getBlock()); ++ this.blockUpdated(blockposition, iblockdata1.getBlock()); ++ if (!this.isClientSide && iblockdata.hasAnalogOutputSignal()) { ++ this.updateNeighbourForOutputSignal(blockposition, newBlock.getBlock()); + } + } + @@ -229,7 +236,7 @@ + int k = i & -34; + + // CraftBukkit start -+ iblockdata1.b(this, blockposition, k, j - 1); // Don't call an event for the old block to limit event spam ++ iblockdata1.updateIndirectNeighbourShapes(this, blockposition, k, j - 1); // Don't call an event for the old block to limit event spam + CraftWorld world = ((WorldServer) this).getWorld(); + if (world != null) { + BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftBlockData.fromData(iblockdata)); @@ -240,24 +247,24 @@ + } + } + // CraftBukkit end -+ iblockdata.a((GeneratorAccess) this, blockposition, k, j - 1); -+ iblockdata.b(this, blockposition, k, j - 1); ++ iblockdata.updateNeighbourShapes(this, blockposition, k, j - 1); ++ iblockdata.updateIndirectNeighbourShapes(this, blockposition, k, j - 1); + } + + // CraftBukkit start - SPIGOT-5710 + if (!preventPoiUpdated) { -+ this.a(blockposition, iblockdata1, iblockdata2); ++ this.onBlockStateChange(blockposition, iblockdata1, iblockdata2); + } + // CraftBukkit end + } + } + // CraftBukkit end + - public void a(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {} + public void onBlockStateChange(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {} @Override -@@ -326,6 +506,17 @@ - IBlockData iblockdata = this.getType(blockposition); +@@ -327,6 +514,17 @@ + IBlockData iblockdata = this.getBlockState(blockposition); try { + // CraftBukkit start @@ -271,13 +278,13 @@ + } + } + // CraftBukkit end - iblockdata.doPhysics(this, blockposition, block, blockposition1, false); + iblockdata.neighborChanged(this, blockposition, block, blockposition1, false); } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours"); -@@ -368,6 +559,14 @@ + CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception while updating neighbours"); +@@ -369,6 +567,14 @@ @Override - public IBlockData getType(BlockPosition blockposition) { + public IBlockData getBlockState(BlockPosition blockposition) { + // CraftBukkit start - tree generation + if (captureTreeGeneration) { + CapturedBlockState previous = capturedBlockStates.get(blockposition); @@ -286,53 +293,52 @@ + } + } + // CraftBukkit end - if (this.isOutsideWorld(blockposition)) { - return Blocks.VOID_AIR.getBlockData(); + if (this.isOutsideBuildHeight(blockposition)) { + return Blocks.VOID_AIR.defaultBlockState(); } else { -@@ -484,7 +683,17 @@ - +@@ -494,6 +700,16 @@ @Nullable @Override -+ // CraftBukkit start - public TileEntity getTileEntity(BlockPosition blockposition) { -+ return getTileEntity(blockposition, true); + public TileEntity getBlockEntity(BlockPosition blockposition) { ++ // CraftBukkit start ++ return getBlockEntity(blockposition, true); + } + + @Nullable -+ public TileEntity getTileEntity(BlockPosition blockposition, boolean validate) { ++ public TileEntity getBlockEntity(BlockPosition blockposition, boolean validate) { + if (capturedTileEntities.containsKey(blockposition)) { + return capturedTileEntities.get(blockposition); + } + // CraftBukkit end - return this.isOutsideWorld(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAtWorldCoords(blockposition).a(blockposition, Chunk.EnumTileEntityState.IMMEDIATE)); + return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, Chunk.EnumTileEntityState.IMMEDIATE)); } -@@ -492,6 +701,12 @@ - BlockPosition blockposition = tileentity.getPosition(); +@@ -501,6 +717,12 @@ + BlockPosition blockposition = tileentity.getBlockPos(); - if (!this.isOutsideWorld(blockposition)) { + if (!this.isOutsideBuildHeight(blockposition)) { + // CraftBukkit start + if (captureBlockStates) { -+ capturedTileEntities.put(blockposition.immutableCopy(), tileentity); ++ capturedTileEntities.put(blockposition.immutable(), tileentity); + return; + } + // CraftBukkit end - this.getChunkAtWorldCoords(blockposition).b(tileentity); + this.getChunkAt(blockposition).addAndRegisterBlockEntity(tileentity); } } -@@ -595,7 +810,7 @@ +@@ -605,7 +827,7 @@ for (int j = 0; j < i; ++j) { EntityComplexPart entitycomplexpart = aentitycomplexpart[j]; -- T t0 = (Entity) entitytypetest.a((Object) entitycomplexpart); -+ T t0 = entitytypetest.a(entitycomplexpart); +- T t0 = (Entity) entitytypetest.tryCast(entitycomplexpart); ++ T t0 = entitytypetest.tryCast(entitycomplexpart); // CraftBukkit - decompile error if (t0 != null && predicate.test(t0)) { list.add(t0); -@@ -921,6 +1136,14 @@ +@@ -931,6 +1153,14 @@ public abstract LevelEntityGetter<Entity> getEntities(); - protected void a(@Nullable Entity entity, GameEvent gameevent, BlockPosition blockposition, int i) { + protected void postGameEventInRadius(@Nullable Entity entity, GameEvent gameevent, BlockPosition blockposition, int i) { + // CraftBukkit start + GenericGameEvent event = new GenericGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.GAME_EVENT.getKey(gameevent))), new Location(this.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()), (entity == null) ? null : entity.getBukkitEntity(), i); + getCraftServer().getPluginManager().callEvent(event); @@ -341,6 +347,6 @@ + } + i = event.getRadius(); + // CraftBukkit end - int j = SectionPosition.a(blockposition.getX() - i); - int k = SectionPosition.a(blockposition.getZ() - i); - int l = SectionPosition.a(blockposition.getX() + i); + int j = SectionPosition.blockToSectionCoord(blockposition.getX() - i); + int k = SectionPosition.blockToSectionCoord(blockposition.getZ() - i); + int l = SectionPosition.blockToSectionCoord(blockposition.getX() + i); diff --git a/paper-server/nms-patches/net/minecraft/world/level/WorldAccess.patch b/paper-server/nms-patches/net/minecraft/world/level/WorldAccess.patch index 6a1a92b6f0..204d48ae8d 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/WorldAccess.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/WorldAccess.patch @@ -3,14 +3,14 @@ @@ -8,6 +8,17 @@ WorldServer getLevel(); - default void addAllEntities(Entity entity) { -- entity.recursiveStream().forEach(this::addEntity); + default void addFreshEntityWithPassengers(Entity entity) { +- entity.getSelfAndPassengers().forEach(this::addFreshEntity); + // CraftBukkit start -+ this.addAllEntities(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); ++ this.addFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); } + -+ default void addAllEntities(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { -+ entity.recursiveStream().forEach((e) -> this.addEntity(e, reason)); ++ default void addFreshEntityWithPassengers(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ entity.getSelfAndPassengers().forEach((e) -> this.addFreshEntity(e, reason)); + } + + @Override diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/AbstractCandleBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/AbstractCandleBlock.patch index 4a5c5ff380..e1a4e22ac4 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/AbstractCandleBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/AbstractCandleBlock.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/AbstractCandleBlock.java +++ b/net/minecraft/world/level/block/AbstractCandleBlock.java -@@ -39,6 +39,11 @@ +@@ -38,6 +38,11 @@ @Override - public void a(World world, IBlockData iblockdata, MovingObjectPositionBlock movingobjectpositionblock, IProjectile iprojectile) { - if (!world.isClientSide && iprojectile.isBurning() && this.c(iblockdata)) { + public void onProjectileHit(World world, IBlockData iblockdata, MovingObjectPositionBlock movingobjectpositionblock, IProjectile iprojectile) { + if (!world.isClientSide && iprojectile.isOnFire() && this.canBeLit(iblockdata)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, movingobjectpositionblock.getBlockPosition(), iprojectile).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, movingobjectpositionblock.getBlockPos(), iprojectile).isCancelled()) { + return; + } + // CraftBukkit end - a(world, iblockdata, movingobjectpositionblock.getBlockPosition(), true); + setLit(world, iblockdata, movingobjectpositionblock.getBlockPos(), true); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/AzaleaBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/AzaleaBlock.patch index 501a20cc4b..981f5ba2ba 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/AzaleaBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/AzaleaBlock.patch @@ -17,11 +17,11 @@ @@ -43,6 +50,29 @@ @Override - public void a(WorldServer worldserver, Random random, BlockPosition blockposition, IBlockData iblockdata) { + public void performBonemeal(WorldServer worldserver, Random random, BlockPosition blockposition, IBlockData iblockdata) { + // CraftBukkit start + worldserver.captureTreeGeneration = true; + // CraftBukkit end - AzaleaBlock.TREE_GROWER.a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), blockposition, iblockdata, random); + AzaleaBlock.TREE_GROWER.growTree(worldserver, worldserver.getChunkSource().getGenerator(), blockposition, iblockdata, random); + // CraftBukkit start + worldserver.captureTreeGeneration = false; + if (worldserver.capturedBlockStates.size() > 0) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BigDripleafBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BigDripleafBlock.patch index 7a088df5a8..b4b02cd2c1 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BigDripleafBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BigDripleafBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BigDripleafBlock.java +++ b/net/minecraft/world/level/block/BigDripleafBlock.java -@@ -40,12 +40,17 @@ +@@ -42,6 +42,11 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -12,27 +12,20 @@ public class BigDripleafBlock extends BlockFacingHorizontal implements IBlockFragilePlantElement, IBlockWaterlogged { private static final BlockStateBoolean WATERLOGGED = BlockProperties.WATERLOGGED; - private static final BlockStateEnum<Tilt> TILT = BlockProperties.TILT; - private static final int NO_TICK = -1; -- private static final Object2IntMap<Tilt> DELAY_UNTIL_NEXT_TILT_STATE = (Object2IntMap) SystemUtils.a((Object) (new Object2IntArrayMap()), (object2intarraymap) -> { -+ private static final Object2IntMap<Tilt> DELAY_UNTIL_NEXT_TILT_STATE = (Object2IntMap) SystemUtils.a((new Object2IntArrayMap()), (object2intarraymap) -> { // CraftBukkit - decompile error - object2intarraymap.defaultReturnValue(-1); - object2intarraymap.put(Tilt.UNSTABLE, 10); - object2intarraymap.put(Tilt.PARTIAL, 10); -@@ -108,7 +113,7 @@ +@@ -110,7 +115,7 @@ @Override - public void a(World world, IBlockData iblockdata, MovingObjectPositionBlock movingobjectpositionblock, IProjectile iprojectile) { -- this.a(iblockdata, world, movingobjectpositionblock.getBlockPosition(), Tilt.FULL, SoundEffects.BIG_DRIPLEAF_TILT_DOWN); -+ this.a(iblockdata, world, movingobjectpositionblock.getBlockPosition(), Tilt.FULL, SoundEffects.BIG_DRIPLEAF_TILT_DOWN, iprojectile); // CraftBukkit + public void onProjectileHit(World world, IBlockData iblockdata, MovingObjectPositionBlock movingobjectpositionblock, IProjectile iprojectile) { +- this.setTiltAndScheduleTick(iblockdata, world, movingobjectpositionblock.getBlockPos(), Tilt.FULL, SoundEffects.BIG_DRIPLEAF_TILT_DOWN); ++ this.setTiltAndScheduleTick(iblockdata, world, movingobjectpositionblock.getBlockPos(), Tilt.FULL, SoundEffects.BIG_DRIPLEAF_TILT_DOWN, iprojectile); // CraftBukkit } @Override -@@ -167,7 +172,20 @@ - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { +@@ -169,7 +174,20 @@ + public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { if (!world.isClientSide) { - if (iblockdata.get(BigDripleafBlock.TILT) == Tilt.NONE && a(blockposition, entity) && !world.isBlockIndirectlyPowered(blockposition)) { -- this.a(iblockdata, world, blockposition, Tilt.UNSTABLE, (SoundEffect) null); + if (iblockdata.getValue(BigDripleafBlock.TILT) == Tilt.NONE && canEntityTilt(blockposition, entity) && !world.hasNeighborSignal(blockposition)) { +- this.setTiltAndScheduleTick(iblockdata, world, blockposition, Tilt.UNSTABLE, (SoundEffect) null); + // CraftBukkit start - tilt dripleaf + org.bukkit.event.Cancellable cancellable; + if (entity instanceof EntityHuman) { @@ -45,60 +38,60 @@ + if (cancellable.isCancelled()) { + return; + } ++ this.setTiltAndScheduleTick(iblockdata, world, blockposition, Tilt.UNSTABLE, (SoundEffect) null, entity); + // CraftBukkit end -+ this.a(iblockdata, world, blockposition, Tilt.UNSTABLE, (SoundEffect) null, entity); } } -@@ -181,9 +199,9 @@ - Tilt tilt = (Tilt) iblockdata.get(BigDripleafBlock.TILT); +@@ -183,9 +201,9 @@ + Tilt tilt = (Tilt) iblockdata.getValue(BigDripleafBlock.TILT); if (tilt == Tilt.UNSTABLE) { -- this.a(iblockdata, (World) worldserver, blockposition, Tilt.PARTIAL, SoundEffects.BIG_DRIPLEAF_TILT_DOWN); -+ this.a(iblockdata, (World) worldserver, blockposition, Tilt.PARTIAL, SoundEffects.BIG_DRIPLEAF_TILT_DOWN, null); // CraftBukkit +- this.setTiltAndScheduleTick(iblockdata, worldserver, blockposition, Tilt.PARTIAL, SoundEffects.BIG_DRIPLEAF_TILT_DOWN); ++ this.setTiltAndScheduleTick(iblockdata, worldserver, blockposition, Tilt.PARTIAL, SoundEffects.BIG_DRIPLEAF_TILT_DOWN, null); // CraftBukkit } else if (tilt == Tilt.PARTIAL) { -- this.a(iblockdata, (World) worldserver, blockposition, Tilt.FULL, SoundEffects.BIG_DRIPLEAF_TILT_DOWN); -+ this.a(iblockdata, (World) worldserver, blockposition, Tilt.FULL, SoundEffects.BIG_DRIPLEAF_TILT_DOWN, null); // CraftBukkit +- this.setTiltAndScheduleTick(iblockdata, worldserver, blockposition, Tilt.FULL, SoundEffects.BIG_DRIPLEAF_TILT_DOWN); ++ this.setTiltAndScheduleTick(iblockdata, worldserver, blockposition, Tilt.FULL, SoundEffects.BIG_DRIPLEAF_TILT_DOWN, null); // CraftBukkit } else if (tilt == Tilt.FULL) { - d(iblockdata, worldserver, blockposition); + resetTilt(iblockdata, worldserver, blockposition); } -@@ -209,8 +227,10 @@ - return entity.isOnGround() && entity.getPositionVector().y > (double) ((float) blockposition.getY() + 0.6875F); +@@ -211,8 +229,10 @@ + return entity.isOnGround() && entity.position().y > (double) ((float) blockposition.getY() + 0.6875F); } -- private void a(IBlockData iblockdata, World world, BlockPosition blockposition, Tilt tilt, @Nullable SoundEffect soundeffect) { -- a(iblockdata, world, blockposition, tilt); +- private void setTiltAndScheduleTick(IBlockData iblockdata, World world, BlockPosition blockposition, Tilt tilt, @Nullable SoundEffect soundeffect) { +- setTilt(iblockdata, world, blockposition, tilt); + // CraftBukkit start -+ private void a(IBlockData iblockdata, World world, BlockPosition blockposition, Tilt tilt, @Nullable SoundEffect soundeffect, @Nullable Entity entity) { -+ if (!a(iblockdata, world, blockposition, tilt, entity)) return; ++ private void setTiltAndScheduleTick(IBlockData iblockdata, World world, BlockPosition blockposition, Tilt tilt, @Nullable SoundEffect soundeffect, @Nullable Entity entity) { ++ if (!setTilt(iblockdata, world, blockposition, tilt, entity)) return; + // CraftBukkit end if (soundeffect != null) { - a(world, blockposition, soundeffect); + playTiltSound(world, blockposition, soundeffect); } -@@ -224,19 +244,27 @@ +@@ -226,19 +246,27 @@ } - private static void d(IBlockData iblockdata, World world, BlockPosition blockposition) { -- a(iblockdata, world, blockposition, Tilt.NONE); -+ a(iblockdata, world, blockposition, Tilt.NONE, null); // CraftBukkit - if (iblockdata.get(BigDripleafBlock.TILT) != Tilt.NONE) { - a(world, blockposition, SoundEffects.BIG_DRIPLEAF_TILT_UP); + private static void resetTilt(IBlockData iblockdata, World world, BlockPosition blockposition) { +- setTilt(iblockdata, world, blockposition, Tilt.NONE); ++ setTilt(iblockdata, world, blockposition, Tilt.NONE, null); // CraftBukkit + if (iblockdata.getValue(BigDripleafBlock.TILT) != Tilt.NONE) { + playTiltSound(world, blockposition, SoundEffects.BIG_DRIPLEAF_TILT_UP); } } -- private static void a(IBlockData iblockdata, World world, BlockPosition blockposition, Tilt tilt) { +- private static void setTilt(IBlockData iblockdata, World world, BlockPosition blockposition, Tilt tilt) { + // CraftBukkit start -+ private static boolean a(IBlockData iblockdata, World world, BlockPosition blockposition, Tilt tilt, @Nullable Entity entity) { ++ private static boolean setTilt(IBlockData iblockdata, World world, BlockPosition blockposition, Tilt tilt, @Nullable Entity entity) { + if (entity != null) { -+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.set(BigDripleafBlock.TILT, tilt)).isCancelled()) { ++ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.setValue(BigDripleafBlock.TILT, tilt)).isCancelled()) { + return false; + } + } + // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BigDripleafBlock.TILT, tilt), 2); - if (tilt.a()) { - world.a(GameEvent.BLOCK_CHANGE, blockposition); + world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BigDripleafBlock.TILT, tilt), 2); + if (tilt.causesVibration()) { + world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition); } + return true; // CraftBukkit diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/Block.patch b/paper-server/nms-patches/net/minecraft/world/level/block/Block.patch index 0efaaccbb2..f760444853 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/Block.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/Block.patch @@ -1,31 +1,31 @@ --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -354,7 +354,13 @@ +@@ -352,7 +352,13 @@ EntityItem entityitem = (EntityItem) supplier.get(); - entityitem.defaultPickupDelay(); -- world.addEntity(entityitem); + entityitem.setDefaultPickUpDelay(); +- world.addFreshEntity(entityitem); + // CraftBukkit start + if (world.captureDrops != null) { + world.captureDrops.add(entityitem); + } else { -+ world.addEntity(entityitem); ++ world.addFreshEntity(entityitem); + } + // CraftBukkit end } } -@@ -380,7 +386,7 @@ +@@ -378,7 +384,7 @@ - public void a(World world, EntityHuman entityhuman, BlockPosition blockposition, IBlockData iblockdata, @Nullable TileEntity tileentity, ItemStack itemstack) { - entityhuman.b(StatisticList.BLOCK_MINED.b(this)); -- entityhuman.applyExhaustion(0.005F); -+ entityhuman.applyExhaustion(0.005F, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.BLOCK_MINED); // CraftBukkit - EntityExhaustionEvent - dropItems(iblockdata, world, blockposition, tileentity, entityhuman, itemstack); + public void playerDestroy(World world, EntityHuman entityhuman, BlockPosition blockposition, IBlockData iblockdata, @Nullable TileEntity tileentity, ItemStack itemstack) { + entityhuman.awardStat(StatisticList.BLOCK_MINED.get(this)); +- entityhuman.causeFoodExhaustion(0.005F); ++ entityhuman.causeFoodExhaustion(0.005F, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.BLOCK_MINED); // CraftBukkit - EntityExhaustionEvent + dropResources(iblockdata, world, blockposition, tileentity, entityhuman, itemstack); } -@@ -514,6 +520,12 @@ - return (ImmutableMap) this.stateDefinition.a().stream().collect(ImmutableMap.toImmutableMap(Function.identity(), function)); +@@ -512,6 +518,12 @@ + return (ImmutableMap) this.stateDefinition.getPossibleStates().stream().collect(ImmutableMap.toImmutableMap(Function.identity(), function)); } + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch index ca745f8e2c..5a707985bb 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch @@ -1,48 +1,48 @@ --- a/net/minecraft/world/level/block/BlockBamboo.java +++ b/net/minecraft/world/level/block/BlockBamboo.java -@@ -187,7 +187,7 @@ - BlockPosition blockposition1 = blockposition.up(i); - IBlockData iblockdata1 = worldserver.getType(blockposition1); +@@ -186,7 +186,7 @@ + BlockPosition blockposition1 = blockposition.above(i); + IBlockData iblockdata1 = worldserver.getBlockState(blockposition1); -- if (k >= 16 || (Integer) iblockdata1.get(BlockBamboo.STAGE) == 1 || !worldserver.isEmpty(blockposition1.up())) { -+ if (k >= 16 || !iblockdata1.a(Blocks.BAMBOO) || (Integer) iblockdata1.get(BlockBamboo.STAGE) == 1 || !worldserver.isEmpty(blockposition1.up())) { // CraftBukkit - If the BlockSpreadEvent was cancelled, we have no bamboo here +- if (k >= 16 || (Integer) iblockdata1.getValue(BlockBamboo.STAGE) == 1 || !worldserver.isEmptyBlock(blockposition1.above())) { ++ if (k >= 16 || !iblockdata1.is(Blocks.BAMBOO) || (Integer) iblockdata1.getValue(BlockBamboo.STAGE) == 1 || !worldserver.isEmptyBlock(blockposition1.above())) { // CraftBukkit - If the BlockSpreadEvent was cancelled, we have no bamboo here return; } -@@ -208,14 +208,18 @@ - BlockPosition blockposition1 = blockposition.down(2); - IBlockData iblockdata2 = world.getType(blockposition1); +@@ -207,14 +207,18 @@ + BlockPosition blockposition1 = blockposition.below(2); + IBlockData iblockdata2 = world.getBlockState(blockposition1); BlockPropertyBambooSize blockpropertybamboosize = BlockPropertyBambooSize.NONE; + boolean shouldUpdateOthers = false; // CraftBukkit if (i >= 1) { - if (iblockdata1.a(Blocks.BAMBOO) && iblockdata1.get(BlockBamboo.LEAVES) != BlockPropertyBambooSize.NONE) { - if (iblockdata1.a(Blocks.BAMBOO) && iblockdata1.get(BlockBamboo.LEAVES) != BlockPropertyBambooSize.NONE) { + if (iblockdata1.is(Blocks.BAMBOO) && iblockdata1.getValue(BlockBamboo.LEAVES) != BlockPropertyBambooSize.NONE) { + if (iblockdata1.is(Blocks.BAMBOO) && iblockdata1.getValue(BlockBamboo.LEAVES) != BlockPropertyBambooSize.NONE) { blockpropertybamboosize = BlockPropertyBambooSize.LARGE; - if (iblockdata2.a(Blocks.BAMBOO)) { -- world.setTypeAndData(blockposition.down(), (IBlockData) iblockdata1.set(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3); -- world.setTypeAndData(blockposition1, (IBlockData) iblockdata2.set(BlockBamboo.LEAVES, BlockPropertyBambooSize.NONE), 3); + if (iblockdata2.is(Blocks.BAMBOO)) { +- world.setBlock(blockposition.below(), (IBlockData) iblockdata1.setValue(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3); +- world.setBlock(blockposition1, (IBlockData) iblockdata2.setValue(BlockBamboo.LEAVES, BlockPropertyBambooSize.NONE), 3); + // CraftBukkit start - moved down -+ // world.setTypeAndData(blockposition.down(), (IBlockData) iblockdata1.set(BlockBamboo.e, BlockPropertyBambooSize.SMALL), 3); -+ // world.setTypeAndData(blockposition1, (IBlockData) iblockdata2.set(BlockBamboo.e, BlockPropertyBambooSize.NONE), 3); ++ // world.setBlock(blockposition.below(), (IBlockData) iblockdata1.setValue(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3); ++ // world.setBlock(blockposition1, (IBlockData) iblockdata2.setValue(BlockBamboo.LEAVES, BlockPropertyBambooSize.NONE), 3); + shouldUpdateOthers = true; + // CraftBukkit end } } } else { -@@ -226,7 +230,14 @@ - int j = (Integer) iblockdata.get(BlockBamboo.AGE) != 1 && !iblockdata2.a(Blocks.BAMBOO) ? 0 : 1; +@@ -225,7 +229,14 @@ + int j = (Integer) iblockdata.getValue(BlockBamboo.AGE) != 1 && !iblockdata2.is(Blocks.BAMBOO) ? 0 : 1; int k = (i < 11 || random.nextFloat() >= 0.25F) && i != 15 ? 0 : 1; -- world.setTypeAndData(blockposition.up(), (IBlockData) ((IBlockData) ((IBlockData) this.getBlockData().set(BlockBamboo.AGE, j)).set(BlockBamboo.LEAVES, blockpropertybamboosize)).set(BlockBamboo.STAGE, k), 3); +- world.setBlock(blockposition.above(), (IBlockData) ((IBlockData) ((IBlockData) this.defaultBlockState().setValue(BlockBamboo.AGE, j)).setValue(BlockBamboo.LEAVES, blockpropertybamboosize)).setValue(BlockBamboo.STAGE, k), 3); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition.up(), (IBlockData) ((IBlockData) ((IBlockData) this.getBlockData().set(BlockBamboo.AGE, j)).set(BlockBamboo.LEAVES, blockpropertybamboosize)).set(BlockBamboo.STAGE, k), 3)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition.above(), (IBlockData) ((IBlockData) ((IBlockData) this.defaultBlockState().setValue(BlockBamboo.AGE, j)).setValue(BlockBamboo.LEAVES, blockpropertybamboosize)).setValue(BlockBamboo.STAGE, k), 3)) { + if (shouldUpdateOthers) { -+ world.setTypeAndData(blockposition.down(), (IBlockData) iblockdata1.set(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3); -+ world.setTypeAndData(blockposition1, (IBlockData) iblockdata2.set(BlockBamboo.LEAVES, BlockPropertyBambooSize.NONE), 3); ++ world.setBlock(blockposition.below(), (IBlockData) iblockdata1.setValue(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3); ++ world.setBlock(blockposition1, (IBlockData) iblockdata2.setValue(BlockBamboo.LEAVES, BlockPropertyBambooSize.NONE), 3); + } + } + // CraftBukkit end } - protected int a(IBlockAccess iblockaccess, BlockPosition blockposition) { + protected int getHeightAboveUpToMax(IBlockAccess iblockaccess, BlockPosition blockposition) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch index 47d27d7893..22b991b815 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch @@ -3,8 +3,8 @@ @@ -94,6 +94,6 @@ } - protected void a(World world, BlockPosition blockposition) { -- world.setTypeAndData(blockposition.up(), (IBlockData) Blocks.BAMBOO.getBlockData().set(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition.up(), (IBlockData) Blocks.BAMBOO.getBlockData().set(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3); // CraftBukkit - BlockSpreadEvent + protected void growBamboo(World world, BlockPosition blockposition) { +- world.setBlock(blockposition.above(), (IBlockData) Blocks.BAMBOO.defaultBlockState().setValue(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition.above(), (IBlockData) Blocks.BAMBOO.defaultBlockState().setValue(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3); // CraftBukkit - BlockSpreadEvent } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockBed.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockBed.patch index a4a50590a8..8fd2292598 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockBed.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockBed.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/level/block/BlockBed.java +++ b/net/minecraft/world/level/block/BlockBed.java -@@ -88,7 +88,8 @@ +@@ -87,7 +87,8 @@ } } -- if (!a(world)) { +- if (!canSetSpawn(world)) { + // CraftBukkit - moved world and biome check into EntityHuman -+ if (false && !a(world)) { - world.a(blockposition, false); - BlockPosition blockposition1 = blockposition.shift(((EnumDirection) iblockdata.get(BlockBed.FACING)).opposite()); ++ if (false && !canSetSpawn(world)) { + world.removeBlock(blockposition, false); + BlockPosition blockposition1 = blockposition.relative(((EnumDirection) iblockdata.getValue(BlockBed.FACING)).getOpposite()); -@@ -105,7 +106,16 @@ +@@ -104,7 +105,16 @@ return EnumInteractionResult.SUCCESS; } else { @@ -18,16 +18,16 @@ + IBlockData finaliblockdata = iblockdata; + BlockPosition finalblockposition = blockposition; + // CraftBukkit end - entityhuman.sleep(blockposition).ifLeft((entityhuman_enumbedresult) -> { + entityhuman.startSleepInBed(blockposition).ifLeft((entityhuman_enumbedresult) -> { + // CraftBukkit start - handling bed explosion from below here -+ if (!world.getDimensionManager().isBedWorks()) { ++ if (!world.dimensionType().bedWorks()) { + this.explodeBed(finaliblockdata, world, finalblockposition); + } else + // CraftBukkit end if (entityhuman_enumbedresult != null) { - entityhuman.a(entityhuman_enumbedresult.a(), true); + entityhuman.displayClientMessage(entityhuman_enumbedresult.getMessage(), true); } -@@ -116,8 +126,27 @@ +@@ -115,8 +125,27 @@ } } @@ -35,24 +35,24 @@ + private EnumInteractionResult explodeBed(IBlockData iblockdata, World world, BlockPosition blockposition) { + { + { -+ world.a(blockposition, false); -+ BlockPosition blockposition1 = blockposition.shift(((EnumDirection) iblockdata.get(BlockBed.FACING)).opposite()); ++ world.removeBlock(blockposition, false); ++ BlockPosition blockposition1 = blockposition.relative(((EnumDirection) iblockdata.getValue(BlockBed.FACING)).getOpposite()); + -+ if (world.getType(blockposition1).getBlock() == this) { -+ world.a(blockposition1, false); ++ if (world.getBlockState(blockposition1).getBlock() == this) { ++ world.removeBlock(blockposition1, false); + } + -+ world.createExplosion((Entity) null, DamageSource.a(), (ExplosionDamageCalculator) null, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, 5.0F, true, Explosion.Effect.DESTROY); ++ world.explode((Entity) null, DamageSource.badRespawnPointExplosion(), (ExplosionDamageCalculator) null, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, 5.0F, true, Explosion.Effect.DESTROY); + return EnumInteractionResult.SUCCESS; + } + } + } + // CraftBukkit end + - public static boolean a(World world) { -- return world.getDimensionManager().isBedWorks(); + public static boolean canSetSpawn(World world) { +- return world.dimensionType().bedWorks(); + // CraftBukkit - moved world and biome check into EntityHuman -+ return true || world.getDimensionManager().isBedWorks(); ++ return true || world.dimensionType().bedWorks(); } - private boolean a(World world, BlockPosition blockposition) { + private boolean kickVillagerOutOfBed(World world, BlockPosition blockposition) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch index 070ca59313..d49ecbe864 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch @@ -3,9 +3,9 @@ @@ -108,7 +108,7 @@ EntityBee entitybee = (EntityBee) iterator.next(); - if (entitybee.getGoalTarget() == null) { -- entitybee.setGoalTarget((EntityLiving) list1.get(world.random.nextInt(i))); -+ entitybee.setGoalTarget((EntityLiving) list1.get(world.random.nextInt(i)), org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit + if (entitybee.getTarget() == null) { +- entitybee.setTarget((EntityLiving) list1.get(world.random.nextInt(i))); ++ entitybee.setTarget((EntityLiving) list1.get(world.random.nextInt(i)), org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit } } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch index 73e561b64c..ed2a8242f6 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch @@ -13,11 +13,11 @@ public static final BlockStateBoolean POWERED = BlockProperties.POWERED; @@ -97,6 +102,19 @@ - if ((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)) { + if ((Boolean) iblockdata.getValue(BlockButtonAbstract.POWERED)) { return EnumInteractionResult.CONSUME; } else { + // CraftBukkit start -+ boolean powered = ((Boolean) iblockdata.get(POWERED)); ++ boolean powered = ((Boolean) iblockdata.getValue(POWERED)); + org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + int old = (powered) ? 15 : 0; + int current = (!powered) ? 15 : 0; @@ -29,12 +29,12 @@ + return EnumInteractionResult.SUCCESS; + } + // CraftBukkit end - this.d(iblockdata, world, blockposition); - this.a(entityhuman, world, blockposition, true); - world.a((Entity) entityhuman, GameEvent.BLOCK_PRESS, blockposition); + this.press(iblockdata, world, blockposition); + this.playSound(entityhuman, world, blockposition, true); + world.gameEvent(entityhuman, GameEvent.BLOCK_PRESS, blockposition); @@ -148,6 +166,16 @@ if (this.sensitive) { - this.e(iblockdata, worldserver, blockposition); + this.checkPressed(iblockdata, worldserver, blockposition); } else { + // CraftBukkit start + org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); @@ -46,12 +46,12 @@ + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, false), 3); - this.f(iblockdata, (World) worldserver, blockposition); - this.a((EntityHuman) null, worldserver, blockposition, false); + worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockButtonAbstract.POWERED, false), 3); + this.updateNeighbours(iblockdata, worldserver, blockposition); + this.playSound((EntityHuman) null, worldserver, blockposition, false); @@ -169,11 +197,48 @@ boolean flag = !list.isEmpty(); - boolean flag1 = (Boolean) iblockdata.get(BlockButtonAbstract.POWERED); + boolean flag1 = (Boolean) iblockdata.getValue(BlockButtonAbstract.POWERED); + // CraftBukkit start - Call interact event when arrows turn on wooden buttons + if (flag1 != flag && flag) { @@ -91,11 +91,11 @@ + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, flag), 3); - this.f(iblockdata, world, blockposition); - this.a((EntityHuman) null, world, blockposition, flag); -- world.a((Entity) list.stream().findFirst().orElse((Object) null), flag ? GameEvent.BLOCK_PRESS : GameEvent.BLOCK_UNPRESS, blockposition); -+ world.a((Entity) list.stream().findFirst().orElse(null), flag ? GameEvent.BLOCK_PRESS : GameEvent.BLOCK_UNPRESS, blockposition); // CraftBukkit - decompile error + world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockButtonAbstract.POWERED, flag), 3); + this.updateNeighbours(iblockdata, world, blockposition); + this.playSound((EntityHuman) null, world, blockposition, flag); +- world.gameEvent((Entity) list.stream().findFirst().orElse((Object) null), flag ? GameEvent.BLOCK_PRESS : GameEvent.BLOCK_UNPRESS, blockposition); ++ world.gameEvent((Entity) list.stream().findFirst().orElse(null), flag ? GameEvent.BLOCK_PRESS : GameEvent.BLOCK_UNPRESS, blockposition); // CraftBukkit - decompile error } if (flag) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCactus.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCactus.patch index 438b7c85a0..17fe431e80 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCactus.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCactus.patch @@ -10,20 +10,20 @@ public static final BlockStateInteger AGE = BlockProperties.AGE_15; @@ -59,7 +61,7 @@ - int j = (Integer) iblockdata.get(BlockCactus.AGE); + int j = (Integer) iblockdata.getValue(BlockCactus.AGE); if (j == 15) { -- worldserver.setTypeUpdate(blockposition1, this.getBlockData()); -+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, this.getBlockData()); // CraftBukkit - IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockCactus.AGE, 0); +- worldserver.setBlockAndUpdate(blockposition1, this.defaultBlockState()); ++ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, this.defaultBlockState()); // CraftBukkit + IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockCactus.AGE, 0); - worldserver.setTypeAndData(blockposition, iblockdata1, 4); + worldserver.setBlock(blockposition, iblockdata1, 4); @@ -116,7 +118,9 @@ @Override - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + CraftEventFactory.blockDamage = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit - entity.damageEntity(DamageSource.CACTUS, 1.0F); + entity.hurt(DamageSource.CACTUS, 1.0F); + CraftEventFactory.blockDamage = null; // CraftBukkit } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCake.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCake.patch index 06b762173a..c3c9b80ed3 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCake.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCake.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/BlockCake.java +++ b/net/minecraft/world/level/block/BlockCake.java -@@ -86,7 +86,18 @@ +@@ -85,7 +85,18 @@ return EnumInteractionResult.PASS; } else { - entityhuman.a(StatisticList.EAT_CAKE_SLICE); + entityhuman.awardStat(StatisticList.EAT_CAKE_SLICE); - entityhuman.getFoodData().eat(2, 0.1F); + // CraftBukkit start + // entityhuman.getFoodData().eat(2, 0.1F); @@ -17,6 +17,6 @@ + + ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().sendHealthUpdate(); + // CraftBukkit end - int i = (Integer) iblockdata.get(BlockCake.BITES); + int i = (Integer) iblockdata.getValue(BlockCake.BITES); - generatoraccess.a((Entity) entityhuman, GameEvent.EAT, blockposition); + generatoraccess.gameEvent(entityhuman, GameEvent.EAT, blockposition); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch index 33dcd56f96..96604d4bef 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch @@ -10,26 +10,26 @@ + public class BlockCampfire extends BlockTileEntity implements IBlockWaterlogged { - protected static final VoxelShape SHAPE = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 7.0D, 16.0D); + protected static final VoxelShape SHAPE = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 7.0D, 16.0D); @@ -92,7 +96,9 @@ @Override - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { - if (!entity.isFireProof() && (Boolean) iblockdata.get(BlockCampfire.LIT) && entity instanceof EntityLiving && !EnchantmentManager.i((EntityLiving) entity)) { + public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + if (!entity.fireImmune() && (Boolean) iblockdata.getValue(BlockCampfire.LIT) && entity instanceof EntityLiving && !EnchantmentManager.hasFrostWalker((EntityLiving) entity)) { + org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); // CraftBukkit - entity.damageEntity(DamageSource.IN_FIRE, (float) this.fireDamage); + entity.hurt(DamageSource.IN_FIRE, (float) this.fireDamage); + org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = null; // CraftBukkit } - super.a(iblockdata, world, blockposition, entity); + super.entityInside(iblockdata, world, blockposition, entity); @@ -202,6 +208,11 @@ - BlockPosition blockposition = movingobjectpositionblock.getBlockPosition(); + BlockPosition blockposition = movingobjectpositionblock.getBlockPos(); - if (!world.isClientSide && iprojectile.isBurning() && iprojectile.a(world, blockposition) && !(Boolean) iblockdata.get(BlockCampfire.LIT) && !(Boolean) iblockdata.get(BlockCampfire.WATERLOGGED)) { + if (!world.isClientSide && iprojectile.isOnFire() && iprojectile.mayInteract(world, blockposition) && !(Boolean) iblockdata.getValue(BlockCampfire.LIT) && !(Boolean) iblockdata.getValue(BlockCampfire.WATERLOGGED)) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, iprojectile).isCancelled()) { + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockProperties.LIT, true), 11); + world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockProperties.LIT, true), 11); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCauldron.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCauldron.patch index fdb95b71bf..86d6731b01 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCauldron.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCauldron.patch @@ -13,15 +13,15 @@ private static final float RAIN_FILL_CHANCE = 0.05F; @@ -51,11 +55,11 @@ @Override - protected void a(IBlockData iblockdata, World world, BlockPosition blockposition, FluidType fluidtype) { + protected void receiveStalactiteDrip(IBlockData iblockdata, World world, BlockPosition blockposition, FluidType fluidtype) { if (fluidtype == FluidTypes.WATER) { -- world.setTypeUpdate(blockposition, Blocks.WATER_CAULDRON.getBlockData()); -+ LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.WATER_CAULDRON.getBlockData(), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit - world.triggerEffect(1047, blockposition, 0); - world.a((Entity) null, GameEvent.FLUID_PLACE, blockposition); +- world.setBlockAndUpdate(blockposition, Blocks.WATER_CAULDRON.defaultBlockState()); ++ LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.WATER_CAULDRON.defaultBlockState(), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit + world.levelEvent(1047, blockposition, 0); + world.gameEvent((Entity) null, GameEvent.FLUID_PLACE, blockposition); } else if (fluidtype == FluidTypes.LAVA) { -- world.setTypeUpdate(blockposition, Blocks.LAVA_CAULDRON.getBlockData()); -+ LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.LAVA_CAULDRON.getBlockData(), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit - world.triggerEffect(1046, blockposition, 0); - world.a((Entity) null, GameEvent.FLUID_PLACE, blockposition); +- world.setBlockAndUpdate(blockposition, Blocks.LAVA_CAULDRON.defaultBlockState()); ++ LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.LAVA_CAULDRON.defaultBlockState(), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit + world.levelEvent(1046, blockposition, 0); + world.gameEvent((Entity) null, GameEvent.FLUID_PLACE, blockposition); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockChest.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockChest.patch index 7b906c105d..c30893cb19 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockChest.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockChest.patch @@ -1,31 +1,31 @@ --- a/net/minecraft/world/level/block/BlockChest.java +++ b/net/minecraft/world/level/block/BlockChest.java @@ -88,24 +88,7 @@ - public Optional<ITileInventory> a(final TileEntityChest tileentitychest, final TileEntityChest tileentitychest1) { + public Optional<ITileInventory> acceptDouble(final TileEntityChest tileentitychest, final TileEntityChest tileentitychest1) { final InventoryLargeChest inventorylargechest = new InventoryLargeChest(tileentitychest, tileentitychest1); - return Optional.of(new ITileInventory() { - @Nullable - @Override - public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) { -- if (tileentitychest.d(entityhuman) && tileentitychest1.d(entityhuman)) { -- tileentitychest.e(playerinventory.player); -- tileentitychest1.e(playerinventory.player); -- return ContainerChest.b(i, playerinventory, (IInventory) inventorylargechest); +- if (tileentitychest.canOpen(entityhuman) && tileentitychest1.canOpen(entityhuman)) { +- tileentitychest.unpackLootTable(playerinventory.player); +- tileentitychest1.unpackLootTable(playerinventory.player); +- return ContainerChest.sixRows(i, playerinventory, inventorylargechest); - } else { - return null; - } - } - - @Override -- public IChatBaseComponent getScoreboardDisplayName() { -- return (IChatBaseComponent) (tileentitychest.hasCustomName() ? tileentitychest.getScoreboardDisplayName() : (tileentitychest1.hasCustomName() ? tileentitychest1.getScoreboardDisplayName() : new ChatMessage("container.chestDouble"))); +- public IChatBaseComponent getDisplayName() { +- return (IChatBaseComponent) (tileentitychest.hasCustomName() ? tileentitychest.getDisplayName() : (tileentitychest1.hasCustomName() ? tileentitychest1.getDisplayName() : new ChatMessage("container.chestDouble"))); - } - }); + return Optional.of(new DoubleInventory(tileentitychest, tileentitychest1, inventorylargechest)); // CraftBukkit } - public Optional<ITileInventory> a(TileEntityChest tileentitychest) { + public Optional<ITileInventory> acceptSingle(TileEntityChest tileentitychest) { @@ -118,6 +101,38 @@ } }; @@ -46,29 +46,29 @@ + @Nullable + @Override + public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) { -+ if (tileentitychest.d(entityhuman) && tileentitychest1.d(entityhuman)) { -+ tileentitychest.e(playerinventory.player); -+ tileentitychest1.e(playerinventory.player); -+ return ContainerChest.b(i, playerinventory, (IInventory) inventorylargechest); ++ if (tileentitychest.canOpen(entityhuman) && tileentitychest1.canOpen(entityhuman)) { ++ tileentitychest.unpackLootTable(playerinventory.player); ++ tileentitychest1.unpackLootTable(playerinventory.player); ++ return ContainerChest.sixRows(i, playerinventory, inventorylargechest); + } else { + return null; + } + } + + @Override -+ public IChatBaseComponent getScoreboardDisplayName() { -+ return (IChatBaseComponent) (tileentitychest.hasCustomName() ? tileentitychest.getScoreboardDisplayName() : (tileentitychest1.hasCustomName() ? tileentitychest1.getScoreboardDisplayName() : new ChatMessage("container.chestDouble"))); ++ public IChatBaseComponent getDisplayName() { ++ return (IChatBaseComponent) (tileentitychest.hasCustomName() ? tileentitychest.getDisplayName() : (tileentitychest1.hasCustomName() ? tileentitychest1.getDisplayName() : new ChatMessage("container.chestDouble"))); + } + }; + // CraftBukkit end + protected BlockChest(BlockBase.Info blockbase_info, Supplier<TileEntityTypes<? extends TileEntityChest>> supplier) { super(blockbase_info, supplier); - this.k((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.getBlockData()).set(BlockChest.FACING, EnumDirection.NORTH)).set(BlockChest.TYPE, BlockPropertyChestType.SINGLE)).set(BlockChest.WATERLOGGED, false)); + this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(BlockChest.FACING, EnumDirection.NORTH)).setValue(BlockChest.TYPE, BlockPropertyChestType.SINGLE)).setValue(BlockChest.WATERLOGGED, false)); @@ -276,7 +291,7 @@ @Override - public DoubleBlockFinder.Result<? extends TileEntityChest> a(IBlockData iblockdata, World world, BlockPosition blockposition, boolean flag) { + public DoubleBlockFinder.Result<? extends TileEntityChest> combine(IBlockData iblockdata, World world, BlockPosition blockposition, boolean flag) { - BiPredicate bipredicate; + BiPredicate<GeneratorAccess, BlockPosition> bipredicate; // CraftBukkit - decompile error @@ -77,16 +77,16 @@ @@ -292,7 +307,14 @@ @Nullable @Override - public ITileInventory getInventory(IBlockData iblockdata, World world, BlockPosition blockposition) { -- return (ITileInventory) ((Optional) this.a(iblockdata, world, blockposition, false).apply(BlockChest.MENU_PROVIDER_COMBINER)).orElse((Object) null); + public ITileInventory getMenuProvider(IBlockData iblockdata, World world, BlockPosition blockposition) { +- return (ITileInventory) ((Optional) this.combine(iblockdata, world, blockposition, false).apply(BlockChest.MENU_PROVIDER_COMBINER)).orElse((Object) null); + // CraftBukkit start -+ return getInventory(iblockdata, world, blockposition, false); ++ return getMenuProvider(iblockdata, world, blockposition, false); + } + + @Nullable -+ public ITileInventory getInventory(IBlockData iblockdata, World world, BlockPosition blockposition, boolean ignoreObstructions) { -+ return (ITileInventory) ((Optional) this.a(iblockdata, world, blockposition, ignoreObstructions).apply(BlockChest.MENU_PROVIDER_COMBINER)).orElse((Object) null); ++ public ITileInventory getMenuProvider(IBlockData iblockdata, World world, BlockPosition blockposition, boolean ignoreObstructions) { ++ return (ITileInventory) ((Optional) this.combine(iblockdata, world, blockposition, ignoreObstructions).apply(BlockChest.MENU_PROVIDER_COMBINER)).orElse((Object) null); + // CraftBukkit end } - public static DoubleBlockFinder.Combiner<TileEntityChest, Float2FloatFunction> a(final LidBlockEntity lidblockentity) { + public static DoubleBlockFinder.Combiner<TileEntityChest, Float2FloatFunction> opennessCombiner(final LidBlockEntity lidblockentity) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockChorusFlower.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockChorusFlower.patch index 450efd8ffe..5cbbfb3bf3 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockChorusFlower.patch +++ b/paper-server/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 -@@ -20,6 +20,8 @@ +@@ -18,6 +18,8 @@ import net.minecraft.world.level.block.state.properties.BlockStateInteger; import net.minecraft.world.phys.MovingObjectPositionBlock; @@ -9,30 +9,30 @@ public class BlockChorusFlower extends Block { public static final int DEAD_AGE = 5; -@@ -84,8 +86,12 @@ +@@ -82,8 +84,12 @@ } - if (flag && b((IWorldReader) worldserver, blockposition1, (EnumDirection) null) && worldserver.isEmpty(blockposition.up(2))) { -- worldserver.setTypeAndData(blockposition, this.plant.a((IBlockAccess) worldserver, blockposition), 2); -- this.a(worldserver, blockposition1, i); + if (flag && allNeighborsEmpty(worldserver, blockposition1, (EnumDirection) null) && worldserver.isEmptyBlock(blockposition.above(2))) { +- worldserver.setBlock(blockposition, this.plant.getStateForPlacement(worldserver, blockposition), 2); +- this.placeGrownFlower(worldserver, blockposition1, i); + // CraftBukkit start - add event -+ if (CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i)), 2)) { -+ worldserver.setTypeAndData(blockposition, this.plant.a((IBlockAccess) worldserver, blockposition), 2); -+ this.a(worldserver, blockposition1, i); ++ if (CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, this.defaultBlockState().setValue(BlockChorusFlower.AGE, Integer.valueOf(i)), 2)) { ++ worldserver.setBlock(blockposition, this.plant.getStateForPlacement(worldserver, blockposition), 2); ++ this.placeGrownFlower(worldserver, blockposition1, i); + } + // CraftBukkit end } else if (i < 4) { j = random.nextInt(4); if (flag1) { -@@ -99,18 +105,30 @@ - BlockPosition blockposition2 = blockposition.shift(enumdirection); +@@ -97,18 +103,30 @@ + BlockPosition blockposition2 = blockposition.relative(enumdirection); - if (worldserver.isEmpty(blockposition2) && worldserver.isEmpty(blockposition2.down()) && b((IWorldReader) worldserver, blockposition2, enumdirection.opposite())) { -- this.a(worldserver, blockposition2, i + 1); + if (worldserver.isEmptyBlock(blockposition2) && worldserver.isEmptyBlock(blockposition2.below()) && allNeighborsEmpty(worldserver, blockposition2, enumdirection.getOpposite())) { +- this.placeGrownFlower(worldserver, blockposition2, i + 1); - flag2 = true; + // CraftBukkit start - add event -+ if (CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition2, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i + 1)), 2)) { -+ this.a(worldserver, blockposition2, i + 1); ++ if (CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition2, this.defaultBlockState().setValue(BlockChorusFlower.AGE, Integer.valueOf(i + 1)), 2)) { ++ this.placeGrownFlower(worldserver, blockposition2, i + 1); + flag2 = true; + } + // CraftBukkit end @@ -40,20 +40,20 @@ } if (flag2) { - worldserver.setTypeAndData(blockposition, this.plant.a((IBlockAccess) worldserver, blockposition), 2); + worldserver.setBlock(blockposition, this.plant.getStateForPlacement(worldserver, blockposition), 2); } else { -- this.a((World) worldserver, blockposition); +- this.placeDeadFlower(worldserver, blockposition); + // CraftBukkit - add event -+ if (CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(5)), 2)) { -+ this.a((World) worldserver, blockposition); ++ if (CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, this.defaultBlockState().setValue(BlockChorusFlower.AGE, Integer.valueOf(5)), 2)) { ++ this.placeDeadFlower(worldserver, blockposition); + } + // CraftBukkit end } } else { -- this.a((World) worldserver, blockposition); +- this.placeDeadFlower(worldserver, blockposition); + // CraftBukkit - add event -+ if (CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(5)), 2)) { -+ this.a((World) worldserver, blockposition); ++ if (CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, this.defaultBlockState().setValue(BlockChorusFlower.AGE, Integer.valueOf(5)), 2)) { ++ this.placeDeadFlower(worldserver, blockposition); + } + // CraftBukkit end } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCocoa.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCocoa.patch index fc9fcce7dc..daa5401b80 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCocoa.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCocoa.patch @@ -10,20 +10,20 @@ public static final int MAX_AGE = 2; @@ -55,7 +57,7 @@ - int i = (Integer) iblockdata.get(BlockCocoa.AGE); + int i = (Integer) iblockdata.getValue(BlockCocoa.AGE); if (i < 2) { -- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, i + 1), 2); -+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, i + 1), 2); // CraftBukkkit +- worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockCocoa.AGE, i + 1), 2); ++ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, (IBlockData) iblockdata.setValue(BlockCocoa.AGE, i + 1), 2); // CraftBukkkit } } @@ -125,7 +127,7 @@ @Override - public void a(WorldServer worldserver, Random random, BlockPosition blockposition, IBlockData iblockdata) { -- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, (Integer) iblockdata.get(BlockCocoa.AGE) + 1), 2); -+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, (Integer) iblockdata.get(BlockCocoa.AGE) + 1), 2); // CraftBukkit + public void performBonemeal(WorldServer worldserver, Random random, BlockPosition blockposition, IBlockData iblockdata) { +- worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockCocoa.AGE, (Integer) iblockdata.getValue(BlockCocoa.AGE) + 1), 2); ++ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, (IBlockData) iblockdata.setValue(BlockCocoa.AGE, (Integer) iblockdata.getValue(BlockCocoa.AGE) + 1), 2); // CraftBukkit } @Override diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCommand.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCommand.patch index 8b5d4cb66b..b432a5455b 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCommand.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCommand.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCommand.java +++ b/net/minecraft/world/level/block/BlockCommand.java -@@ -26,6 +26,8 @@ +@@ -27,6 +27,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -9,10 +9,10 @@ public class BlockCommand extends BlockTileEntity implements GameMasterBlock { private static final Logger LOGGER = LogManager.getLogger(); -@@ -56,6 +58,15 @@ +@@ -57,6 +59,15 @@ TileEntityCommand tileentitycommand = (TileEntityCommand) tileentity; - boolean flag1 = world.isBlockIndirectlyPowered(blockposition); - boolean flag2 = tileentitycommand.f(); + boolean flag1 = world.hasNeighborSignal(blockposition); + boolean flag2 = tileentitycommand.isPowered(); + // CraftBukkit start + org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + int old = flag2 ? 15 : 0; @@ -23,5 +23,5 @@ + flag1 = eventRedstone.getNewCurrent() > 0; + // CraftBukkit end - tileentitycommand.a(flag1); - if (!flag2 && !tileentitycommand.g() && tileentitycommand.t() != TileEntityCommand.Type.SEQUENCE) { + tileentitycommand.setPowered(flag1); + if (!flag2 && !tileentitycommand.isAutomatic() && tileentitycommand.getMode() != TileEntityCommand.Type.SEQUENCE) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockComposter.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockComposter.patch index d2c7eb2e00..fdd013ad86 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockComposter.patch +++ b/paper-server/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 -@@ -38,6 +38,12 @@ +@@ -37,6 +37,12 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -13,53 +13,44 @@ public class BlockComposter extends Block implements IInventoryHolder { public static final int READY = 8; -@@ -47,7 +53,7 @@ - public static final Object2FloatMap<IMaterial> COMPOSTABLES = new Object2FloatOpenHashMap(); - private static final int AABB_SIDE_THICKNESS = 2; - private static final VoxelShape OUTER_SHAPE = VoxelShapes.b(); -- private static final VoxelShape[] SHAPES = (VoxelShape[]) SystemUtils.a((Object) (new VoxelShape[9]), (avoxelshape) -> { -+ private static final VoxelShape[] SHAPES = (VoxelShape[]) SystemUtils.a((new VoxelShape[9]), (avoxelshape) -> { // CraftBukkit - decompile error - for (int i = 0; i < 8; ++i) { - avoxelshape[i] = VoxelShapes.a(BlockComposter.OUTER_SHAPE, Block.a(2.0D, (double) Math.max(2, 1 + i * 2), 2.0D, 14.0D, 16.0D, 14.0D), OperatorBoolean.ONLY_FIRST); - } -@@ -225,18 +231,25 @@ +@@ -224,18 +230,25 @@ - return EnumInteractionResult.a(world.isClientSide); + return EnumInteractionResult.sidedSuccess(world.isClientSide); } else if (i == 8) { -- d(iblockdata, world, blockposition); -+ d(iblockdata, world, blockposition, (Entity) null); // CraftBukkit - no event for players - return EnumInteractionResult.a(world.isClientSide); +- extractProduce(iblockdata, world, blockposition); ++ extractProduce(iblockdata, world, blockposition, (Entity) null); // CraftBukkit - no event for players + return EnumInteractionResult.sidedSuccess(world.isClientSide); } else { return EnumInteractionResult.PASS; } } -- public static IBlockData a(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition) { -+ public static IBlockData a(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition, Entity entity) { // CraftBukkit - int i = (Integer) iblockdata.get(BlockComposter.LEVEL); +- public static IBlockData insertItem(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition) { ++ public static IBlockData insertItem(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition, Entity entity) { // CraftBukkit + int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL); if (i < 7 && BlockComposter.COMPOSTABLES.containsKey(itemstack.getItem())) { -- IBlockData iblockdata1 = a(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack); +- IBlockData iblockdata1 = addItem(iblockdata, worldserver, blockposition, itemstack); + // CraftBukkit start + double rand = worldserver.getRandom().nextDouble(); -+ IBlockData iblockdata1 = a(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack, rand); ++ IBlockData iblockdata1 = addItem(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack, rand); + if (iblockdata == iblockdata1 || org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) { + return iblockdata; + } -+ iblockdata1 = a(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack, rand); ++ iblockdata1 = addItem(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack, rand); + // CraftBukkit end - itemstack.subtract(1); + itemstack.shrink(1); return iblockdata1; -@@ -245,7 +258,15 @@ +@@ -244,7 +257,15 @@ } } -- public static IBlockData d(IBlockData iblockdata, World world, BlockPosition blockposition) { +- public static IBlockData extractProduce(IBlockData iblockdata, World world, BlockPosition blockposition) { + // CraftBukkit start -+ public static IBlockData d(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { ++ public static IBlockData extractProduce(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + if (entity != null) { -+ IBlockData iblockdata1 = c(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition); ++ IBlockData iblockdata1 = empty(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition); + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) { + return iblockdata; + } @@ -68,17 +59,17 @@ if (!world.isClientSide) { float f = 0.7F; double d0 = (double) (world.random.nextFloat() * 0.7F) + 0.15000000596046448D; -@@ -271,10 +292,16 @@ +@@ -270,10 +291,16 @@ } - static IBlockData a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) { + static IBlockData addItem(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) { + // CraftBukkit start -+ return a(iblockdata, generatoraccess, blockposition, itemstack, generatoraccess.getRandom().nextDouble()); ++ return addItem(iblockdata, generatoraccess, blockposition, itemstack, generatoraccess.getRandom().nextDouble()); + } + -+ static IBlockData a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack, double rand) { ++ static IBlockData addItem(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack, double rand) { + // CraftBukkit end - int i = (Integer) iblockdata.get(BlockComposter.LEVEL); + int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL); float f = BlockComposter.COMPOSTABLES.getFloat(itemstack.getItem()); - if ((i != 0 || f <= 0.0F) && generatoraccess.getRandom().nextDouble() >= (double) f) { @@ -86,9 +77,9 @@ return iblockdata; } else { int j = i + 1; -@@ -322,7 +349,8 @@ - public IWorldInventory a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { - int i = (Integer) iblockdata.get(BlockComposter.LEVEL); +@@ -321,7 +348,8 @@ + public IWorldInventory getContainer(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { + int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL); - 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())); + // CraftBukkit - empty generatoraccess, blockposition @@ -96,7 +87,7 @@ } public static class ContainerOutput extends InventorySubcontainer implements IWorldInventory { -@@ -337,6 +365,7 @@ +@@ -336,6 +364,7 @@ this.state = iblockdata; this.level = generatoraccess; this.pos = blockposition; @@ -104,25 +95,25 @@ } @Override -@@ -361,8 +390,15 @@ +@@ -360,8 +389,15 @@ @Override - public void update() { -- BlockComposter.c(this.state, this.level, this.pos); + public void setChanged() { +- BlockComposter.empty(this.state, this.level, this.pos); - this.changed = true; + // CraftBukkit start - allow putting items back (eg cancelled InventoryMoveItemEvent) + if (this.isEmpty()) { -+ BlockComposter.c(this.state, this.level, this.pos); ++ BlockComposter.empty(this.state, this.level, this.pos); + this.changed = true; + } else { -+ this.level.setTypeAndData(this.pos, this.state, 3); ++ this.level.setBlock(this.pos, this.state, 3); + this.changed = false; + } + // CraftBukkit end } } -@@ -375,6 +411,7 @@ +@@ -374,6 +410,7 @@ public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { super(1); @@ -130,7 +121,7 @@ this.state = iblockdata; this.level = generatoraccess; this.pos = blockposition; -@@ -417,8 +454,9 @@ +@@ -416,8 +453,9 @@ public static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch index 163789e6c4..5ee18686b3 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockConcretePowder.java +++ b/net/minecraft/world/level/block/BlockConcretePowder.java -@@ -13,6 +13,12 @@ +@@ -12,6 +12,12 @@ import net.minecraft.world.level.block.state.BlockBase; import net.minecraft.world.level.block.state.IBlockData; @@ -13,23 +13,23 @@ public class BlockConcretePowder extends BlockFalling { private final IBlockData concrete; -@@ -25,7 +31,7 @@ +@@ -24,7 +30,7 @@ @Override - public void a(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1, EntityFallingBlock entityfallingblock) { - if (canHarden(world, blockposition, iblockdata1)) { -- world.setTypeAndData(blockposition, this.concrete, 3); + public void onLand(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1, EntityFallingBlock entityfallingblock) { + if (shouldSolidify(world, blockposition, iblockdata1)) { +- world.setBlock(blockposition, this.concrete, 3); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.concrete, 3); // CraftBukkit } } -@@ -36,7 +42,24 @@ - BlockPosition blockposition = blockactioncontext.getClickPosition(); - IBlockData iblockdata = world.getType(blockposition); +@@ -35,7 +41,24 @@ + BlockPosition blockposition = blockactioncontext.getClickedPos(); + IBlockData iblockdata = world.getBlockState(blockposition); -- return canHarden(world, blockposition, iblockdata) ? this.concrete : super.getPlacedState(blockactioncontext); +- return shouldSolidify(world, blockposition, iblockdata) ? this.concrete : super.getStateForPlacement(blockactioncontext); + // CraftBukkit start -+ if (!canHarden(world, blockposition, iblockdata)) { -+ return super.getPlacedState(blockactioncontext); ++ if (!shouldSolidify(world, blockposition, iblockdata)) { ++ return super.getStateForPlacement(blockactioncontext); + } + + // TODO: An event factory call for methods like this @@ -37,24 +37,24 @@ + blockState.setData(this.concrete); + + BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState); -+ world.getMinecraftServer().server.getPluginManager().callEvent(event); ++ world.getServer().server.getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + return blockState.getHandle(); + } + -+ return super.getPlacedState(blockactioncontext); ++ return super.getStateForPlacement(blockactioncontext); + // CraftBukkit end } - private static boolean canHarden(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) { -@@ -72,7 +95,25 @@ + private static boolean shouldSolidify(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) { +@@ -71,7 +94,25 @@ @Override - public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { -- return a((IBlockAccess) generatoraccess, blockposition) ? this.concrete : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); + public IBlockData updateShape(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { +- return touchesLiquid(generatoraccess, blockposition) ? this.concrete : super.updateShape(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); + // CraftBukkit start -+ if (a((IBlockAccess) generatoraccess, blockposition)) { ++ if (touchesLiquid(generatoraccess, blockposition)) { + // Suppress during worldgen + if (!(generatoraccess instanceof World)) { + return this.concrete; @@ -70,7 +70,7 @@ + } + } + -+ return super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); ++ return super.updateShape(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); + // CraftBukkit end } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoral.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoral.patch index cfce2e65ee..0f7b10c3a9 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoral.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoral.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/world/level/block/BlockCoral.java @@ -26,6 +26,11 @@ @Override - public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - if (!this.a((IBlockAccess) worldserver, blockposition)) { + public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + if (!this.scanForWater(worldserver, blockposition)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.deadBlock.getBlockData()).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.deadBlock.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, this.deadBlock.getBlockData(), 2); + worldserver.setBlock(blockposition, this.deadBlock.defaultBlockState(), 2); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoralFan.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoralFan.patch index d2e4c6f947..9bdaeac9ff 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoralFan.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoralFan.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/world/level/block/BlockCoralFan.java @@ -28,6 +28,11 @@ @Override - public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - if (!e(iblockdata, worldserver, blockposition)) { + public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + if (!scanForWater(iblockdata, worldserver, blockposition)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.deadBlock.getBlockData().set(BlockCoralFan.WATERLOGGED, false)).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.deadBlock.defaultBlockState().setValue(BlockCoralFan.WATERLOGGED, false)).isCancelled()) { + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) this.deadBlock.getBlockData().set(BlockCoralFan.WATERLOGGED, false), 2); + worldserver.setBlock(blockposition, (IBlockData) this.deadBlock.defaultBlockState().setValue(BlockCoralFan.WATERLOGGED, false), 2); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoralFanWall.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoralFanWall.patch index da6718f887..29117601b0 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoralFanWall.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoralFanWall.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/world/level/block/BlockCoralFanWall.java @@ -28,6 +28,11 @@ @Override - public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - if (!e(iblockdata, worldserver, blockposition)) { + public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + if (!scanForWater(iblockdata, worldserver, blockposition)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.deadBlock.getBlockData().set(BlockCoralFanWall.WATERLOGGED, false).set(BlockCoralFanWall.FACING, iblockdata.get(BlockCoralFanWall.FACING))).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.deadBlock.defaultBlockState().setValue(BlockCoralFanWall.WATERLOGGED, false).setValue(BlockCoralFanWall.FACING, iblockdata.getValue(BlockCoralFanWall.FACING))).isCancelled()) { + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) ((IBlockData) this.deadBlock.getBlockData().set(BlockCoralFanWall.WATERLOGGED, false)).set(BlockCoralFanWall.FACING, (EnumDirection) iblockdata.get(BlockCoralFanWall.FACING)), 2); + worldserver.setBlock(blockposition, (IBlockData) ((IBlockData) this.deadBlock.defaultBlockState().setValue(BlockCoralFanWall.WATERLOGGED, false)).setValue(BlockCoralFanWall.FACING, (EnumDirection) iblockdata.getValue(BlockCoralFanWall.FACING)), 2); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoralPlant.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoralPlant.patch index 47b84ee9bb..08a08622a2 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoralPlant.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoralPlant.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/world/level/block/BlockCoralPlant.java @@ -33,6 +33,11 @@ @Override - public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - if (!e(iblockdata, worldserver, blockposition)) { + public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + if (!scanForWater(iblockdata, worldserver, blockposition)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.deadBlock.getBlockData().set(BlockCoralPlant.WATERLOGGED, false)).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.deadBlock.defaultBlockState().setValue(BlockCoralPlant.WATERLOGGED, false)).isCancelled()) { + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) this.deadBlock.getBlockData().set(BlockCoralPlant.WATERLOGGED, false), 2); + worldserver.setBlock(blockposition, (IBlockData) this.deadBlock.defaultBlockState().setValue(BlockCoralPlant.WATERLOGGED, false), 2); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCrops.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCrops.patch index 7ae016a7d3..787e97214f 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCrops.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCrops.patch @@ -10,11 +10,11 @@ public static final int MAX_AGE = 7; @@ -76,7 +78,7 @@ - float f = a((Block) this, (IBlockAccess) worldserver, blockposition); + float f = getGrowthSpeed(this, worldserver, blockposition); if (random.nextInt((int) (25.0F / f) + 1) == 0) { -- worldserver.setTypeAndData(blockposition, this.setAge(i + 1), 2); -+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, this.setAge(i + 1), 2); // CraftBukkit +- worldserver.setBlock(blockposition, this.getStateForAge(i + 1), 2); ++ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, this.getStateForAge(i + 1), 2); // CraftBukkit } } } @@ -22,17 +22,17 @@ i = j; } -- world.setTypeAndData(blockposition, this.setAge(i), 2); -+ CraftEventFactory.handleBlockGrowEvent(world, blockposition, this.setAge(i), 2); // CraftBukkit +- world.setBlock(blockposition, this.getStateForAge(i), 2); ++ CraftEventFactory.handleBlockGrowEvent(world, blockposition, this.getStateForAge(i), 2); // CraftBukkit } - protected int a(World world) { + protected int getBonemealAgeIncrease(World world) { @@ -149,7 +151,7 @@ @Override - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { - if (entity instanceof EntityRavager && world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (entity instanceof EntityRavager && !CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.getBlockData(), !world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) { // CraftBukkit - world.a(blockposition, true, entity); ++ if (entity instanceof EntityRavager && !CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.defaultBlockState(), !world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) { // CraftBukkit + world.destroyBlock(blockposition, true, entity); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDaylightDetector.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDaylightDetector.patch index a25715e102..77180af784 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDaylightDetector.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDaylightDetector.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/level/block/BlockDaylightDetector.java +++ b/net/minecraft/world/level/block/BlockDaylightDetector.java -@@ -67,6 +67,7 @@ +@@ -66,6 +66,7 @@ - i = MathHelper.clamp(i, 0, 15); - if ((Integer) iblockdata.get(BlockDaylightDetector.POWER) != i) { -+ i = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, blockposition, ((Integer) iblockdata.get(POWER)), i).getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDaylightDetector.POWER, i), 3); + i = MathHelper.clamp(i, (int) 0, (int) 15); + if ((Integer) iblockdata.getValue(BlockDaylightDetector.POWER) != i) { ++ i = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, blockposition, ((Integer) iblockdata.getValue(POWER)), i).getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent + world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockDaylightDetector.POWER, i), 3); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDiodeAbstract.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDiodeAbstract.patch index 43f6028646..1fd1f42a0d 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDiodeAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDiodeAbstract.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/level/block/BlockDiodeAbstract.java +++ b/net/minecraft/world/level/block/BlockDiodeAbstract.java -@@ -20,6 +20,8 @@ - import net.minecraft.world.phys.shapes.VoxelShape; +@@ -19,6 +19,8 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; + import net.minecraft.world.ticks.TickListPriority; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + public abstract class BlockDiodeAbstract extends BlockFacingHorizontal { - protected static final VoxelShape SHAPE = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D); -@@ -46,8 +48,18 @@ - boolean flag1 = this.a((World) worldserver, blockposition, iblockdata); + protected static final VoxelShape SHAPE = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D); +@@ -45,8 +47,18 @@ + boolean flag1 = this.shouldTurnOn(worldserver, blockposition, iblockdata); if (flag && !flag1) { + // CraftBukkit start @@ -18,13 +18,13 @@ + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.POWERED, false), 2); + worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockDiodeAbstract.POWERED, false), 2); } else if (!flag) { + // CraftBukkit start + if (CraftEventFactory.callRedstoneChange(worldserver, blockposition, 0, 15).getNewCurrent() != 15) { + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.POWERED, true), 2); + worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockDiodeAbstract.POWERED, true), 2); if (!flag1) { - worldserver.getBlockTickList().a(blockposition, this, this.g(iblockdata), TickListPriority.VERY_HIGH); + worldserver.scheduleTick(blockposition, (Block) this, this.getDelay(iblockdata), TickListPriority.VERY_HIGH); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDirtSnowSpreadable.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDirtSnowSpreadable.patch index 621967b805..0ab947f9ea 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDirtSnowSpreadable.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDirtSnowSpreadable.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/world/level/block/BlockDirtSnowSpreadable.java +++ b/net/minecraft/world/level/block/BlockDirtSnowSpreadable.java -@@ -42,6 +42,11 @@ +@@ -41,6 +41,11 @@ @Override - public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - if (!b(iblockdata, (IWorldReader) worldserver, blockposition)) { + public void randomTick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + if (!canBeGrass(iblockdata, worldserver, blockposition)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.DIRT.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - worldserver.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData()); + worldserver.setBlockAndUpdate(blockposition, Blocks.DIRT.defaultBlockState()); } else { - if (worldserver.getLightLevel(blockposition.up()) >= 9) { -@@ -51,7 +56,7 @@ - BlockPosition blockposition1 = blockposition.c(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1); + if (worldserver.getMaxLocalRawBrightness(blockposition.above()) >= 9) { +@@ -50,7 +55,7 @@ + BlockPosition blockposition1 = blockposition.offset(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1); - if (worldserver.getType(blockposition1).a(Blocks.DIRT) && c(iblockdata1, (IWorldReader) worldserver, blockposition1)) { -- worldserver.setTypeUpdate(blockposition1, (IBlockData) iblockdata1.set(BlockDirtSnowSpreadable.SNOWY, worldserver.getType(blockposition1.up()).a(Blocks.SNOW))); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, (IBlockData) iblockdata1.set(BlockDirtSnowSpreadable.SNOWY, worldserver.getType(blockposition1.up()).a(Blocks.SNOW))); // CraftBukkit + if (worldserver.getBlockState(blockposition1).is(Blocks.DIRT) && canPropagate(iblockdata1, worldserver, blockposition1)) { +- worldserver.setBlockAndUpdate(blockposition1, (IBlockData) iblockdata1.setValue(BlockDirtSnowSpreadable.SNOWY, worldserver.getBlockState(blockposition1.above()).is(Blocks.SNOW))); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, (IBlockData) iblockdata1.setValue(BlockDirtSnowSpreadable.SNOWY, worldserver.getBlockState(blockposition1.above()).is(Blocks.SNOW))); // CraftBukkit } } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDispenser.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDispenser.patch index 0036c4b9c3..30344ab7f0 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDispenser.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDispenser.patch @@ -1,20 +1,15 @@ --- a/net/minecraft/world/level/block/BlockDispenser.java +++ b/net/minecraft/world/level/block/BlockDispenser.java -@@ -41,10 +41,11 @@ - - public static final BlockStateDirection FACING = BlockDirectional.FACING; - public static final BlockStateBoolean TRIGGERED = BlockProperties.TRIGGERED; -- public static final Map<Item, IDispenseBehavior> DISPENSER_REGISTRY = (Map) SystemUtils.a((Object) (new Object2ObjectOpenHashMap()), (object2objectopenhashmap) -> { -+ public static final Map<Item, IDispenseBehavior> DISPENSER_REGISTRY = (Map) SystemUtils.a((new Object2ObjectOpenHashMap()), (object2objectopenhashmap) -> { // CraftBukkit - decompile error +@@ -46,6 +46,7 @@ object2objectopenhashmap.defaultReturnValue(new DispenseBehaviorItem()); }); private static final int TRIGGER_DURATION = 4; + public static boolean eventFired = false; // CraftBukkit - public static void a(IMaterial imaterial, IDispenseBehavior idispensebehavior) { - BlockDispenser.DISPENSER_REGISTRY.put(imaterial.getItem(), idispensebehavior); -@@ -88,6 +89,7 @@ - IDispenseBehavior idispensebehavior = this.a(itemstack); + public static void registerBehavior(IMaterial imaterial, IDispenseBehavior idispensebehavior) { + BlockDispenser.DISPENSER_REGISTRY.put(imaterial.asItem(), idispensebehavior); +@@ -89,6 +90,7 @@ + IDispenseBehavior idispensebehavior = this.getDispenseMethod(itemstack); if (idispensebehavior != IDispenseBehavior.NOOP) { + eventFired = false; // CraftBukkit - reset event status diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDoor.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDoor.patch index f9231b0950..cb9079d9bb 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDoor.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDoor.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockDoor.java +++ b/net/minecraft/world/level/block/BlockDoor.java -@@ -34,6 +34,8 @@ +@@ -33,6 +33,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -9,13 +9,13 @@ public class BlockDoor extends Block { public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING; -@@ -192,9 +194,24 @@ +@@ -191,9 +193,24 @@ @Override - public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) { -- boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || world.isBlockIndirectlyPowered(blockposition.shift(iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN)); + public void neighborChanged(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) { +- boolean flag1 = world.hasNeighborSignal(blockposition) || world.hasNeighborSignal(blockposition.relative(iblockdata.getValue(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN)); + // CraftBukkit start -+ BlockPosition otherHalf = blockposition.shift(iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN); ++ BlockPosition otherHalf = blockposition.relative(iblockdata.getValue(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN); + + org.bukkit.World bworld = world.getWorld(); + org.bukkit.block.Block bukkitBlock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); @@ -24,15 +24,15 @@ + int power = bukkitBlock.getBlockPower(); + int powerTop = blockTop.getBlockPower(); + if (powerTop > power) power = powerTop; -+ int oldPower = (Boolean) iblockdata.get(BlockDoor.POWERED) ? 15 : 0; ++ int oldPower = (Boolean) iblockdata.getValue(BlockDoor.POWERED) ? 15 : 0; + + if (oldPower == 0 ^ power == 0) { + BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power); + world.getCraftServer().getPluginManager().callEvent(eventRedstone); -- if (!this.getBlockData().a(block) && flag1 != (Boolean) iblockdata.get(BlockDoor.POWERED)) { +- if (!this.defaultBlockState().is(block) && flag1 != (Boolean) iblockdata.getValue(BlockDoor.POWERED)) { + boolean flag1 = eventRedstone.getNewCurrent() > 0; + // CraftBukkit end - if (flag1 != (Boolean) iblockdata.get(BlockDoor.OPEN)) { - this.a(world, blockposition, flag1); - world.a(flag1 ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, blockposition); + if (flag1 != (Boolean) iblockdata.getValue(BlockDoor.OPEN)) { + this.playSound(world, blockposition, flag1); + world.gameEvent(flag1 ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, blockposition); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDragonEgg.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDragonEgg.patch index 9023ea854e..f0e1da23b3 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDragonEgg.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDragonEgg.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockDragonEgg.java +++ b/net/minecraft/world/level/block/BlockDragonEgg.java -@@ -15,6 +15,8 @@ +@@ -16,6 +16,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -8,11 +8,11 @@ + public class BlockDragonEgg extends BlockFalling { - protected static final VoxelShape SHAPE = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D); -@@ -44,6 +46,18 @@ - BlockPosition blockposition1 = blockposition.c(world.random.nextInt(16) - world.random.nextInt(16), world.random.nextInt(8) - world.random.nextInt(8), world.random.nextInt(16) - world.random.nextInt(16)); + protected static final VoxelShape SHAPE = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D); +@@ -47,6 +49,18 @@ + BlockPosition blockposition1 = blockposition.offset(world.random.nextInt(16) - world.random.nextInt(16), world.random.nextInt(8) - world.random.nextInt(8), world.random.nextInt(16) - world.random.nextInt(16)); - if (world.getType(blockposition1).isAir()) { + if (world.getBlockState(blockposition1).isAir() && worldborder.isWithinBounds(blockposition1)) { + // CraftBukkit start + org.bukkit.block.Block from = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + org.bukkit.block.Block to = world.getWorld().getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDropper.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDropper.patch index fb21d299aa..da6a8df7be 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDropper.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDropper.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockDropper.java +++ b/net/minecraft/world/level/block/BlockDropper.java -@@ -16,6 +16,12 @@ +@@ -15,6 +15,12 @@ import net.minecraft.world.level.block.state.BlockBase; import net.minecraft.world.level.block.state.IBlockData; @@ -13,14 +13,14 @@ public class BlockDropper extends BlockDispenser { private static final IDispenseBehavior DISPENSE_BEHAVIOUR = new DispenseBehaviorItem(); -@@ -53,8 +59,25 @@ +@@ -52,8 +58,25 @@ if (iinventory == null) { itemstack1 = BlockDropper.DISPENSE_BEHAVIOUR.dispense(sourceblock, itemstack); } else { -- itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, itemstack.cloneItemStack().cloneAndSubtract(1), enumdirection.opposite()); +- itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, itemstack.copy().split(1), enumdirection.getOpposite()); - if (itemstack1.isEmpty()) { + // CraftBukkit start - Fire event when pushing items into other inventories -+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().cloneAndSubtract(1)); ++ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.copy().split(1)); + + org.bukkit.inventory.Inventory destinationInventory; + // Have to special case large chests as they work oddly @@ -35,9 +35,9 @@ + if (event.isCancelled()) { + return; + } -+ itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection.opposite()); ++ itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection.getOpposite()); + if (event.getItem().equals(oitemstack) && itemstack1.isEmpty()) { + // CraftBukkit end - itemstack1 = itemstack.cloneItemStack(); - itemstack1.subtract(1); + itemstack1 = itemstack.copy(); + itemstack1.shrink(1); } else { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch index 92d7ddd42f..a11d29c699 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch @@ -13,14 +13,14 @@ + public class BlockEnderPortal extends BlockTileEntity { - protected static final VoxelShape SHAPE = Block.a(0.0D, 6.0D, 0.0D, 16.0D, 12.0D, 16.0D); + protected static final VoxelShape SHAPE = Block.box(0.0D, 6.0D, 0.0D, 16.0D, 12.0D, 16.0D); @@ -40,13 +47,22 @@ @Override - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { - if (world instanceof WorldServer && !entity.isPassenger() && !entity.isVehicle() && entity.canPortal() && VoxelShapes.c(VoxelShapes.a(entity.getBoundingBox().d((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), iblockdata.getShape(world, blockposition), OperatorBoolean.AND)) { -- ResourceKey<World> resourcekey = world.getDimensionKey() == World.END ? World.OVERWORLD : World.END; + public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + if (world instanceof WorldServer && !entity.isPassenger() && !entity.isVehicle() && entity.canChangeDimensions() && VoxelShapes.joinIsNotEmpty(VoxelShapes.create(entity.getBoundingBox().move((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), iblockdata.getShape(world, blockposition), OperatorBoolean.AND)) { +- ResourceKey<World> resourcekey = world.dimension() == World.END ? World.OVERWORLD : World.END; + ResourceKey<World> resourcekey = world.getTypeKey() == DimensionManager.END_LOCATION ? World.OVERWORLD : World.END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends - WorldServer worldserver = ((WorldServer) world).getMinecraftServer().getWorldServer(resourcekey); + WorldServer worldserver = ((WorldServer) world).getServer().getLevel(resourcekey); if (worldserver == null) { - return; @@ -32,10 +32,10 @@ + world.getCraftServer().getPluginManager().callEvent(event); + + if (entity instanceof EntityPlayer) { -+ ((EntityPlayer) entity).b(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL); ++ ((EntityPlayer) entity).changeDimension(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL); + return; + } + // CraftBukkit end - entity.b(worldserver); + entity.changeDimension(worldserver); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch index 0662326b74..c5b6c7f839 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/BlockFenceGate.java +++ b/net/minecraft/world/level/block/BlockFenceGate.java -@@ -130,6 +130,17 @@ - public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) { +@@ -129,6 +129,17 @@ + public void neighborChanged(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) { if (!world.isClientSide) { - boolean flag1 = world.isBlockIndirectlyPowered(blockposition); + boolean flag1 = world.hasNeighborSignal(blockposition); + // CraftBukkit start -+ boolean oldPowered = iblockdata.get(BlockFenceGate.POWERED); ++ boolean oldPowered = iblockdata.getValue(BlockFenceGate.POWERED); + if (oldPowered != flag1) { + int newPower = flag1 ? 15 : 0; + int oldPower = oldPowered ? 15 : 0; @@ -16,5 +16,5 @@ + } + // CraftBukkit end - if ((Boolean) iblockdata.get(BlockFenceGate.POWERED) != flag1) { - world.setTypeAndData(blockposition, (IBlockData) ((IBlockData) iblockdata.set(BlockFenceGate.POWERED, flag1)).set(BlockFenceGate.OPEN, flag1), 2); + if ((Boolean) iblockdata.getValue(BlockFenceGate.POWERED) != flag1) { + world.setBlock(blockposition, (IBlockData) ((IBlockData) iblockdata.setValue(BlockFenceGate.POWERED, flag1)).setValue(BlockFenceGate.OPEN, flag1), 2); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFire.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFire.patch index 7769de27ce..3e22babf6e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFire.patch +++ b/paper-server/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 -@@ -28,6 +28,14 @@ +@@ -27,6 +27,14 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -15,19 +15,19 @@ public class BlockFire extends BlockFireAbstract { public static final int MAX_AGE = 15; -@@ -93,7 +101,24 @@ +@@ -92,7 +100,24 @@ @Override - public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { -- return this.canPlace(iblockdata, generatoraccess, blockposition) ? this.a(generatoraccess, blockposition, (Integer) iblockdata.get(BlockFire.AGE)) : Blocks.AIR.getBlockData(); + public IBlockData updateShape(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { +- return this.canSurvive(iblockdata, generatoraccess, blockposition) ? this.getStateWithAge(generatoraccess, blockposition, (Integer) iblockdata.getValue(BlockFire.AGE)) : Blocks.AIR.defaultBlockState(); + // CraftBukkit start -+ if (!this.canPlace(iblockdata, generatoraccess, blockposition)) { ++ if (!this.canSurvive(iblockdata, generatoraccess, blockposition)) { + // Suppress during worldgen + if (!(generatoraccess instanceof World)) { -+ return Blocks.AIR.getBlockData(); ++ return Blocks.AIR.defaultBlockState(); + } + CraftBlockState blockState = CraftBlockStates.getBlockState(generatoraccess, blockposition); -+ blockState.setData(Blocks.AIR.getBlockData()); ++ blockState.setData(Blocks.AIR.defaultBlockState()); + + BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState); + ((World) generatoraccess).getCraftServer().getPluginManager().callEvent(event); @@ -36,94 +36,94 @@ + return blockState.getHandle(); + } + } -+ return this.a(generatoraccess, blockposition, (Integer) iblockdata.get(BlockFire.AGE)); ++ return this.getStateWithAge(generatoraccess, blockposition, (Integer) iblockdata.getValue(BlockFire.AGE)); + // CraftBukkit end } @Override -@@ -142,7 +167,7 @@ - worldserver.getBlockTickList().a(blockposition, this, a(worldserver.random)); +@@ -141,7 +166,7 @@ + worldserver.scheduleTick(blockposition, (Block) this, getFireTickDelay(worldserver.random)); if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { - if (!iblockdata.canPlace(worldserver, blockposition)) { -- worldserver.a(blockposition, false); + if (!iblockdata.canSurvive(worldserver, blockposition)) { +- worldserver.removeBlock(blockposition, false); + fireExtinguished(worldserver, blockposition); // CraftBukkit - invalid place location } - IBlockData iblockdata1 = worldserver.getType(blockposition.down()); -@@ -150,7 +175,7 @@ - int i = (Integer) iblockdata.get(BlockFire.AGE); + IBlockData iblockdata1 = worldserver.getBlockState(blockposition.below()); +@@ -149,7 +174,7 @@ + int i = (Integer) iblockdata.getValue(BlockFire.AGE); - if (!flag && worldserver.isRaining() && this.a((World) worldserver, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) { -- worldserver.a(blockposition, false); + if (!flag && worldserver.isRaining() && this.isNearRain(worldserver, blockposition) && random.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 + random.nextInt(3) / 2); -@@ -164,14 +189,14 @@ - BlockPosition blockposition1 = blockposition.down(); +@@ -163,14 +188,14 @@ + BlockPosition blockposition1 = blockposition.below(); - if (!worldserver.getType(blockposition1).d(worldserver, blockposition1, EnumDirection.UP) || i > 3) { -- worldserver.a(blockposition, false); + if (!worldserver.getBlockState(blockposition1).isFaceSturdy(worldserver, blockposition1, EnumDirection.UP) || i > 3) { +- worldserver.removeBlock(blockposition, false); + fireExtinguished(worldserver, blockposition); // CraftBukkit } return; } - if (i == 15 && random.nextInt(4) == 0 && !this.f(worldserver.getType(blockposition.down()))) { -- worldserver.a(blockposition, false); + if (i == 15 && random.nextInt(4) == 0 && !this.canBurn(worldserver.getBlockState(blockposition.below()))) { +- worldserver.removeBlock(blockposition, false); + fireExtinguished(worldserver, blockposition); // CraftBukkit return; } } -@@ -179,12 +204,14 @@ - boolean flag1 = worldserver.u(blockposition); +@@ -178,12 +203,14 @@ + boolean flag1 = worldserver.isHumidAt(blockposition); int k = flag1 ? -50 : 0; -- this.trySpread(worldserver, blockposition.east(), 300 + k, random, i); -- this.trySpread(worldserver, blockposition.west(), 300 + k, random, i); -- this.trySpread(worldserver, blockposition.down(), 250 + k, random, i); -- this.trySpread(worldserver, blockposition.up(), 250 + k, random, i); -- this.trySpread(worldserver, blockposition.north(), 300 + k, random, i); -- this.trySpread(worldserver, blockposition.south(), 300 + k, random, i); +- this.checkBurnOut(worldserver, blockposition.east(), 300 + k, random, i); +- this.checkBurnOut(worldserver, blockposition.west(), 300 + k, random, i); +- this.checkBurnOut(worldserver, blockposition.below(), 250 + k, random, i); +- this.checkBurnOut(worldserver, blockposition.above(), 250 + k, random, i); +- this.checkBurnOut(worldserver, blockposition.north(), 300 + k, random, i); +- this.checkBurnOut(worldserver, blockposition.south(), 300 + k, random, i); + // CraftBukkit start - add source blockposition to burn calls + this.trySpread(worldserver, blockposition.east(), 300 + k, random, i, blockposition); + this.trySpread(worldserver, blockposition.west(), 300 + k, random, i, blockposition); -+ this.trySpread(worldserver, blockposition.down(), 250 + k, random, i, blockposition); -+ this.trySpread(worldserver, blockposition.up(), 250 + k, random, i, blockposition); ++ this.trySpread(worldserver, blockposition.below(), 250 + k, random, i, blockposition); ++ this.trySpread(worldserver, blockposition.above(), 250 + k, random, i, blockposition); + this.trySpread(worldserver, blockposition.north(), 300 + k, random, i, blockposition); + this.trySpread(worldserver, blockposition.south(), 300 + k, random, i, blockposition); + // CraftBukkit end BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition(); for (int l = -1; l <= 1; ++l) { -@@ -210,7 +237,15 @@ - if (i2 > 0 && random.nextInt(k1) <= i2 && (!worldserver.isRaining() || !this.a((World) worldserver, (BlockPosition) blockposition_mutableblockposition))) { +@@ -209,7 +236,15 @@ + if (i2 > 0 && random.nextInt(k1) <= i2 && (!worldserver.isRaining() || !this.isNearRain(worldserver, blockposition_mutableblockposition))) { int j2 = Math.min(15, i + random.nextInt(5) / 4); -- worldserver.setTypeAndData(blockposition_mutableblockposition, this.a(worldserver, blockposition_mutableblockposition, j2), 3); +- worldserver.setBlock(blockposition_mutableblockposition, this.getStateWithAge(worldserver, blockposition_mutableblockposition, j2), 3); + // CraftBukkit start - Call to stop spread of fire -+ if (worldserver.getType(blockposition_mutableblockposition).getBlock() != Blocks.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.a(worldserver, blockposition_mutableblockposition, j2), 3); // CraftBukkit ++ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition_mutableblockposition, this.getStateWithAge(worldserver, blockposition_mutableblockposition, j2), 3); // CraftBukkit + } + // CraftBukkit end } } } -@@ -234,12 +269,24 @@ - return iblockdata.b(BlockProperties.WATERLOGGED) && (Boolean) iblockdata.get(BlockProperties.WATERLOGGED) ? 0 : this.flameOdds.getInt(iblockdata.getBlock()); +@@ -233,12 +268,24 @@ + return iblockdata.hasProperty(BlockProperties.WATERLOGGED) && (Boolean) iblockdata.getValue(BlockProperties.WATERLOGGED) ? 0 : this.flameOdds.getInt(iblockdata.getBlock()); } -- private void trySpread(World world, BlockPosition blockposition, int i, Random random, int j) { +- private void checkBurnOut(World world, BlockPosition blockposition, int i, Random random, int j) { + private void trySpread(World world, BlockPosition blockposition, int i, Random random, int j, BlockPosition sourceposition) { // CraftBukkit add sourceposition - int k = this.getBurnChance(world.getType(blockposition)); + int k = this.getBurnOdd(world.getBlockState(blockposition)); if (random.nextInt(i) < k) { - IBlockData iblockdata = world.getType(blockposition); + IBlockData iblockdata = world.getBlockState(blockposition); + // CraftBukkit start + org.bukkit.block.Block theBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch index 8622ebaa9e..5e614a1bb8 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch @@ -1,47 +1,47 @@ --- a/net/minecraft/world/level/block/BlockFireAbstract.java +++ b/net/minecraft/world/level/block/BlockFireAbstract.java -@@ -125,7 +125,14 @@ - if (!entity.isFireProof()) { - entity.setFireTicks(entity.getFireTicks() + 1); - if (entity.getFireTicks() == 0) { -- entity.setOnFire(8); +@@ -124,7 +124,14 @@ + if (!entity.fireImmune()) { + entity.setRemainingFireTicks(entity.getRemainingFireTicks() + 1); + if (entity.getRemainingFireTicks() == 0) { +- entity.setSecondsOnFire(8); + // 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); + world.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ entity.setOnFire(event.getDuration(), false); ++ entity.setSecondsOnFire(event.getDuration(), false); + } + // CraftBukkit end } - entity.damageEntity(DamageSource.IN_FIRE, this.fireDamage); -@@ -147,14 +154,14 @@ + entity.hurt(DamageSource.IN_FIRE, this.fireDamage); +@@ -146,14 +153,14 @@ } - if (!iblockdata.canPlace(world, blockposition)) { -- world.a(blockposition, false); + if (!iblockdata.canSurvive(world, blockposition)) { +- world.removeBlock(blockposition, false); + fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke } } } - private static boolean a(World world) { -- return world.getDimensionKey() == World.OVERWORLD || world.getDimensionKey() == World.NETHER; + private static boolean inPortalDimension(World world) { +- return world.dimension() == World.OVERWORLD || world.dimension() == World.NETHER; + return world.getTypeKey() == net.minecraft.world.level.dimension.DimensionManager.OVERWORLD_LOCATION || world.getTypeKey() == net.minecraft.world.level.dimension.DimensionManager.NETHER_LOCATION; // CraftBukkit - getTypeKey() } @Override -@@ -202,4 +209,12 @@ +@@ -201,4 +208,12 @@ } } } + + // CraftBukkit start -+ protected void fireExtinguished(GeneratorAccess world, BlockPosition position) { -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, position, Blocks.AIR.getBlockData()).isCancelled()) { -+ world.a(position, false); ++ protected void fireExtinguished(net.minecraft.world.level.GeneratorAccess world, BlockPosition position) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, position, Blocks.AIR.defaultBlockState()).isCancelled()) { ++ world.removeBlock(position, false); + } + } + // CraftBukkit end diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFluids.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFluids.patch index 5663343489..2f664a051c 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFluids.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFluids.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/world/level/block/BlockFluids.java +++ b/net/minecraft/world/level/block/BlockFluids.java -@@ -143,14 +143,20 @@ - if (world.getFluid(blockposition1).a((Tag) TagsFluid.WATER)) { - Block block = world.getFluid(blockposition).isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE; +@@ -141,14 +141,20 @@ + if (world.getFluidState(blockposition1).is((Tag) TagsFluid.WATER)) { + Block block = world.getFluidState(blockposition).isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE; -- world.setTypeUpdate(blockposition, block.getBlockData()); +- world.setBlockAndUpdate(blockposition, block.defaultBlockState()); - this.fizz(world, blockposition); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, block.getBlockData())) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, block.defaultBlockState())) { + this.fizz(world, blockposition); + } + // CraftBukkit end return false; } - if (flag && world.getType(blockposition1).a(Blocks.BLUE_ICE)) { -- world.setTypeUpdate(blockposition, Blocks.BASALT.getBlockData()); + if (flag && world.getBlockState(blockposition1).is(Blocks.BLUE_ICE)) { +- world.setBlockAndUpdate(blockposition, Blocks.BASALT.defaultBlockState()); - this.fizz(world, blockposition); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.BASALT.getBlockData())) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.BASALT.defaultBlockState())) { + this.fizz(world, blockposition); + } + // CraftBukkit end diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFungi.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFungi.patch index 8ca0174198..eafa6a78f3 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFungi.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFungi.patch @@ -3,7 +3,7 @@ @@ -51,6 +51,13 @@ @Override - public void a(WorldServer worldserver, Random random, BlockPosition blockposition, IBlockData iblockdata) { + public void performBonemeal(WorldServer worldserver, Random random, BlockPosition blockposition, IBlockData iblockdata) { + // CraftBukkit start + if (this == Blocks.WARPED_FUNGUS) { + BlockSapling.treeType = org.bukkit.TreeType.WARPED_FUNGUS; @@ -11,6 +11,6 @@ + BlockSapling.treeType = org.bukkit.TreeType.CRIMSON_FUNGUS; + } + // CraftBukkit end - ((WorldGenFeatureConfigured) this.feature.get()).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), random, blockposition); + ((WorldGenFeatureConfigured) this.feature.get()).place(worldserver, worldserver.getChunkSource().getGenerator(), random, blockposition); } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockGrass.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockGrass.patch deleted file mode 100644 index df4cdce88e..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockGrass.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/block/BlockGrass.java -+++ b/net/minecraft/world/level/block/BlockGrass.java -@@ -70,7 +70,7 @@ - } - - if (iblockdata3.canPlace(worldserver, blockposition2)) { -- worldserver.setTypeAndData(blockposition2, iblockdata3, 3); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition2, iblockdata3, 3); // CraftBukkit - } - } - } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockGrassPath.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockGrassPath.patch index d2b8f8292c..f86819e4c2 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockGrassPath.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockGrassPath.patch @@ -3,12 +3,12 @@ @@ -43,6 +43,11 @@ @Override - public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + // CraftBukkit start - do not fade if the block is valid here -+ if (iblockdata.canPlace(worldserver, blockposition)) { ++ if (iblockdata.canSurvive(worldserver, blockposition)) { + return; + } + // CraftBukkit end - BlockSoil.fade(iblockdata, worldserver, blockposition); + BlockSoil.turnToDirt(iblockdata, worldserver, blockposition); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockGrowingTop.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockGrowingTop.patch index 75f188c152..e93fd2a3a7 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockGrowingTop.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockGrowingTop.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/BlockGrowingTop.java +++ b/net/minecraft/world/level/block/BlockGrowingTop.java -@@ -45,7 +45,7 @@ - BlockPosition blockposition1 = blockposition.shift(this.growthDirection); +@@ -44,7 +44,7 @@ + BlockPosition blockposition1 = blockposition.relative(this.growthDirection); - if (this.g(worldserver.getType(blockposition1))) { -- worldserver.setTypeUpdate(blockposition1, this.a(iblockdata, worldserver.random)); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, this.a(iblockdata, worldserver.random)); // CraftBukkit + if (this.canGrowInto(worldserver.getBlockState(blockposition1))) { +- worldserver.setBlockAndUpdate(blockposition1, this.getGrowIntoState(iblockdata, worldserver.random)); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, this.getGrowIntoState(iblockdata, worldserver.random)); // CraftBukkit } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockIce.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockIce.patch index 325d1e9ba8..388a97d6fb 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockIce.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockIce.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/BlockIce.java +++ b/net/minecraft/world/level/block/BlockIce.java -@@ -50,6 +50,11 @@ +@@ -49,6 +49,11 @@ } protected void melt(IBlockData iblockdata, World world, BlockPosition blockposition) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, world.getDimensionManager().isNether() ? Blocks.AIR.getBlockData() : Blocks.WATER.getBlockData()).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, world.dimensionType().ultraWarm() ? Blocks.AIR.defaultBlockState() : Blocks.WATER.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - if (world.getDimensionManager().isNether()) { - world.a(blockposition, false); + if (world.dimensionType().ultraWarm()) { + world.removeBlock(blockposition, false); } else { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockJukeBox.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockJukeBox.patch index 7880c2266d..57433db045 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockJukeBox.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockJukeBox.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/level/block/BlockJukeBox.java +++ b/net/minecraft/world/level/block/BlockJukeBox.java -@@ -62,7 +62,13 @@ - TileEntity tileentity = generatoraccess.getTileEntity(blockposition); +@@ -59,7 +59,13 @@ + TileEntity tileentity = generatoraccess.getBlockEntity(blockposition); if (tileentity instanceof TileEntityJukeBox) { -- ((TileEntityJukeBox) tileentity).setRecord(itemstack.cloneItemStack()); +- ((TileEntityJukeBox) tileentity).setRecord(itemstack.copy()); + // CraftBukkit start - There can only be one -+ itemstack = itemstack.cloneItemStack(); ++ itemstack = itemstack.copy(); + if (!itemstack.isEmpty()) { + itemstack.setCount(1); + } + ((TileEntityJukeBox) tileentity).setRecord(itemstack); + // CraftBukkit end - generatoraccess.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockJukeBox.HAS_RECORD, true), 2); + generatoraccess.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockJukeBox.HAS_RECORD, true), 2); } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch index 4df27c4709..dae8867269 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockLeaves.java +++ b/net/minecraft/world/level/block/BlockLeaves.java -@@ -21,6 +21,8 @@ +@@ -20,6 +20,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -9,18 +9,18 @@ public class BlockLeaves extends Block { public static final int DECAY_DISTANCE = 7; -@@ -46,6 +48,14 @@ +@@ -45,6 +47,14 @@ @Override - public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - if (!(Boolean) iblockdata.get(BlockLeaves.PERSISTENT) && (Integer) iblockdata.get(BlockLeaves.DISTANCE) == 7) { + public void randomTick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + if (!(Boolean) iblockdata.getValue(BlockLeaves.PERSISTENT) && (Integer) iblockdata.getValue(BlockLeaves.DISTANCE) == 7) { + // CraftBukkit start + LeavesDecayEvent event = new LeavesDecayEvent(worldserver.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ())); + worldserver.getCraftServer().getPluginManager().callEvent(event); + -+ if (event.isCancelled() || worldserver.getType(blockposition).getBlock() != this) { ++ if (event.isCancelled() || worldserver.getBlockState(blockposition).getBlock() != this) { + return; + } + // CraftBukkit end - c(iblockdata, (World) worldserver, blockposition); - worldserver.a(blockposition, false); + dropResources(iblockdata, worldserver, blockposition); + worldserver.removeBlock(blockposition, false); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockLectern.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockLectern.patch index 1a5b5ad8f7..369e7104ea 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockLectern.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockLectern.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/level/block/BlockLectern.java +++ b/net/minecraft/world/level/block/BlockLectern.java -@@ -199,12 +199,13 @@ +@@ -198,12 +198,13 @@ } - private void d(IBlockData iblockdata, World world, BlockPosition blockposition) { -- TileEntity tileentity = world.getTileEntity(blockposition); -+ TileEntity tileentity = world.getTileEntity(blockposition, false); // CraftBukkit - don't validate, type may be changed already + 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 tileentitylectern = (TileEntityLectern) tileentity; - EnumDirection enumdirection = (EnumDirection) iblockdata.get(BlockLectern.FACING); - ItemStack itemstack = tileentitylectern.getBook().cloneItemStack(); + 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.getAdjacentX(); - float f1 = 0.25F * (float) enumdirection.getAdjacentZ(); + 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/paper-server/nms-patches/net/minecraft/world/level/block/BlockLever.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockLever.patch index 27e4ec7038..ffa857e1be 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockLever.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockLever.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockLever.java +++ b/net/minecraft/world/level/block/BlockLever.java -@@ -25,6 +25,8 @@ +@@ -23,6 +23,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -9,12 +9,12 @@ public class BlockLever extends BlockAttachable { public static final BlockStateBoolean POWERED = BlockProperties.POWERED; -@@ -92,6 +94,20 @@ +@@ -90,6 +92,20 @@ return EnumInteractionResult.SUCCESS; } else { + // CraftBukkit start - Interact Lever -+ boolean powered = iblockdata.get(BlockLever.POWERED); // Old powered state ++ boolean powered = iblockdata.getValue(BlockLever.POWERED); // Old powered state + org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + int old = (powered) ? 15 : 0; + int current = (!powered) ? 15 : 0; @@ -27,6 +27,6 @@ + } + // CraftBukkit end + - iblockdata1 = this.d(iblockdata, world, blockposition); - float f = (Boolean) iblockdata1.get(BlockLever.POWERED) ? 0.6F : 0.5F; + iblockdata1 = this.pull(iblockdata, world, blockposition); + float f = (Boolean) iblockdata1.getValue(BlockLever.POWERED) ? 0.6F : 0.5F; diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockMagma.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockMagma.patch index cda1c85d73..d2ce08ac28 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockMagma.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockMagma.patch @@ -3,9 +3,9 @@ @@ -30,7 +30,9 @@ @Override public void stepOn(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { - if (!entity.isFireProof() && entity instanceof EntityLiving && !EnchantmentManager.i((EntityLiving) entity)) { + if (!entity.fireImmune() && entity instanceof EntityLiving && !EnchantmentManager.hasFrostWalker((EntityLiving) entity)) { + org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit - entity.damageEntity(DamageSource.HOT_FLOOR, 1.0F); + entity.hurt(DamageSource.HOT_FLOOR, 1.0F); + org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = null; // CraftBukkit } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockMinecartDetector.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockMinecartDetector.patch index 5ab8ac0980..209283b155 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockMinecartDetector.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockMinecartDetector.patch @@ -25,4 +25,4 @@ + // CraftBukkit end if (flag1 && !flag) { - iblockdata1 = (IBlockData) iblockdata.set(BlockMinecartDetector.POWERED, true); + iblockdata1 = (IBlockData) iblockdata.setValue(BlockMinecartDetector.POWERED, true); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockMobSpawner.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockMobSpawner.patch index 985d0ac8bb..a5d4bc2e84 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockMobSpawner.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockMobSpawner.patch @@ -1,20 +1,18 @@ --- a/net/minecraft/world/level/block/BlockMobSpawner.java +++ b/net/minecraft/world/level/block/BlockMobSpawner.java -@@ -33,9 +33,19 @@ +@@ -33,9 +33,16 @@ @Override - public void dropNaturally(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { - super.dropNaturally(iblockdata, worldserver, blockposition, itemstack); -+ /* CraftBukkit start - Delegate to getExpDrop - int i = 15 + worldserver.random.nextInt(15) + worldserver.random.nextInt(15); - - this.dropExperience(worldserver, blockposition, i); -+ */ + public void spawnAfterBreak(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { + super.spawnAfterBreak(iblockdata, worldserver, blockposition, itemstack); ++ // CraftBukkit start - Delegate to getExpDrop + } + + @Override + public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { -+ int i = 15 + worldserver.random.nextInt(15) + worldserver.random.nextInt(15); -+ + int i = 15 + worldserver.random.nextInt(15) + worldserver.random.nextInt(15); + +- this.popExperience(worldserver, blockposition, i); ++ // this.popExperience(worldserver, blockposition, i); + return i; + // CraftBukkit end } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch index 5ea5b2762c..95053238c7 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch @@ -10,11 +10,11 @@ private final Block hostBlock; @@ -43,7 +45,7 @@ - EntitySilverfish entitysilverfish = (EntitySilverfish) EntityTypes.SILVERFISH.a((World) worldserver); + EntitySilverfish entitysilverfish = (EntitySilverfish) EntityTypes.SILVERFISH.create(worldserver); - entitysilverfish.setPositionRotation((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F); -- worldserver.addEntity(entitysilverfish); -+ worldserver.addEntity(entitysilverfish, SpawnReason.SILVERFISH_BLOCK); // CraftBukkit - add SpawnReason - entitysilverfish.doSpawnEffect(); + entitysilverfish.moveTo((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/paper-server/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch index 15a306cffb..5c3d9b617f 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch @@ -14,17 +14,17 @@ @@ -61,7 +65,7 @@ } - if (worldserver.isEmpty(blockposition2) && iblockdata.canPlace(worldserver, blockposition2)) { -- worldserver.setTypeAndData(blockposition2, iblockdata, 2); + if (worldserver.isEmptyBlock(blockposition2) && iblockdata.canSurvive(worldserver, blockposition2)) { +- worldserver.setBlock(blockposition2, iblockdata, 2); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition2, iblockdata, 2); // CraftBukkit } } @@ -82,6 +86,7 @@ - public boolean a(WorldServer worldserver, BlockPosition blockposition, IBlockData iblockdata, Random random) { - worldserver.a(blockposition, false); + public boolean growMushroom(WorldServer worldserver, BlockPosition blockposition, IBlockData iblockdata, Random random) { + worldserver.removeBlock(blockposition, false); + BlockSapling.treeType = (this == Blocks.BROWN_MUSHROOM) ? TreeType.BROWN_MUSHROOM : TreeType.BROWN_MUSHROOM; // CraftBukkit - if (((WorldGenFeatureConfigured) this.featureSupplier.get()).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), random, blockposition)) { + if (((WorldGenFeatureConfigured) this.featureSupplier.get()).place(worldserver, worldserver.getChunkSource().getGenerator(), random, blockposition)) { return true; } else { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockNetherWart.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockNetherWart.patch index 2cf667a46b..714b242d94 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockNetherWart.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockNetherWart.patch @@ -3,8 +3,8 @@ @@ -46,7 +46,7 @@ if (i < 3 && random.nextInt(10) == 0) { - iblockdata = (IBlockData) iblockdata.set(BlockNetherWart.AGE, i + 1); -- worldserver.setTypeAndData(blockposition, iblockdata, 2); + iblockdata = (IBlockData) iblockdata.setValue(BlockNetherWart.AGE, i + 1); +- worldserver.setBlock(blockposition, iblockdata, 2); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata, 2); // CraftBukkit } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockNote.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockNote.patch index c30ddc6553..1508423f70 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockNote.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockNote.patch @@ -1,47 +1,47 @@ --- a/net/minecraft/world/level/block/BlockNote.java +++ b/net/minecraft/world/level/block/BlockNote.java -@@ -49,7 +49,8 @@ +@@ -48,7 +48,8 @@ - if (flag1 != (Boolean) iblockdata.get(BlockNote.POWERED)) { + if (flag1 != (Boolean) iblockdata.getValue(BlockNote.POWERED)) { if (flag1) { -- this.play(world, blockposition); -+ this.play(world, blockposition, iblockdata); // CraftBukkit -+ iblockdata = world.getType(blockposition); // CraftBukkit - SPIGOT-5617: update in case changed in event +- this.playNote(world, blockposition); ++ this.playNote(world, blockposition, iblockdata); // CraftBukkit ++ iblockdata = world.getBlockState(blockposition); // CraftBukkit - SPIGOT-5617: update in case changed in event } - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockNote.POWERED, flag1), 3); -@@ -57,9 +58,14 @@ + world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockNote.POWERED, flag1), 3); +@@ -56,9 +57,14 @@ } -- private void play(World world, BlockPosition blockposition) { -+ private void play(World world, BlockPosition blockposition, IBlockData data) { // CraftBukkit - if (world.getType(blockposition.up()).isAir()) { -- world.playBlockAction(blockposition, this, 0, 0); +- private void playNote(World world, BlockPosition blockposition) { ++ private void playNote(World world, BlockPosition blockposition, IBlockData data) { // CraftBukkit + if (world.getBlockState(blockposition.above()).isAir()) { +- world.blockEvent(blockposition, this, 0, 0); + // CraftBukkit start -+ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, blockposition, data.get(BlockNote.INSTRUMENT), data.get(BlockNote.NOTE)); ++ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, blockposition, data.getValue(BlockNote.INSTRUMENT), data.getValue(BlockNote.NOTE)); + if (!event.isCancelled()) { -+ world.playBlockAction(blockposition, this, 0, 0); ++ world.blockEvent(blockposition, this, 0, 0); + } + // CraftBukkit end } } -@@ -71,7 +77,7 @@ +@@ -70,7 +76,7 @@ } else { - iblockdata = (IBlockData) iblockdata.a((IBlockState) BlockNote.NOTE); - world.setTypeAndData(blockposition, iblockdata, 3); -- this.play(world, blockposition); -+ this.play(world, blockposition, iblockdata); // CraftBukkit - entityhuman.a(StatisticList.TUNE_NOTEBLOCK); + iblockdata = (IBlockData) iblockdata.cycle(BlockNote.NOTE); + world.setBlock(blockposition, iblockdata, 3); +- this.playNote(world, blockposition); ++ this.playNote(world, blockposition, iblockdata); // CraftBukkit + entityhuman.awardStat(StatisticList.TUNE_NOTEBLOCK); return EnumInteractionResult.CONSUME; } -@@ -80,7 +86,7 @@ +@@ -79,7 +85,7 @@ @Override public void attack(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) { if (!world.isClientSide) { -- this.play(world, blockposition); -+ this.play(world, blockposition, iblockdata); // CraftBukkit - entityhuman.a(StatisticList.PLAY_NOTEBLOCK); +- this.playNote(world, blockposition); ++ this.playNote(world, blockposition, iblockdata); // CraftBukkit + entityhuman.awardStat(StatisticList.PLAY_NOTEBLOCK); } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockNylium.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockNylium.patch index 2125554e7d..f6155a70cf 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockNylium.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockNylium.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/BlockNylium.java +++ b/net/minecraft/world/level/block/BlockNylium.java -@@ -31,6 +31,11 @@ +@@ -30,6 +30,11 @@ @Override - public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - if (!b(iblockdata, (IWorldReader) worldserver, blockposition)) { + public void randomTick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + if (!canBeNylium(iblockdata, worldserver, blockposition)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.NETHERRACK.getBlockData()).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.NETHERRACK.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - worldserver.setTypeUpdate(blockposition, Blocks.NETHERRACK.getBlockData()); + worldserver.setBlockAndUpdate(blockposition, Blocks.NETHERRACK.defaultBlockState()); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockObserver.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockObserver.patch index bbaabcfdf4..552e21f375 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockObserver.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockObserver.patch @@ -11,20 +11,20 @@ public static final BlockStateBoolean POWERED = BlockProperties.POWERED; @@ -41,8 +43,18 @@ @Override - public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - if ((Boolean) iblockdata.get(BlockObserver.POWERED)) { + public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + if ((Boolean) iblockdata.getValue(BlockObserver.POWERED)) { + // CraftBukkit start + if (CraftEventFactory.callRedstoneChange(worldserver, blockposition, 15, 0).getNewCurrent() != 0) { + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockObserver.POWERED, false), 2); + worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockObserver.POWERED, false), 2); } else { + // CraftBukkit start + if (CraftEventFactory.callRedstoneChange(worldserver, blockposition, 0, 15).getNewCurrent() != 15) { + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockObserver.POWERED, true), 2); - worldserver.getBlockTickList().a(blockposition, this, 2); + worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockObserver.POWERED, true), 2); + worldserver.scheduleTick(blockposition, (Block) this, 2); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockOre.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockOre.patch index c0109dc12e..0e79ef07e8 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockOre.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockOre.patch @@ -1,32 +1,24 @@ --- a/net/minecraft/world/level/block/BlockOre.java +++ b/net/minecraft/world/level/block/BlockOre.java -@@ -25,6 +25,7 @@ +@@ -25,13 +25,20 @@ @Override - public void dropNaturally(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { - super.dropNaturally(iblockdata, worldserver, blockposition, itemstack); -+ /* CraftBukkit start - Delegated to getExpDrop - if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { - int i = this.xpRange.a(worldserver.random); - -@@ -32,6 +33,21 @@ - this.dropExperience(worldserver, blockposition, i); - } - } -+ // */ - - } + public void spawnAfterBreak(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { + super.spawnAfterBreak(iblockdata, worldserver, blockposition, itemstack); ++ // CraftBukkit start - Delegated to getExpDrop ++ } + + @Override + public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { -+ if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { -+ int i = this.xpRange.a(worldserver.random); -+ -+ if (i > 0) { -+ return i; -+ } -+ } -+ -+ return 0; + // CraftBukkit end -+ } + if (EnchantmentManager.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { + int i = this.xpRange.sample(worldserver.random); + + if (i > 0) { +- this.popExperience(worldserver, blockposition, i); ++ return i; // CraftBukkit + } + } + ++ return 0; // CraftBukkit + } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPlant.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPlant.patch index 1c0d46a345..1e84032584 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPlant.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPlant.patch @@ -3,15 +3,15 @@ @@ -23,7 +23,14 @@ @Override - public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { -- return !iblockdata.canPlace(generatoraccess, blockposition) ? Blocks.AIR.getBlockData() : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); + public IBlockData updateShape(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { +- return !iblockdata.canSurvive(generatoraccess, blockposition) ? Blocks.AIR.defaultBlockState() : super.updateShape(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); + // CraftBukkit start -+ if (!iblockdata.canPlace(generatoraccess, blockposition)) { ++ if (!iblockdata.canSurvive(generatoraccess, blockposition)) { + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(generatoraccess, blockposition).isCancelled()) { -+ return Blocks.AIR.getBlockData(); ++ return Blocks.AIR.defaultBlockState(); + } + } -+ return super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); ++ return super.updateShape(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); + // CraftBukkit end } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPortal.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPortal.patch index 46412c9e7d..96a7b27223 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPortal.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPortal.patch @@ -14,21 +14,21 @@ @@ -58,7 +62,8 @@ } - if (worldserver.getType(blockposition).a((IBlockAccess) worldserver, blockposition, EntityTypes.ZOMBIFIED_PIGLIN)) { -- Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.up(), EnumMobSpawn.STRUCTURE, false, false); + if (worldserver.getBlockState(blockposition).isValidSpawn(worldserver, blockposition, EntityTypes.ZOMBIFIED_PIGLIN)) { +- Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawn(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.above(), EnumMobSpawn.STRUCTURE, false, false); + // CraftBukkit - set spawn reason to NETHER_PORTAL -+ Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.up(), EnumMobSpawn.STRUCTURE, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); ++ Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawn(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.above(), EnumMobSpawn.STRUCTURE, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); if (entity != null) { - entity.resetPortalCooldown(); + entity.setPortalCooldown(); @@ -80,6 +85,10 @@ @Override - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { - if (!entity.isPassenger() && !entity.isVehicle() && entity.canPortal()) { + public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + if (!entity.isPassenger() && !entity.isVehicle() && entity.canChangeDimensions()) { + // CraftBukkit start - Entity in portal + EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ())); + world.getCraftServer().getPluginManager().callEvent(event); + // CraftBukkit end - entity.d(blockposition); + entity.handleInsidePortal(blockposition); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPoweredRail.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPoweredRail.patch index 0759c82448..fab74e6c31 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPoweredRail.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPoweredRail.patch @@ -10,7 +10,7 @@ public static final BlockStateEnum<BlockPropertyTrackPosition> SHAPE = BlockProperties.RAIL_SHAPE_STRAIGHT; @@ -113,6 +115,13 @@ - boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || this.a(world, blockposition, iblockdata, true, 0) || this.a(world, blockposition, iblockdata, false, 0); + boolean flag1 = world.hasNeighborSignal(blockposition) || this.findPoweredRailSignal(world, blockposition, iblockdata, true, 0) || this.findPoweredRailSignal(world, blockposition, iblockdata, false, 0); if (flag1 != flag) { + // CraftBukkit start @@ -20,6 +20,6 @@ + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockPoweredRail.POWERED, flag1), 3); - world.applyPhysics(blockposition.down(), this); - if (((BlockPropertyTrackPosition) iblockdata.get(BlockPoweredRail.SHAPE)).b()) { + world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockPoweredRail.POWERED, flag1), 3); + world.updateNeighborsAt(blockposition.below(), this); + if (((BlockPropertyTrackPosition) iblockdata.getValue(BlockPoweredRail.SHAPE)).isAscending()) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateAbstract.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateAbstract.patch index 177a5f6a03..54843b3dfc 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateAbstract.patch +++ b/paper-server/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.a(1.0D, 0.0D, 1.0D, 15.0D, 0.5D, 15.0D); + protected static final VoxelShape PRESSED_AABB = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 0.5D, 15.0D); @@ -81,6 +83,19 @@ boolean flag = i > 0; boolean flag1 = j > 0; @@ -27,5 +27,5 @@ + // CraftBukkit end + if (i != j) { - IBlockData iblockdata1 = this.a(iblockdata, j); + IBlockData iblockdata1 = this.setSignalForState(iblockdata, j); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateBinary.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateBinary.patch index 16170cef0e..c8f9bf8f19 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateBinary.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateBinary.patch @@ -14,7 +14,7 @@ Entity entity = (Entity) iterator.next(); + // CraftBukkit start - Call interact event when turning on a pressure plate -+ if (this.getPower(world.getType(blockposition)) == 0) { ++ if (this.getSignalForState(world.getBlockState(blockposition)) == 0) { + org.bukkit.World bworld = world.getWorld(); + org.bukkit.plugin.PluginManager manager = world.getCraftServer().getPluginManager(); + org.bukkit.event.Cancellable cancellable; @@ -33,6 +33,6 @@ + } + // CraftBukkit end + - if (!entity.isIgnoreBlockTrigger()) { + if (!entity.isIgnoringBlockTriggers()) { return 15; } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateWeighted.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateWeighted.patch index faf022cb06..25ac3dcf71 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateWeighted.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateWeighted.patch @@ -12,12 +12,12 @@ @@ -27,7 +29,31 @@ @Override - protected int b(World world, BlockPosition blockposition) { -- int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.TOUCH_AABB.a(blockposition)).size(), this.maxWeight); + protected int getSignalStrength(World world, BlockPosition blockposition) { +- int i = Math.min(world.getEntitiesOfClass(Entity.class, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition)).size(), this.maxWeight); + // CraftBukkit start -+ // int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight); ++ // int i = Math.min(world.getEntitiesOfClass(Entity.class, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition)).size(), this.maxWeight); + int i = 0; -+ java.util.Iterator iterator = world.a(Entity.class, BlockPressurePlateWeighted.TOUCH_AABB.a(blockposition)).iterator(); ++ java.util.Iterator iterator = world.getEntitiesOfClass(Entity.class, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition)).iterator(); + + while (iterator.hasNext()) { + Entity entity = (Entity) iterator.next(); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch index 3c6f905562..b60e96af3d 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch @@ -18,57 +18,57 @@ + BlockStateListPopulator blockList = new BlockStateListPopulator(world); // CraftBukkit - Use BlockStateListPopulator if (shapedetector_shapedetectorcollection != null) { - for (i = 0; i < this.getSnowmanShape().b(); ++i) { - ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(0, i, 0); + for (i = 0; i < this.getOrCreateSnowGolemFull().getHeight(); ++i) { + ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.getBlock(0, i, 0); -- world.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2); -- world.triggerEffect(2001, shapedetectorblock.getPosition(), Block.getCombinedId(shapedetectorblock.a())); -+ blockList.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit -+ // world.triggerEffect(2001, shapedetectorblock.getPosition(), Block.getCombinedId(shapedetectorblock.a())); // CraftBukkit +- world.setBlock(shapedetectorblock.getPos(), Blocks.AIR.defaultBlockState(), 2); +- world.levelEvent(2001, shapedetectorblock.getPos(), Block.getId(shapedetectorblock.getState())); ++ blockList.setBlock(shapedetectorblock.getPos(), Blocks.AIR.defaultBlockState(), 2); // CraftBukkit ++ // world.levelEvent(2001, shapedetectorblock.getPos(), Block.getId(shapedetectorblock.getState())); // CraftBukkit } - EntitySnowman entitysnowman = (EntitySnowman) EntityTypes.SNOW_GOLEM.a(world); - BlockPosition blockposition1 = shapedetector_shapedetectorcollection.a(0, 2, 0).getPosition(); + EntitySnowman entitysnowman = (EntitySnowman) EntityTypes.SNOW_GOLEM.create(world); + BlockPosition blockposition1 = shapedetector_shapedetectorcollection.getBlock(0, 2, 0).getPos(); - entitysnowman.setPositionRotation((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.05D, (double) blockposition1.getZ() + 0.5D, 0.0F, 0.0F); -- world.addEntity(entitysnowman); + entitysnowman.moveTo((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.05D, (double) blockposition1.getZ() + 0.5D, 0.0F, 0.0F); +- world.addFreshEntity(entitysnowman); + // CraftBukkit start -+ if (!world.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) { ++ if (!world.addFreshEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) { + return; + } + for (BlockPosition pos : blockList.getBlocks()) { -+ world.triggerEffect(2001, pos, Block.getCombinedId(world.getType(pos))); ++ world.levelEvent(2001, pos, Block.getId(world.getBlockState(pos))); + } + blockList.updateList(); + // CraftBukkit end - iterator = world.a(EntityPlayer.class, entitysnowman.getBoundingBox().g(5.0D)).iterator(); + iterator = world.getEntitiesOfClass(EntityPlayer.class, entitysnowman.getBoundingBox().inflate(5.0D)).iterator(); while (iterator.hasNext()) { @@ -96,8 +110,8 @@ - for (int k = 0; k < this.getIronGolemShape().b(); ++k) { - ShapeDetectorBlock shapedetectorblock2 = shapedetector_shapedetectorcollection.a(i, k, 0); + for (int k = 0; k < this.getOrCreateIronGolemFull().getHeight(); ++k) { + ShapeDetectorBlock shapedetectorblock2 = shapedetector_shapedetectorcollection.getBlock(i, k, 0); -- world.setTypeAndData(shapedetectorblock2.getPosition(), Blocks.AIR.getBlockData(), 2); -- world.triggerEffect(2001, shapedetectorblock2.getPosition(), Block.getCombinedId(shapedetectorblock2.a())); -+ blockList.setTypeAndData(shapedetectorblock2.getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit -+ // world.triggerEffect(2001, shapedetectorblock2.getPosition(), Block.getCombinedId(shapedetectorblock2.a())); // CraftBukkit +- world.setBlock(shapedetectorblock2.getPos(), Blocks.AIR.defaultBlockState(), 2); +- world.levelEvent(2001, shapedetectorblock2.getPos(), Block.getId(shapedetectorblock2.getState())); ++ blockList.setBlock(shapedetectorblock2.getPos(), Blocks.AIR.defaultBlockState(), 2); // CraftBukkit ++ // world.levelEvent(2001, shapedetectorblock2.getPos(), Block.getId(shapedetectorblock2.getState())); // CraftBukkit } } @@ -106,7 +120,15 @@ entityirongolem.setPlayerCreated(true); - entityirongolem.setPositionRotation((double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.05D, (double) blockposition2.getZ() + 0.5D, 0.0F, 0.0F); -- world.addEntity(entityirongolem); + entityirongolem.moveTo((double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.05D, (double) blockposition2.getZ() + 0.5D, 0.0F, 0.0F); +- world.addFreshEntity(entityirongolem); + // CraftBukkit start -+ if (!world.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) { ++ if (!world.addFreshEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) { + return; + } + for (BlockPosition pos : blockList.getBlocks()) { -+ world.triggerEffect(2001, pos, Block.getCombinedId(world.getType(pos))); ++ world.levelEvent(2001, pos, Block.getId(world.getBlockState(pos))); + } + blockList.updateList(); + // CraftBukkit end - iterator = world.a(EntityPlayer.class, entityirongolem.getBoundingBox().g(5.0D)).iterator(); + iterator = world.getEntitiesOfClass(EntityPlayer.class, entityirongolem.getBoundingBox().inflate(5.0D)).iterator(); while (iterator.hasNext()) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneComparator.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneComparator.patch index feb76c0413..d9561c2b18 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneComparator.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneComparator.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/world/level/block/BlockRedstoneComparator.java +++ b/net/minecraft/world/level/block/BlockRedstoneComparator.java -@@ -28,6 +28,8 @@ - import net.minecraft.world.phys.AxisAlignedBB; +@@ -26,6 +26,8 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; + import net.minecraft.world.ticks.TickListPriority; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + public class BlockRedstoneComparator extends BlockDiodeAbstract implements ITileEntity { public static final BlockStateEnum<BlockPropertyComparatorMode> MODE = BlockProperties.MODE_COMPARATOR; -@@ -99,7 +101,8 @@ +@@ -97,7 +99,8 @@ @Nullable - private EntityItemFrame a(World world, EnumDirection enumdirection, BlockPosition blockposition) { -- List<EntityItemFrame> list = world.a(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) -> { + private EntityItemFrame getItemFrame(World world, EnumDirection enumdirection, BlockPosition blockposition) { +- List<EntityItemFrame> 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<EntityItemFrame> list = world.a(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>) (entityitemframe) -> { ++ List<EntityItemFrame> 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>) (entityitemframe) -> { return entityitemframe != null && entityitemframe.getDirection() == enumdirection; }); -@@ -154,8 +157,18 @@ - boolean flag1 = (Boolean) iblockdata.get(BlockRedstoneComparator.POWERED); +@@ -152,8 +155,18 @@ + boolean flag1 = (Boolean) iblockdata.getValue(BlockRedstoneComparator.POWERED); if (flag1 && !flag) { + // CraftBukkit start @@ -28,13 +28,13 @@ + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneComparator.POWERED, false), 2); + world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockRedstoneComparator.POWERED, false), 2); } else if (!flag1 && flag) { + // CraftBukkit start + if (CraftEventFactory.callRedstoneChange(world, blockposition, 0, 15).getNewCurrent() != 15) { + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneComparator.POWERED, true), 2); + world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockRedstoneComparator.POWERED, true), 2); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneLamp.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneLamp.patch index 9af94ef443..b5409541b9 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneLamp.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneLamp.patch @@ -1,35 +1,35 @@ --- a/net/minecraft/world/level/block/BlockRedstoneLamp.java +++ b/net/minecraft/world/level/block/BlockRedstoneLamp.java -@@ -12,6 +12,8 @@ +@@ -11,6 +11,8 @@ + import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.block.state.properties.BlockStateBoolean; - import net.minecraft.world.level.block.state.properties.IBlockState; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + public class BlockRedstoneLamp extends Block { public static final BlockStateBoolean LIT = BlockRedstoneTorch.LIT; -@@ -36,6 +38,11 @@ +@@ -35,6 +37,11 @@ if (flag1) { - world.getBlockTickList().a(blockposition, this, 4); + world.scheduleTick(blockposition, (Block) this, 4); } else { + // CraftBukkit start + if (CraftEventFactory.callRedstoneChange(world, blockposition, 0, 15).getNewCurrent() != 15) { + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.LIT), 2); + world.setBlock(blockposition, (IBlockData) iblockdata.cycle(BlockRedstoneLamp.LIT), 2); } } -@@ -46,6 +53,11 @@ +@@ -45,6 +52,11 @@ @Override - public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - if ((Boolean) iblockdata.get(BlockRedstoneLamp.LIT) && !worldserver.isBlockIndirectlyPowered(blockposition)) { + public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + if ((Boolean) iblockdata.getValue(BlockRedstoneLamp.LIT) && !worldserver.hasNeighborSignal(blockposition)) { + // CraftBukkit start + if (CraftEventFactory.callRedstoneChange(worldserver, blockposition, 15, 0).getNewCurrent() != 0) { + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.LIT), 2); + worldserver.setBlock(blockposition, (IBlockData) iblockdata.cycle(BlockRedstoneLamp.LIT), 2); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneOre.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneOre.patch index 348c7c96e7..de1396f495 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneOre.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneOre.patch @@ -31,14 +31,14 @@ + if (entity instanceof EntityHuman) { + org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null); + if (!event.isCancelled()) { -+ interact(world.getType(blockposition), world, blockposition, entity); // add entity ++ interact(world.getBlockState(blockposition), world, blockposition, entity); // add entity + super.stepOn(world, blockposition, iblockdata, entity); + } + } else { + EntityInteractEvent event = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ())); + world.getCraftServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { -+ interact(world.getType(blockposition), world, blockposition, entity); // add entity ++ interact(world.getBlockState(blockposition), world, blockposition, entity); // add entity + super.stepOn(world, blockposition, iblockdata, entity); + } + } @@ -48,62 +48,58 @@ @Override @@ -47,7 +68,7 @@ if (world.isClientSide) { - playEffect(world, blockposition); + spawnParticles(world, blockposition); } else { - interact(iblockdata, world, blockposition); + interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman } - ItemStack itemstack = entityhuman.b(enumhand); + ItemStack itemstack = entityhuman.getItemInHand(enumhand); @@ -55,9 +76,14 @@ - return itemstack.getItem() instanceof ItemBlock && (new BlockActionContext(entityhuman, enumhand, itemstack, movingobjectpositionblock)).b() ? EnumInteractionResult.PASS : EnumInteractionResult.SUCCESS; + return itemstack.getItem() instanceof ItemBlock && (new BlockActionContext(entityhuman, enumhand, itemstack, movingobjectpositionblock)).canPlace() ? EnumInteractionResult.PASS : EnumInteractionResult.SUCCESS; } - private static void interact(IBlockData iblockdata, World world, BlockPosition blockposition) { + private static void interact(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { // CraftBukkit - add Entity - playEffect(world, blockposition); - if (!(Boolean) iblockdata.get(BlockRedstoneOre.LIT)) { + spawnParticles(world, blockposition); + if (!(Boolean) iblockdata.getValue(BlockRedstoneOre.LIT)) { + // CraftBukkit start -+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.set(BlockRedstoneOre.LIT, true)).isCancelled()) { ++ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.setValue(BlockRedstoneOre.LIT, true)).isCancelled()) { + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.LIT, true), 3); + world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockRedstoneOre.LIT, true), 3); } @@ -71,6 +97,11 @@ @Override - public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - if ((Boolean) iblockdata.get(BlockRedstoneOre.LIT)) { + public void randomTick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + if ((Boolean) iblockdata.getValue(BlockRedstoneOre.LIT)) { + // CraftBukkit start -+ if (CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, iblockdata.set(BlockRedstoneOre.LIT, false)).isCancelled()) { ++ if (CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, iblockdata.setValue(BlockRedstoneOre.LIT, false)).isCancelled()) { + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.LIT, false), 3); + worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockRedstoneOre.LIT, false), 3); } -@@ -79,12 +110,25 @@ +@@ -79,12 +110,20 @@ @Override - public void dropNaturally(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { - super.dropNaturally(iblockdata, worldserver, blockposition, itemstack); -+ /* CraftBukkit start - Delegated to getExpDrop - if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { - int i = 1 + worldserver.random.nextInt(5); - - this.dropExperience(worldserver, blockposition, i); - } -+ // */ -+ + public void spawnAfterBreak(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { + super.spawnAfterBreak(iblockdata, worldserver, blockposition, itemstack); ++ // CraftBukkit start - Delegated to getExpDrop + } - ++ + @Override + public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { -+ if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { -+ int i = 1 + worldserver.random.nextInt(5); -+ + if (EnchantmentManager.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { + int i = 1 + worldserver.random.nextInt(5); + +- this.popExperience(worldserver, blockposition, i); ++ // this.popExperience(worldserver, blockposition, i); + return i; -+ } + } + + return 0; + // CraftBukkit end } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneTorch.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneTorch.patch index 4d1e0a0099..bf8c4cbc33 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneTorch.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneTorch.patch @@ -16,11 +16,11 @@ + // CraftBukkit start + org.bukkit.plugin.PluginManager manager = worldserver.getCraftServer().getPluginManager(); + org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ int oldCurrent = ((Boolean) iblockdata.get(BlockRedstoneTorch.LIT)).booleanValue() ? 15 : 0; ++ int oldCurrent = ((Boolean) iblockdata.getValue(BlockRedstoneTorch.LIT)).booleanValue() ? 15 : 0; + + BlockRedstoneEvent event = new BlockRedstoneEvent(block, oldCurrent, oldCurrent); + // CraftBukkit end - if ((Boolean) iblockdata.get(BlockRedstoneTorch.LIT)) { + if ((Boolean) iblockdata.getValue(BlockRedstoneTorch.LIT)) { if (flag) { + // CraftBukkit start + if (oldCurrent != 0) { @@ -31,13 +31,13 @@ + } + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, false), 3); - if (a(worldserver, blockposition, true)) { - worldserver.triggerEffect(1502, blockposition, 0); + worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockRedstoneTorch.LIT, false), 3); + if (isToggledTooFrequently(worldserver, blockposition, true)) { + worldserver.levelEvent(1502, blockposition, 0); @@ -86,6 +104,15 @@ } } - } else if (!flag && !a(worldserver, blockposition, false)) { + } else if (!flag && !isToggledTooFrequently(worldserver, blockposition, false)) { + // CraftBukkit start + if (oldCurrent != 15) { + event.setNewCurrent(15); @@ -47,6 +47,6 @@ + } + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, true), 3); + worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockRedstoneTorch.LIT, true), 3); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneWire.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneWire.patch index f2043996cf..9428b11ee1 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneWire.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneWire.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockRedstoneWire.java +++ b/net/minecraft/world/level/block/BlockRedstoneWire.java -@@ -38,6 +38,8 @@ +@@ -37,6 +37,8 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -9,22 +9,13 @@ public class BlockRedstoneWire extends Block { public static final BlockStateEnum<BlockPropertyRedstoneSide> NORTH = BlockProperties.NORTH_REDSTONE; -@@ -55,7 +57,7 @@ - private static final Map<EnumDirection, VoxelShape> SHAPES_FLOOR = Maps.newEnumMap(ImmutableMap.of(EnumDirection.NORTH, Block.a(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), EnumDirection.SOUTH, Block.a(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), EnumDirection.EAST, Block.a(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), EnumDirection.WEST, Block.a(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D))); - private static final Map<EnumDirection, VoxelShape> SHAPES_UP = Maps.newEnumMap(ImmutableMap.of(EnumDirection.NORTH, VoxelShapes.a((VoxelShape) BlockRedstoneWire.SHAPES_FLOOR.get(EnumDirection.NORTH), Block.a(3.0D, 0.0D, 0.0D, 13.0D, 16.0D, 1.0D)), EnumDirection.SOUTH, VoxelShapes.a((VoxelShape) BlockRedstoneWire.SHAPES_FLOOR.get(EnumDirection.SOUTH), Block.a(3.0D, 0.0D, 15.0D, 13.0D, 16.0D, 16.0D)), EnumDirection.EAST, VoxelShapes.a((VoxelShape) BlockRedstoneWire.SHAPES_FLOOR.get(EnumDirection.EAST), Block.a(15.0D, 0.0D, 3.0D, 16.0D, 16.0D, 13.0D)), EnumDirection.WEST, VoxelShapes.a((VoxelShape) BlockRedstoneWire.SHAPES_FLOOR.get(EnumDirection.WEST), Block.a(0.0D, 0.0D, 3.0D, 1.0D, 16.0D, 13.0D)))); - private static final Map<IBlockData, VoxelShape> SHAPES_CACHE = Maps.newHashMap(); -- private static final Vec3D[] COLORS = (Vec3D[]) SystemUtils.a((Object) (new Vec3D[16]), (avec3d) -> { -+ private static final Vec3D[] COLORS = (Vec3D[]) SystemUtils.a((new Vec3D[16]), (avec3d) -> { // CraftBukkit - decompile error - for (int i = 0; i <= 15; ++i) { - float f = (float) i / 15.0F; - float f1 = f * 0.6F + (f > 0.0F ? 0.4F : 0.3F); -@@ -258,7 +260,16 @@ - private void a(World world, BlockPosition blockposition, IBlockData iblockdata) { - int i = this.a(world, blockposition); +@@ -257,7 +259,16 @@ + private void updatePowerStrength(World world, BlockPosition blockposition, IBlockData iblockdata) { + int i = this.calculateTargetStrength(world, blockposition); -- if ((Integer) iblockdata.get(BlockRedstoneWire.POWER) != i) { +- if ((Integer) iblockdata.getValue(BlockRedstoneWire.POWER) != i) { + // CraftBukkit start -+ int oldPower = (Integer) iblockdata.get(BlockRedstoneWire.POWER); ++ int oldPower = (Integer) iblockdata.getValue(BlockRedstoneWire.POWER); + if (oldPower != i) { + BlockRedstoneEvent event = new BlockRedstoneEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), oldPower, i); + world.getCraftServer().getPluginManager().callEvent(event); @@ -33,6 +24,6 @@ + } + if (oldPower != i) { + // CraftBukkit end - if (world.getType(blockposition) == iblockdata) { - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneWire.POWER, i), 2); + if (world.getBlockState(blockposition) == iblockdata) { + world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockRedstoneWire.POWER, i), 2); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockReed.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockReed.patch index dc5abbd775..35b6c8f6ca 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockReed.patch +++ b/paper-server/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 @@ -57,7 +57,7 @@ - int j = (Integer) iblockdata.get(BlockReed.AGE); + int j = (Integer) iblockdata.getValue(BlockReed.AGE); if (j == 15) { -- worldserver.setTypeUpdate(blockposition.up(), this.getBlockData()); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition.up(), this.getBlockData()); // CraftBukkit - worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockReed.AGE, 0), 4); +- 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); } else { - worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockReed.AGE, j + 1), 4); + worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockReed.AGE, j + 1), 4); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSapling.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSapling.patch index 4a45380333..09083a3664 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSapling.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSapling.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockSapling.java +++ b/net/minecraft/world/level/block/BlockSapling.java -@@ -15,12 +15,20 @@ +@@ -14,12 +14,20 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -15,20 +15,20 @@ public static final BlockStateInteger STAGE = BlockProperties.STAGE; protected static final float AABB_OFFSET = 6.0F; - protected static final VoxelShape SHAPE = Block.a(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D); + protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D); private final WorldGenTreeProvider treeGrower; + public static TreeType treeType; // CraftBukkit protected BlockSapling(WorldGenTreeProvider worldgentreeprovider, BlockBase.Info blockbase_info) { super(blockbase_info); -@@ -36,7 +44,30 @@ +@@ -35,7 +43,30 @@ @Override - public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - if (worldserver.getLightLevel(blockposition.up()) >= 9 && random.nextInt(7) == 0) { + public void randomTick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + if (worldserver.getMaxLocalRawBrightness(blockposition.above()) >= 9 && random.nextInt(7) == 0) { + // CraftBukkit start + worldserver.captureTreeGeneration = true; + // CraftBukkit end - this.grow(worldserver, blockposition, iblockdata, random); + this.advanceTree(worldserver, blockposition, iblockdata, random); + // CraftBukkit start + worldserver.captureTreeGeneration = false; + if (worldserver.capturedBlockStates.size() > 0) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockScaffolding.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockScaffolding.patch index dd9fe1c7c1..42ee703114 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockScaffolding.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockScaffolding.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/BlockScaffolding.java +++ b/net/minecraft/world/level/block/BlockScaffolding.java @@ -96,7 +96,7 @@ - int i = a((IBlockAccess) worldserver, blockposition); - IBlockData iblockdata1 = (IBlockData) ((IBlockData) iblockdata.set(BlockScaffolding.DISTANCE, i)).set(BlockScaffolding.BOTTOM, this.a(worldserver, blockposition, i)); + int i = getDistance(worldserver, blockposition); + IBlockData iblockdata1 = (IBlockData) ((IBlockData) iblockdata.setValue(BlockScaffolding.DISTANCE, i)).setValue(BlockScaffolding.BOTTOM, this.isBottom(worldserver, blockposition, i)); -- if ((Integer) iblockdata1.get(BlockScaffolding.DISTANCE) == 7) { -+ if ((Integer) iblockdata1.get(BlockScaffolding.DISTANCE) == 7 && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { // CraftBukkit - BlockFadeEvent - if ((Integer) iblockdata.get(BlockScaffolding.DISTANCE) == 7) { - worldserver.addEntity(new EntityFallingBlock(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (IBlockData) iblockdata1.set(BlockScaffolding.WATERLOGGED, false))); +- if ((Integer) iblockdata1.getValue(BlockScaffolding.DISTANCE) == 7) { ++ if ((Integer) iblockdata1.getValue(BlockScaffolding.DISTANCE) == 7 && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { // CraftBukkit - BlockFadeEvent + if ((Integer) iblockdata.getValue(BlockScaffolding.DISTANCE) == 7) { + worldserver.addFreshEntity(new EntityFallingBlock(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (IBlockData) iblockdata1.setValue(BlockScaffolding.WATERLOGGED, false))); } else { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSnow.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSnow.patch index 73190bf361..1f94c57767 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSnow.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSnow.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/BlockSnow.java +++ b/net/minecraft/world/level/block/BlockSnow.java -@@ -87,6 +87,11 @@ +@@ -86,6 +86,11 @@ @Override - public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + public void randomTick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { if (worldserver.getBrightness(EnumSkyBlock.BLOCK, blockposition) > 11) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - c(iblockdata, (World) worldserver, blockposition); - worldserver.a(blockposition, false); + dropResources(iblockdata, worldserver, blockposition); + worldserver.removeBlock(blockposition, false); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSoil.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSoil.patch index 2d8f45736b..b49b2bcbec 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSoil.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSoil.patch @@ -14,16 +14,16 @@ public static final BlockStateInteger MOISTURE = BlockProperties.MOISTURE; @@ -82,26 +87,49 @@ - if (!a((IWorldReader) worldserver, blockposition) && !worldserver.isRainingAt(blockposition.up())) { + if (!isNearWater(worldserver, blockposition) && !worldserver.isRainingAt(blockposition.above())) { if (i > 0) { -- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, i - 1), 2); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, i - 1), 2); // CraftBukkit - } else if (!a((IBlockAccess) worldserver, blockposition)) { - fade(iblockdata, worldserver, blockposition); +- worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockSoil.MOISTURE, i - 1), 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(worldserver, blockposition, (IBlockData) iblockdata.setValue(BlockSoil.MOISTURE, i - 1), 2); // CraftBukkit + } else if (!isUnderCrops(worldserver, blockposition)) { + turnToDirt(iblockdata, worldserver, blockposition); } } else if (i < 7) { -- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, 7), 2); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, 7), 2); // CraftBukkit +- worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockSoil.MOISTURE, 7), 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(worldserver, blockposition, (IBlockData) iblockdata.setValue(BlockSoil.MOISTURE, 7), 2); // CraftBukkit } } @@ -31,7 +31,7 @@ @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. - if (!world.isClientSide && world.random.nextFloat() < f - 0.5F && entity instanceof EntityLiving && (entity instanceof EntityHuman || world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) && entity.getWidth() * entity.getWidth() * entity.getHeight() > 0.512F) { + if (!world.isClientSide && world.random.nextFloat() < f - 0.5F && entity instanceof EntityLiving && (entity instanceof EntityHuman || world.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) { @@ -45,23 +45,23 @@ + return; + } + -+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) { ++ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - fade(iblockdata, world, blockposition); + turnToDirt(iblockdata, world, blockposition); } - super.fallOn(world, iblockdata, blockposition, entity, f); + // super.fallOn(world, iblockdata, blockposition, entity, f); // CraftBukkit - moved up } - public static void fade(IBlockData iblockdata, World world, BlockPosition blockposition) { + public static void turnToDirt(IBlockData iblockdata, World world, BlockPosition blockposition) { + // CraftBukkit start -+ if (CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) { ++ if (CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.DIRT.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - world.setTypeUpdate(blockposition, a(iblockdata, Blocks.DIRT.getBlockData(), world, blockposition)); + world.setBlockAndUpdate(blockposition, pushEntitiesUp(iblockdata, Blocks.DIRT.defaultBlockState(), world, blockposition)); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSponge.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSponge.patch index 1c54acb6a3..c07e213a2b 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSponge.patch +++ b/paper-server/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 @@ +@@ -14,6 +14,13 @@ import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Material; @@ -14,7 +14,7 @@ public class BlockSponge extends Block { public static final int MAX_DEPTH = 6; -@@ -50,6 +57,7 @@ +@@ -49,6 +56,7 @@ queue.add(new Tuple<>(blockposition, 0)); int i = 0; @@ -22,46 +22,46 @@ while (!queue.isEmpty()) { Tuple<BlockPosition, Integer> tuple = (Tuple) queue.poll(); -@@ -61,27 +69,31 @@ +@@ -60,27 +68,31 @@ for (int l = 0; l < k; ++l) { EnumDirection enumdirection = aenumdirection[l]; - BlockPosition blockposition2 = blockposition1.shift(enumdirection); -- IBlockData iblockdata = world.getType(blockposition2); -- Fluid fluid = world.getFluid(blockposition2); + BlockPosition blockposition2 = blockposition1.relative(enumdirection); +- IBlockData iblockdata = world.getBlockState(blockposition2); +- Fluid fluid = world.getFluidState(blockposition2); + // CraftBukkit start -+ IBlockData iblockdata = blockList.getType(blockposition2); -+ Fluid fluid = blockList.getFluid(blockposition2); ++ IBlockData iblockdata = blockList.getBlockState(blockposition2); ++ Fluid fluid = blockList.getFluidState(blockposition2); + // CraftBukkit end Material material = iblockdata.getMaterial(); - if (fluid.a((Tag) TagsFluid.WATER)) { -- if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).removeFluid(world, blockposition2, iblockdata).isEmpty()) { -+ if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).removeFluid(blockList, blockposition2, iblockdata).isEmpty()) { // CraftBukkit + if (fluid.is((Tag) TagsFluid.WATER)) { +- if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).pickupBlock(world, blockposition2, iblockdata).isEmpty()) { ++ if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).pickupBlock(blockList, blockposition2, iblockdata).isEmpty()) { // CraftBukkit ++i; if (j < 6) { queue.add(new Tuple<>(blockposition2, j + 1)); } } else if (iblockdata.getBlock() instanceof BlockFluids) { -- world.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3); -+ blockList.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3); // CraftBukkit +- world.setBlock(blockposition2, Blocks.AIR.defaultBlockState(), 3); ++ blockList.setBlock(blockposition2, Blocks.AIR.defaultBlockState(), 3); // CraftBukkit ++i; if (j < 6) { queue.add(new Tuple<>(blockposition2, j + 1)); } } else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) { -- TileEntity tileentity = iblockdata.isTileEntity() ? world.getTileEntity(blockposition2) : null; +- TileEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition2) : null; + // CraftBukkit start -+ // TileEntity tileentity = iblockdata.isTileEntity() ? world.getTileEntity(blockposition2) : null; ++ // TileEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition2) : null; -- a(iblockdata, (GeneratorAccess) world, blockposition2, tileentity); -- world.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3); -+ // a(iblockdata, (GeneratorAccess) world, blockposition2, tileentity); -+ blockList.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3); +- dropResources(iblockdata, world, blockposition2, tileentity); +- world.setBlock(blockposition2, Blocks.AIR.defaultBlockState(), 3); ++ // dropResources(iblockdata, world, blockposition2, tileentity); ++ blockList.setBlock(blockposition2, Blocks.AIR.defaultBlockState(), 3); + // CraftBukkit end ++i; if (j < 6) { queue.add(new Tuple<>(blockposition2, j + 1)); -@@ -94,6 +106,39 @@ +@@ -93,6 +105,39 @@ break; } } @@ -79,22 +79,22 @@ + + for (CraftBlockState block : blocks) { + BlockPosition blockposition2 = block.getPosition(); -+ IBlockData iblockdata = world.getType(blockposition2); -+ Fluid fluid = world.getFluid(blockposition2); ++ IBlockData iblockdata = world.getBlockState(blockposition2); ++ Fluid fluid = world.getFluidState(blockposition2); + Material material = iblockdata.getMaterial(); + -+ if (fluid.a(TagsFluid.WATER)) { -+ if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).removeFluid(blockList, blockposition2, iblockdata).isEmpty()) { ++ if (fluid.is(TagsFluid.WATER)) { ++ if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).pickupBlock(blockList, blockposition2, iblockdata).isEmpty()) { + // NOP + } else if (iblockdata.getBlock() instanceof BlockFluids) { + // NOP + } else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) { -+ TileEntity tileentity = iblockdata.isTileEntity() ? world.getTileEntity(blockposition2) : null; ++ TileEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition2) : null; + -+ a(iblockdata, world, blockposition2, tileentity); ++ dropResources(iblockdata, world, blockposition2, tileentity); + } + } -+ world.setTypeAndData(blockposition2, block.getHandle(), block.getFlag()); ++ world.setBlock(blockposition2, block.getHandle(), block.getFlag()); + } + } + // CraftBukkit end diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockStem.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockStem.patch index 08787546bc..4361a41d40 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockStem.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockStem.patch @@ -12,30 +12,30 @@ @@ -57,14 +59,18 @@ if (i < 7) { - iblockdata = (IBlockData) iblockdata.set(BlockStem.AGE, i + 1); -- worldserver.setTypeAndData(blockposition, iblockdata, 2); + iblockdata = (IBlockData) iblockdata.setValue(BlockStem.AGE, i + 1); +- worldserver.setBlock(blockposition, iblockdata, 2); + CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata, 2); // CraftBukkit } else { - EnumDirection enumdirection = EnumDirection.EnumDirectionLimit.HORIZONTAL.a(random); - BlockPosition blockposition1 = blockposition.shift(enumdirection); - IBlockData iblockdata1 = worldserver.getType(blockposition1.down()); + EnumDirection enumdirection = EnumDirection.EnumDirectionLimit.HORIZONTAL.getRandomDirection(random); + BlockPosition blockposition1 = blockposition.relative(enumdirection); + IBlockData iblockdata1 = worldserver.getBlockState(blockposition1.below()); - if (worldserver.getType(blockposition1).isAir() && (iblockdata1.a(Blocks.FARMLAND) || iblockdata1.a((Tag) TagsBlock.DIRT))) { -- worldserver.setTypeUpdate(blockposition1, this.fruit.getBlockData()); + if (worldserver.getBlockState(blockposition1).isAir() && (iblockdata1.is(Blocks.FARMLAND) || iblockdata1.is((Tag) TagsBlock.DIRT))) { +- worldserver.setBlockAndUpdate(blockposition1, this.fruit.defaultBlockState()); + // CraftBukkit start -+ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, this.fruit.getBlockData())) { ++ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, this.fruit.defaultBlockState())) { + return; + } + // CraftBukkit end - worldserver.setTypeUpdate(blockposition, (IBlockData) this.fruit.d().getBlockData().set(BlockFacingHorizontal.FACING, enumdirection)); + worldserver.setBlockAndUpdate(blockposition, (IBlockData) this.fruit.getAttachedStem().defaultBlockState().setValue(BlockFacingHorizontal.FACING, enumdirection)); } } @@ -93,7 +99,7 @@ - int i = Math.min(7, (Integer) iblockdata.get(BlockStem.AGE) + MathHelper.nextInt(worldserver.random, 2, 5)); - IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockStem.AGE, i); + int i = Math.min(7, (Integer) iblockdata.getValue(BlockStem.AGE) + MathHelper.nextInt(worldserver.random, 2, 5)); + IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockStem.AGE, i); -- worldserver.setTypeAndData(blockposition, iblockdata1, 2); +- worldserver.setBlock(blockposition, iblockdata1, 2); + CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata1, 2); // CraftBukkit if (i == 7) { - iblockdata1.b(worldserver, blockposition, worldserver.random); + iblockdata1.randomTick(worldserver, blockposition, worldserver.random); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch index 5d6ee0d514..2e6927b0a7 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch @@ -16,20 +16,20 @@ private static final float HURT_SPEED_THRESHOLD = 0.003F; @@ -59,7 +67,7 @@ - int i = (Integer) iblockdata.get(BlockSweetBerryBush.AGE); + int i = (Integer) iblockdata.getValue(BlockSweetBerryBush.AGE); - if (i < 3 && random.nextInt(5) == 0 && worldserver.getLightLevel(blockposition.up(), 0) >= 9) { -- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.AGE, i + 1), 2); -+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.AGE, i + 1), 2); // CraftBukkit + if (i < 3 && random.nextInt(5) == 0 && worldserver.getRawBrightness(blockposition.above(), 0) >= 9) { +- worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockSweetBerryBush.AGE, i + 1), 2); ++ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, (IBlockData) iblockdata.setValue(BlockSweetBerryBush.AGE, i + 1), 2); // CraftBukkit } } @@ -73,7 +81,9 @@ - double d1 = Math.abs(entity.locZ() - entity.zOld); + double d1 = Math.abs(entity.getZ() - entity.zOld); if (d0 >= 0.003000000026077032D || d1 >= 0.003000000026077032D) { + CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); // CraftBukkit - entity.damageEntity(DamageSource.SWEET_BERRY_BUSH, 1.0F); + entity.hurt(DamageSource.SWEET_BERRY_BUSH, 1.0F); + CraftEventFactory.blockDamage = null; // CraftBukkit } } @@ -38,16 +38,16 @@ } else if (i > 1) { int j = 1 + world.random.nextInt(2); -- a(world, blockposition, new ItemStack(Items.SWEET_BERRIES, j + (flag ? 1 : 0))); +- popResource(world, blockposition, new ItemStack(Items.SWEET_BERRIES, j + (flag ? 1 : 0))); + // CraftBukkit start + PlayerHarvestBlockEvent event = CraftEventFactory.callPlayerHarvestBlockEvent(world, blockposition, entityhuman, Collections.singletonList(new ItemStack(Items.SWEET_BERRIES, j + (flag ? 1 : 0)))); + if (event.isCancelled()) { + return EnumInteractionResult.SUCCESS; // We need to return a success either way, because making it PASS or FAIL will result in a bug where cancelling while harvesting w/ block in hand places block + } + for (org.bukkit.inventory.ItemStack itemStack : event.getItemsHarvested()) { -+ a(world, blockposition, CraftItemStack.asNMSCopy(itemStack)); ++ 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.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.AGE, 1), 2); - return EnumInteractionResult.a(world.isClientSide); + world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockSweetBerryBush.AGE, 1), 2); + return EnumInteractionResult.sidedSuccess(world.isClientSide); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockTNT.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockTNT.patch index 436da06694..c4f7b41b80 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockTNT.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockTNT.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/BlockTNT.java +++ b/net/minecraft/world/level/block/BlockTNT.java @@ -121,6 +121,11 @@ - Entity entity = iprojectile.getShooter(); + Entity entity = iprojectile.getOwner(); - if (iprojectile.isBurning() && iprojectile.a(world, blockposition)) { + if (iprojectile.isOnFire() && iprojectile.mayInteract(world, blockposition)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - a(world, blockposition, entity instanceof EntityLiving ? (EntityLiving) entity : null); - world.a(blockposition, false); + explode(world, blockposition, entity instanceof EntityLiving ? (EntityLiving) entity : null); + world.removeBlock(blockposition, false); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockTallPlant.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockTallPlant.patch index 425b550426..edd9e36513 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockTallPlant.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockTallPlant.patch @@ -3,12 +3,12 @@ @@ -92,6 +92,11 @@ } - protected static void b(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) { + protected static void preventCreativeDropFromBottomPart(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, blockposition).isCancelled()) { + return; + } + // CraftBukkit end - BlockPropertyDoubleBlockHalf blockpropertydoubleblockhalf = (BlockPropertyDoubleBlockHalf) iblockdata.get(BlockTallPlant.HALF); + BlockPropertyDoubleBlockHalf blockpropertydoubleblockhalf = (BlockPropertyDoubleBlockHalf) iblockdata.getValue(BlockTallPlant.HALF); if (blockpropertydoubleblockhalf == BlockPropertyDoubleBlockHalf.UPPER) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch index 57c378b1d2..341da79239 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockTrapdoor.java +++ b/net/minecraft/world/level/block/BlockTrapdoor.java -@@ -29,6 +29,8 @@ +@@ -27,6 +27,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -9,23 +9,23 @@ public class BlockTrapdoor extends BlockFacingHorizontal implements IBlockWaterlogged { public static final BlockStateBoolean OPEN = BlockProperties.OPEN; -@@ -117,6 +119,19 @@ - boolean flag1 = world.isBlockIndirectlyPowered(blockposition); +@@ -115,6 +117,19 @@ + boolean flag1 = world.hasNeighborSignal(blockposition); - if (flag1 != (Boolean) iblockdata.get(BlockTrapdoor.POWERED)) { + if (flag1 != (Boolean) iblockdata.getValue(BlockTrapdoor.POWERED)) { + // CraftBukkit start + org.bukkit.World bworld = world.getWorld(); + org.bukkit.block.Block bblock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + + int power = bblock.getBlockPower(); -+ int oldPower = (Boolean) iblockdata.get(OPEN) ? 15 : 0; ++ int oldPower = (Boolean) iblockdata.getValue(OPEN) ? 15 : 0; + -+ if (oldPower == 0 ^ power == 0 || block.getBlockData().isPowerSource()) { ++ if (oldPower == 0 ^ power == 0 || block.defaultBlockState().isSignalSource()) { + BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bblock, oldPower, power); + world.getCraftServer().getPluginManager().callEvent(eventRedstone); + flag1 = eventRedstone.getNewCurrent() > 0; + } + // CraftBukkit end - if ((Boolean) iblockdata.get(BlockTrapdoor.OPEN) != flag1) { - iblockdata = (IBlockData) iblockdata.set(BlockTrapdoor.OPEN, flag1); - this.a((EntityHuman) null, world, blockposition, flag1); + if ((Boolean) iblockdata.getValue(BlockTrapdoor.OPEN) != flag1) { + iblockdata = (IBlockData) iblockdata.setValue(BlockTrapdoor.OPEN, flag1); + this.playSound((EntityHuman) null, world, blockposition, flag1); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockTripwire.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockTripwire.patch index c4d20d38c2..fba98e72c6 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockTripwire.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockTripwire.patch @@ -14,7 +14,7 @@ } + // CraftBukkit start - Call interact even when triggering connected tripwire -+ if (flag != flag1 && flag1 && (Boolean)iblockdata.get(ATTACHED)) { ++ if (flag != flag1 && flag1 && (Boolean)iblockdata.getValue(ATTACHED)) { + org.bukkit.World bworld = world.getWorld(); + org.bukkit.plugin.PluginManager manager = world.getCraftServer().getPluginManager(); + org.bukkit.block.Block block = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); @@ -48,5 +48,5 @@ + // CraftBukkit end + if (flag1 != flag) { - iblockdata = (IBlockData) iblockdata.set(BlockTripwire.POWERED, flag1); - world.setTypeAndData(blockposition, iblockdata, 3); + iblockdata = (IBlockData) iblockdata.setValue(BlockTripwire.POWERED, flag1); + world.setBlock(blockposition, iblockdata, 3); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockTripwireHook.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockTripwireHook.patch index fb38f3f955..b2ebd01343 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockTripwireHook.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockTripwireHook.patch @@ -10,7 +10,7 @@ public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING; @@ -160,6 +162,17 @@ - this.a(world, blockposition1, flag4, flag5, flag2, flag3); + this.playSound(world, blockposition1, flag4, flag5, flag2, flag3); } + // CraftBukkit start @@ -24,6 +24,6 @@ + } + // CraftBukkit end + - this.a(world, blockposition, flag4, flag5, flag2, flag3); + this.playSound(world, blockposition, flag4, flag5, flag2, flag3); if (!flag) { - world.setTypeAndData(blockposition, (IBlockData) iblockdata3.set(BlockTripwireHook.FACING, enumdirection), 3); + world.setBlock(blockposition, (IBlockData) iblockdata3.setValue(BlockTripwireHook.FACING, enumdirection), 3); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch index 7e1e860229..5885d8f28b 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch @@ -14,9 +14,9 @@ public static final int MAX_HATCH_LEVEL = 2; @@ -62,6 +68,19 @@ - private void a(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, int i) { - if (this.a(world, entity)) { - if (!world.isClientSide && world.random.nextInt(i) == 0 && iblockdata.a(Blocks.TURTLE_EGG)) { + private void destroyEgg(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, int i) { + if (this.canDestroyEgg(world, entity)) { + if (!world.isClientSide && world.random.nextInt(i) == 0 && iblockdata.is(Blocks.TURTLE_EGG)) { + // CraftBukkit start - Step on eggs + org.bukkit.event.Cancellable cancellable; + if (entity instanceof EntityHuman) { @@ -30,36 +30,36 @@ + return; + } + // CraftBukkit end - this.a(world, blockposition, iblockdata); + this.decreaseEggs(world, blockposition, iblockdata); } @@ -87,9 +106,19 @@ - int i = (Integer) iblockdata.get(BlockTurtleEgg.HATCH); + int i = (Integer) iblockdata.getValue(BlockTurtleEgg.HATCH); if (i < 2) { + // CraftBukkit start - Call BlockGrowEvent -+ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata.set(BlockTurtleEgg.HATCH, i + 1), 2)) { ++ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata.setValue(BlockTurtleEgg.HATCH, i + 1), 2)) { + return; + } + // CraftBukkit end worldserver.playSound((EntityHuman) null, blockposition, SoundEffects.TURTLE_EGG_CRACK, SoundCategory.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F); -- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockTurtleEgg.HATCH, i + 1), 2); -+ // worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockTurtleEgg.a, i + 1), 2); // CraftBukkit - handled above +- 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 } else { + // CraftBukkit start - Call BlockFadeEvent -+ if (CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { ++ 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 + random.nextFloat() * 0.2F); - worldserver.a(blockposition, false); + worldserver.removeBlock(blockposition, false); @@ -100,7 +129,7 @@ - entityturtle.setAgeRaw(-24000); + entityturtle.setAge(-24000); entityturtle.setHomePos(blockposition); - entityturtle.setPositionRotation((double) blockposition.getX() + 0.3D + (double) j * 0.2D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.3D, 0.0F, 0.0F); -- worldserver.addEntity(entityturtle); -+ worldserver.addEntity(entityturtle, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); // CraftBukkit + entityturtle.moveTo((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/paper-server/nms-patches/net/minecraft/world/level/block/BlockVine.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockVine.patch index 64a3121d9f..12ff380abc 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockVine.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockVine.patch @@ -10,49 +10,49 @@ public static final BlockStateBoolean UP = BlockSprawling.UP; @@ -196,20 +198,24 @@ - BlockPosition blockposition3 = blockposition2.shift(enumdirection1); - BlockPosition blockposition4 = blockposition2.shift(enumdirection2); + BlockPosition blockposition3 = blockposition2.relative(enumdirection1); + BlockPosition blockposition4 = blockposition2.relative(enumdirection2); + // CraftBukkit start - Call BlockSpreadEvent + BlockPosition source = blockposition; + - if (flag && a((IBlockAccess) worldserver, blockposition3, enumdirection1)) { -- worldserver.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection1), true), 2); -+ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection1), true), 2); - } else if (flag1 && a((IBlockAccess) worldserver, blockposition4, enumdirection2)) { -- worldserver.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection2), true), 2); -+ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection2), true), 2); + if (flag && isAcceptableNeighbour(worldserver, blockposition3, enumdirection1)) { +- worldserver.setBlock(blockposition2, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection1), true), 2); ++ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition2, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection1), true), 2); + } else if (flag1 && isAcceptableNeighbour(worldserver, blockposition4, enumdirection2)) { +- worldserver.setBlock(blockposition2, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection2), true), 2); ++ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition2, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection2), true), 2); } else { - EnumDirection enumdirection3 = enumdirection.opposite(); + EnumDirection enumdirection3 = enumdirection.getOpposite(); - if (flag && worldserver.isEmpty(blockposition3) && a((IBlockAccess) worldserver, blockposition.shift(enumdirection1), enumdirection3)) { -- worldserver.setTypeAndData(blockposition3, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), true), 2); -+ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition3, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), true), 2); - } else if (flag1 && worldserver.isEmpty(blockposition4) && a((IBlockAccess) worldserver, blockposition.shift(enumdirection2), enumdirection3)) { -- worldserver.setTypeAndData(blockposition4, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), true), 2); -+ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition4, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), true), 2); - } else if ((double) random.nextFloat() < 0.05D && a((IBlockAccess) worldserver, blockposition2.up(), EnumDirection.UP)) { -- worldserver.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(BlockVine.UP, true), 2); -+ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition2, (IBlockData) this.getBlockData().set(BlockVine.UP, true), 2); + if (flag && worldserver.isEmptyBlock(blockposition3) && isAcceptableNeighbour(worldserver, blockposition.relative(enumdirection1), enumdirection3)) { +- worldserver.setBlock(blockposition3, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection3), true), 2); ++ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition3, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection3), true), 2); + } else if (flag1 && worldserver.isEmptyBlock(blockposition4) && isAcceptableNeighbour(worldserver, blockposition.relative(enumdirection2), enumdirection3)) { +- worldserver.setBlock(blockposition4, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection3), true), 2); ++ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition4, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection3), true), 2); + } else if ((double) random.nextFloat() < 0.05D && isAcceptableNeighbour(worldserver, blockposition2.above(), EnumDirection.UP)) { +- worldserver.setBlock(blockposition2, (IBlockData) this.defaultBlockState().setValue(BlockVine.UP, true), 2); ++ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition2, (IBlockData) this.defaultBlockState().setValue(BlockVine.UP, true), 2); } + // CraftBukkit end } - } else if (a((IBlockAccess) worldserver, blockposition2, enumdirection)) { - worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(getDirection(enumdirection), true), 2); + } else if (isAcceptableNeighbour(worldserver, blockposition2, enumdirection)) { + worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(getPropertyForFace(enumdirection), true), 2); @@ -239,7 +245,7 @@ } - if (this.canSpread(iblockdata2)) { -- worldserver.setTypeAndData(blockposition1, iblockdata2, 2); + if (this.hasHorizontalConnection(iblockdata2)) { +- worldserver.setBlock(blockposition1, iblockdata2, 2); + CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, iblockdata2, 2); // CraftBukkit } return; @@ -254,7 +260,7 @@ - IBlockData iblockdata4 = this.a(iblockdata, iblockdata3, random); + IBlockData iblockdata4 = this.copyRandomFaces(iblockdata, iblockdata3, random); - if (iblockdata3 != iblockdata4 && this.canSpread(iblockdata4)) { -- worldserver.setTypeAndData(blockposition2, iblockdata4, 2); + if (iblockdata3 != iblockdata4 && this.hasHorizontalConnection(iblockdata4)) { +- worldserver.setBlock(blockposition2, iblockdata4, 2); + CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition2, iblockdata4, 2); // CraftBukkit } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockWaterLily.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockWaterLily.patch index ab1490aa63..44068eccf8 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockWaterLily.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockWaterLily.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/world/level/block/BlockWaterLily.java @@ -25,7 +25,7 @@ @Override - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { - super.a(iblockdata, world, blockposition, entity); + public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + super.entityInside(iblockdata, world, blockposition, entity); - if (world instanceof WorldServer && entity instanceof EntityBoat) { -+ if (world instanceof WorldServer && entity instanceof EntityBoat && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { // CraftBukkit - world.a(new BlockPosition(blockposition), true, entity); ++ if (world instanceof WorldServer && entity instanceof EntityBoat && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { // CraftBukkit + world.destroyBlock(new BlockPosition(blockposition), true, entity); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch index b09c1cf829..7a3a2730ad 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch @@ -3,7 +3,7 @@ @@ -51,7 +51,7 @@ EntityLiving entityliving = (EntityLiving) entity; - if (!entityliving.isInvulnerable(DamageSource.WITHER)) { + if (!entityliving.isInvulnerableTo(DamageSource.WITHER)) { - entityliving.addEffect(new MobEffect(MobEffects.WITHER, 40)); + entityliving.addEffect(new MobEffect(MobEffects.WITHER, 40), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.WITHER_ROSE); // CraftBukkit } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch index da107d1243..cd20a0b804 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch @@ -15,50 +15,50 @@ @@ -50,6 +55,7 @@ } - public static void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) { + public static void checkSpawn(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) { + if (world.captureBlockStates) return; // CraftBukkit if (!world.isClientSide) { - IBlockData iblockdata = tileentityskull.getBlock(); - boolean flag = iblockdata.a(Blocks.WITHER_SKELETON_SKULL) || iblockdata.a(Blocks.WITHER_SKELETON_WALL_SKULL); + IBlockData iblockdata = tileentityskull.getBlockState(); + boolean flag = iblockdata.is(Blocks.WITHER_SKELETON_SKULL) || iblockdata.is(Blocks.WITHER_SKELETON_WALL_SKULL); @@ -59,12 +65,14 @@ - ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.a(world, blockposition); + ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.find(world, blockposition); if (shapedetector_shapedetectorcollection != null) { + // CraftBukkit start - Use BlockStateListPopulator + BlockStateListPopulator blockList = new BlockStateListPopulator(world); - for (int i = 0; i < shapedetector.c(); ++i) { - for (int j = 0; j < shapedetector.b(); ++j) { - ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(i, j, 0); + for (int i = 0; i < shapedetector.getWidth(); ++i) { + for (int j = 0; j < shapedetector.getHeight(); ++j) { + ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.getBlock(i, j, 0); -- world.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2); -- world.triggerEffect(2001, shapedetectorblock.getPosition(), Block.getCombinedId(shapedetectorblock.a())); -+ blockList.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit -+ // world.triggerEffect(2001, shapedetectorblock.getPosition(), Block.getCombinedId(shapedetectorblock.a())); // CraftBukkit +- world.setBlock(shapedetectorblock.getPos(), Blocks.AIR.defaultBlockState(), 2); +- world.levelEvent(2001, shapedetectorblock.getPos(), Block.getId(shapedetectorblock.getState())); ++ blockList.setBlock(shapedetectorblock.getPos(), Blocks.AIR.defaultBlockState(), 2); // CraftBukkit ++ // world.levelEvent(2001, shapedetectorblock.getPos(), Block.getId(shapedetectorblock.getState())); // CraftBukkit } } @@ -74,6 +82,15 @@ - entitywither.setPositionRotation((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.55D, (double) blockposition1.getZ() + 0.5D, shapedetector_shapedetectorcollection.getFacing().n() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F); - entitywither.yBodyRot = shapedetector_shapedetectorcollection.getFacing().n() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F; - entitywither.beginSpawnSequence(); + 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.yBodyRot = shapedetector_shapedetectorcollection.getForwards().getAxis() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F; + entitywither.makeInvulnerable(); + // CraftBukkit start -+ if (!world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) { ++ if (!world.addFreshEntity(entitywither, SpawnReason.BUILD_WITHER)) { + return; + } + for (BlockPosition pos : blockList.getBlocks()) { -+ world.triggerEffect(2001, pos, Block.getCombinedId(world.getType(pos))); ++ world.levelEvent(2001, pos, Block.getId(world.getBlockState(pos))); + } + blockList.updateList(); + // CraftBukkit end - Iterator iterator = world.a(EntityPlayer.class, entitywither.getBoundingBox().g(50.0D)).iterator(); + Iterator iterator = world.getEntitiesOfClass(EntityPlayer.class, entitywither.getBoundingBox().inflate(50.0D)).iterator(); while (iterator.hasNext()) { @@ -82,7 +99,7 @@ - CriterionTriggers.SUMMONED_ENTITY.a(entityplayer, (Entity) entitywither); + CriterionTriggers.SUMMONED_ENTITY.trigger(entityplayer, (Entity) entitywither); } -- world.addEntity(entitywither); -+ // world.addEntity(entitywither); // CraftBukkit - moved up +- world.addFreshEntity(entitywither); ++ // world.addFreshEntity(entitywither); // CraftBukkit - moved up - for (int k = 0; k < shapedetector.c(); ++k) { - for (int l = 0; l < shapedetector.b(); ++l) { + for (int k = 0; k < shapedetector.getWidth(); ++k) { + for (int l = 0; l < shapedetector.getHeight(); ++l) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BuddingAmethystBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BuddingAmethystBlock.patch index aa753f7fe9..e778875c32 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BuddingAmethystBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BuddingAmethystBlock.patch @@ -2,9 +2,9 @@ +++ b/net/minecraft/world/level/block/BuddingAmethystBlock.java @@ -44,7 +44,7 @@ if (block != null) { - IBlockData iblockdata2 = (IBlockData) ((IBlockData) block.getBlockData().set(AmethystClusterBlock.FACING, enumdirection)).set(AmethystClusterBlock.WATERLOGGED, iblockdata1.getFluid().getType() == FluidTypes.WATER); + IBlockData iblockdata2 = (IBlockData) ((IBlockData) block.defaultBlockState().setValue(AmethystClusterBlock.FACING, enumdirection)).setValue(AmethystClusterBlock.WATERLOGGED, iblockdata1.getFluidState().getType() == FluidTypes.WATER); -- worldserver.setTypeUpdate(blockposition1, iblockdata2); +- worldserver.setBlockAndUpdate(blockposition1, iblockdata2); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, iblockdata2); // CraftBukkit } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/CaveVines.patch b/paper-server/nms-patches/net/minecraft/world/level/block/CaveVines.patch index 6dc0cee918..63d3d0aae4 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/CaveVines.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/CaveVines.patch @@ -14,15 +14,15 @@ + public interface CaveVines { - VoxelShape SHAPE = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D); + VoxelShape SHAPE = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D); BlockStateBoolean BERRIES = BlockProperties.BERRIES; -- static EnumInteractionResult harvest(IBlockData iblockdata, World world, BlockPosition blockposition) { -+ static EnumInteractionResult harvest(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { - if ((Boolean) iblockdata.get(CaveVines.BERRIES)) { -- Block.a(world, blockposition, new ItemStack(Items.GLOW_BERRIES, 1)); +- static EnumInteractionResult use(IBlockData iblockdata, World world, BlockPosition blockposition) { ++ static EnumInteractionResult use(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + if ((Boolean) iblockdata.getValue(CaveVines.BERRIES)) { +- Block.popResource(world, blockposition, new ItemStack(Items.GLOW_BERRIES, 1)); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, (IBlockData) iblockdata.set(CaveVines.BERRIES, false)).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, (IBlockData) iblockdata.setValue(CaveVines.BERRIES, false)).isCancelled()) { + return EnumInteractionResult.SUCCESS; + } + @@ -32,13 +32,13 @@ + return EnumInteractionResult.SUCCESS; // We need to return a success either way, because making it PASS or FAIL will result in a bug where cancelling while harvesting w/ block in hand places block + } + for (org.bukkit.inventory.ItemStack itemStack : event.getItemsHarvested()) { -+ Block.a(world, blockposition, CraftItemStack.asNMSCopy(itemStack)); ++ Block.popResource(world, blockposition, CraftItemStack.asNMSCopy(itemStack)); + } + } else { -+ Block.a(world, blockposition, new ItemStack(Items.GLOW_BERRIES, 1)); ++ Block.popResource(world, blockposition, new ItemStack(Items.GLOW_BERRIES, 1)); + } + // CraftBukkit end + - float f = MathHelper.b(world.random, 0.8F, 1.2F); + 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); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/CaveVinesBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/CaveVinesBlock.patch index b938347ae1..aca985b880 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/CaveVinesBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/CaveVinesBlock.patch @@ -3,9 +3,9 @@ @@ -57,7 +57,7 @@ @Override - public EnumInteractionResult interact(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) { -- return CaveVines.harvest(iblockdata, world, blockposition); -+ return CaveVines.harvest(iblockdata, world, blockposition, entityhuman); // CraftBukkit + public EnumInteractionResult use(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) { +- return CaveVines.use(iblockdata, world, blockposition); ++ return CaveVines.use(iblockdata, world, blockposition, entityhuman); // CraftBukkit } @Override diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/CaveVinesPlantBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/CaveVinesPlantBlock.patch index f9836c2acb..57f58da3f9 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/CaveVinesPlantBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/CaveVinesPlantBlock.patch @@ -3,9 +3,9 @@ @@ -40,7 +40,7 @@ @Override - public EnumInteractionResult interact(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) { -- return CaveVines.harvest(iblockdata, world, blockposition); -+ return CaveVines.harvest(iblockdata, world, blockposition, entityhuman); // CraftBukkit + public EnumInteractionResult use(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) { +- return CaveVines.use(iblockdata, world, blockposition); ++ return CaveVines.use(iblockdata, world, blockposition, entityhuman); // CraftBukkit } @Override diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/ChangeOverTimeBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/ChangeOverTimeBlock.patch index a4f2d3d1e4..6710bebed4 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/ChangeOverTimeBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/ChangeOverTimeBlock.patch @@ -3,8 +3,8 @@ @@ -69,7 +69,7 @@ if (random.nextFloat() < f1) { - this.a(iblockdata).ifPresent((iblockdata2) -> { -- worldserver.setTypeUpdate(blockposition, iblockdata2); + this.getNext(iblockdata).ifPresent((iblockdata2) -> { +- worldserver.setBlockAndUpdate(blockposition, iblockdata2); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(worldserver, blockposition, iblockdata2); // CraftBukkit }); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/LayeredCauldronBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/LayeredCauldronBlock.patch index aa7893e6fa..0f125e2c92 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/LayeredCauldronBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/LayeredCauldronBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/LayeredCauldronBlock.java +++ b/net/minecraft/world/level/block/LayeredCauldronBlock.java -@@ -17,6 +17,12 @@ +@@ -16,6 +16,12 @@ import net.minecraft.world.level.material.FluidType; import net.minecraft.world.level.material.FluidTypes; @@ -13,36 +13,36 @@ public class LayeredCauldronBlock extends AbstractCauldronBlock { public static final int MIN_FILL_LEVEL = 1; -@@ -56,10 +62,14 @@ +@@ -55,10 +61,14 @@ @Override - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { - if (!world.isClientSide && entity.isBurning() && this.a(iblockdata, blockposition, entity)) { -- entity.extinguish(); + public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + if (!world.isClientSide && entity.isOnFire() && this.isEntityInsideContent(iblockdata, blockposition, entity)) { +- entity.clearFire(); + // CraftBukkit start - if (entity.a(world, blockposition)) { -- this.d(iblockdata, world, blockposition); -+ if (!decreaseLevel(iblockdata, world, blockposition, entity, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH)) { + if (entity.mayInteract(world, blockposition)) { +- this.handleEntityOnFireInside(iblockdata, world, blockposition); ++ if (!lowerFillLevel(iblockdata, world, blockposition, entity, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH)) { + return; + } } -+ entity.extinguish(); ++ entity.clearFire(); + // CraftBukkit end } } -@@ -69,15 +79,38 @@ +@@ -68,15 +78,38 @@ } - public static void e(IBlockData iblockdata, World world, BlockPosition blockposition) { + public static void lowerFillLevel(IBlockData iblockdata, World world, BlockPosition blockposition) { + // CraftBukkit start -+ decreaseLevel(iblockdata, world, blockposition, null, CauldronLevelChangeEvent.ChangeReason.UNKNOWN); ++ lowerFillLevel(iblockdata, world, blockposition, null, CauldronLevelChangeEvent.ChangeReason.UNKNOWN); + } + -+ public static boolean decreaseLevel(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) { - int i = (Integer) iblockdata.get(LayeredCauldronBlock.LEVEL) - 1; ++ public static boolean lowerFillLevel(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) { + int i = (Integer) iblockdata.getValue(LayeredCauldronBlock.LEVEL) - 1; -- world.setTypeUpdate(blockposition, i == 0 ? Blocks.CAULDRON.getBlockData() : (IBlockData) iblockdata.set(LayeredCauldronBlock.LEVEL, i)); -+ return changeLevel(iblockdata, world, blockposition, i == 0 ? Blocks.CAULDRON.getBlockData() : iblockdata.set(LayeredCauldronBlock.LEVEL, i), entity, reason); +- world.setBlockAndUpdate(blockposition, i == 0 ? Blocks.CAULDRON.defaultBlockState() : (IBlockData) iblockdata.setValue(LayeredCauldronBlock.LEVEL, i)); ++ return changeLevel(iblockdata, world, blockposition, i == 0 ? Blocks.CAULDRON.defaultBlockState() : iblockdata.setValue(LayeredCauldronBlock.LEVEL, i), entity, reason); } + // CraftBukkit start @@ -64,23 +64,23 @@ + // CraftBukkit end + @Override - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, BiomeBase.Precipitation biomebase_precipitation) { - if (BlockCauldron.a(world, biomebase_precipitation) && (Integer) iblockdata.get(LayeredCauldronBlock.LEVEL) != 3 && this.fillPredicate.test(biomebase_precipitation)) { -- world.setTypeUpdate(blockposition, (IBlockData) iblockdata.a((IBlockState) LayeredCauldronBlock.LEVEL)); -+ changeLevel(iblockdata, world, blockposition, (IBlockData) iblockdata.a((IBlockState) LayeredCauldronBlock.LEVEL), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit + public void handlePrecipitation(IBlockData iblockdata, World world, BlockPosition blockposition, BiomeBase.Precipitation biomebase_precipitation) { + if (BlockCauldron.shouldHandlePrecipitation(world, biomebase_precipitation) && (Integer) iblockdata.getValue(LayeredCauldronBlock.LEVEL) != 3 && this.fillPredicate.test(biomebase_precipitation)) { +- world.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.cycle(LayeredCauldronBlock.LEVEL)); ++ changeLevel(iblockdata, world, blockposition, (IBlockData) iblockdata.cycle(LayeredCauldronBlock.LEVEL), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit } } -@@ -94,7 +127,11 @@ +@@ -93,7 +126,11 @@ @Override - protected void a(IBlockData iblockdata, World world, BlockPosition blockposition, FluidType fluidtype) { - if (!this.c(iblockdata)) { -- world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(LayeredCauldronBlock.LEVEL, (Integer) iblockdata.get(LayeredCauldronBlock.LEVEL) + 1)); + protected void receiveStalactiteDrip(IBlockData iblockdata, World world, BlockPosition blockposition, FluidType fluidtype) { + if (!this.isFull(iblockdata)) { +- world.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(LayeredCauldronBlock.LEVEL, (Integer) iblockdata.getValue(LayeredCauldronBlock.LEVEL) + 1)); + // CraftBukkit start -+ if (!changeLevel(iblockdata, world, blockposition, (IBlockData) iblockdata.set(LayeredCauldronBlock.LEVEL, (Integer) iblockdata.get(LayeredCauldronBlock.LEVEL) + 1), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) { ++ if (!changeLevel(iblockdata, world, blockposition, (IBlockData) iblockdata.setValue(LayeredCauldronBlock.LEVEL, (Integer) iblockdata.getValue(LayeredCauldronBlock.LEVEL) + 1), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) { + return; + } + // CraftBukkit end - world.triggerEffect(1047, blockposition, 0); + world.levelEvent(1047, blockposition, 0); } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch index 2fffa8ff76..af9dd1b9d7 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/LightningRodBlock.java +++ b/net/minecraft/world/level/block/LightningRodBlock.java -@@ -33,6 +33,11 @@ +@@ -32,6 +32,11 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.Vec3D; @@ -12,12 +12,12 @@ public class LightningRodBlock extends RodBlock implements IBlockWaterlogged { public static final BlockStateBoolean WATERLOGGED = BlockProperties.WATERLOGGED; -@@ -79,6 +84,18 @@ +@@ -78,6 +83,18 @@ } - public void d(IBlockData iblockdata, World world, BlockPosition blockposition) { + public void onLightningStrike(IBlockData iblockdata, World world, BlockPosition blockposition) { + // CraftBukkit start -+ boolean powered = iblockdata.get(LightningRodBlock.POWERED); ++ boolean powered = iblockdata.getValue(LightningRodBlock.POWERED); + int old = (powered) ? 15 : 0; + int current = (!powered) ? 15 : 0; + @@ -28,14 +28,14 @@ + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(LightningRodBlock.POWERED, true), 3); - this.e(iblockdata, world, blockposition); - world.getBlockTickList().a(blockposition, this, 8); -@@ -135,7 +152,7 @@ - Entity entity = iprojectile.getShooter(); + world.setBlock(blockposition, (IBlockData) iblockdata.setValue(LightningRodBlock.POWERED, true), 3); + this.updateNeighbours(iblockdata, world, blockposition); + world.scheduleTick(blockposition, (Block) this, 8); +@@ -134,7 +151,7 @@ + Entity entity = iprojectile.getOwner(); - entitylightning.b(entity instanceof EntityPlayer ? (EntityPlayer) entity : null); -- world.addEntity(entitylightning); + entitylightning.setCause(entity instanceof EntityPlayer ? (EntityPlayer) entity : null); +- world.addFreshEntity(entitylightning); + ((WorldServer) world).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit world.playSound((EntityHuman) null, blockposition, SoundEffects.TRIDENT_THUNDER, SoundCategory.WEATHER, 5.0F, 1.0F); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/MultifaceBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/MultifaceBlock.patch index 3d45662d0d..139c241149 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/MultifaceBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/MultifaceBlock.patch @@ -1,46 +1,37 @@ --- a/net/minecraft/world/level/block/MultifaceBlock.java +++ b/net/minecraft/world/level/block/MultifaceBlock.java -@@ -45,7 +45,7 @@ - private static final VoxelShape NORTH_AABB = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 1.0D); - private static final VoxelShape SOUTH_AABB = Block.a(0.0D, 0.0D, 15.0D, 16.0D, 16.0D, 16.0D); - private static final Map<EnumDirection, BlockStateBoolean> PROPERTY_BY_DIRECTION = BlockSprawling.PROPERTY_BY_DIRECTION; -- private static final Map<EnumDirection, VoxelShape> SHAPE_BY_DIRECTION = (Map) SystemUtils.a((Object) Maps.newEnumMap(EnumDirection.class), (enummap) -> { -+ private static final Map<EnumDirection, VoxelShape> SHAPE_BY_DIRECTION = (Map) SystemUtils.a(Maps.newEnumMap(EnumDirection.class), (enummap) -> { // CraftBukkit - decompile error - enummap.put(EnumDirection.NORTH, MultifaceBlock.NORTH_AABB); - enummap.put(EnumDirection.EAST, MultifaceBlock.EAST_AABB); - enummap.put(EnumDirection.SOUTH, MultifaceBlock.SOUTH_AABB); -@@ -134,7 +134,7 @@ +@@ -133,7 +133,7 @@ - return (IBlockData) Arrays.stream(blockactioncontext.f()).map((enumdirection) -> { - return this.c(iblockdata, (IBlockAccess) world, blockposition, enumdirection); + return (IBlockData) Arrays.stream(blockactioncontext.getNearestLookingDirections()).map((enumdirection) -> { + return this.getStateForPlacement(iblockdata, world, blockposition, enumdirection); - }).filter(Objects::nonNull).findFirst().orElse((Object) null); + }).filter(Objects::nonNull).findFirst().orElse(null); // CraftBukkit - decompile error } @Nullable -@@ -226,7 +226,7 @@ +@@ -225,7 +225,7 @@ if (optional.isPresent()) { Pair<BlockPosition, EnumDirection> pair = (Pair) optional.get(); -- return this.a(generatoraccess, (BlockPosition) pair.getFirst(), (EnumDirection) pair.getSecond(), flag); -+ return this.a(generatoraccess, (BlockPosition) pair.getFirst(), (EnumDirection) pair.getSecond(), flag, blockposition); // CraftBukkit +- return this.spreadToFace(generatoraccess, (BlockPosition) pair.getFirst(), (EnumDirection) pair.getSecond(), flag); ++ return this.spreadToFace(generatoraccess, (BlockPosition) pair.getFirst(), (EnumDirection) pair.getSecond(), flag, blockposition); // CraftBukkit } else { return false; } -@@ -271,7 +271,7 @@ +@@ -270,7 +270,7 @@ } } -- private boolean a(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection enumdirection, boolean flag) { -+ private boolean a(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection enumdirection, boolean flag, BlockPosition source) { // CraftBukkit - IBlockData iblockdata = generatoraccess.getType(blockposition); - IBlockData iblockdata1 = this.c(iblockdata, (IBlockAccess) generatoraccess, blockposition, enumdirection); +- private boolean spreadToFace(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection enumdirection, boolean flag) { ++ private boolean spreadToFace(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection enumdirection, boolean flag, BlockPosition source) { // CraftBukkit + IBlockData iblockdata = generatoraccess.getBlockState(blockposition); + IBlockData iblockdata1 = this.getStateForPlacement(iblockdata, generatoraccess, blockposition, enumdirection); -@@ -280,7 +280,7 @@ - generatoraccess.A(blockposition).e(blockposition); +@@ -279,7 +279,7 @@ + generatoraccess.getChunk(blockposition).markPosForPostprocessing(blockposition); } -- return generatoraccess.setTypeAndData(blockposition, iblockdata1, 2); +- return generatoraccess.setBlock(blockposition, iblockdata1, 2); + return org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(generatoraccess, source, blockposition, iblockdata1, 2); // CraftBukkit } else { return false; diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch index b96c5326b8..01e29cbc07 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch +++ b/paper-server/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 -@@ -43,6 +43,11 @@ +@@ -41,6 +41,11 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -12,79 +12,79 @@ public class PointedDripstoneBlock extends Block implements Fallable, IBlockWaterlogged { public static final BlockStateDirection TIP_DIRECTION = BlockProperties.VERTICAL_DIRECTION; -@@ -125,6 +130,11 @@ - BlockPosition blockposition = movingobjectpositionblock.getBlockPosition(); +@@ -123,6 +128,11 @@ + BlockPosition blockposition = movingobjectpositionblock.getBlockPos(); - if (!world.isClientSide && iprojectile.a(world, blockposition) && iprojectile instanceof EntityThrownTrident && iprojectile.getMot().f() > 0.6D) { + if (!world.isClientSide && iprojectile.mayInteract(world, blockposition) && iprojectile instanceof EntityThrownTrident && iprojectile.getDeltaMovement().length() > 0.6D) { + // CraftBukkit start -+ if (CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { ++ if (CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - world.b(blockposition, true); + world.destroyBlock(blockposition, true); } -@@ -133,7 +143,9 @@ +@@ -131,7 +141,9 @@ @Override public void fallOn(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, float f) { - if (iblockdata.get(PointedDripstoneBlock.TIP_DIRECTION) == EnumDirection.UP && iblockdata.get(PointedDripstoneBlock.THICKNESS) == DripstoneThickness.TIP) { + if (iblockdata.getValue(PointedDripstoneBlock.TIP_DIRECTION) == EnumDirection.UP && iblockdata.getValue(PointedDripstoneBlock.THICKNESS) == DripstoneThickness.TIP) { + CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); // CraftBukkit - entity.a(f + 2.0F, 2.0F, DamageSource.STALAGMITE); + entity.causeFallDamage(f + 2.0F, 2.0F, DamageSource.STALAGMITE); + CraftEventFactory.blockDamage = null; // CraftBukkit } else { super.fallOn(world, iblockdata, blockposition, entity, f); } -@@ -397,15 +409,15 @@ - if (a(iblockdata, enumdirection.opposite())) { - c(iblockdata, (GeneratorAccess) worldserver, blockposition1); - } else if (iblockdata.isAir() || iblockdata.a(Blocks.WATER)) { -- a((GeneratorAccess) worldserver, blockposition1, enumdirection, DripstoneThickness.TIP); -+ a((GeneratorAccess) worldserver, blockposition1, enumdirection, DripstoneThickness.TIP, blockposition); // CraftBukkit +@@ -405,15 +417,15 @@ + if (isUnmergedTipWithDirection(iblockdata, enumdirection.getOpposite())) { + createMergedTips(iblockdata, worldserver, blockposition1); + } else if (iblockdata.isAir() || iblockdata.is(Blocks.WATER)) { +- createDripstone(worldserver, blockposition1, enumdirection, DripstoneThickness.TIP); ++ createDripstone(worldserver, blockposition1, enumdirection, DripstoneThickness.TIP, blockposition); // CraftBukkit } } -- private static void a(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection enumdirection, DripstoneThickness dripstonethickness) { -+ private static void a(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection enumdirection, DripstoneThickness dripstonethickness, BlockPosition source) { - IBlockData iblockdata = (IBlockData) ((IBlockData) ((IBlockData) Blocks.POINTED_DRIPSTONE.getBlockData().set(PointedDripstoneBlock.TIP_DIRECTION, enumdirection)).set(PointedDripstoneBlock.THICKNESS, dripstonethickness)).set(PointedDripstoneBlock.WATERLOGGED, generatoraccess.getFluid(blockposition).getType() == FluidTypes.WATER); +- private static void createDripstone(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection enumdirection, DripstoneThickness dripstonethickness) { ++ private static void createDripstone(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection enumdirection, DripstoneThickness dripstonethickness, BlockPosition source) { // CraftBukkit + IBlockData iblockdata = (IBlockData) ((IBlockData) ((IBlockData) Blocks.POINTED_DRIPSTONE.defaultBlockState().setValue(PointedDripstoneBlock.TIP_DIRECTION, enumdirection)).setValue(PointedDripstoneBlock.THICKNESS, dripstonethickness)).setValue(PointedDripstoneBlock.WATERLOGGED, generatoraccess.getFluidState(blockposition).getType() == FluidTypes.WATER); -- generatoraccess.setTypeAndData(blockposition, iblockdata, 3); +- generatoraccess.setBlock(blockposition, iblockdata, 3); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(generatoraccess, source, blockposition, iblockdata, 3); // CraftBukkit } - private static void c(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { -@@ -420,8 +432,8 @@ - blockposition1 = blockposition.down(); + private static void createMergedTips(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { +@@ -428,8 +440,8 @@ + blockposition1 = blockposition.below(); } -- a(generatoraccess, blockposition2, EnumDirection.DOWN, DripstoneThickness.TIP_MERGE); -- a(generatoraccess, blockposition1, EnumDirection.UP, DripstoneThickness.TIP_MERGE); -+ a(generatoraccess, blockposition2, EnumDirection.DOWN, DripstoneThickness.TIP_MERGE, blockposition); // CraftBukkit -+ a(generatoraccess, blockposition1, EnumDirection.UP, DripstoneThickness.TIP_MERGE, blockposition); // CraftBukkit +- 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 } - public static void a(World world, BlockPosition blockposition, IBlockData iblockdata) { -@@ -454,7 +466,7 @@ + public static void spawnDripParticle(World world, BlockPosition blockposition, IBlockData iblockdata) { +@@ -462,7 +474,7 @@ - return (BlockPosition) a(generatoraccess, blockposition, enumdirection.e(), predicate, (iblockdata1) -> { - return a(iblockdata1, flag); + return (BlockPosition) findBlockVertical(generatoraccess, blockposition, enumdirection.getAxisDirection(), predicate, (iblockdata1) -> { + return isTip(iblockdata1, flag); - }, i).orElse((Object) null); + }, i).orElse(null); // CraftBukkit - decompile error } } -@@ -567,12 +579,12 @@ - return iblockdata.getBlock() instanceof AbstractCauldronBlock && ((AbstractCauldronBlock) iblockdata.getBlock()).a(fluidtype); +@@ -575,12 +587,12 @@ + return iblockdata.getBlock() instanceof AbstractCauldronBlock && ((AbstractCauldronBlock) iblockdata.getBlock()).canReceiveStalactiteDrip(fluidtype); }; -- return (BlockPosition) a(world, blockposition, EnumDirection.DOWN.e(), BlockBase.BlockData::isAir, predicate, 11).orElse((Object) null); -+ return (BlockPosition) a(world, blockposition, EnumDirection.DOWN.e(), BlockBase.BlockData::isAir, predicate, 11).orElse(null); // CraftBukkit - decompile error +- return (BlockPosition) findBlockVertical(world, blockposition, EnumDirection.DOWN.getAxisDirection(), BlockBase.BlockData::isAir, predicate, 11).orElse((Object) null); ++ return (BlockPosition) findBlockVertical(world, blockposition, EnumDirection.DOWN.getAxisDirection(), BlockBase.BlockData::isAir, predicate, 11).orElse(null); // CraftBukkit - decompile error } @Nullable - public static BlockPosition a(World world, BlockPosition blockposition) { -- return (BlockPosition) a(world, blockposition, EnumDirection.UP.e(), BlockBase.BlockData::isAir, PointedDripstoneBlock::h, 11).orElse((Object) null); -+ return (BlockPosition) a(world, blockposition, EnumDirection.UP.e(), BlockBase.BlockData::isAir, PointedDripstoneBlock::h, 11).orElse(null); // CraftBukkit - decompile error + public static BlockPosition findStalactiteTipAboveCauldron(World world, BlockPosition blockposition) { +- return (BlockPosition) findBlockVertical(world, blockposition, EnumDirection.UP.getAxisDirection(), BlockBase.BlockData::isAir, PointedDripstoneBlock::canDrip, 11).orElse((Object) null); ++ return (BlockPosition) findBlockVertical(world, blockposition, EnumDirection.UP.getAxisDirection(), BlockBase.BlockData::isAir, PointedDripstoneBlock::canDrip, 11).orElse(null); // CraftBukkit - decompile error } - public static FluidType b(World world, BlockPosition blockposition) { + public static FluidType getCauldronFillFluidType(World world, BlockPosition blockposition) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/PowderSnowBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/PowderSnowBlock.patch index 18bb84f5c1..043e4d661b 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/PowderSnowBlock.patch +++ b/paper-server/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 -@@ -68,7 +68,12 @@ +@@ -69,7 +69,12 @@ - entity.o(true); + entity.setIsInPowderSnow(true); if (!world.isClientSide) { -- if (entity.isBurning() && (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity instanceof EntityHuman) && entity.a(world, blockposition)) { +- if (entity.isOnFire() && (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity instanceof EntityHuman) && entity.mayInteract(world, blockposition)) { + // CraftBukkit start -+ if (entity.isBurning() && entity.a(world, blockposition)) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.getBlockData(), !(world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity instanceof EntityHuman)).isCancelled()) { ++ if (entity.isOnFire() && entity.mayInteract(world, blockposition)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.defaultBlockState(), !(world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity instanceof EntityHuman)).isCancelled()) { + return; + } + // CraftBukkit end - world.b(blockposition, false); + world.destroyBlock(blockposition, false); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/RootedDirtBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/RootedDirtBlock.patch index 58a4826629..cffab25097 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/RootedDirtBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/RootedDirtBlock.patch @@ -3,8 +3,8 @@ @@ -26,6 +26,6 @@ @Override - public void a(WorldServer worldserver, Random random, BlockPosition blockposition, IBlockData iblockdata) { -- worldserver.setTypeUpdate(blockposition.down(), Blocks.HANGING_ROOTS.getBlockData()); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition.down(), Blocks.HANGING_ROOTS.getBlockData()); // CraftBukkit + public void performBonemeal(WorldServer worldserver, Random random, BlockPosition blockposition, IBlockData iblockdata) { +- worldserver.setBlockAndUpdate(blockposition.below(), Blocks.HANGING_ROOTS.defaultBlockState()); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition.below(), Blocks.HANGING_ROOTS.defaultBlockState()); // CraftBukkit } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch index b394a906b8..e81bad0c3e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkSensorBlock.java +++ b/net/minecraft/world/level/block/SculkSensorBlock.java -@@ -38,11 +38,16 @@ +@@ -38,6 +38,11 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -12,34 +12,28 @@ public class SculkSensorBlock extends BlockTileEntity implements IBlockWaterlogged { public static final int ACTIVE_TICKS = 40; - public static final int COOLDOWN_TICKS = 1; -- public static final Object2IntMap<GameEvent> VIBRATION_STRENGTH_FOR_EVENT = Object2IntMaps.unmodifiable((Object2IntMap) SystemUtils.a((Object) (new Object2IntOpenHashMap()), (object2intopenhashmap) -> { -+ public static final Object2IntMap<GameEvent> VIBRATION_STRENGTH_FOR_EVENT = Object2IntMaps.unmodifiable((Object2IntMap) SystemUtils.a((new Object2IntOpenHashMap()), (object2intopenhashmap) -> { // CraftBukkit - decompile error - object2intopenhashmap.put(GameEvent.STEP, 1); - object2intopenhashmap.put(GameEvent.FLAP, 2); - object2intopenhashmap.put(GameEvent.SWIM, 3); @@ -216,6 +221,15 @@ } - public static void a(World world, BlockPosition blockposition, IBlockData iblockdata) { + public static void deactivate(World world, BlockPosition blockposition, IBlockData iblockdata) { + // CraftBukkit start -+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(CraftBlock.at(world, blockposition), iblockdata.get(SculkSensorBlock.POWER), 0); ++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(CraftBlock.at(world, blockposition), iblockdata.getValue(SculkSensorBlock.POWER), 0); + world.getCraftServer().getPluginManager().callEvent(eventRedstone); + + if (eventRedstone.getNewCurrent() > 0) { -+ world.setTypeAndData(blockposition, iblockdata.set(SculkSensorBlock.POWER, eventRedstone.getNewCurrent()), 3); ++ world.setBlock(blockposition, iblockdata.setValue(SculkSensorBlock.POWER, eventRedstone.getNewCurrent()), 3); + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) ((IBlockData) iblockdata.set(SculkSensorBlock.PHASE, SculkSensorPhase.COOLDOWN)).set(SculkSensorBlock.POWER, 0), 3); - world.getBlockTickList().a(new BlockPosition(blockposition), iblockdata.getBlock(), 1); - if (!(Boolean) iblockdata.get(SculkSensorBlock.WATERLOGGED)) { + world.setBlock(blockposition, (IBlockData) ((IBlockData) iblockdata.setValue(SculkSensorBlock.PHASE, SculkSensorPhase.COOLDOWN)).setValue(SculkSensorBlock.POWER, 0), 3); + world.scheduleTick(new BlockPosition(blockposition), iblockdata.getBlock(), 1); + if (!(Boolean) iblockdata.getValue(SculkSensorBlock.WATERLOGGED)) { @@ -226,6 +240,15 @@ } - public static void a(World world, BlockPosition blockposition, IBlockData iblockdata, int i) { + public static void activate(World world, BlockPosition blockposition, IBlockData iblockdata, int i) { + // CraftBukkit start -+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(CraftBlock.at(world, blockposition), iblockdata.get(SculkSensorBlock.POWER), i); ++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(CraftBlock.at(world, blockposition), iblockdata.getValue(SculkSensorBlock.POWER), i); + world.getCraftServer().getPluginManager().callEvent(eventRedstone); + + if (eventRedstone.getNewCurrent() <= 0) { @@ -47,6 +41,6 @@ + } + i = eventRedstone.getNewCurrent(); + // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) ((IBlockData) iblockdata.set(SculkSensorBlock.PHASE, SculkSensorPhase.ACTIVE)).set(SculkSensorBlock.POWER, i), 3); - world.getBlockTickList().a(new BlockPosition(blockposition), iblockdata.getBlock(), 40); - a(world, blockposition); + world.setBlock(blockposition, (IBlockData) ((IBlockData) iblockdata.setValue(SculkSensorBlock.PHASE, SculkSensorPhase.ACTIVE)).setValue(SculkSensorBlock.POWER, i), 3); + world.scheduleTick(new BlockPosition(blockposition), iblockdata.getBlock(), 40); + updateNeighbours(world, blockposition); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/ContainerOpenersCounter.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/ContainerOpenersCounter.patch index fa292ecbd4..f7c48de3a7 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/ContainerOpenersCounter.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/ContainerOpenersCounter.patch @@ -9,14 +9,14 @@ public ContainerOpenersCounter() {} @@ -25,8 +26,19 @@ - protected abstract boolean a(EntityHuman entityhuman); + protected abstract boolean isOwnContainer(EntityHuman entityhuman); - public void a(EntityHuman entityhuman, World world, BlockPosition blockposition, IBlockData iblockdata) { + public void incrementOpeners(EntityHuman entityhuman, World world, BlockPosition blockposition, IBlockData iblockdata) { + int oldPower = Math.max(0, Math.min(15, this.openCount)); // CraftBukkit - Get power before new viewer is added int i = this.openCount++; + // CraftBukkit start - Call redstone event -+ if (world.getType(blockposition).a(net.minecraft.world.level.block.Blocks.TRAPPED_CHEST)) { ++ if (world.getBlockState(blockposition).is(net.minecraft.world.level.block.Blocks.TRAPPED_CHEST)) { + int newPower = Math.max(0, Math.min(15, this.openCount)); + + if (oldPower != newPower) { @@ -26,17 +26,17 @@ + // CraftBukkit end + if (i == 0) { - this.a(world, blockposition, iblockdata); - world.a((Entity) entityhuman, GameEvent.CONTAINER_OPEN, blockposition); + this.onOpen(world, blockposition, iblockdata); + world.gameEvent(entityhuman, GameEvent.CONTAINER_OPEN, blockposition); @@ -37,8 +49,19 @@ } - public void b(EntityHuman entityhuman, World world, BlockPosition blockposition, IBlockData iblockdata) { + public void decrementOpeners(EntityHuman entityhuman, World world, BlockPosition blockposition, IBlockData iblockdata) { + int oldPower = Math.max(0, Math.min(15, this.openCount)); // CraftBukkit - Get power before new viewer is added int i = this.openCount--; + // CraftBukkit start - Call redstone event -+ if (world.getType(blockposition).a(net.minecraft.world.level.block.Blocks.TRAPPED_CHEST)) { ++ if (world.getBlockState(blockposition).is(net.minecraft.world.level.block.Blocks.TRAPPED_CHEST)) { + int newPower = Math.max(0, Math.min(15, this.openCount)); + + if (oldPower != newPower) { @@ -46,12 +46,12 @@ + // CraftBukkit end + if (this.openCount == 0) { - this.b(world, blockposition, iblockdata); - world.a((Entity) entityhuman, GameEvent.CONTAINER_CLOSE, blockposition); + this.onClose(world, blockposition, iblockdata); + world.gameEvent(entityhuman, GameEvent.CONTAINER_CLOSE, blockposition); @@ -59,6 +82,7 @@ - public void c(World world, BlockPosition blockposition, IBlockData iblockdata) { - int i = this.a(world, blockposition); + public void recheckOpeners(World world, BlockPosition blockposition, IBlockData iblockdata) { + int i = this.getOpenCount(world, blockposition); + if (opened) i++; // CraftBukkit - add dummy count from API int j = this.openCount; diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch index 1ca83a1eee..841a853111 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch +++ b/paper-server/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 -@@ -12,8 +12,18 @@ +@@ -15,8 +15,18 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -19,7 +19,7 @@ private static final Logger LOGGER = LogManager.getLogger(); private final TileEntityTypes<?> type; @Nullable -@@ -41,7 +51,16 @@ +@@ -48,7 +58,16 @@ return this.level != null; } @@ -35,22 +35,22 @@ + } + // CraftBukkit end - public NBTTagCompound save(NBTTagCompound nbttagcompound) { - return this.c(nbttagcompound); -@@ -57,6 +76,11 @@ - nbttagcompound.setInt("x", this.worldPosition.getX()); - nbttagcompound.setInt("y", this.worldPosition.getY()); - nbttagcompound.setInt("z", this.worldPosition.getZ()); -+ // CraftBukkit start - store container -+ if (this.persistentDataContainer != null && !this.persistentDataContainer.isEmpty()) { -+ nbttagcompound.set("PublicBukkitValues", this.persistentDataContainer.toTagCompound()); -+ } -+ // CraftBukkit end - return nbttagcompound; - } + protected void saveAdditional(NBTTagCompound nbttagcompound) {} + +@@ -70,6 +89,11 @@ + NBTTagCompound nbttagcompound = new NBTTagCompound(); + + this.saveAdditional(nbttagcompound); ++ // CraftBukkit start - store container ++ if (this.persistentDataContainer != null && !this.persistentDataContainer.isEmpty()) { ++ nbttagcompound.put("PublicBukkitValues", this.persistentDataContainer.toTagCompound()); ++ } ++ // CraftBukkit end + return nbttagcompound; } -@@ -164,4 +188,15 @@ - public void b(IBlockData iblockdata) { + +@@ -201,4 +225,15 @@ + public void setBlockState(IBlockData iblockdata) { this.blockState = iblockdata; } + diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBanner.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBanner.patch index 17a109a7ee..0f3df62ed6 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBanner.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBanner.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityBanner.java +++ b/net/minecraft/world/level/block/entity/TileEntityBanner.java -@@ -99,6 +99,11 @@ +@@ -101,6 +101,11 @@ } this.itemPatterns = nbttagcompound.getList("Patterns", 10); @@ -10,5 +10,5 @@ + } + // CraftBukkit end this.patterns = null; - this.receivedData = true; } + diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch index 1ad5149578..0317463839 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch +++ b/paper-server/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 -@@ -40,6 +40,11 @@ +@@ -39,6 +39,11 @@ import net.minecraft.world.level.levelgen.HeightMap; import net.minecraft.world.phys.AxisAlignedBB; @@ -12,7 +12,7 @@ public class TileEntityBeacon extends TileEntity implements ITileInventory { private static final int MAX_LEVELS = 4; -@@ -62,6 +67,15 @@ +@@ -61,6 +66,15 @@ public IChatBaseComponent name; public ChestLock lockKey; private final IContainerProperties dataAccess; @@ -28,8 +28,8 @@ public TileEntityBeacon(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.BEACON, blockposition, iblockdata); -@@ -230,39 +244,78 @@ - super.aa_(); +@@ -229,39 +243,78 @@ + super.setRemoved(); } - private static void applyEffects(World world, BlockPosition blockposition, int i, @Nullable MobEffectList mobeffectlist, @Nullable MobEffectList mobeffectlist1) { @@ -59,8 +59,8 @@ + { + double d0 = (double) (i * 10 + 10); + - AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition)).g(d0).b(0.0D, (double) world.getHeight(), 0.0D); - List<EntityHuman> list = world.a(EntityHuman.class, axisalignedbb); + AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition)).inflate(d0).expandTowards(0.0D, (double) world.getHeight(), 0.0D); + List<EntityHuman> list = world.getEntitiesOfClass(EntityHuman.class, axisalignedbb); + + return list; + } @@ -114,20 +114,20 @@ + } + // CraftBukkit end + - public static void a(World world, BlockPosition blockposition, SoundEffect soundeffect) { + public static void playSound(World world, BlockPosition blockposition, SoundEffect soundeffect) { world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); } -@@ -292,8 +345,11 @@ +@@ -290,8 +343,11 @@ @Override public void load(NBTTagCompound nbttagcompound) { super.load(nbttagcompound); -- this.primaryPower = a(nbttagcompound.getInt("Primary")); -- this.secondaryPower = a(nbttagcompound.getInt("Secondary")); +- this.primaryPower = getValidEffectById(nbttagcompound.getInt("Primary")); +- this.secondaryPower = getValidEffectById(nbttagcompound.getInt("Secondary")); + // CraftBukkit start - persist manually set non-default beacon effects (SPIGOT-3598) -+ this.primaryPower = MobEffectList.fromId(nbttagcompound.getInt("Primary")); -+ this.secondaryPower = MobEffectList.fromId(nbttagcompound.getInt("Secondary")); ++ this.primaryPower = MobEffectList.byId(nbttagcompound.getInt("Primary")); ++ this.secondaryPower = MobEffectList.byId(nbttagcompound.getInt("Secondary")); + this.levels = nbttagcompound.getInt("Levels"); // SPIGOT-5053, use where available + // CraftBukkit end - if (nbttagcompound.hasKeyOfType("CustomName", 8)) { - this.name = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName")); + if (nbttagcompound.contains("CustomName", 8)) { + this.name = IChatBaseComponent.ChatSerializer.fromJson(nbttagcompound.getString("CustomName")); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch index 103c21bd4e..0ee9c212a7 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch @@ -16,20 +16,20 @@ + return this.stored.size() == this.maxBees; // CraftBukkit } - public void a(@Nullable EntityHuman entityhuman, IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { + public void emptyAllLivingFromHive(@Nullable EntityHuman entityhuman, IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { @@ -99,7 +100,7 @@ - if (entityhuman.getPositionVector().distanceSquared(entity.getPositionVector()) <= 16.0D) { + if (entityhuman.position().distanceToSqr(entity.position()) <= 16.0D) { if (!this.isSedated()) { -- entitybee.setGoalTarget(entityhuman); -+ entitybee.setGoalTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit +- entitybee.setTarget(entityhuman); ++ entitybee.setTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit } else { - entitybee.setCannotEnterHiveTicks(400); + entitybee.setStayOutOfHiveCountdown(400); } @@ -111,10 +112,16 @@ } - private List<Entity> releaseBees(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { + private List<Entity> releaseAllOccupants(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { + // CraftBukkit start - This allows us to bypass the night/rain/emergency check + return releaseBees(iblockdata, tileentitybeehive_releasestatus, false); + } @@ -38,7 +38,7 @@ List<Entity> list = Lists.newArrayList(); this.stored.removeIf((tileentitybeehive_hivebee) -> { -- return releaseBee(this.level, this.worldPosition, iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, this.savedFlowerPos); +- return releaseOccupant(this.level, this.worldPosition, iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, this.savedFlowerPos); + return releaseBee(this.level, this.worldPosition, iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, this.savedFlowerPos, force); + // CraftBukkit end }); @@ -47,16 +47,16 @@ @@ -138,7 +145,19 @@ } - public void a(Entity entity, boolean flag, int i) { + public void addOccupantWithPresetTicks(Entity entity, boolean flag, int i) { - if (this.stored.size() < 3) { + if (this.stored.size() < this.maxBees) { // CraftBukkit + // CraftBukkit start + if (this.level != null) { -+ org.bukkit.event.entity.EntityEnterBlockEvent event = new org.bukkit.event.entity.EntityEnterBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, getPosition())); ++ org.bukkit.event.entity.EntityEnterBlockEvent event = new org.bukkit.event.entity.EntityEnterBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, getBlockPos())); + org.bukkit.Bukkit.getPluginManager().callEvent(event); + if (event.isCancelled()) { + if (entity instanceof EntityBee) { -+ ((EntityBee) entity).setCannotEnterHiveTicks(400); ++ ((EntityBee) entity).setStayOutOfHiveCountdown(400); + } + return; + } @@ -68,7 +68,7 @@ @@ -168,7 +187,13 @@ } - private static boolean releaseBee(World world, BlockPosition blockposition, IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, @Nullable BlockPosition blockposition1) { + private static boolean releaseOccupant(World world, BlockPosition blockposition, IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, @Nullable BlockPosition blockposition1) { - if ((world.isNight() || world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) { + // CraftBukkit start - This allows us to bypass the night/rain/emergency check + return releaseBee(world, blockposition, iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, blockposition1, false); @@ -81,20 +81,20 @@ } else { NBTTagCompound nbttagcompound = tileentitybeehive_hivebee.entityData; @@ -191,6 +216,18 @@ - if (!entity.getEntityType().a((Tag) TagsEntity.BEEHIVE_INHABITORS)) { + if (!entity.getType().is(TagsEntity.BEEHIVE_INHABITORS)) { return false; } else { + // CraftBukkit start + if (entity instanceof EntityBee) { -+ float f = entity.getWidth(); ++ 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.getAdjacentX(); -+ double d2 = (double) blockposition.getY() + 0.5D - (double) (entity.getHeight() / 2.0F); -+ double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getAdjacentZ(); ++ double d1 = (double) blockposition.getX() + 0.5D + d0 * (double) enumdirection.getStepX(); ++ double d2 = (double) blockposition.getY() + 0.5D - (double) (entity.getBbHeight() / 2.0F); ++ double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getStepZ(); + -+ entity.setPositionRotation(d1, d2, d3, entity.getYRot(), entity.getXRot()); ++ entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot()); + } -+ if (!world.addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BEEHIVE)) return false; // CraftBukkit - SpawnReason, moved from below ++ 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; @@ -104,25 +104,25 @@ } + /* // CraftBukkit start - float f = entity.getWidth(); + 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.getAdjacentX(); + double d1 = (double) blockposition.getX() + 0.5D + d0 * (double) enumdirection.getStepX(); @@ -227,10 +265,11 @@ - double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getAdjacentZ(); + double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getStepZ(); - entity.setPositionRotation(d1, d2, d3, entity.getYRot(), entity.getXRot()); + entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot()); + */ // CraftBukkit end } world.playSound((EntityHuman) null, blockposition, SoundEffects.BEEHIVE_EXIT, SoundCategory.BLOCKS, 1.0F, 1.0F); -- return world.addEntity(entity); -+ return true; // return this.world.addEntity(entity); // CraftBukkit - moved up +- return world.addFreshEntity(entity); ++ return true; // return this.world.addFreshEntity(entity); // CraftBukkit - moved up } } else { return false; @@ -276,6 +315,10 @@ - if (releaseBee(world, blockposition, iblockdata, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus, blockposition1)) { + if (releaseOccupant(world, blockposition, iblockdata, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus, blockposition1)) { iterator.remove(); + // CraftBukkit start + } else { @@ -132,11 +132,11 @@ } } @@ -313,6 +356,11 @@ - this.savedFlowerPos = GameProfileSerializer.b(nbttagcompound.getCompound("FlowerPos")); + this.savedFlowerPos = GameProfileSerializer.readBlockPos(nbttagcompound.getCompound("FlowerPos")); } + // CraftBukkit start -+ if (nbttagcompound.hasKey("Bukkit.MaxEntities")) { ++ if (nbttagcompound.contains("Bukkit.MaxEntities")) { + this.maxBees = nbttagcompound.getInt("Bukkit.MaxEntities"); + } + // CraftBukkit end @@ -144,10 +144,10 @@ @Override @@ -322,6 +370,7 @@ - if (this.s()) { - nbttagcompound.set("FlowerPos", GameProfileSerializer.a(this.savedFlowerPos)); + if (this.hasSavedFlowerPos()) { + nbttagcompound.put("FlowerPos", GameProfileSerializer.writeBlockPos(this.savedFlowerPos)); } -+ nbttagcompound.setInt("Bukkit.MaxEntities", this.maxBees); // CraftBukkit ++ nbttagcompound.putInt("Bukkit.MaxEntities", this.maxBees); // CraftBukkit - return nbttagcompound; } + diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch index bc7c2267ea..50a7b0b271 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch @@ -60,9 +60,9 @@ @@ -109,8 +152,19 @@ ItemStack itemstack = (ItemStack) tileentitybrewingstand.items.get(4); - if (tileentitybrewingstand.fuel <= 0 && itemstack.a(Items.BLAZE_POWDER)) { + if (tileentitybrewingstand.fuel <= 0 && itemstack.is(Items.BLAZE_POWDER)) { - tileentitybrewingstand.fuel = 20; -- itemstack.subtract(1); +- itemstack.shrink(1); + // CraftBukkit start + BrewingStandFuelEvent event = new BrewingStandFuelEvent(CraftBlock.at(world, blockposition), CraftItemStack.asCraftMirror(itemstack), 20); + world.getCraftServer().getPluginManager().callEvent(event); @@ -73,10 +73,10 @@ + + tileentitybrewingstand.fuel = event.getFuelPower(); + if (tileentitybrewingstand.fuel > 0 && event.isConsuming()) { -+ itemstack.subtract(1); ++ itemstack.shrink(1); + } + // CraftBukkit end - a(world, blockposition, iblockdata); + setChanged(world, blockposition, iblockdata); } @@ -118,12 +172,17 @@ @@ -95,24 +95,24 @@ + // CraftBukkit end if (flag2 && flag) { -- a(world, blockposition, tileentitybrewingstand.items); -+ a(world, blockposition, tileentitybrewingstand.items, tileentitybrewingstand); // CraftBukkit - a(world, blockposition, iblockdata); - } else if (!flag || !itemstack1.a(tileentitybrewingstand.ingredient)) { +- doBrew(world, blockposition, tileentitybrewingstand.items); ++ doBrew(world, blockposition, tileentitybrewingstand.items, tileentitybrewingstand); // CraftBukkit + setChanged(world, blockposition, iblockdata); + } else if (!flag || !itemstack1.is(tileentitybrewingstand.ingredient)) { tileentitybrewingstand.brewTime = 0; @@ -187,11 +246,33 @@ } } -- private static void a(World world, BlockPosition blockposition, NonNullList<ItemStack> nonnulllist) { +- private static void doBrew(World world, BlockPosition blockposition, NonNullList<ItemStack> nonnulllist) { + // CraftBukkit start -+ private static void a(World world, BlockPosition blockposition, NonNullList<ItemStack> nonnulllist, TileEntityBrewingStand tileentitybrewingstand) { ++ private static void doBrew(World world, BlockPosition blockposition, NonNullList<ItemStack> nonnulllist, TileEntityBrewingStand tileentitybrewingstand) { ItemStack itemstack = (ItemStack) nonnulllist.get(3); + InventoryHolder owner = tileentitybrewingstand.getOwner(); -+ + List<org.bukkit.inventory.ItemStack> brewResults = new ArrayList<>(3); ++ + for (int i = 0; i < 3; ++i) { -+ brewResults.add(i, CraftItemStack.asCraftMirror(PotionBrewer.d(itemstack, (ItemStack) nonnulllist.get(i)))); ++ brewResults.add(i, CraftItemStack.asCraftMirror(PotionBrewer.mix(itemstack, (ItemStack) nonnulllist.get(i)))); + } + + if (owner != null) { @@ -125,7 +125,7 @@ + // CraftBukkit end for (int i = 0; i < 3; ++i) { -- nonnulllist.set(i, PotionBrewer.d(itemstack, (ItemStack) nonnulllist.get(i))); +- nonnulllist.set(i, PotionBrewer.mix(itemstack, (ItemStack) nonnulllist.get(i))); + // CraftBukkit start - validate index in case it is cleared by plugins + if (i < brewResults.size()) { + nonnulllist.set(i, CraftItemStack.asNMSCopy(brewResults.get(i))); @@ -135,4 +135,4 @@ + // CraftBukkit end } - itemstack.subtract(1); + itemstack.shrink(1); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch index fe9f6706f2..43f0da3cb2 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch +++ b/paper-server/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 -@@ -21,6 +21,12 @@ +@@ -20,6 +20,12 @@ import net.minecraft.world.level.block.BlockCampfire; import net.minecraft.world.level.block.state.IBlockData; @@ -13,8 +13,8 @@ public class TileEntityCampfire extends TileEntity implements Clearable { private static final int BURN_COOL_SPEED = 2; -@@ -52,6 +58,20 @@ - return recipecampfire.a(inventorysubcontainer); +@@ -51,6 +57,20 @@ + return recipecampfire.assemble(inventorysubcontainer); }).orElse(itemstack); + // CraftBukkit start - fire BlockCookEvent @@ -31,6 +31,6 @@ + result = blockCookEvent.getResult(); + itemstack1 = CraftItemStack.asNMSCopy(result); + // CraftBukkit end - InventoryUtils.dropItem(world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1); + InventoryUtils.dropItemStack(world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1); tileentitycampfire.items.set(i, ItemStack.EMPTY); - world.notify(blockposition, iblockdata, iblockdata, 3); + world.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityChest.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityChest.patch index 41bc9995b3..328ceec04e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityChest.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityChest.patch @@ -49,15 +49,15 @@ + protected TileEntityChest(TileEntityTypes<?> tileentitytypes, BlockPosition blockposition, IBlockData iblockdata) { super(tileentitytypes, blockposition, iblockdata); - this.items = NonNullList.a(27, ItemStack.EMPTY); -@@ -200,4 +236,11 @@ + this.items = NonNullList.withSize(27, ItemStack.EMPTY); +@@ -199,4 +235,11 @@ - world.playBlockAction(blockposition, block, 1, j); + world.blockEvent(blockposition, block, 1, j); } + + // CraftBukkit start + @Override -+ public boolean isFilteredNBT() { ++ public boolean onlyOpCanSetNbt() { + return true; + } + // CraftBukkit end diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityCommand.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityCommand.patch index 136de02976..76aef62fa6 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityCommand.patch +++ b/paper-server/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 @@ +@@ -20,6 +20,13 @@ + private boolean auto; private boolean conditionMet; - private boolean sendToClient; private final CommandBlockListenerAbstract commandBlock = new CommandBlockListenerAbstract() { + // CraftBukkit start + @Override diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch index 465df97f20..faa4cc3e3e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch @@ -12,25 +12,25 @@ public class TileEntityConduit extends TileEntity { private static final int BLOCK_REFRESH_RATE = 2; -@@ -205,7 +210,7 @@ +@@ -203,7 +208,7 @@ EntityHuman entityhuman = (EntityHuman) iterator.next(); - if (blockposition.a((BaseBlockPosition) entityhuman.getChunkCoordinates(), (double) j) && entityhuman.isInWaterOrRain()) { + if (blockposition.closerThan((BaseBlockPosition) 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 } } -@@ -234,8 +239,13 @@ +@@ -232,8 +237,13 @@ } if (tileentityconduit.destroyTarget != null) { -- world.playSound((EntityHuman) null, tileentityconduit.destroyTarget.locX(), tileentityconduit.destroyTarget.locY(), tileentityconduit.destroyTarget.locZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F); -- tileentityconduit.destroyTarget.damageEntity(DamageSource.MAGIC, 4.0F); +- world.playSound((EntityHuman) null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F); +- tileentityconduit.destroyTarget.hurt(DamageSource.MAGIC, 4.0F); + // CraftBukkit start + CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); -+ if (tileentityconduit.destroyTarget.damageEntity(DamageSource.MAGIC, 4.0F)) { -+ world.playSound((EntityHuman) null, tileentityconduit.destroyTarget.locX(), tileentityconduit.destroyTarget.locY(), tileentityconduit.destroyTarget.locZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F); ++ if (tileentityconduit.destroyTarget.hurt(DamageSource.MAGIC, 4.0F)) { ++ world.playSound((EntityHuman) null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F); + } + CraftEventFactory.blockDamage = null; + // CraftBukkit end diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityContainer.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityContainer.patch index 5319021869..bb36a0fa74 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityContainer.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityContainer.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/entity/TileEntityContainer.java +++ b/net/minecraft/world/level/block/entity/TileEntityContainer.java -@@ -90,4 +90,12 @@ +@@ -89,4 +89,12 @@ } - protected abstract Container createContainer(int i, PlayerInventory playerinventory); + protected abstract Container createMenu(int i, PlayerInventory playerinventory); + + // CraftBukkit start + @Override diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityDispenser.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityDispenser.patch index 3776af10fe..f0dcaf0825 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityDispenser.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityDispenser.patch @@ -1,12 +1,11 @@ --- a/net/minecraft/world/level/block/entity/TileEntityDispenser.java +++ b/net/minecraft/world/level/block/entity/TileEntityDispenser.java -@@ -14,12 +14,49 @@ +@@ -14,12 +14,48 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.IBlockData; +// CraftBukkit start +import java.util.List; -+ +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.entity.HumanEntity; +// CraftBukkit end @@ -49,4 +48,4 @@ + protected TileEntityDispenser(TileEntityTypes<?> tileentitytypes, BlockPosition blockposition, IBlockData iblockdata) { super(tileentitytypes, blockposition, iblockdata); - this.items = NonNullList.a(9, ItemStack.EMPTY); + this.items = NonNullList.withSize(9, ItemStack.EMPTY); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch index e0127865a4..357031c5ae 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch +++ b/paper-server/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 -@@ -32,6 +32,14 @@ +@@ -31,6 +31,14 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -15,16 +15,16 @@ public class TileEntityEndGateway extends TileEntityEnderPortal { private static final Logger LOGGER = LogManager.getLogger(); -@@ -170,7 +178,7 @@ +@@ -167,7 +175,7 @@ tileentityendgateway.teleportCooldown = 100; BlockPosition blockposition1; -- if (tileentityendgateway.exitPortal == null && world.getDimensionKey() == World.END) { +- if (tileentityendgateway.exitPortal == null && world.dimension() == World.END) { + if (tileentityendgateway.exitPortal == null && world.getTypeKey() == DimensionManager.END_LOCATION) { // CraftBukkit - work in alternate worlds - blockposition1 = a(worldserver, blockposition); - blockposition1 = blockposition1.up(10); + blockposition1 = findOrCreateValidTeleportPos(worldserver, blockposition); + blockposition1 = blockposition1.above(10); TileEntityEndGateway.LOGGER.debug("Creating portal at {}", blockposition1); -@@ -199,6 +207,27 @@ +@@ -196,6 +204,27 @@ entity1 = entity.getRootVehicle(); } @@ -41,23 +41,14 @@ + return; + } + -+ entity1.resetPortalCooldown(); ++ entity1.setPortalCooldown(); + ((EntityPlayer) entity1).connection.teleport(teleEvent.getTo()); -+ c(world, blockposition, iblockdata, tileentityendgateway); // CraftBukkit - call at end of method ++ triggerCooldown(world, blockposition, iblockdata, tileentityendgateway); // CraftBukkit - call at end of method + return; + + } + // CraftBukkit end + - entity1.resetPortalCooldown(); - entity1.enderTeleportAndLoad((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D); + entity1.setPortalCooldown(); + entity1.teleportToWithTicket((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D); } -@@ -310,7 +339,7 @@ - } - - private static void a(WorldServer worldserver, BlockPosition blockposition, WorldGenEndGatewayConfiguration worldgenendgatewayconfiguration) { -- WorldGenerator.END_GATEWAY.b((WorldGenFeatureConfiguration) worldgenendgatewayconfiguration).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition); -+ WorldGenerator.END_GATEWAY.b(worldgenendgatewayconfiguration).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition); // CraftBukkit - decompile error - } - - @Override diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch index a5b1c290a4..64ae78b309 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch @@ -55,23 +55,23 @@ + } + // CraftBukkit end + - private static boolean b(Item item) { - return TagsItem.NON_FLAMMABLE_WOOD.isTagged(item); + private static boolean isNeverAFurnaceFuel(Item item) { + return TagsItem.NON_FLAMMABLE_WOOD.contains(item); } -@@ -266,13 +310,24 @@ - tileentityfurnace.cookingProgress = MathHelper.clamp(tileentityfurnace.cookingProgress - 2, 0, tileentityfurnace.cookingTotalTime); +@@ -265,13 +309,24 @@ + tileentityfurnace.cookingProgress = MathHelper.clamp(tileentityfurnace.cookingProgress - 2, (int) 0, tileentityfurnace.cookingTotalTime); } } else { -- IRecipe<?> irecipe = (IRecipe) world.getCraftingManager().craft(tileentityfurnace.recipeType, tileentityfurnace, world).orElse((Object) null); -+ IRecipe<?> irecipe = (IRecipe) world.getCraftingManager().craft((Recipes<RecipeCooking>) tileentityfurnace.recipeType, tileentityfurnace, world).orElse(null); // CraftBukkit - decompile error // Eclipse fail +- IRecipe<?> irecipe = (IRecipe) world.getRecipeManager().getRecipeFor(tileentityfurnace.recipeType, tileentityfurnace, world).orElse((Object) null); ++ IRecipe<?> irecipe = (IRecipe) world.getRecipeManager().getRecipeFor((Recipes<RecipeCooking>) tileentityfurnace.recipeType, tileentityfurnace, world).orElse(null); // CraftBukkit - decompile error // Eclipse fail int i = tileentityfurnace.getMaxStackSize(); - if (!tileentityfurnace.isBurning() && canBurn(irecipe, tileentityfurnace.items, i)) { -- tileentityfurnace.litTime = tileentityfurnace.fuelTime(itemstack); + if (!tileentityfurnace.isLit() && canBurn(irecipe, tileentityfurnace.items, i)) { +- tileentityfurnace.litTime = tileentityfurnace.getBurnDuration(itemstack); + // CraftBukkit start + CraftItemStack fuel = CraftItemStack.asCraftMirror(itemstack); + -+ FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(CraftBlock.at(world, blockposition), fuel, tileentityfurnace.fuelTime(itemstack)); ++ FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(CraftBlock.at(world, blockposition), fuel, tileentityfurnace.getBurnDuration(itemstack)); + world.getCraftServer().getPluginManager().callEvent(furnaceBurnEvent); + + if (furnaceBurnEvent.isCancelled()) { @@ -80,16 +80,16 @@ + + tileentityfurnace.litTime = furnaceBurnEvent.getBurnTime(); tileentityfurnace.litDuration = tileentityfurnace.litTime; -- if (tileentityfurnace.isBurning()) { -+ if (tileentityfurnace.isBurning() && furnaceBurnEvent.isBurning()) { +- if (tileentityfurnace.isLit()) { ++ if (tileentityfurnace.isLit() && furnaceBurnEvent.isBurning()) { + // CraftBukkit end flag1 = true; if (!itemstack.isEmpty()) { Item item = itemstack.getItem(); -@@ -288,11 +343,23 @@ +@@ -287,11 +342,23 @@ } - if (tileentityfurnace.isBurning() && canBurn(irecipe, tileentityfurnace.items, i)) { + if (tileentityfurnace.isLit() && canBurn(irecipe, tileentityfurnace.items, i)) { + // CraftBukkit start + if (irecipe != null && tileentityfurnace.cookingProgress == 0) { + CraftItemStack source = CraftItemStack.asCraftMirror(tileentityfurnace.items.get(0)); @@ -105,13 +105,13 @@ ++tileentityfurnace.cookingProgress; if (tileentityfurnace.cookingProgress == tileentityfurnace.cookingTotalTime) { tileentityfurnace.cookingProgress = 0; - tileentityfurnace.cookingTotalTime = getRecipeCookingTime(world, tileentityfurnace.recipeType, tileentityfurnace); + tileentityfurnace.cookingTotalTime = getTotalCookTime(world, tileentityfurnace.recipeType, tileentityfurnace); - if (burn(irecipe, tileentityfurnace.items, i)) { + if (burn(tileentityfurnace.level, tileentityfurnace.worldPosition, irecipe, tileentityfurnace.items, i)) { // CraftBukkit tileentityfurnace.setRecipeUsed(irecipe); } -@@ -331,17 +398,44 @@ +@@ -330,17 +397,44 @@ } } @@ -119,7 +119,7 @@ + private static boolean burn(World world, BlockPosition blockposition, @Nullable IRecipe<?> irecipe, NonNullList<ItemStack> nonnulllist, int i) { // CraftBukkit if (irecipe != null && canBurn(irecipe, nonnulllist, i)) { ItemStack itemstack = (ItemStack) nonnulllist.get(0); - ItemStack itemstack1 = irecipe.getResult(); + ItemStack itemstack1 = irecipe.getResultItem(); ItemStack itemstack2 = (ItemStack) nonnulllist.get(2); + // CraftBukkit start - fire FurnaceSmeltEvent @@ -138,9 +138,9 @@ + + if (!itemstack1.isEmpty()) { + if (itemstack2.isEmpty()) { -+ nonnulllist.set(2, itemstack1.cloneItemStack()); ++ nonnulllist.set(2, itemstack1.copy()); + } else if (CraftItemStack.asCraftMirror(itemstack2).isSimilar(result)) { -+ itemstack2.add(itemstack1.getCount()); ++ itemstack2.grow(itemstack1.getCount()); + } else { + return false; + } @@ -148,65 +148,65 @@ + + /* if (itemstack2.isEmpty()) { - nonnulllist.set(2, itemstack1.cloneItemStack()); - } else if (itemstack2.a(itemstack1.getItem())) { - itemstack2.add(1); + nonnulllist.set(2, itemstack1.copy()); + } else if (itemstack2.is(itemstack1.getItem())) { + itemstack2.grow(1); } + */ + // CraftBukkit end - if (itemstack.a(Blocks.WET_SPONGE.getItem()) && !((ItemStack) nonnulllist.get(1)).isEmpty() && ((ItemStack) nonnulllist.get(1)).a(Items.BUCKET)) { + 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)); -@@ -365,7 +459,7 @@ +@@ -364,7 +458,7 @@ } - private static int getRecipeCookingTime(World world, Recipes<? extends RecipeCooking> recipes, IInventory iinventory) { -- return (Integer) world.getCraftingManager().craft(recipes, iinventory, world).map(RecipeCooking::getCookingTime).orElse(200); -+ return (world != null) ? (Integer) world.getCraftingManager().craft((Recipes<RecipeCooking>) recipes, iinventory, world).map(RecipeCooking::getCookingTime).orElse(200) : 200; // CraftBukkit - SPIGOT-4302 // Eclipse fail + private static int getTotalCookTime(World world, Recipes<? extends RecipeCooking> recipes, IInventory iinventory) { +- return (Integer) world.getRecipeManager().getRecipeFor(recipes, iinventory, world).map(RecipeCooking::getCookingTime).orElse(200); ++ return (world != null) ? (Integer) world.getRecipeManager().getRecipeFor((Recipes<RecipeCooking>) recipes, iinventory, world).map(RecipeCooking::getCookingTime).orElse(200) : 200; // CraftBukkit - SPIGOT-4302 // Eclipse fail } public static boolean isFuel(ItemStack itemstack) { -@@ -484,14 +578,20 @@ +@@ -483,14 +577,20 @@ @Override public void awardUsedRecipes(EntityHuman entityhuman) {} -- public void a(EntityPlayer entityplayer) { -- List<IRecipe<?>> list = this.a(entityplayer.getWorldServer(), entityplayer.getPositionVector()); -+ public void a(EntityPlayer entityplayer, ItemStack itemstack, int amount) { // CraftBukkit -+ List<IRecipe<?>> list = this.a(entityplayer.getWorldServer(), entityplayer.getPositionVector(), this.worldPosition, entityplayer, itemstack, amount); // CraftBukkit +- public void awardUsedRecipesAndPopExperience(EntityPlayer entityplayer) { +- List<IRecipe<?>> list = this.getRecipesToAwardAndPopExperience(entityplayer.getLevel(), entityplayer.position()); ++ public void awardUsedRecipesAndPopExperience(EntityPlayer entityplayer, ItemStack itemstack, int amount) { // CraftBukkit ++ List<IRecipe<?>> list = this.getRecipesToAwardAndPopExperience(entityplayer.getLevel(), entityplayer.position(), this.worldPosition, entityplayer, itemstack, amount); // CraftBukkit - entityplayer.discoverRecipes(list); + entityplayer.awardRecipes(list); this.recipesUsed.clear(); } - public List<IRecipe<?>> a(WorldServer worldserver, Vec3D vec3d) { + public List<IRecipe<?>> getRecipesToAwardAndPopExperience(WorldServer worldserver, Vec3D vec3d) { + // CraftBukkit start -+ return this.a(worldserver, vec3d, this.worldPosition, null, null, 0); ++ return this.getRecipesToAwardAndPopExperience(worldserver, vec3d, this.worldPosition, null, null, 0); + } + -+ public List<IRecipe<?>> a(WorldServer worldserver, Vec3D vec3d, BlockPosition blockposition, EntityPlayer entityplayer, ItemStack itemstack, int amount) { ++ public List<IRecipe<?>> getRecipesToAwardAndPopExperience(WorldServer worldserver, Vec3D vec3d, BlockPosition blockposition, EntityPlayer entityplayer, ItemStack itemstack, int amount) { + // CraftBukkit end List<IRecipe<?>> list = Lists.newArrayList(); ObjectIterator objectiterator = this.recipesUsed.object2IntEntrySet().iterator(); -@@ -500,14 +600,14 @@ +@@ -499,14 +599,14 @@ - worldserver.getCraftingManager().getRecipe((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> { + worldserver.getRecipeManager().byKey((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> { list.add(irecipe); -- a(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience()); -+ a(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit +- createExperience(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience()); ++ createExperience(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit }); } return list; } -- private static void a(WorldServer worldserver, Vec3D vec3d, int i, float f) { -+ private static void a(WorldServer worldserver, Vec3D vec3d, int i, float f, BlockPosition blockposition, EntityHuman entityhuman, ItemStack itemstack, int amount) { // CraftBukkit - int j = MathHelper.d((float) i * f); - float f1 = MathHelper.h((float) i * f); +- private static void createExperience(WorldServer worldserver, Vec3D vec3d, int i, float f) { ++ private static void createExperience(WorldServer worldserver, Vec3D vec3d, int i, float f, BlockPosition blockposition, EntityHuman entityhuman, ItemStack itemstack, int amount) { // CraftBukkit + int j = MathHelper.floor((float) i * f); + float f1 = MathHelper.frac((float) i * f); -@@ -515,6 +615,17 @@ +@@ -514,6 +614,17 @@ ++j; } @@ -221,6 +221,6 @@ + j = event.getExpToDrop(); + // CraftBukkit end + - EntityExperienceOrb.a(worldserver, vec3d, j); + EntityExperienceOrb.award(worldserver, vec3d, j); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityHopper.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityHopper.patch index f17ab99cf2..ac1de97903 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityHopper.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityHopper.patch @@ -55,34 +55,34 @@ + public TileEntityHopper(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.HOPPER, blockposition, iblockdata); - this.items = NonNullList.a(5, ItemStack.EMPTY); -@@ -115,7 +157,7 @@ + this.items = NonNullList.withSize(5, ItemStack.EMPTY); +@@ -114,7 +156,7 @@ boolean flag = false; if (!tileentityhopper.isEmpty()) { -- flag = a(world, blockposition, iblockdata, (IInventory) tileentityhopper); -+ flag = a(world, blockposition, iblockdata, (IInventory) tileentityhopper, tileentityhopper); // CraftBukkit +- flag = ejectItems(world, blockposition, iblockdata, tileentityhopper); ++ flag = ejectItems(world, blockposition, iblockdata, (IInventory) tileentityhopper, tileentityhopper); // CraftBukkit } - if (!tileentityhopper.i()) { -@@ -149,7 +191,7 @@ + if (!tileentityhopper.inventoryFull()) { +@@ -148,7 +190,7 @@ return false; } -- private static boolean a(World world, BlockPosition blockposition, IBlockData iblockdata, IInventory iinventory) { -+ private static boolean a(World world, BlockPosition blockposition, IBlockData iblockdata, IInventory iinventory, TileEntityHopper hopper) { // CraftBukkit - IInventory iinventory1 = b(world, blockposition, iblockdata); +- private static boolean ejectItems(World world, BlockPosition blockposition, IBlockData iblockdata, IInventory iinventory) { ++ private static boolean ejectItems(World world, BlockPosition blockposition, IBlockData iblockdata, IInventory iinventory, TileEntityHopper hopper) { // CraftBukkit + IInventory iinventory1 = getAttachedContainer(world, blockposition, iblockdata); if (iinventory1 == null) { -@@ -163,7 +205,28 @@ - for (int i = 0; i < iinventory.getSize(); ++i) { +@@ -162,7 +204,28 @@ + for (int i = 0; i < iinventory.getContainerSize(); ++i) { if (!iinventory.getItem(i).isEmpty()) { - ItemStack itemstack = iinventory.getItem(i).cloneItemStack(); -- ItemStack itemstack1 = addItem(iinventory, iinventory1, iinventory.splitStack(i, 1), enumdirection); -+ // ItemStack itemstack1 = addItem(iinventory, iinventory1, iinventory.splitStack(i, 1), enumdirection); + ItemStack itemstack = iinventory.getItem(i).copy(); +- ItemStack itemstack1 = addItem(iinventory, iinventory1, iinventory.removeItem(i, 1), enumdirection); ++ // ItemStack itemstack1 = addItem(iinventory, iinventory1, iinventory.removeItem(i, 1), enumdirection); + + // CraftBukkit start - Call event when pushing items into other inventories -+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, 1)); ++ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, 1)); + + Inventory destinationInventory; + // Have to special case large chests as they work oddly @@ -103,15 +103,15 @@ + // CraftBukkit end if (itemstack1.isEmpty()) { - iinventory1.update(); -@@ -228,7 +291,34 @@ + iinventory1.setChanged(); +@@ -227,7 +290,34 @@ - if (!itemstack.isEmpty() && b(iinventory, itemstack, i, enumdirection)) { - ItemStack itemstack1 = itemstack.cloneItemStack(); -- ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.splitStack(i, 1), (EnumDirection) null); -+ // ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.splitStack(i, 1), (EnumDirection) null); + if (!itemstack.isEmpty() && canTakeItemFromContainer(iinventory, itemstack, i, enumdirection)) { + ItemStack itemstack1 = itemstack.copy(); +- ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.removeItem(i, 1), (EnumDirection) null); ++ // ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.removeItem(i, 1), (EnumDirection) null); + // CraftBukkit start - Call event on collection of items from inventories into the hopper -+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, 1)); ++ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, 1)); + + Inventory sourceInventory; + // Have to special case large chests as they work oddly @@ -139,10 +139,10 @@ + // CraftBukkit end if (itemstack2.isEmpty()) { - iinventory.update(); -@@ -243,6 +333,13 @@ + iinventory.setChanged(); +@@ -242,6 +332,13 @@ - public static boolean a(IInventory iinventory, EntityItem entityitem) { + public static boolean addItem(IInventory iinventory, EntityItem entityitem) { boolean flag = false; + // CraftBukkit start + InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory.getOwner().getInventory(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); @@ -151,6 +151,6 @@ + return false; + } + // CraftBukkit end - ItemStack itemstack = entityitem.getItemStack().cloneItemStack(); + ItemStack itemstack = entityitem.getItem().copy(); ItemStack itemstack1 = addItem((IInventory) null, iinventory, itemstack, (EnumDirection) null); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch index 546c65c42a..340a52d7c6 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch +++ b/paper-server/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 -@@ -27,13 +27,71 @@ +@@ -26,13 +26,71 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; @@ -72,9 +72,9 @@ + // CraftBukkit end + @Override - public int getSize() { + public int getContainerSize() { return 1; -@@ -78,11 +136,20 @@ +@@ -77,11 +135,20 @@ } @Override @@ -83,8 +83,8 @@ + public void setItem(int i, ItemStack itemstack) { + if (i == 0) { + TileEntityLectern.this.setBook(itemstack); -+ if (TileEntityLectern.this.getWorld() != null) { -+ BlockLectern.setHasBook(TileEntityLectern.this.getWorld(), TileEntityLectern.this.getPosition(), TileEntityLectern.this.getBlock(), TileEntityLectern.this.hasBook()); ++ if (TileEntityLectern.this.getLevel() != null) { ++ BlockLectern.resetBookState(TileEntityLectern.this.getLevel(), TileEntityLectern.this.getBlockPos(), TileEntityLectern.this.getBlockState(), TileEntityLectern.this.hasBook()); + } + } + } @@ -97,16 +97,16 @@ } @Override -@@ -162,7 +229,7 @@ +@@ -161,7 +228,7 @@ if (j != this.page) { this.page = j; - this.update(); -- BlockLectern.a(this.getWorld(), this.getPosition(), this.getBlock()); -+ if (this.level != null) BlockLectern.a(this.getWorld(), this.getPosition(), this.getBlock()); // CraftBukkit + this.setChanged(); +- BlockLectern.signalPageChange(this.getLevel(), this.getBlockPos(), this.getBlockState()); ++ if (this.level != null) BlockLectern.signalPageChange(this.getLevel(), this.getBlockPos(), this.getBlockState()); // CraftBukkit } } -@@ -185,6 +252,32 @@ +@@ -184,6 +251,32 @@ return itemstack; } @@ -121,35 +121,35 @@ + } + + @Override -+ public boolean shouldSendSuccess() { ++ public boolean acceptsSuccess() { + return false; + } + + @Override -+ public boolean shouldSendFailure() { ++ public boolean acceptsFailure() { + return false; + } + + @Override -+ public boolean shouldBroadcastCommands() { ++ public boolean shouldInformAdmins() { + return false; + } + + // CraftBukkit end - private CommandListenerWrapper a(@Nullable EntityHuman entityhuman) { + private CommandListenerWrapper createCommandSourceStack(@Nullable EntityHuman entityhuman) { String s; Object object; -@@ -199,7 +292,8 @@ +@@ -198,7 +291,8 @@ - Vec3D vec3d = Vec3D.a((BaseBlockPosition) this.worldPosition); + Vec3D vec3d = Vec3D.atCenterOf(this.worldPosition); -- return new CommandListenerWrapper(ICommandListener.NULL, vec3d, Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getMinecraftServer(), entityhuman); +- return new CommandListenerWrapper(ICommandListener.NULL, vec3d, Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getServer(), entityhuman); + // CraftBukkit - this -+ return new CommandListenerWrapper(this, vec3d, Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getMinecraftServer(), entityhuman); ++ return new CommandListenerWrapper(this, vec3d, Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getServer(), entityhuman); } @Override -@@ -238,7 +332,7 @@ +@@ -236,7 +330,7 @@ @Override public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch index 7694f833c1..712f9be770 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch @@ -49,20 +49,20 @@ + public TileEntityShulkerBox(@Nullable EnumColor enumcolor, BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.SHULKER_BOX, blockposition, iblockdata); - this.itemStacks = NonNullList.a(27, ItemStack.EMPTY); + this.itemStacks = NonNullList.withSize(27, ItemStack.EMPTY); @@ -163,6 +199,7 @@ } ++this.openCount; + if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call. - this.level.playBlockAction(this.worldPosition, this.getBlock().getBlock(), 1, this.openCount); + this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount); if (this.openCount == 1) { - this.level.a((Entity) entityhuman, GameEvent.CONTAINER_OPEN, this.worldPosition); + this.level.gameEvent(entityhuman, GameEvent.CONTAINER_OPEN, this.worldPosition); @@ -176,6 +213,7 @@ - public void closeContainer(EntityHuman entityhuman) { + public void stopOpen(EntityHuman entityhuman) { if (!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.playBlockAction(this.worldPosition, this.getBlock().getBlock(), 1, this.openCount); + this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount); if (this.openCount <= 0) { - this.level.a((Entity) entityhuman, GameEvent.CONTAINER_CLOSE, this.worldPosition); + this.level.gameEvent(entityhuman, GameEvent.CONTAINER_CLOSE, this.worldPosition); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch index bda80c85eb..1f2ebdcdd3 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntitySign.java +++ b/net/minecraft/world/level/block/entity/TileEntitySign.java -@@ -25,7 +25,7 @@ +@@ -24,7 +24,7 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; @@ -9,22 +9,22 @@ public static final int LINES = 4; private static final String[] RAW_TEXT_FIELD_NAMES = new String[]{"Text1", "Text2", "Text3", "Text4"}; -@@ -65,6 +65,12 @@ +@@ -64,6 +64,12 @@ } } + // CraftBukkit start + if (Boolean.getBoolean("convertLegacySigns")) { -+ nbttagcompound.setBoolean("Bukkit.isConverted", true); ++ nbttagcompound.putBoolean("Bukkit.isConverted", true); + } + // CraftBukkit end + - nbttagcompound.setString("Color", this.color.b()); - nbttagcompound.setBoolean("GlowingText", this.hasGlowingText); - return nbttagcompound; -@@ -76,8 +82,24 @@ + nbttagcompound.putString("Color", this.color.getName()); + nbttagcompound.putBoolean("GlowingText", this.hasGlowingText); + } +@@ -74,8 +80,24 @@ super.load(nbttagcompound); - this.color = EnumColor.a(nbttagcompound.getString("Color"), EnumColor.BLACK); + this.color = EnumColor.byName(nbttagcompound.getString("Color"), EnumColor.BLACK); + // CraftBukkit start - Add an option to convert signs correctly + // This is done with a flag instead of all the time because @@ -44,10 +44,10 @@ + continue; + } + // CraftBukkit end - IChatBaseComponent ichatbasecomponent = this.a(s); + IChatBaseComponent ichatbasecomponent = this.loadLine(s); this.messages[i] = ichatbasecomponent; -@@ -115,6 +137,10 @@ +@@ -113,6 +135,10 @@ if (ichatmutablecomponent != null) { return ichatmutablecomponent; } @@ -58,7 +58,7 @@ } catch (Exception exception) { ; } -@@ -207,11 +233,37 @@ +@@ -204,11 +230,37 @@ return true; } @@ -72,36 +72,36 @@ + } + + @Override -+ public boolean shouldSendSuccess() { ++ public boolean acceptsSuccess() { + return false; + } + + @Override -+ public boolean shouldSendFailure() { ++ public boolean acceptsFailure() { + return false; + } + + @Override -+ public boolean shouldBroadcastCommands() { ++ public boolean shouldInformAdmins() { + return false; + } + // CraftBukkit end + - public CommandListenerWrapper b(@Nullable EntityPlayer entityplayer) { - String s = entityplayer == null ? "Sign" : entityplayer.getDisplayName().getString(); - Object object = entityplayer == null ? new ChatComponentText("Sign") : entityplayer.getScoreboardDisplayName(); + public CommandListenerWrapper createCommandSourceStack(@Nullable EntityPlayer entityplayer) { + String s = entityplayer == null ? "Sign" : entityplayer.getName().getString(); + Object object = entityplayer == null ? new ChatComponentText("Sign") : entityplayer.getDisplayName(); -- return new CommandListenerWrapper(ICommandListener.NULL, Vec3D.a((BaseBlockPosition) this.worldPosition), Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getMinecraftServer(), entityplayer); +- return new CommandListenerWrapper(ICommandListener.NULL, Vec3D.atCenterOf(this.worldPosition), Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getServer(), entityplayer); + // CraftBukkit - this -+ return new CommandListenerWrapper(this, Vec3D.a((BaseBlockPosition) this.worldPosition), Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getMinecraftServer(), entityplayer); ++ return new CommandListenerWrapper(this, Vec3D.atCenterOf(this.worldPosition), Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getServer(), entityplayer); } public EnumColor getColor() { -@@ -244,6 +296,6 @@ +@@ -241,6 +293,6 @@ - private void i() { - this.update(); -- this.level.notify(this.getPosition(), this.getBlock(), this.getBlock(), 3); -+ if (this.level != null) this.level.notify(this.getPosition(), this.getBlock(), this.getBlock(), 3); // CraftBukkit - skip notify if world is null (SPIGOT-5122) + private void markUpdated() { + this.setChanged(); +- this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3); ++ if (this.level != null) this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3); // CraftBukkit - skip notify if world is null (SPIGOT-5122) } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.patch b/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.patch index 020dc1dacf..6685ebccd9 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.java +++ b/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.java -@@ -38,6 +38,7 @@ +@@ -37,6 +37,7 @@ if (worldgenfeatureconfigured == null) { return false; } else { + setTreeType(worldgenfeatureconfigured); // CraftBukkit - IBlockData iblockdata1 = Blocks.AIR.getBlockData(); + IBlockData iblockdata1 = Blocks.AIR.defaultBlockState(); - worldserver.setTypeAndData(blockposition.c(i, 0, j), iblockdata1, 4); + worldserver.setBlock(blockposition.offset(i, 0, j), iblockdata1, 4); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch b/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch index d8c128b32f..691ad307e4 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/grower/WorldGenTreeProvider.java +++ b/net/minecraft/world/level/block/grower/WorldGenTreeProvider.java -@@ -14,6 +14,12 @@ +@@ -13,6 +13,12 @@ + import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.levelgen.feature.WorldGenFeatureConfigured; - import net.minecraft.world.level.levelgen.feature.configurations.WorldGenFeatureTreeConfiguration; +// CraftBukkit start -+import net.minecraft.data.worldgen.BiomeDecoratorGroups; ++import net.minecraft.data.worldgen.features.TreeFeatures; +import net.minecraft.world.level.block.BlockSapling; +import org.bukkit.TreeType; +// CraftBukkit end @@ -13,56 +13,56 @@ public abstract class WorldGenTreeProvider { public WorldGenTreeProvider() {} -@@ -27,6 +33,7 @@ +@@ -26,6 +32,7 @@ if (worldgenfeatureconfigured == null) { return false; } else { + setTreeType(worldgenfeatureconfigured); // CraftBukkit - worldserver.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 4); - if (worldgenfeatureconfigured.a(worldserver, chunkgenerator, random, blockposition)) { + worldserver.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 4); + if (worldgenfeatureconfigured.place(worldserver, chunkgenerator, random, blockposition)) { return true; -@@ -52,4 +59,48 @@ +@@ -51,4 +58,48 @@ return true; } + + // CraftBukkit start + protected void setTreeType(WorldGenFeatureConfigured<?, ?> worldgentreeabstract) { -+ if (worldgentreeabstract == BiomeDecoratorGroups.OAK || worldgentreeabstract == BiomeDecoratorGroups.OAK_BEES_005) { ++ if (worldgentreeabstract == TreeFeatures.OAK || worldgentreeabstract == TreeFeatures.OAK_BEES_005) { + BlockSapling.treeType = TreeType.TREE; -+ } else if (worldgentreeabstract == BiomeDecoratorGroups.HUGE_RED_MUSHROOM) { ++ } else if (worldgentreeabstract == TreeFeatures.HUGE_RED_MUSHROOM) { + BlockSapling.treeType = TreeType.RED_MUSHROOM; -+ } else if (worldgentreeabstract == BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM) { ++ } else if (worldgentreeabstract == TreeFeatures.HUGE_BROWN_MUSHROOM) { + BlockSapling.treeType = TreeType.BROWN_MUSHROOM; -+ } else if (worldgentreeabstract == BiomeDecoratorGroups.JUNGLE_TREE) { ++ } else if (worldgentreeabstract == TreeFeatures.JUNGLE_TREE) { + BlockSapling.treeType = TreeType.COCOA_TREE; -+ } else if (worldgentreeabstract == BiomeDecoratorGroups.JUNGLE_TREE_NO_VINE) { ++ } else if (worldgentreeabstract == TreeFeatures.JUNGLE_TREE_NO_VINE) { + BlockSapling.treeType = TreeType.SMALL_JUNGLE; -+ } else if (worldgentreeabstract == BiomeDecoratorGroups.PINE) { ++ } else if (worldgentreeabstract == TreeFeatures.PINE) { + BlockSapling.treeType = TreeType.TALL_REDWOOD; -+ } else if (worldgentreeabstract == BiomeDecoratorGroups.SPRUCE) { ++ } else if (worldgentreeabstract == TreeFeatures.SPRUCE) { + BlockSapling.treeType = TreeType.REDWOOD; -+ } else if (worldgentreeabstract == BiomeDecoratorGroups.ACACIA) { ++ } else if (worldgentreeabstract == TreeFeatures.ACACIA) { + BlockSapling.treeType = TreeType.ACACIA; -+ } else if (worldgentreeabstract == BiomeDecoratorGroups.BIRCH || worldgentreeabstract == BiomeDecoratorGroups.BIRCH_BEES_005) { ++ } else if (worldgentreeabstract == TreeFeatures.BIRCH || worldgentreeabstract == TreeFeatures.BIRCH_BEES_005) { + BlockSapling.treeType = TreeType.BIRCH; -+ } else if (worldgentreeabstract == BiomeDecoratorGroups.SUPER_BIRCH_BEES_0002) { ++ } else if (worldgentreeabstract == TreeFeatures.SUPER_BIRCH_BEES_0002) { + BlockSapling.treeType = TreeType.TALL_BIRCH; -+ } else if (worldgentreeabstract == BiomeDecoratorGroups.SWAMP_OAK) { ++ } else if (worldgentreeabstract == TreeFeatures.SWAMP_OAK) { + BlockSapling.treeType = TreeType.SWAMP; -+ } else if (worldgentreeabstract == BiomeDecoratorGroups.FANCY_OAK || worldgentreeabstract == BiomeDecoratorGroups.FANCY_OAK_BEES_005) { ++ } else if (worldgentreeabstract == TreeFeatures.FANCY_OAK || worldgentreeabstract == TreeFeatures.FANCY_OAK_BEES_005) { + BlockSapling.treeType = TreeType.BIG_TREE; -+ } else if (worldgentreeabstract == BiomeDecoratorGroups.JUNGLE_BUSH) { ++ } else if (worldgentreeabstract == TreeFeatures.JUNGLE_BUSH) { + BlockSapling.treeType = TreeType.JUNGLE_BUSH; -+ } else if (worldgentreeabstract == BiomeDecoratorGroups.DARK_OAK) { ++ } else if (worldgentreeabstract == TreeFeatures.DARK_OAK) { + BlockSapling.treeType = TreeType.DARK_OAK; -+ } else if (worldgentreeabstract == BiomeDecoratorGroups.MEGA_SPRUCE) { ++ } else if (worldgentreeabstract == TreeFeatures.MEGA_SPRUCE) { + BlockSapling.treeType = TreeType.MEGA_REDWOOD; -+ } else if (worldgentreeabstract == BiomeDecoratorGroups.MEGA_PINE) { ++ } else if (worldgentreeabstract == TreeFeatures.MEGA_PINE) { + BlockSapling.treeType = TreeType.MEGA_REDWOOD; -+ } else if (worldgentreeabstract == BiomeDecoratorGroups.MEGA_JUNGLE_TREE) { ++ } else if (worldgentreeabstract == TreeFeatures.MEGA_JUNGLE_TREE) { + BlockSapling.treeType = TreeType.JUNGLE; -+ } else if (worldgentreeabstract == BiomeDecoratorGroups.AZALEA_TREE) { ++ } else if (worldgentreeabstract == TreeFeatures.AZALEA_TREE) { + BlockSapling.treeType = TreeType.AZALEA; + } else { + throw new IllegalArgumentException("Unknown tree generator " + worldgentreeabstract); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch b/paper-server/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch index d1b32827d1..dbe75e8377 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch +++ b/paper-server/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 -@@ -39,6 +39,14 @@ +@@ -38,6 +38,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 BlockStateBoolean EXTENDED = BlockProperties.EXTENDED; -@@ -139,6 +147,18 @@ +@@ -138,6 +146,18 @@ } } @@ -31,18 +31,18 @@ + } + // PAIL: checkME - what happened to setTypeAndData? + // CraftBukkit end - world.playBlockAction(blockposition, this, b0, enumdirection.b()); + world.blockEvent(blockposition, this, b0, enumdirection.get3DDataValue()); } -@@ -317,6 +337,48 @@ +@@ -316,6 +336,48 @@ IBlockData[] aiblockdata = new IBlockData[list.size() + list2.size()]; - EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite(); + EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.getOpposite(); int j = 0; + // CraftBukkit start + final org.bukkit.block.Block bblock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + -+ final List<BlockPosition> moved = pistonextendschecker.getMovedBlocks(); -+ final List<BlockPosition> broken = pistonextendschecker.getBrokenBlocks(); ++ final List<BlockPosition> moved = pistonextendschecker.getToPush(); ++ final List<BlockPosition> broken = pistonextendschecker.getToDestroy(); + + List<org.bukkit.block.Block> blocks = new AbstractList<org.bukkit.block.Block>() { + @@ -70,12 +70,12 @@ + + if (event.isCancelled()) { + for (BlockPosition b : broken) { -+ world.notify(b, Blocks.AIR.getBlockData(), world.getType(b), 3); ++ world.sendBlockUpdated(b, Blocks.AIR.defaultBlockState(), world.getBlockState(b), 3); + } + for (BlockPosition b : moved) { -+ world.notify(b, Blocks.AIR.getBlockData(), world.getType(b), 3); -+ b = b.shift(enumdirection1); -+ world.notify(b, Blocks.AIR.getBlockData(), world.getType(b), 3); ++ world.sendBlockUpdated(b, Blocks.AIR.defaultBlockState(), world.getBlockState(b), 3); ++ b = b.relative(enumdirection1); ++ world.sendBlockUpdated(b, Blocks.AIR.defaultBlockState(), world.getBlockState(b), 3); + } + return false; + } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/state/properties/IBlockState.patch b/paper-server/nms-patches/net/minecraft/world/level/block/state/properties/IBlockState.patch new file mode 100644 index 0000000000..aceeb8d5af --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/level/block/state/properties/IBlockState.patch @@ -0,0 +1,63 @@ +--- a/net/minecraft/world/level/block/state/properties/IBlockState.java ++++ b/net/minecraft/world/level/block/state/properties/IBlockState.java +@@ -21,7 +21,7 @@ + + protected IBlockState(String s, Class<T> oclass) { + this.codec = Codec.STRING.comapFlatMap((s1) -> { +- return (DataResult) this.getValue(s1).map(DataResult::success).orElseGet(() -> { ++ return this.getValue(s1).map(DataResult::success).orElseGet(() -> { // CraftBukkit - decompile error + return DataResult.error("Unable to read property: " + this + " with value: " + s1); + }); + }, this::getName); +@@ -96,23 +96,27 @@ + DataResult<T> dataresult = this.codec.parse(dynamicops, u0); + + return dataresult.map((comparable) -> { +- return (IBlockDataHolder) s0.setValue(this, comparable); ++ return s0.setValue(this, comparable); // CraftBukkit - decompile error + }).setPartial(s0); + } + +- public static final class a extends Record { ++ // CraftBukkit start ++ public static final record a<T extends Comparable<T>>(IBlockState<T> property, T value) { + ++ /* + private final IBlockState<T> property; + private final T value; ++ */ + +- public a(IBlockState<T> iblockstate, T t0) { +- if (!iblockstate.getPossibleValues().contains(t0)) { +- throw new IllegalArgumentException("Value " + t0 + " does not belong to property " + iblockstate); ++ public a(IBlockState<T> property, T value) { ++ if (!property.getPossibleValues().contains(value)) { ++ throw new IllegalArgumentException("Value " + value + " does not belong to property " + property); + } else { +- this.property = iblockstate; +- this.value = t0; ++ this.property = property; ++ this.value = value; + } + } ++ // CraftBukkit end + + public String toString() { + String s = this.property.getName(); +@@ -120,6 +124,8 @@ + return s + "=" + this.property.getName(this.value); + } + ++ // CraftBukkit start ++ /* + public final int hashCode() { + return this.hashCode < invokedynamic > (this); + } +@@ -135,5 +141,7 @@ + public T value() { + return this.value; + } ++ */ ++ // CraftBukkit end + } + } diff --git a/paper-server/nms-patches/net/minecraft/world/level/border/WorldBorder.patch b/paper-server/nms-patches/net/minecraft/world/level/border/WorldBorder.patch index e82ac55833..30e7fd67a6 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/border/WorldBorder.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/border/WorldBorder.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/border/WorldBorder.java +++ b/net/minecraft/world/level/border/WorldBorder.java -@@ -28,6 +28,7 @@ +@@ -29,6 +29,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); @@ -8,10 +8,10 @@ public WorldBorder() {} -@@ -149,6 +150,7 @@ +@@ -164,6 +165,7 @@ } - public void a(IWorldBorderListener iworldborderlistener) { + public void addListener(IWorldBorderListener iworldborderlistener) { + if (listeners.contains(iworldborderlistener)) return; // CraftBukkit this.listeners.add(iworldborderlistener); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/BiomeStorage.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/BiomeStorage.patch deleted file mode 100644 index df6cec907a..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/BiomeStorage.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- a/net/minecraft/world/level/chunk/BiomeStorage.java -+++ b/net/minecraft/world/level/chunk/BiomeStorage.java -@@ -109,4 +109,14 @@ - - return this.biomes[i1 << BiomeStorage.WIDTH_BITS + BiomeStorage.WIDTH_BITS | j1 << BiomeStorage.WIDTH_BITS | l]; - } -+ -+ // CraftBukkit start -+ public void setBiome(int i, int j, int k, BiomeBase biome) { -+ int l = i & BiomeStorage.HORIZONTAL_MASK; -+ int i1 = MathHelper.clamp(j - this.quartMinY, 0, this.quartHeight); -+ int j1 = k & BiomeStorage.HORIZONTAL_MASK; -+ -+ this.biomes[i1 << BiomeStorage.WIDTH_BITS + BiomeStorage.WIDTH_BITS | j1 << BiomeStorage.WIDTH_BITS | l] = biome; -+ } -+ // CraftBukkit end - } diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/Chunk.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/Chunk.patch index 613658f2be..e783d9fe44 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/Chunk.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/Chunk.patch @@ -1,27 +1,27 @@ --- a/net/minecraft/world/level/chunk/Chunk.java +++ b/net/minecraft/world/level/chunk/Chunk.java -@@ -92,7 +92,7 @@ - private final Map<BlockPosition, NBTTagCompound> pendingBlockEntities; - private final Map<BlockPosition, Chunk.c> tickersInLevel; +@@ -77,7 +77,7 @@ + private final Map<BlockPosition, Chunk.d> tickersInLevel; public boolean loaded; + private boolean clientLightReady; - public final World level; + public final WorldServer level; // CraftBukkit - type - public final Map<HeightMap.Type, HeightMap> heightmaps; - private final ChunkConverter upgradeData; - public final Map<BlockPosition, TileEntity> blockEntities; -@@ -122,7 +122,7 @@ - this.blockEntities = Maps.newHashMap(); - this.structureStarts = Maps.newHashMap(); - this.structuresRefences = Maps.newHashMap(); + @Nullable + private Supplier<PlayerChunk.State> fullStatus; + @Nullable +@@ -94,7 +94,7 @@ + super(chunkcoordintpair, chunkconverter, world, world.registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY), i, achunksection, blendingdata); + this.tickersInLevel = Maps.newHashMap(); + this.clientLightReady = false; - this.level = world; + this.level = (WorldServer) world; // CraftBukkit - type - this.chunkPos = chunkcoordintpair; - this.upgradeData = chunkconverter; this.gameEventDispatcherSections = new Int2ObjectOpenHashMap(); -@@ -152,8 +152,22 @@ - } - - this.postProcessing = new ShortList[world.getSectionsCount()]; + HeightMap.Type[] aheightmap_type = HeightMap.Type.values(); + int j = aheightmap_type.length; +@@ -110,8 +110,22 @@ + this.postLoad = chunk_c; + this.blockTicks = levelchunkticks; + this.fluidTicks = levelchunkticks1; + // CraftBukkit start + this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this); } @@ -38,48 +38,48 @@ + public final org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer(DATA_TYPE_REGISTRY); + // CraftBukkit end + - public Chunk(WorldServer worldserver, ProtoChunk protochunk, @Nullable Consumer<Chunk> consumer) { - this(worldserver, protochunk.getPos(), protochunk.getBiomeIndex(), protochunk.q(), protochunk.o(), protochunk.p(), protochunk.getInhabitedTime(), protochunk.getSections(), consumer); - Iterator iterator = protochunk.y().values().iterator(); -@@ -184,6 +198,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()); + Iterator iterator = protochunk.getBlockEntities().values().iterator(); +@@ -142,6 +156,7 @@ - this.b(protochunk.s()); + this.setLightCorrect(protochunk.isLightCorrect()); this.unsaved = true; + this.needsDecoration = true; // CraftBukkit } @Override -@@ -285,9 +300,16 @@ +@@ -238,9 +253,16 @@ } } + // CraftBukkit start @Nullable @Override - public IBlockData setType(BlockPosition blockposition, IBlockData iblockdata, boolean flag) { -+ return this.setType(blockposition, iblockdata, flag, true); + public IBlockData setBlockState(BlockPosition blockposition, IBlockData iblockdata, boolean flag) { ++ return this.setBlockState(blockposition, iblockdata, flag, true); + } + + @Nullable -+ public IBlockData setType(BlockPosition blockposition, IBlockData iblockdata, boolean flag, boolean doPlace) { ++ public IBlockData setBlockState(BlockPosition blockposition, IBlockData iblockdata, boolean flag, boolean doPlace) { + // CraftBukkit end int i = blockposition.getY(); - int j = this.getSectionIndex(i); - ChunkSection chunksection = this.sections[j]; -@@ -333,7 +355,8 @@ - if (!chunksection.getType(k, l, i1).a(block)) { - return null; - } else { -- if (!this.level.isClientSide) { -+ // 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); - } + ChunkSection chunksection = this.getSection(this.getSectionIndex(i)); + boolean flag1 = chunksection.hasOnlyAir(); +@@ -279,7 +301,8 @@ + if (!chunksection.getBlockState(j, k, l).is(block)) { + return null; + } else { +- if (!this.level.isClientSide) { ++ // 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); + } -@@ -401,7 +424,12 @@ +@@ -323,7 +346,12 @@ @Nullable - public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) { + public TileEntity getBlockEntity(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) { - TileEntity tileentity = (TileEntity) this.blockEntities.get(blockposition); + // CraftBukkit start + TileEntity tileentity = level.capturedTileEntities.get(blockposition); @@ -90,22 +90,22 @@ if (tileentity == null) { NBTTagCompound nbttagcompound = (NBTTagCompound) this.pendingBlockEntities.remove(blockposition); -@@ -460,6 +488,13 @@ - tileentity1.aa_(); +@@ -394,6 +422,13 @@ + tileentity1.setRemoved(); } + // CraftBukkit start + } else { -+ System.out.println("Attempted to place a tile entity (" + tileentity + ") at " + tileentity.getPosition().getX() + "," + tileentity.getPosition().getY() + "," + tileentity.getPosition().getZ() -+ + " (" + getType(blockposition) + ") where there was no entity tile!"); ++ System.out.println("Attempted to place a tile entity (" + tileentity + ") at " + tileentity.getBlockPos().getX() + "," + tileentity.getBlockPos().getY() + "," + tileentity.getBlockPos().getZ() ++ + " (" + getBlockState(blockposition) + ") where there was no entity tile!"); + System.out.println("Chunk coordinates: " + (this.chunkPos.x * 16) + "," + (this.chunkPos.z * 16)); + new Exception().printStackTrace(); + // CraftBukkit end } } -@@ -494,6 +529,12 @@ - if (this.E()) { +@@ -423,6 +458,12 @@ + if (this.isInLevel()) { TileEntity tileentity = (TileEntity) this.blockEntities.remove(blockposition); + // CraftBukkit start - SPIGOT-5561: Also remove from pending map @@ -115,9 +115,9 @@ + // CraftBukkit end + if (tileentity != null) { - this.c(tileentity); - tileentity.aa_(); -@@ -541,6 +582,50 @@ + this.removeGameEventListener(tileentity); + tileentity.setRemoved(); +@@ -470,6 +511,55 @@ } @@ -158,70 +158,31 @@ + + public void unloadCallback() { + org.bukkit.Server server = this.level.getCraftServer(); -+ org.bukkit.event.world.ChunkUnloadEvent unloadEvent = new org.bukkit.event.world.ChunkUnloadEvent(this.bukkitChunk, this.isNeedsSaving()); ++ org.bukkit.event.world.ChunkUnloadEvent unloadEvent = new org.bukkit.event.world.ChunkUnloadEvent(this.bukkitChunk, this.isUnsaved()); + server.getPluginManager().callEvent(unloadEvent); + // note: saving can be prevented, but not forced if no saving is actually required + this.mustNotSave = !unloadEvent.isSaveChunk(); + } ++ ++ @Override ++ public boolean isUnsaved() { ++ return super.isUnsaved() && !this.mustNotSave; ++ } + // CraftBukkit end + - public void markDirty() { - this.unsaved = true; + public boolean isEmpty() { + return false; } -@@ -664,7 +749,7 @@ +@@ -658,7 +748,7 @@ - @Override - public boolean isNeedsSaving() { -- return this.unsaved; -+ return this.unsaved && !this.mustNotSave; // CraftBukkit - } - - @Nullable -@@ -795,7 +880,7 @@ - - public void B() { - if (this.blockTicks instanceof ProtoChunkTickList) { -- ((ProtoChunkTickList) this.blockTicks).a(this.level.getBlockTickList(), (blockposition) -> { -+ ((ProtoChunkTickList<Block>) this.blockTicks).a(this.level.getBlockTickList(), (blockposition) -> { // CraftBukkit - decompile error - return this.getType(blockposition).getBlock(); - }); - this.blockTicks = TickListEmpty.b(); -@@ -805,7 +890,7 @@ - } - - if (this.liquidTicks instanceof ProtoChunkTickList) { -- ((ProtoChunkTickList) this.liquidTicks).a(this.level.getFluidTickList(), (blockposition) -> { -+ ((ProtoChunkTickList<FluidType>) this.liquidTicks).a(this.level.getFluidTickList(), (blockposition) -> { // CraftBukkit - decompile error - return this.getFluid(blockposition).getType(); - }); - this.liquidTicks = TickListEmpty.b(); -@@ -819,14 +904,14 @@ - public void a(WorldServer worldserver) { - RegistryBlocks registryblocks; - -- if (this.blockTicks == TickListEmpty.b()) { -+ if (this.blockTicks == TickListEmpty.<Block>b()) { // CraftBukkit - decompile error - registryblocks = IRegistry.BLOCK; - Objects.requireNonNull(registryblocks); - this.blockTicks = new TickListChunk<>(registryblocks::getKey, worldserver.getBlockTickList().a(this.chunkPos, true, false), worldserver.getTime()); - this.setNeedsSaving(true); - } - -- if (this.liquidTicks == TickListEmpty.b()) { -+ if (this.liquidTicks == TickListEmpty.<FluidType>b()) { // CraftBukkit - decompile error - registryblocks = IRegistry.FLUID; - Objects.requireNonNull(registryblocks); - this.liquidTicks = new TickListChunk<>(registryblocks::getKey, worldserver.getFluidTickList().a(this.chunkPos, true, false), worldserver.getTime()); -@@ -899,7 +984,7 @@ - - private <T extends TileEntity> void f(T t0) { - IBlockData iblockdata = t0.getBlock(); -- BlockEntityTicker<T> blockentityticker = iblockdata.a(this.level, t0.getTileType()); -+ BlockEntityTicker<T> blockentityticker = iblockdata.a(this.level, (TileEntityTypes<T>) t0.getTileType()); // CraftBukkit - decompile error + private <T extends TileEntity> void updateBlockEntityTicker(T t0) { + IBlockData iblockdata = t0.getBlockState(); +- BlockEntityTicker<T> blockentityticker = iblockdata.getTicker(this.level, t0.getType()); ++ BlockEntityTicker<T> blockentityticker = iblockdata.getTicker(this.level, (TileEntityTypes<T>) t0.getType()); // CraftBukkit - decompile error if (blockentityticker == null) { - this.l(t0.getPosition()); -@@ -978,7 +1063,7 @@ + this.removeBlockEntityTicker(t0.getBlockPos()); +@@ -751,7 +841,7 @@ private boolean loggedInvalidBlockState; a(TileEntity tileentity, BlockEntityTicker blockentityticker) { @@ -230,12 +191,12 @@ this.ticker = blockentityticker; } -@@ -1001,7 +1086,7 @@ +@@ -774,7 +864,7 @@ this.loggedInvalidBlockState = true; - Chunk.LOGGER.warn("Block entity {} @ {} state {} invalid for ticking:", new org.apache.logging.log4j.util.Supplier[]{this::d, this::c, () -> { + Chunk.LOGGER.warn("Block entity {} @ {} state {} invalid for ticking:", new org.apache.logging.log4j.util.Supplier[]{this::getType, this::getPos, () -> { return iblockdata; - }}); + }}); // CraftBukkit - squelch checkstyle } - gameprofilerfiller.exit(); + gameprofilerfiller.pop(); diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch index 04283df2f2..7d9591d3e4 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch @@ -1,46 +1,55 @@ --- a/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/net/minecraft/world/level/chunk/ChunkGenerator.java -@@ -63,7 +63,7 @@ - protected final WorldChunkManager biomeSource; - protected final WorldChunkManager runtimeBiomeSource; - private final StructureSettings settings; -- private final long strongholdSeed; -+ public final long strongholdSeed; // PAIL private -> public - private final List<ChunkCoordIntPair> strongholdPositions; - private final BaseStoneSource defaultBaseStoneSource; - -@@ -217,7 +217,7 @@ +@@ -225,7 +225,7 @@ } } -- public void addDecorations(RegionLimitedWorldAccess regionlimitedworldaccess, StructureManager structuremanager) { -+ public void addVanillaDecorations(RegionLimitedWorldAccess regionlimitedworldaccess, StructureManager structuremanager) { // CraftBukkit - ChunkCoordIntPair chunkcoordintpair = regionlimitedworldaccess.a(); - int i = chunkcoordintpair.d(); - int j = chunkcoordintpair.e(); -@@ -236,8 +236,45 @@ +- public void applyBiomeDecoration(GeneratorAccessSeed generatoraccessseed, IChunkAccess ichunkaccess, StructureManager structuremanager) { ++ public void addVanillaDecorations(GeneratorAccessSeed generatoraccessseed, IChunkAccess ichunkaccess, StructureManager structuremanager) { // CraftBukkit + ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos(); + + if (!SharedConstants.debugVoidTerrain(chunkcoordintpair)) { +@@ -249,7 +249,7 @@ + + for (int k = 0; k < j; ++k) { + ChunkSection chunksection = achunksection[k]; +- DataPaletteBlock datapaletteblock = chunksection.getBiomes(); ++ DataPaletteBlock<BiomeBase> datapaletteblock = chunksection.getBiomes(); // CraftBukkit - decompile error + + Objects.requireNonNull(set); + datapaletteblock.getAll(set::add); +@@ -278,7 +278,7 @@ + StructureGenerator<?> structuregenerator = (StructureGenerator) iterator.next(); + + seededrandom.setFeatureSeed(i, i1, l); +- Supplier supplier = () -> { ++ Supplier<String> supplier = () -> { // CraftBukkit - decompile error + Optional optional = iregistry1.getResourceKey(structuregenerator).map(Object::toString); + + Objects.requireNonNull(structuregenerator); +@@ -364,6 +364,33 @@ } } -+ public void addDecorations(RegionLimitedWorldAccess regionlimitedworldaccess, StructureManager structuremanager) { ++ public void applyBiomeDecoration(GeneratorAccessSeed generatoraccessseed, IChunkAccess ichunkaccess, StructureManager structuremanager) { + // CraftBukkit start -+ addDecorations(regionlimitedworldaccess, structuremanager, true); ++ applyBiomeDecoration(generatoraccessseed, ichunkaccess, structuremanager, true); + } + -+ public void addDecorations(RegionLimitedWorldAccess regionlimitedworldaccess, StructureManager structuremanager, boolean vanilla) { ++ public void applyBiomeDecoration(GeneratorAccessSeed generatoraccessseed, IChunkAccess ichunkaccess, StructureManager structuremanager, boolean vanilla) { + if (vanilla) { -+ addVanillaDecorations(regionlimitedworldaccess, structuremanager); ++ addVanillaDecorations(generatoraccessseed, ichunkaccess, structuremanager); + } + -+ org.bukkit.World world = regionlimitedworldaccess.getMinecraftWorld().getWorld(); ++ org.bukkit.World world = generatoraccessseed.getMinecraftWorld().getWorld(); + // only call when a populator is present (prevents unnecessary entity conversion) -+ if (world.getPopulators().size() != 0) { -+ org.bukkit.craftbukkit.generator.CraftLimitedRegion limitedRegion = new org.bukkit.craftbukkit.generator.CraftLimitedRegion(regionlimitedworldaccess); -+ int x = regionlimitedworldaccess.a().x; -+ int z = regionlimitedworldaccess.a().z; ++ if (!world.getPopulators().isEmpty()) { ++ org.bukkit.craftbukkit.generator.CraftLimitedRegion limitedRegion = new org.bukkit.craftbukkit.generator.CraftLimitedRegion(generatoraccessseed, ichunkaccess.getPos()); ++ int x = ichunkaccess.getPos().x; ++ int z = ichunkaccess.getPos().z; + for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) { -+ SeededRandom seededrandom = new SeededRandom(); -+ seededrandom.a(regionlimitedworldaccess.getSeed(), x, z); ++ SeededRandom seededrandom = new SeededRandom(new LegacyRandomSource(generatoraccessseed.getSeed())); ++ seededrandom.setDecorationSeed(generatoraccessseed.getSeed(), x, z); + populator.populate(world, seededrandom, x, z, limitedRegion); + } + limitedRegion.saveEntities(); @@ -49,51 +58,15 @@ + // CraftBukkit end + } + - public abstract void buildBase(RegionLimitedWorldAccess regionlimitedworldaccess, IChunkAccess ichunkaccess); + private static StructureBoundingBox getWritableArea(IChunkAccess ichunkaccess) { + ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos(); + int i = chunkcoordintpair.getMinBlockX(); +@@ -439,7 +466,7 @@ -+ // CraftBukkit start - spilt surface and bedrock generation code -+ public SeededRandom buildSurface(RegionLimitedWorldAccess regionlimitedworldaccess, IChunkAccess iChunkAccess) { -+ throw new UnsupportedOperationException("Methode not overridden"); -+ } -+ -+ public void buildBedrock(IChunkAccess iChunkAccess, Random random) { -+ throw new UnsupportedOperationException("Methode not overridden"); -+ } -+ // CraftBukkit end -+ - public void addMobs(RegionLimitedWorldAccess regionlimitedworldaccess) {} + Entry<StructureFeature<?, ?>, Collection<ResourceKey<BiomeBase>>> entry = (Entry) unmodifiableiterator.next(); - public StructureSettings getSettings() { -@@ -269,7 +306,16 @@ - while (iterator.hasNext()) { - Supplier<StructureFeature<?, ?>> supplier = (Supplier) iterator.next(); +- structurestart3 = ((StructureFeature) entry.getKey()).generate(iregistrycustom, this, this.biomeSource, definedstructuremanager, i, chunkcoordintpair, j, structuresettingsfeature1, ichunkaccess, (biomebase) -> { ++ structurestart3 = (entry.getKey()).generate(iregistrycustom, this, this.biomeSource, definedstructuremanager, i, chunkcoordintpair, j, structuresettingsfeature1, ichunkaccess, (biomebase) -> { // CraftBukkit - decompile error + Collection collection = (Collection) entry.getValue(); -- this.a((StructureFeature) supplier.get(), iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, biomebase); -+ // CraftBukkit start -+ StructureFeature<?, ?> structurefeature = (StructureFeature) supplier.get(); -+ if (structurefeature.LIST_CODEC == StructureGenerator.STRONGHOLD) { -+ synchronized (structurefeature) { -+ this.a((StructureFeature) supplier.get(), iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, biomebase); -+ } -+ } else { -+ this.a((StructureFeature) supplier.get(), iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, biomebase); -+ } -+ // CraftBukkit end - } - - } -@@ -364,9 +410,11 @@ - } - - static { -- IRegistry.a(IRegistry.CHUNK_GENERATOR, "noise", (Object) ChunkGeneratorAbstract.CODEC); -- IRegistry.a(IRegistry.CHUNK_GENERATOR, "flat", (Object) ChunkProviderFlat.CODEC); -- IRegistry.a(IRegistry.CHUNK_GENERATOR, "debug", (Object) ChunkProviderDebug.CODEC); -+ // CraftBukkit start - decompile errors -+ IRegistry.a(IRegistry.CHUNK_GENERATOR, "noise", ChunkGeneratorAbstract.CODEC); -+ IRegistry.a(IRegistry.CHUNK_GENERATOR, "flat", ChunkProviderFlat.CODEC); -+ IRegistry.a(IRegistry.CHUNK_GENERATOR, "debug", ChunkProviderDebug.CODEC); -+ // CraftBukkit end - CODEC = IRegistry.CHUNK_GENERATOR.dispatchStable(ChunkGenerator::a, Function.identity()); - } - } + Objects.requireNonNull(collection); diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch new file mode 100644 index 0000000000..9a32216ab8 --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/world/level/chunk/ChunkSection.java ++++ b/net/minecraft/world/level/chunk/ChunkSection.java +@@ -176,6 +176,12 @@ + return (BiomeBase) this.biomes.get(i, j, k); + } + ++ // CraftBukkit start ++ public void setBiome(int i, int j, int k, BiomeBase biome) { ++ this.biomes.set(i, j, k, biome); ++ } ++ // CraftBukkit end ++ + public void fillBiomesFromNoise(BiomeResolver biomeresolver, Climate.Sampler climate_sampler, int i, int j) { + DataPaletteBlock<BiomeBase> datapaletteblock = this.getBiomes(); + diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkStatus.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkStatus.patch index fd89fa9e46..02ac95cbe7 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkStatus.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkStatus.patch @@ -1,20 +1,11 @@ --- a/net/minecraft/world/level/chunk/ChunkStatus.java +++ b/net/minecraft/world/level/chunk/ChunkStatus.java -@@ -39,7 +39,7 @@ +@@ -47,7 +47,7 @@ }); - public static final ChunkStatus STRUCTURE_STARTS = a("structure_starts", ChunkStatus.EMPTY, 0, ChunkStatus.PRE_FEATURES, ChunkStatus.Type.PROTOCHUNK, (chunkstatus, executor, worldserver, chunkgenerator, definedstructuremanager, lightenginethreaded, function, list, ichunkaccess) -> { - if (!ichunkaccess.getChunkStatus().b(chunkstatus)) { -- if (worldserver.getMinecraftServer().getSaveData().getGeneratorSettings().shouldGenerateMapFeatures()) { -+ if (worldserver.serverLevelData.getGeneratorSettings().shouldGenerateMapFeatures()) { // CraftBukkit - chunkgenerator.createStructures(worldserver.t(), worldserver.getStructureManager(), ichunkaccess, definedstructuremanager, worldserver.getSeed()); + public static final ChunkStatus STRUCTURE_STARTS = register("structure_starts", ChunkStatus.EMPTY, 0, ChunkStatus.PRE_FEATURES, ChunkStatus.Type.PROTOCHUNK, (chunkstatus, executor, worldserver, chunkgenerator, definedstructuremanager, lightenginethreaded, function, list, ichunkaccess, flag) -> { + if (!ichunkaccess.getStatus().isOrAfter(chunkstatus)) { +- if (worldserver.getServer().getWorldData().worldGenSettings().generateFeatures()) { ++ if (worldserver.serverLevelData.worldGenSettings().generateFeatures()) { // CraftBukkit + chunkgenerator.createStructures(worldserver.registryAccess(), worldserver.structureFeatureManager(), ichunkaccess, definedstructuremanager, worldserver.getSeed()); } -@@ -112,7 +112,7 @@ - return (CompletableFuture) function.apply(ichunkaccess); - }); - private static final List<ChunkStatus> STATUS_BY_RANGE = ImmutableList.of(ChunkStatus.FULL, ChunkStatus.FEATURES, ChunkStatus.LIQUID_CARVERS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS); -- private static final IntList RANGE_BY_STATUS = (IntList) SystemUtils.a((Object) (new IntArrayList(a().size())), (intarraylist) -> { -+ private static final IntList RANGE_BY_STATUS = (IntList) SystemUtils.a((new IntArrayList(a().size())), (java.util.function.Consumer<IntArrayList>) (intarraylist) -> { // CraftBukkit - decompile error - int i = 0; - - for (int j = a().size() - 1; j >= 0; --j) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/DataPaletteBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/DataPaletteBlock.patch new file mode 100644 index 0000000000..8622eaa2d4 --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/DataPaletteBlock.patch @@ -0,0 +1,152 @@ +--- a/net/minecraft/world/level/chunk/DataPaletteBlock.java ++++ b/net/minecraft/world/level/chunk/DataPaletteBlock.java +@@ -54,7 +54,7 @@ + } + + public static <T> Codec<DataPaletteBlock<T>> codec(Registry<T> registry, Codec<T> codec, DataPaletteBlock.e datapaletteblock_e, T t0) { +- return RecordCodecBuilder.create((instance) -> { ++ return RecordCodecBuilder.<DataPaletteBlock.d<T>>create((instance) -> { // CraftBukkit - decompile error + return instance.group(codec.mapResult(ExtraCodecs.orElsePartial(t0)).listOf().fieldOf("palette").forGetter(DataPaletteBlock.d::paletteEntries), Codec.LONG_STREAM.optionalFieldOf("data").forGetter(DataPaletteBlock.d::storage)).apply(instance, DataPaletteBlock.d::new); + }).comapFlatMap((datapaletteblock_d) -> { + return read(registry, datapaletteblock_e, datapaletteblock_d); +@@ -97,7 +97,7 @@ + public T getAndSet(int i, int j, int k, T t0) { + this.acquire(); + +- Object object; ++ T object; // CraftBukkit - decompile error + + try { + object = this.getAndSet(this.strategy.getIndex(i, j, k), t0); +@@ -309,19 +309,19 @@ + + switch (i) { + case 0: +- datapaletteblock_a = new DataPaletteBlock.a<>(null.SINGLE_VALUE_PALETTE_FACTORY, i); ++ datapaletteblock_a = new DataPaletteBlock.a<>(SINGLE_VALUE_PALETTE_FACTORY, i); // CraftBukkit - decompile error + break; + case 1: + case 2: + case 3: + case 4: +- datapaletteblock_a = new DataPaletteBlock.a<>(null.LINEAR_PALETTE_FACTORY, 4); ++ datapaletteblock_a = new DataPaletteBlock.a<>(LINEAR_PALETTE_FACTORY, 4); // CraftBukkit - decompile error + break; + case 5: + case 6: + case 7: + case 8: +- datapaletteblock_a = new DataPaletteBlock.a<>(null.HASHMAP_PALETTE_FACTORY, i); ++ datapaletteblock_a = new DataPaletteBlock.a<>(HASHMAP_PALETTE_FACTORY, i); // CraftBukkit - decompile error + break; + default: + datapaletteblock_a = new DataPaletteBlock.a<>(DataPaletteBlock.e.GLOBAL_PALETTE_FACTORY, MathHelper.ceillog2(registry.size())); +@@ -337,12 +337,12 @@ + + switch (i) { + case 0: +- datapaletteblock_a = new DataPaletteBlock.a<>(null.SINGLE_VALUE_PALETTE_FACTORY, i); ++ datapaletteblock_a = new DataPaletteBlock.a<>(SINGLE_VALUE_PALETTE_FACTORY, i); // CraftBukkit - decompile error + break; + case 1: + case 2: + case 3: +- datapaletteblock_a = new DataPaletteBlock.a<>(null.LINEAR_PALETTE_FACTORY, i); ++ datapaletteblock_a = new DataPaletteBlock.a<>(LINEAR_PALETTE_FACTORY, i); // CraftBukkit - decompile error + break; + default: + datapaletteblock_a = new DataPaletteBlock.a<>(DataPaletteBlock.e.GLOBAL_PALETTE_FACTORY, MathHelper.ceillog2(registry.size())); +@@ -375,8 +375,10 @@ + } + } + +- private static final class a<T> extends Record { ++ // CraftBukkit start ++ private static final record a<T>(DataPalette.a factory, int bits) { + ++ /* + private final DataPalette.a factory; + private final int bits; + +@@ -384,6 +386,8 @@ + this.factory = datapalette_a; + this.bits = i; + } ++ */ ++ // CraftBukkit end + + public DataPaletteBlock.c<T> createData(Registry<T> registry, DataPaletteExpandable<T> datapaletteexpandable, int i) { + Object object = this.bits == 0 ? new ZeroBitStorage(i) : new SimpleBitStorage(this.bits, i); +@@ -392,6 +396,8 @@ + return new DataPaletteBlock.c(this, (DataBits) object, datapalette); + } + ++ // CraftBukkit start ++ /* + public final String toString() { + return this.toString < invokedynamic > (this); + } +@@ -403,6 +409,8 @@ + public final boolean equals(Object object) { + return this.equals<invokedynamic>(this, object); + } ++ */ ++ // CraftBukkit end + + public DataPalette.a factory() { + return this.factory; +@@ -413,8 +421,10 @@ + } + } + +- private static final class c extends Record { ++ // CraftBukkit start ++ private static final record c<T>(DataPaletteBlock.a<T> configuration, DataBits storage, DataPalette<T> palette) { + ++ /* + private final DataPaletteBlock.a<T> configuration; + final DataBits storage; + final DataPalette<T> palette; +@@ -424,6 +434,8 @@ + this.storage = databits; + this.palette = datapalette; + } ++ */ ++ // CraftBukkit end + + public void copyFrom(DataPalette<T> datapalette, DataBits databits) { + for (int i = 0; i < databits.getSize(); ++i) { +@@ -444,6 +456,8 @@ + packetdataserializer.writeLongArray(this.storage.getRaw()); + } + ++ // CraftBukkit start ++ /* + public final String toString() { + return this.toString < invokedynamic > (this); + } +@@ -467,10 +481,14 @@ + public DataPalette<T> palette() { + return this.palette; + } ++ */ ++ // CraftBukkit end + } + +- private static final class d extends Record { ++ // CraftBukkit start ++ private static final record d<T>(List<T> paletteEntries, Optional<LongStream> storage) { + ++ /* + private final List<T> paletteEntries; + private final Optional<LongStream> storage; + +@@ -498,6 +516,8 @@ + public Optional<LongStream> storage() { + return this.storage; + } ++ */ ++ // CraftBukkit end + } + + @FunctionalInterface diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch new file mode 100644 index 0000000000..420adb2fa4 --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch @@ -0,0 +1,63 @@ +--- a/net/minecraft/world/level/chunk/IChunkAccess.java ++++ b/net/minecraft/world/level/chunk/IChunkAccess.java +@@ -93,7 +93,11 @@ + } + + replaceMissingSections(levelheightaccessor, iregistry, this.sections); ++ // CraftBukkit start ++ this.biomeRegistry = iregistry; + } ++ public final IRegistry<BiomeBase> biomeRegistry; ++ // CraftBukkit end + + private static void replaceMissingSections(LevelHeightAccessor levelheightaccessor, IRegistry<BiomeBase> iregistry, ChunkSection[] achunksection) { + for (int i = 0; i < achunksection.length; ++i) { +@@ -392,6 +396,27 @@ + } + } + ++ // CraftBukkit start ++ public void setBiome(int i, int j, int k, BiomeBase biome) { ++ try { ++ int l = QuartPos.fromBlock(this.getMinBuildHeight()); ++ int i1 = l + QuartPos.fromBlock(this.getHeight()) - 1; ++ int j1 = MathHelper.clamp(j, l, i1); ++ int k1 = this.getSectionIndex(QuartPos.toBlock(j1)); ++ ++ this.sections[k1].setBiome(i & 3, j1 & 3, k & 3, biome); ++ } catch (Throwable throwable) { ++ CrashReport crashreport = CrashReport.forThrowable(throwable, "Setting biome"); ++ CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Biome being set"); ++ ++ crashreportsystemdetails.setDetail("Location", () -> { ++ return CrashReportSystemDetails.formatLocation(this, i, j, k); ++ }); ++ throw new ReportedException(crashreport); ++ } ++ } ++ // CraftBukkit end ++ + public void fillBiomesFromNoise(BiomeResolver biomeresolver, Climate.Sampler climate_sampler) { + ChunkCoordIntPair chunkcoordintpair = this.getPos(); + int i = QuartPos.fromBlock(chunkcoordintpair.getMinBlockX()); +@@ -423,8 +448,10 @@ + return this; + } + +- public static final class a extends Record { ++ // CraftBukkit start ++ public static final record a(SerializableTickContainer<Block> blocks, SerializableTickContainer<FluidType> fluids) { + ++ /* + private final SerializableTickContainer<Block> blocks; + private final SerializableTickContainer<FluidType> fluids; + +@@ -444,6 +471,8 @@ + public final boolean equals(Object object) { + return this.equals<invokedynamic>(this, object); + } ++ */ ++ // CraftBukkit end + + public SerializableTickContainer<Block> blocks() { + return this.blocks; diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch index 08fff92d85..c4affbde21 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch @@ -1,38 +1,45 @@ --- a/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java +++ b/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java -@@ -163,6 +163,12 @@ +@@ -190,7 +190,7 @@ + dataresult = BelowZeroRetrogen.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("below_zero_retrogen"))); + logger1 = ChunkRegionLoader.LOGGER; + Objects.requireNonNull(logger1); +- Optional optional = dataresult.resultOrPartial(logger1::error); ++ Optional<BelowZeroRetrogen> optional = dataresult.resultOrPartial(logger1::error); // CraftBukkit - decompile error - object = new Chunk(worldserver.getLevel(), chunkcoordintpair, biomestorage, chunkconverter, (TickList) object1, (TickList) object2, k, achunksection, (chunk) -> { - loadEntities(worldserver, nbttagcompound1, chunk); -+ // CraftBukkit start - load chunk persistent data from nbt -+ net.minecraft.nbt.NBTBase persistentBase = nbttagcompound1.get("ChunkBukkitValues"); -+ if (persistentBase instanceof NBTTagCompound) { -+ chunk.persistentDataContainer.putAll((NBTTagCompound) persistentBase); -+ } -+ // CraftBukkit end - }); - } else { - ProtoChunk protochunk = new ProtoChunk(chunkcoordintpair, chunkconverter, achunksection, protochunkticklist, protochunkticklist1, worldserver); -@@ -294,8 +300,9 @@ - boolean flag = ichunkaccess.s(); + Objects.requireNonNull(protochunk); + optional.ifPresent(protochunk::setBelowZeroRetrogen); +@@ -321,7 +321,7 @@ + nbttagcompound.putLong("InhabitedTime", ichunkaccess.getInhabitedTime()); + nbttagcompound.putString("Status", ichunkaccess.getStatus().getName()); + BlendingData blendingdata = ichunkaccess.getBlendingData(); +- DataResult dataresult; ++ DataResult<NBTBase> dataresult; // CraftBukkit - decompile error + Logger logger; - for (int i = lightenginethreaded.c(); i < lightenginethreaded.d(); ++i) { -+ int finalI = i; // CraftBukkit - decompile errors - ChunkSection chunksection = (ChunkSection) Arrays.stream(achunksection).filter((chunksection1) -> { -- return chunksection1 != null && SectionPosition.a(chunksection1.getYPosition()) == i; -+ return chunksection1 != null && SectionPosition.a(chunksection1.getYPosition()) == finalI; // CraftBukkit - decompile errors - }).findFirst().orElse(Chunk.EMPTY_SECTION); - NibbleArray nibblearray = lightenginethreaded.a(EnumSkyBlock.BLOCK).a(SectionPosition.a(chunkcoordintpair, i)); - NibbleArray nibblearray1 = lightenginethreaded.a(EnumSkyBlock.SKY).a(SectionPosition.a(chunkcoordintpair, i)); -@@ -403,6 +410,11 @@ + if (blendingdata != null) { +@@ -452,6 +452,11 @@ - nbttagcompound1.set("Heightmaps", nbttagcompound3); - nbttagcompound1.set("Structures", a(worldserver, chunkcoordintpair, ichunkaccess.g(), ichunkaccess.w())); + nbttagcompound.put("Heightmaps", nbttagcompound3); + nbttagcompound.put("structures", packStructureData(StructurePieceSerializationContext.fromLevel(worldserver), chunkcoordintpair, ichunkaccess.getAllStarts(), ichunkaccess.getAllReferences())); + // CraftBukkit start - store chunk persistent data in nbt + if (ichunkaccess instanceof Chunk && !((Chunk) ichunkaccess).persistentDataContainer.isEmpty()) { -+ nbttagcompound1.set("ChunkBukkitValues", ((Chunk) ichunkaccess).persistentDataContainer.toTagCompound()); ++ nbttagcompound.put("ChunkBukkitValues", ((Chunk) ichunkaccess).persistentDataContainer.toTagCompound()); + } + // CraftBukkit end return nbttagcompound; } +@@ -498,6 +503,12 @@ + } + } + ++ // CraftBukkit start - load chunk persistent data from nbt ++ net.minecraft.nbt.NBTBase persistentBase = nbttagcompound.get("ChunkBukkitValues"); ++ if (persistentBase instanceof NBTTagCompound) { ++ chunk.persistentDataContainer.putAll((NBTTagCompound) persistentBase); ++ } ++ // CraftBukkit end + }; + } + diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/EntityStorage.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/EntityStorage.patch deleted file mode 100644 index 0afd6f62cf..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/EntityStorage.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/world/level/chunk/storage/EntityStorage.java -+++ b/net/minecraft/world/level/chunk/storage/EntityStorage.java -@@ -33,10 +33,10 @@ - private static final Logger LOGGER = LogManager.getLogger(); - private static final String ENTITIES_TAG = "Entities"; - private static final String POSITION_TAG = "Position"; -- private final WorldServer level; -+ public final WorldServer level; // PAIL private -> public - private final IOWorker worker; - private final LongSet emptyChunks = new LongOpenHashSet(); -- private final ThreadedMailbox<Runnable> entityDeserializerQueue; -+ public final ThreadedMailbox<Runnable> entityDeserializerQueue; // PAIL private -> public - protected final DataFixer fixerUpper; - - public EntityStorage(WorldServer worldserver, File file, DataFixer datafixer, boolean flag, Executor executor) { -@@ -51,8 +51,8 @@ - if (this.emptyChunks.contains(chunkcoordintpair.pair())) { - return CompletableFuture.completedFuture(b(chunkcoordintpair)); - } else { -- CompletableFuture completablefuture = this.worker.b(chunkcoordintpair); -- Function function = (nbttagcompound) -> { -+ CompletableFuture<NBTTagCompound> completablefuture = this.worker.b(chunkcoordintpair); // CraftBukkit - decompile error -+ Function<NBTTagCompound, ChunkEntities<Entity>> function = (nbttagcompound) -> { // CraftBukkit - decompile error - if (nbttagcompound == null) { - this.emptyChunks.add(chunkcoordintpair.pair()); - return b(chunkcoordintpair); diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch index e6dce93bd0..610585e48d 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/storage/IChunkLoader.java +++ b/net/minecraft/world/level/chunk/storage/IChunkLoader.java -@@ -15,6 +15,14 @@ +@@ -18,6 +18,14 @@ import net.minecraft.world.level.levelgen.structure.PersistentStructureLegacy; import net.minecraft.world.level.storage.WorldPersistentData; @@ -14,18 +14,18 @@ + public class IChunkLoader implements AutoCloseable { - private final IOWorker worker; -@@ -27,10 +35,49 @@ - this.worker = new IOWorker(file, flag, "chunk"); + public static final int LAST_MONOLYTH_STRUCTURE_DATA_VERSION = 1493; +@@ -31,9 +39,48 @@ + this.worker = new IOWorker(path, flag, "chunk"); } -- public NBTTagCompound getChunkData(ResourceKey<World> resourcekey, Supplier<WorldPersistentData> supplier, NBTTagCompound nbttagcompound) { +- public NBTTagCompound upgradeChunkTag(ResourceKey<World> resourcekey, Supplier<WorldPersistentData> supplier, NBTTagCompound nbttagcompound, Optional<ResourceKey<Codec<? extends ChunkGenerator>>> optional) { + // CraftBukkit start + private boolean check(ChunkProviderServer cps, int x, int z) throws IOException { + ChunkCoordIntPair pos = new ChunkCoordIntPair(x, z); + if (cps != null) { + com.google.common.base.Preconditions.checkState(org.bukkit.Bukkit.isPrimaryThread(), "primary thread"); -+ if (cps.isLoaded(x, z)) { ++ if (cps.hasChunk(x, z)) { + return true; + } + } @@ -37,8 +37,8 @@ + return true; + } + -+ ChunkStatus status = ChunkStatus.a(level.getString("Status")); -+ if (status != null && status.b(ChunkStatus.FEATURES)) { ++ ChunkStatus status = ChunkStatus.byName(level.getString("Status")); ++ if (status != null && status.isOrAfter(ChunkStatus.FEATURES)) { + return true; + } + } @@ -46,23 +46,31 @@ + return false; + } + -+ public NBTTagCompound getChunkData(ResourceKey<DimensionManager> resourcekey, Supplier<WorldPersistentData> supplier, NBTTagCompound nbttagcompound, ChunkCoordIntPair pos, @Nullable GeneratorAccess generatoraccess) throws IOException { ++ public NBTTagCompound upgradeChunkTag(ResourceKey<DimensionManager> resourcekey, Supplier<WorldPersistentData> supplier, NBTTagCompound nbttagcompound, Optional<ResourceKey<Codec<? extends ChunkGenerator>>> optional, ChunkCoordIntPair pos, @Nullable GeneratorAccess generatoraccess) throws IOException { + // CraftBukkit end - int i = a(nbttagcompound); - boolean flag = true; + int i = getVersion(nbttagcompound); + // CraftBukkit start + if (i < 1466) { + NBTTagCompound level = nbttagcompound.getCompound("Level"); + if (level.getBoolean("TerrainPopulated") && !level.getBoolean("LightPopulated")) { -+ ChunkProviderServer cps = (generatoraccess == null) ? null : ((WorldServer) generatoraccess).getChunkProvider(); ++ 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.setBoolean("LightPopulated", true); ++ level.putBoolean("LightPopulated", true); + } + } + } + // CraftBukkit end + if (i < 1493) { - nbttagcompound = GameProfileSerializer.a(this.fixerUpper, DataFixTypes.CHUNK, nbttagcompound, i, 1493); + nbttagcompound = GameProfileSerializer.update(this.fixerUpper, DataFixTypes.CHUNK, nbttagcompound, i, 1493); if (nbttagcompound.getCompound("Level").getBoolean("hasLegacyStructureData")) { +@@ -55,7 +102,7 @@ + return nbttagcompound; + } + +- public static void injectDatafixingContext(NBTTagCompound nbttagcompound, ResourceKey<World> resourcekey, Optional<ResourceKey<Codec<? extends ChunkGenerator>>> optional) { ++ public static void injectDatafixingContext(NBTTagCompound nbttagcompound, ResourceKey<DimensionManager> resourcekey, Optional<ResourceKey<Codec<? extends ChunkGenerator>>> optional) { // CraftBukkit + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + + nbttagcompound1.putString("dimension", resourcekey.location().toString()); diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/RegionFile.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/RegionFile.patch index 8bff3c79e0..0dc4f280cf 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/RegionFile.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/RegionFile.patch @@ -5,7 +5,7 @@ package net.minecraft.world.level.chunk.storage; import com.google.common.annotations.VisibleForTesting; -@@ -60,8 +61,8 @@ +@@ -57,8 +58,8 @@ } else { this.externalFileDir = path1; this.offsets = this.header.asIntBuffer(); @@ -16,16 +16,16 @@ this.timestamps = this.header.asIntBuffer(); if (flag) { this.file = FileChannel.open(path, StandardOpenOption.CREATE, StandardOpenOption.READ, StandardOpenOption.WRITE, StandardOpenOption.DSYNC); -@@ -70,7 +71,7 @@ +@@ -67,7 +68,7 @@ } - this.usedSectors.a(0, 2); + this.usedSectors.force(0, 2); - this.header.position(0); + ((java.nio.Buffer) this.header).position(0); // CraftBukkit - decompile error int i = this.file.read(this.header, 0L); if (i != -1) { -@@ -125,7 +126,7 @@ +@@ -122,7 +123,7 @@ ByteBuffer bytebuffer = ByteBuffer.allocate(l); this.file.read(bytebuffer, (long) (j * 4096)); @@ -34,7 +34,7 @@ if (bytebuffer.remaining() < 5) { RegionFile.LOGGER.error("Chunk {} header is truncated: expected {} but read {}", chunkcoordintpair, l, bytebuffer.remaining()); return null; -@@ -227,7 +228,7 @@ +@@ -224,7 +225,7 @@ try { this.file.read(bytebuffer, (long) (j * 4096)); @@ -43,16 +43,16 @@ if (bytebuffer.remaining() != 5) { return false; } else { -@@ -330,7 +331,7 @@ +@@ -327,7 +328,7 @@ bytebuffer.putInt(1); - bytebuffer.put((byte) (this.version.a() | 128)); + bytebuffer.put((byte) (this.version.getId() | 128)); - bytebuffer.flip(); + ((java.nio.Buffer) bytebuffer).flip(); // CraftBukkit - decompile error return bytebuffer; } -@@ -339,7 +340,7 @@ +@@ -336,7 +337,7 @@ FileChannel filechannel = FileChannel.open(path1, StandardOpenOption.CREATE, StandardOpenOption.WRITE); try { @@ -61,16 +61,16 @@ filechannel.write(bytebuffer); } catch (Throwable throwable) { if (filechannel != null) { -@@ -363,7 +364,7 @@ +@@ -360,7 +361,7 @@ } - private void d() throws IOException { + private void writeHeader() throws IOException { - this.header.position(0); + ((java.nio.Buffer) this.header).position(0); // CraftBukkit - decompile error this.file.write(this.header, 0L); } -@@ -399,7 +400,7 @@ +@@ -396,7 +397,7 @@ if (i != j) { ByteBuffer bytebuffer = RegionFile.PADDING_BUFFER.duplicate(); diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/RegionFileCache.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/RegionFileCache.patch index 24b94b5d51..57edeb9b52 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/RegionFileCache.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/RegionFileCache.patch @@ -1,42 +1,56 @@ --- a/net/minecraft/world/level/chunk/storage/RegionFileCache.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileCache.java -@@ -27,7 +27,7 @@ +@@ -29,7 +29,7 @@ this.sync = flag; } -- private RegionFile getFile(ChunkCoordIntPair chunkcoordintpair) throws IOException { -+ private RegionFile getFile(ChunkCoordIntPair chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit - long i = ChunkCoordIntPair.pair(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ()); +- private RegionFile getRegionFile(ChunkCoordIntPair chunkcoordintpair) throws IOException { ++ private RegionFile getRegionFile(ChunkCoordIntPair chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit + long i = ChunkCoordIntPair.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ()); RegionFile regionfile = (RegionFile) this.regionCache.getAndMoveToFirst(i); -@@ -45,6 +45,7 @@ - File file = this.folder; +@@ -44,6 +44,7 @@ + Path path = this.folder; int j = chunkcoordintpair.getRegionX(); - File file1 = new File(file, "r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca"); -+ if (existingOnly && !file1.exists()) return null; // CraftBukkit - RegionFile regionfile1 = new RegionFile(file1, this.folder, this.sync); + Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca"); ++ if (existingOnly && !Files.exists(path1)) return null; // CraftBukkit + RegionFile regionfile1 = new RegionFile(path1, this.folder, this.sync); this.regionCache.putAndMoveToFirst(i, regionfile1); -@@ -54,7 +55,12 @@ +@@ -53,7 +54,12 @@ @Nullable public NBTTagCompound read(ChunkCoordIntPair chunkcoordintpair) throws IOException { -- RegionFile regionfile = this.getFile(chunkcoordintpair); +- RegionFile regionfile = this.getRegionFile(chunkcoordintpair); + // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing -+ RegionFile regionfile = this.getFile(chunkcoordintpair, true); ++ RegionFile regionfile = this.getRegionFile(chunkcoordintpair, true); + if (regionfile == null) { + return null; + } + // CraftBukkit end - DataInputStream datainputstream = regionfile.a(chunkcoordintpair); + DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkcoordintpair); NBTTagCompound nbttagcompound; -@@ -94,7 +100,7 @@ +@@ -93,7 +99,12 @@ + } + + public void scanChunk(ChunkCoordIntPair chunkcoordintpair, StreamTagVisitor streamtagvisitor) throws IOException { +- RegionFile regionfile = this.getRegionFile(chunkcoordintpair); ++ // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing ++ RegionFile regionfile = this.getRegionFile(chunkcoordintpair, true); ++ if (regionfile == null) { ++ return; ++ } ++ // CraftBukkit end + DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkcoordintpair); + + try { +@@ -119,7 +130,7 @@ } protected void write(ChunkCoordIntPair chunkcoordintpair, @Nullable NBTTagCompound nbttagcompound) throws IOException { -- RegionFile regionfile = this.getFile(chunkcoordintpair); -+ RegionFile regionfile = this.getFile(chunkcoordintpair, false); // CraftBukkit +- RegionFile regionfile = this.getRegionFile(chunkcoordintpair); ++ RegionFile regionfile = this.getRegionFile(chunkcoordintpair, false); // CraftBukkit if (nbttagcompound == null) { - regionfile.d(chunkcoordintpair); + regionfile.clear(chunkcoordintpair); diff --git a/paper-server/nms-patches/net/minecraft/world/level/entity/PersistentEntitySectionManager.patch b/paper-server/nms-patches/net/minecraft/world/level/entity/PersistentEntitySectionManager.patch index 8591eb5f0e..f775e8dd0a 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/entity/PersistentEntitySectionManager.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/entity/PersistentEntitySectionManager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/entity/PersistentEntitySectionManager.java +++ b/net/minecraft/world/level/entity/PersistentEntitySectionManager.java -@@ -32,12 +32,17 @@ +@@ -32,6 +32,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -12,20 +12,13 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements AutoCloseable { static final Logger LOGGER = LogManager.getLogger(); - final Set<UUID> knownUuids = Sets.newHashSet(); - final LevelCallback<T> callbacks; -- private final EntityPersistentStorage<T> permanentStorage; -+ public final EntityPersistentStorage<T> permanentStorage; // PAIL private -> public - private final EntityLookup<T> visibleEntityStorage = new EntityLookup<>(); - final EntitySectionStorage<T> sectionStorage; - private final LevelEntityGetter<T> entityGetter; @@ -55,6 +60,16 @@ this.entityGetter = new LevelEntityGetterAdapter<>(this.visibleEntityStorage, this.sectionStorage); } + // CraftBukkit start - add method to get all entities in chunk + public List<Entity> getEntities(ChunkCoordIntPair chunkCoordIntPair) { -+ return sectionStorage.b(chunkCoordIntPair.pair()).flatMap(EntitySection::b).map(entity -> (Entity) entity).collect(Collectors.toList()); ++ return sectionStorage.getExistingSectionsInChunk(chunkCoordIntPair.toLong()).flatMap(EntitySection::getEntities).map(entity -> (Entity) entity).collect(Collectors.toList()); + } + + public boolean isPending(long pair) { @@ -33,36 +26,18 @@ + } + // CraftBukkit end + - void a(long i, EntitySection<T> entitysection) { - if (entitysection.a()) { - this.sectionStorage.e(i); -@@ -82,7 +97,7 @@ - long i = SectionPosition.c(t0.getChunkCoordinates()); - EntitySection<T> entitysection = this.sectionStorage.c(i); - -- entitysection.a((Object) t0); -+ entitysection.a(t0); // CraftBukkit - decompile error - t0.a(new PersistentEntitySectionManager.a(t0, i, entitysection)); - if (!flag) { - this.callbacks.f(t0); -@@ -186,7 +201,7 @@ - }); - } - -- private void b(long i) { -+ public void b(long i) { // PAIL private -> public, rename scheduleEntityLoading - PersistentEntitySectionManager.b persistententitysectionmanager_b = (PersistentEntitySectionManager.b) this.chunkLoadStatuses.get(i); - - if (persistententitysectionmanager_b == PersistentEntitySectionManager.b.FRESH) { + void removeSectionIfEmpty(long i, EntitySection<T> entitysection) { + if (entitysection.isEmpty()) { + this.sectionStorage.remove(i); @@ -196,6 +211,12 @@ } - private boolean a(long i, Consumer<T> consumer) { + private boolean storeChunkSections(long i, Consumer<T> consumer) { + // CraftBukkit start - add boolean for event call -+ return a(i, consumer, false); ++ return storeChunkSections(i, consumer, false); + } + -+ private boolean a(long i, Consumer<T> consumer, boolean callEvent) { ++ private boolean storeChunkSections(long i, Consumer<T> consumer, boolean callEvent) { + // CraftBukkit end PersistentEntitySectionManager.b persistententitysectionmanager_b = (PersistentEntitySectionManager.b) this.chunkLoadStatuses.get(i); @@ -72,21 +47,21 @@ if (list.isEmpty()) { if (persistententitysectionmanager_b == PersistentEntitySectionManager.b.LOADED) { + if (callEvent) CraftEventFactory.callEntitiesUnloadEvent(((EntityStorage) permanentStorage).level, new ChunkCoordIntPair(i), ImmutableList.of()); // CraftBukkit - this.permanentStorage.a(new ChunkEntities<>(new ChunkCoordIntPair(i), ImmutableList.of())); + this.permanentStorage.storeEntities(new ChunkEntities<>(new ChunkCoordIntPair(i), ImmutableList.of())); } @@ -215,6 +237,7 @@ - this.c(i); + 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.a(new ChunkEntities<>(new ChunkCoordIntPair(i), list)); + this.permanentStorage.storeEntities(new ChunkEntities<>(new ChunkCoordIntPair(i), list)); list.forEach(consumer); return true; @@ -238,7 +261,7 @@ - private boolean d(long i) { - boolean flag = this.a(i, (entityaccess) -> { - entityaccess.cD().forEach(this::g); + private boolean processChunkUnload(long i) { + boolean flag = this.storeChunkSections(i, (entityaccess) -> { + entityaccess.getPassengersAndSelf().forEach(this::unloadEntity); - }); + }, true); // CraftBukkit - add boolean for event call @@ -95,25 +70,25 @@ @@ -254,19 +277,23 @@ } - private void f() { + private void processUnloads() { - this.chunksToUnload.removeIf((i) -> { + this.chunksToUnload.removeIf((java.util.function.LongPredicate) (i) -> { // CraftBukkit - decompile error - return this.chunkVisibility.get(i) != Visibility.HIDDEN ? true : this.d(i); + return this.chunkVisibility.get(i) != Visibility.HIDDEN ? true : this.processChunkUnload(i); }); } - private void g() { + private void processPendingLoads() { - ChunkEntities chunkentities; + ChunkEntities<T> chunkentities; // CraftBukkit - decompile error while ((chunkentities = (ChunkEntities) this.loadingInbox.poll()) != null) { - chunkentities.b().forEach((entityaccess) -> { - this.a(entityaccess, true); + chunkentities.getEntities().forEach((entityaccess) -> { + this.addEntity(entityaccess, true); }); - this.chunkLoadStatuses.put(chunkentities.a().pair(), PersistentEntitySectionManager.b.LOADED); + this.chunkLoadStatuses.put(chunkentities.getPos().toLong(), PersistentEntitySectionManager.b.LOADED); + // CraftBukkit start - call entity load event -+ List<Entity> entities = getEntities(chunkentities.a()); // PAIL rename getChunkPos -+ CraftEventFactory.callEntitiesLoadEvent(((EntityStorage) permanentStorage).level, chunkentities.a(), entities); ++ List<Entity> entities = getEntities(chunkentities.getPos()); ++ CraftEventFactory.callEntitiesLoadEvent(((EntityStorage) permanentStorage).level, chunkentities.getPos(), entities); + // CraftBukkit end } @@ -121,47 +96,47 @@ @@ -292,7 +319,7 @@ } - public void b() { -- this.h().forEach((i) -> { -+ this.h().forEach((java.util.function.LongConsumer) (i) -> { // CraftBukkit - decompile error + public void autoSave() { +- this.getAllChunksToSave().forEach((i) -> { ++ this.getAllChunksToSave().forEach((java.util.function.LongConsumer) (i) -> { // CraftBukkit - decompile error boolean flag = this.chunkVisibility.get(i) == Visibility.HIDDEN; if (flag) { @@ -311,7 +338,7 @@ while (!longset.isEmpty()) { - this.permanentStorage.a(false); - this.g(); + this.permanentStorage.flush(false); + this.processPendingLoads(); - longset.removeIf((i) -> { + longset.removeIf((java.util.function.LongPredicate) (i) -> { // CraftBukkit - decompile error boolean flag = this.chunkVisibility.get(i) == Visibility.HIDDEN; - return flag ? this.d(i) : this.a(i, (entityaccess) -> { + return flag ? this.processChunkUnload(i) : this.storeChunkSections(i, (entityaccess) -> { @@ -323,7 +350,15 @@ } public void close() throws IOException { -- this.c(); +- this.saveAll(); + // CraftBukkit start - add save boolean + close(true); + } + + public void close(boolean save) throws IOException { + if (save) { -+ this.c(); // PAIL rename saveAll ++ this.saveAll(); + } + // CraftBukkit end this.permanentStorage.close(); } @@ -350,7 +385,7 @@ - public void a(Writer writer) throws IOException { - CSVWriter csvwriter = CSVWriter.a().a("x").a("y").a("z").a("visibility").a("load_status").a("entity_count").a(writer); + 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); -- this.sectionStorage.a().forEach((i) -> { -+ this.sectionStorage.a().forEach((java.util.function.LongConsumer) (i) -> { // CraftBukkit - decompile error +- this.sectionStorage.getAllChunksWithExistingSections().forEach((i) -> { ++ this.sectionStorage.getAllChunksWithExistingSections().forEach((java.util.function.LongConsumer) (i) -> { // CraftBukkit - decompile error PersistentEntitySectionManager.b persistententitysectionmanager_b = (PersistentEntitySectionManager.b) this.chunkLoadStatuses.get(i); - this.sectionStorage.a(i).forEach((j) -> { + this.sectionStorage.getExistingSectionPositionsInChunk(i).forEach((j) -> { @@ -389,7 +424,7 @@ private EntitySection<T> currentSection; @@ -171,12 +146,3 @@ this.currentSectionKey = i; this.currentSection = entitysection; } -@@ -409,7 +444,7 @@ - PersistentEntitySectionManager.this.a(this.currentSectionKey, this.currentSection); - EntitySection<T> entitysection = PersistentEntitySectionManager.this.sectionStorage.c(i); - -- entitysection.a((Object) this.entity); -+ entitysection.a(this.entity); // CraftBukkit - decompile error - this.currentSection = entitysection; - this.currentSectionKey = i; - this.a(visibility, entitysection.c()); diff --git a/paper-server/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationListener.patch b/paper-server/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationListener.patch index e73b1381bc..9abd2ff076 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationListener.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationListener.patch @@ -18,14 +18,14 @@ } else { BlockPosition blockposition1 = (BlockPosition) optional.get(); -- if (!this.config.a(world, this, blockposition, gameevent, entity)) { +- if (!this.config.shouldListen(world, this, blockposition, gameevent, entity)) { + // CraftBukkit start -+ boolean defaultCancel = !this.config.a(world, this, blockposition, gameevent, entity); ++ boolean defaultCancel = !this.config.shouldListen(world, this, blockposition, gameevent, entity); + BlockReceiveGameEvent event = new BlockReceiveGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.GAME_EVENT.getKey(gameevent))), CraftBlock.at(world, blockposition), (entity == null) ? null : entity.getBukkitEntity()); + event.setCancelled(defaultCancel); + world.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + // CraftBukkit end return false; - } else if (this.a(world, blockposition, blockposition1)) { + } else if (this.isOccluded(world, blockposition, blockposition1)) { return false; diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.patch index c6afa323f7..3652c99460 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.patch @@ -1,69 +1,7 @@ --- a/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.java +++ b/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.java -@@ -76,7 +76,7 @@ - protected final IBlockData defaultBlock; - protected final IBlockData defaultFluid; - private final long seed; -- protected final Supplier<GeneratorSettingBase> settings; -+ public final Supplier<GeneratorSettingBase> settings; // PAIL protected -> public - private final int height; - private final NoiseSampler sampler; - private final BaseStoneSource baseStoneSource; -@@ -257,6 +257,19 @@ +@@ -1,3 +1,4 @@ ++// keep + package net.minecraft.world.level.levelgen; - @Override - public void buildBase(RegionLimitedWorldAccess regionlimitedworldaccess, IChunkAccess ichunkaccess) { -+ // CraftBukkit start - spilt surface and bedrock generation code -+ Random random = buildSurface(regionlimitedworldaccess, ichunkaccess); -+ buildBedrock(ichunkaccess, random); -+ } -+ -+ @Override -+ public void buildBedrock(IChunkAccess iChunkAccess, Random random) { -+ a(iChunkAccess, random); // PAIL rename setBedrock -+ } -+ -+ @Override -+ public SeededRandom buildSurface(RegionLimitedWorldAccess regionlimitedworldaccess, IChunkAccess ichunkaccess) { -+ // CraftBukkit end - ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos(); - int i = chunkcoordintpair.x; - int j = chunkcoordintpair.z; -@@ -281,7 +294,10 @@ - } - } - -- this.a(ichunkaccess, seededrandom); -+ // CraftBukkit start - spilt surface and bedrock generation code -+ // this.a(ichunkaccess, seededrandom); -+ return seededrandom; -+ // CraftBukkit end - } - - private void a(IChunkAccess ichunkaccess, Random random) { -@@ -403,16 +419,23 @@ - BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition(); - - for (int i1 = 0; i1 < this.cellCountX; ++i1) { -+ // CraftBukkit start - decompile error -+ int i1Final = i1; - list.forEach((noiseinterpolator1) -> { -- noiseinterpolator1.a(i1); -+ noiseinterpolator1.a(i1Final); -+ // CraftBukkit end - }); - - for (int j1 = 0; j1 < this.cellCountZ; ++j1) { - ChunkSection chunksection = ichunkaccess.b(ichunkaccess.getSectionsCount() - 1); - - for (int k1 = j - 1; k1 >= 0; --k1) { -+ // CraftBukkit start - decompile error -+ int kiFinal = k1; -+ int j1Final = j1; - list.forEach((noiseinterpolator1) -> { -- noiseinterpolator1.a(k1, j1); -+ noiseinterpolator1.a(kiFinal, j1Final); -+ // CraftBukkit end - }); - - for (int l1 = this.cellHeight - 1; l1 >= 0; --l1) { + import com.google.common.collect.ImmutableList; diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/GeneratorSettings.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/GeneratorSettings.patch index 0ec7ab64f2..d959185597 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/GeneratorSettings.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/levelgen/GeneratorSettings.patch @@ -13,42 +13,57 @@ - public static final Codec<GeneratorSettings> CODEC = RecordCodecBuilder.create((instance) -> { + public static final Codec<GeneratorSettings> CODEC = RecordCodecBuilder.<GeneratorSettings>create((instance) -> { // CraftBukkit - decompile error - return instance.group(Codec.LONG.fieldOf("seed").stable().forGetter(GeneratorSettings::getSeed), Codec.BOOL.fieldOf("generate_features").orElse(true).stable().forGetter(GeneratorSettings::shouldGenerateMapFeatures), Codec.BOOL.fieldOf("bonus_chest").orElse(false).stable().forGetter(GeneratorSettings::c), RegistryMaterials.b(IRegistry.LEVEL_STEM_REGISTRY, Lifecycle.stable(), WorldDimension.CODEC).xmap(WorldDimension::a, Function.identity()).fieldOf("dimensions").forGetter(GeneratorSettings::d), Codec.STRING.optionalFieldOf("legacy_custom_options").stable().forGetter((generatorsettings) -> { + return instance.group(Codec.LONG.fieldOf("seed").stable().forGetter(GeneratorSettings::seed), Codec.BOOL.fieldOf("generate_features").orElse(true).stable().forGetter(GeneratorSettings::generateFeatures), Codec.BOOL.fieldOf("bonus_chest").orElse(false).stable().forGetter(GeneratorSettings::generateBonusChest), RegistryMaterials.dataPackCodec(IRegistry.LEVEL_STEM_REGISTRY, Lifecycle.stable(), WorldDimension.CODEC).xmap(WorldDimension::sortMap, Function.identity()).fieldOf("dimensions").forGetter(GeneratorSettings::dimensions), Codec.STRING.optionalFieldOf("legacy_custom_options").stable().forGetter((generatorsettings) -> { return generatorsettings.legacyCustomOptions; })).apply(instance, instance.stable(GeneratorSettings::new)); -@@ -121,7 +126,7 @@ - public static RegistryMaterials<WorldDimension> a(RegistryMaterials<WorldDimension> registrymaterials, Supplier<DimensionManager> supplier, ChunkGenerator chunkgenerator) { +@@ -130,7 +135,7 @@ + public static RegistryMaterials<WorldDimension> withOverworld(RegistryMaterials<WorldDimension> registrymaterials, Supplier<DimensionManager> supplier, ChunkGenerator chunkgenerator) { RegistryMaterials<WorldDimension> registrymaterials1 = new RegistryMaterials<>(IRegistry.LEVEL_STEM_REGISTRY, Lifecycle.experimental()); -- registrymaterials1.a(WorldDimension.OVERWORLD, (Object) (new WorldDimension(supplier, chunkgenerator)), Lifecycle.stable()); -+ registrymaterials1.a(WorldDimension.OVERWORLD, (new WorldDimension(supplier, chunkgenerator)), Lifecycle.stable()); // CraftBukkit - decompile error - Iterator iterator = registrymaterials.d().iterator(); +- registrymaterials1.register(WorldDimension.OVERWORLD, (Object) (new WorldDimension(supplier, chunkgenerator)), Lifecycle.stable()); ++ registrymaterials1.register(WorldDimension.OVERWORLD, (new WorldDimension(supplier, chunkgenerator)), Lifecycle.stable()); // CraftBukkit - decompile error + Iterator iterator = registrymaterials.entrySet().iterator(); while (iterator.hasNext()) { -@@ -129,7 +134,7 @@ +@@ -138,7 +143,7 @@ ResourceKey<WorldDimension> resourcekey = (ResourceKey) entry.getKey(); if (resourcekey != WorldDimension.OVERWORLD) { -- registrymaterials1.a(resourcekey, (Object) ((WorldDimension) entry.getValue()), registrymaterials.d((Object) ((WorldDimension) entry.getValue()))); -+ registrymaterials1.a(resourcekey, ((WorldDimension) entry.getValue()), registrymaterials.d(((WorldDimension) entry.getValue()))); // CraftBukkit - decompile error +- registrymaterials1.register(resourcekey, (Object) ((WorldDimension) entry.getValue()), registrymaterials.lifecycle((WorldDimension) entry.getValue())); ++ registrymaterials1.register(resourcekey, ((WorldDimension) entry.getValue()), registrymaterials.lifecycle((WorldDimension) entry.getValue())); // CraftBukkit - decompile error } } -@@ -242,7 +247,7 @@ +@@ -159,17 +164,19 @@ + } + } + +- public ImmutableSet<ResourceKey<World>> levels() { ++ // CraftBukkit start ++ public ImmutableSet<ResourceKey<DimensionManager>> levels() { + return (ImmutableSet) this.dimensions().entrySet().stream().map(Entry::getKey).map(GeneratorSettings::levelStemToLevel).collect(ImmutableSet.toImmutableSet()); + } + +- public static ResourceKey<World> levelStemToLevel(ResourceKey<WorldDimension> resourcekey) { +- return ResourceKey.create(IRegistry.DIMENSION_REGISTRY, resourcekey.location()); ++ public static ResourceKey<DimensionManager> levelStemToLevel(ResourceKey<WorldDimension> resourcekey) { ++ return ResourceKey.create(IRegistry.DIMENSION_TYPE_REGISTRY, resourcekey.location()); + } + +- public static ResourceKey<WorldDimension> levelToLevelStem(ResourceKey<World> resourcekey) { ++ public static ResourceKey<WorldDimension> levelToLevelStem(ResourceKey<DimensionManager> resourcekey) { + return ResourceKey.create(IRegistry.LEVEL_STEM_REGISTRY, resourcekey.location()); + } ++ // CraftBukkit end + + public boolean isDebug() { + return this.overworld() instanceof ChunkProviderDebug; +@@ -246,7 +253,7 @@ switch (b0) { case 0: - JsonObject jsonobject = !s.isEmpty() ? ChatDeserializer.a(s) : new JsonObject(); + JsonObject jsonobject = !s.isEmpty() ? ChatDeserializer.parse(s) : new JsonObject(); - Dynamic<JsonElement> dynamic = new Dynamic(JsonOps.INSTANCE, jsonobject); -+ Dynamic<JsonElement> dynamic = new Dynamic(RegistryReadOps.a(JsonOps.INSTANCE, IResourceManager.Empty.INSTANCE, (IRegistryCustom.Dimension) iregistrycustom), jsonobject); // CraftBukkit - SPIGOT-6237 ++ Dynamic<JsonElement> dynamic = new Dynamic(RegistryReadOps.createAndLoad(JsonOps.INSTANCE, IResourceManager.Empty.INSTANCE, (IRegistryCustom.Dimension) iregistrycustom), jsonobject); // CraftBukkit - SPIGOT-6237 DataResult dataresult = GeneratorSettingsFlat.CODEC.parse(dynamic); Logger logger = GeneratorSettings.LOGGER; -@@ -278,7 +283,7 @@ - Entry<ResourceKey<WorldDimension>, WorldDimension> entry = (Entry) iterator.next(); - ResourceKey<WorldDimension> resourcekey = (ResourceKey) entry.getKey(); - -- registrymaterials.a(resourcekey, (Object) (new WorldDimension(((WorldDimension) entry.getValue()).a(), ((WorldDimension) entry.getValue()).c().withSeed(j))), this.dimensions.d((Object) ((WorldDimension) entry.getValue()))); -+ registrymaterials.a(resourcekey, (Object) (new WorldDimension(((WorldDimension) entry.getValue()).a(), ((WorldDimension) entry.getValue()).c().withSeed(j))), this.dimensions.d(((WorldDimension) entry.getValue()))); // CraftBukkit - decompile error - } - } else { - registrymaterials = this.dimensions; diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch index 6469db56a2..dff62de181 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/levelgen/MobSpawnerPatrol.java +++ b/net/minecraft/world/level/levelgen/MobSpawnerPatrol.java -@@ -119,7 +119,7 @@ +@@ -116,7 +116,7 @@ - entitymonsterpatrolling.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); - entitymonsterpatrolling.prepare(worldserver, worldserver.getDamageScaler(blockposition), EnumMobSpawn.PATROL, (GroupDataEntity) null, (NBTTagCompound) null); -- worldserver.addAllEntities(entitymonsterpatrolling); -+ worldserver.addAllEntities(entitymonsterpatrolling, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PATROL); // CraftBukkit + entitymonsterpatrolling.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); + entitymonsterpatrolling.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(blockposition), EnumMobSpawn.PATROL, (GroupDataEntity) null, (NBTTagCompound) null); +- worldserver.addFreshEntityWithPassengers(entitymonsterpatrolling); ++ worldserver.addFreshEntityWithPassengers(entitymonsterpatrolling, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PATROL); // CraftBukkit return true; } else { return false; diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPhantom.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPhantom.patch index 2d8e6a56a9..da85e3924d 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPhantom.patch +++ b/paper-server/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 -@@ -77,7 +77,7 @@ +@@ -75,7 +75,7 @@ - entityphantom.setPositionRotation(blockposition1, 0.0F, 0.0F); - groupdataentity = entityphantom.prepare(worldserver, difficultydamagescaler, EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null); -- worldserver.addAllEntities(entityphantom); -+ worldserver.addAllEntities(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit + entityphantom.moveTo(blockposition1, 0.0F, 0.0F); + groupdataentity = entityphantom.finalizeSpawn(worldserver, difficultydamagescaler, EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null); +- worldserver.addFreshEntityWithPassengers(entityphantom); ++ worldserver.addFreshEntityWithPassengers(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit } i += k; diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/NoiseSampler.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/NoiseSampler.patch deleted file mode 100644 index 9c9d158144..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/NoiseSampler.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/net/minecraft/world/level/levelgen/NoiseSampler.java -+++ b/net/minecraft/world/level/levelgen/NoiseSampler.java -@@ -13,7 +13,7 @@ - public class NoiseSampler { - - private static final int OLD_CELL_COUNT_Y = 32; -- private static final float[] BIOME_WEIGHTS = (float[]) SystemUtils.a((Object) (new float[25]), (afloat) -> { -+ private static final float[] BIOME_WEIGHTS = (float[]) SystemUtils.a((new float[25]), (afloat) -> { // CraftBukkit - decompile error - for (int i = -2; i <= 2; ++i) { - for (int j = -2; j <= 2; ++j) { - float f = 10.0F / MathHelper.c((float) (i * i + j * j) + 0.2F); -@@ -97,6 +97,11 @@ - f6 = f4; - f7 = f5; - } -+ // CraftBukkit start - fix MC-54738 -+ if (f6 < -1.8F) { -+ f6 = -1.8F; -+ } -+ // CraftBukkit end - - float f8 = f4 > f3 ? 0.5F : 1.0F; - float f9 = f8 * NoiseSampler.BIOME_WEIGHTS[k1 + 2 + (l1 + 2) * 5] / (f6 + 2.0F); diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/StructureSettings.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/StructureSettings.patch index 7a339b2bcb..fd34a6d157 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/StructureSettings.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/levelgen/StructureSettings.patch @@ -4,26 +4,27 @@ +// mc-dev import package net.minecraft.world.level.levelgen; - import com.google.common.collect.ImmutableMap; -@@ -22,14 +23,15 @@ + import com.google.common.annotations.VisibleForTesting; +@@ -31,7 +32,8 @@ return structuresettings.structureConfig; })).apply(instance, StructureSettings::new); }); -- public static final ImmutableMap<StructureGenerator<?>, StructureSettingsFeature> DEFAULTS = ImmutableMap.builder().put(StructureGenerator.VILLAGE, new StructureSettingsFeature(32, 8, 10387312)).put(StructureGenerator.DESERT_PYRAMID, new StructureSettingsFeature(32, 8, 14357617)).put(StructureGenerator.IGLOO, new StructureSettingsFeature(32, 8, 14357618)).put(StructureGenerator.JUNGLE_TEMPLE, new StructureSettingsFeature(32, 8, 14357619)).put(StructureGenerator.SWAMP_HUT, new StructureSettingsFeature(32, 8, 14357620)).put(StructureGenerator.PILLAGER_OUTPOST, new StructureSettingsFeature(32, 8, 165745296)).put(StructureGenerator.STRONGHOLD, new StructureSettingsFeature(1, 0, 0)).put(StructureGenerator.OCEAN_MONUMENT, new StructureSettingsFeature(32, 5, 10387313)).put(StructureGenerator.END_CITY, new StructureSettingsFeature(20, 11, 10387313)).put(StructureGenerator.WOODLAND_MANSION, new StructureSettingsFeature(80, 20, 10387319)).put(StructureGenerator.BURIED_TREASURE, new StructureSettingsFeature(1, 0, 0)).put(StructureGenerator.MINESHAFT, new StructureSettingsFeature(1, 0, 0)).put(StructureGenerator.RUINED_PORTAL, new StructureSettingsFeature(40, 15, 34222645)).put(StructureGenerator.SHIPWRECK, new StructureSettingsFeature(24, 4, 165745295)).put(StructureGenerator.OCEAN_RUIN, new StructureSettingsFeature(20, 8, 14357621)).put(StructureGenerator.BASTION_REMNANT, new StructureSettingsFeature(27, 4, 30084232)).put(StructureGenerator.NETHER_BRIDGE, new StructureSettingsFeature(27, 4, 30084232)).put(StructureGenerator.NETHER_FOSSIL, new StructureSettingsFeature(2, 1, 14357921)).build(); +- public static final ImmutableMap<StructureGenerator<?>, StructureSettingsFeature> DEFAULTS = ImmutableMap.builder().put(StructureGenerator.VILLAGE, new StructureSettingsFeature(34, 8, 10387312)).put(StructureGenerator.DESERT_PYRAMID, new StructureSettingsFeature(32, 8, 14357617)).put(StructureGenerator.IGLOO, new StructureSettingsFeature(32, 8, 14357618)).put(StructureGenerator.JUNGLE_TEMPLE, new StructureSettingsFeature(32, 8, 14357619)).put(StructureGenerator.SWAMP_HUT, new StructureSettingsFeature(32, 8, 14357620)).put(StructureGenerator.PILLAGER_OUTPOST, new StructureSettingsFeature(32, 8, 165745296)).put(StructureGenerator.STRONGHOLD, new StructureSettingsFeature(1, 0, 0)).put(StructureGenerator.OCEAN_MONUMENT, new StructureSettingsFeature(32, 5, 10387313)).put(StructureGenerator.END_CITY, new StructureSettingsFeature(20, 11, 10387313)).put(StructureGenerator.WOODLAND_MANSION, new StructureSettingsFeature(80, 20, 10387319)).put(StructureGenerator.BURIED_TREASURE, new StructureSettingsFeature(1, 0, 0)).put(StructureGenerator.MINESHAFT, new StructureSettingsFeature(1, 0, 0)).put(StructureGenerator.RUINED_PORTAL, new StructureSettingsFeature(40, 15, 34222645)).put(StructureGenerator.SHIPWRECK, new StructureSettingsFeature(24, 4, 165745295)).put(StructureGenerator.OCEAN_RUIN, new StructureSettingsFeature(20, 8, 14357621)).put(StructureGenerator.BASTION_REMNANT, new StructureSettingsFeature(27, 4, 30084232)).put(StructureGenerator.NETHER_BRIDGE, new StructureSettingsFeature(27, 4, 30084232)).put(StructureGenerator.NETHER_FOSSIL, new StructureSettingsFeature(2, 1, 14357921)).build(); + // CraftBukkit - decompile error -+ public static final ImmutableMap<StructureGenerator<?>, StructureSettingsFeature> DEFAULTS = ImmutableMap.<StructureGenerator<?>, StructureSettingsFeature>builder().put(StructureGenerator.VILLAGE, new StructureSettingsFeature(32, 8, 10387312)).put(StructureGenerator.DESERT_PYRAMID, new StructureSettingsFeature(32, 8, 14357617)).put(StructureGenerator.IGLOO, new StructureSettingsFeature(32, 8, 14357618)).put(StructureGenerator.JUNGLE_TEMPLE, new StructureSettingsFeature(32, 8, 14357619)).put(StructureGenerator.SWAMP_HUT, new StructureSettingsFeature(32, 8, 14357620)).put(StructureGenerator.PILLAGER_OUTPOST, new StructureSettingsFeature(32, 8, 165745296)).put(StructureGenerator.STRONGHOLD, new StructureSettingsFeature(1, 0, 0)).put(StructureGenerator.OCEAN_MONUMENT, new StructureSettingsFeature(32, 5, 10387313)).put(StructureGenerator.END_CITY, new StructureSettingsFeature(20, 11, 10387313)).put(StructureGenerator.WOODLAND_MANSION, new StructureSettingsFeature(80, 20, 10387319)).put(StructureGenerator.BURIED_TREASURE, new StructureSettingsFeature(1, 0, 0)).put(StructureGenerator.MINESHAFT, new StructureSettingsFeature(1, 0, 0)).put(StructureGenerator.RUINED_PORTAL, new StructureSettingsFeature(40, 15, 34222645)).put(StructureGenerator.SHIPWRECK, new StructureSettingsFeature(24, 4, 165745295)).put(StructureGenerator.OCEAN_RUIN, new StructureSettingsFeature(20, 8, 14357621)).put(StructureGenerator.BASTION_REMNANT, new StructureSettingsFeature(27, 4, 30084232)).put(StructureGenerator.NETHER_BRIDGE, new StructureSettingsFeature(27, 4, 30084232)).put(StructureGenerator.NETHER_FOSSIL, new StructureSettingsFeature(2, 1, 14357921)).build(); ++ public static final ImmutableMap<StructureGenerator<?>, StructureSettingsFeature> DEFAULTS = ImmutableMap.<StructureGenerator<?>, StructureSettingsFeature>builder().put(StructureGenerator.VILLAGE, new StructureSettingsFeature(34, 8, 10387312)).put(StructureGenerator.DESERT_PYRAMID, new StructureSettingsFeature(32, 8, 14357617)).put(StructureGenerator.IGLOO, new StructureSettingsFeature(32, 8, 14357618)).put(StructureGenerator.JUNGLE_TEMPLE, new StructureSettingsFeature(32, 8, 14357619)).put(StructureGenerator.SWAMP_HUT, new StructureSettingsFeature(32, 8, 14357620)).put(StructureGenerator.PILLAGER_OUTPOST, new StructureSettingsFeature(32, 8, 165745296)).put(StructureGenerator.STRONGHOLD, new StructureSettingsFeature(1, 0, 0)).put(StructureGenerator.OCEAN_MONUMENT, new StructureSettingsFeature(32, 5, 10387313)).put(StructureGenerator.END_CITY, new StructureSettingsFeature(20, 11, 10387313)).put(StructureGenerator.WOODLAND_MANSION, new StructureSettingsFeature(80, 20, 10387319)).put(StructureGenerator.BURIED_TREASURE, new StructureSettingsFeature(1, 0, 0)).put(StructureGenerator.MINESHAFT, new StructureSettingsFeature(1, 0, 0)).put(StructureGenerator.RUINED_PORTAL, new StructureSettingsFeature(40, 15, 34222645)).put(StructureGenerator.SHIPWRECK, new StructureSettingsFeature(24, 4, 165745295)).put(StructureGenerator.OCEAN_RUIN, new StructureSettingsFeature(20, 8, 14357621)).put(StructureGenerator.BASTION_REMNANT, new StructureSettingsFeature(27, 4, 30084232)).put(StructureGenerator.NETHER_BRIDGE, new StructureSettingsFeature(27, 4, 30084232)).put(StructureGenerator.NETHER_FOSSIL, new StructureSettingsFeature(2, 1, 14357921)).build(); public static final StructureSettingsStronghold DEFAULT_STRONGHOLD; private final Map<StructureGenerator<?>, StructureSettingsFeature> structureConfig; - @Nullable - private final StructureSettingsStronghold stronghold; - - public StructureSettings(Optional<StructureSettingsStronghold> optional, Map<StructureGenerator<?>, StructureSettingsFeature> map) { -- this.stronghold = (StructureSettingsStronghold) optional.orElse((Object) null); -+ this.stronghold = (StructureSettingsStronghold) optional.orElse(null); // CraftBukkit - decompile error - this.structureConfig = map; + private final ImmutableMap<StructureGenerator<?>, ImmutableMultimap<StructureFeature<?, ?>, ResourceKey<BiomeBase>>> configuredStructures; +@@ -54,7 +56,7 @@ } -@@ -53,6 +55,15 @@ + public StructureSettings(Optional<StructureSettingsStronghold> optional, Map<StructureGenerator<?>, StructureSettingsFeature> map) { +- this(map, (StructureSettingsStronghold) optional.orElse((Object) null)); ++ this(map, (StructureSettingsStronghold) optional.orElse(null)); // CraftBukkit - decompile error + } + + public StructureSettings(boolean flag) { +@@ -81,6 +83,15 @@ } static { @@ -39,7 +40,7 @@ Iterator iterator = IRegistry.STRUCTURE_FEATURE.iterator(); StructureGenerator structuregenerator; -@@ -67,5 +78,7 @@ +@@ -95,5 +106,7 @@ } while (StructureSettings.DEFAULTS.containsKey(structuregenerator)); throw new IllegalStateException("Structure feature without default settings: " + IRegistry.STRUCTURE_FEATURE.getKey(structuregenerator)); diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch index 4077b0e698..2a9a079a88 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch +++ b/paper-server/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 -@@ -20,9 +20,13 @@ +@@ -20,6 +20,10 @@ import net.minecraft.world.level.levelgen.feature.StructureGenerator; import net.minecraft.world.level.storage.WorldPersistentData; @@ -10,27 +10,14 @@ + public class PersistentStructureLegacy { -- private static final Map<String, String> CURRENT_TO_LEGACY_MAP = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { -+ private static final Map<String, String> CURRENT_TO_LEGACY_MAP = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error - hashmap.put("Village", "Village"); - hashmap.put("Mineshaft", "Mineshaft"); - hashmap.put("Mansion", "Mansion"); -@@ -35,7 +39,7 @@ - hashmap.put("Fortress", "Fortress"); - hashmap.put("EndCity", "EndCity"); - }); -- private static final Map<String, String> LEGACY_TO_CURRENT_MAP = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { -+ private static final Map<String, String> LEGACY_TO_CURRENT_MAP = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error - hashmap.put("Iglu", "Igloo"); - hashmap.put("TeDP", "Desert_Pyramid"); - hashmap.put("TeJP", "Jungle_Pyramid"); + private static final Map<String, String> CURRENT_TO_LEGACY_MAP = (Map) SystemUtils.make(Maps.newHashMap(), (hashmap) -> { @@ -234,16 +238,16 @@ } } -- public static PersistentStructureLegacy a(ResourceKey<World> resourcekey, @Nullable WorldPersistentData worldpersistentdata) { +- public static PersistentStructureLegacy getLegacyStructureHandler(ResourceKey<World> resourcekey, @Nullable WorldPersistentData worldpersistentdata) { - if (resourcekey == World.OVERWORLD) { -+ public static PersistentStructureLegacy a(ResourceKey<DimensionManager> resourcekey, @Nullable WorldPersistentData worldpersistentdata) { // CraftBukkit ++ public static PersistentStructureLegacy getLegacyStructureHandler(ResourceKey<DimensionManager> resourcekey, @Nullable WorldPersistentData worldpersistentdata) { // CraftBukkit + if (resourcekey == DimensionManager.OVERWORLD_LOCATION) { // 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 { diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/WorldGenWitchHut.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/WorldGenWitchHut.patch index 85f8a3aea4..f0e988f785 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/WorldGenWitchHut.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/WorldGenWitchHut.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/level/levelgen/structure/WorldGenWitchHut.java +++ b/net/minecraft/world/level/levelgen/structure/WorldGenWitchHut.java -@@ -101,7 +101,7 @@ - entitywitch.setPersistent(); - entitywitch.setPositionRotation((double) blockposition_mutableblockposition.getX() + 0.5D, (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + 0.5D, 0.0F, 0.0F); - entitywitch.prepare(generatoraccessseed, generatoraccessseed.getDamageScaler(blockposition_mutableblockposition), EnumMobSpawn.STRUCTURE, (GroupDataEntity) null, (NBTTagCompound) null); -- generatoraccessseed.addAllEntities(entitywitch); -+ generatoraccessseed.addAllEntities(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason +@@ -97,7 +97,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), EnumMobSpawn.STRUCTURE, (GroupDataEntity) null, (NBTTagCompound) null); +- generatoraccessseed.addFreshEntityWithPassengers(entitywitch); ++ generatoraccessseed.addFreshEntityWithPassengers(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason } } -@@ -121,7 +121,7 @@ - entitycat.setPersistent(); - entitycat.setPositionRotation((double) blockposition_mutableblockposition.getX() + 0.5D, (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + 0.5D, 0.0F, 0.0F); - entitycat.prepare(worldaccess, worldaccess.getDamageScaler(blockposition_mutableblockposition), EnumMobSpawn.STRUCTURE, (GroupDataEntity) null, (NBTTagCompound) null); -- worldaccess.addAllEntities(entitycat); -+ worldaccess.addAllEntities(entitycat, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason +@@ -116,7 +116,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), EnumMobSpawn.STRUCTURE, (GroupDataEntity) null, (NBTTagCompound) null); +- worldaccess.addFreshEntityWithPassengers(entitycat); ++ worldaccess.addFreshEntityWithPassengers(entitycat, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch index 1a76b79a57..7bd0fad4e4 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch @@ -1,42 +1,22 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java -@@ -64,8 +64,8 @@ - public static final String ENTITY_TAG_NBT = "nbt"; - public static final String SIZE_TAG = "size"; - static final int CHUNK_SIZE = 16; -- private final List<DefinedStructure.a> palettes = Lists.newArrayList(); -- private final List<DefinedStructure.EntityInfo> entityInfoList = Lists.newArrayList(); -+ public final List<DefinedStructure.a> palettes = Lists.newArrayList(); // PAIL private->public -+ public final List<DefinedStructure.EntityInfo> entityInfoList = Lists.newArrayList(); // PAIL private->public - private BaseBlockPosition size; - private String author; - -@@ -147,7 +147,7 @@ +@@ -142,7 +142,7 @@ } - private static List<DefinedStructure.BlockInfo> a(List<DefinedStructure.BlockInfo> list, List<DefinedStructure.BlockInfo> list1, List<DefinedStructure.BlockInfo> list2) { + private static List<DefinedStructure.BlockInfo> buildInfoList(List<DefinedStructure.BlockInfo> list, List<DefinedStructure.BlockInfo> list1, List<DefinedStructure.BlockInfo> list2) { - Comparator<DefinedStructure.BlockInfo> comparator = Comparator.comparingInt((definedstructure_blockinfo) -> { + Comparator<DefinedStructure.BlockInfo> comparator = Comparator.<DefinedStructure.BlockInfo>comparingInt((definedstructure_blockinfo) -> { // CraftBukkit - decompile error return definedstructure_blockinfo.pos.getY(); }).thenComparingInt((definedstructure_blockinfo) -> { return definedstructure_blockinfo.pos.getX(); -@@ -167,7 +167,7 @@ +@@ -463,11 +463,13 @@ } - private void a(World world, BlockPosition blockposition, BlockPosition blockposition1) { -- List<Entity> list = world.a(Entity.class, new AxisAlignedBB(blockposition, blockposition1), (entity) -> { -+ List<Entity> list = world.a(Entity.class, new AxisAlignedBB(blockposition, blockposition1), (java.util.function.Predicate) (entity) -> { // CraftBukkit - decompile error - return !(entity instanceof EntityHuman); - }); - -@@ -471,11 +471,13 @@ - } - - private static Optional<Entity> a(WorldAccess worldaccess, NBTTagCompound nbttagcompound) { + private static Optional<Entity> createEntityIgnoreException(WorldAccess worldaccess, NBTTagCompound nbttagcompound) { - try { + // CraftBukkit start + // try { - return EntityTypes.a(nbttagcompound, (World) worldaccess.getLevel()); + return EntityTypes.create(nbttagcompound, (World) worldaccess.getLevel()); - } catch (Exception exception) { - return Optional.empty(); - } @@ -46,10 +26,10 @@ + // CraftBukkit end } - public BaseBlockPosition a(EnumBlockRotation enumblockrotation) { -@@ -868,7 +870,7 @@ - public IBlockData a(int i) { - IBlockData iblockdata = (IBlockData) this.ids.fromId(i); + public BaseBlockPosition getSize(EnumBlockRotation enumblockrotation) { +@@ -860,7 +862,7 @@ + public IBlockData stateFor(int i) { + IBlockData iblockdata = (IBlockData) this.ids.byId(i); - return iblockdata == null ? DefinedStructure.b.DEFAULT_BLOCK_STATE : iblockdata; + return iblockdata == null ? DEFAULT_BLOCK_STATE : iblockdata; // CraftBukkit - decompile error diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.patch index ba774c0ea0..364d0c54d0 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.java -@@ -24,7 +24,7 @@ +@@ -22,7 +22,7 @@ + private boolean keepLiquids; @Nullable private Random random; - @Nullable - private int palette; + public int palette = -1; // CraftBukkit - Set initial value so we know if the palette has been set forcefully private final List<DefinedStructureProcessor> processors; private boolean knownShape; private boolean finalizeEntities; -@@ -151,6 +151,13 @@ +@@ -149,6 +149,13 @@ if (i == 0) { throw new IllegalStateException("No palettes"); @@ -21,5 +21,5 @@ + return list.get(this.palette); + // CraftBukkit end } else { - return (DefinedStructure.a) list.get(this.b(blockposition).nextInt(i)); + return (DefinedStructure.a) list.get(this.getRandom(blockposition).nextInt(i)); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureManager.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureManager.patch deleted file mode 100644 index 1d87b5496b..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureManager.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- a/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureManager.java -+++ b/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureManager.java -@@ -34,7 +34,7 @@ - private static final String STRUCTURE_DIRECTORY_NAME = "structures"; - private static final String STRUCTURE_FILE_EXTENSION = ".nbt"; - private static final String STRUCTURE_TEXT_FILE_EXTENSION = ".snbt"; -- private final Map<MinecraftKey, Optional<DefinedStructure>> structureRepository = Maps.newConcurrentMap(); -+ public final Map<MinecraftKey, Optional<DefinedStructure>> structureRepository = Maps.newConcurrentMap(); // PAIL private->public - private final DataFixer fixerUpper; - private IResourceManager resourceManager; - private final Path generatedDir; -@@ -71,7 +71,7 @@ - this.structureRepository.clear(); - } - -- private Optional<DefinedStructure> e(MinecraftKey minecraftkey) { -+ public Optional<DefinedStructure> e(MinecraftKey minecraftkey) { // PAIL private->public - MinecraftKey minecraftkey1 = new MinecraftKey(minecraftkey.getNamespace(), "structures/" + minecraftkey.getKey() + ".nbt"); - - try { -@@ -106,7 +106,7 @@ - } - } - -- private Optional<DefinedStructure> f(MinecraftKey minecraftkey) { -+ public Optional<DefinedStructure> f(MinecraftKey minecraftkey) { // PAIL private->public - if (!this.generatedDir.toFile().isDirectory()) { - return Optional.empty(); - } else { -@@ -140,7 +140,7 @@ - } - } - -- private DefinedStructure a(InputStream inputstream) throws IOException { -+ public DefinedStructure a(InputStream inputstream) throws IOException { //PAIL rename loadFromStream; private -> public - NBTTagCompound nbttagcompound = NBTCompressedStreamTools.a(inputstream); - - return this.a(nbttagcompound); -@@ -214,7 +214,7 @@ - } - } - -- private Path b(MinecraftKey minecraftkey, String s) { -+ public Path b(MinecraftKey minecraftkey, String s) { //PAIL private->public - if (minecraftkey.getKey().contains("//")) { - throw new ResourceKeyInvalidException("Invalid resource path: " + minecraftkey); - } else { diff --git a/paper-server/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch b/paper-server/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch index 5ebe336c3a..5ff4f33703 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch +++ b/paper-server/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 @@ +@@ -31,6 +31,15 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -16,10 +16,10 @@ public abstract class FluidTypeFlowing extends FluidType { public static final BlockStateBoolean FALLING = BlockProperties.FALLING; -@@ -132,6 +141,15 @@ - Fluid fluid1 = this.a((IWorldReader) generatoraccess, blockposition1, iblockdata1); +@@ -131,6 +140,15 @@ + Fluid fluid1 = this.getNewLiquid(generatoraccess, blockposition1, iblockdata1); - if (this.a(generatoraccess, blockposition, iblockdata, EnumDirection.DOWN, blockposition1, iblockdata1, generatoraccess.getFluid(blockposition1), fluid1.getType())) { + if (this.canSpreadTo(generatoraccess, blockposition, iblockdata, EnumDirection.DOWN, blockposition1, iblockdata1, generatoraccess.getFluidState(blockposition1), fluid1.getType())) { + // CraftBukkit start + org.bukkit.block.Block source = CraftBlock.at(generatoraccess, blockposition); + BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN); @@ -29,13 +29,13 @@ + return; + } + // CraftBukkit end - this.a(generatoraccess, blockposition1, iblockdata1, EnumDirection.DOWN, fluid1); - if (this.a((IWorldReader) generatoraccess, blockposition) >= 3) { - this.a(generatoraccess, blockposition, fluid, iblockdata); -@@ -162,6 +180,15 @@ - IBlockData iblockdata1 = generatoraccess.getType(blockposition1); + this.spreadTo(generatoraccess, blockposition1, iblockdata1, EnumDirection.DOWN, fluid1); + if (this.sourceNeighborCount(generatoraccess, blockposition) >= 3) { + this.spreadToSides(generatoraccess, blockposition, fluid, iblockdata); +@@ -161,6 +179,15 @@ + IBlockData iblockdata1 = generatoraccess.getBlockState(blockposition1); - if (this.a(generatoraccess, blockposition, iblockdata, enumdirection, blockposition1, iblockdata1, generatoraccess.getFluid(blockposition1), fluid1.getType())) { + if (this.canSpreadTo(generatoraccess, blockposition, iblockdata, enumdirection, blockposition1, iblockdata1, generatoraccess.getFluidState(blockposition1), fluid1.getType())) { + // CraftBukkit start + org.bukkit.block.Block source = CraftBlock.at(generatoraccess, blockposition); + BlockFromToEvent event = new BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection)); @@ -45,33 +45,33 @@ + continue; + } + // CraftBukkit end - this.a(generatoraccess, blockposition1, iblockdata1, enumdirection, fluid1); + this.spreadTo(generatoraccess, blockposition1, iblockdata1, enumdirection, fluid1); } } -@@ -440,12 +467,23 @@ +@@ -439,12 +466,23 @@ if (fluid1.isEmpty()) { fluid = fluid1; -- world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3); +- world.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 3); + // CraftBukkit start -+ FluidLevelChangeEvent event = CraftEventFactory.callFluidLevelChangeEvent(world, blockposition, Blocks.AIR.getBlockData()); ++ FluidLevelChangeEvent event = CraftEventFactory.callFluidLevelChangeEvent(world, blockposition, Blocks.AIR.defaultBlockState()); + if (event.isCancelled()) { + return; + } -+ world.setTypeAndData(blockposition, ((CraftBlockData) event.getNewData()).getState(), 3); ++ world.setBlock(blockposition, ((CraftBlockData) event.getNewData()).getState(), 3); + // CraftBukkit end } else if (!fluid1.equals(fluid)) { fluid = fluid1; - IBlockData iblockdata = fluid1.getBlockData(); + IBlockData iblockdata = fluid1.createLegacyBlock(); - -- world.setTypeAndData(blockposition, iblockdata, 2); +- world.setBlock(blockposition, iblockdata, 2); + // CraftBukkit start + FluidLevelChangeEvent event = CraftEventFactory.callFluidLevelChangeEvent(world, blockposition, iblockdata); + if (event.isCancelled()) { + return; + } -+ world.setTypeAndData(blockposition, ((CraftBlockData) event.getNewData()).getState(), 2); ++ world.setBlock(blockposition, ((CraftBlockData) event.getNewData()).getState(), 2); + // CraftBukkit end - world.getFluidTickList().a(blockposition, fluid1.getType(), i); - world.applyPhysics(blockposition, iblockdata.getBlock()); + world.scheduleTick(blockposition, fluid1.getType(), i); + world.updateNeighborsAt(blockposition, iblockdata.getBlock()); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch b/paper-server/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch index 3137b7f216..9fd0b9b13c 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch @@ -3,42 +3,42 @@ @@ -85,6 +85,13 @@ if (iblockdata.isAir()) { - if (this.a((IWorldReader) world, blockposition1)) { + if (this.hasFlammableNeighbours(world, blockposition1)) { + // CraftBukkit start - Prevent lava putting something on fire -+ if (world.getType(blockposition1).getBlock() != Blocks.FIRE) { ++ if (world.getBlockState(blockposition1).getBlock() != Blocks.FIRE) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition1, blockposition).isCancelled()) { + continue; + } + } + // CraftBukkit end - world.setTypeUpdate(blockposition1, BlockFireAbstract.a((IBlockAccess) world, blockposition1)); + world.setBlockAndUpdate(blockposition1, BlockFireAbstract.getState(world, blockposition1)); return; } @@ -101,6 +108,14 @@ } - if (world.isEmpty(blockposition2.up()) && this.b(world, blockposition2)) { + if (world.isEmptyBlock(blockposition2.above()) && this.isFlammable(world, blockposition2)) { + // CraftBukkit start - Prevent lava putting something on fire -+ BlockPosition up = blockposition2.up(); -+ if (world.getType(up).getBlock() != Blocks.FIRE) { ++ BlockPosition up = blockposition2.above(); ++ if (world.getBlockState(up).getBlock() != Blocks.FIRE) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, up, blockposition).isCancelled()) { + continue; + } + } + // CraftBukkit end - world.setTypeUpdate(blockposition2.up(), BlockFireAbstract.a((IBlockAccess) world, blockposition2)); + world.setBlockAndUpdate(blockposition2.above(), BlockFireAbstract.getState(world, blockposition2)); } } @@ -196,7 +211,11 @@ - if (this.a((Tag) TagsFluid.LAVA) && fluid1.a((Tag) TagsFluid.WATER)) { + if (this.is(TagsFluid.LAVA) && fluid1.is((Tag) TagsFluid.WATER)) { if (iblockdata.getBlock() instanceof BlockFluids) { -- generatoraccess.setTypeAndData(blockposition, Blocks.STONE.getBlockData(), 3); +- generatoraccess.setBlock(blockposition, Blocks.STONE.defaultBlockState(), 3); + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(generatoraccess.getMinecraftWorld(), blockposition, Blocks.STONE.getBlockData(), 3)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(generatoraccess.getMinecraftWorld(), blockposition, Blocks.STONE.defaultBlockState(), 3)) { + return; + } + // CraftBukkit end } - this.a(generatoraccess, blockposition); + this.fizz(generatoraccess, blockposition); diff --git a/paper-server/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch b/paper-server/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch index caa611ce4d..c9c196742e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch @@ -18,8 +18,8 @@ private final int width; + org.bukkit.craftbukkit.util.BlockStateListPopulator blocks; // CraftBukkit - add field - public static Optional<BlockPortalShape> a(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { - return a(generatoraccess, blockposition, (blockportalshape) -> { + public static Optional<BlockPortalShape> findEmptyPortalShape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { + return findPortalShape(generatoraccess, blockposition, (blockportalshape) -> { @@ -56,6 +62,7 @@ } @@ -30,9 +30,9 @@ this.rightDir = enumdirection_enumaxis == EnumDirection.EnumAxis.X ? EnumDirection.WEST : EnumDirection.SOUTH; @@ -100,6 +107,7 @@ - if (!a(iblockdata)) { + if (!isEmpty(iblockdata)) { if (BlockPortalShape.FRAME.test(iblockdata, this.level, blockposition_mutableblockposition)) { -+ blocks.setTypeAndData(blockposition_mutableblockposition, iblockdata, 18); // CraftBukkit - lower left / right ++ blocks.setBlock(blockposition_mutableblockposition, iblockdata, 18); // CraftBukkit - lower left / right return i; } break; @@ -40,15 +40,15 @@ if (!BlockPortalShape.FRAME.test(iblockdata1, this.level, blockposition_mutableblockposition)) { break; } -+ blocks.setTypeAndData(blockposition_mutableblockposition, iblockdata1, 18); // CraftBukkit - bottom row ++ blocks.setBlock(blockposition_mutableblockposition, iblockdata1, 18); // CraftBukkit - bottom row } return 0; @@ -129,6 +138,7 @@ - if (!BlockPortalShape.FRAME.test(this.level.getType(blockposition_mutableblockposition1), this.level, blockposition_mutableblockposition1)) { + if (!BlockPortalShape.FRAME.test(this.level.getBlockState(blockposition_mutableblockposition1), this.level, blockposition_mutableblockposition1)) { return false; } -+ blocks.setTypeAndData(blockposition_mutableblockposition1, this.level.getType(blockposition_mutableblockposition1), 18); // CraftBukkit - upper row ++ blocks.setBlock(blockposition_mutableblockposition1, this.level.getBlockState(blockposition_mutableblockposition1), 18); // CraftBukkit - upper row } return true; @@ -57,8 +57,8 @@ } } + // CraftBukkit start - left and right -+ blocks.setTypeAndData(blockposition_mutableblockposition.g(this.bottomLeft).c(EnumDirection.UP, i).c(this.rightDir, -1), this.level.getType(blockposition_mutableblockposition), 18); -+ blocks.setTypeAndData(blockposition_mutableblockposition.g(this.bottomLeft).c(EnumDirection.UP, i).c(this.rightDir, this.width), this.level.getType(blockposition_mutableblockposition), 18); ++ blocks.setBlock(blockposition_mutableblockposition.set(this.bottomLeft).move(EnumDirection.UP, i).move(this.rightDir, -1), this.level.getBlockState(blockposition_mutableblockposition), 18); ++ blocks.setBlock(blockposition_mutableblockposition.set(this.bottomLeft).move(EnumDirection.UP, i).move(this.rightDir, this.width), this.level.getBlockState(blockposition_mutableblockposition), 18); + // CraftBukkit end } @@ -67,41 +67,41 @@ return this.bottomLeft != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; } -- public void createPortal() { +- public void createPortalBlocks() { + // CraftBukkit start - return boolean -+ public boolean createPortal() { ++ public boolean createPortalBlocks() { + org.bukkit.World bworld = this.level.getMinecraftWorld().getWorld(); + + // Copy below for loop - IBlockData iblockdata = (IBlockData) Blocks.NETHER_PORTAL.getBlockData().set(BlockPortal.AXIS, this.axis); + IBlockData iblockdata = (IBlockData) Blocks.NETHER_PORTAL.defaultBlockState().setValue(BlockPortal.AXIS, this.axis); - BlockPosition.a(this.bottomLeft, this.bottomLeft.shift(EnumDirection.UP, this.height - 1).shift(this.rightDir, this.width - 1)).forEach((blockposition) -> { -+ blocks.setTypeAndData(blockposition, iblockdata, 18); + BlockPosition.betweenClosed(this.bottomLeft, this.bottomLeft.relative(EnumDirection.UP, this.height - 1).relative(this.rightDir, this.width - 1)).forEach((blockposition) -> { ++ blocks.setBlock(blockposition, iblockdata, 18); + }); + + PortalCreateEvent event = new PortalCreateEvent((java.util.List<org.bukkit.block.BlockState>) (java.util.List) blocks.getList(), bworld, null, PortalCreateEvent.CreateReason.FIRE); -+ this.level.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event); ++ this.level.getMinecraftWorld().getServer().server.getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return false; + } + // CraftBukkit end -+ BlockPosition.a(this.bottomLeft, this.bottomLeft.shift(EnumDirection.UP, this.height - 1).shift(this.rightDir, this.width - 1)).forEach((blockposition) -> { - this.level.setTypeAndData(blockposition, iblockdata, 18); ++ BlockPosition.betweenClosed(this.bottomLeft, this.bottomLeft.relative(EnumDirection.UP, this.height - 1).relative(this.rightDir, this.width - 1)).forEach((blockposition) -> { + this.level.setBlock(blockposition, iblockdata, 18); }); + return true; // CraftBukkit } - public boolean c() { + public boolean isComplete() { @@ -213,7 +243,7 @@ return new Vec3D(d2, d3, d4); } -- public static ShapeDetectorShape a(WorldServer worldserver, BlockUtil.Rectangle blockutil_rectangle, EnumDirection.EnumAxis enumdirection_enumaxis, Vec3D vec3d, EntitySize entitysize, Vec3D vec3d1, float f, float f1) { -+ public static ShapeDetectorShape a(WorldServer worldserver, BlockUtil.Rectangle blockutil_rectangle, EnumDirection.EnumAxis enumdirection_enumaxis, Vec3D vec3d, EntitySize entitysize, Vec3D vec3d1, float f, float f1, CraftPortalEvent portalEventInfo) { // CraftBukkit // PAIL rename toDetectorShape +- public static ShapeDetectorShape createPortalInfo(WorldServer worldserver, BlockUtil.Rectangle blockutil_rectangle, EnumDirection.EnumAxis enumdirection_enumaxis, Vec3D vec3d, EntitySize entitysize, Vec3D vec3d1, float f, float f1) { ++ public static ShapeDetectorShape createPortalInfo(WorldServer worldserver, BlockUtil.Rectangle blockutil_rectangle, EnumDirection.EnumAxis enumdirection_enumaxis, Vec3D vec3d, EntitySize entitysize, Vec3D vec3d1, float f, float f1, CraftPortalEvent portalEventInfo) { // CraftBukkit BlockPosition blockposition = blockutil_rectangle.minCorner; - IBlockData iblockdata = worldserver.getType(blockposition); - EnumDirection.EnumAxis enumdirection_enumaxis1 = (EnumDirection.EnumAxis) iblockdata.d(BlockProperties.HORIZONTAL_AXIS).orElse(EnumDirection.EnumAxis.X); + IBlockData iblockdata = worldserver.getBlockState(blockposition); + EnumDirection.EnumAxis enumdirection_enumaxis1 = (EnumDirection.EnumAxis) iblockdata.getOptionalValue(BlockProperties.HORIZONTAL_AXIS).orElse(EnumDirection.EnumAxis.X); @@ -227,6 +257,6 @@ boolean flag = enumdirection_enumaxis1 == EnumDirection.EnumAxis.X; Vec3D vec3d3 = new Vec3D((double) blockposition.getX() + (flag ? d2 : d4), (double) blockposition.getY() + d3, (double) blockposition.getZ() + (flag ? d4 : d2)); diff --git a/paper-server/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch b/paper-server/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch index 3b2914fd55..728ea242f7 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch @@ -1,28 +1,30 @@ --- a/net/minecraft/world/level/portal/PortalTravelAgent.java +++ b/net/minecraft/world/level/portal/PortalTravelAgent.java -@@ -43,13 +43,19 @@ +@@ -42,15 +42,21 @@ } - public Optional<BlockUtil.Rectangle> findPortal(BlockPosition blockposition, boolean flag) { + public Optional<BlockUtil.Rectangle> findPortalAround(BlockPosition blockposition, boolean flag, WorldBorder worldborder) { + // CraftBukkit start -+ return findPortal(blockposition, flag ? 16 : 128); // Search Radius ++ return findPortalAround(blockposition, worldborder, flag ? 16 : 128); // Search Radius + } + -+ public Optional<BlockUtil.Rectangle> findPortal(BlockPosition blockposition, int i) { - VillagePlace villageplace = this.level.A(); ++ public Optional<BlockUtil.Rectangle> findPortalAround(BlockPosition blockposition, WorldBorder worldborder, int i) { + VillagePlace villageplace = this.level.getPoiManager(); - int i = flag ? 16 : 128; + // int i = flag ? 16 : 128; + // CraftBukkit end - villageplace.a(this.level, blockposition, i); - Optional<VillagePlaceRecord> optional = villageplace.b((villageplacetype) -> { + villageplace.ensureLoadedAndValid(this.level, blockposition, i); + Optional<VillagePlaceRecord> optional = villageplace.getInSquare((villageplacetype) -> { return villageplacetype == VillagePlaceType.NETHER_PORTAL; -- }, blockposition, i, VillagePlace.Occupancy.ANY).sorted(Comparator.comparingDouble((villageplacerecord) -> { -+ }, blockposition, i, VillagePlace.Occupancy.ANY).sorted(Comparator.comparingDouble((VillagePlaceRecord villageplacerecord) -> { // CraftBukkit - decompile error - return villageplacerecord.f().j(blockposition); + }, blockposition, i, VillagePlace.Occupancy.ANY).filter((villageplacerecord) -> { + return worldborder.isWithinBounds(villageplacerecord.getPos()); +- }).sorted(Comparator.comparingDouble((villageplacerecord) -> { ++ }).sorted(Comparator.comparingDouble((VillagePlaceRecord villageplacerecord) -> { // CraftBukkit - decompile error + return villageplacerecord.getPos().distSqr(blockposition); }).thenComparingInt((villageplacerecord) -> { - return villageplacerecord.f().getY(); -@@ -70,6 +76,12 @@ + return villageplacerecord.getPos().getY(); +@@ -71,6 +77,12 @@ } public Optional<BlockUtil.Rectangle> createPortal(BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { @@ -32,19 +34,19 @@ + + public Optional<BlockUtil.Rectangle> createPortal(BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis, net.minecraft.world.entity.Entity entity, int createRadius) { + // CraftBukkit end - EnumDirection enumdirection = EnumDirection.a(EnumDirection.EnumAxisDirection.POSITIVE, enumdirection_enumaxis); + EnumDirection enumdirection = EnumDirection.get(EnumDirection.EnumAxisDirection.POSITIVE, enumdirection_enumaxis); double d0 = -1.0D; BlockPosition blockposition1 = null; -@@ -78,7 +90,7 @@ +@@ -79,7 +91,7 @@ WorldBorder worldborder = this.level.getWorldBorder(); int i = Math.min(this.level.getMaxBuildHeight(), this.level.getMinBuildHeight() + this.level.getLogicalHeight()) - 1; - BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.i(); -- Iterator iterator = BlockPosition.a(blockposition, 16, EnumDirection.EAST, EnumDirection.SOUTH).iterator(); -+ Iterator iterator = BlockPosition.a(blockposition, createRadius, EnumDirection.EAST, EnumDirection.SOUTH).iterator(); // CraftBukkit + 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; -@@ -133,6 +145,7 @@ +@@ -134,6 +146,7 @@ int j1; int k1; @@ -52,30 +54,30 @@ if (d0 == -1.0D) { j1 = Math.max(this.level.getMinBuildHeight() - -1, 70); k1 = i - 9; -@@ -153,7 +166,7 @@ - IBlockData iblockdata = l < 0 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData(); +@@ -154,7 +167,7 @@ + IBlockData iblockdata = l < 0 ? Blocks.OBSIDIAN.defaultBlockState() : Blocks.AIR.defaultBlockState(); - blockposition_mutableblockposition.a((BaseBlockPosition) blockposition1, k * enumdirection.getAdjacentX() + l1 * enumdirection1.getAdjacentX(), l, k * enumdirection.getAdjacentZ() + l1 * enumdirection1.getAdjacentZ()); -- this.level.setTypeUpdate(blockposition_mutableblockposition, iblockdata); -+ blockList.setTypeAndData(blockposition_mutableblockposition, iblockdata, 3); // CraftBukkit + blockposition_mutableblockposition.setWithOffset(blockposition1, k * enumdirection.getStepX() + l1 * enumdirection1.getStepX(), l, k * enumdirection.getStepZ() + l1 * enumdirection1.getStepZ()); +- this.level.setBlockAndUpdate(blockposition_mutableblockposition, iblockdata); ++ blockList.setBlock(blockposition_mutableblockposition, iblockdata, 3); // CraftBukkit } } } -@@ -163,7 +176,7 @@ +@@ -164,7 +177,7 @@ for (k1 = -1; k1 < 4; ++k1) { if (j1 == -1 || j1 == 2 || k1 == -1 || k1 == 3) { - blockposition_mutableblockposition.a((BaseBlockPosition) blockposition1, j1 * enumdirection.getAdjacentX(), k1, j1 * enumdirection.getAdjacentZ()); -- this.level.setTypeAndData(blockposition_mutableblockposition, Blocks.OBSIDIAN.getBlockData(), 3); -+ blockList.setTypeAndData(blockposition_mutableblockposition, Blocks.OBSIDIAN.getBlockData(), 3); // CraftBukkit + blockposition_mutableblockposition.setWithOffset(blockposition1, j1 * enumdirection.getStepX(), k1, j1 * enumdirection.getStepZ()); +- this.level.setBlock(blockposition_mutableblockposition, Blocks.OBSIDIAN.defaultBlockState(), 3); ++ blockList.setBlock(blockposition_mutableblockposition, Blocks.OBSIDIAN.defaultBlockState(), 3); // CraftBukkit } } } -@@ -173,10 +186,20 @@ +@@ -174,10 +187,20 @@ for (k1 = 0; k1 < 2; ++k1) { for (j = 0; j < 3; ++j) { - blockposition_mutableblockposition.a((BaseBlockPosition) blockposition1, k1 * enumdirection.getAdjacentX(), j, k1 * enumdirection.getAdjacentZ()); -- this.level.setTypeAndData(blockposition_mutableblockposition, iblockdata1, 18); -+ blockList.setTypeAndData(blockposition_mutableblockposition, iblockdata1, 18); // CraftBukkit + blockposition_mutableblockposition.setWithOffset(blockposition1, k1 * enumdirection.getStepX(), j, k1 * enumdirection.getStepZ()); +- this.level.setBlock(blockposition_mutableblockposition, iblockdata1, 18); ++ blockList.setBlock(blockposition_mutableblockposition, iblockdata1, 18); // CraftBukkit } } @@ -89,6 +91,6 @@ + } + blockList.updateList(); + // CraftBukkit end - return Optional.of(new BlockUtil.Rectangle(blockposition1.immutableCopy(), 2, 3)); + return Optional.of(new BlockUtil.Rectangle(blockposition1.immutable(), 2, 3)); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch b/paper-server/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch index 1d7afff603..278510d586 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/saveddata/maps/WorldMap.java +++ b/net/minecraft/world/level/saveddata/maps/WorldMap.java -@@ -32,6 +32,16 @@ +@@ -31,6 +31,16 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start +import java.util.UUID; -+ ++import net.minecraft.nbt.NBTBase; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; @@ -17,7 +17,7 @@ public class WorldMap extends PersistentBase { private static final Logger LOGGER = LogManager.getLogger(); -@@ -54,6 +64,13 @@ +@@ -53,6 +63,13 @@ private final Map<String, WorldMapFrame> frameMarkers = Maps.newHashMap(); private int trackedDecorationCount; @@ -31,18 +31,18 @@ private WorldMap(int i, int j, byte b0, boolean flag, boolean flag1, boolean flag2, ResourceKey<World> resourcekey) { this.scale = b0; this.x = i; -@@ -63,6 +80,10 @@ +@@ -62,6 +79,10 @@ this.unlimitedTracking = flag1; this.locked = flag2; - this.b(); + this.setDirty(); + // CraftBukkit start + mapView = new CraftMapView(this); + server = (CraftServer) org.bukkit.Bukkit.getServer(); + // CraftBukkit end } - public static WorldMap a(double d0, double d1, byte b0, boolean flag, boolean flag1, ResourceKey<World> resourcekey) { -@@ -84,8 +105,26 @@ + public static WorldMap createFresh(double d0, double d1, byte b0, boolean flag, boolean flag1, ResourceKey<World> resourcekey) { +@@ -83,8 +104,26 @@ Logger logger = WorldMap.LOGGER; Objects.requireNonNull(logger); @@ -63,7 +63,7 @@ + This is to prevent them being corrupted with the wrong map data. */ + // PAIL: Use Vanilla exception handling for now + } else { -+ return world.getHandle().getDimensionKey(); ++ return world.getHandle().dimension(); + } + } + throw new IllegalArgumentException("Invalid map dimension: " + nbttagcompound.get("dimension")); @@ -71,24 +71,24 @@ }); int i = nbttagcompound.getInt("xCenter"); int j = nbttagcompound.getInt("zCenter"); -@@ -123,13 +162,32 @@ +@@ -122,13 +161,32 @@ @Override - public NBTTagCompound a(NBTTagCompound nbttagcompound) { -- DataResult dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.dimension.a()); -+ DataResult<NBTBase> dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.dimension.a()); // CraftBukkit - decompile error + public NBTTagCompound save(NBTTagCompound nbttagcompound) { +- DataResult dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.dimension.location()); ++ DataResult<NBTBase> 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.set("dimension", 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().getDimensionKey() == this.dimension) { ++ if (cWorld.getHandle().dimension() == this.dimension) { + this.uniqueId = cWorld.getUID(); + break; + } @@ -97,24 +97,24 @@ + /* 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.setLong("UUIDLeast", this.uniqueId.getLeastSignificantBits()); -+ nbttagcompound.setLong("UUIDMost", this.uniqueId.getMostSignificantBits()); ++ nbttagcompound.putLong("UUIDLeast", this.uniqueId.getLeastSignificantBits()); ++ nbttagcompound.putLong("UUIDMost", this.uniqueId.getMostSignificantBits()); + } + } + // CraftBukkit end - nbttagcompound.setInt("xCenter", this.x); - nbttagcompound.setInt("zCenter", this.z); - nbttagcompound.setByte("scale", this.scale); -@@ -504,7 +562,7 @@ + nbttagcompound.putInt("xCenter", this.x); + nbttagcompound.putInt("zCenter", this.z); + nbttagcompound.putByte("scale", this.scale); +@@ -503,7 +561,7 @@ this.player = entityhuman; } -- private WorldMap.b a() { -+ private WorldMap.b a(byte[] buffer) { // CraftBukkit +- private WorldMap.b createPatch() { ++ private WorldMap.b createPatch(byte[] buffer) { // CraftBukkit int i = this.minDirtyX; int j = this.minDirtyY; int k = this.maxDirtyX + 1 - this.minDirtyX; -@@ -513,7 +571,7 @@ +@@ -512,7 +570,7 @@ for (int i1 = 0; i1 < k; ++i1) { for (int j1 = 0; j1 < l; ++j1) { @@ -123,16 +123,16 @@ } } -@@ -523,19 +581,29 @@ +@@ -522,19 +580,29 @@ @Nullable - Packet<?> a(int i) { + Packet<?> nextUpdatePacket(int i) { WorldMap.b worldmap_b; + org.bukkit.craftbukkit.map.RenderData render = WorldMap.this.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) this.player.getBukkitEntity()); // CraftBukkit if (this.dirtyData) { this.dirtyData = false; -- worldmap_b = this.a(); -+ worldmap_b = this.a(render.buffer); // CraftBukkit +- worldmap_b = this.createPatch(); ++ worldmap_b = this.createPatch(render.buffer); // CraftBukkit } else { worldmap_b = null; } @@ -148,7 +148,7 @@ + + for (org.bukkit.map.MapCursor cursor : render.cursors) { + if (cursor.isVisible()) { -+ icons.add(new MapIcon(MapIcon.Type.a(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), CraftChatMessage.fromStringOrNull(cursor.getCaption()))); ++ icons.add(new MapIcon(MapIcon.Type.byIcon(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), CraftChatMessage.fromStringOrNull(cursor.getCaption()))); + } + } + collection = icons; diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/Convertable.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/Convertable.patch index ce0584df92..ab6b63169f 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/Convertable.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/Convertable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/Convertable.java +++ b/net/minecraft/world/level/storage/Convertable.java -@@ -61,6 +61,10 @@ +@@ -56,6 +56,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -11,64 +11,33 @@ public class Convertable { static final Logger LOGGER = LogManager.getLogger(); -@@ -106,26 +110,26 @@ - Logger logger = Convertable.LOGGER; - - Objects.requireNonNull(logger); -- return Pair.of((GeneratorSettings) dataresult.resultOrPartial(SystemUtils.a("WorldGenSettings: ", logger::error)).orElseGet(() -> { -+ return Pair.of(dataresult.resultOrPartial(SystemUtils.a("WorldGenSettings: ", (java.util.function.Consumer<String>) logger::error)).orElseGet(() -> { // CraftBukkit - decompile error - DataResult dataresult1 = RegistryLookupCodec.a(IRegistry.DIMENSION_TYPE_REGISTRY).codec().parse(dynamic2); - Logger logger1 = Convertable.LOGGER; - - Objects.requireNonNull(logger1); -- IRegistry<DimensionManager> iregistry = (IRegistry) dataresult1.resultOrPartial(SystemUtils.a("Dimension type registry: ", logger1::error)).orElseThrow(() -> { -+ IRegistry<DimensionManager> iregistry = (IRegistry) ((DataResult<IRegistry<DimensionManager>>) dataresult1).resultOrPartial(SystemUtils.a("Dimension type registry: ", (java.util.function.Consumer<String>) logger1::error)).orElseThrow(() -> { // CraftBukkit - decompile error - return new IllegalStateException("Failed to get dimension registry"); - }); - - dataresult1 = RegistryLookupCodec.a(IRegistry.BIOME_REGISTRY).codec().parse(dynamic2); - logger1 = Convertable.LOGGER; - Objects.requireNonNull(logger1); -- IRegistry<BiomeBase> iregistry1 = (IRegistry) dataresult1.resultOrPartial(SystemUtils.a("Biome registry: ", logger1::error)).orElseThrow(() -> { -+ IRegistry<BiomeBase> iregistry1 = (IRegistry) ((DataResult<IRegistry<BiomeBase>>) dataresult1).resultOrPartial(SystemUtils.a("Biome registry: ", (java.util.function.Consumer<String>) logger1::error)).orElseThrow(() -> { // CraftBukkit - decompile error - return new IllegalStateException("Failed to get biome registry"); - }); - - dataresult1 = RegistryLookupCodec.a(IRegistry.NOISE_GENERATOR_SETTINGS_REGISTRY).codec().parse(dynamic2); - logger1 = Convertable.LOGGER; - Objects.requireNonNull(logger1); -- IRegistry<GeneratorSettingBase> iregistry2 = (IRegistry) dataresult1.resultOrPartial(SystemUtils.a("Noise settings registry: ", logger1::error)).orElseThrow(() -> { -+ IRegistry<GeneratorSettingBase> iregistry2 = (IRegistry) ((DataResult<IRegistry<GeneratorSettingBase>>) dataresult1).resultOrPartial(SystemUtils.a("Noise settings registry: ", (java.util.function.Consumer<String>) logger1::error)).orElseThrow(() -> { // CraftBukkit - decompile error - return new IllegalStateException("Failed to get noise settings registry"); - }); - -@@ -302,9 +306,23 @@ +@@ -277,9 +281,23 @@ return this.backupDir; } -- public Convertable.ConversionSession c(String s) throws IOException { +- public Convertable.ConversionSession createAccess(String s) throws IOException { - return new Convertable.ConversionSession(s); + // CraftBukkit start -+ public Convertable.ConversionSession c(String s, ResourceKey<WorldDimension> dimensionType) throws IOException { ++ public Convertable.ConversionSession createAccess(String s, ResourceKey<WorldDimension> dimensionType) throws IOException { + return new Convertable.ConversionSession(s, dimensionType); + } + -+ public static File getFolder(File file, ResourceKey<WorldDimension> dimensionType) { ++ public static Path getStorageFolder(Path path, ResourceKey<WorldDimension> dimensionType) { + if (dimensionType == WorldDimension.OVERWORLD) { -+ return file; ++ return path; + } else if (dimensionType == WorldDimension.NETHER) { -+ return new File(file, "DIM-1"); ++ return path.resolve("DIM-1"); + } else if (dimensionType == WorldDimension.END) { -+ return new File(file, "DIM1"); ++ return path.resolve("DIM1"); + } else { -+ return new File(file, "dimensions/" + dimensionType.a().getNamespace() + "/" + dimensionType.a().getKey()); ++ return path.resolve("dimensions").resolve(dimensionType.location().getNamespace()).resolve(dimensionType.location().getPath()); + } } + // CraftBukkit end public class ConversionSession implements AutoCloseable { -@@ -312,8 +330,12 @@ +@@ -287,8 +305,12 @@ public final Path levelPath; private final String levelId; private final Map<SavedFile, Path> resources = Maps.newHashMap(); @@ -81,13 +50,13 @@ + // CraftBukkit end this.levelId = s; this.levelPath = Convertable.this.baseDir.resolve(s); - this.lock = SessionLock.a(this.levelPath); -@@ -330,7 +352,7 @@ + this.lock = SessionLock.create(this.levelPath); +@@ -305,7 +327,7 @@ } - public File a(ResourceKey<World> resourcekey) { -- return DimensionManager.a(resourcekey, this.levelPath.toFile()); -+ return getFolder(this.levelPath.toFile(), this.dimensionType); // CraftBukkit + public Path getDimensionPath(ResourceKey<World> resourcekey) { +- return DimensionManager.getStorageFolder(resourcekey, this.levelPath); ++ return getStorageFolder(this.levelPath, this.dimensionType); // CraftBukkit } - private void checkSession() { + private void checkLock() { diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch index 6831697340..3b4e8f1b4c 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch @@ -28,44 +28,39 @@ return (NBTBase) dynamic.get("DimensionData").get("1").get("DragonFight").orElseEmptyMap().getValue(); }); -- return new WorldDataServer(datafixer, i, nbttagcompound, dynamic.get("WasModded").asBoolean(false), dynamic.get("SpawnX").asInt(0), dynamic.get("SpawnY").asInt(0), dynamic.get("SpawnZ").asInt(0), dynamic.get("SpawnAngle").asFloat(0.0F), j, dynamic.get("DayTime").asLong(j), levelversion.a(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.a(dynamic, WorldBorder.DEFAULT_SETTINGS), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(MinecraftSerializableUUID.CODEC).result().orElse((Object) null), (Set) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> { +- return new WorldDataServer(datafixer, i, nbttagcompound, dynamic.get("WasModded").asBoolean(false), dynamic.get("SpawnX").asInt(0), dynamic.get("SpawnY").asInt(0), dynamic.get("SpawnZ").asInt(0), dynamic.get("SpawnAngle").asFloat(0.0F), j, dynamic.get("DayTime").asLong(j), levelversion.levelDataVersion(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.read(dynamic, WorldBorder.DEFAULT_SETTINGS), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(MinecraftSerializableUUID.CODEC).result().orElse((Object) null), (Set) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> { + // CraftBukkit - decompile error -+ return new WorldDataServer(datafixer, i, nbttagcompound, dynamic.get("WasModded").asBoolean(false), dynamic.get("SpawnX").asInt(0), dynamic.get("SpawnY").asInt(0), dynamic.get("SpawnZ").asInt(0), dynamic.get("SpawnAngle").asFloat(0.0F), j, dynamic.get("DayTime").asLong(j), levelversion.a(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.a(dynamic, WorldBorder.DEFAULT_SETTINGS), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(MinecraftSerializableUUID.CODEC).result().orElse(null), (Set) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> { - return SystemUtils.a(dynamic1.asString().result()); ++ return new WorldDataServer(datafixer, i, nbttagcompound, dynamic.get("WasModded").asBoolean(false), dynamic.get("SpawnX").asInt(0), dynamic.get("SpawnY").asInt(0), dynamic.get("SpawnZ").asInt(0), dynamic.get("SpawnAngle").asFloat(0.0F), j, dynamic.get("DayTime").asLong(j), levelversion.levelDataVersion(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.read(dynamic, WorldBorder.DEFAULT_SETTINGS), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(MinecraftSerializableUUID.CODEC).result().orElse(null), (Set) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> { + return SystemUtils.toStream(dynamic1.asString().result()); }).collect(Collectors.toCollection(Sets::newLinkedHashSet)), new CustomFunctionCallbackTimerQueue<>(CustomFunctionCallbackTimers.SERVER_CALLBACKS, dynamic.get("ScheduledEvents").asStream()), (NBTTagCompound) dynamic.get("CustomBossEvents").orElseEmptyMap().getValue(), nbttagcompound1, worldsettings, generatorsettings, lifecycle); } @@ -141,7 +152,7 @@ - private void a(IRegistryCustom iregistrycustom, NBTTagCompound nbttagcompound, @Nullable NBTTagCompound nbttagcompound1) { + private void setTagData(IRegistryCustom iregistrycustom, NBTTagCompound nbttagcompound, @Nullable NBTTagCompound nbttagcompound1) { NBTTagList nbttaglist = new NBTTagList(); -- Stream stream = this.knownServerBrands.stream().map(NBTTagString::a); -+ Stream<NBTTagString> stream = this.knownServerBrands.stream().map(NBTTagString::a); // CraftBukkit - decompile error +- Stream stream = this.knownServerBrands.stream().map(NBTTagString::valueOf); ++ Stream<NBTTagString> stream = this.knownServerBrands.stream().map(NBTTagString::valueOf); // CraftBukkit - decompile error Objects.requireNonNull(nbttaglist); stream.forEach(nbttaglist::add); -@@ -155,11 +166,11 @@ - nbttagcompound.set("Version", nbttagcompound2); - nbttagcompound.setInt("DataVersion", SharedConstants.getGameVersion().getWorldVersion()); - RegistryWriteOps<NBTBase> registrywriteops = RegistryWriteOps.a(DynamicOpsNBT.INSTANCE, iregistrycustom); +@@ -156,7 +167,7 @@ + nbttagcompound.put("Version", nbttagcompound2); + nbttagcompound.putInt("DataVersion", SharedConstants.getCurrentVersion().getWorldVersion()); + RegistryWriteOps<NBTBase> registrywriteops = RegistryWriteOps.create(DynamicOpsNBT.INSTANCE, iregistrycustom); - DataResult dataresult = GeneratorSettings.CODEC.encodeStart(registrywriteops, this.worldGenSettings); + DataResult<NBTBase> dataresult = GeneratorSettings.CODEC.encodeStart(registrywriteops, this.worldGenSettings); // CraftBukkit - decompile error Logger logger = WorldDataServer.LOGGER; Objects.requireNonNull(logger); -- dataresult.resultOrPartial(SystemUtils.a("WorldGenSettings: ", logger::error)).ifPresent((nbtbase) -> { -+ dataresult.resultOrPartial(SystemUtils.a("WorldGenSettings: ", (java.util.function.Consumer<String>) logger::error)).ifPresent((nbtbase) -> { // CraftBukkit - decompile error - nbttagcompound.set("WorldGenSettings", nbtbase); - }); - nbttagcompound.setInt("GameType", this.settings.getGameType().getId()); -@@ -203,6 +214,7 @@ - nbttagcompound.a("WanderingTraderId", this.wanderingTraderId); +@@ -204,6 +215,7 @@ + nbttagcompound.putUUID("WanderingTraderId", this.wanderingTraderId); } -+ nbttagcompound.setString("Bukkit.Version", Bukkit.getName() + "/" + Bukkit.getVersion() + "/" + Bukkit.getBukkitVersion()); // CraftBukkit ++ nbttagcompound.putString("Bukkit.Version", Bukkit.getName() + "/" + Bukkit.getVersion() + "/" + Bukkit.getBukkitVersion()); // CraftBukkit } @Override -@@ -320,6 +332,20 @@ +@@ -321,6 +333,20 @@ @Override public void setThundering(boolean flag) { @@ -74,7 +69,7 @@ + return; + } + -+ org.bukkit.World world = Bukkit.getWorld(getName()); ++ org.bukkit.World world = Bukkit.getWorld(getLevelName()); + if (world != null) { + ThunderChangeEvent thunder = new ThunderChangeEvent(world, flag); + Bukkit.getServer().getPluginManager().callEvent(thunder); @@ -86,16 +81,16 @@ this.thundering = flag; } -@@ -340,6 +366,20 @@ +@@ -341,6 +367,20 @@ @Override - public void setStorm(boolean flag) { + public void setRaining(boolean flag) { + // CraftBukkit start + if (this.raining == flag) { + return; + } + -+ org.bukkit.World world = Bukkit.getWorld(getName()); ++ org.bukkit.World world = Bukkit.getWorld(getLevelName()); + if (world != null) { + WeatherChangeEvent weather = new WeatherChangeEvent(world, flag); + Bukkit.getServer().getPluginManager().callEvent(weather); @@ -107,22 +102,22 @@ this.raining = flag; } -@@ -406,6 +446,12 @@ +@@ -407,6 +447,12 @@ @Override public void setDifficulty(EnumDifficulty enumdifficulty) { - this.settings = this.settings.a(enumdifficulty); + this.settings = this.settings.withDifficulty(enumdifficulty); + // CraftBukkit start + PacketPlayOutServerDifficulty packet = new PacketPlayOutServerDifficulty(this.getDifficulty(), this.isDifficultyLocked()); -+ for (EntityPlayer player : (java.util.List<EntityPlayer>) (java.util.List) world.getPlayers()) { -+ player.connection.sendPacket(packet); ++ for (EntityPlayer player : (java.util.List<EntityPlayer>) (java.util.List) world.players()) { ++ player.connection.send(packet); + } + // CraftBukkit end } @Override -@@ -526,4 +572,12 @@ - public WorldSettings I() { - return this.settings.h(); +@@ -527,4 +573,12 @@ + public WorldSettings getLevelSettings() { + return this.settings.copy(); } + + // CraftBukkit start - Check if the name stored in NBT is the correct one diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/WorldNBTStorage.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/WorldNBTStorage.patch index 500b7b5127..387e09fb6c 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/WorldNBTStorage.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/WorldNBTStorage.patch @@ -22,15 +22,15 @@ + if (entityhuman instanceof EntityPlayer) { + CraftPlayer player = (CraftPlayer) entityhuman.getBukkitEntity(); + // Only update first played if it is older than the one we have -+ long modified = new File(this.playerDir, entityhuman.getUniqueID().toString() + ".dat").lastModified(); ++ long modified = new File(this.playerDir, entityhuman.getUUID().toString() + ".dat").lastModified(); + if (modified < player.getFirstPlayed()) { + player.setFirstPlayed(modified); + } + } + // CraftBukkit end - int i = nbttagcompound.hasKeyOfType("DataVersion", 3) ? nbttagcompound.getInt("DataVersion") : -1; + int i = nbttagcompound.contains("DataVersion", 3) ? nbttagcompound.getInt("DataVersion") : -1; - entityhuman.load(GameProfileSerializer.a(this.fixerUpper, DataFixTypes.PLAYER, nbttagcompound, i)); + entityhuman.load(GameProfileSerializer.update(this.fixerUpper, DataFixTypes.PLAYER, nbttagcompound, i)); @@ -63,6 +80,22 @@ return nbttagcompound; } @@ -41,7 +41,7 @@ + File file1 = new File(this.playerDir, s + ".dat"); + + if (file1.exists()) { -+ return NBTCompressedStreamTools.a((InputStream) (new FileInputStream(file1))); ++ return NBTCompressedStreamTools.readCompressed((InputStream) (new FileInputStream(file1))); + } + } catch (Exception exception) { + LOGGER.warn("Failed to load player data for " + s); diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch index ba3dfe6ae1..e5104efc5f 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch @@ -17,15 +17,15 @@ @@ -115,8 +122,21 @@ } - public void fillInventory(IInventory iinventory, LootTableInfo loottableinfo) { + public void fill(IInventory iinventory, LootTableInfo loottableinfo) { + // CraftBukkit start + this.fillInventory(iinventory, loottableinfo, false); + } + + public void fillInventory(IInventory iinventory, LootTableInfo loottableinfo, boolean plugin) { + // CraftBukkit end - List<ItemStack> list = this.populateLoot(loottableinfo); - Random random = loottableinfo.a(); + List<ItemStack> list = this.getRandomItems(loottableinfo); + Random random = loottableinfo.getRandom(); + // CraftBukkit start + LootGenerateEvent event = CraftEventFactory.callLootGenerateEvent(iinventory, this, loottableinfo, list, plugin); + if (event.isCancelled()) { @@ -33,6 +33,6 @@ + } + list = event.getLoot().stream().map(CraftItemStack::asNMSCopy).collect(Collectors.toList()); + // CraftBukkit end - List<Integer> list1 = this.a(iinventory, random); + List<Integer> list1 = this.getAvailableSlots(iinventory, random); - this.a(list, list1.size(), random); + this.shuffleAndSplitItems(list, list1.size(), random); diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTableRegistry.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTableRegistry.patch index b362ab0e8c..051de7af11 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTableRegistry.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTableRegistry.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/level/storage/loot/LootTableRegistry.java @@ -22,6 +22,7 @@ private static final Logger LOGGER = LogManager.getLogger(); - private static final Gson GSON = LootSerialization.c().create(); + private static final Gson GSON = LootSerialization.createLootTableSerializer().create(); private Map<MinecraftKey, LootTable> tables = ImmutableMap.of(); + public Map<LootTable, MinecraftKey> lootTableToKey = ImmutableMap.of(); // CraftBukkit private final LootPredicateManager predicateManager; @@ -12,8 +12,8 @@ LootPredicateManager lootpredicatemanager = this.predicateManager; Objects.requireNonNull(this.predicateManager); -- Function function = lootpredicatemanager::a; -+ Function<MinecraftKey, net.minecraft.world.level.storage.loot.predicates.LootItemCondition> function = lootpredicatemanager::a; // CraftBukkit - decompile error +- Function function = lootpredicatemanager::get; ++ Function<MinecraftKey, net.minecraft.world.level.storage.loot.predicates.LootItemCondition> function = lootpredicatemanager::get; // CraftBukkit - decompile error Objects.requireNonNull(immutablemap); LootCollector lootcollector = new LootCollector(lootcontextparameterset, function, immutablemap::get); @@ -28,4 +28,4 @@ + // CraftBukkit end } - public static void a(LootCollector lootcollector, MinecraftKey minecraftkey, LootTable loottable) { + public static void validate(LootCollector lootcollector, MinecraftKey minecraftkey, LootTable loottable) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/functions/LootEnchantFunction.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/functions/LootEnchantFunction.patch index fc43056ef0..65e587eb35 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/functions/LootEnchantFunction.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/functions/LootEnchantFunction.patch @@ -3,10 +3,10 @@ @@ -49,8 +49,13 @@ if (entity instanceof EntityLiving) { - int i = EnchantmentManager.g((EntityLiving) entity); + int i = EnchantmentManager.getMobLooting((EntityLiving) entity); + // CraftBukkit start - use lootingModifier if set by plugin -+ if (loottableinfo.hasContextParameter(LootContextParameters.LOOTING_MOD)) { -+ i = loottableinfo.getContextParameter(LootContextParameters.LOOTING_MOD); ++ if (loottableinfo.hasParam(LootContextParameters.LOOTING_MOD)) { ++ i = loottableinfo.getParamOrNull(LootContextParameters.LOOTING_MOD); + } + // CraftBukkit end @@ -18,9 +18,9 @@ @@ -99,7 +104,7 @@ public b() {} - public void a(JsonObject jsonobject, LootEnchantFunction lootenchantfunction, JsonSerializationContext jsonserializationcontext) { -- super.a(jsonobject, (LootItemFunctionConditional) lootenchantfunction, jsonserializationcontext); -+ super.a(jsonobject, lootenchantfunction, jsonserializationcontext); // CraftBukkit - decompile error + public void serialize(JsonObject jsonobject, LootEnchantFunction lootenchantfunction, JsonSerializationContext jsonserializationcontext) { +- super.serialize(jsonobject, (LootItemFunctionConditional) lootenchantfunction, jsonserializationcontext); ++ super.serialize(jsonobject, lootenchantfunction, jsonserializationcontext); // CraftBukkit - decompile error jsonobject.add("count", jsonserializationcontext.serialize(lootenchantfunction.value)); - if (lootenchantfunction.c()) { + if (lootenchantfunction.hasLimit()) { jsonobject.add("limit", jsonserializationcontext.serialize(lootenchantfunction.limit)); diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/parameters/LootContextParameters.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/parameters/LootContextParameters.patch index 7bc1ed20a0..c0e4302af4 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/parameters/LootContextParameters.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/parameters/LootContextParameters.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/storage/loot/parameters/LootContextParameters.java +++ b/net/minecraft/world/level/storage/loot/parameters/LootContextParameters.java @@ -21,6 +21,7 @@ - public static final LootContextParameter<TileEntity> BLOCK_ENTITY = a("block_entity"); - public static final LootContextParameter<ItemStack> TOOL = a("tool"); - public static final LootContextParameter<Float> EXPLOSION_RADIUS = a("explosion_radius"); + public static final LootContextParameter<TileEntity> BLOCK_ENTITY = create("block_entity"); + public static final LootContextParameter<ItemStack> TOOL = create("tool"); + public static final LootContextParameter<Float> EXPLOSION_RADIUS = create("explosion_radius"); + public static final LootContextParameter<Integer> LOOTING_MOD = new LootContextParameter<>(new MinecraftKey("bukkit:looting_mod")); // CraftBukkit public LootContextParameters() {} diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.patch index 958b64d0cd..36ea7ff3ad 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.java @@ -41,6 +41,11 @@ if (entity instanceof EntityLiving) { - i = EnchantmentManager.g((EntityLiving) entity); + i = EnchantmentManager.getMobLooting((EntityLiving) entity); } + // CraftBukkit start - only use lootingModifier if set by Bukkit -+ if (loottableinfo.hasContextParameter(LootContextParameters.LOOTING_MOD)) { -+ i = loottableinfo.getContextParameter(LootContextParameters.LOOTING_MOD); ++ if (loottableinfo.hasParam(LootContextParameters.LOOTING_MOD)) { ++ i = loottableinfo.getParamOrNull(LootContextParameters.LOOTING_MOD); + } + // CraftBukkit end - return loottableinfo.a().nextFloat() < this.percent + (float) i * this.lootingMultiplier; + return loottableinfo.getRandom().nextFloat() < this.percent + (float) i * this.lootingMultiplier; } diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionSurvivesExplosion.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionSurvivesExplosion.patch index 17a7f7ba41..a44cbea100 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionSurvivesExplosion.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionSurvivesExplosion.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/storage/loot/predicates/LootItemConditionSurvivesExplosion.java +++ b/net/minecraft/world/level/storage/loot/predicates/LootItemConditionSurvivesExplosion.java @@ -34,7 +34,8 @@ - Random random = loottableinfo.a(); + Random random = loottableinfo.getRandom(); float f = 1.0F / ofloat; - return random.nextFloat() <= f; diff --git a/paper-server/nms-patches/net/minecraft/world/ticks/NextTickListEntry.patch b/paper-server/nms-patches/net/minecraft/world/ticks/NextTickListEntry.patch new file mode 100644 index 0000000000..e2dbe2f3ff --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/ticks/NextTickListEntry.patch @@ -0,0 +1,59 @@ +--- a/net/minecraft/world/ticks/NextTickListEntry.java ++++ b/net/minecraft/world/ticks/NextTickListEntry.java +@@ -5,13 +5,17 @@ + import javax.annotation.Nullable; + import net.minecraft.core.BlockPosition; + +-public final class NextTickListEntry extends Record { ++// CraftBukkit start ++public final record NextTickListEntry<T>(T type, BlockPosition pos, long triggerTick, TickListPriority priority, long subTickOrder) { + ++ /* + private final T type; + private final BlockPosition pos; + private final long triggerTick; + private final TickListPriority priority; + private final long subTickOrder; ++ */ ++ // CraftBukkit end + public static final Comparator<NextTickListEntry<?>> DRAIN_ORDER = (nextticklistentry, nextticklistentry1) -> { + int i = Long.compare(nextticklistentry.triggerTick, nextticklistentry1.triggerTick); + +@@ -41,19 +45,23 @@ + this(t0, blockposition, i, TickListPriority.NORMAL, j); + } + +- public NextTickListEntry(T t0, BlockPosition blockposition, long i, TickListPriority ticklistpriority, long j) { +- blockposition = blockposition.immutable(); +- this.type = t0; +- this.pos = blockposition; +- this.triggerTick = i; +- this.priority = ticklistpriority; +- this.subTickOrder = j; ++ // CraftBukkit start ++ public NextTickListEntry(T type, BlockPosition pos, long triggerTick, TickListPriority priority, long subTickOrder) { ++ pos = pos.immutable(); ++ this.type = type; ++ this.pos = pos; ++ this.triggerTick = triggerTick; ++ this.priority = priority; ++ this.subTickOrder = subTickOrder; ++ // CraftBukkit end + } + + public static <T> NextTickListEntry<T> probe(T t0, BlockPosition blockposition) { + return new NextTickListEntry(t0, blockposition, 0L, TickListPriority.NORMAL, 0L); + } + ++ // CraftBukkit start ++ /* + public final String toString() { + return this.toString < invokedynamic > (this); + } +@@ -85,4 +93,6 @@ + public long subTickOrder() { + return this.subTickOrder; + } ++ */ ++ // CraftBukkit end + } diff --git a/paper-server/nms-patches/net/minecraft/world/ticks/TickListChunk.patch b/paper-server/nms-patches/net/minecraft/world/ticks/TickListChunk.patch new file mode 100644 index 0000000000..a48949a8f2 --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/ticks/TickListChunk.patch @@ -0,0 +1,53 @@ +--- a/net/minecraft/world/ticks/TickListChunk.java ++++ b/net/minecraft/world/ticks/TickListChunk.java +@@ -10,12 +10,16 @@ + import net.minecraft.nbt.NBTTagList; + import net.minecraft.world.level.ChunkCoordIntPair; + +-final class TickListChunk extends Record { ++// CraftBukkit start ++final record TickListChunk<T>(T type, BlockPosition pos, int delay, TickListPriority priority) { + ++ /* + private final T type; + private final BlockPosition pos; + private final int delay; + private final TickListPriority priority; ++ */ ++ // CraftBukkit end + private static final String TAG_ID = "i"; + private static final String TAG_X = "x"; + private static final String TAG_Y = "y"; +@@ -32,12 +36,16 @@ + } + }; + ++ // CraftBukkit start ++ /* + TickListChunk(T t0, BlockPosition blockposition, int i, TickListPriority ticklistpriority) { + this.type = t0; + this.pos = blockposition; + this.delay = i; + this.priority = ticklistpriority; + } ++ */ ++ // CraftBukkit end + + public static <T> void loadTickList(NBTTagList nbttaglist, Function<String, Optional<T>> function, ChunkCoordIntPair chunkcoordintpair, Consumer<TickListChunk<T>> consumer) { + long i = chunkcoordintpair.toLong(); +@@ -85,6 +93,8 @@ + return new TickListChunk(t0, blockposition, 0, TickListPriority.NORMAL); + } + ++ // CraftBukkit start ++ /* + public final String toString() { + return this.toString < invokedynamic > (this); + } +@@ -112,4 +122,6 @@ + public TickListPriority priority() { + return this.priority; + } ++ */ ++ // CraftBukkit end + } diff --git a/paper-server/pom.xml b/paper-server/pom.xml index b013c8688c..626b271674 100644 --- a/paper-server/pom.xml +++ b/paper-server/pom.xml @@ -4,7 +4,7 @@ <groupId>org.bukkit</groupId> <artifactId>craftbukkit</artifactId> <packaging>jar</packaging> - <version>1.17.1-R0.1-SNAPSHOT</version> + <version>1.18-pre5-R0.1-SNAPSHOT</version> <name>CraftBukkit</name> <url>https://www.spigotmc.org/</url> @@ -13,11 +13,19 @@ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <api.version>unknown</api.version> <bt.name>git</bt.name> - <minecraft_version>1_17_R1</minecraft_version> - <maven.compiler.source>1.8</maven.compiler.source> - <maven.compiler.target>1.8</maven.compiler.target> + <minecraft_version>1_18_R1</minecraft_version> + <maven.compiler.source>16</maven.compiler.source> + <maven.compiler.target>16</maven.compiler.target> </properties> + <repositories> + <repository> + <id>minecraft-libraries</id> + <name>Minecraft Libraries</name> + <url>https://libraries.minecraft.net/</url> + </repository> + </repositories> + <dependencies> <dependency> <groupId>org.bukkit</groupId> @@ -42,13 +50,6 @@ <artifactId>log4j-iostreams</artifactId> <version>2.14.1</version> <scope>compile</scope> - <exclusions> - <!-- included in minecraft-server --> - <exclusion> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-api</artifactId> - </exclusion> - </exclusions> </dependency> <dependency> <groupId>org.ow2.asm</groupId> @@ -56,6 +57,85 @@ <version>9.2</version> <scope>compile</scope> </dependency> + <!-- Mojang depends --> + <dependency> + <groupId>com.github.oshi</groupId> + <artifactId>oshi-core</artifactId> + <version>5.8.2</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>com.mojang</groupId> + <artifactId>authlib</artifactId> + <version>3.2.38</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>com.mojang</groupId> + <artifactId>brigadier</artifactId> + <version>1.0.18</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>com.mojang</groupId> + <artifactId>datafixerupper</artifactId> + <version>4.0.26</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>com.mojang</groupId> + <artifactId>javabridge</artifactId> + <version>1.2.24</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.11.0</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>io.netty</groupId> + <artifactId>netty-all</artifactId> + <version>4.1.68.Final</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>it.unimi.dsi</groupId> + <artifactId>fastutil</artifactId> + <version>8.5.6</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>net.sf.jopt-simple</groupId> + <artifactId>jopt-simple</artifactId> + <version>5.0.4</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <version>3.12.0</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>2.14.1</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j18-impl</artifactId> + <version>2.14.1</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.8.0-beta4</version> + <scope>compile</scope> + </dependency> <!-- deprecated API depend --> <dependency> <groupId>com.googlecode.json-simple</groupId> @@ -66,13 +146,13 @@ <dependency> <groupId>org.xerial</groupId> <artifactId>sqlite-jdbc</artifactId> - <version>3.34.0</version> + <version>3.36.0.3</version> <scope>runtime</scope> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> - <version>5.1.49</version> + <version>8.0.27</version> <scope>runtime</scope> </dependency> <!-- add these back in as they are not exposed by the API --> @@ -207,87 +287,21 @@ </goals> <configuration> <createSourcesJar>${shadeSourcesJar}</createSourcesJar> - <filters> - <filter> - <artifact>org.spigotmc:minecraft-server</artifact> - <excludes> - <exclude>com/google/common/**</exclude> - <exclude>com/google/gson/**</exclude> - <exclude>com/google/thirdparty/**</exclude> - </excludes> - </filter> - <filter> - <artifact>org.eclipse.sisu:org.eclipse.sisu.inject</artifact> - <excludes> - <exclude>META-INF/services/javax.annotation.processing.Processor</exclude> - </excludes> - </filter> - </filters> + <artifactSet> + <includes> + <include>org.spigotmc:minecraft-server</include> + </includes> + </artifactSet> <relocations> - <!-- Cannot be relocated as it breaks translation property keys --> - <!-- - <relocation> - <pattern>joptsimple</pattern> - <shadedPattern>org.bukkit.craftbukkit.libs.joptsimple</shadedPattern> - </relocation> - --> - <relocation> - <pattern>jline</pattern> - <shadedPattern>org.bukkit.craftbukkit.libs.jline</shadedPattern> - </relocation> - <relocation> - <pattern>it.unimi</pattern> - <shadedPattern>org.bukkit.craftbukkit.libs.it.unimi</shadedPattern> - </relocation> - <relocation> - <pattern>org.apache.commons.codec</pattern> - <shadedPattern>org.bukkit.craftbukkit.libs.org.apache.commons.codec</shadedPattern> - </relocation> - <relocation> - <pattern>org.apache.commons.io</pattern> - <shadedPattern>org.bukkit.craftbukkit.libs.org.apache.commons.io</shadedPattern> - </relocation> - <relocation> - <pattern>org.apache.commons.lang3</pattern> - <shadedPattern>org.bukkit.craftbukkit.libs.org.apache.commons.lang3</shadedPattern> - </relocation> - <relocation> - <pattern>org.apache.http</pattern> - <shadedPattern>org.bukkit.craftbukkit.libs.org.apache.http</shadedPattern> - </relocation> - <relocation> - <pattern>org.apache.maven</pattern> - <shadedPattern>org.bukkit.craftbukkit.libs.org.apache.maven</shadedPattern> - </relocation> - <relocation> - <pattern>org.codehaus.plexus</pattern> - <shadedPattern>org.bukkit.craftbukkit.libs.org.codehaus.plexus</shadedPattern> - </relocation> - <relocation> - <pattern>org.eclipse.aether</pattern> - <shadedPattern>org.bukkit.craftbukkit.libs.org.eclipse.aether</shadedPattern> - </relocation> - <relocation> - <pattern>org.eclipse.sisu</pattern> - <shadedPattern>org.bukkit.craftbukkit.libs.org.eclipse.sisu</shadedPattern> - </relocation> - <relocation> - <pattern>org.objectweb.asm</pattern> - <shadedPattern>org.bukkit.craftbukkit.libs.org.objectweb.asm</shadedPattern> - </relocation> <relocation> <pattern>org.bukkit.craftbukkit</pattern> <shadedPattern>org.bukkit.craftbukkit.v${minecraft_version}</shadedPattern> <excludes> + <exclude>org.bukkit.craftbukkit.bootstrap.*</exclude> <exclude>org.bukkit.craftbukkit.Main*</exclude> </excludes> </relocation> </relocations> - <transformers> - <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> - <resource>META-INF/services/java.sql.Driver</resource> - </transformer> - </transformers> </configuration> </execution> </executions> @@ -295,21 +309,74 @@ <plugin> <groupId>net.md-5</groupId> <artifactId>specialsource-maven-plugin</artifactId> - <version>1.2.2</version> + <version>1.2.3</version> <executions> <execution> <phase>package</phase> <goals> <goal>remap</goal> </goals> - <id>remap-fields</id> + <id>remap-members</id> <configuration> - <srgIn>org.spigotmc:minecraft-server:${project.version}:csrg:maps-spigot-fields</srgIn> + <logFile>${project.build.directory}/server.txt</logFile> + <srgIn>org.spigotmc:minecraft-server:${project.version}:csrg:maps-spigot-members</srgIn> <reverse>true</reverse> </configuration> </execution> </executions> </plugin> + <plugin> + <groupId>net.nicoulaj.maven.plugins</groupId> + <artifactId>checksum-maven-plugin</artifactId> + <version>1.11</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>artifacts</goal> + <goal>dependencies</goal> + </goals> + <configuration> + <algorithms> + <algorithm>SHA-256</algorithm> + </algorithms> + <scopes> + <scope>compile</scope> + <scope>runtime</scope> + </scopes> + <shasumSummary>true</shasumSummary> + <transitive>true</transitive> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + <version>3.3.0</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <appendAssemblyId>false</appendAssemblyId> + <archive> + <manifest> + <addDefaultEntries>false</addDefaultEntries> + </manifest> + <manifestEntries> + <Main-Class>org.bukkit.craftbukkit.bootstrap.Main</Main-Class> + </manifestEntries> + </archive> + <descriptors> + <descriptor>${project.basedir}/src/assembly/bootstrap.xml</descriptor> + </descriptors> + </configuration> + </execution> + </executions> + </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> @@ -327,7 +394,7 @@ <dependency> <groupId>org.eclipse.jdt</groupId> <artifactId>ecj</artifactId> - <version>3.26.0</version> + <version>3.27.0</version> </dependency> </dependencies> </plugin> @@ -380,7 +447,7 @@ <dependency> <groupId>com.puppycrawl.tools</groupId> <artifactId>checkstyle</artifactId> - <version>8.44</version> + <version>9.1</version> </dependency> </dependencies> </plugin> @@ -392,7 +459,7 @@ <execution> <phase>process-classes</phase> <goals> - <goal>check</goal> + <!--<goal>check</goal>--> </goals> </execution> </executions> diff --git a/paper-server/src/assembly/META-INF/main-class b/paper-server/src/assembly/META-INF/main-class new file mode 100644 index 0000000000..94a6b1554c --- /dev/null +++ b/paper-server/src/assembly/META-INF/main-class @@ -0,0 +1 @@ +org.bukkit.craftbukkit.Main \ No newline at end of file diff --git a/paper-server/src/assembly/bootstrap.xml b/paper-server/src/assembly/bootstrap.xml new file mode 100644 index 0000000000..f8980991f5 --- /dev/null +++ b/paper-server/src/assembly/bootstrap.xml @@ -0,0 +1,65 @@ +<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd"> + + <id>bootstrap</id> + + <formats> + <format>jar</format> + </formats> + + <includeBaseDirectory>false</includeBaseDirectory> + + <files> + <file> + <destName>libraries.list</destName> + <outputDirectory>META-INF</outputDirectory> + <source>${project.build.directory}/dependencies-checksums.sha</source> + </file> + <file> + <destName>versions.list</destName> + <outputDirectory>META-INF</outputDirectory> + <source>${project.build.directory}/artifacts-checksums.sha</source> + </file> + </files> + + <fileSets> + <fileSet> + <directory>${project.basedir}/src/assembly/META-INF</directory> + <filtered>true</filtered> + <outputDirectory>META-INF</outputDirectory> + </fileSet> + </fileSets> + + <dependencySets> + <!-- libraries --> + <dependencySet> + <excludes> + <exclude>org.spigotmc:minecraft-server</exclude> + </excludes> + <outputDirectory>META-INF/libraries</outputDirectory> + <useProjectArtifact>false</useProjectArtifact> + </dependencySet> + + <!-- main jar --> + <dependencySet> + <includes> + <include>${project.groupId}:${project.artifactId}</include> + </includes> + <outputDirectory>META-INF/versions</outputDirectory> + </dependencySet> + + <!-- bootstrap --> + <dependencySet> + <includes> + <include>${project.groupId}:${project.artifactId}</include> + </includes> + <unpack>true</unpack> + <unpackOptions> + <includes> + <include>org/bukkit/craftbukkit/bootstrap/**</include> + </includes> + </unpackOptions> + </dependencySet> + </dependencySets> +</assembly> diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java index 1640d8bb73..275cdebb74 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java @@ -14,7 +14,7 @@ public class CraftArt { static { ImmutableBiMap.Builder<Paintings, Art> artworkBuilder = ImmutableBiMap.builder(); for (MinecraftKey key : IRegistry.MOTIVE.keySet()) { - artworkBuilder.put(IRegistry.MOTIVE.get(key), Art.getByName(key.getKey())); + artworkBuilder.put(IRegistry.MOTIVE.get(key), Art.getByName(key.getPath())); } artwork = artworkBuilder.build(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index 990bbc66d2..1008a62e45 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -2,6 +2,7 @@ package org.bukkit.craftbukkit; import com.google.common.base.Preconditions; import com.google.common.base.Predicates; +import com.mojang.serialization.Codec; import java.lang.ref.WeakReference; import java.util.Arrays; import java.util.Collection; @@ -12,21 +13,22 @@ import java.util.function.Predicate; import net.minecraft.core.BlockPosition; import net.minecraft.core.IRegistry; import net.minecraft.core.SectionPosition; -import net.minecraft.nbt.GameProfileSerializer; +import net.minecraft.nbt.DynamicOpsNBT; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.server.level.WorldServer; import net.minecraft.util.thread.ThreadedMailbox; import net.minecraft.world.level.ChunkCoordIntPair; import net.minecraft.world.level.EnumSkyBlock; -import net.minecraft.world.level.biome.WorldChunkManager; +import net.minecraft.world.level.biome.BiomeBase; +import net.minecraft.world.level.biome.Biomes; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; -import net.minecraft.world.level.chunk.BiomeStorage; import net.minecraft.world.level.chunk.ChunkSection; import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.DataPaletteBlock; import net.minecraft.world.level.chunk.IChunkAccess; import net.minecraft.world.level.chunk.NibbleArray; +import net.minecraft.world.level.chunk.storage.ChunkRegionLoader; import net.minecraft.world.level.chunk.storage.EntityStorage; import net.minecraft.world.level.entity.PersistentEntitySectionManager; import net.minecraft.world.level.levelgen.HeightMap; @@ -40,7 +42,6 @@ import org.bukkit.block.BlockState; import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.block.data.CraftBlockData; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.entity.Entity; import org.bukkit.persistence.PersistentDataContainer; import org.bukkit.plugin.Plugin; @@ -50,7 +51,7 @@ public class CraftChunk implements Chunk { private final WorldServer worldServer; private final int x; private final int z; - private static final DataPaletteBlock<IBlockData> emptyBlockIDs = new ChunkSection(0).getBlocks(); + private static final DataPaletteBlock<IBlockData> emptyBlockIDs = new DataPaletteBlock<>(net.minecraft.world.level.block.Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), DataPaletteBlock.e.SECTION_STATES); private static final byte[] emptyLight = new byte[2048]; public CraftChunk(net.minecraft.world.level.chunk.Chunk chunk) { @@ -81,7 +82,7 @@ public class CraftChunk implements Chunk { net.minecraft.world.level.chunk.Chunk c = weakChunk.get(); if (c == null) { - c = worldServer.getChunkAt(x, z); + c = worldServer.getChunk(x, z); weakChunk = new WeakReference<net.minecraft.world.level.chunk.Chunk>(c); } @@ -117,7 +118,7 @@ public class CraftChunk implements Chunk { @Override public boolean isEntitiesLoaded() { - return getCraftWorld().getHandle().entityManager.a(ChunkCoordIntPair.pair(x, z)); // PAIL rename isEntitiesLoaded + return getCraftWorld().getHandle().entityManager.areEntitiesLoaded(ChunkCoordIntPair.asLong(x, z)); } @Override @@ -127,40 +128,40 @@ public class CraftChunk implements Chunk { } PersistentEntitySectionManager<net.minecraft.world.entity.Entity> entityManager = getCraftWorld().getHandle().entityManager; - long pair = ChunkCoordIntPair.pair(x, z); + long pair = ChunkCoordIntPair.asLong(x, z); - if (entityManager.a(pair)) { // PAIL rename isEntitiesLoaded + if (entityManager.areEntitiesLoaded(pair)) { return entityManager.getEntities(new ChunkCoordIntPair(x, z)).stream() .map(net.minecraft.world.entity.Entity::getBukkitEntity) .filter(Objects::nonNull).toArray(Entity[]::new); } - entityManager.b(pair); // Start entity loading + entityManager.ensureChunkQueuedForLoad(pair); // Start entity loading // SPIGOT-6772: Use entity mailbox and re-schedule entities if they get unloaded ThreadedMailbox<Runnable> mailbox = ((EntityStorage) entityManager.permanentStorage).entityDeserializerQueue; BooleanSupplier supplier = () -> { // only execute inbox if our entities are not present - if (entityManager.a(pair)) { + if (entityManager.areEntitiesLoaded(pair)) { return true; } if (!entityManager.isPending(pair)) { // Our entities got unloaded, this should normally not happen. - entityManager.b(pair); // Re-start entity loading + entityManager.ensureChunkQueuedForLoad(pair); // Re-start entity loading } // tick loading inbox, which loads the created entities to the world // (if present) entityManager.tick(); // check if our entities are loaded - return entityManager.a(pair); + return entityManager.areEntitiesLoaded(pair); }; // now we wait until the entities are loaded, // the converting from NBT to entity object is done on the main Thread which is why we wait while (!supplier.getAsBoolean()) { - if (mailbox.b() != 0) { // PAIL rename size + if (mailbox.size() != 0) { mailbox.run(); } else { Thread.yield(); @@ -218,7 +219,7 @@ public class CraftChunk implements Chunk { @Override public boolean isSlimeChunk() { // 987234911L is deterimined in EntitySlime when seeing if a slime can spawn in a chunk - return SeededRandom.a(getX(), getZ(), getWorld().getSeed(), 987234911L).nextInt(10) == 0; + return SeededRandom.seedSlimeChunk(getX(), getZ(), getWorld().getSeed(), 987234911L).nextInt(10) == 0; } @Override @@ -269,7 +270,7 @@ public class CraftChunk implements Chunk { Predicate<IBlockData> nms = Predicates.equalTo(((CraftBlockData) block).getState()); for (ChunkSection section : getHandle().getSections()) { - if (section != null && section.getBlocks().contains(nms)) { + if (section != null && section.getStates().maybeHas(nms)) { return true; } } @@ -291,37 +292,36 @@ public class CraftChunk implements Chunk { byte[][] sectionSkyLights = new byte[cs.length][]; byte[][] sectionEmitLights = new byte[cs.length][]; boolean[] sectionEmpty = new boolean[cs.length]; + DataPaletteBlock<BiomeBase>[] biome = (includeBiome || includeBiomeTempRain) ? new DataPaletteBlock[cs.length] : null; + + IRegistry<BiomeBase> iregistry = worldServer.registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY); + Codec<DataPaletteBlock<BiomeBase>> biomeCodec = DataPaletteBlock.codec(iregistry, iregistry.byNameCodec(), DataPaletteBlock.e.SECTION_BIOMES, iregistry.getOrThrow(Biomes.PLAINS)); for (int i = 0; i < cs.length; i++) { - if (ChunkSection.a(cs[i])) { // Section is empty? // PAIL rename isEmpty - sectionBlockIDs[i] = emptyBlockIDs; + NBTTagCompound data = new NBTTagCompound(); + + data.put("block_states", ChunkRegionLoader.BLOCK_STATE_CODEC.encodeStart(DynamicOpsNBT.INSTANCE, cs[i].getStates()).get().left().get()); + sectionBlockIDs[i] = ChunkRegionLoader.BLOCK_STATE_CODEC.parse(DynamicOpsNBT.INSTANCE, data.getCompound("block_states")).get().left().get(); + + LightEngine lightengine = chunk.level.getLightEngine(); + NibbleArray skyLightArray = lightengine.getLayerListener(EnumSkyBlock.SKY).getDataLayerData(SectionPosition.of(x, i, z)); + if (skyLightArray == null) { sectionSkyLights[i] = emptyLight; + } else { + sectionSkyLights[i] = new byte[2048]; + System.arraycopy(skyLightArray.getData(), 0, sectionSkyLights[i], 0, 2048); + } + NibbleArray emitLightArray = lightengine.getLayerListener(EnumSkyBlock.BLOCK).getDataLayerData(SectionPosition.of(x, i, z)); + if (emitLightArray == null) { sectionEmitLights[i] = emptyLight; - sectionEmpty[i] = true; - } else { // Not empty - NBTTagCompound data = new NBTTagCompound(); - cs[i].getBlocks().a(data, "Palette", "BlockStates"); + } else { + sectionEmitLights[i] = new byte[2048]; + System.arraycopy(emitLightArray.getData(), 0, sectionEmitLights[i], 0, 2048); + } - DataPaletteBlock blockids = new DataPaletteBlock<>(ChunkSection.GLOBAL_BLOCKSTATE_PALETTE, net.minecraft.world.level.block.Block.BLOCK_STATE_REGISTRY, GameProfileSerializer::c, GameProfileSerializer::a, Blocks.AIR.getBlockData()); // TODO: snapshot whole ChunkSection - blockids.a(data.getList("Palette", CraftMagicNumbers.NBT.TAG_COMPOUND), data.getLongArray("BlockStates")); - - sectionBlockIDs[i] = blockids; - - LightEngine lightengine = chunk.level.getChunkProvider().getLightEngine(); - NibbleArray skyLightArray = lightengine.a(EnumSkyBlock.SKY).a(SectionPosition.a(x, i, z)); - if (skyLightArray == null) { - sectionSkyLights[i] = emptyLight; - } else { - sectionSkyLights[i] = new byte[2048]; - System.arraycopy(skyLightArray.asBytes(), 0, sectionSkyLights[i], 0, 2048); - } - NibbleArray emitLightArray = lightengine.a(EnumSkyBlock.BLOCK).a(SectionPosition.a(x, i, z)); - if (emitLightArray == null) { - sectionEmitLights[i] = emptyLight; - } else { - sectionEmitLights[i] = new byte[2048]; - System.arraycopy(emitLightArray.asBytes(), 0, sectionEmitLights[i], 0, 2048); - } + if (biome != null) { + data.put("biomes", biomeCodec.encodeStart(DynamicOpsNBT.INSTANCE, cs[i].getBiomes()).get().left().get()); + biome[i] = biomeCodec.parse(DynamicOpsNBT.INSTANCE, data.getCompound("biomes")).get().left().get(); } } @@ -329,13 +329,7 @@ public class CraftChunk implements Chunk { if (includeMaxBlockY) { hmap = new HeightMap(chunk, HeightMap.Type.MOTION_BLOCKING); - hmap.a(chunk, HeightMap.Type.MOTION_BLOCKING, chunk.heightmaps.get(HeightMap.Type.MOTION_BLOCKING).a()); - } - - BiomeStorage biome = null; - - if (includeBiome || includeBiomeTempRain) { - biome = chunk.getBiomeIndex(); + hmap.setRawData(chunk, HeightMap.Type.MOTION_BLOCKING, chunk.heightmaps.get(HeightMap.Type.MOTION_BLOCKING).getRawData()); } World world = getWorld(); @@ -348,13 +342,7 @@ public class CraftChunk implements Chunk { } public static ChunkSnapshot getEmptyChunkSnapshot(int x, int z, CraftWorld world, boolean includeBiome, boolean includeBiomeTempRain) { - BiomeStorage biome = null; - - if (includeBiome || includeBiomeTempRain) { - WorldChunkManager wcm = world.getHandle().getChunkProvider().getChunkGenerator().getWorldChunkManager(); - biome = new BiomeStorage(world.getHandle().t().d(IRegistry.BIOME_REGISTRY), world.getHandle(), new ChunkCoordIntPair(x, z), wcm); - } - IChunkAccess actual = world.getHandle().getChunkAt(x, z, ChunkStatus.EMPTY); + IChunkAccess actual = world.getHandle().getChunk(x, z, ChunkStatus.EMPTY); /* Fill with empty data */ int hSection = actual.getSectionsCount(); @@ -362,12 +350,18 @@ public class CraftChunk implements Chunk { byte[][] skyLight = new byte[hSection][]; byte[][] emitLight = new byte[hSection][]; boolean[] empty = new boolean[hSection]; + DataPaletteBlock<BiomeBase>[] biome = (includeBiome || includeBiomeTempRain) ? new DataPaletteBlock[hSection] : null; for (int i = 0; i < hSection; i++) { blockIDs[i] = emptyBlockIDs; skyLight[i] = emptyLight; emitLight[i] = emptyLight; empty[i] = true; + + if (biome != null) { + IRegistry<BiomeBase> iregistry = world.getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY); + biome[i] = new DataPaletteBlock<>(iregistry, iregistry.getOrThrow(Biomes.PLAINS), DataPaletteBlock.e.SECTION_BIOMES); + } } return new CraftChunkSnapshot(x, z, world.getMinHeight(), world.getMaxHeight(), world.getName(), world.getFullTime(), blockIDs, skyLight, emitLight, empty, new HeightMap(actual, HeightMap.Type.MOTION_BLOCKING), biome); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java index d90a3ec09f..3ca8103277 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java @@ -7,7 +7,6 @@ import net.minecraft.core.BlockPosition; import net.minecraft.core.IRegistry; import net.minecraft.world.level.biome.BiomeBase; import net.minecraft.world.level.block.state.IBlockData; -import net.minecraft.world.level.chunk.BiomeStorage; import net.minecraft.world.level.chunk.DataPaletteBlock; import net.minecraft.world.level.levelgen.HeightMap; import org.bukkit.ChunkSnapshot; @@ -32,9 +31,9 @@ public class CraftChunkSnapshot implements ChunkSnapshot { private final boolean[] empty; private final HeightMap hmap; // Height map private final long captureFulltime; - private final BiomeStorage biome; + private final DataPaletteBlock<BiomeBase>[] biome; - CraftChunkSnapshot(int x, int z, int minHeight, int maxHeight, String wname, long wtime, DataPaletteBlock<IBlockData>[] sectionBlockIDs, byte[][] sectionSkyLights, byte[][] sectionEmitLights, boolean[] sectionEmpty, HeightMap hmap, BiomeStorage biome) { + CraftChunkSnapshot(int x, int z, int minHeight, int maxHeight, String wname, long wtime, DataPaletteBlock<IBlockData>[] sectionBlockIDs, byte[][] sectionSkyLights, byte[][] sectionEmitLights, boolean[] sectionEmpty, HeightMap hmap, DataPaletteBlock<BiomeBase>[] biome) { this.x = x; this.z = z; this.minHeight = minHeight; @@ -70,7 +69,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot { Predicate<IBlockData> nms = Predicates.equalTo(((CraftBlockData) block).getState()); for (DataPaletteBlock<IBlockData> palette : blockids) { - if (palette.contains(nms)) { + if (palette.maybeHas(nms)) { return true; } } @@ -82,21 +81,21 @@ public class CraftChunkSnapshot implements ChunkSnapshot { public Material getBlockType(int x, int y, int z) { validateChunkCoordinates(x, y, z); - return CraftMagicNumbers.getMaterial(blockids[getSectionIndex(y)].a(x, y & 0xF, z).getBlock()); + return CraftMagicNumbers.getMaterial(blockids[getSectionIndex(y)].get(x, y & 0xF, z).getBlock()); } @Override public final BlockData getBlockData(int x, int y, int z) { validateChunkCoordinates(x, y, z); - return CraftBlockData.fromData(blockids[getSectionIndex(y)].a(x, y & 0xF, z)); + return CraftBlockData.fromData(blockids[getSectionIndex(y)].get(x, y & 0xF, z)); } @Override public final int getData(int x, int y, int z) { validateChunkCoordinates(x, y, z); - return CraftMagicNumbers.toLegacyData(blockids[getSectionIndex(y)].a(x, y & 0xF, z)); + return CraftMagicNumbers.toLegacyData(blockids[getSectionIndex(y)].get(x, y & 0xF, z)); } @Override @@ -120,7 +119,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot { Preconditions.checkState(hmap != null, "ChunkSnapshot created without height map. Please call getSnapshot with includeMaxblocky=true"); validateChunkCoordinates(x, 0, z); - return hmap.a(x, z); + return hmap.getFirstAvailable(x, z); } @Override @@ -133,7 +132,8 @@ public class CraftChunkSnapshot implements ChunkSnapshot { Preconditions.checkState(biome != null, "ChunkSnapshot created without biome. Please call getSnapshot with includeBiome=true"); validateChunkCoordinates(x, y, z); - return CraftBlock.biomeBaseToBiome((IRegistry<BiomeBase>) biome.biomeRegistry, biome.getBiome(x >> 2, y >> 2, z >> 2)); + DataPaletteBlock<BiomeBase> biome = this.biome[getSectionIndex(y)]; + return CraftBlock.biomeBaseToBiome((IRegistry<BiomeBase>) biome.registry, biome.get(x >> 2, y >> 2, z >> 2)); } @Override @@ -146,7 +146,8 @@ public class CraftChunkSnapshot implements ChunkSnapshot { Preconditions.checkState(biome != null, "ChunkSnapshot created without biome. Please call getSnapshot with includeBiome=true"); validateChunkCoordinates(x, y, z); - return biome.getBiome(x >> 2, y >> 2, z >> 2).getAdjustedTemperature(new BlockPosition((this.x << 4) | x, y, (this.z << 4) | z)); + DataPaletteBlock<BiomeBase> biome = this.biome[getSectionIndex(y)]; + return biome.get(x >> 2, y >> 2, z >> 2).getTemperature(new BlockPosition((this.x << 4) | x, y, (this.z << 4) | z)); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java index 9e45081839..f077b8ff0b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java @@ -20,7 +20,7 @@ public class CraftCrashReport implements Supplier<String> { public String get() { StringWriter value = new StringWriter(); try { - value.append("\n Running: ").append(Bukkit.getName()).append(" version ").append(Bukkit.getVersion()).append(" (Implementing API version ").append(Bukkit.getBukkitVersion()).append(") ").append(String.valueOf(MinecraftServer.getServer().getOnlineMode())); + value.append("\n Running: ").append(Bukkit.getName()).append(" version ").append(Bukkit.getVersion()).append(" (Implementing API version ").append(Bukkit.getBukkitVersion()).append(") ").append(String.valueOf(MinecraftServer.getServer().usesAuthentication())); value.append("\n Plugins: {"); for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { PluginDescriptionFile description = plugin.getDescription(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEffect.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEffect.java index 151a6db2a3..da975e6360 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEffect.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEffect.java @@ -60,7 +60,7 @@ public class CraftEffect { break; case STEP_SOUND: Validate.isTrue(((Material) data).isBlock(), "Material is not a block!"); - datavalue = Block.getCombinedId(CraftMagicNumbers.getBlock((Material) data).getBlockData()); + datavalue = Block.getId(CraftMagicNumbers.getBlock((Material) data).defaultBlockState()); break; case COMPOSTER_FILL_ATTEMPT: datavalue = ((Boolean) data) ? 1 : 0; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftIpBanList.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftIpBanList.java index 594b6da344..c9c43fb9a7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftIpBanList.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftIpBanList.java @@ -53,7 +53,7 @@ public class CraftIpBanList implements org.bukkit.BanList { @Override public Set<org.bukkit.BanEntry> getBanEntries() { ImmutableSet.Builder<org.bukkit.BanEntry> builder = ImmutableSet.builder(); - for (String target : list.getEntries()) { + for (String target : list.getUserList()) { builder.add(new CraftIpBanEntry(target, (IpBanEntry) list.get(target), list)); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java index 14fa2a434c..b250f644cc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java @@ -42,7 +42,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { @Override public Collection<ItemStack> populateLoot(Random random, LootContext context) { LootTableInfo nmsContext = convertContext(context); - List<net.minecraft.world.item.ItemStack> nmsItems = handle.populateLoot(nmsContext); + List<net.minecraft.world.item.ItemStack> nmsItems = handle.getRandomItems(nmsContext); Collection<ItemStack> bukkit = new ArrayList<>(nmsItems.size()); for (net.minecraft.world.item.ItemStack item : nmsItems) { @@ -62,7 +62,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { IInventory handle = craftInventory.getInventory(); // TODO: When events are added, call event here w/ custom reason? - getHandle().fillInventory(handle, nmsContext); + getHandle().fill(handle, nmsContext); } @Override @@ -83,7 +83,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { Entity nmsLootedEntity = ((CraftEntity) context.getLootedEntity()).getHandle(); setMaybe(builder, LootContextParameters.THIS_ENTITY, nmsLootedEntity); setMaybe(builder, LootContextParameters.DAMAGE_SOURCE, DamageSource.GENERIC); - setMaybe(builder, LootContextParameters.ORIGIN, nmsLootedEntity.getPositionVector()); + setMaybe(builder, LootContextParameters.ORIGIN, nmsLootedEntity.position()); } if (context.getKiller() != null) { @@ -102,46 +102,46 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { // SPIGOT-5603 - Avoid IllegalArgumentException in LootTableInfo#build() LootContextParameterSet.Builder nmsBuilder = new LootContextParameterSet.Builder(); - for (LootContextParameter<?> param : getHandle().getLootContextParameterSet().getRequired()) { - nmsBuilder.addRequired(param); + for (LootContextParameter<?> param : getHandle().getParamSet().getRequired()) { + nmsBuilder.required(param); } - for (LootContextParameter<?> param : getHandle().getLootContextParameterSet().getOptional()) { - if (!getHandle().getLootContextParameterSet().getRequired().contains(param)) { - nmsBuilder.addOptional(param); + for (LootContextParameter<?> param : getHandle().getParamSet().getAllowed()) { + if (!getHandle().getParamSet().getRequired().contains(param)) { + nmsBuilder.optional(param); } } - nmsBuilder.addOptional(LootContextParameters.LOOTING_MOD); + nmsBuilder.optional(LootContextParameters.LOOTING_MOD); - return builder.build(nmsBuilder.build()); + return builder.create(nmsBuilder.build()); } private <T> void setMaybe(LootTableInfo.Builder builder, LootContextParameter<T> param, T value) { - if (getHandle().getLootContextParameterSet().getRequired().contains(param) || getHandle().getLootContextParameterSet().getOptional().contains(param)) { - builder.set(param, value); + if (getHandle().getParamSet().getRequired().contains(param) || getHandle().getParamSet().getAllowed().contains(param)) { + builder.withParameter(param, value); } } public static LootContext convertContext(LootTableInfo info) { - Vec3D position = info.getContextParameter(LootContextParameters.ORIGIN); + Vec3D position = info.getParamOrNull(LootContextParameters.ORIGIN); if (position == null) { - position = info.getContextParameter(LootContextParameters.THIS_ENTITY).getPositionVector(); // Every vanilla context has origin or this_entity, see LootContextParameterSets + position = info.getParamOrNull(LootContextParameters.THIS_ENTITY).position(); // Every vanilla context has origin or this_entity, see LootContextParameterSets } - Location location = new Location(info.getWorld().getWorld(), position.getX(), position.getY(), position.getZ()); + Location location = new Location(info.getLevel().getWorld(), position.x(), position.y(), position.z()); LootContext.Builder contextBuilder = new LootContext.Builder(location); - if (info.hasContextParameter(LootContextParameters.KILLER_ENTITY)) { - CraftEntity killer = info.getContextParameter(LootContextParameters.KILLER_ENTITY).getBukkitEntity(); + if (info.hasParam(LootContextParameters.KILLER_ENTITY)) { + CraftEntity killer = info.getParamOrNull(LootContextParameters.KILLER_ENTITY).getBukkitEntity(); if (killer instanceof CraftHumanEntity) { contextBuilder.killer((CraftHumanEntity) killer); } } - if (info.hasContextParameter(LootContextParameters.THIS_ENTITY)) { - contextBuilder.lootedEntity(info.getContextParameter(LootContextParameters.THIS_ENTITY).getBukkitEntity()); + if (info.hasParam(LootContextParameters.THIS_ENTITY)) { + contextBuilder.lootedEntity(info.getParamOrNull(LootContextParameters.THIS_ENTITY).getBukkitEntity()); } - if (info.hasContextParameter(LootContextParameters.LOOTING_MOD)) { - contextBuilder.lootingModifier(info.getContextParameter(LootContextParameters.LOOTING_MOD)); + if (info.hasParam(LootContextParameters.LOOTING_MOD)) { + contextBuilder.lootingModifier(info.getParamOrNull(LootContextParameters.LOOTING_MOD)); } contextBuilder.luck(info.getLuck()); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java index 9d046f7d98..1a56ad1fc4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java @@ -61,7 +61,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa NBTTagCompound data = getBukkitData(); if (data != null) { - if (data.hasKey("lastKnownName")) { + if (data.contains("lastKnownName")) { return data.getString("lastKnownName"); } } @@ -90,9 +90,9 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } if (value) { - server.getHandle().addOp(profile); + server.getHandle().op(profile); } else { - server.getHandle().removeOp(profile); + server.getHandle().deop(profile); } } @@ -119,15 +119,15 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa @Override public boolean isWhitelisted() { - return server.getHandle().getWhitelist().isWhitelisted(profile); + return server.getHandle().getWhiteList().isWhiteListed(profile); } @Override public void setWhitelisted(boolean value) { if (value) { - server.getHandle().getWhitelist().add(new WhiteListEntry(profile)); + server.getHandle().getWhiteList().add(new WhiteListEntry(profile)); } else { - server.getHandle().getWhitelist().remove(profile); + server.getHandle().getWhiteList().remove(profile); } } @@ -188,8 +188,8 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa NBTTagCompound result = getData(); if (result != null) { - if (!result.hasKey("bukkit")) { - result.set("bukkit", new NBTTagCompound()); + if (!result.contains("bukkit")) { + result.put("bukkit", new NBTTagCompound()); } result = result.getCompound("bukkit"); } @@ -209,7 +209,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa NBTTagCompound data = getBukkitData(); if (data != null) { - if (data.hasKey("firstPlayed")) { + if (data.contains("firstPlayed")) { return data.getLong("firstPlayed"); } else { File file = getDataFile(); @@ -228,7 +228,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa NBTTagCompound data = getBukkitData(); if (data != null) { - if (data.hasKey("lastPlayed")) { + if (data.contains("lastPlayed")) { return data.getLong("lastPlayed"); } else { File file = getDataFile(); @@ -249,7 +249,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa NBTTagCompound data = getData(); if (data == null) return null; - if (data.hasKey("SpawnX") && data.hasKey("SpawnY") && data.hasKey("SpawnZ")) { + if (data.contains("SpawnX") && data.contains("SpawnY") && data.contains("SpawnZ")) { String spawnWorld = data.getString("SpawnWorld"); if (spawnWorld.equals("")) { spawnWorld = server.getWorlds().get(0).getName(); @@ -276,7 +276,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } private ServerStatisticManager getStatisticManager() { - return server.getHandle().getStatisticManager(getUniqueId(), getName()); + return server.getHandle().getPlayerStats(getUniqueId(), getName()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java index 9fcbcc42ab..d85ff7f62d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java @@ -67,7 +67,6 @@ public enum CraftParticle { SNOW_SHOVEL("item_snowball"), SLIME("item_slime"), HEART("heart"), - BARRIER("barrier"), ITEM_CRACK("item"), BLOCK_CRACK("block"), BLOCK_DUST("block"), @@ -108,7 +107,6 @@ public enum CraftParticle { LANDING_OBSIDIAN_TEAR("landing_obsidian_tear"), REVERSE_PORTAL("reverse_portal"), WHITE_ASH("white_ash"), - LIGHT("light"), DUST_COLOR_TRANSITION("dust_color_transition"), VIBRATION("vibration"), FALLING_SPORE_BLOSSOM("falling_spore_blossom"), @@ -125,6 +123,7 @@ public enum CraftParticle { WAX_OFF("wax_off"), ELECTRIC_SPARK("electric_spark"), SCRAPE("scrape"), + BLOCK_MARKER("block_marker"), // ----- Legacy Separator ----- LEGACY_BLOCK_CRACK("block"), LEGACY_BLOCK_DUST("block"), @@ -215,7 +214,7 @@ public enum CraftParticle { } public static Particle toBukkit(net.minecraft.core.particles.ParticleParam nms) { - return toBukkit(nms.getParticle()); + return toBukkit(nms.getType()); } public static Particle toBukkit(net.minecraft.core.particles.Particle nms) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftProfileBanList.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftProfileBanList.java index 250df57007..631281badc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftProfileBanList.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftProfileBanList.java @@ -68,7 +68,7 @@ public class CraftProfileBanList implements org.bukkit.BanList { ImmutableSet.Builder<org.bukkit.BanEntry> builder = ImmutableSet.builder(); for (JsonListEntry entry : list.getValues()) { - GameProfile profile = (GameProfile) entry.getKey(); + GameProfile profile = (GameProfile) entry.getUser(); builder.add(new CraftProfileBanEntry(profile, (GameProfileBanEntry) entry, list)); } @@ -104,6 +104,6 @@ public class CraftProfileBanList implements org.bukkit.BanList { // } - return ((uuid != null) ? MinecraftServer.getServer().getUserCache().getProfile(uuid) : MinecraftServer.getServer().getUserCache().getProfile(target)).orElse(null); + return ((uuid != null) ? MinecraftServer.getServer().getProfileCache().get(uuid) : MinecraftServer.getServer().getProfileCache().get(target)).orElse(null); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRaid.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRaid.java index 3b8ab1a725..7bb2aa00fe 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRaid.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRaid.java @@ -48,7 +48,7 @@ public final class CraftRaid implements Raid { @Override public Location getLocation() { BlockPosition pos = handle.getCenter(); - World world = handle.getWorld(); + World world = handle.getLevel(); return new Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()); } @@ -82,7 +82,7 @@ public final class CraftRaid implements Raid { @Override public float getTotalHealth() { - return handle.sumMobHealth(); + return handle.getHealthOfLivingRaiders(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java index 54e7467d17..da731b601e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java @@ -5,11 +5,12 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; +import java.util.Optional; import java.util.Random; import net.minecraft.core.BlockPosition; import net.minecraft.core.EnumDirection; import net.minecraft.core.IRegistry; -import net.minecraft.data.worldgen.BiomeDecoratorGroups; +import net.minecraft.data.worldgen.features.TreeFeatures; import net.minecraft.world.entity.EntityAreaEffectCloud; import net.minecraft.world.entity.EntityExperienceOrb; import net.minecraft.world.entity.EntityInsentient; @@ -213,7 +214,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor { @Override public Biome getBiome(int x, int y, int z) { - return CraftBlock.biomeBaseToBiome(getHandle().t().d(IRegistry.BIOME_REGISTRY), getHandle().getBiome(x >> 2, y >> 2, z >> 2)); + return CraftBlock.biomeBaseToBiome(getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY), getHandle().getNoiseBiome(x, y, z)); } @Override @@ -224,7 +225,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor { @Override public void setBiome(int x, int y, int z, Biome biome) { Preconditions.checkArgument(biome != Biome.CUSTOM, "Cannot set the biome to %s", biome); - BiomeBase biomeBase = CraftBlock.biomeToBiomeBase(getHandle().t().d(IRegistry.BIOME_REGISTRY), biome); + BiomeBase biomeBase = CraftBlock.biomeToBiomeBase(getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY), biome); setBiome(x, y, z, biomeBase); } @@ -261,7 +262,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor { } private IBlockData getData(int x, int y, int z) { - return getHandle().getType(new BlockPosition(x, y, z)); + return getHandle().getBlockState(new BlockPosition(x, y, z)); } @Override @@ -287,14 +288,14 @@ public abstract class CraftRegionAccessor implements RegionAccessor { @Override public boolean generateTree(Location location, Random random, TreeType treeType) { BlockPosition pos = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - return generateTree(getHandle(), getHandle().getMinecraftWorld().getChunkProvider().generator, pos, random, treeType); + return generateTree(getHandle(), getHandle().getMinecraftWorld().getChunkSource().getGenerator(), pos, random, treeType); } @Override public boolean generateTree(Location location, Random random, TreeType treeType, Consumer<BlockState> consumer) { BlockPosition pos = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()); BlockStateListPopulator populator = new BlockStateListPopulator(getHandle()); - boolean result = generateTree(populator, getHandle().getMinecraftWorld().getChunkProvider().generator, pos, random, treeType); + boolean result = generateTree(populator, getHandle().getMinecraftWorld().getChunkSource().getGenerator(), pos, random, treeType); populator.refreshTiles(); for (BlockState blockState : populator.getList()) { @@ -311,69 +312,69 @@ public abstract class CraftRegionAccessor implements RegionAccessor { net.minecraft.world.level.levelgen.feature.WorldGenFeatureConfigured gen; switch (treeType) { case BIG_TREE: - gen = BiomeDecoratorGroups.FANCY_OAK; + gen = TreeFeatures.FANCY_OAK; break; case BIRCH: - gen = BiomeDecoratorGroups.BIRCH; + gen = TreeFeatures.BIRCH; break; case REDWOOD: - gen = BiomeDecoratorGroups.SPRUCE; + gen = TreeFeatures.SPRUCE; break; case TALL_REDWOOD: - gen = BiomeDecoratorGroups.PINE; + gen = TreeFeatures.PINE; break; case JUNGLE: - gen = BiomeDecoratorGroups.MEGA_JUNGLE_TREE; + gen = TreeFeatures.MEGA_JUNGLE_TREE; break; case SMALL_JUNGLE: - gen = BiomeDecoratorGroups.JUNGLE_TREE_NO_VINE; + gen = TreeFeatures.JUNGLE_TREE_NO_VINE; break; case COCOA_TREE: - gen = BiomeDecoratorGroups.JUNGLE_TREE; + gen = TreeFeatures.JUNGLE_TREE; break; case JUNGLE_BUSH: - gen = BiomeDecoratorGroups.JUNGLE_BUSH; + gen = TreeFeatures.JUNGLE_BUSH; break; case RED_MUSHROOM: - gen = BiomeDecoratorGroups.HUGE_RED_MUSHROOM; + gen = TreeFeatures.HUGE_RED_MUSHROOM; break; case BROWN_MUSHROOM: - gen = BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM; + gen = TreeFeatures.HUGE_BROWN_MUSHROOM; break; case SWAMP: - gen = BiomeDecoratorGroups.SWAMP_OAK; + gen = TreeFeatures.SWAMP_OAK; break; case ACACIA: - gen = BiomeDecoratorGroups.ACACIA; + gen = TreeFeatures.ACACIA; break; case DARK_OAK: - gen = BiomeDecoratorGroups.DARK_OAK; + gen = TreeFeatures.DARK_OAK; break; case MEGA_REDWOOD: - gen = BiomeDecoratorGroups.MEGA_PINE; + gen = TreeFeatures.MEGA_PINE; break; case TALL_BIRCH: - gen = BiomeDecoratorGroups.SUPER_BIRCH_BEES_0002; + gen = TreeFeatures.SUPER_BIRCH_BEES_0002; break; case CHORUS_PLANT: - ((BlockChorusFlower) Blocks.CHORUS_FLOWER).a(access, pos, random, 8); + ((BlockChorusFlower) Blocks.CHORUS_FLOWER).generatePlant(access, pos, random, 8); return true; case CRIMSON_FUNGUS: - gen = BiomeDecoratorGroups.CRIMSON_FUNGI_PLANTED; + gen = TreeFeatures.CRIMSON_FUNGUS_PLANTED; break; case WARPED_FUNGUS: - gen = BiomeDecoratorGroups.WARPED_FUNGI_PLANTED; + gen = TreeFeatures.WARPED_FUNGUS_PLANTED; break; case AZALEA: - gen = BiomeDecoratorGroups.AZALEA_TREE; + gen = TreeFeatures.AZALEA_TREE; break; case TREE: default: - gen = BiomeDecoratorGroups.OAK; + gen = TreeFeatures.OAK; break; } - return gen.feature.generate(new FeaturePlaceContext(access, chunkGenerator, random, pos, gen.config)); + return gen.feature.place(new FeaturePlaceContext(Optional.empty(), access, chunkGenerator, random, pos, gen.config)); } @Override @@ -503,7 +504,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor { Preconditions.checkArgument(entity != null, "Cannot spawn null entity"); if (randomizeData && entity instanceof EntityInsentient) { - ((EntityInsentient) entity).prepare(getHandle(), getHandle().getDamageScaler(entity.getChunkCoordinates()), EnumMobSpawn.COMMAND, (GroupDataEntity) null, null); + ((EntityInsentient) entity).finalizeSpawn(getHandle(), getHandle().getCurrentDifficultyAt(entity.blockPosition()), EnumMobSpawn.COMMAND, (GroupDataEntity) null, null); } if (!isNormalWorld()) { @@ -543,9 +544,9 @@ public abstract class CraftRegionAccessor implements RegionAccessor { // order is important for some of these if (Boat.class.isAssignableFrom(clazz)) { entity = new EntityBoat(world, x, y, z); - entity.setPositionRotation(x, y, z, yaw, pitch); + entity.moveTo(x, y, z, yaw, pitch); } else if (FallingBlock.class.isAssignableFrom(clazz)) { - entity = new EntityFallingBlock(world, x, y, z, getHandle().getType(new BlockPosition(x, y, z))); + entity = new EntityFallingBlock(world, x, y, z, getHandle().getBlockState(new BlockPosition(x, y, z))); } else if (Projectile.class.isAssignableFrom(clazz)) { if (Snowball.class.isAssignableFrom(clazz)) { entity = new EntitySnowball(world, x, y, z); @@ -553,22 +554,22 @@ public abstract class CraftRegionAccessor implements RegionAccessor { entity = new EntityEgg(world, x, y, z); } else if (AbstractArrow.class.isAssignableFrom(clazz)) { if (TippedArrow.class.isAssignableFrom(clazz)) { - entity = EntityTypes.ARROW.a(world); - ((EntityTippedArrow) entity).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false))); + entity = EntityTypes.ARROW.create(world); + ((EntityTippedArrow) entity).setPotionType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false))); } else if (SpectralArrow.class.isAssignableFrom(clazz)) { - entity = EntityTypes.SPECTRAL_ARROW.a(world); + entity = EntityTypes.SPECTRAL_ARROW.create(world); } else if (Trident.class.isAssignableFrom(clazz)) { - entity = EntityTypes.TRIDENT.a(world); + entity = EntityTypes.TRIDENT.create(world); } else { - entity = EntityTypes.ARROW.a(world); + entity = EntityTypes.ARROW.create(world); } - entity.setPositionRotation(x, y, z, 0, 0); + entity.moveTo(x, y, z, 0, 0); } else if (ThrownExpBottle.class.isAssignableFrom(clazz)) { - entity = EntityTypes.EXPERIENCE_BOTTLE.a(world); - entity.setPositionRotation(x, y, z, 0, 0); + entity = EntityTypes.EXPERIENCE_BOTTLE.create(world); + entity.moveTo(x, y, z, 0, 0); } else if (EnderPearl.class.isAssignableFrom(clazz)) { - entity = EntityTypes.ENDER_PEARL.a(world); - entity.setPositionRotation(x, y, z, 0, 0); + entity = EntityTypes.ENDER_PEARL.create(world); + entity.moveTo(x, y, z, 0, 0); } else if (ThrownPotion.class.isAssignableFrom(clazz)) { if (LingeringPotion.class.isAssignableFrom(clazz)) { entity = new EntityPotion(world, x, y, z); @@ -579,23 +580,23 @@ public abstract class CraftRegionAccessor implements RegionAccessor { } } else if (Fireball.class.isAssignableFrom(clazz)) { if (SmallFireball.class.isAssignableFrom(clazz)) { - entity = EntityTypes.SMALL_FIREBALL.a(world); + entity = EntityTypes.SMALL_FIREBALL.create(world); } else if (WitherSkull.class.isAssignableFrom(clazz)) { - entity = EntityTypes.WITHER_SKULL.a(world); + entity = EntityTypes.WITHER_SKULL.create(world); } else if (DragonFireball.class.isAssignableFrom(clazz)) { - entity = EntityTypes.DRAGON_FIREBALL.a(world); + entity = EntityTypes.DRAGON_FIREBALL.create(world); } else { - entity = EntityTypes.FIREBALL.a(world); + entity = EntityTypes.FIREBALL.create(world); } - entity.setPositionRotation(x, y, z, yaw, pitch); + entity.moveTo(x, y, z, yaw, pitch); Vector direction = location.getDirection().multiply(10); ((EntityFireball) entity).setDirection(direction.getX(), direction.getY(), direction.getZ()); } else if (ShulkerBullet.class.isAssignableFrom(clazz)) { - entity = EntityTypes.SHULKER_BULLET.a(world); - entity.setPositionRotation(x, y, z, yaw, pitch); + entity = EntityTypes.SHULKER_BULLET.create(world); + entity.moveTo(x, y, z, yaw, pitch); } else if (LlamaSpit.class.isAssignableFrom(clazz)) { - entity = EntityTypes.LLAMA_SPIT.a(world); - entity.setPositionRotation(x, y, z, yaw, pitch); + entity = EntityTypes.LLAMA_SPIT.create(world); + entity.moveTo(x, y, z, yaw, pitch); } else if (Firework.class.isAssignableFrom(clazz)) { entity = new EntityFireworks(world, x, y, z, net.minecraft.world.item.ItemStack.EMPTY); } @@ -618,204 +619,204 @@ public abstract class CraftRegionAccessor implements RegionAccessor { } else if (EnderSignal.class.isAssignableFrom(clazz)) { entity = new EntityEnderSignal(world, x, y, z); } else if (EnderCrystal.class.isAssignableFrom(clazz)) { - entity = EntityTypes.END_CRYSTAL.a(world); - entity.setPositionRotation(x, y, z, 0, 0); + entity = EntityTypes.END_CRYSTAL.create(world); + entity.moveTo(x, y, z, 0, 0); } else if (LivingEntity.class.isAssignableFrom(clazz)) { if (Chicken.class.isAssignableFrom(clazz)) { - entity = EntityTypes.CHICKEN.a(world); + entity = EntityTypes.CHICKEN.create(world); } else if (Cow.class.isAssignableFrom(clazz)) { if (MushroomCow.class.isAssignableFrom(clazz)) { - entity = EntityTypes.MOOSHROOM.a(world); + entity = EntityTypes.MOOSHROOM.create(world); } else { - entity = EntityTypes.COW.a(world); + entity = EntityTypes.COW.create(world); } } else if (Golem.class.isAssignableFrom(clazz)) { if (Snowman.class.isAssignableFrom(clazz)) { - entity = EntityTypes.SNOW_GOLEM.a(world); + entity = EntityTypes.SNOW_GOLEM.create(world); } else if (IronGolem.class.isAssignableFrom(clazz)) { - entity = EntityTypes.IRON_GOLEM.a(world); + entity = EntityTypes.IRON_GOLEM.create(world); } else if (Shulker.class.isAssignableFrom(clazz)) { - entity = EntityTypes.SHULKER.a(world); + entity = EntityTypes.SHULKER.create(world); } } else if (Creeper.class.isAssignableFrom(clazz)) { - entity = EntityTypes.CREEPER.a(world); + entity = EntityTypes.CREEPER.create(world); } else if (Ghast.class.isAssignableFrom(clazz)) { - entity = EntityTypes.GHAST.a(world); + entity = EntityTypes.GHAST.create(world); } else if (Pig.class.isAssignableFrom(clazz)) { - entity = EntityTypes.PIG.a(world); + entity = EntityTypes.PIG.create(world); } else if (Player.class.isAssignableFrom(clazz)) { // need a net server handler for this one } else if (Sheep.class.isAssignableFrom(clazz)) { - entity = EntityTypes.SHEEP.a(world); + entity = EntityTypes.SHEEP.create(world); } else if (AbstractHorse.class.isAssignableFrom(clazz)) { if (ChestedHorse.class.isAssignableFrom(clazz)) { if (Donkey.class.isAssignableFrom(clazz)) { - entity = EntityTypes.DONKEY.a(world); + entity = EntityTypes.DONKEY.create(world); } else if (Mule.class.isAssignableFrom(clazz)) { - entity = EntityTypes.MULE.a(world); + entity = EntityTypes.MULE.create(world); } else if (Llama.class.isAssignableFrom(clazz)) { if (TraderLlama.class.isAssignableFrom(clazz)) { - entity = EntityTypes.TRADER_LLAMA.a(world); + entity = EntityTypes.TRADER_LLAMA.create(world); } else { - entity = EntityTypes.LLAMA.a(world); + entity = EntityTypes.LLAMA.create(world); } } } else if (SkeletonHorse.class.isAssignableFrom(clazz)) { - entity = EntityTypes.SKELETON_HORSE.a(world); + entity = EntityTypes.SKELETON_HORSE.create(world); } else if (ZombieHorse.class.isAssignableFrom(clazz)) { - entity = EntityTypes.ZOMBIE_HORSE.a(world); + entity = EntityTypes.ZOMBIE_HORSE.create(world); } else { - entity = EntityTypes.HORSE.a(world); + entity = EntityTypes.HORSE.create(world); } } else if (AbstractSkeleton.class.isAssignableFrom(clazz)) { if (Stray.class.isAssignableFrom(clazz)) { - entity = EntityTypes.STRAY.a(world); + entity = EntityTypes.STRAY.create(world); } else if (WitherSkeleton.class.isAssignableFrom(clazz)) { - entity = EntityTypes.WITHER_SKELETON.a(world); + entity = EntityTypes.WITHER_SKELETON.create(world); } else if (Skeleton.class.isAssignableFrom(clazz)) { - entity = EntityTypes.SKELETON.a(world); + entity = EntityTypes.SKELETON.create(world); } } else if (Slime.class.isAssignableFrom(clazz)) { if (MagmaCube.class.isAssignableFrom(clazz)) { - entity = EntityTypes.MAGMA_CUBE.a(world); + entity = EntityTypes.MAGMA_CUBE.create(world); } else { - entity = EntityTypes.SLIME.a(world); + entity = EntityTypes.SLIME.create(world); } } else if (Spider.class.isAssignableFrom(clazz)) { if (CaveSpider.class.isAssignableFrom(clazz)) { - entity = EntityTypes.CAVE_SPIDER.a(world); + entity = EntityTypes.CAVE_SPIDER.create(world); } else { - entity = EntityTypes.SPIDER.a(world); + entity = EntityTypes.SPIDER.create(world); } } else if (Squid.class.isAssignableFrom(clazz)) { if (GlowSquid.class.isAssignableFrom(clazz)) { - entity = EntityTypes.GLOW_SQUID.a(world); + entity = EntityTypes.GLOW_SQUID.create(world); } else { - entity = EntityTypes.SQUID.a(world); + entity = EntityTypes.SQUID.create(world); } } else if (Tameable.class.isAssignableFrom(clazz)) { if (Wolf.class.isAssignableFrom(clazz)) { - entity = EntityTypes.WOLF.a(world); + entity = EntityTypes.WOLF.create(world); } else if (Parrot.class.isAssignableFrom(clazz)) { - entity = EntityTypes.PARROT.a(world); + entity = EntityTypes.PARROT.create(world); } else if (Cat.class.isAssignableFrom(clazz)) { - entity = EntityTypes.CAT.a(world); + entity = EntityTypes.CAT.create(world); } } else if (PigZombie.class.isAssignableFrom(clazz)) { - entity = EntityTypes.ZOMBIFIED_PIGLIN.a(world); + entity = EntityTypes.ZOMBIFIED_PIGLIN.create(world); } else if (Zombie.class.isAssignableFrom(clazz)) { if (Husk.class.isAssignableFrom(clazz)) { - entity = EntityTypes.HUSK.a(world); + entity = EntityTypes.HUSK.create(world); } else if (ZombieVillager.class.isAssignableFrom(clazz)) { - entity = EntityTypes.ZOMBIE_VILLAGER.a(world); + entity = EntityTypes.ZOMBIE_VILLAGER.create(world); } else if (Drowned.class.isAssignableFrom(clazz)) { - entity = EntityTypes.DROWNED.a(world); + entity = EntityTypes.DROWNED.create(world); } else { entity = new EntityZombie(world); } } else if (Giant.class.isAssignableFrom(clazz)) { - entity = EntityTypes.GIANT.a(world); + entity = EntityTypes.GIANT.create(world); } else if (Silverfish.class.isAssignableFrom(clazz)) { - entity = EntityTypes.SILVERFISH.a(world); + entity = EntityTypes.SILVERFISH.create(world); } else if (Enderman.class.isAssignableFrom(clazz)) { - entity = EntityTypes.ENDERMAN.a(world); + entity = EntityTypes.ENDERMAN.create(world); } else if (Blaze.class.isAssignableFrom(clazz)) { - entity = EntityTypes.BLAZE.a(world); + entity = EntityTypes.BLAZE.create(world); } else if (AbstractVillager.class.isAssignableFrom(clazz)) { if (Villager.class.isAssignableFrom(clazz)) { - entity = EntityTypes.VILLAGER.a(world); + entity = EntityTypes.VILLAGER.create(world); } else if (WanderingTrader.class.isAssignableFrom(clazz)) { - entity = EntityTypes.WANDERING_TRADER.a(world); + entity = EntityTypes.WANDERING_TRADER.create(world); } } else if (Witch.class.isAssignableFrom(clazz)) { - entity = EntityTypes.WITCH.a(world); + entity = EntityTypes.WITCH.create(world); } else if (Wither.class.isAssignableFrom(clazz)) { - entity = EntityTypes.WITHER.a(world); + entity = EntityTypes.WITHER.create(world); } else if (ComplexLivingEntity.class.isAssignableFrom(clazz)) { if (EnderDragon.class.isAssignableFrom(clazz)) { if (isNormalWorld()) { - entity = EntityTypes.ENDER_DRAGON.a(getHandle().getMinecraftWorld()); + entity = EntityTypes.ENDER_DRAGON.create(getHandle().getMinecraftWorld()); } else { throw new IllegalArgumentException("Cannot spawn entity " + clazz.getName() + " during world generation"); } } } else if (Ambient.class.isAssignableFrom(clazz)) { if (Bat.class.isAssignableFrom(clazz)) { - entity = EntityTypes.BAT.a(world); + entity = EntityTypes.BAT.create(world); } } else if (Rabbit.class.isAssignableFrom(clazz)) { - entity = EntityTypes.RABBIT.a(world); + entity = EntityTypes.RABBIT.create(world); } else if (Endermite.class.isAssignableFrom(clazz)) { - entity = EntityTypes.ENDERMITE.a(world); + entity = EntityTypes.ENDERMITE.create(world); } else if (Guardian.class.isAssignableFrom(clazz)) { if (ElderGuardian.class.isAssignableFrom(clazz)) { - entity = EntityTypes.ELDER_GUARDIAN.a(world); + entity = EntityTypes.ELDER_GUARDIAN.create(world); } else { - entity = EntityTypes.GUARDIAN.a(world); + entity = EntityTypes.GUARDIAN.create(world); } } else if (ArmorStand.class.isAssignableFrom(clazz)) { entity = new EntityArmorStand(world, x, y, z); } else if (PolarBear.class.isAssignableFrom(clazz)) { - entity = EntityTypes.POLAR_BEAR.a(world); + entity = EntityTypes.POLAR_BEAR.create(world); } else if (Vex.class.isAssignableFrom(clazz)) { - entity = EntityTypes.VEX.a(world); + entity = EntityTypes.VEX.create(world); } else if (Illager.class.isAssignableFrom(clazz)) { if (Spellcaster.class.isAssignableFrom(clazz)) { if (Evoker.class.isAssignableFrom(clazz)) { - entity = EntityTypes.EVOKER.a(world); + entity = EntityTypes.EVOKER.create(world); } else if (Illusioner.class.isAssignableFrom(clazz)) { - entity = EntityTypes.ILLUSIONER.a(world); + entity = EntityTypes.ILLUSIONER.create(world); } } else if (Vindicator.class.isAssignableFrom(clazz)) { - entity = EntityTypes.VINDICATOR.a(world); + entity = EntityTypes.VINDICATOR.create(world); } else if (Pillager.class.isAssignableFrom(clazz)) { - entity = EntityTypes.PILLAGER.a(world); + entity = EntityTypes.PILLAGER.create(world); } } else if (Turtle.class.isAssignableFrom(clazz)) { - entity = EntityTypes.TURTLE.a(world); + entity = EntityTypes.TURTLE.create(world); } else if (Phantom.class.isAssignableFrom(clazz)) { - entity = EntityTypes.PHANTOM.a(world); + entity = EntityTypes.PHANTOM.create(world); } else if (Fish.class.isAssignableFrom(clazz)) { if (Cod.class.isAssignableFrom(clazz)) { - entity = EntityTypes.COD.a(world); + entity = EntityTypes.COD.create(world); } else if (PufferFish.class.isAssignableFrom(clazz)) { - entity = EntityTypes.PUFFERFISH.a(world); + entity = EntityTypes.PUFFERFISH.create(world); } else if (Salmon.class.isAssignableFrom(clazz)) { - entity = EntityTypes.SALMON.a(world); + entity = EntityTypes.SALMON.create(world); } else if (TropicalFish.class.isAssignableFrom(clazz)) { - entity = EntityTypes.TROPICAL_FISH.a(world); + entity = EntityTypes.TROPICAL_FISH.create(world); } } else if (Dolphin.class.isAssignableFrom(clazz)) { - entity = EntityTypes.DOLPHIN.a(world); + entity = EntityTypes.DOLPHIN.create(world); } else if (Ocelot.class.isAssignableFrom(clazz)) { - entity = EntityTypes.OCELOT.a(world); + entity = EntityTypes.OCELOT.create(world); } else if (Ravager.class.isAssignableFrom(clazz)) { - entity = EntityTypes.RAVAGER.a(world); + entity = EntityTypes.RAVAGER.create(world); } else if (Panda.class.isAssignableFrom(clazz)) { - entity = EntityTypes.PANDA.a(world); + entity = EntityTypes.PANDA.create(world); } else if (Fox.class.isAssignableFrom(clazz)) { - entity = EntityTypes.FOX.a(world); + entity = EntityTypes.FOX.create(world); } else if (Bee.class.isAssignableFrom(clazz)) { - entity = EntityTypes.BEE.a(world); + entity = EntityTypes.BEE.create(world); } else if (Hoglin.class.isAssignableFrom(clazz)) { - entity = EntityTypes.HOGLIN.a(world); + entity = EntityTypes.HOGLIN.create(world); } else if (Piglin.class.isAssignableFrom(clazz)) { - entity = EntityTypes.PIGLIN.a(world); + entity = EntityTypes.PIGLIN.create(world); } else if (PiglinBrute.class.isAssignableFrom(clazz)) { - entity = EntityTypes.PIGLIN_BRUTE.a(world); + entity = EntityTypes.PIGLIN_BRUTE.create(world); } else if (Strider.class.isAssignableFrom(clazz)) { - entity = EntityTypes.STRIDER.a(world); + entity = EntityTypes.STRIDER.create(world); } else if (Zoglin.class.isAssignableFrom(clazz)) { - entity = EntityTypes.ZOGLIN.a(world); + entity = EntityTypes.ZOGLIN.create(world); } else if (Axolotl.class.isAssignableFrom(clazz)) { - entity = EntityTypes.AXOLOTL.a(world); + entity = EntityTypes.AXOLOTL.create(world); } else if (Goat.class.isAssignableFrom(clazz)) { - entity = EntityTypes.GOAT.a(world); + entity = EntityTypes.GOAT.create(world); } if (entity != null) { - entity.setLocation(x, y, z, yaw, pitch); - entity.setHeadRotation(yaw); // SPIGOT-3587 + entity.absMoveTo(x, y, z, yaw, pitch); + entity.setYHeadRot(yaw); // SPIGOT-3587 } } else if (Hanging.class.isAssignableFrom(clazz)) { if (LeashHitch.class.isAssignableFrom(clazz)) { @@ -836,12 +837,12 @@ public abstract class CraftRegionAccessor implements RegionAccessor { final BlockPosition pos = new BlockPosition(x, y, z); for (BlockFace dir : faces) { - IBlockData nmsBlock = getHandle().getType(pos.shift(CraftBlock.blockFaceToNotch(dir))); - if (nmsBlock.getMaterial().isBuildable() || BlockDiodeAbstract.isDiode(nmsBlock)) { + IBlockData nmsBlock = getHandle().getBlockState(pos.relative(CraftBlock.blockFaceToNotch(dir))); + if (nmsBlock.getMaterial().isSolid() || BlockDiodeAbstract.isDiode(nmsBlock)) { boolean taken = false; AxisAlignedBB bb = (ItemFrame.class.isAssignableFrom(clazz)) - ? EntityItemFrame.calculateBoundingBox(null, pos, CraftBlock.blockFaceToNotch(dir).opposite(), width, height) - : EntityHanging.calculateBoundingBox(null, pos, CraftBlock.blockFaceToNotch(dir).opposite(), width, height); + ? EntityItemFrame.calculateBoundingBox(null, pos, CraftBlock.blockFaceToNotch(dir).getOpposite(), width, height) + : EntityHanging.calculateBoundingBox(null, pos, CraftBlock.blockFaceToNotch(dir).getOpposite(), width, height); List<net.minecraft.world.entity.Entity> list = (List<net.minecraft.world.entity.Entity>) getHandle().getEntities(null, bb); for (Iterator<net.minecraft.world.entity.Entity> it = list.iterator(); !taken && it.hasNext(); ) { net.minecraft.world.entity.Entity e = it.next(); @@ -864,13 +865,13 @@ public abstract class CraftRegionAccessor implements RegionAccessor { randomizeData = false; // Don't randomize if no valid face is found, prevents null painting } - EnumDirection dir = CraftBlock.blockFaceToNotch(face).opposite(); + EnumDirection dir = CraftBlock.blockFaceToNotch(face).getOpposite(); if (Painting.class.isAssignableFrom(clazz)) { if (isNormalWorld() && randomizeData) { entity = new EntityPainting(getHandle().getMinecraftWorld(), new BlockPosition(x, y, z), dir); } else { entity = new EntityPainting(EntityTypes.PAINTING, getHandle().getMinecraftWorld()); - entity.setLocation(x, y, z, yaw, pitch); + entity.absMoveTo(x, y, z, yaw, pitch); ((EntityPainting) entity).setDirection(dir); } } else if (ItemFrame.class.isAssignableFrom(clazz)) { @@ -886,15 +887,15 @@ public abstract class CraftRegionAccessor implements RegionAccessor { } else if (ExperienceOrb.class.isAssignableFrom(clazz)) { entity = new EntityExperienceOrb(world, x, y, z, 0); } else if (LightningStrike.class.isAssignableFrom(clazz)) { - entity = EntityTypes.LIGHTNING_BOLT.a(world); - entity.teleportAndSync(location.getX(), location.getY(), location.getZ()); + entity = EntityTypes.LIGHTNING_BOLT.create(world); + entity.moveTo(location.getX(), location.getY(), location.getZ()); } else if (AreaEffectCloud.class.isAssignableFrom(clazz)) { entity = new EntityAreaEffectCloud(world, x, y, z); } else if (EvokerFangs.class.isAssignableFrom(clazz)) { entity = new EntityEvokerFangs(world, x, y, z, (float) Math.toRadians(yaw), 0, null); } else if (Marker.class.isAssignableFrom(clazz)) { - entity = EntityTypes.MARKER.a(world); - entity.setPosition(x, y, z); + entity = EntityTypes.MARKER.create(world); + entity.setPos(x, y, z); } if (entity != null) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 26a63be2a4..38b227d3fe 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -46,6 +46,7 @@ import java.util.UUID; import java.util.function.Consumer; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.stream.Collectors; import javax.imageio.ImageIO; import jline.console.ConsoleReader; import net.minecraft.advancements.Advancement; @@ -71,8 +72,12 @@ import net.minecraft.server.dedicated.DedicatedServerSettings; import net.minecraft.server.level.EntityPlayer; import net.minecraft.server.level.TicketType; import net.minecraft.server.level.WorldServer; +import net.minecraft.server.players.GameProfileBanEntry; +import net.minecraft.server.players.IpBanEntry; import net.minecraft.server.players.JsonListEntry; +import net.minecraft.server.players.OpListEntry; import net.minecraft.server.players.PlayerList; +import net.minecraft.server.players.WhiteListEntry; import net.minecraft.tags.Tags; import net.minecraft.tags.TagsBlock; import net.minecraft.tags.TagsEntity; @@ -301,7 +306,7 @@ public final class CraftServer implements Server { } })); this.serverVersion = CraftServer.class.getPackage().getImplementationVersion(); - this.structureManager = new CraftStructureManager(console.getDefinedStructureManager()); + this.structureManager = new CraftStructureManager(console.getStructureManager()); Bukkit.setServer(this); @@ -453,7 +458,7 @@ public final class CraftServer implements Server { CommandDispatcher dispatcher = console.vanillaCommandDispatcher; // Build a list of all Vanilla commands and create wrappers - for (CommandNode<CommandListenerWrapper> cmd : dispatcher.a().getRoot().getChildren()) { + for (CommandNode<CommandListenerWrapper> cmd : dispatcher.getDispatcher().getRoot().getChildren()) { commandMap.register("minecraft", new VanillaCommandWrapper(dispatcher, cmd)); } } @@ -478,15 +483,15 @@ public final class CraftServer implements Server { node = clone; } - dispatcher.a().getRoot().addChild(node); + dispatcher.getDispatcher().getRoot().addChild(node); } else { - new BukkitCommandWrapper(this, entry.getValue()).register(dispatcher.a(), label); + new BukkitCommandWrapper(this, entry.getValue()).register(dispatcher.getDispatcher(), label); } } // Refresh commands for (EntityPlayer player : getHandle().players) { - dispatcher.a(player); + dispatcher.sendCommands(player); } } @@ -516,7 +521,7 @@ public final class CraftServer implements Server { @Override public String getVersion() { - return serverVersion + " (MC: " + console.getVersion() + ")"; + return serverVersion + " (MC: " + console.getServerVersion() + ")"; } @Override @@ -560,7 +565,7 @@ public final class CraftServer implements Server { public Player getPlayerExact(String name) { Validate.notNull(name, "Name cannot be null"); - EntityPlayer player = playerList.getPlayer(name); + EntityPlayer player = playerList.getPlayerByName(name); return (player != null) ? player.getBukkitEntity() : null; } @@ -622,9 +627,14 @@ public final class CraftServer implements Server { return this.getProperties().viewDistance; } + @Override + public int getSimulationDistance() { + return this.getProperties().simulationDistance; + } + @Override public String getIp() { - return this.getServer().getServerIp(); + return this.getServer().getLocalIp(); } @Override @@ -634,7 +644,7 @@ public final class CraftServer implements Server { @Override public boolean getGenerateStructures() { - return this.getProperties().a(this.getServer().getCustomRegistry()).shouldGenerateMapFeatures(); + return this.getProperties().getWorldGenSettings(this.getServer().registryAccess()).generateFeatures(); } @Override @@ -649,7 +659,7 @@ public final class CraftServer implements Server { @Override public boolean getAllowNether() { - return this.getServer().getAllowNether(); + return this.getServer().isNetherEnabled(); } public boolean getWarnOnOverload() { @@ -667,7 +677,7 @@ public final class CraftServer implements Server { // NOTE: Temporary calls through to server.properies until its replaced private DedicatedServerProperties getProperties() { - return this.console.getDedicatedServerProperties(); + return this.console.getProperties(); } // End Temporary calls @@ -788,8 +798,8 @@ public final class CraftServer implements Server { console.settings = new DedicatedServerSettings(console.options); DedicatedServerProperties config = console.settings.getProperties(); - console.setPVP(config.pvp); - console.setAllowFlight(config.allowFlight); + console.setPvpAllowed(config.pvp); + console.setFlightAllowed(config.allowFlight); console.setMotd(config.motd); monsterSpawn = configuration.getInt("spawn-limits.monsters"); animalSpawn = configuration.getInt("spawn-limits.animals"); @@ -805,19 +815,19 @@ public final class CraftServer implements Server { loadIcon(); try { - playerList.getIPBans().load(); + playerList.getIpBans().load(); } catch (IOException ex) { logger.log(Level.WARNING, "Failed to load banned-ips.json, " + ex.getMessage()); } try { - playerList.getProfileBans().load(); + playerList.getBans().load(); } catch (IOException ex) { logger.log(Level.WARNING, "Failed to load banned-players.json, " + ex.getMessage()); } - for (WorldServer world : console.getWorlds()) { + for (WorldServer world : console.getAllLevels()) { world.serverLevelData.setDifficulty(config.difficulty); - world.setSpawnFlags(config.spawnMonsters, config.spawnAnimals); + world.setSpawnSettings(config.spawnMonsters, config.spawnAnimals); if (this.getTicksPerAnimalSpawns() < 0) { world.ticksPerAnimalSpawns = 400; } else { @@ -953,7 +963,7 @@ public final class CraftServer implements Server { @Override public String toString() { - return "CraftServer{" + "serverName=" + serverName + ",serverVersion=" + serverVersion + ",minecraftVersion=" + console.getVersion() + '}'; + return "CraftServer{" + "serverName=" + serverName + ",serverVersion=" + serverVersion + ",minecraftVersion=" + console.getServerVersion() + '}'; } public World createWorld(String name, World.Environment environment) { @@ -1016,16 +1026,15 @@ public final class CraftServer implements Server { Convertable.ConversionSession worldSession; try { - worldSession = Convertable.a(getWorldContainer().toPath()).c(name, actualDimension); + worldSession = Convertable.createDefault(getWorldContainer().toPath()).createAccess(name, actualDimension); } catch (IOException ex) { throw new RuntimeException(ex); } - MinecraftServer.convertWorld(worldSession); // Run conversion now boolean hardcore = creator.hardcore(); - RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.INSTANCE, console.resources.i(), console.registryHolder); - WorldDataServer worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, console.datapackconfiguration); + RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.createAndLoad(DynamicOpsNBT.INSTANCE, console.resources.getResourceManager(), console.registryHolder); + WorldDataServer worlddata = (WorldDataServer) worldSession.getDataTag(registryreadops, console.datapackconfiguration); WorldSettings worldSettings; // See MinecraftServer.a(String, String, long, WorldType, JsonElement) @@ -1036,34 +1045,32 @@ public final class CraftServer implements Server { properties.put("generate-structures", Objects.toString(creator.generateStructures())); properties.put("level-type", Objects.toString(creator.type().getName())); - GeneratorSettings generatorsettings = GeneratorSettings.a(console.getCustomRegistry(), properties); - worldSettings = new WorldSettings(name, EnumGamemode.getById(getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), console.datapackconfiguration); + GeneratorSettings generatorsettings = GeneratorSettings.create(console.registryAccess(), properties); + worldSettings = new WorldSettings(name, EnumGamemode.byId(getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), console.datapackconfiguration); worlddata = new WorldDataServer(worldSettings, generatorsettings, Lifecycle.stable()); } worlddata.checkName(name); - worlddata.a(console.getServerModName(), console.getModded().isPresent()); + worlddata.setModdedInfo(console.getServerModName(), console.getModdedStatus().shouldReportAsModified()); if (console.options.has("forceUpgrade")) { - net.minecraft.server.Main.convertWorld(worldSession, DataConverterRegistry.a(), console.options.has("eraseCache"), () -> { + net.minecraft.server.Main.forceUpgrade(worldSession, DataConverterRegistry.getDataFixer(), console.options.has("eraseCache"), () -> { return true; - }, worlddata.getGeneratorSettings().d().d().stream().map((entry) -> { - return ResourceKey.a(IRegistry.DIMENSION_TYPE_REGISTRY, ((ResourceKey) entry.getKey()).a()); - }).collect(ImmutableSet.toImmutableSet())); + }, worlddata.worldGenSettings()); } - long j = BiomeManager.a(creator.seed()); + long j = BiomeManager.obfuscateSeed(creator.seed()); List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(worlddata)); - RegistryMaterials<WorldDimension> registrymaterials = worlddata.getGeneratorSettings().d(); - WorldDimension worlddimension = (WorldDimension) registrymaterials.a(actualDimension); + RegistryMaterials<WorldDimension> registrymaterials = worlddata.worldGenSettings().dimensions(); + WorldDimension worlddimension = (WorldDimension) registrymaterials.get(actualDimension); DimensionManager dimensionmanager; net.minecraft.world.level.chunk.ChunkGenerator chunkgenerator; if (worlddimension == null) { - dimensionmanager = (DimensionManager) console.registryHolder.d(IRegistry.DIMENSION_TYPE_REGISTRY).d(DimensionManager.OVERWORLD_LOCATION); - chunkgenerator = GeneratorSettings.a(console.registryHolder.d(IRegistry.BIOME_REGISTRY), console.registryHolder.d(IRegistry.NOISE_GENERATOR_SETTINGS_REGISTRY), (new Random()).nextLong()); + dimensionmanager = (DimensionManager) console.registryHolder.registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrThrow(DimensionManager.OVERWORLD_LOCATION); + chunkgenerator = GeneratorSettings.makeDefaultOverworld(console.registryHolder, (new Random()).nextLong()); } else { - dimensionmanager = worlddimension.b(); - chunkgenerator = worlddimension.c(); + dimensionmanager = worlddimension.type(); + chunkgenerator = worlddimension.generator(); } WorldInfo worldInfo = new CraftWorldInfo(worlddata, worldSession, creator.environment(), dimensionmanager); @@ -1072,35 +1079,35 @@ public final class CraftServer implements Server { } if (biomeProvider != null) { - WorldChunkManager worldChunkManager = new CustomWorldChunkManager(worldInfo, biomeProvider, console.registryHolder.b(IRegistry.BIOME_REGISTRY)); + WorldChunkManager worldChunkManager = new CustomWorldChunkManager(worldInfo, biomeProvider, console.registryHolder.ownedRegistryOrThrow(IRegistry.BIOME_REGISTRY)); if (chunkgenerator instanceof ChunkGeneratorAbstract) { - chunkgenerator = new ChunkGeneratorAbstract(worldChunkManager, chunkgenerator.strongholdSeed, ((ChunkGeneratorAbstract) chunkgenerator).settings); + chunkgenerator = new ChunkGeneratorAbstract(((ChunkGeneratorAbstract) chunkgenerator).noises, worldChunkManager, chunkgenerator.strongholdSeed, ((ChunkGeneratorAbstract) chunkgenerator).settings); } } ResourceKey<net.minecraft.world.level.World> worldKey; - String levelName = this.getServer().getDedicatedServerProperties().levelName; + String levelName = this.getServer().getProperties().levelName; if (name.equals(levelName + "_nether")) { worldKey = net.minecraft.world.level.World.NETHER; } else if (name.equals(levelName + "_the_end")) { worldKey = net.minecraft.world.level.World.END; } else { - worldKey = ResourceKey.a(IRegistry.DIMENSION_REGISTRY, new MinecraftKey(name.toLowerCase(java.util.Locale.ENGLISH))); + worldKey = ResourceKey.create(IRegistry.DIMENSION_REGISTRY, new MinecraftKey(name.toLowerCase(java.util.Locale.ENGLISH))); } WorldServer internal = (WorldServer) new WorldServer(console, console.executor, worldSession, worlddata, worldKey, dimensionmanager, getServer().progressListenerFactory.create(11), - chunkgenerator, worlddata.getGeneratorSettings().isDebugWorld(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, creator.environment(), generator, biomeProvider); + chunkgenerator, worlddata.worldGenSettings().isDebug(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, creator.environment(), generator, biomeProvider); if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) { return null; } - console.initWorld(internal, worlddata, worlddata, worlddata.getGeneratorSettings()); + console.initWorld(internal, worlddata, worlddata, worlddata.worldGenSettings()); - internal.setSpawnFlags(true, true); - console.levels.put(internal.getDimensionKey(), internal); + internal.setSpawnSettings(true, true); + console.levels.put(internal.dimension(), internal); - getServer().loadSpawn(internal.getChunkProvider().chunkMap.progressListener, internal); + getServer().prepareLevels(internal.getChunkSource().chunkMap.progressListener, internal); internal.entityManager.tick(); // SPIGOT-6526: Load pending entities so they are available to the API pluginManager.callEvent(new WorldLoadEvent(internal.getWorld())); @@ -1120,15 +1127,15 @@ public final class CraftServer implements Server { WorldServer handle = ((CraftWorld) world).getHandle(); - if (!(console.levels.containsKey(handle.getDimensionKey()))) { + if (!(console.levels.containsKey(handle.dimension()))) { return false; } - if (handle.getDimensionKey() == net.minecraft.world.level.World.OVERWORLD) { + if (handle.dimension() == net.minecraft.world.level.World.OVERWORLD) { return false; } - if (handle.getPlayers().size() > 0) { + if (handle.players().size() > 0) { return false; } @@ -1144,7 +1151,7 @@ public final class CraftServer implements Server { handle.save(null, true, true); } - handle.getChunkProvider().close(save); + handle.getChunkSource().close(save); handle.entityManager.close(save); // SPIGOT-6722: close entityManager handle.convertable.close(); } catch (Exception ex) { @@ -1152,7 +1159,7 @@ public final class CraftServer implements Server { } worlds.remove(world.getName().toLowerCase(java.util.Locale.ENGLISH)); - console.levels.remove(handle.getDimensionKey()); + console.levels.remove(handle.dimension()); return true; } @@ -1209,7 +1216,7 @@ public final class CraftServer implements Server { @Override public void savePlayers() { checkSaveState(); - playerList.savePlayers(); + playerList.saveAll(); } @Override @@ -1267,7 +1274,7 @@ public final class CraftServer implements Server { public Recipe getRecipe(NamespacedKey recipeKey) { Preconditions.checkArgument(recipeKey != null, "recipeKey == null"); - return getServer().getCraftingManager().getRecipe(CraftNamespacedKey.toMinecraft(recipeKey)).map(IRecipe::toBukkitRecipe).orElse(null); + return getServer().getRecipeManager().byKey(CraftNamespacedKey.toMinecraft(recipeKey)).map(IRecipe::toBukkitRecipe).orElse(null); } @Override @@ -1280,7 +1287,7 @@ public final class CraftServer implements Server { } @Override - public boolean canUse(EntityHuman entityhuman) { + public boolean stillValid(EntityHuman entityhuman) { return false; } }; @@ -1310,7 +1317,7 @@ public final class CraftServer implements Server { if (recipe.isPresent()) { RecipeCrafting recipeCrafting = recipe.get(); if (craftResult.setRecipeUsed(craftWorld.getHandle(), craftPlayer.getHandle(), recipeCrafting)) { - itemstack = recipeCrafting.a(inventoryCrafting); + itemstack = recipeCrafting.assemble(inventoryCrafting); } } @@ -1320,7 +1327,7 @@ public final class CraftServer implements Server { // Set the resulting matrix items for (int i = 0; i < craftingMatrix.length; i++) { Item remaining = inventoryCrafting.getContents().get(i).getItem().getCraftingRemainingItem(); - craftingMatrix[i] = (remaining != null) ? CraftItemStack.asBukkitCopy(remaining.createItemStack()) : null; + craftingMatrix[i] = (remaining != null) ? CraftItemStack.asBukkitCopy(remaining.getDefaultInstance()) : null; } return CraftItemStack.asBukkitCopy(result); @@ -1335,7 +1342,7 @@ public final class CraftServer implements Server { inventoryCrafting.setItem(i, CraftItemStack.asNMSCopy(craftingMatrix[i])); } - return getServer().getCraftingManager().craft(Recipes.CRAFTING, inventoryCrafting, world.getHandle()); + return getServer().getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventoryCrafting, world.getHandle()); } @Override @@ -1345,7 +1352,7 @@ public final class CraftServer implements Server { @Override public void clearRecipes() { - console.getCraftingManager().clearRecipes(); + console.getRecipeManager().clearRecipes(); } @Override @@ -1358,7 +1365,7 @@ public final class CraftServer implements Server { Preconditions.checkArgument(recipeKey != null, "recipeKey == null"); MinecraftKey mcKey = CraftNamespacedKey.toMinecraft(recipeKey); - for (Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>> recipes : getServer().getCraftingManager().recipes.values()) { + for (Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>> recipes : getServer().getRecipeManager().recipes.values()) { if (recipes.remove(mcKey) != null) { return true; } @@ -1405,7 +1412,7 @@ public final class CraftServer implements Server { @Override public int getSpawnRadius() { - return this.getServer().getSpawnProtection(); + return this.getServer().getSpawnProtectionRadius(); } @Override @@ -1416,12 +1423,12 @@ public final class CraftServer implements Server { @Override public boolean getOnlineMode() { - return console.getOnlineMode(); + return console.usesAuthentication(); } @Override public boolean getAllowFlight() { - return console.getAllowFlight(); + return console.isFlightAllowed(); } @Override @@ -1504,7 +1511,7 @@ public final class CraftServer implements Server { @Override @Deprecated public CraftMapView getMap(int id) { - WorldMap worldmap = console.getWorldServer(net.minecraft.world.level.World.OVERWORLD).a("map_" + id); + WorldMap worldmap = console.getLevel(net.minecraft.world.level.World.OVERWORLD).getMapData("map_" + id); if (worldmap == null) { return null; } @@ -1517,8 +1524,8 @@ public final class CraftServer implements Server { net.minecraft.world.level.World minecraftWorld = ((CraftWorld) world).getHandle(); // creates a new map at world spawn with the scale of 3, with out tracking position and unlimited tracking - int newId = ItemWorldMap.createNewSavedData(minecraftWorld, minecraftWorld.getWorldData().a(), minecraftWorld.getWorldData().c(), 3, false, false, minecraftWorld.getDimensionKey()); - return minecraftWorld.a(ItemWorldMap.a(newId)).mapView; + int newId = ItemWorldMap.createNewSavedData(minecraftWorld, minecraftWorld.getLevelData().getXSpawn(), minecraftWorld.getLevelData().getZSpawn(), 3, false, false, minecraftWorld.dimension()); + return minecraftWorld.getMapData(ItemWorldMap.makeKey(newId)).mapView; } @Override @@ -1537,17 +1544,17 @@ public final class CraftServer implements Server { BlockPosition structurePosition = new BlockPosition(structureLocation.getBlockX(), structureLocation.getBlockY(), structureLocation.getBlockZ()); // Create map with trackPlayer = true, unlimitedTracking = true - net.minecraft.world.item.ItemStack stack = ItemWorldMap.createFilledMapView(worldServer, structurePosition.getX(), structurePosition.getZ(), MapView.Scale.NORMAL.getValue(), true, true); - ItemWorldMap.applySepiaFilter(worldServer, stack); + net.minecraft.world.item.ItemStack stack = ItemWorldMap.create(worldServer, structurePosition.getX(), structurePosition.getZ(), MapView.Scale.NORMAL.getValue(), true, true); + ItemWorldMap.renderBiomePreviewMap(worldServer, stack); // "+" map ID taken from EntityVillager - ItemWorldMap.getSavedMap(stack, worldServer).decorateMap(stack, structurePosition, "+", MapIcon.Type.a(structureType.getMapIcon().getValue())); + ItemWorldMap.getSavedData(stack, worldServer).addTargetDecoration(stack, structurePosition, "+", MapIcon.Type.byIcon(structureType.getMapIcon().getValue())); return CraftItemStack.asBukkitCopy(stack); } @Override public void shutdown() { - console.safeShutdown(false); + console.halt(false); } @Override @@ -1584,7 +1591,7 @@ public final class CraftServer implements Server { OfflinePlayer result = getPlayerExact(name); if (result == null) { // This is potentially blocking :( - GameProfile profile = console.getUserCache().getProfile(name).orElse(null); + GameProfile profile = console.getProfileCache().get(name).orElse(null); if (profile == null) { // Make an OfflinePlayer using an offline mode UUID since the name has no profile result = getOfflinePlayer(new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name)); @@ -1626,7 +1633,7 @@ public final class CraftServer implements Server { @Override @SuppressWarnings("unchecked") public Set<String> getIPBans() { - return new HashSet<String>(Arrays.asList(playerList.getIPBans().getEntries())); + return playerList.getIpBans().getEntries().stream().map(IpBanEntry::getUser).collect(Collectors.toSet()); } @Override @@ -1647,8 +1654,8 @@ public final class CraftServer implements Server { public Set<OfflinePlayer> getBannedPlayers() { Set<OfflinePlayer> result = new HashSet<OfflinePlayer>(); - for (JsonListEntry entry : playerList.getProfileBans().getValues()) { - result.add(getOfflinePlayer((GameProfile) entry.getKey())); + for (GameProfileBanEntry entry : playerList.getBans().getValues()) { + result.add(getOfflinePlayer(entry.getUser())); } return result; @@ -1660,17 +1667,17 @@ public final class CraftServer implements Server { switch (type) { case IP: - return new CraftIpBanList(playerList.getIPBans()); + return new CraftIpBanList(playerList.getIpBans()); case NAME: default: - return new CraftProfileBanList(playerList.getProfileBans()); + return new CraftProfileBanList(playerList.getBans()); } } @Override public void setWhitelist(boolean value) { - playerList.setHasWhitelist(value); - console.setHasWhitelist(value); + playerList.setUsingWhiteList(value); + console.storeUsingWhiteList(value); } @Override @@ -1687,8 +1694,8 @@ public final class CraftServer implements Server { public Set<OfflinePlayer> getWhitelistedPlayers() { Set<OfflinePlayer> result = new LinkedHashSet<OfflinePlayer>(); - for (JsonListEntry entry : playerList.getWhitelist().getValues()) { - result.add(getOfflinePlayer((GameProfile) entry.getKey())); + for (WhiteListEntry entry : playerList.getWhiteList().getValues()) { + result.add(getOfflinePlayer(entry.getUser())); } return result; @@ -1698,8 +1705,8 @@ public final class CraftServer implements Server { public Set<OfflinePlayer> getOperators() { Set<OfflinePlayer> result = new HashSet<OfflinePlayer>(); - for (JsonListEntry entry : playerList.getOPs().getValues()) { - result.add(getOfflinePlayer((GameProfile) entry.getKey())); + for (OpListEntry entry : playerList.getOps().getValues()) { + result.add(getOfflinePlayer(entry.getUser())); } return result; @@ -1707,12 +1714,12 @@ public final class CraftServer implements Server { @Override public void reloadWhitelist() { - playerList.reloadWhitelist(); + playerList.reloadWhiteList(); } @Override public GameMode getDefaultGameMode() { - return GameMode.getByValue(console.getWorldServer(net.minecraft.world.level.World.OVERWORLD).serverLevelData.getGameType().getId()); + return GameMode.getByValue(console.getLevel(net.minecraft.world.level.World.OVERWORLD).serverLevelData.getGameType().getId()); } @Override @@ -1720,7 +1727,7 @@ public final class CraftServer implements Server { Validate.notNull(mode, "Mode cannot be null"); for (World world : getWorlds()) { - ((CraftWorld) world).getHandle().serverLevelData.setGameType(EnumGamemode.getById(mode.getValue())); + ((CraftWorld) world).getHandle().serverLevelData.setGameType(EnumGamemode.byId(mode.getValue())); } } @@ -1743,7 +1750,7 @@ public final class CraftServer implements Server { @Override public File getWorldContainer() { - return this.getServer().storageSource.a(net.minecraft.world.level.World.OVERWORLD).getParentFile(); + return this.getServer().storageSource.getDimensionPath(net.minecraft.world.level.World.OVERWORLD).getParent().toFile(); } @Override @@ -1990,18 +1997,19 @@ public final class CraftServer implements Server { @Override public void setIdleTimeout(int threshold) { - console.setIdleTimeout(threshold); + console.setPlayerIdleTimeout(threshold); } @Override public int getIdleTimeout() { - return console.getIdleTimeout(); + return console.getPlayerIdleTimeout(); } @Override public ChunkGenerator.ChunkData createChunkData(World world) { Validate.notNull(world, "World cannot be null"); - return new OldCraftChunkData(world); + WorldServer handle = ((CraftWorld) world).getHandle(); + return new OldCraftChunkData(world.getMinHeight(), world.getMaxHeight(), handle.registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY)); } @Override @@ -2013,7 +2021,7 @@ public final class CraftServer implements Server { public KeyedBossBar createBossBar(NamespacedKey key, String title, BarColor barColor, BarStyle barStyle, BarFlag... barFlags) { Preconditions.checkArgument(key != null, "key"); - BossBattleCustom bossBattleCustom = getServer().getBossBattleCustomData().register(CraftNamespacedKey.toMinecraft(key), CraftChatMessage.fromString(title, true)[0]); + BossBattleCustom bossBattleCustom = getServer().getCustomBossEvents().create(CraftNamespacedKey.toMinecraft(key), CraftChatMessage.fromString(title, true)[0]); CraftKeyedBossbar craftKeyedBossbar = new CraftKeyedBossbar(bossBattleCustom); craftKeyedBossbar.setColor(barColor); craftKeyedBossbar.setStyle(barStyle); @@ -2026,7 +2034,7 @@ public final class CraftServer implements Server { @Override public Iterator<KeyedBossBar> getBossBars() { - return Iterators.unmodifiableIterator(Iterators.transform(getServer().getBossBattleCustomData().getBattles().iterator(), new Function<BossBattleCustom, org.bukkit.boss.KeyedBossBar>() { + return Iterators.unmodifiableIterator(Iterators.transform(getServer().getCustomBossEvents().getEvents().iterator(), new Function<BossBattleCustom, org.bukkit.boss.KeyedBossBar>() { @Override public org.bukkit.boss.KeyedBossBar apply(BossBattleCustom bossBattleCustom) { return bossBattleCustom.getBukkitEntity(); @@ -2037,7 +2045,7 @@ public final class CraftServer implements Server { @Override public KeyedBossBar getBossBar(NamespacedKey key) { Preconditions.checkArgument(key != null, "key"); - net.minecraft.server.bossevents.BossBattleCustom bossBattleCustom = getServer().getBossBattleCustomData().a(CraftNamespacedKey.toMinecraft(key)); + net.minecraft.server.bossevents.BossBattleCustom bossBattleCustom = getServer().getCustomBossEvents().get(CraftNamespacedKey.toMinecraft(key)); return (bossBattleCustom == null) ? null : bossBattleCustom.getBukkitEntity(); } @@ -2045,8 +2053,8 @@ public final class CraftServer implements Server { @Override public boolean removeBossBar(NamespacedKey key) { Preconditions.checkArgument(key != null, "key"); - net.minecraft.server.bossevents.BossBattleCustomData bossBattleCustomData = getServer().getBossBattleCustomData(); - net.minecraft.server.bossevents.BossBattleCustom bossBattleCustom = bossBattleCustomData.a(CraftNamespacedKey.toMinecraft(key)); + net.minecraft.server.bossevents.BossBattleCustomData bossBattleCustomData = getServer().getCustomBossEvents(); + net.minecraft.server.bossevents.BossBattleCustom bossBattleCustom = bossBattleCustomData.get(CraftNamespacedKey.toMinecraft(key)); if (bossBattleCustom != null) { bossBattleCustomData.remove(bossBattleCustom); @@ -2060,7 +2068,7 @@ public final class CraftServer implements Server { public Entity getEntity(UUID uuid) { Validate.notNull(uuid, "UUID cannot be null"); - for (WorldServer world : getServer().getWorlds()) { + for (WorldServer world : getServer().getAllLevels()) { net.minecraft.world.entity.Entity entity = world.getEntity(uuid); if (entity != null) { return entity.getBukkitEntity(); @@ -2074,13 +2082,13 @@ public final class CraftServer implements Server { public org.bukkit.advancement.Advancement getAdvancement(NamespacedKey key) { Preconditions.checkArgument(key != null, "key"); - Advancement advancement = console.getAdvancementData().a(CraftNamespacedKey.toMinecraft(key)); + Advancement advancement = console.getAdvancements().getAdvancement(CraftNamespacedKey.toMinecraft(key)); return (advancement == null) ? null : advancement.bukkit; } @Override public Iterator<org.bukkit.advancement.Advancement> advancementIterator() { - return Iterators.unmodifiableIterator(Iterators.transform(console.getAdvancementData().getAdvancements().iterator(), new Function<Advancement, org.bukkit.advancement.Advancement>() { + return Iterators.unmodifiableIterator(Iterators.transform(console.getAdvancements().getAllAdvancements().iterator(), new Function<Advancement, org.bukkit.advancement.Advancement>() { @Override public org.bukkit.advancement.Advancement apply(Advancement advancement) { return advancement.bukkit; @@ -2129,19 +2137,19 @@ public final class CraftServer implements Server { case org.bukkit.Tag.REGISTRY_BLOCKS: Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Block namespace must have material type"); - return (org.bukkit.Tag<T>) new CraftBlockTag(TagsBlock.a(), key); + return (org.bukkit.Tag<T>) new CraftBlockTag(TagsBlock.getAllTags(), key); case org.bukkit.Tag.REGISTRY_ITEMS: Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Item namespace must have material type"); - return (org.bukkit.Tag<T>) new CraftItemTag(TagsItem.a(), key); + return (org.bukkit.Tag<T>) new CraftItemTag(TagsItem.getAllTags(), key); case org.bukkit.Tag.REGISTRY_FLUIDS: Preconditions.checkArgument(clazz == org.bukkit.Fluid.class, "Fluid namespace must have fluid type"); - return (org.bukkit.Tag<T>) new CraftFluidTag(TagsFluid.a(), key); + return (org.bukkit.Tag<T>) new CraftFluidTag(TagsFluid.getAllTags(), key); case org.bukkit.Tag.REGISTRY_ENTITY_TYPES: Preconditions.checkArgument(clazz == org.bukkit.entity.EntityType.class, "Entity type namespace must have entity type"); - return (org.bukkit.Tag<T>) new CraftEntityTag(TagsEntity.a(), key); + return (org.bukkit.Tag<T>) new CraftEntityTag(TagsEntity.getAllTags(), key); default: throw new IllegalArgumentException(); } @@ -2154,23 +2162,23 @@ public final class CraftServer implements Server { case org.bukkit.Tag.REGISTRY_BLOCKS: Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Block namespace must have material type"); - Tags<Block> blockTags = TagsBlock.a(); - return blockTags.a().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftBlockTag(blockTags, key)).collect(ImmutableList.toImmutableList()); + Tags<Block> blockTags = TagsBlock.getAllTags(); + return blockTags.getAllTags().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftBlockTag(blockTags, key)).collect(ImmutableList.toImmutableList()); case org.bukkit.Tag.REGISTRY_ITEMS: Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Item namespace must have material type"); - Tags<Item> itemTags = TagsItem.a(); - return itemTags.a().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftItemTag(itemTags, key)).collect(ImmutableList.toImmutableList()); + Tags<Item> itemTags = TagsItem.getAllTags(); + return itemTags.getAllTags().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftItemTag(itemTags, key)).collect(ImmutableList.toImmutableList()); case org.bukkit.Tag.REGISTRY_FLUIDS: Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Fluid namespace must have fluid type"); - Tags<FluidType> fluidTags = TagsFluid.a(); - return fluidTags.a().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftFluidTag(fluidTags, key)).collect(ImmutableList.toImmutableList()); + Tags<FluidType> fluidTags = TagsFluid.getAllTags(); + return fluidTags.getAllTags().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftFluidTag(fluidTags, key)).collect(ImmutableList.toImmutableList()); case org.bukkit.Tag.REGISTRY_ENTITY_TYPES: Preconditions.checkArgument(clazz == org.bukkit.entity.EntityType.class, "Entity type namespace must have entity type"); - Tags<EntityTypes<?>> entityTags = TagsEntity.a(); - return entityTags.a().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftEntityTag(entityTags, key)).collect(ImmutableList.toImmutableList()); + Tags<EntityTypes<?>> entityTags = TagsEntity.getAllTags(); + return entityTags.getAllTags().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftEntityTag(entityTags, key)).collect(ImmutableList.toImmutableList()); default: throw new IllegalArgumentException(); } @@ -2180,8 +2188,8 @@ public final class CraftServer implements Server { public LootTable getLootTable(NamespacedKey key) { Validate.notNull(key, "NamespacedKey cannot be null"); - LootTableRegistry registry = getServer().getLootTableRegistry(); - return new CraftLootTable(key, registry.getLootTable(CraftNamespacedKey.toMinecraft(key))); + LootTableRegistry registry = getServer().getLootTables(); + return new CraftLootTable(key, registry.get(CraftNamespacedKey.toMinecraft(key))); } @Override @@ -2189,12 +2197,12 @@ public final class CraftServer implements Server { Preconditions.checkArgument(selector != null, "Selector cannot be null"); Preconditions.checkArgument(sender != null, "Sender cannot be null"); - ArgumentEntity arg = ArgumentEntity.multipleEntities(); + ArgumentEntity arg = ArgumentEntity.entities(); List<? extends net.minecraft.world.entity.Entity> nms; try { StringReader reader = new StringReader(selector); - nms = arg.parse(reader, true).getEntities(VanillaCommandWrapper.getListener(sender)); + nms = arg.parse(reader, true).findEntities(VanillaCommandWrapper.getListener(sender)); Preconditions.checkArgument(!reader.canRead(), "Spurious trailing data in selector: " + selector); } catch (CommandSyntaxException ex) { throw new IllegalArgumentException("Could not parse selector: " + selector, ex); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java index 1307e30f95..8ff7086247 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java @@ -122,11 +122,11 @@ public enum CraftStatistic { } public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.stats.Statistic<?> statistic) { - IRegistry statRegistry = statistic.getWrapper().getRegistry(); - MinecraftKey nmsKey = IRegistry.STAT_TYPE.getKey(statistic.getWrapper()); + IRegistry statRegistry = statistic.getType().getRegistry(); + MinecraftKey nmsKey = IRegistry.STAT_TYPE.getKey(statistic.getType()); if (statRegistry == IRegistry.CUSTOM_STAT) { - nmsKey = (MinecraftKey) statistic.b(); + nmsKey = (MinecraftKey) statistic.getValue(); } return statistics.get(nmsKey); @@ -135,7 +135,7 @@ public enum CraftStatistic { public static net.minecraft.stats.Statistic getNMSStatistic(org.bukkit.Statistic bukkit) { Preconditions.checkArgument(bukkit.getType() == Statistic.Type.UNTYPED, "This method only accepts untyped statistics"); - net.minecraft.stats.Statistic<MinecraftKey> nms = StatisticList.CUSTOM.b(statistics.inverse().get(bukkit)); + net.minecraft.stats.Statistic<MinecraftKey> nms = StatisticList.CUSTOM.get(statistics.inverse().get(bukkit)); Preconditions.checkArgument(nms != null, "NMS Statistic %s does not exist", bukkit); return nms; @@ -144,22 +144,22 @@ public enum CraftStatistic { public static net.minecraft.stats.Statistic getMaterialStatistic(org.bukkit.Statistic stat, Material material) { try { if (stat == Statistic.MINE_BLOCK) { - return StatisticList.BLOCK_MINED.b(CraftMagicNumbers.getBlock(material)); + return StatisticList.BLOCK_MINED.get(CraftMagicNumbers.getBlock(material)); } if (stat == Statistic.CRAFT_ITEM) { - return StatisticList.ITEM_CRAFTED.b(CraftMagicNumbers.getItem(material)); + return StatisticList.ITEM_CRAFTED.get(CraftMagicNumbers.getItem(material)); } if (stat == Statistic.USE_ITEM) { - return StatisticList.ITEM_USED.b(CraftMagicNumbers.getItem(material)); + return StatisticList.ITEM_USED.get(CraftMagicNumbers.getItem(material)); } if (stat == Statistic.BREAK_ITEM) { - return StatisticList.ITEM_BROKEN.b(CraftMagicNumbers.getItem(material)); + return StatisticList.ITEM_BROKEN.get(CraftMagicNumbers.getItem(material)); } if (stat == Statistic.PICKUP) { - return StatisticList.ITEM_PICKED_UP.b(CraftMagicNumbers.getItem(material)); + return StatisticList.ITEM_PICKED_UP.get(CraftMagicNumbers.getItem(material)); } if (stat == Statistic.DROP) { - return StatisticList.ITEM_DROPPED.b(CraftMagicNumbers.getItem(material)); + return StatisticList.ITEM_DROPPED.get(CraftMagicNumbers.getItem(material)); } } catch (ArrayIndexOutOfBoundsException e) { return null; @@ -172,26 +172,26 @@ public enum CraftStatistic { EntityTypes<?> nmsEntity = IRegistry.ENTITY_TYPE.get(new MinecraftKey(entity.getName())); if (stat == org.bukkit.Statistic.KILL_ENTITY) { - return net.minecraft.stats.StatisticList.ENTITY_KILLED.b(nmsEntity); + return net.minecraft.stats.StatisticList.ENTITY_KILLED.get(nmsEntity); } if (stat == org.bukkit.Statistic.ENTITY_KILLED_BY) { - return net.minecraft.stats.StatisticList.ENTITY_KILLED_BY.b(nmsEntity); + return net.minecraft.stats.StatisticList.ENTITY_KILLED_BY.get(nmsEntity); } } return null; } public static EntityType getEntityTypeFromStatistic(net.minecraft.stats.Statistic<EntityTypes<?>> statistic) { - MinecraftKey name = EntityTypes.getName(statistic.b()); - return EntityType.fromName(name.getKey()); + MinecraftKey name = EntityTypes.getKey(statistic.getValue()); + return EntityType.fromName(name.getPath()); } public static Material getMaterialFromStatistic(net.minecraft.stats.Statistic<?> statistic) { - if (statistic.b() instanceof Item) { - return CraftMagicNumbers.getMaterial((Item) statistic.b()); + if (statistic.getValue() instanceof Item) { + return CraftMagicNumbers.getMaterial((Item) statistic.getValue()); } - if (statistic.b() instanceof Block) { - return CraftMagicNumbers.getMaterial((Block) statistic.b()); + if (statistic.getValue() instanceof Block) { + return CraftMagicNumbers.getMaterial((Block) statistic.getValue()); } return null; } @@ -207,7 +207,7 @@ public enum CraftStatistic { public static int getStatistic(ServerStatisticManager manager, Statistic statistic) { Validate.notNull(statistic, "Statistic cannot be null"); Validate.isTrue(statistic.getType() == Type.UNTYPED, "Must supply additional paramater for this statistic"); - return manager.getStatisticValue(CraftStatistic.getNMSStatistic(statistic)); + return manager.getValue(CraftStatistic.getNMSStatistic(statistic)); } public static void incrementStatistic(ServerStatisticManager manager, Statistic statistic, int amount) { @@ -225,7 +225,7 @@ public enum CraftStatistic { Validate.isTrue(statistic.getType() == Type.UNTYPED, "Must supply additional paramater for this statistic"); Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0"); net.minecraft.stats.Statistic nmsStatistic = CraftStatistic.getNMSStatistic(statistic); - manager.setStatistic(null, nmsStatistic, newValue);; + manager.setValue(null, nmsStatistic, newValue);; } public static void incrementStatistic(ServerStatisticManager manager, Statistic statistic, Material material) { @@ -242,7 +242,7 @@ public enum CraftStatistic { Validate.isTrue(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, "This statistic does not take a Material parameter"); net.minecraft.stats.Statistic nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material); Validate.notNull(nmsStatistic, "The supplied Material does not have a corresponding statistic"); - return manager.getStatisticValue(nmsStatistic); + return manager.getValue(nmsStatistic); } public static void incrementStatistic(ServerStatisticManager manager, Statistic statistic, Material material, int amount) { @@ -262,7 +262,7 @@ public enum CraftStatistic { Validate.isTrue(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, "This statistic does not take a Material parameter"); net.minecraft.stats.Statistic nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material); Validate.notNull(nmsStatistic, "The supplied Material does not have a corresponding statistic"); - manager.setStatistic(null, nmsStatistic, newValue); + manager.setValue(null, nmsStatistic, newValue); } public static void incrementStatistic(ServerStatisticManager manager, Statistic statistic, EntityType entityType) { @@ -279,7 +279,7 @@ public enum CraftStatistic { Validate.isTrue(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter"); net.minecraft.stats.Statistic nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType); Validate.notNull(nmsStatistic, "The supplied EntityType does not have a corresponding statistic"); - return manager.getStatisticValue(nmsStatistic); + return manager.getValue(nmsStatistic); } public static void incrementStatistic(ServerStatisticManager manager, Statistic statistic, EntityType entityType, int amount) { @@ -299,6 +299,6 @@ public enum CraftStatistic { Validate.isTrue(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter"); net.minecraft.stats.Statistic nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType); Validate.notNull(nmsStatistic, "The supplied EntityType does not have a corresponding statistic"); - manager.setStatistic(null, nmsStatistic, newValue); + manager.setValue(null, nmsStatistic, newValue); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 80b4c02e04..0aac7caefd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -159,7 +159,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public Location getSpawnLocation() { - BlockPosition spawn = world.getSpawn(); + BlockPosition spawn = world.getSharedSpawnPos(); return new Location(this, spawn.getX(), spawn.getY(), spawn.getZ()); } @@ -193,7 +193,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public Chunk getChunkAt(int x, int z) { - return this.world.getChunkProvider().getChunkAt(x, z, true).bukkitChunk; + return this.world.getChunkSource().getChunk(x, z, true).bukkitChunk; } @Override @@ -205,13 +205,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean isChunkLoaded(int x, int z) { - return world.getChunkProvider().isChunkLoaded(x, z); + return world.getChunkSource().isChunkLoaded(x, z); } @Override public boolean isChunkGenerated(int x, int z) { try { - return isChunkLoaded(x, z) || world.getChunkProvider().chunkMap.read(new ChunkCoordIntPair(x, z)) != null; + return isChunkLoaded(x, z) || world.getChunkSource().chunkMap.read(new ChunkCoordIntPair(x, z)) != null; } catch (IOException ex) { throw new RuntimeException(ex); } @@ -219,7 +219,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public Chunk[] getLoadedChunks() { - Long2ObjectLinkedOpenHashMap<PlayerChunk> chunks = world.getChunkProvider().chunkMap.visibleChunkMap; + Long2ObjectLinkedOpenHashMap<PlayerChunk> chunks = world.getChunkSource().chunkMap.visibleChunkMap; return chunks.values().stream().map(PlayerChunk::getFullChunk).filter(Objects::nonNull).map(net.minecraft.world.level.chunk.Chunk::getBukkitChunk).toArray(Chunk[]::new); } @@ -246,7 +246,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean unloadChunkRequest(int x, int z) { if (isChunkLoaded(x, z)) { - world.getChunkProvider().removeTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 1, Unit.INSTANCE); + world.getChunkSource().removeRegionTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 1, Unit.INSTANCE); } return true; @@ -256,12 +256,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { if (!isChunkLoaded(x, z)) { return true; } - net.minecraft.world.level.chunk.Chunk chunk = world.getChunkAt(x, z); + net.minecraft.world.level.chunk.Chunk chunk = world.getChunk(x, z); chunk.mustNotSave = !save; unloadChunkRequest(x, z); - world.getChunkProvider().purgeUnload(); + world.getChunkSource().purgeUnload(); return !isChunkLoaded(x, z); } @@ -304,9 +304,9 @@ public class CraftWorld extends CraftRegionAccessor implements World { // This flags 65 blocks distributed across all the sections of the chunk, so that everything is sent, including biomes int height = getMaxHeight() / 16; for (int idx = 0; idx < 64; idx++) { - world.notify(new BlockPosition(px + (idx / height), ((idx % height) * 16), pz), Blocks.AIR.getBlockData(), Blocks.STONE.getBlockData(), 3); + world.sendBlockUpdated(new BlockPosition(px + (idx / height), ((idx % height) * 16), pz), Blocks.AIR.defaultBlockState(), Blocks.STONE.defaultBlockState(), 3); } - world.notify(new BlockPosition(px + 15, (height * 16) - 1, pz + 15), Blocks.AIR.getBlockData(), Blocks.STONE.getBlockData(), 3); + world.sendBlockUpdated(new BlockPosition(px + 15, (height * 16) - 1, pz + 15), Blocks.AIR.defaultBlockState(), Blocks.STONE.defaultBlockState(), 3); return true; } @@ -318,16 +318,16 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean loadChunk(int x, int z, boolean generate) { - IChunkAccess chunk = world.getChunkProvider().getChunkAt(x, z, generate ? ChunkStatus.FULL : ChunkStatus.EMPTY, true); + IChunkAccess chunk = world.getChunkSource().getChunk(x, z, generate ? ChunkStatus.FULL : ChunkStatus.EMPTY, true); // If generate = false, but the chunk already exists, we will get this back. if (chunk instanceof ProtoChunkExtension) { // We then cycle through again to get the full chunk immediately, rather than after the ticket addition - chunk = world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, true); + chunk = world.getChunkSource().getChunk(x, z, ChunkStatus.FULL, true); } if (chunk instanceof net.minecraft.world.level.chunk.Chunk) { - world.getChunkProvider().addTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 1, Unit.INSTANCE); + world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 1, Unit.INSTANCE); return true; } @@ -354,7 +354,7 @@ 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.getChunkProvider().chunkMap.distanceManager; + ChunkMapDistance chunkDistanceManager = this.world.getChunkSource().chunkMap.distanceManager; if (chunkDistanceManager.addTicketAtLevel(TicketType.PLUGIN_TICKET, new ChunkCoordIntPair(x, z), 31, plugin)) { // keep in-line with force loading, add at level 31 this.getChunkAt(x, z); // ensure loaded @@ -368,7 +368,7 @@ 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.getChunkProvider().chunkMap.distanceManager; + ChunkMapDistance chunkDistanceManager = this.world.getChunkSource().chunkMap.distanceManager; return chunkDistanceManager.removeTicketAtLevel(TicketType.PLUGIN_TICKET, new ChunkCoordIntPair(x, z), 31, plugin); // keep in-line with force loading, remove at level 31 } @@ -376,14 +376,14 @@ public class CraftWorld extends CraftRegionAccessor implements World { public void removePluginChunkTickets(Plugin plugin) { Preconditions.checkNotNull(plugin, "null plugin"); - ChunkMapDistance chunkDistanceManager = this.world.getChunkProvider().chunkMap.distanceManager; + ChunkMapDistance chunkDistanceManager = this.world.getChunkSource().chunkMap.distanceManager; chunkDistanceManager.removeAllTicketsFor(TicketType.PLUGIN_TICKET, 31, plugin); // keep in-line with force loading, remove at level 31 } @Override public Collection<Plugin> getPluginChunkTickets(int x, int z) { - ChunkMapDistance chunkDistanceManager = this.world.getChunkProvider().chunkMap.distanceManager; - ArraySetSorted<Ticket<?>> tickets = chunkDistanceManager.tickets.get(ChunkCoordIntPair.pair(x, z)); + ChunkMapDistance chunkDistanceManager = this.world.getChunkSource().chunkMap.distanceManager; + ArraySetSorted<Ticket<?>> tickets = chunkDistanceManager.tickets.get(ChunkCoordIntPair.asLong(x, z)); if (tickets == null) { return Collections.emptyList(); @@ -391,7 +391,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { ImmutableList.Builder<Plugin> ret = ImmutableList.builder(); for (Ticket<?> ticket : tickets) { - if (ticket.getTicketType() == TicketType.PLUGIN_TICKET) { + if (ticket.getType() == TicketType.PLUGIN_TICKET) { ret.add((Plugin) ticket.key); } } @@ -402,7 +402,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public Map<Plugin, Collection<Chunk>> getPluginChunkTickets() { Map<Plugin, ImmutableList.Builder<Chunk>> ret = new HashMap<>(); - ChunkMapDistance chunkDistanceManager = this.world.getChunkProvider().chunkMap.distanceManager; + ChunkMapDistance chunkDistanceManager = this.world.getChunkSource().chunkMap.distanceManager; for (Long2ObjectMap.Entry<ArraySetSorted<Ticket<?>>> chunkTickets : chunkDistanceManager.tickets.long2ObjectEntrySet()) { long chunkKey = chunkTickets.getLongKey(); @@ -410,7 +410,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { Chunk chunk = null; for (Ticket<?> ticket : tickets) { - if (ticket.getTicketType() != TicketType.PLUGIN_TICKET) { + if (ticket.getType() != TicketType.PLUGIN_TICKET) { continue; } @@ -427,19 +427,19 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean isChunkForceLoaded(int x, int z) { - return getHandle().getForceLoadedChunks().contains(ChunkCoordIntPair.pair(x, z)); + return getHandle().getForcedChunks().contains(ChunkCoordIntPair.asLong(x, z)); } @Override public void setChunkForceLoaded(int x, int z, boolean forced) { - getHandle().setForceLoaded(x, z, forced); + getHandle().setChunkForced(x, z, forced); } @Override public Collection<Chunk> getForceLoadedChunks() { Set<Chunk> chunks = new HashSet<>(); - for (long coord : getHandle().getForceLoadedChunks()) { + for (long coord : getHandle().getForcedChunks()) { chunks.add(getChunkAt(ChunkCoordIntPair.getX(coord), ChunkCoordIntPair.getZ(coord))); } @@ -463,7 +463,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { if (function != null) { function.accept((org.bukkit.entity.Item) entity.getBukkitEntity()); } - world.addEntity(entity, SpawnReason.CUSTOM); + world.addFreshEntity(entity, SpawnReason.CUSTOM); return (org.bukkit.entity.Item) entity.getBukkitEntity(); } @@ -497,35 +497,35 @@ public class CraftWorld extends CraftRegionAccessor implements World { EntityArrow arrow; if (TippedArrow.class.isAssignableFrom(clazz)) { - arrow = EntityTypes.ARROW.a(world); - ((EntityTippedArrow) arrow).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false))); + arrow = EntityTypes.ARROW.create(world); + ((EntityTippedArrow) arrow).setPotionType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false))); } else if (SpectralArrow.class.isAssignableFrom(clazz)) { - arrow = EntityTypes.SPECTRAL_ARROW.a(world); + arrow = EntityTypes.SPECTRAL_ARROW.create(world); } else if (Trident.class.isAssignableFrom(clazz)) { - arrow = EntityTypes.TRIDENT.a(world); + arrow = EntityTypes.TRIDENT.create(world); } else { - arrow = EntityTypes.ARROW.a(world); + arrow = EntityTypes.ARROW.create(world); } - arrow.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); + arrow.moveTo(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); arrow.shoot(velocity.getX(), velocity.getY(), velocity.getZ(), speed, spread); - world.addEntity(arrow); + world.addFreshEntity(arrow); return (T) arrow.getBukkitEntity(); } @Override public LightningStrike strikeLightning(Location loc) { - EntityLightning lightning = EntityTypes.LIGHTNING_BOLT.a(world); - lightning.teleportAndSync(loc.getX(), loc.getY(), loc.getZ()); + EntityLightning lightning = EntityTypes.LIGHTNING_BOLT.create(world); + lightning.moveTo(loc.getX(), loc.getY(), loc.getZ()); world.strikeLightning(lightning, LightningStrikeEvent.Cause.CUSTOM); return (LightningStrike) lightning.getBukkitEntity(); } @Override public LightningStrike strikeLightningEffect(Location loc) { - EntityLightning lightning = EntityTypes.LIGHTNING_BOLT.a(world); - lightning.teleportAndSync(loc.getX(), loc.getY(), loc.getZ()); - lightning.setEffect(true); + EntityLightning lightning = EntityTypes.LIGHTNING_BOLT.create(world); + lightning.moveTo(loc.getX(), loc.getY(), loc.getZ()); + lightning.setVisualOnly(true); world.strikeLightning(lightning, LightningStrikeEvent.Cause.CUSTOM); return (LightningStrike) lightning.getBukkitEntity(); } @@ -545,10 +545,10 @@ public class CraftWorld extends CraftRegionAccessor implements World { if (grownTree) { // Copy block data to delegate for (BlockState blockstate : world.capturedBlockStates.values()) { BlockPosition position = ((CraftBlockState) blockstate).getPosition(); - net.minecraft.world.level.block.state.IBlockData oldBlock = world.getType(position); + net.minecraft.world.level.block.state.IBlockData oldBlock = world.getBlockState(position); int flag = ((CraftBlockState) blockstate).getFlag(); delegate.setBlockData(blockstate.getX(), blockstate.getY(), blockstate.getZ(), blockstate.getBlockData()); - net.minecraft.world.level.block.state.IBlockData newBlock = world.getType(position); + net.minecraft.world.level.block.state.IBlockData newBlock = world.getBlockState(position); world.notifyAndUpdatePhysics(position, null, oldBlock, newBlock, newBlock, flag, 512); } world.capturedBlockStates.clear(); @@ -561,7 +561,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public String getName() { - return world.serverLevelData.getName(); + return world.serverLevelData.getLevelName(); } @Override @@ -609,13 +609,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { CraftPlayer cp = (CraftPlayer) p; if (cp.getHandle().connection == null) continue; - cp.getHandle().connection.sendPacket(new PacketPlayOutUpdateTime(cp.getHandle().level.getTime(), cp.getHandle().getPlayerTime(), cp.getHandle().level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); + cp.getHandle().connection.send(new PacketPlayOutUpdateTime(cp.getHandle().level.getGameTime(), cp.getHandle().getPlayerTime(), cp.getHandle().level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); } } @Override public long getGameTime() { - return world.levelData.getTime(); + return world.levelData.getGameTime(); } @Override @@ -635,7 +635,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source) { - return !world.createExplosion(source == null ? null : ((CraftEntity) source).getHandle(), x, y, z, power, setFire, breakBlocks ? Explosion.Effect.BREAK : Explosion.Effect.NONE).wasCanceled; + return !world.explode(source == null ? null : ((CraftEntity) source).getHandle(), x, y, z, power, setFire, breakBlocks ? Explosion.Effect.BREAK : Explosion.Effect.NONE).wasCanceled; } @Override @@ -709,7 +709,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public int getHighestBlockYAt(int x, int z, org.bukkit.HeightMap heightMap) { // Transient load for this tick - return world.getChunkAt(x >> 4, z >> 4).getHighestBlock(CraftHeightMap.toNMS(heightMap), x, z); + return world.getChunk(x >> 4, z >> 4).getHeight(CraftHeightMap.toNMS(heightMap), x, z); } @Override @@ -742,13 +742,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setBiome(int x, int y, int z, BiomeBase bb) { BlockPosition pos = new BlockPosition(x, 0, z); - if (this.world.isLoaded(pos)) { - net.minecraft.world.level.chunk.Chunk chunk = this.world.getChunkAtWorldCoords(pos); + if (this.world.hasChunkAt(pos)) { + net.minecraft.world.level.chunk.Chunk chunk = this.world.getChunkAt(pos); if (chunk != null) { - chunk.getBiomeIndex().setBiome(x >> 2, y >> 2, z >> 2, bb); + chunk.setBiome(x, y, z, bb); - chunk.markDirty(); // SPIGOT-2890 + chunk.setUnsaved(true); // SPIGOT-2890 } } } @@ -761,7 +761,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public double getTemperature(int x, int y, int z) { BlockPosition pos = new BlockPosition(x, y, z); - return this.world.getBiome(x >> 2, y >> 2, z >> 2).getAdjustedTemperature(pos); + return this.world.getNoiseBiome(x >> 2, y >> 2, z >> 2).getTemperature(pos); } @Override @@ -771,7 +771,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public double getHumidity(int x, int y, int z) { - return this.world.getBiome(x >> 2, y >> 2, z >> 2).getHumidity(); + return this.world.getNoiseBiome(x >> 2, y >> 2, z >> 2).getDownfall(); } @Override @@ -783,12 +783,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public Iterable<net.minecraft.world.entity.Entity> getNMSEntities() { - return getHandle().getEntities().a(); + return getHandle().getEntities().getAll(); } @Override public void addEntityToWorld(net.minecraft.world.entity.Entity entity, SpawnReason reason) { - getHandle().addEntity(entity, reason); + getHandle().addFreshEntity(entity, reason); } @Override @@ -914,7 +914,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { Vector dir = direction.clone().normalize().multiply(maxDistance); Vec3D startPos = new Vec3D(start.getX(), start.getY(), start.getZ()); Vec3D endPos = new Vec3D(start.getX() + dir.getX(), start.getY() + dir.getY(), start.getZ() + dir.getZ()); - MovingObjectPosition nmsHitResult = this.getHandle().rayTrace(new RayTrace(startPos, endPos, ignorePassableBlocks ? RayTrace.BlockCollisionOption.COLLIDER : RayTrace.BlockCollisionOption.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), null)); + MovingObjectPosition nmsHitResult = this.getHandle().clip(new RayTrace(startPos, endPos, ignorePassableBlocks ? RayTrace.BlockCollisionOption.COLLIDER : RayTrace.BlockCollisionOption.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), null)); return CraftRayTraceResult.fromNMS(this, nmsHitResult); } @@ -951,9 +951,9 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public List<Player> getPlayers() { - List<Player> list = new ArrayList<Player>(world.getPlayers().size()); + List<Player> list = new ArrayList<Player>(world.players().size()); - for (EntityHuman human : world.getPlayers()) { + for (EntityHuman human : world.players()) { HumanEntity bukkitEntity = human.getBukkitEntity(); if ((bukkitEntity != null) && (bukkitEntity instanceof Player)) { @@ -987,7 +987,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setDifficulty(Difficulty difficulty) { - this.getHandle().serverLevelData.setDifficulty(EnumDifficulty.getById(difficulty.getValue())); + this.getHandle().serverLevelData.setDifficulty(EnumDifficulty.byId(difficulty.getValue())); } @Override @@ -1001,24 +1001,24 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean hasStorm() { - return world.levelData.hasStorm(); + return world.levelData.isRaining(); } @Override public void setStorm(boolean hasStorm) { - world.levelData.setStorm(hasStorm); + world.levelData.setRaining(hasStorm); setWeatherDuration(0); // Reset weather duration (legacy behaviour) setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands) } @Override public int getWeatherDuration() { - return world.serverLevelData.getWeatherDuration(); + return world.serverLevelData.getRainTime(); } @Override public void setWeatherDuration(int duration) { - world.serverLevelData.setWeatherDuration(duration); + world.serverLevelData.setRainTime(duration); } @Override @@ -1035,12 +1035,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public int getThunderDuration() { - return world.serverLevelData.getThunderDuration(); + return world.serverLevelData.getThunderTime(); } @Override public void setThunderDuration(int duration) { - world.serverLevelData.setThunderDuration(duration); + world.serverLevelData.setThunderTime(duration); } @Override @@ -1116,7 +1116,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { distance = (int) player.getLocation().distanceSquared(location); if (distance <= radius) { - ((CraftPlayer) player).getHandle().connection.sendPacket(packet); + ((CraftPlayer) player).getHandle().connection.send(packet); } } } @@ -1133,10 +1133,10 @@ public class CraftWorld extends CraftRegionAccessor implements World { Validate.notNull(material, "Material cannot be null"); Validate.isTrue(material.isBlock(), "Material must be a block"); - EntityFallingBlock entity = new EntityFallingBlock(world, location.getX(), location.getY(), location.getZ(), CraftMagicNumbers.getBlock(material).getBlockData()); + EntityFallingBlock entity = new EntityFallingBlock(world, location.getX(), location.getY(), location.getZ(), CraftMagicNumbers.getBlock(material).defaultBlockState()); entity.time = 1; - world.addEntity(entity, SpawnReason.CUSTOM); + world.addFreshEntity(entity, SpawnReason.CUSTOM); return (FallingBlock) entity.getBukkitEntity(); } @@ -1148,7 +1148,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { EntityFallingBlock entity = new EntityFallingBlock(world, location.getX(), location.getY(), location.getZ(), ((CraftBlockData) data).getState()); entity.time = 1; - world.addEntity(entity, SpawnReason.CUSTOM); + world.addFreshEntity(entity, SpawnReason.CUSTOM); return (FallingBlock) entity.getBukkitEntity(); } @@ -1159,17 +1159,17 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setSpawnFlags(boolean allowMonsters, boolean allowAnimals) { - world.setSpawnFlags(allowMonsters, allowAnimals); + world.setSpawnSettings(allowMonsters, allowAnimals); } @Override public boolean getAllowAnimals() { - return world.getChunkProvider().spawnFriendlies; + return world.getChunkSource().spawnFriendlies; } @Override public boolean getAllowMonsters() { - return world.getChunkProvider().spawnEnemies; + return world.getChunkSource().spawnEnemies; } @Override @@ -1184,47 +1184,47 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public int getLogicalHeight() { - return world.getDimensionManager().getLogicalHeight(); + return world.dimensionType().logicalHeight(); } @Override public boolean isNatural() { - return world.getDimensionManager().isNatural(); + return world.dimensionType().natural(); } @Override public boolean isBedWorks() { - return world.getDimensionManager().isBedWorks(); + return world.dimensionType().bedWorks(); } @Override public boolean hasSkyLight() { - return world.getDimensionManager().hasSkyLight(); + return world.dimensionType().hasSkyLight(); } @Override public boolean hasCeiling() { - return world.getDimensionManager().hasCeiling(); + return world.dimensionType().hasCeiling(); } @Override public boolean isPiglinSafe() { - return world.getDimensionManager().isPiglinSafe(); + return world.dimensionType().piglinSafe(); } @Override public boolean isRespawnAnchorWorks() { - return world.getDimensionManager().isRespawnAnchorWorks(); + return world.dimensionType().respawnAnchorWorks(); } @Override public boolean hasRaids() { - return world.getDimensionManager().hasRaids(); + return world.dimensionType().hasRaids(); } @Override public boolean isUltraWarm() { - return world.getDimensionManager().isNether(); + return world.dimensionType().ultraWarm(); } @Override @@ -1241,12 +1241,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { public void setKeepSpawnInMemory(boolean keepLoaded) { world.keepSpawnInMemory = keepLoaded; // Grab the worlds spawn chunk - BlockPosition chunkcoordinates = this.world.getSpawn(); + BlockPosition chunkcoordinates = this.world.getSharedSpawnPos(); if (keepLoaded) { - world.getChunkProvider().addTicket(TicketType.START, new ChunkCoordIntPair(chunkcoordinates), 11, Unit.INSTANCE); + world.getChunkSource().addRegionTicket(TicketType.START, new ChunkCoordIntPair(chunkcoordinates), 11, Unit.INSTANCE); } else { // TODO: doesn't work well if spawn changed.... - world.getChunkProvider().removeTicket(TicketType.START, new ChunkCoordIntPair(chunkcoordinates), 11, Unit.INSTANCE); + world.getChunkSource().removeRegionTicket(TicketType.START, new ChunkCoordIntPair(chunkcoordinates), 11, Unit.INSTANCE); } } @@ -1271,7 +1271,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public File getWorldFolder() { - return world.convertable.getWorldFolder(SavedFile.ROOT).toFile().getParentFile(); + return world.convertable.getLevelPath(SavedFile.ROOT).toFile().getParentFile(); } @Override @@ -1296,17 +1296,17 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public org.bukkit.WorldType getWorldType() { - return world.isFlatWorld() ? org.bukkit.WorldType.FLAT : org.bukkit.WorldType.NORMAL; + return world.isFlat() ? org.bukkit.WorldType.FLAT : org.bukkit.WorldType.NORMAL; } @Override public boolean canGenerateStructures() { - return world.serverLevelData.getGeneratorSettings().shouldGenerateMapFeatures(); + return world.serverLevelData.worldGenSettings().generateFeatures(); } @Override public boolean isHardcore() { - return world.getWorldData().isHardcore(); + return world.getLevelData().isHardcore(); } @Override @@ -1508,7 +1508,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { double z = loc.getZ(); PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), SoundCategory.valueOf(category.name()), new Vec3D(x, y, z), volume, pitch); - world.getMinecraftServer().getPlayerList().sendPacketNearby(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.getDimensionKey(), packet); + world.getServer().getPlayerList().broadcast(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.dimension(), packet); } private static Map<String, GameRules.GameRuleKey<?>> gamerules; @@ -1518,10 +1518,10 @@ public class CraftWorld extends CraftRegionAccessor implements World { } Map<String, GameRules.GameRuleKey<?>> gamerules = new HashMap<>(); - GameRules.a(new GameRules.GameRuleVisitor() { + GameRules.visitGameRuleTypes(new GameRules.GameRuleVisitor() { @Override - public <T extends GameRules.GameRuleValue<T>> void a(GameRules.GameRuleKey<T> gamerules_gamerulekey, GameRules.GameRuleDefinition<T> gamerules_gameruledefinition) { - gamerules.put(gamerules_gamerulekey.a(), gamerules_gamerulekey); + public <T extends GameRules.GameRuleValue<T>> void visit(GameRules.GameRuleKey<T> gamerules_gamerulekey, GameRules.GameRuleDefinition<T> gamerules_gameruledefinition) { + gamerules.put(gamerules_gamerulekey.getId(), gamerules_gamerulekey); } }); @@ -1535,10 +1535,10 @@ public class CraftWorld extends CraftRegionAccessor implements World { } Map<String, GameRules.GameRuleDefinition<?>> gameruleDefinitions = new HashMap<>(); - GameRules.a(new GameRules.GameRuleVisitor() { + GameRules.visitGameRuleTypes(new GameRules.GameRuleVisitor() { @Override - public <T extends GameRules.GameRuleValue<T>> void a(GameRules.GameRuleKey<T> gamerules_gamerulekey, GameRules.GameRuleDefinition<T> gamerules_gameruledefinition) { - gameruleDefinitions.put(gamerules_gamerulekey.a(), gamerules_gameruledefinition); + public <T extends GameRules.GameRuleValue<T>> void visit(GameRules.GameRuleKey<T> gamerules_gamerulekey, GameRules.GameRuleDefinition<T> gamerules_gameruledefinition) { + gameruleDefinitions.put(gamerules_gamerulekey.getId(), gamerules_gameruledefinition); } }); @@ -1552,7 +1552,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { return null; } - GameRules.GameRuleValue<?> value = getHandle().getGameRules().get(getGameRulesNMS().get(rule)); + GameRules.GameRuleValue<?> value = getHandle().getGameRules().getRule(getGameRulesNMS().get(rule)); return value != null ? value.toString() : ""; } @@ -1563,9 +1563,9 @@ public class CraftWorld extends CraftRegionAccessor implements World { if (!isGameRule(rule)) return false; - GameRules.GameRuleValue<?> handle = getHandle().getGameRules().get(getGameRulesNMS().get(rule)); - handle.setValue(value); - handle.onChange(getHandle().getMinecraftServer()); + GameRules.GameRuleValue<?> handle = getHandle().getGameRules().getRule(getGameRulesNMS().get(rule)); + handle.deserialize(value); + handle.onChanged(getHandle().getServer()); return true; } @@ -1583,13 +1583,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public <T> T getGameRuleValue(GameRule<T> rule) { Validate.notNull(rule, "GameRule cannot be null"); - return convert(rule, getHandle().getGameRules().get(getGameRulesNMS().get(rule.getName()))); + return convert(rule, getHandle().getGameRules().getRule(getGameRulesNMS().get(rule.getName()))); } @Override public <T> T getGameRuleDefault(GameRule<T> rule) { Validate.notNull(rule, "GameRule cannot be null"); - return convert(rule, getGameRuleDefinitions().get(rule.getName()).getValue()); + return convert(rule, getGameRuleDefinitions().get(rule.getName()).createRule()); } @Override @@ -1599,9 +1599,9 @@ public class CraftWorld extends CraftRegionAccessor implements World { if (!isGameRule(rule.getName())) return false; - GameRules.GameRuleValue<?> handle = getHandle().getGameRules().get(getGameRulesNMS().get(rule.getName())); - handle.setValue(newValue.toString()); - handle.onChange(getHandle().getMinecraftServer()); + GameRules.GameRuleValue<?> handle = getHandle().getGameRules().getRule(getGameRulesNMS().get(rule.getName())); + handle.deserialize(newValue.toString()); + handle.onChanged(getHandle().getServer()); return true; } @@ -1611,9 +1611,9 @@ public class CraftWorld extends CraftRegionAccessor implements World { } if (value instanceof GameRules.GameRuleBoolean) { - return rule.getType().cast(((GameRules.GameRuleBoolean) value).a()); + return rule.getType().cast(((GameRules.GameRuleBoolean) value).get()); } else if (value instanceof GameRules.GameRuleInt) { - return rule.getType().cast(value.getIntValue()); + return rule.getType().cast(value.getCommandResult()); } else { throw new IllegalArgumentException("Invalid GameRule type (" + value + ") for GameRule " + rule.getName()); } @@ -1713,7 +1713,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public Location locateNearestStructure(Location origin, StructureType structureType, int radius, boolean findUnexplored) { BlockPosition originPos = new BlockPosition(origin.getX(), origin.getY(), origin.getZ()); - BlockPosition nearest = getHandle().getChunkProvider().getChunkGenerator().findNearestMapFeature(getHandle(), StructureGenerator.STRUCTURES_REGISTRY.get(structureType.getName()), originPos, radius, findUnexplored); + BlockPosition nearest = getHandle().getChunkSource().getGenerator().findNearestMapFeature(getHandle(), StructureGenerator.STRUCTURES_REGISTRY.get(structureType.getName()), originPos, radius, findUnexplored); return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ()); } @@ -1722,19 +1722,19 @@ public class CraftWorld extends CraftRegionAccessor implements World { Validate.notNull(location, "Location cannot be null"); Validate.isTrue(radius >= 0, "Radius cannot be negative"); - PersistentRaid persistentRaid = world.getPersistentRaid(); + PersistentRaid persistentRaid = world.getRaids(); net.minecraft.world.entity.raid.Raid raid = persistentRaid.getNearbyRaid(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), radius * radius); return (raid == null) ? null : new CraftRaid(raid); } @Override public List<Raid> getRaids() { - PersistentRaid persistentRaid = world.getPersistentRaid(); + PersistentRaid persistentRaid = world.getRaids(); return persistentRaid.raidMap.values().stream().map(CraftRaid::new).collect(Collectors.toList()); } @Override public DragonBattle getEnderDragonBattle() { - return (getHandle().getDragonBattle() == null) ? null : new CraftDragonBattle(getHandle().getDragonBattle()); + return (getHandle().dragonFight() == null) ? null : new CraftDragonBattle(getHandle().dragonFight()); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java index 31f197ded3..e4247b7c35 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java @@ -43,7 +43,7 @@ public class CraftWorldBorder implements WorldBorder { time = Math.min(9223372036854775L, Math.max(0L, time)); if (time > 0L) { - this.handle.transitionSizeBetween(this.handle.getSize(), newSize, time * 1000L); + this.handle.lerpSizeBetween(this.handle.getSize(), newSize, time * 1000L); } else { this.handle.setSize(newSize); } @@ -73,22 +73,22 @@ public class CraftWorldBorder implements WorldBorder { @Override public double getDamageBuffer() { - return this.handle.getDamageBuffer(); + return this.handle.getDamageSafeZone(); } @Override public void setDamageBuffer(double blocks) { - this.handle.setDamageBuffer(blocks); + this.handle.setDamageSafeZone(blocks); } @Override public double getDamageAmount() { - return this.handle.getDamageAmount(); + return this.handle.getDamagePerBlock(); } @Override public void setDamageAmount(double damage) { - this.handle.setDamageAmount(damage); + this.handle.setDamagePerBlock(damage); } @Override @@ -103,18 +103,18 @@ public class CraftWorldBorder implements WorldBorder { @Override public int getWarningDistance() { - return this.handle.getWarningDistance(); + return this.handle.getWarningBlocks(); } @Override public void setWarningDistance(int distance) { - this.handle.setWarningDistance(distance); + this.handle.setWarningBlocks(distance); } @Override public boolean isInside(Location location) { Preconditions.checkArgument(location != null, "location"); - return location.getWorld().equals(this.world) && this.handle.a(new BlockPosition(location.getX(), location.getY(), location.getZ())); + return location.getWorld().equals(this.world) && this.handle.isWithinBounds(new BlockPosition(location.getX(), location.getY(), location.getZ())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java index 147ca09753..468ac806ef 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java @@ -149,8 +149,8 @@ public class Main { } float javaVersion = Float.parseFloat(System.getProperty("java.class.version")); - if (javaVersion < 60.0) { - System.err.println("Unsupported Java detected (" + javaVersion + "). This version of Minecraft requires at least Java 16. Check your Java version with the command 'java -version'."); + if (javaVersion < 61.0) { + System.err.println("Unsupported Java detected (" + javaVersion + "). This version of Minecraft requires at least Java 11. Check your Java version with the command 'java -version'."); return; } if (javaVersion > 61.0) { @@ -181,11 +181,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, -28); + deadline.add(Calendar.DAY_OF_YEAR, -7); 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/paper-server/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java b/paper-server/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java index 77abcd6de4..d6b17e3645 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java @@ -20,7 +20,7 @@ public class CraftAdvancement implements org.bukkit.advancement.Advancement { @Override public NamespacedKey getKey() { - return CraftNamespacedKey.fromMinecraft(handle.getName()); + return CraftNamespacedKey.fromMinecraft(handle.getId()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancementProgress.java b/paper-server/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancementProgress.java index 5e1e9fd0a3..6b053669b8 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancementProgress.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancementProgress.java @@ -33,18 +33,18 @@ public class CraftAdvancementProgress implements AdvancementProgress { @Override public boolean awardCriteria(String criteria) { - return playerData.grantCriteria(advancement.getHandle(), criteria); + return playerData.award(advancement.getHandle(), criteria); } @Override public boolean revokeCriteria(String criteria) { - return playerData.revokeCritera(advancement.getHandle(), criteria); + return playerData.revoke(advancement.getHandle(), criteria); } @Override public Date getDateAwarded(String criteria) { - CriterionProgress criterion = handle.getCriterionProgress(criteria); - return (criterion == null) ? null : criterion.getDate(); + CriterionProgress criterion = handle.getCriterion(criteria); + return (criterion == null) ? null : criterion.getObtained(); } @Override @@ -54,6 +54,6 @@ public class CraftAdvancementProgress implements AdvancementProgress { @Override public Collection<String> getAwardedCriteria() { - return Collections.unmodifiableCollection(Lists.newArrayList(handle.getAwardedCriteria())); + return Collections.unmodifiableCollection(Lists.newArrayList(handle.getCompletedCriteria())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java b/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java index 743afe7b7a..31c8f90cbb 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java @@ -30,7 +30,7 @@ public class CraftAttributeInstance implements AttributeInstance { @Override public void setBaseValue(double d) { - handle.setValue(d); + handle.setBaseValue(d); } @Override @@ -46,7 +46,7 @@ public class CraftAttributeInstance implements AttributeInstance { @Override public void addModifier(AttributeModifier modifier) { Preconditions.checkArgument(modifier != null, "modifier"); - handle.addModifier(convert(modifier)); + handle.addPermanentModifier(convert(modifier)); } @Override @@ -62,7 +62,7 @@ public class CraftAttributeInstance implements AttributeInstance { @Override public double getDefaultValue() { - return handle.getAttribute().getDefault(); + return handle.getAttribute().getDefaultValue(); } public static net.minecraft.world.entity.ai.attributes.AttributeModifier convert(AttributeModifier bukkit) { @@ -70,6 +70,6 @@ public class CraftAttributeInstance implements AttributeInstance { } public static AttributeModifier convert(net.minecraft.world.entity.ai.attributes.AttributeModifier nms) { - return new AttributeModifier(nms.getUniqueId(), nms.getName(), nms.getAmount(), AttributeModifier.Operation.values()[nms.getOperation().ordinal()]); + return new AttributeModifier(nms.getId(), nms.getName(), nms.getAmount(), AttributeModifier.Operation.values()[nms.getOperation().ordinal()]); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java b/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java index 43fa8d3c57..c8713d8879 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java @@ -21,7 +21,7 @@ public class CraftAttributeMap implements Attributable { @Override public AttributeInstance getAttribute(Attribute attribute) { Preconditions.checkArgument(attribute != null, "attribute"); - net.minecraft.world.entity.ai.attributes.AttributeModifiable nms = handle.a(toMinecraft(attribute)); + net.minecraft.world.entity.ai.attributes.AttributeModifiable nms = handle.getInstance(toMinecraft(attribute)); return (nms == null) ? null : new CraftAttributeInstance(nms, attribute); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java index ad16135058..e19b87d6da 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java @@ -32,7 +32,7 @@ public final class CapturedBlockState extends CraftBlockState { Random random = generatoraccessseed.getRandom(); // Begin copied block from WorldGenFeatureTreeBeehive - TileEntity tileentity = generatoraccessseed.getTileEntity(blockposition1); + TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition1); if (tileentity instanceof TileEntityBeehive) { TileEntityBeehive tileentitybeehive = (TileEntityBeehive) tileentity; @@ -41,7 +41,7 @@ public final class CapturedBlockState extends CraftBlockState { for (int k = 0; k < j; ++k) { EntityBee entitybee = new EntityBee(EntityTypes.BEE, generatoraccessseed.getMinecraftWorld()); - tileentitybeehive.a(entitybee, false, random.nextInt(599)); + tileentitybeehive.addOccupantWithPresetTicks(entitybee, false, random.nextInt(599)); } } // End copied block diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java index af06f630c2..3012757934 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java @@ -27,7 +27,7 @@ public class CraftBanner extends CraftBlockEntityState<TileEntityBanner> impleme public void load(TileEntityBanner banner) { super.load(banner); - base = DyeColor.getByWoolData((byte) ((BlockBannerAbstract) this.data.getBlock()).getColor().getColorIndex()); + base = DyeColor.getByWoolData((byte) ((BlockBannerAbstract) this.data.getBlock()).getColor().getId()); patterns = new ArrayList<Pattern>(); if (banner.itemPatterns != null) { @@ -88,14 +88,14 @@ public class CraftBanner extends CraftBlockEntityState<TileEntityBanner> impleme public void applyTo(TileEntityBanner banner) { super.applyTo(banner); - banner.baseColor = EnumColor.fromColorIndex(base.getWoolData()); + banner.baseColor = EnumColor.byId(base.getWoolData()); NBTTagList newPatterns = new NBTTagList(); for (Pattern p : patterns) { NBTTagCompound compound = new NBTTagCompound(); - compound.setInt("Color", p.getColor().getWoolData()); - compound.setString("Pattern", p.getPattern().getIdentifier()); + compound.putInt("Color", p.getColor().getWoolData()); + compound.putString("Pattern", p.getPattern().getIdentifier()); newPatterns.add(compound); } banner.itemPatterns = newPatterns; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java index bc324e1621..16b18d8a5f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java @@ -33,13 +33,13 @@ public class CraftBarrel extends CraftLootable<TileEntityBarrel> implements Barr public void open() { requirePlaced(); if (!getTileEntity().openersCounter.opened) { - IBlockData blockData = getTileEntity().getBlock(); - boolean open = blockData.get(BlockBarrel.OPEN); + IBlockData blockData = getTileEntity().getBlockState(); + boolean open = blockData.getValue(BlockBarrel.OPEN); if (!open) { - getTileEntity().setOpenFlag(blockData, true); + getTileEntity().updateBlockState(blockData, true); if (getWorldHandle() instanceof net.minecraft.world.level.World) { - getTileEntity().playOpenSound(blockData, SoundEffects.BARREL_OPEN); + getTileEntity().playSound(blockData, SoundEffects.BARREL_OPEN); } } } @@ -50,10 +50,10 @@ public class CraftBarrel extends CraftLootable<TileEntityBarrel> implements Barr public void close() { requirePlaced(); if (getTileEntity().openersCounter.opened) { - IBlockData blockData = getTileEntity().getBlock(); - getTileEntity().setOpenFlag(blockData, false); + IBlockData blockData = getTileEntity().getBlockState(); + getTileEntity().updateBlockState(blockData, false); if (getWorldHandle() instanceof net.minecraft.world.level.World) { - getTileEntity().playOpenSound(blockData, SoundEffects.BARREL_CLOSE); + getTileEntity().playSound(blockData, SoundEffects.BARREL_CLOSE); } } getTileEntity().openersCounter.opened = false; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java index 10c076bac8..cb9dd20c09 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java @@ -29,7 +29,7 @@ public class CraftBeacon extends CraftBlockEntityState<TileEntityBeacon> impleme if (tileEntity instanceof TileEntityBeacon) { TileEntityBeacon beacon = (TileEntityBeacon) tileEntity; - Collection<EntityHuman> nms = TileEntityBeacon.getHumansInRange(beacon.getWorld(), beacon.getPosition(), beacon.levels); + Collection<EntityHuman> nms = TileEntityBeacon.getHumansInRange(beacon.getLevel(), beacon.getBlockPos(), beacon.levels); Collection<LivingEntity> bukkit = new ArrayList<LivingEntity>(nms.size()); for (EntityHuman human : nms) { @@ -55,7 +55,7 @@ public class CraftBeacon extends CraftBlockEntityState<TileEntityBeacon> impleme @Override public void setPrimaryEffect(PotionEffectType effect) { - this.getSnapshot().primaryPower = (effect != null) ? MobEffectList.fromId(effect.getId()) : null; + this.getSnapshot().primaryPower = (effect != null) ? MobEffectList.byId(effect.getId()) : null; } @Override @@ -65,7 +65,7 @@ public class CraftBeacon extends CraftBlockEntityState<TileEntityBeacon> impleme @Override public void setSecondaryEffect(PotionEffectType effect) { - this.getSnapshot().secondaryPower = (effect != null) ? MobEffectList.fromId(effect.getId()) : null; + this.getSnapshot().secondaryPower = (effect != null) ? MobEffectList.byId(effect.getId()) : null; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java index d7485cc1a3..70a2b6cb0b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java @@ -43,7 +43,7 @@ public class CraftBeehive extends CraftBlockEntityState<TileEntityBeehive> imple @Override public int getEntityCount() { - return getSnapshot().getBeeCount(); + return getSnapshot().getOccupantCount(); } @Override @@ -78,6 +78,6 @@ public class CraftBeehive extends CraftBlockEntityState<TileEntityBeehive> imple public void addEntity(Bee entity) { Preconditions.checkArgument(entity != null, "Entity must not be null"); - getSnapshot().addBee(((CraftBee) entity).getHandle(), false); + getSnapshot().addOccupant(((CraftBee) entity).getHandle(), false); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 12aac2a6dd..b5ce6f3612 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -65,7 +65,7 @@ public class CraftBlock implements Block { public CraftBlock(GeneratorAccess world, BlockPosition position) { this.world = world; - this.position = position.immutableCopy(); + this.position = position.immutable(); } public static CraftBlock at(GeneratorAccess world, BlockPosition position) { @@ -73,7 +73,7 @@ public class CraftBlock implements Block { } public net.minecraft.world.level.block.state.IBlockData getNMS() { - return world.getType(position); + return world.getBlockState(position); } public BlockPosition getPosition() { @@ -149,12 +149,12 @@ public class CraftBlock implements Block { } private void setData(final byte data, int flag) { - world.setTypeAndData(position, CraftMagicNumbers.getBlock(getType(), data), flag); + world.setBlock(position, CraftMagicNumbers.getBlock(getType(), data), flag); } @Override public byte getData() { - IBlockData blockData = world.getType(position); + IBlockData blockData = world.getBlockState(position); return CraftMagicNumbers.toLegacyData(blockData); } @@ -188,21 +188,21 @@ public class CraftBlock implements Block { public boolean setTypeAndData(final IBlockData blockData, final boolean applyPhysics) { IBlockData old = getNMS(); // SPIGOT-611: need to do this to prevent glitchiness. Easier to handle this here (like /setblock) than to fix weirdness in tile entity cleanup - if (old.isTileEntity() && blockData.getBlock() != old.getBlock()) { // SPIGOT-3725 remove old tile entity if block changes + if (old.hasBlockEntity() && blockData.getBlock() != old.getBlock()) { // SPIGOT-3725 remove old tile entity if block changes // SPIGOT-4612: faster - just clear tile if (world instanceof net.minecraft.world.level.World) { - ((net.minecraft.world.level.World) world).removeTileEntity(position); + ((net.minecraft.world.level.World) world).removeBlockEntity(position); } else { - world.setTypeAndData(position, Blocks.AIR.getBlockData(), 0); + world.setBlock(position, Blocks.AIR.defaultBlockState(), 0); } } if (applyPhysics) { - return world.setTypeAndData(position, blockData, 3); + return world.setBlock(position, blockData, 3); } else { - boolean success = world.setTypeAndData(position, blockData, 2 | 16 | 1024); // NOTIFY | NO_OBSERVER | NO_PLACE (custom) + boolean success = world.setBlock(position, blockData, 2 | 16 | 1024); // NOTIFY | NO_OBSERVER | NO_PLACE (custom) if (success && world instanceof net.minecraft.world.level.World) { - world.getMinecraftWorld().notify( + world.getMinecraftWorld().sendBlockUpdated( position, old, blockData, @@ -215,12 +215,12 @@ public class CraftBlock implements Block { @Override public Material getType() { - return CraftMagicNumbers.getMaterial(world.getType(position).getBlock()); + return CraftMagicNumbers.getMaterial(world.getBlockState(position).getBlock()); } @Override public byte getLightLevel() { - return (byte) world.getMinecraftWorld().getLightLevel(position); + return (byte) world.getMinecraftWorld().getMaxLocalRawBrightness(position); } @Override @@ -271,7 +271,7 @@ public class CraftBlock implements Block { @Override public String toString() { - return "CraftBlock{pos=" + position + ",type=" + getType() + ",data=" + getNMS() + ",fluid=" + world.getFluid(position) + '}'; + return "CraftBlock{pos=" + position + ",type=" + getType() + ",data=" + getNMS() + ",fluid=" + world.getFluidState(position) + '}'; } public static BlockFace notchToBlockFace(EnumDirection notch) { @@ -349,7 +349,7 @@ public class CraftBlock implements Block { @Override public double getTemperature() { - return world.getBiome(position).getAdjustedTemperature(position); + return world.getBiome(position).getTemperature(position); } @Override @@ -359,12 +359,12 @@ public class CraftBlock implements Block { @Override public boolean isBlockPowered() { - return world.getMinecraftWorld().getBlockPower(position) > 0; + return world.getMinecraftWorld().getDirectSignalTo(position) > 0; } @Override public boolean isBlockIndirectlyPowered() { - return world.getMinecraftWorld().isBlockIndirectlyPowered(position); + return world.getMinecraftWorld().hasNeighborSignal(position); } @Override @@ -387,12 +387,12 @@ public class CraftBlock implements Block { @Override public boolean isBlockFacePowered(BlockFace face) { - return world.getMinecraftWorld().isBlockFacePowered(position, blockFaceToNotch(face)); + return world.getMinecraftWorld().hasSignal(position, blockFaceToNotch(face)); } @Override public boolean isBlockFaceIndirectlyPowered(BlockFace face) { - int power = world.getMinecraftWorld().getBlockFacePower(position, blockFaceToNotch(face)); + int power = world.getMinecraftWorld().getSignal(position, blockFaceToNotch(face)); Block relative = getRelative(face); if (relative.getType() == Material.REDSTONE_WIRE) { @@ -409,20 +409,20 @@ public class CraftBlock implements Block { int x = getX(); int y = getY(); int z = getZ(); - if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y - 1, z), EnumDirection.DOWN)) power = getPower(power, world.getType(new BlockPosition(x, y - 1, z))); - if ((face == BlockFace.UP || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y + 1, z), EnumDirection.UP)) power = getPower(power, world.getType(new BlockPosition(x, y + 1, z))); - if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x + 1, y, z), EnumDirection.EAST)) power = getPower(power, world.getType(new BlockPosition(x + 1, y, z))); - if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x - 1, y, z), EnumDirection.WEST)) power = getPower(power, world.getType(new BlockPosition(x - 1, y, z))); - if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y, z - 1), EnumDirection.NORTH)) power = getPower(power, world.getType(new BlockPosition(x, y, z - 1))); - if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y, z + 1), EnumDirection.SOUTH)) power = getPower(power, world.getType(new BlockPosition(x, y, z + 1))); + if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.hasSignal(new BlockPosition(x, y - 1, z), EnumDirection.DOWN)) power = getPower(power, world.getBlockState(new BlockPosition(x, y - 1, z))); + if ((face == BlockFace.UP || face == BlockFace.SELF) && world.hasSignal(new BlockPosition(x, y + 1, z), EnumDirection.UP)) power = getPower(power, world.getBlockState(new BlockPosition(x, y + 1, z))); + if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.hasSignal(new BlockPosition(x + 1, y, z), EnumDirection.EAST)) power = getPower(power, world.getBlockState(new BlockPosition(x + 1, y, z))); + if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.hasSignal(new BlockPosition(x - 1, y, z), EnumDirection.WEST)) power = getPower(power, world.getBlockState(new BlockPosition(x - 1, y, z))); + if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.hasSignal(new BlockPosition(x, y, z - 1), EnumDirection.NORTH)) power = getPower(power, world.getBlockState(new BlockPosition(x, y, z - 1))); + if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.hasSignal(new BlockPosition(x, y, z + 1), EnumDirection.SOUTH)) power = getPower(power, world.getBlockState(new BlockPosition(x, y, z + 1))); return power > 0 ? power : (face == BlockFace.SELF ? isBlockIndirectlyPowered() : isBlockFaceIndirectlyPowered(face)) ? 15 : 0; } private static int getPower(int i, IBlockData iblockdata) { - if (!iblockdata.a(Blocks.REDSTONE_WIRE)) { + if (!iblockdata.is(Blocks.REDSTONE_WIRE)) { return i; } else { - int j = iblockdata.get(BlockRedstoneWire.POWER); + int j = iblockdata.getValue(BlockRedstoneWire.POWER); return j > i ? j : i; } @@ -445,7 +445,7 @@ public class CraftBlock implements Block { @Override public PistonMoveReaction getPistonMoveReaction() { - return PistonMoveReaction.getById(getNMS().getPushReaction().ordinal()); + return PistonMoveReaction.getById(getNMS().getPistonPushReaction().ordinal()); } @Override @@ -462,18 +462,18 @@ public class CraftBlock implements Block { boolean result = false; // Modelled off EntityHuman#hasBlock - if (block != Blocks.AIR && (item == null || !iblockdata.isRequiresSpecialTool() || nmsItem.canDestroySpecialBlock(iblockdata))) { - net.minecraft.world.level.block.Block.dropItems(iblockdata, world.getMinecraftWorld(), position, world.getTileEntity(position), null, nmsItem); + if (block != Blocks.AIR && (item == null || !iblockdata.requiresCorrectToolForDrops() || nmsItem.isCorrectToolForDrops(iblockdata))) { + net.minecraft.world.level.block.Block.dropResources(iblockdata, world.getMinecraftWorld(), position, world.getBlockEntity(position), null, nmsItem); result = true; } - return setTypeAndData(Blocks.AIR.getBlockData(), true) && result; + return setTypeAndData(Blocks.AIR.defaultBlockState(), true) && result; } @Override public boolean applyBoneMeal(BlockFace face) { EnumDirection direction = blockFaceToNotch(face); - ItemActionContext context = new ItemActionContext(getCraftWorld().getHandle(), null, EnumHand.MAIN_HAND, Items.BONE_MEAL.createItemStack(), new MovingObjectPositionBlock(Vec3D.ZERO, direction, getPosition(), false)); + ItemActionContext context = new ItemActionContext(getCraftWorld().getHandle(), null, EnumHand.MAIN_HAND, Items.BONE_MEAL.getDefaultInstance(), new MovingObjectPositionBlock(Vec3D.ZERO, direction, getPosition(), false)); return ItemBoneMeal.applyBonemeal(context) == EnumInteractionResult.SUCCESS; } @@ -495,7 +495,7 @@ public class CraftBlock implements Block { // Modelled off EntityHuman#hasBlock if (item == null || isPreferredTool(iblockdata, nms)) { - return net.minecraft.world.level.block.Block.getDrops(iblockdata, (WorldServer) world.getMinecraftWorld(), position, world.getTileEntity(position), entity == null ? null : ((CraftEntity) entity).getHandle(), nms) + return net.minecraft.world.level.block.Block.getDrops(iblockdata, (WorldServer) world.getMinecraftWorld(), position, world.getBlockEntity(position), entity == null ? null : ((CraftEntity) entity).getHandle(), nms) .stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList()); } else { return Collections.emptyList(); @@ -512,11 +512,11 @@ public class CraftBlock implements Block { @Override public float getBreakSpeed(Player player) { Preconditions.checkArgument(player != null, "player cannot be null"); - return getNMS().getDamage(((CraftPlayer) player).getHandle(), world, position); + return getNMS().getDestroyProgress(((CraftPlayer) player).getHandle(), world, position); } private boolean isPreferredTool(IBlockData iblockdata, net.minecraft.world.item.ItemStack nmsItem) { - return !iblockdata.isRequiresSpecialTool() || nmsItem.canDestroySpecialBlock(iblockdata); + return !iblockdata.requiresCorrectToolForDrops() || nmsItem.isCorrectToolForDrops(iblockdata); } @Override @@ -563,7 +563,7 @@ public class CraftBlock implements Block { Vec3D startPos = new Vec3D(start.getX(), start.getY(), start.getZ()); Vec3D endPos = new Vec3D(start.getX() + dir.getX(), start.getY() + dir.getY(), start.getZ() + dir.getZ()); - MovingObjectPosition nmsHitResult = world.rayTraceBlock(new RayTrace(startPos, endPos, RayTrace.BlockCollisionOption.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), null), position); + MovingObjectPosition nmsHitResult = world.clip(new RayTrace(startPos, endPos, RayTrace.BlockCollisionOption.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), null), position); return CraftRayTraceResult.fromNMS(this.getWorld(), nmsHitResult); } @@ -575,7 +575,7 @@ public class CraftBlock implements Block { return new BoundingBox(); // Return an empty bounding box if the block has no dimension } - AxisAlignedBB aabb = shape.getBoundingBox(); + AxisAlignedBB aabb = shape.bounds(); return new BoundingBox(getX() + aabb.minX, getY() + aabb.minY, getZ() + aabb.minZ, getX() + aabb.maxX, getY() + aabb.maxY, getZ() + aabb.maxZ); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java index 1584bf8d9f..44203fddd1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java @@ -12,7 +12,7 @@ public abstract class CraftBlockEntityState<T extends TileEntity> extends CraftB private final T snapshot; public CraftBlockEntityState(World world, T tileEntity) { - super(world, tileEntity.getPosition(), tileEntity.getBlock()); + super(world, tileEntity.getBlockPos(), tileEntity.getBlockState()); this.tileEntity = tileEntity; @@ -30,15 +30,15 @@ public abstract class CraftBlockEntityState<T extends TileEntity> extends CraftB return null; } - NBTTagCompound nbtTagCompound = tileEntity.save(new NBTTagCompound()); - T snapshot = (T) TileEntity.create(getPosition(), getHandle(), nbtTagCompound); + NBTTagCompound nbtTagCompound = tileEntity.saveWithFullMetadata(); + T snapshot = (T) TileEntity.loadStatic(getPosition(), getHandle(), nbtTagCompound); return snapshot; } // copies the TileEntity-specific data, retains the position private void copyData(T from, T to) { - NBTTagCompound nbtTagCompound = from.save(new NBTTagCompound()); + NBTTagCompound nbtTagCompound = from.saveWithFullMetadata(); to.load(nbtTagCompound); } @@ -56,7 +56,7 @@ public abstract class CraftBlockEntityState<T extends TileEntity> extends CraftB protected TileEntity getTileEntityFromWorld() { requirePlaced(); - return getWorldHandle().getTileEntity(this.getPosition()); + return getWorldHandle().getBlockEntity(this.getPosition()); } // gets the NBT data of the TileEntity represented by this block state @@ -64,7 +64,7 @@ public abstract class CraftBlockEntityState<T extends TileEntity> extends CraftB // update snapshot applyTo(snapshot); - return snapshot.save(new NBTTagCompound()); + return snapshot.saveWithFullMetadata(); } // copies the data of the given tile entity to this block state @@ -94,7 +94,7 @@ public abstract class CraftBlockEntityState<T extends TileEntity> extends CraftB if (isApplicable(tile)) { applyTo((T) tile); - tile.update(); + tile.setChanged(); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java index 53348f9d2b..3bac4e4e25 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -161,7 +161,7 @@ public class CraftBlockState implements BlockState { Preconditions.checkArgument(type.isBlock(), "Material must be a block!"); if (this.getType() != type) { - this.data = CraftMagicNumbers.getBlock(type).getBlockData(); + this.data = CraftMagicNumbers.getBlock(type).defaultBlockState(); } } @@ -216,7 +216,7 @@ public class CraftBlockState implements BlockState { IBlockData newBlock = this.data; block.setTypeAndData(newBlock, applyPhysics); if (access instanceof net.minecraft.world.level.World) { - world.getHandle().notify( + world.getHandle().sendBlockUpdated( position, block.getNMS(), newBlock, @@ -226,7 +226,7 @@ public class CraftBlockState implements BlockState { // Update levers etc if (false && applyPhysics && getData() instanceof Attachable) { // Call does not map to new API - world.getHandle().applyPhysics(position.shift(CraftBlock.blockFaceToNotch(((Attachable) getData()).getAttachedFace())), newBlock.getBlock()); + world.getHandle().updateNeighborsAt(position.relative(CraftBlock.blockFaceToNotch(((Attachable) getData()).getAttachedFace())), newBlock.getBlock()); } return true; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java index f9e23e29e4..fb76979cc2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java @@ -326,7 +326,7 @@ public final class CraftBlockStates { CraftWorld world = (CraftWorld) block.getWorld(); BlockPosition blockPosition = craftBlock.getPosition(); IBlockData blockData = craftBlock.getNMS(); - TileEntity tileEntity = craftBlock.getHandle().getTileEntity(blockPosition); + TileEntity tileEntity = craftBlock.getHandle().getBlockEntity(blockPosition); CraftBlockState blockState = getBlockState(world, blockPosition, blockData, tileEntity); blockState.setWorldHandle(craftBlock.getHandle()); // Inject the block's generator access return blockState; @@ -338,7 +338,7 @@ public final class CraftBlockStates { public static BlockState getBlockState(BlockPosition blockPosition, Material material, @Nullable NBTTagCompound blockEntityTag) { Preconditions.checkNotNull(material, "material is null"); - IBlockData blockData = CraftMagicNumbers.getBlock(material).getBlockData(); + IBlockData blockData = CraftMagicNumbers.getBlock(material).defaultBlockState(); return getBlockState(blockPosition, blockData, blockEntityTag); } @@ -349,7 +349,7 @@ public final class CraftBlockStates { public static BlockState getBlockState(BlockPosition blockPosition, IBlockData blockData, @Nullable NBTTagCompound blockEntityTag) { Preconditions.checkNotNull(blockPosition, "blockPosition is null"); Preconditions.checkNotNull(blockData, "blockData is null"); - TileEntity tileEntity = (blockEntityTag == null) ? null : TileEntity.create(blockPosition, blockData, blockEntityTag); + TileEntity tileEntity = (blockEntityTag == null) ? null : TileEntity.loadStatic(blockPosition, blockData, blockEntityTag); return getBlockState(null, blockPosition, blockData, tileEntity); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java index b23029b48e..9ec58bc1b7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java @@ -45,7 +45,7 @@ public class CraftChest extends CraftLootable<TileEntityChest> implements Chest CraftWorld world = (CraftWorld) this.getWorld(); BlockChest blockChest = (BlockChest) (this.getType() == Material.CHEST ? Blocks.CHEST : Blocks.TRAPPED_CHEST); - ITileInventory nms = blockChest.getInventory(data, world.getHandle(), this.getPosition(), true); + ITileInventory nms = blockChest.getMenuProvider(data, world.getHandle(), this.getPosition(), true); if (nms instanceof BlockChest.DoubleInventory) { inventory = new CraftInventoryDoubleChest((BlockChest.DoubleInventory) nms); @@ -57,9 +57,9 @@ public class CraftChest extends CraftLootable<TileEntityChest> implements Chest public void open() { requirePlaced(); if (!getTileEntity().openersCounter.opened && getWorldHandle() instanceof net.minecraft.world.level.World) { - IBlockData block = getTileEntity().getBlock(); - getTileEntity().getWorld().playBlockAction(getPosition(), block.getBlock(), 1, getTileEntity().openersCounter.getOpenerCount() + 1); - TileEntityChest.playOpenSound(getTileEntity().getWorld(), getPosition(), block, SoundEffects.CHEST_OPEN); + IBlockData block = getTileEntity().getBlockState(); + getTileEntity().getLevel().blockEvent(getPosition(), block.getBlock(), 1, getTileEntity().openersCounter.getOpenerCount() + 1); + TileEntityChest.playSound(getTileEntity().getLevel(), getPosition(), block, SoundEffects.CHEST_OPEN); } getTileEntity().openersCounter.opened = true; } @@ -68,9 +68,9 @@ public class CraftChest extends CraftLootable<TileEntityChest> implements Chest public void close() { requirePlaced(); if (getTileEntity().openersCounter.opened && getWorldHandle() instanceof net.minecraft.world.level.World) { - IBlockData block = getTileEntity().getBlock(); - getTileEntity().getWorld().playBlockAction(getPosition(), block.getBlock(), 1, 0); - TileEntityChest.playOpenSound(getTileEntity().getWorld(), getPosition(), block, SoundEffects.CHEST_CLOSE); + IBlockData block = getTileEntity().getBlockState(); + getTileEntity().getLevel().blockEvent(getPosition(), block.getBlock(), 1, 0); + TileEntityChest.playSound(getTileEntity().getLevel(), getPosition(), block, SoundEffects.CHEST_CLOSE); } getTileEntity().openersCounter.opened = false; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java index 041b5b9d66..a90a2113e4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java @@ -1,8 +1,7 @@ package org.bukkit.craftbukkit.block; import com.google.common.base.Preconditions; -import net.minecraft.core.BlockPosition; -import net.minecraft.resources.MinecraftKey; +import java.util.Optional; import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.level.block.entity.TileEntityMobSpawner; import org.bukkit.World; @@ -17,8 +16,8 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa @Override public EntityType getSpawnedType() { - MinecraftKey key = this.getSnapshot().getSpawner().getMobName(null, BlockPosition.ZERO); - return (key == null) ? EntityType.PIG : EntityType.fromName(key.getKey()); + Optional<EntityTypes<?>> type = EntityTypes.by(this.getSnapshot().getSpawner().nextSpawnData.getEntityToSpawn()); + return (type.isEmpty()) ? EntityType.PIG : EntityType.fromName(EntityTypes.getKey(type.get()).getPath()); } @Override @@ -27,12 +26,13 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa throw new IllegalArgumentException("Can't spawn EntityType " + entityType + " from mobspawners!"); } - this.getSnapshot().getSpawner().setMobName(EntityTypes.a(entityType.getName()).get()); + this.getSnapshot().getSpawner().setEntityId(EntityTypes.byString(entityType.getName()).get()); } @Override public String getCreatureTypeName() { - return this.getSnapshot().getSpawner().getMobName(null, BlockPosition.ZERO).getKey(); + Optional<EntityTypes<?>> type = EntityTypes.by(this.getSnapshot().getSpawner().nextSpawnData.getEntityToSpawn()); + return (type.isEmpty()) ? "" : EntityTypes.getKey(type.get()).getPath(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java index 474fe3c77e..14cb18b136 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java @@ -53,7 +53,7 @@ public class CraftDispenser extends CraftLootable<TileEntityDispenser> implement CraftWorld world = (CraftWorld) this.getWorld(); BlockDispenser dispense = (BlockDispenser) Blocks.DISPENSER; - dispense.dispense(world.getHandle(), this.getPosition()); + dispense.dispenseFrom(world.getHandle(), this.getPosition()); return true; } else { return false; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java index 7df00f6938..9bd43e7914 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java @@ -40,7 +40,7 @@ public class CraftDropper extends CraftLootable<TileEntityDropper> implements Dr CraftWorld world = (CraftWorld) this.getWorld(); BlockDropper drop = (BlockDropper) Blocks.DROPPER; - drop.dispense(world.getHandle(), this.getPosition()); + drop.dispenseFrom(world.getHandle(), this.getPosition()); } } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java index ecf1bd31e7..5746082f5e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java @@ -36,7 +36,7 @@ public abstract class CraftFurnace<T extends TileEntityFurnace> extends CraftCon public void setBurnTime(short burnTime) { this.getSnapshot().litTime = burnTime; // SPIGOT-844: Allow lighting and relighting using this API - this.data = this.data.set(BlockFurnace.LIT, burnTime > 0); + this.data = this.data.setValue(BlockFurnace.LIT, burnTime > 0); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java index 469904ee92..8950b032e2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java @@ -28,9 +28,9 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple CraftWorld world = (CraftWorld) this.getWorld(); Material record = this.getPlaying(); if (record == Material.AIR) { - getWorldHandle().setTypeAndData(this.getPosition(), Blocks.JUKEBOX.getBlockData().set(BlockJukeBox.HAS_RECORD, false), 3); + getWorldHandle().setBlock(this.getPosition(), Blocks.JUKEBOX.defaultBlockState().setValue(BlockJukeBox.HAS_RECORD, false), 3); } else { - getWorldHandle().setTypeAndData(this.getPosition(), Blocks.JUKEBOX.getBlockData().set(BlockJukeBox.HAS_RECORD, true), 3); + getWorldHandle().setBlock(this.getPosition(), Blocks.JUKEBOX.defaultBlockState().setValue(BlockJukeBox.HAS_RECORD, true), 3); } world.playEffect(this.getLocation(), Effect.RECORD_PLAY, record); } @@ -63,15 +63,15 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple ItemStack nms = CraftItemStack.asNMSCopy(record); this.getSnapshot().setRecord(nms); if (nms.isEmpty()) { - this.data = this.data.set(BlockJukeBox.HAS_RECORD, false); + this.data = this.data.setValue(BlockJukeBox.HAS_RECORD, false); } else { - this.data = this.data.set(BlockJukeBox.HAS_RECORD, true); + this.data = this.data.setValue(BlockJukeBox.HAS_RECORD, true); } } @Override public boolean isPlaying() { - return getHandle().get(BlockJukeBox.HAS_RECORD); + return getHandle().getValue(BlockJukeBox.HAS_RECORD); } @Override @@ -89,7 +89,7 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple TileEntityJukeBox jukebox = (TileEntityJukeBox) tileEntity; boolean result = !jukebox.getRecord().isEmpty(); CraftWorld world = (CraftWorld) this.getWorld(); - ((BlockJukeBox) Blocks.JUKEBOX).dropRecord(world.getHandle(), getPosition()); + ((BlockJukeBox) Blocks.JUKEBOX).dropRecording(world.getHandle(), getPosition()); return result; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftLectern.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftLectern.java index 99cf060b61..f6f18e324d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftLectern.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftLectern.java @@ -43,7 +43,7 @@ public class CraftLectern extends CraftBlockEntityState<TileEntityLectern> imple boolean result = super.update(force, applyPhysics); if (result && this.getType() == Material.LECTERN && getWorldHandle() instanceof net.minecraft.world.level.World) { - BlockLectern.a(this.world.getHandle(), this.getPosition(), this.getHandle()); + BlockLectern.signalPageChange(this.world.getHandle(), this.getPosition(), this.getHandle()); } return result; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java index 29015ac9d1..78796c8f45 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java @@ -36,15 +36,15 @@ public class CraftShulkerBox extends CraftLootable<TileEntityShulkerBox> impleme public DyeColor getColor() { EnumColor color = ((BlockShulkerBox) CraftMagicNumbers.getBlock(this.getType())).color; - return (color == null) ? null : DyeColor.getByWoolData((byte) color.getColorIndex()); + return (color == null) ? null : DyeColor.getByWoolData((byte) color.getId()); } @Override public void open() { requirePlaced(); if (!getTileEntity().opened && getWorldHandle() instanceof net.minecraft.world.level.World) { - net.minecraft.world.level.World world = getTileEntity().getWorld(); - world.playBlockAction(getPosition(), getTileEntity().getBlock().getBlock(), 1, 1); + net.minecraft.world.level.World world = getTileEntity().getLevel(); + world.blockEvent(getPosition(), getTileEntity().getBlockState().getBlock(), 1, 1); world.playSound(null, getPosition(), SoundEffects.SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F); } getTileEntity().opened = true; @@ -54,8 +54,8 @@ public class CraftShulkerBox extends CraftLootable<TileEntityShulkerBox> impleme public void close() { requirePlaced(); if (getTileEntity().opened && getWorldHandle() instanceof net.minecraft.world.level.World) { - net.minecraft.world.level.World world = getTileEntity().getWorld(); - world.playBlockAction(getPosition(), getTileEntity().getBlock().getBlock(), 1, 0); + net.minecraft.world.level.World world = getTileEntity().getLevel(); + world.blockEvent(getPosition(), getTileEntity().getBlockState().getBlock(), 1, 0); world.playSound(null, getPosition(), SoundEffects.SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F); } getTileEntity().opened = false; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java index e4c7d17025..3cb7186440 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java @@ -64,12 +64,12 @@ public class CraftSign extends CraftBlockEntityState<TileEntitySign> implements @Override public DyeColor getColor() { - return DyeColor.getByWoolData((byte) getSnapshot().getColor().getColorIndex()); + return DyeColor.getByWoolData((byte) getSnapshot().getColor().getId()); } @Override public void setColor(DyeColor color) { - getSnapshot().setColor(EnumColor.fromColorIndex(color.getWoolData())); + getSnapshot().setColor(EnumColor.byId(color.getWoolData())); } @Override @@ -82,7 +82,7 @@ public class CraftSign extends CraftBlockEntityState<TileEntitySign> implements if (line.equals(originalLines[i])) { continue; // The line contents are still the same, skip. } - sign.a(i, CraftChatMessage.fromString(line)[0]); + sign.setMessage(i, CraftChatMessage.fromString(line)[0]); } } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java index 4da5a7a15b..a421e6d3a7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java @@ -65,7 +65,7 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement return false; } - GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(name).orElse(null); + GameProfile profile = MinecraftServer.getServer().getProfileCache().get(name).orElse(null); if (profile == null) { return false; } @@ -153,7 +153,7 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement super.applyTo(skull); if (getSkullType() == SkullType.PLAYER) { - skull.setGameProfile(profile); + skull.setOwner(profile); } } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java index 53ee384850..1a09e9e701 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java @@ -49,7 +49,7 @@ public class CraftStructureBlock extends CraftBlockEntityState<TileEntityStructu @Override public void setAuthor(LivingEntity entity) { Preconditions.checkArgument(entity != null, "Structure Block author entity cannot be null"); - getSnapshot().setAuthor(((CraftLivingEntity) entity).getHandle()); + getSnapshot().createdBy(((CraftLivingEntity) entity).getHandle()); } @Override @@ -105,7 +105,7 @@ public class CraftStructureBlock extends CraftBlockEntityState<TileEntityStructu @Override public UsageMode getUsageMode() { - return UsageMode.valueOf(getSnapshot().getUsageMode().name()); + return UsageMode.valueOf(getSnapshot().getMode().name()); } @Override @@ -179,13 +179,13 @@ public class CraftStructureBlock extends CraftBlockEntityState<TileEntityStructu // Ensure block type is correct if (access instanceof net.minecraft.world.level.World) { - tileEntity.setUsageMode(tileEntity.getUsageMode()); + tileEntity.setMode(tileEntity.getMode()); } else if (access != null) { // Custom handle during world generation // From TileEntityStructure#setUsageMode(BlockPropertyStructureMode) - net.minecraft.world.level.block.state.IBlockData data = access.getType(this.getPosition()); - if (data.a(net.minecraft.world.level.block.Blocks.STRUCTURE_BLOCK)) { - access.setTypeAndData(this.getPosition(), data.set(net.minecraft.world.level.block.BlockStructure.MODE, tileEntity.getUsageMode()), 2); + net.minecraft.world.level.block.state.IBlockData data = access.getBlockState(this.getPosition()); + if (data.is(net.minecraft.world.level.block.Blocks.STRUCTURE_BLOCK)) { + access.setBlock(this.getPosition(), data.setValue(net.minecraft.world.level.block.BlockStructure.MODE, tileEntity.getMode()), 2); } } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java index e39d5abcbd..2990d9e8a1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java @@ -60,7 +60,7 @@ public class CraftBlockData implements BlockData { * @return the matching Bukkit type */ protected <B extends Enum<B>> B get(BlockStateEnum<?> nms, Class<B> bukkit) { - return toBukkit(state.get(nms), bukkit); + return toBukkit(state.getValue(nms), bukkit); } /** @@ -76,7 +76,7 @@ public class CraftBlockData implements BlockData { protected <B extends Enum<B>> Set<B> getValues(BlockStateEnum<?> nms, Class<B> bukkit) { ImmutableSet.Builder<B> values = ImmutableSet.builder(); - for (Enum<?> e : nms.getValues()) { + for (Enum<?> e : nms.getPossibleValues()) { values.add(toBukkit(e, bukkit)); } @@ -93,7 +93,7 @@ public class CraftBlockData implements BlockData { */ protected <B extends Enum<B>, N extends Enum<N> & INamable> void set(BlockStateEnum<N> nms, Enum<B> bukkit) { this.parsedStates = null; - this.state = this.state.set(nms, toNMS(bukkit, nms.getType())); + this.state = this.state.setValue(nms, toNMS(bukkit, nms.getValueClass())); } @Override @@ -106,7 +106,7 @@ public class CraftBlockData implements BlockData { clone.parsedStates = null; for (IBlockState parsed : craft.parsedStates.keySet()) { - clone.state = clone.state.set(parsed, craft.state.get(parsed)); + clone.state = clone.state.setValue(parsed, craft.state.getValue(parsed)); } return clone; @@ -178,7 +178,7 @@ public class CraftBlockData implements BlockData { */ protected <T extends Comparable<T>> T get(IBlockState<T> ibs) { // Straight integer or boolean getter - return this.state.get(ibs); + return this.state.getValue(ibs); } /** @@ -192,12 +192,12 @@ public class CraftBlockData implements BlockData { public <T extends Comparable<T>, V extends T> void set(IBlockState<T> ibs, V v) { // Straight integer or boolean setter this.parsedStates = null; - this.state = this.state.set(ibs, v); + this.state = this.state.setValue(ibs, v); } @Override public String getAsString() { - return toString(state.getStateMap()); + return toString(state.getValues()); } @Override @@ -235,10 +235,10 @@ public class CraftBlockData implements BlockData { public NBTTagCompound toStates() { NBTTagCompound compound = new NBTTagCompound(); - for (Map.Entry<IBlockState<?>, Comparable<?>> entry : state.getStateMap().entrySet()) { + for (Map.Entry<IBlockState<?>, Comparable<?>> entry : state.getValues().entrySet()) { IBlockState iblockstate = (IBlockState) entry.getKey(); - compound.setString(iblockstate.getName(), iblockstate.a(entry.getValue())); + compound.putString(iblockstate.getName(), iblockstate.getName(entry.getValue())); } return compound; @@ -303,9 +303,9 @@ public class CraftBlockData implements BlockData { for (Block instance : IRegistry.BLOCK) { if (instance.getClass() == block) { if (state == null) { - state = instance.getStates().a(name); + state = instance.getStateDefinition().getProperty(name); } else { - IBlockState<?> newState = instance.getStates().a(name); + IBlockState<?> newState = instance.getStateDefinition().getProperty(name); Preconditions.checkState(state == newState, "State mistmatch %s,%s", state, newState); } @@ -510,16 +510,16 @@ public class CraftBlockData implements BlockData { } StringReader reader = new StringReader(data); - ArgumentBlock arg = new ArgumentBlock(reader, false).a(false); + ArgumentBlock arg = new ArgumentBlock(reader, false).parse(false); Preconditions.checkArgument(!reader.canRead(), "Spurious trailing data: " + data); - blockData = arg.getBlockData(); - parsed = arg.getStateMap(); + blockData = arg.getState(); + parsed = arg.getProperties(); } catch (CommandSyntaxException ex) { throw new IllegalArgumentException("Could not parse data: " + data, ex); } } else { - blockData = block.getBlockData(); + blockData = block.defaultBlockState(); } CraftBlockData craft = fromData(blockData); @@ -533,6 +533,6 @@ public class CraftBlockData implements BlockData { @Override public SoundGroup getSoundGroup() { - return CraftSoundGroup.getSoundGroup(state.getStepSound()); + return CraftSoundGroup.getSoundGroup(state.getSoundType()); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleaf.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleaf.java index 435386dbff..5adfa59fe1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleaf.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleaf.java @@ -3,6 +3,8 @@ */ package org.bukkit.craftbukkit.block.impl; +import org.bukkit.block.data.type.BigDripleaf.Tilt; + public final class CraftBigDripleaf extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.BigDripleaf, org.bukkit.block.data.type.Dripleaf, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged { public CraftBigDripleaf() { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/bootstrap/Main.java b/paper-server/src/main/java/org/bukkit/craftbukkit/bootstrap/Main.java new file mode 100644 index 0000000000..f8a4122d1c --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/bootstrap/Main.java @@ -0,0 +1,168 @@ +// Based on net.minecraft.bundler.Main +package org.bukkit.craftbukkit.bootstrap; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.security.DigestOutputStream; +import java.security.MessageDigest; +import java.util.ArrayList; +import java.util.List; + +public class Main { + + public static void main(String[] argv) { + new Main().run(argv); + } + + private void run(String[] argv) { + try { + String defaultMainClassName = readResource("main-class", BufferedReader::readLine); + String mainClassName = System.getProperty("bundlerMainClass", defaultMainClassName); + + String repoDir = System.getProperty("bundlerRepoDir", "bundler"); + Path outputDir = Paths.get(repoDir).toAbsolutePath(); + Files.createDirectories(outputDir); + + System.out.println("Unbundling libraries to " + outputDir); + + boolean readOnly = Boolean.getBoolean("bundlerReadOnly"); + List<URL> extractedUrls = new ArrayList<>(); + readAndExtractDir("versions", outputDir, extractedUrls, readOnly); + readAndExtractDir("libraries", outputDir, extractedUrls, readOnly); + + if (mainClassName == null || mainClassName.isEmpty()) { + System.out.println("Empty main class specified, exiting"); + System.exit(0); + } + + ClassLoader maybePlatformClassLoader = getClass().getClassLoader().getParent(); + URLClassLoader classLoader = new URLClassLoader(extractedUrls.toArray(new URL[0]), maybePlatformClassLoader); + + System.out.println("Starting server"); + Thread runThread = new Thread(() -> { + try { + Class<?> mainClass = Class.forName(mainClassName, true, classLoader); + MethodHandle mainHandle = MethodHandles.lookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)).asFixedArity(); + mainHandle.invoke(argv); + } catch (Throwable t) { + Thrower.INSTANCE.sneakyThrow(t); + } + }, "ServerMain"); + + runThread.setContextClassLoader(classLoader); + runThread.start(); + } catch (Exception e) { + e.printStackTrace(System.out); + System.out.println("Failed to extract server libraries, exiting"); + } + } + + private <T> T readResource(String resource, ResourceParser<T> parser) throws Exception { + String fullPath = "/META-INF/" + resource; + try (InputStream is = getClass().getResourceAsStream(fullPath)) { + if (is == null) { + throw new IllegalStateException("Resource " + fullPath + " not found"); + } + return parser.parse(new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))); + } + } + + private void readAndExtractDir(String subdir, Path outputDir, List<URL> extractedUrls, boolean readOnly) throws Exception { + List<FileEntry> entries = readResource(subdir + ".list", reader -> reader.lines().map(FileEntry::parseLine).toList()); + Path subdirPath = outputDir.resolve(subdir); + for (FileEntry entry : entries) { + if (entry.path.startsWith("minecraft-server")) { + continue; + } + Path outputFile = subdirPath.resolve(entry.path); + if (!readOnly) { + checkAndExtractJar(subdir, entry, outputFile); + } + extractedUrls.add(outputFile.toUri().toURL()); + } + } + + private void checkAndExtractJar(String subdir, FileEntry entry, Path outputFile) throws Exception { + if (!Files.exists(outputFile) || !checkIntegrity(outputFile, entry.hash())) { + System.out.printf("Unpacking %s (%s:%s) to %s%n", entry.path, subdir, entry.id, outputFile); + extractJar(subdir, entry.path, outputFile); + } + } + + private void extractJar(String subdir, String jarPath, Path outputFile) throws IOException { + Files.createDirectories(outputFile.getParent()); + + try (InputStream input = getClass().getResourceAsStream("/META-INF/" + subdir + "/" + jarPath)) { + if (input == null) { + throw new IllegalStateException("Declared library " + jarPath + " not found"); + } + + Files.copy(input, outputFile, StandardCopyOption.REPLACE_EXISTING); + } + } + + private static boolean checkIntegrity(Path file, String expectedHash) throws Exception { + MessageDigest digest = MessageDigest.getInstance("SHA-256"); + + try (InputStream output = Files.newInputStream(file)) { + output.transferTo(new DigestOutputStream(OutputStream.nullOutputStream(), digest)); + + String actualHash = byteToHex(digest.digest()); + if (actualHash.equalsIgnoreCase(expectedHash)) { + return true; + } + + System.out.printf("Expected file %s to have hash %s, but got %s%n", new Object[]{file, expectedHash, actualHash}); + } + return false; + } + + private static String byteToHex(byte[] bytes) { + StringBuilder result = new StringBuilder(bytes.length * 2); + for (byte b : bytes) { + result.append(Character.forDigit(b >> 4 & 0xF, 16)); + result.append(Character.forDigit(b >> 0 & 0xF, 16)); + } + return result.toString(); + } + + @FunctionalInterface + private static interface ResourceParser<T> { + + T parse(BufferedReader param1BufferedReader) throws Exception; + } + + private static final record FileEntry(String hash, String id, String path) { + + public static FileEntry parseLine(String line) { + String[] fields = line.split(" "); + if (fields.length != 2) { + throw new IllegalStateException("Malformed library entry: " + line); + } + String path = fields[1].substring(1); + return new FileEntry(fields[0], path, path); + } + } + + private static class Thrower<T extends Throwable> { + + private static final Thrower<RuntimeException> INSTANCE = new Thrower(); + + public void sneakyThrow(Throwable exception) throws T { + throw (T) exception; + } + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java b/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java index bffa45126a..3987087351 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java @@ -48,9 +48,9 @@ public class CraftBossBar implements BossBar { private void initialize() { this.flags = new HashMap<>(); - this.flags.put(BarFlag.DARKEN_SKY, new FlagContainer(handle::isDarkenSky, handle::setDarkenSky)); - this.flags.put(BarFlag.PLAY_BOSS_MUSIC, new FlagContainer(handle::isPlayMusic, handle::setPlayMusic)); - this.flags.put(BarFlag.CREATE_FOG, new FlagContainer(handle::isCreateFog, handle::setCreateFog)); + this.flags.put(BarFlag.DARKEN_SKY, new FlagContainer(handle::shouldDarkenScreen, handle::setDarkenScreen)); + this.flags.put(BarFlag.PLAY_BOSS_MUSIC, new FlagContainer(handle::shouldPlayBossMusic, handle::setPlayBossMusic)); + this.flags.put(BarFlag.CREATE_FOG, new FlagContainer(handle::shouldCreateWorldFog, handle::setCreateWorldFog)); } private BarColor convertColor(BossBattle.BarColor color) { @@ -103,7 +103,7 @@ public class CraftBossBar implements BossBar { @Override public void setTitle(String title) { handle.name = CraftChatMessage.fromString(title, true)[0]; - handle.sendUpdate(PacketPlayOutBoss::createUpdateNamePacket); + handle.broadcast(PacketPlayOutBoss::createUpdateNamePacket); } @Override @@ -114,7 +114,7 @@ public class CraftBossBar implements BossBar { @Override public void setColor(BarColor color) { handle.color = convertColor(color); - handle.sendUpdate(PacketPlayOutBoss::createUpdateStylePacket); + handle.broadcast(PacketPlayOutBoss::createUpdateStylePacket); } @Override @@ -125,7 +125,7 @@ public class CraftBossBar implements BossBar { @Override public void setStyle(BarStyle style) { handle.overlay = convertStyle(style); - handle.sendUpdate(PacketPlayOutBoss::createUpdateStylePacket); + handle.broadcast(PacketPlayOutBoss::createUpdateStylePacket); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java b/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java index a954f47033..6a0cbc244a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java @@ -40,22 +40,22 @@ public class CraftDragonBattle implements DragonBattle { @Override public boolean generateEndPortal(boolean withPortals) { - if (handle.portalLocation != null || handle.getExitPortalShape() != null) { + if (handle.portalLocation != null || handle.findExitPortal() != null) { return false; } - this.handle.generateExitPortal(withPortals); + this.handle.spawnExitPortal(withPortals); return true; } @Override public boolean hasBeenPreviouslyKilled() { - return handle.isPreviouslyKilled(); + return handle.hasPreviouslyKilledDragon(); } @Override public void initiateRespawn() { - this.handle.initiateRespawn(); + this.handle.tryRespawn(); } @Override @@ -71,13 +71,13 @@ public class CraftDragonBattle implements DragonBattle { return false; } - this.handle.setRespawnPhase(toNMSRespawnPhase(phase)); + this.handle.setRespawnStage(toNMSRespawnPhase(phase)); return true; } @Override public void resetCrystals() { - this.handle.resetCrystals(); + this.handle.resetSpikeCrystals(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftKeyedBossbar.java b/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftKeyedBossbar.java index 555633b6c4..cf4a9b150b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftKeyedBossbar.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftKeyedBossbar.java @@ -13,7 +13,7 @@ public class CraftKeyedBossbar extends CraftBossBar implements KeyedBossBar { @Override public NamespacedKey getKey() { - return CraftNamespacedKey.fromMinecraft(getHandle().getKey()); + return CraftNamespacedKey.fromMinecraft(getHandle().getTextId()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java b/paper-server/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java index 23d922a8ba..785b681a29 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java @@ -46,7 +46,7 @@ public class BukkitCommandWrapper implements com.mojang.brigadier.Command<Comman @Override public CompletableFuture<Suggestions> getSuggestions(CommandContext<CommandListenerWrapper> context, SuggestionsBuilder builder) throws CommandSyntaxException { - List<String> results = server.tabComplete(context.getSource().getBukkitSender(), builder.getInput(), context.getSource().getWorld(), context.getSource().getPosition(), true); + List<String> results = server.tabComplete(context.getSource().getBukkitSender(), builder.getInput(), context.getSource().getLevel(), context.getSource().getPosition(), true); // Defaults to sub nodes, but we have just one giant args node, so offset accordingly builder = builder.createOffset(builder.getInput().lastIndexOf(' ') + 1); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java b/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java index 8d857e7d50..ca31e5ffbd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java @@ -24,7 +24,7 @@ public class CraftBlockCommandSender extends ServerCommandSender implements Bloc @Override public Block getBlock() { - return CraftBlock.at(tile.getWorld(), tile.getPosition()); + return CraftBlock.at(tile.getLevel(), tile.getBlockPos()); } @Override @@ -43,7 +43,7 @@ public class CraftBlockCommandSender extends ServerCommandSender implements Bloc @Override public String getName() { - return block.getName(); + return block.getTextName(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java b/paper-server/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java index a3fc0c0597..09eb0207be 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java @@ -42,7 +42,7 @@ public final class VanillaCommandWrapper extends BukkitCommand { if (!testPermission(sender)) return true; CommandListenerWrapper icommandlistener = getListener(sender); - dispatcher.a(icommandlistener, toDispatcher(args, getName()), toDispatcher(args, commandLabel), true); + dispatcher.performCommand(icommandlistener, toDispatcher(args, getName()), toDispatcher(args, commandLabel), true); return true; } @@ -53,10 +53,10 @@ public final class VanillaCommandWrapper extends BukkitCommand { Validate.notNull(alias, "Alias cannot be null"); CommandListenerWrapper icommandlistener = getListener(sender); - ParseResults<CommandListenerWrapper> parsed = dispatcher.a().parse(toDispatcher(args, getName()), icommandlistener); + ParseResults<CommandListenerWrapper> parsed = dispatcher.getDispatcher().parse(toDispatcher(args, getName()), icommandlistener); List<String> results = new ArrayList<>(); - dispatcher.a().getCompletionSuggestions(parsed).thenAccept((suggestions) -> { + dispatcher.getDispatcher().getCompletionSuggestions(parsed).thenAccept((suggestions) -> { suggestions.getList().forEach((s) -> results.add(s.getText())); }); @@ -65,19 +65,19 @@ public final class VanillaCommandWrapper extends BukkitCommand { public static CommandListenerWrapper getListener(CommandSender sender) { if (sender instanceof Player) { - return ((CraftPlayer) sender).getHandle().getCommandListener(); + return ((CraftPlayer) sender).getHandle().createCommandSourceStack(); } if (sender instanceof BlockCommandSender) { return ((CraftBlockCommandSender) sender).getWrapper(); } if (sender instanceof CommandMinecart) { - return ((EntityMinecartCommandBlock) ((CraftMinecartCommand) sender).getHandle()).getCommandBlock().getWrapper(); + return ((EntityMinecartCommandBlock) ((CraftMinecartCommand) sender).getHandle()).getCommandBlock().createCommandSourceStack(); } if (sender instanceof RemoteConsoleCommandSender) { - return ((DedicatedServer) MinecraftServer.getServer()).rconConsoleSource.getWrapper(); + return ((DedicatedServer) MinecraftServer.getServer()).rconConsoleSource.createCommandSourceStack(); } if (sender instanceof ConsoleCommandSender) { - return ((CraftServer) sender.getServer()).getServer().getServerCommandListener(); + return ((CraftServer) sender.getServer()).getServer().createCommandSourceStack(); } if (sender instanceof ProxiedCommandSender) { return ((ProxiedNativeCommandSender) sender).getHandle(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java index 0f038a258e..b4027b6206 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java @@ -25,7 +25,7 @@ public class CraftEnchantment extends Enchantment { @Override public int getStartLevel() { - return target.getStartLevel(); + return target.getMinLevel(); } @Override @@ -66,7 +66,7 @@ public class CraftEnchantment extends Enchantment { @Override public boolean isTreasure() { - return target.isTreasure(); + return target.isTreasureOnly(); } @Override @@ -185,7 +185,7 @@ public class CraftEnchantment extends Enchantment { return false; } CraftEnchantment ench = (CraftEnchantment) other; - return !target.isCompatible(ench.target); + return !target.isCompatibleWith(ench.target); } public net.minecraft.world.item.enchantment.Enchantment getHandle() { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java index 21da1f9f91..b13d7384b6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java @@ -41,7 +41,7 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac @Override public int getMaxDomestication() { - return getHandle().getMaxDomestication(); + return getHandle().getMaxTemper(); } @Override @@ -52,13 +52,13 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac @Override public double getJumpStrength() { - return getHandle().getJumpStrength(); + return getHandle().getCustomJump(); } @Override public void setJumpStrength(double strength) { Validate.isTrue(strength >= 0, "Jump strength cannot be less than zero"); - getHandle().getAttributeInstance(GenericAttributes.JUMP_STRENGTH).setValue(strength); + getHandle().getAttribute(GenericAttributes.JUMP_STRENGTH).setBaseValue(strength); } @Override @@ -81,7 +81,7 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac public void setOwner(AnimalTamer owner) { if (owner != null) { setTamed(true); - getHandle().setGoalTarget(null, null, false); + getHandle().setTarget(null, null, false); setOwnerUUID(owner.getUniqueId()); } else { setTamed(false); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java index d51996f857..e8f57ccb35 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java @@ -16,7 +16,7 @@ public class CraftAgeable extends CraftCreature implements Ageable { @Override public void setAge(int age) { - getHandle().setAgeRaw(age); + getHandle().setAge(age); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java index 9aa0cbb7fc..83d00577b8 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java @@ -43,7 +43,7 @@ public class CraftAnimals extends CraftAgeable implements Animals { @Override public void setLoveModeTicks(int ticks) { Preconditions.checkArgument(ticks >= 0, "Love mode ticks must be positive or 0"); - getHandle().setLoveTicks(ticks); + getHandle().setInLoveTime(ticks); } @Override @@ -53,7 +53,7 @@ public class CraftAnimals extends CraftAgeable implements Animals { @Override public boolean isBreedItem(ItemStack itemStack) { - return getHandle().isBreedItem(CraftItemStack.asNMSCopy(itemStack)); + return getHandle().isFood(CraftItemStack.asNMSCopy(itemStack)); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java index 73c4b549d0..1a5e537669 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java @@ -133,7 +133,7 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud @Override public void setColor(Color color) { - getHandle().setColor(color.asRGB()); + getHandle().setFixedColor(color.asRGB()); } @Override @@ -141,7 +141,7 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud int effectId = effect.getType().getId(); MobEffect existing = null; for (MobEffect mobEffect : getHandle().effects) { - if (MobEffectList.getId(mobEffect.getMobEffect()) == effectId) { + if (MobEffectList.getId(mobEffect.getEffect()) == effectId) { existing = mobEffect; } } @@ -174,7 +174,7 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud @Override public boolean hasCustomEffect(PotionEffectType type) { for (MobEffect effect : getHandle().effects) { - if (CraftPotionUtil.equals(effect.getMobEffect(), type)) { + if (CraftPotionUtil.equals(effect.getEffect(), type)) { return true; } } @@ -191,7 +191,7 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud int effectId = effect.getId(); MobEffect existing = null; for (MobEffect mobEffect : getHandle().effects) { - if (MobEffectList.getId(mobEffect.getMobEffect()) == effectId) { + if (MobEffectList.getId(mobEffect.getEffect()) == effectId) { existing = mobEffect; } } @@ -206,26 +206,26 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud @Override public void setBasePotionData(PotionData data) { Validate.notNull(data, "PotionData cannot be null"); - getHandle().setType(CraftPotionUtil.fromBukkit(data)); + getHandle().setPotionType(CraftPotionUtil.fromBukkit(data)); } @Override public PotionData getBasePotionData() { - return CraftPotionUtil.toBukkit(getHandle().getType()); + return CraftPotionUtil.toBukkit(getHandle().getPotionType()); } @Override public ProjectileSource getSource() { - EntityLiving source = getHandle().getSource(); + EntityLiving source = getHandle().getOwner(); return (source == null) ? null : (LivingEntity) source.getBukkitEntity(); } @Override public void setSource(ProjectileSource shooter) { if (shooter instanceof CraftLivingEntity) { - getHandle().setSource((EntityLiving) ((CraftLivingEntity) shooter).getHandle()); + getHandle().setOwner((EntityLiving) ((CraftLivingEntity) shooter).getHandle()); } else { - getHandle().setSource((EntityLiving) null); + getHandle().setOwner((EntityLiving) null); } } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java index da1a5a04ec..6a8557724e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java @@ -144,12 +144,12 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand { @Override public boolean hasBasePlate() { - return !getHandle().hasBasePlate(); + return !getHandle().isNoBasePlate(); } @Override public void setBasePlate(boolean basePlate) { - getHandle().setBasePlate(!basePlate); + getHandle().setNoBasePlate(!basePlate); } @Override @@ -171,12 +171,12 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand { @Override public boolean hasArms() { - return getHandle().hasArms(); + return getHandle().isShowArms(); } @Override public void setArms(boolean arms) { - getHandle().setArms(arms); + getHandle().setShowArms(arms); } @Override @@ -217,16 +217,16 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand { @Override public void addEquipmentLock(EquipmentSlot equipmentSlot, LockType lockType) { - getHandle().disabledSlots |= (1 << CraftEquipmentSlot.getNMS(equipmentSlot).getSlotFlag() + lockType.ordinal() * 8); + getHandle().disabledSlots |= (1 << CraftEquipmentSlot.getNMS(equipmentSlot).getFilterFlag() + lockType.ordinal() * 8); } @Override public void removeEquipmentLock(EquipmentSlot equipmentSlot, LockType lockType) { - getHandle().disabledSlots &= ~(1 << CraftEquipmentSlot.getNMS(equipmentSlot).getSlotFlag() + lockType.ordinal() * 8); + getHandle().disabledSlots &= ~(1 << CraftEquipmentSlot.getNMS(equipmentSlot).getFilterFlag() + lockType.ordinal() * 8); } @Override public boolean hasEquipmentLock(EquipmentSlot equipmentSlot, LockType lockType) { - return (getHandle().disabledSlots & (1 << CraftEquipmentSlot.getNMS(equipmentSlot).getSlotFlag() + lockType.ordinal() * 8)) != 0; + return (getHandle().disabledSlots & (1 << CraftEquipmentSlot.getNMS(equipmentSlot).getFilterFlag() + lockType.ordinal() * 8)) != 0; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java index bdfbab7452..139d902cbc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java @@ -21,7 +21,7 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow { @Override public void setKnockbackStrength(int knockbackStrength) { Validate.isTrue(knockbackStrength >= 0, "Knockback cannot be negative"); - getHandle().setKnockbackStrength(knockbackStrength); + getHandle().setKnockback(knockbackStrength); } @Override @@ -31,13 +31,13 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow { @Override public double getDamage() { - return getHandle().getDamage(); + return getHandle().getBaseDamage(); } @Override public void setDamage(double damage) { Preconditions.checkArgument(damage >= 0, "Damage must be positive"); - getHandle().setDamage(damage); + getHandle().setBaseDamage(damage); } @Override @@ -54,12 +54,12 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow { @Override public boolean isCritical() { - return getHandle().isCritical(); + return getHandle().isCritArrow(); } @Override public void setCritical(boolean critical) { - getHandle().setCritical(critical); + getHandle().setCritArrow(critical); } @Override @@ -70,9 +70,9 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow { @Override public void setShooter(ProjectileSource shooter) { if (shooter instanceof Entity) { - getHandle().setShooter(((CraftEntity) shooter).getHandle()); + getHandle().setOwner(((CraftEntity) shooter).getHandle()); } else { - getHandle().setShooter(null); + getHandle().setOwner(null); } getHandle().projectileSource = shooter; } @@ -88,7 +88,7 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow { return null; } - BlockPosition pos = getHandle().getChunkCoordinates(); + BlockPosition pos = getHandle().blockPosition(); return getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); } @@ -100,7 +100,7 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow { @Override public void setPickupStatus(PickupStatus status) { Preconditions.checkNotNull(status, "status"); - getHandle().pickup = EntityArrow.PickupStatus.a(status.ordinal()); + getHandle().pickup = EntityArrow.PickupStatus.byOrdinal(status.ordinal()); } @Override @@ -113,7 +113,7 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow { @Override public boolean isShotFromCrossbow() { - return getHandle().isShotFromCrossbow(); + return getHandle().shotFromCrossbow(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java index 822fd12b93..8e34b8dd81 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java @@ -27,11 +27,11 @@ public class CraftBat extends CraftAmbient implements Bat { @Override public boolean isAwake() { - return !getHandle().isAsleep(); + return !getHandle().isResting(); } @Override public void setAwake(boolean state) { - getHandle().setAsleep(!state); + getHandle().setResting(!state); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java index 3b5063c895..4757719857 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java @@ -43,14 +43,14 @@ public class CraftBee extends CraftAnimals implements Bee { @Override public Location getFlower() { - BlockPosition flower = getHandle().getFlowerPos(); + BlockPosition flower = getHandle().getSavedFlowerPos(); return (flower == null) ? null : new Location(getWorld(), flower.getX(), flower.getY(), flower.getZ()); } @Override public void setFlower(Location location) { Preconditions.checkArgument(location == null || this.getWorld().equals(location.getWorld()), "Flower must be in same world"); - getHandle().setFlowerPos(location == null ? null : new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ())); + getHandle().setSavedFlowerPos(location == null ? null : new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ())); } @Override @@ -75,12 +75,12 @@ public class CraftBee extends CraftAnimals implements Bee { @Override public int getAnger() { - return getHandle().getAnger(); + return getHandle().getRemainingPersistentAngerTime(); } @Override public void setAnger(int anger) { - getHandle().setAnger(anger); + getHandle().setRemainingPersistentAngerTime(anger); } @Override @@ -90,6 +90,6 @@ public class CraftBee extends CraftAnimals implements Bee { @Override public void setCannotEnterHiveTicks(int ticks) { - getHandle().setCannotEnterHiveTicks(ticks); + getHandle().setStayOutOfHiveCountdown(ticks); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java index c7a459c0c8..848f230978 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java @@ -14,7 +14,7 @@ public class CraftBoat extends CraftVehicle implements Boat { @Override public TreeSpecies getWoodType() { - return getTreeSpecies(getHandle().getType()); + return getTreeSpecies(getHandle().getBoatType()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java index 38a09900a4..d1ad336fbc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java @@ -44,11 +44,11 @@ public class CraftCat extends CraftTameableAnimal implements Cat { @Override public DyeColor getCollarColor() { - return DyeColor.getByWoolData((byte) getHandle().getCollarColor().getColorIndex()); + return DyeColor.getByWoolData((byte) getHandle().getCollarColor().getId()); } @Override public void setCollarColor(DyeColor color) { - getHandle().setCollarColor(EnumColor.fromColorIndex(color.getWoolData())); + getHandle().setCollarColor(EnumColor.byId(color.getWoolData())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java index 552dfbb880..723a429a9b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java @@ -17,13 +17,13 @@ public abstract class CraftChestedHorse extends CraftAbstractHorse implements Ch @Override public boolean isCarryingChest() { - return getHandle().isCarryingChest(); + return getHandle().hasChest(); } @Override public void setCarryingChest(boolean chest) { if (chest == isCarryingChest()) return; - getHandle().setCarryingChest(chest); - getHandle().loadChest(); + getHandle().setChest(chest); + getHandle().createInventory(); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java index c06af19d9a..3068e8467e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java @@ -73,7 +73,7 @@ public class CraftCreeper extends CraftMonster implements Creeper { @Override public void explode() { - getHandle().explode(); + getHandle().explodeCreeper(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderCrystal.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderCrystal.java index 66a461dddb..c22d70c0a8 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderCrystal.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderCrystal.java @@ -14,12 +14,12 @@ public class CraftEnderCrystal extends CraftEntity implements EnderCrystal { @Override public boolean isShowingBottom() { - return getHandle().isShowingBottom(); + return getHandle().showsBottom(); } @Override public void setShowingBottom(boolean showing) { - getHandle().setShowingBottom(showing); + getHandle().setShowBottom(showing); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java index 23074f0767..7a8359b0bc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java @@ -49,16 +49,16 @@ public class CraftEnderDragon extends CraftComplexLivingEntity implements EnderD @Override public Phase getPhase() { - return Phase.values()[getHandle().getDataWatcher().get(EntityEnderDragon.DATA_PHASE)]; + return Phase.values()[getHandle().getEntityData().get(EntityEnderDragon.DATA_PHASE)]; } @Override public void setPhase(Phase phase) { - getHandle().getDragonControllerManager().setControllerPhase(getMinecraftPhase(phase)); + getHandle().getPhaseManager().setPhase(getMinecraftPhase(phase)); } public static Phase getBukkitPhase(DragonControllerPhase phase) { - return Phase.values()[phase.b()]; + return Phase.values()[phase.getId()]; } public static DragonControllerPhase getMinecraftPhase(Phase phase) { @@ -73,7 +73,7 @@ public class CraftEnderDragon extends CraftComplexLivingEntity implements EnderD @Override public DragonBattle getDragonBattle() { - return getHandle().getEnderDragonBattle() != null ? new CraftDragonBattle(getHandle().getEnderDragonBattle()) : null; + return getHandle().getDragonFight() != null ? new CraftDragonBattle(getHandle().getDragonFight()) : null; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java index 1d9b9f5487..ffa4e57abc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java @@ -39,7 +39,7 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal { @Override public void setTargetLocation(Location location) { Preconditions.checkArgument(getWorld().equals(location.getWorld()), "Cannot target EnderSignal across worlds"); - getHandle().a(new BlockPosition(location.getX(), location.getY(), location.getZ())); + getHandle().signalTo(new BlockPosition(location.getX(), location.getY(), location.getZ())); } @Override @@ -54,12 +54,12 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal { @Override public ItemStack getItem() { - return CraftItemStack.asBukkitCopy(getHandle().getSuppliedItem()); + return CraftItemStack.asBukkitCopy(getHandle().getItem()); } @Override public void setItem(ItemStack item) { - getHandle().setItem(item != null ? CraftItemStack.asNMSCopy(item) : Items.ENDER_EYE.createItemStack()); + getHandle().setItem(item != null ? CraftItemStack.asNMSCopy(item) : Items.ENDER_EYE.getDefaultInstance()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java index 8894d61979..7eff75a22d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java @@ -18,24 +18,24 @@ public class CraftEnderman extends CraftMonster implements Enderman { @Override public MaterialData getCarriedMaterial() { - IBlockData blockData = getHandle().getCarried(); + IBlockData blockData = getHandle().getCarriedBlock(); return (blockData == null) ? Material.AIR.getNewData((byte) 0) : CraftMagicNumbers.getMaterial(blockData); } @Override public BlockData getCarriedBlock() { - IBlockData blockData = getHandle().getCarried(); + IBlockData blockData = getHandle().getCarriedBlock(); return (blockData == null) ? null : CraftBlockData.fromData(blockData); } @Override public void setCarriedMaterial(MaterialData data) { - getHandle().setCarried(CraftMagicNumbers.getBlock(data)); + getHandle().setCarriedBlock(CraftMagicNumbers.getBlock(data)); } @Override public void setCarriedBlock(BlockData blockData) { - getHandle().setCarried(blockData == null ? null : ((CraftBlockData) blockData).getState()); + getHandle().setCarriedBlock(blockData == null ? null : ((CraftBlockData) blockData).getState()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 73a8188e59..edd2276b69 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -408,16 +408,16 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public Location getLocation() { - return new Location(getWorld(), entity.locX(), entity.locY(), entity.locZ(), entity.getBukkitYaw(), entity.getXRot()); + return new Location(getWorld(), entity.getX(), entity.getY(), entity.getZ(), entity.getBukkitYaw(), entity.getXRot()); } @Override public Location getLocation(Location loc) { if (loc != null) { loc.setWorld(getWorld()); - loc.setX(entity.locX()); - loc.setY(entity.locY()); - loc.setZ(entity.locZ()); + loc.setX(entity.getX()); + loc.setY(entity.getY()); + loc.setZ(entity.getZ()); loc.setYaw(entity.getBukkitYaw()); loc.setPitch(entity.getXRot()); } @@ -427,25 +427,25 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public Vector getVelocity() { - return CraftVector.toBukkit(entity.getMot()); + return CraftVector.toBukkit(entity.getDeltaMovement()); } @Override public void setVelocity(Vector velocity) { Preconditions.checkArgument(velocity != null, "velocity"); velocity.checkFinite(); - entity.setMot(CraftVector.toNMS(velocity)); + entity.setDeltaMovement(CraftVector.toNMS(velocity)); entity.hurtMarked = true; } @Override public double getHeight() { - return getHandle().getHeight(); + return getHandle().getBbHeight(); } @Override public double getWidth() { - return getHandle().getWidth(); + return getHandle().getBbWidth(); } @Override @@ -484,7 +484,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { entity.setXRot(pitch); entity.yRotO = yaw; entity.xRotO = pitch; - entity.setHeadRotation(yaw); + entity.setYHeadRot(yaw); } @Override @@ -513,9 +513,9 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } // entity.setLocation() throws no event, and so cannot be cancelled - entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + entity.absMoveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); // SPIGOT-619: Force sync head rotation also - entity.setHeadRotation(location.getYaw()); + entity.setYHeadRot(location.getYaw()); return true; } @@ -534,7 +534,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { public List<org.bukkit.entity.Entity> getNearbyEntities(double x, double y, double z) { Preconditions.checkState(!entity.generation, "Cannot get nearby entities during world generation"); - List<Entity> notchEntityList = entity.level.getEntities(entity, entity.getBoundingBox().grow(x, y, z), Predicates.alwaysTrue()); + List<Entity> notchEntityList = entity.level.getEntities(entity, entity.getBoundingBox().inflate(x, y, z), Predicates.alwaysTrue()); List<org.bukkit.entity.Entity> bukkitEntityList = new java.util.ArrayList<org.bukkit.entity.Entity>(notchEntityList.size()); for (Entity e : notchEntityList) { @@ -555,7 +555,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public int getMaxFireTicks() { - return entity.getMaxFireTicks(); + return entity.getFireImmuneTicks(); } @Override @@ -597,7 +597,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public void remove() { - entity.die(); + entity.discard(); } @Override @@ -663,7 +663,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { public boolean addPassenger(org.bukkit.entity.Entity passenger) { Preconditions.checkArgument(passenger != null, "passenger == null"); - return ((CraftEntity) passenger).getHandle().a(getHandle(), true); + return ((CraftEntity) passenger).getHandle().startRiding(getHandle(), true); } @Override @@ -711,7 +711,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public UUID getUniqueId() { - return getHandle().getUniqueID(); + return getHandle().getUUID(); } @Override @@ -737,7 +737,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { Preconditions.checkState(!entity.generation, "Cannot play effect during world generation"); if (type.getApplicable().isInstance(this)) { - this.getHandle().level.broadcastEntityEffect(getHandle(), type.getData()); + this.getHandle().level.broadcastEntityEvent(getHandle(), type.getData()); } } @@ -841,7 +841,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public boolean isCustomNameVisible() { - return getHandle().getCustomNameVisible(); + return getHandle().isCustomNameVisible(); } @Override @@ -866,7 +866,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public String getName() { - return CraftChatMessage.fromComponent(getHandle().getDisplayName()); + return CraftChatMessage.fromComponent(getHandle().getName()); } @Override @@ -951,7 +951,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public boolean isInvulnerable() { - return getHandle().isInvulnerable(DamageSource.GENERIC); + return getHandle().isInvulnerableTo(DamageSource.GENERIC); } @Override @@ -986,28 +986,28 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public Set<String> getScoreboardTags() { - return getHandle().getScoreboardTags(); + return getHandle().getTags(); } @Override public boolean addScoreboardTag(String tag) { - return getHandle().addScoreboardTag(tag); + return getHandle().addTag(tag); } @Override public boolean removeScoreboardTag(String tag) { - return getHandle().removeScoreboardTag(tag); + return getHandle().removeTag(tag); } @Override public PistonMoveReaction getPistonMoveReaction() { - return PistonMoveReaction.getById(getHandle().getPushReaction().ordinal()); + return PistonMoveReaction.getById(getHandle().getPistonPushReaction().ordinal()); } @Override public BlockFace getFacing() { // Use this method over getDirection because it handles boats and minecarts. - return CraftBlock.notchToBlockFace(getHandle().getAdjustedDirection()); + return CraftBlock.notchToBlockFace(getHandle().getMotionDirection()); } @Override @@ -1022,7 +1022,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { public void storeBukkitValues(NBTTagCompound c) { if (!this.persistentDataContainer.isEmpty()) { - c.set("BukkitValues", this.persistentDataContainer.toTagCompound()); + c.put("BukkitValues", this.persistentDataContainer.toTagCompound()); } } @@ -1036,8 +1036,8 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { protected NBTTagCompound save() { NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setString("id", getHandle().getSaveID()); - getHandle().save(nbttagcompound); + nbttagcompound.putString("id", getHandle().getEncodeId()); + getHandle().saveWithoutId(nbttagcompound); return nbttagcompound; } @@ -1049,13 +1049,13 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } WorldServer world = ((CraftWorld) getWorld()).getHandle(); - PlayerChunkMap.EntityTracker entityTracker = world.getChunkProvider().chunkMap.entityMap.get(getEntityId()); + PlayerChunkMap.EntityTracker entityTracker = world.getChunkSource().chunkMap.entityMap.get(getEntityId()); if (entityTracker == null) { return; } - entityTracker.broadcast(getHandle().getPacket()); + entityTracker.broadcast(getHandle().getAddEntityPacket()); } private static PermissibleBase getPermissibleBase() { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java index 5e8e9d9506..fb490be8ef 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java @@ -29,11 +29,11 @@ public class CraftEvoker extends CraftSpellcaster implements Evoker { @Override public Evoker.Spell getCurrentSpell() { - return Evoker.Spell.values()[getHandle().getSpell().ordinal()]; + return Evoker.Spell.values()[getHandle().getCurrentSpell().ordinal()]; } @Override public void setCurrentSpell(Evoker.Spell spell) { - getHandle().setSpell(spell == null ? EntityIllagerWizard.Spell.NONE : EntityIllagerWizard.Spell.a(spell.ordinal())); + getHandle().setIsCastingSpell(spell == null ? EntityIllagerWizard.Spell.NONE : EntityIllagerWizard.Spell.byId(spell.ordinal())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java index 340ff53e2c..19c42371de 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java @@ -37,6 +37,6 @@ public class CraftEvokerFangs extends CraftEntity implements EvokerFangs { @Override public void setOwner(LivingEntity owner) { - getHandle().a(owner == null ? null : ((CraftLivingEntity) owner).getHandle()); + getHandle().setOwner(owner == null ? null : ((CraftLivingEntity) owner).getHandle()); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java index ed1a64976e..a1e5d5a8e3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java @@ -36,7 +36,7 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock { @Override public BlockData getBlockData() { - return CraftBlockData.fromData(getHandle().getBlock()); + return CraftBlockData.fromData(getHandle().getBlockState()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java index 54ca19fd05..44a5a58732 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java @@ -41,9 +41,9 @@ public class CraftFireball extends AbstractProjectile implements Fireball { @Override public void setShooter(ProjectileSource shooter) { if (shooter instanceof CraftLivingEntity) { - getHandle().setShooter(((CraftLivingEntity) shooter).getHandle()); + getHandle().setOwner(((CraftLivingEntity) shooter).getHandle()); } else { - getHandle().setShooter(null); + getHandle().setOwner(null); } getHandle().projectileSource = shooter; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java index 2759de2c63..c91468dec8 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java @@ -19,11 +19,11 @@ public class CraftFirework extends CraftProjectile implements Firework { public CraftFirework(CraftServer server, EntityFireworks entity) { super(server, entity); - ItemStack item = getHandle().getDataWatcher().get(EntityFireworks.DATA_ID_FIREWORKS_ITEM); + ItemStack item = getHandle().getEntityData().get(EntityFireworks.DATA_ID_FIREWORKS_ITEM); if (item.isEmpty()) { item = new ItemStack(Items.FIREWORK_ROCKET); - getHandle().getDataWatcher().set(EntityFireworks.DATA_ID_FIREWORKS_ITEM, item); + getHandle().getEntityData().set(EntityFireworks.DATA_ID_FIREWORKS_ITEM, item); } this.item = CraftItemStack.asCraftMirror(item); @@ -61,7 +61,7 @@ public class CraftFirework extends CraftProjectile implements Firework { // Copied from EntityFireworks constructor, update firework lifetime/power getHandle().lifetime = 10 * (1 + meta.getPower()) + random.nextInt(6) + random.nextInt(7); - getHandle().getDataWatcher().markDirty(EntityFireworks.DATA_ID_FIREWORKS_ITEM); + getHandle().getEntityData().markDirty(EntityFireworks.DATA_ID_FIREWORKS_ITEM); } @Override @@ -76,6 +76,6 @@ public class CraftFirework extends CraftProjectile implements Firework { @Override public void setShotAtAngle(boolean shotAtAngle) { - getHandle().getDataWatcher().set(EntityFireworks.DATA_SHOT_AT_ANGLE, shotAtAngle); + getHandle().getEntityData().set(EntityFireworks.DATA_SHOT_AT_ANGLE, shotAtAngle); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java index 5a02fab2e0..bcfd61ea61 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java @@ -71,7 +71,7 @@ public class CraftFishHook extends CraftProjectile implements FishHook { EntityFishingHook hook = getHandle(); if (this.biteChance == -1) { - if (hook.level.isRainingAt(new BlockPosition(MathHelper.floor(hook.locX()), MathHelper.floor(hook.locY()) + 1, MathHelper.floor(hook.locZ())))) { + if (hook.level.isRainingAt(new BlockPosition(MathHelper.floor(hook.getX()), MathHelper.floor(hook.getY()) + 1, MathHelper.floor(hook.getZ())))) { return 1 / 300.0; } return 1 / 500.0; @@ -87,7 +87,7 @@ public class CraftFishHook extends CraftProjectile implements FishHook { @Override public boolean isInOpenWater() { - return getHandle().isInOpenWater(); + return getHandle().isOpenWaterFishing(); } @Override @@ -101,7 +101,7 @@ public class CraftFishHook extends CraftProjectile implements FishHook { EntityFishingHook hook = getHandle(); hook.hookedIn = (entity != null) ? ((CraftEntity) entity).getHandle() : null; - hook.getDataWatcher().set(EntityFishingHook.DATA_HOOKED_ENTITY, hook.hookedIn != null ? hook.hookedIn.getId() + 1 : 0); + hook.getEntityData().set(EntityFishingHook.DATA_HOOKED_ENTITY, hook.hookedIn != null ? hook.hookedIn.getId() + 1 : 0); } @Override @@ -111,7 +111,7 @@ public class CraftFishHook extends CraftProjectile implements FishHook { return false; } - hook.reel(hook.hookedIn); + hook.pullEntity(hook.hookedIn); return true; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java index d8646392d2..02ff46c802 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java @@ -50,7 +50,7 @@ public class CraftFox extends CraftAnimals implements Fox { @Override public void setCrouching(boolean crouching) { - getHandle().setCrouching(crouching); + getHandle().setIsCrouching(crouching); } @Override @@ -70,7 +70,7 @@ public class CraftFox extends CraftAnimals implements Fox { @Override public AnimalTamer getFirstTrustedPlayer() { - UUID uuid = getHandle().getDataWatcher().get(EntityFox.DATA_TRUSTED_ID_0).orElse(null); + UUID uuid = getHandle().getEntityData().get(EntityFox.DATA_TRUSTED_ID_0).orElse(null); if (uuid == null) { return null; } @@ -85,16 +85,16 @@ public class CraftFox extends CraftAnimals implements Fox { @Override public void setFirstTrustedPlayer(AnimalTamer player) { - if (player == null && getHandle().getDataWatcher().get(EntityFox.DATA_TRUSTED_ID_1).isPresent()) { + if (player == null && getHandle().getEntityData().get(EntityFox.DATA_TRUSTED_ID_1).isPresent()) { throw new IllegalStateException("Must remove second trusted player first"); } - getHandle().getDataWatcher().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(player.getUniqueId())); } @Override public AnimalTamer getSecondTrustedPlayer() { - UUID uuid = getHandle().getDataWatcher().get(EntityFox.DATA_TRUSTED_ID_1).orElse(null); + UUID uuid = getHandle().getEntityData().get(EntityFox.DATA_TRUSTED_ID_1).orElse(null); if (uuid == null) { return null; } @@ -109,10 +109,10 @@ public class CraftFox extends CraftAnimals implements Fox { @Override public void setSecondTrustedPlayer(AnimalTamer player) { - if (player != null && !getHandle().getDataWatcher().get(EntityFox.DATA_TRUSTED_ID_0).isPresent()) { + if (player != null && !getHandle().getEntityData().get(EntityFox.DATA_TRUSTED_ID_0).isPresent()) { throw new IllegalStateException("Must add first trusted player first"); } - getHandle().getDataWatcher().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(player.getUniqueId())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowSquid.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowSquid.java index bcc1464bc5..44ba04c3fa 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowSquid.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowSquid.java @@ -34,6 +34,6 @@ public class CraftGlowSquid extends CraftSquid implements GlowSquid { @Override public void setDarkTicksRemaining(int darkTicksRemaining) { Preconditions.checkArgument(darkTicksRemaining >= 0, "darkTicksRemaining must be >= 0"); - getHandle().setDarkTicksRemaining(darkTicksRemaining); + getHandle().setDarkTicks(darkTicksRemaining); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGuardian.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGuardian.java index 980a6d5a72..be95190b75 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGuardian.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGuardian.java @@ -33,7 +33,7 @@ public class CraftGuardian extends CraftMonster implements Guardian { // clean up laser target, when target is removed if (target == null) { - getHandle().a(0); // PAIL rename setLaserTarget + getHandle().setActiveAttackTarget(0); } } @@ -45,9 +45,9 @@ public class CraftGuardian extends CraftMonster implements Guardian { return false; } - getHandle().a(target.getEntityId()); // PAIL rename setLaserTarget + getHandle().setActiveAttackTarget(target.getEntityId()); } else { - getHandle().a(0); // PAIL rename setLaserTarget + getHandle().setActiveAttackTarget(0); } return true; @@ -55,7 +55,7 @@ public class CraftGuardian extends CraftMonster implements Guardian { @Override public boolean hasLaser() { - return getHandle().fy(); // PAIL rename hasLaserTarget + return getHandle().hasActiveAttackTarget(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java index 1c7ef05e48..6a4712b940 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java @@ -31,24 +31,24 @@ public class CraftHorse extends CraftAbstractHorse implements Horse { @Override public Color getColor() { - return Color.values()[getHandle().getColor().a()]; + return Color.values()[getHandle().getVariant().getId()]; } @Override public void setColor(Color color) { Validate.notNull(color, "Color cannot be null"); - getHandle().setVariant(HorseColor.a(color.ordinal()), getHandle().getStyle()); + getHandle().setVariantAndMarkings(HorseColor.byId(color.ordinal()), getHandle().getMarkings()); } @Override public Style getStyle() { - return Style.values()[getHandle().getStyle().a()]; + return Style.values()[getHandle().getMarkings().getId()]; } @Override public void setStyle(Style style) { Validate.notNull(style, "Style cannot be null"); - getHandle().setVariant(getHandle().getColor(), HorseStyle.a(style.ordinal())); + getHandle().setVariantAndMarkings(getHandle().getVariant(), HorseStyle.byId(style.ordinal())); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 3b9604f6f9..212c9fa06f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -74,7 +74,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { super(server, entity); mode = server.getDefaultGameMode(); this.inventory = new CraftInventoryPlayer(entity.getInventory()); - enderChest = new CraftInventory(entity.getEnderChest()); + enderChest = new CraftInventory(entity.getEnderChestInventory()); } @Override @@ -94,7 +94,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @Override public MainHand getMainHand() { - return getHandle().getMainHand() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT; + return getHandle().getMainArm() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT; } @Override @@ -133,18 +133,18 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { Preconditions.checkArgument(location.getWorld().equals(getWorld()), "Cannot sleep across worlds"); BlockPosition blockposition = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - IBlockData iblockdata = getHandle().level.getType(blockposition); + IBlockData iblockdata = getHandle().level.getBlockState(blockposition); if (!(iblockdata.getBlock() instanceof BlockBed)) { return false; } - if (getHandle().sleep(blockposition, force).left().isPresent()) { + if (getHandle().startSleepInBed(blockposition, force).left().isPresent()) { return false; } // From BlockBed - iblockdata = (IBlockData) iblockdata.set(BlockBed.OCCUPIED, true); - getHandle().level.setTypeAndData(blockposition, iblockdata, 4); + iblockdata = (IBlockData) iblockdata.setValue(BlockBed.OCCUPIED, true); + getHandle().level.setBlock(blockposition, iblockdata, 4); return true; } @@ -153,20 +153,20 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { public void wakeup(boolean setSpawnLocation) { Preconditions.checkState(isSleeping(), "Cannot wakeup if not sleeping"); - getHandle().wakeup(true, setSpawnLocation); + getHandle().stopSleepInBed(true, setSpawnLocation); } @Override public Location getBedLocation() { Preconditions.checkState(isSleeping(), "Not sleeping"); - BlockPosition bed = getHandle().getBedPosition().get(); + BlockPosition bed = getHandle().getSleepingPos().get(); return new Location(getWorld(), bed.getX(), bed.getY(), bed.getZ()); } @Override public String getName() { - return getHandle().getName(); + return getHandle().getScoreboardName(); } @Override @@ -290,15 +290,15 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { if (iinventory instanceof ITileInventory) { if (iinventory instanceof TileEntity) { TileEntity te = (TileEntity) iinventory; - if (!te.hasWorld()) { - te.setWorld(getHandle().level); + if (!te.hasLevel()) { + te.setLevel(getHandle().level); } } } Containers<?> container = CraftContainer.getNotchInventoryType(inventory); if (iinventory instanceof ITileInventory) { - getHandle().openContainer(iinventory); + getHandle().openMenu(iinventory); } else { openCustomInventory(inventory, player, container); } @@ -320,7 +320,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { String title = container.getBukkitView().getTitle(); - player.connection.sendPacket(new PacketPlayOutOpenWindow(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); + player.connection.send(new PacketPlayOutOpenWindow(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); player.containerMenu = container; player.initMenu(container); } @@ -336,7 +336,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { return null; } } - getHandle().openContainer(((BlockWorkbench) Blocks.CRAFTING_TABLE).getInventory(null, getHandle().level, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()))); + getHandle().openMenu(((BlockWorkbench) Blocks.CRAFTING_TABLE).getMenuProvider(null, getHandle().level, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()))); if (force) { getHandle().containerMenu.checkReachable = false; } @@ -357,7 +357,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { // If there isn't an enchant table we can force create one, won't be very useful though. BlockPosition pos = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - getHandle().openContainer(((BlockEnchantmentTable) Blocks.ENCHANTING_TABLE).getInventory(null, getHandle().level, pos)); + getHandle().openMenu(((BlockEnchantmentTable) Blocks.ENCHANTING_TABLE).getMenuProvider(null, getHandle().level, pos)); if (force) { getHandle().containerMenu.checkReachable = false; @@ -371,7 +371,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { if (((EntityPlayer) getHandle()).connection == null) return; if (getHandle().containerMenu != getHandle().inventoryMenu) { // fire INVENTORY_CLOSE if one already open - ((EntityPlayer) getHandle()).connection.a(new PacketPlayInCloseWindow(getHandle().containerMenu.containerId)); + ((EntityPlayer) getHandle()).connection.handleContainerClose(new PacketPlayInCloseWindow(getHandle().containerMenu.containerId)); } EntityPlayer player = (EntityPlayer) getHandle(); Container container; @@ -390,7 +390,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { // Now open the window Containers<?> windowType = CraftContainer.getNotchInventoryType(inventory.getTopInventory()); String title = inventory.getTitle(); - player.connection.sendPacket(new PacketPlayOutOpenWindow(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); + player.connection.send(new PacketPlayOutOpenWindow(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); player.containerMenu = container; player.initMenu(container); } @@ -418,7 +418,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { int level = 1; // note: using level 0 with active 'is-regular-villager'-flag allows hiding the name suffix if (merchant instanceof CraftAbstractVillager) { mcMerchant = ((CraftAbstractVillager) merchant).getHandle(); - name = ((CraftAbstractVillager) merchant).getHandle().getScoreboardDisplayName(); + name = ((CraftAbstractVillager) merchant).getHandle().getDisplayName(); if (merchant instanceof CraftVillager) { level = ((CraftVillager) merchant).getHandle().getVillagerData().getLevel(); } @@ -430,14 +430,14 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { } mcMerchant.setTradingPlayer(this.getHandle()); - mcMerchant.openTrade(this.getHandle(), name, level); + mcMerchant.openTradingScreen(this.getHandle(), name, level); return this.getHandle().containerMenu.getBukkitView(); } @Override public void closeInventory() { - getHandle().closeInventory(); + getHandle().closeContainer(); } @Override @@ -447,12 +447,12 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @Override public boolean isHandRaised() { - return getHandle().isHandRaised(); + return getHandle().isUsingItem(); } @Override public ItemStack getItemInUse() { - net.minecraft.world.item.ItemStack item = getHandle().getActiveItem(); + net.minecraft.world.item.ItemStack item = getHandle().getUseItem(); return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); } @@ -463,27 +463,27 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @Override public int getExpToLevel() { - return getHandle().getExpToLevel(); + return getHandle().getXpNeededForNextLevel(); } @Override public float getAttackCooldown() { - return getHandle().getAttackCooldown(0.5f); + return getHandle().getAttackStrengthScale(0.5f); } @Override public boolean hasCooldown(Material material) { Preconditions.checkArgument(material != null, "material"); - return getHandle().getCooldownTracker().hasCooldown(CraftMagicNumbers.getItem(material)); + return getHandle().getCooldowns().isOnCooldown(CraftMagicNumbers.getItem(material)); } @Override public int getCooldown(Material material) { Preconditions.checkArgument(material != null, "material"); - ItemCooldown.Info cooldown = getHandle().getCooldownTracker().cooldowns.get(CraftMagicNumbers.getItem(material)); - return (cooldown == null) ? 0 : Math.max(0, cooldown.endTime - getHandle().getCooldownTracker().tickCount); + ItemCooldown.Info cooldown = getHandle().getCooldowns().cooldowns.get(CraftMagicNumbers.getItem(material)); + return (cooldown == null) ? 0 : Math.max(0, cooldown.endTime - getHandle().getCooldowns().tickCount); } @Override @@ -491,7 +491,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { Preconditions.checkArgument(material != null, "material"); Preconditions.checkArgument(ticks >= 0, "Cannot have negative cooldown"); - getHandle().getCooldownTracker().setCooldown(CraftMagicNumbers.getItem(material), ticks); + getHandle().getCooldowns().addCooldown(CraftMagicNumbers.getItem(material), ticks); } @Override @@ -501,7 +501,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @Override public int discoverRecipes(Collection<NamespacedKey> recipes) { - return getHandle().discoverRecipes(bukkitKeysToMinecraftRecipes(recipes)); + return getHandle().awardRecipes(bukkitKeysToMinecraftRecipes(recipes)); } @Override @@ -511,7 +511,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @Override public int undiscoverRecipes(Collection<NamespacedKey> recipes) { - return getHandle().undiscoverRecipes(bukkitKeysToMinecraftRecipes(recipes)); + return getHandle().resetRecipes(bukkitKeysToMinecraftRecipes(recipes)); } @Override @@ -526,10 +526,10 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { private Collection<IRecipe<?>> bukkitKeysToMinecraftRecipes(Collection<NamespacedKey> recipeKeys) { Collection<IRecipe<?>> recipes = new ArrayList<>(); - CraftingManager manager = getHandle().level.getMinecraftServer().getCraftingManager(); + CraftingManager manager = getHandle().level.getServer().getRecipeManager(); for (NamespacedKey recipeKey : recipeKeys) { - Optional<? extends IRecipe<?>> recipe = manager.getRecipe(CraftNamespacedKey.toMinecraft(recipeKey)); + Optional<? extends IRecipe<?>> recipe = manager.byKey(CraftNamespacedKey.toMinecraft(recipeKey)); if (!recipe.isPresent()) { continue; } @@ -543,7 +543,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @Override public org.bukkit.entity.Entity getShoulderEntityLeft() { if (!getHandle().getShoulderEntityLeft().isEmpty()) { - Optional<Entity> shoulder = EntityTypes.a(getHandle().getShoulderEntityLeft(), getHandle().level); + Optional<Entity> shoulder = EntityTypes.create(getHandle().getShoulderEntityLeft(), getHandle().level); return (!shoulder.isPresent()) ? null : shoulder.get().getBukkitEntity(); } @@ -562,7 +562,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @Override public org.bukkit.entity.Entity getShoulderEntityRight() { if (!getHandle().getShoulderEntityRight().isEmpty()) { - Optional<Entity> shoulder = EntityTypes.a(getHandle().getShoulderEntityRight(), getHandle().level); + Optional<Entity> shoulder = EntityTypes.create(getHandle().getShoulderEntityRight(), getHandle().level); return (!shoulder.isPresent()) ? null : shoulder.get().getBukkitEntity(); } @@ -581,7 +581,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @Override public boolean dropItem(boolean dropAll) { if (!(getHandle() instanceof EntityPlayer)) return false; - return ((EntityPlayer) getHandle()).dropItem(dropAll); + return ((EntityPlayer) getHandle()).drop(dropAll); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java index f333dd2726..d973749181 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java @@ -23,12 +23,12 @@ public class CraftItem extends CraftEntity implements Item { @Override public ItemStack getItemStack() { - return CraftItemStack.asCraftMirror(item.getItemStack()); + return CraftItemStack.asCraftMirror(item.getItem()); } @Override public void setItemStack(ItemStack stack) { - item.setItemStack(CraftItemStack.asNMSCopy(stack)); + item.setItem(CraftItemStack.asNMSCopy(stack)); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java index 5ddd594c13..f5f4ce4208 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java @@ -44,13 +44,13 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame { super.update(); // mark dirty, so that the client gets updated with item and rotation - for (DataWatcher.Item<?> dataItem : getHandle().getDataWatcher().getAll()) { - getHandle().getDataWatcher().markDirty(dataItem.a()); + for (DataWatcher.Item<?> dataItem : getHandle().getEntityData().getAll()) { + getHandle().getEntityData().markDirty(dataItem.getAccessor()); } // update redstone if (!getHandle().generation) { - getHandle().getWorld().updateAdjacentComparators(getHandle().pos, Blocks.AIR); + getHandle().getLevel().updateNeighbourForOutputSignal(getHandle().pos, Blocks.AIR); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index fb0b019334..f4b1096bd4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -116,7 +116,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { // during world generation, we don't want to run logic for dropping items and xp if (getHandle().generation && health == 0) { - getHandle().die(); + getHandle().discard(); return; } @@ -129,14 +129,14 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public double getAbsorptionAmount() { - return getHandle().getAbsorptionHearts(); + return getHandle().getAbsorptionAmount(); } @Override public void setAbsorptionAmount(double amount) { Preconditions.checkArgument(amount >= 0 && Double.isFinite(amount), "amount < 0 or non-finite"); - getHandle().setAbsorptionHearts((float) amount); + getHandle().setAbsorptionAmount((float) amount); } @Override @@ -148,7 +148,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public void setMaxHealth(double amount) { Validate.isTrue(amount > 0, "Max health must be greater than 0"); - getHandle().getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(amount); + getHandle().getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(amount); if (getHealth() > amount) { setHealth(amount); @@ -157,12 +157,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public void resetMaxHealth() { - setMaxHealth(getHandle().getAttributeInstance(GenericAttributes.MAX_HEALTH).getAttribute().getDefault()); + setMaxHealth(getHandle().getAttribute(GenericAttributes.MAX_HEALTH).getAttribute().getDefaultValue()); } @Override public double getEyeHeight() { - return getHandle().getHeadHeight(); + return getHandle().getEyeHeight(); } @Override @@ -238,12 +238,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public int getRemainingAir() { - return getHandle().getAirTicks(); + return getHandle().getAirSupply(); } @Override public void setRemainingAir(int ticks) { - getHandle().setAirTicks(ticks); + getHandle().setAirSupply(ticks); } @Override @@ -274,7 +274,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public void setArrowsInBody(int count) { Preconditions.checkArgument(count >= 0, "New arrow amount must be >= 0"); - getHandle().getDataWatcher().set(EntityLiving.DATA_ARROW_COUNT_ID, count); + getHandle().getEntityData().set(EntityLiving.DATA_ARROW_COUNT_ID, count); } @Override @@ -294,7 +294,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle()); } - entity.damageEntity(reason, (float) amount); + entity.hurt(reason, (float) amount); } @Override @@ -360,7 +360,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public boolean addPotionEffect(PotionEffect effect, boolean force) { - getHandle().addEffect(new MobEffect(MobEffectList.fromId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()), EntityPotionEffectEvent.Cause.PLUGIN); + getHandle().addEffect(new MobEffect(MobEffectList.byId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()), EntityPotionEffectEvent.Cause.PLUGIN); return true; } @@ -375,25 +375,25 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public boolean hasPotionEffect(PotionEffectType type) { - return getHandle().hasEffect(MobEffectList.fromId(type.getId())); + return getHandle().hasEffect(MobEffectList.byId(type.getId())); } @Override public PotionEffect getPotionEffect(PotionEffectType type) { - MobEffect handle = getHandle().getEffect(MobEffectList.fromId(type.getId())); - return (handle == null) ? null : new PotionEffect(PotionEffectType.getById(MobEffectList.getId(handle.getMobEffect())), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isShowParticles()); + MobEffect handle = getHandle().getEffect(MobEffectList.byId(type.getId())); + return (handle == null) ? null : new PotionEffect(PotionEffectType.getById(MobEffectList.getId(handle.getEffect())), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isVisible()); } @Override public void removePotionEffect(PotionEffectType type) { - getHandle().removeEffect(MobEffectList.fromId(type.getId()), EntityPotionEffectEvent.Cause.PLUGIN); + getHandle().removeEffect(MobEffectList.byId(type.getId()), EntityPotionEffectEvent.Cause.PLUGIN); } @Override public Collection<PotionEffect> getActivePotionEffects() { List<PotionEffect> effects = new ArrayList<PotionEffect>(); for (MobEffect handle : getHandle().activeEffects.values()) { - effects.add(new PotionEffect(PotionEffectType.getById(MobEffectList.getId(handle.getMobEffect())), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isShowParticles())); + effects.add(new PotionEffect(PotionEffectType.getById(MobEffectList.getId(handle.getEffect())), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isVisible())); } return effects; } @@ -413,17 +413,17 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { if (Snowball.class.isAssignableFrom(projectile)) { launch = new EntitySnowball(world, getHandle()); - ((EntityProjectile) launch).a(getHandle(), getHandle().getXRot(), getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // ItemSnowball + ((EntityProjectile) launch).shootFromRotation(getHandle(), getHandle().getXRot(), getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // ItemSnowball } else if (Egg.class.isAssignableFrom(projectile)) { launch = new EntityEgg(world, getHandle()); - ((EntityProjectile) launch).a(getHandle(), getHandle().getXRot(), getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // ItemEgg + ((EntityProjectile) launch).shootFromRotation(getHandle(), getHandle().getXRot(), getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // ItemEgg } else if (EnderPearl.class.isAssignableFrom(projectile)) { launch = new EntityEnderPearl(world, getHandle()); - ((EntityProjectile) launch).a(getHandle(), getHandle().getXRot(), getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // ItemEnderPearl + ((EntityProjectile) launch).shootFromRotation(getHandle(), getHandle().getXRot(), getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // ItemEnderPearl } else if (AbstractArrow.class.isAssignableFrom(projectile)) { if (TippedArrow.class.isAssignableFrom(projectile)) { launch = new EntityTippedArrow(world, getHandle()); - ((EntityTippedArrow) launch).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false))); + ((EntityTippedArrow) launch).setPotionType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false))); } else if (SpectralArrow.class.isAssignableFrom(projectile)) { launch = new EntitySpectralArrow(world, getHandle()); } else if (Trident.class.isAssignableFrom(projectile)) { @@ -431,7 +431,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } else { launch = new EntityTippedArrow(world, getHandle()); } - ((EntityArrow) launch).a(getHandle(), getHandle().getXRot(), getHandle().getYRot(), 0.0F, 3.0F, 1.0F); // ItemBow + ((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()); @@ -440,10 +440,10 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { launch = new EntityPotion(world, getHandle()); ((EntityPotion) launch).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1))); } - ((EntityProjectile) launch).a(getHandle(), getHandle().getXRot(), getHandle().getYRot(), -20.0F, 0.5F, 1.0F); // ItemSplashPotion + ((EntityProjectile) launch).shootFromRotation(getHandle(), getHandle().getXRot(), getHandle().getYRot(), -20.0F, 0.5F, 1.0F); // ItemSplashPotion } else if (ThrownExpBottle.class.isAssignableFrom(projectile)) { launch = new EntityThrownExpBottle(world, getHandle()); - ((EntityProjectile) launch).a(getHandle(), getHandle().getXRot(), getHandle().getYRot(), -20.0F, 0.7F, 1.0F); // ItemExpBottle + ((EntityProjectile) launch).shootFromRotation(getHandle(), getHandle().getXRot(), getHandle().getYRot(), -20.0F, 0.7F, 1.0F); // ItemExpBottle } else if (FishHook.class.isAssignableFrom(projectile) && getHandle() instanceof EntityHuman) { launch = new EntityFishingHook((EntityHuman) getHandle(), world, 0, 0); } else if (Fireball.class.isAssignableFrom(projectile)) { @@ -461,26 +461,26 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } ((EntityFireball) launch).projectileSource = this; - launch.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + launch.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); } else if (LlamaSpit.class.isAssignableFrom(projectile)) { Location location = getEyeLocation(); Vector direction = location.getDirection(); - launch = EntityTypes.LLAMA_SPIT.a(world); + launch = EntityTypes.LLAMA_SPIT.create(world); - ((EntityLlamaSpit) launch).setShooter(getHandle()); + ((EntityLlamaSpit) launch).setOwner(getHandle()); ((EntityLlamaSpit) launch).shoot(direction.getX(), direction.getY(), direction.getZ(), 1.5F, 10.0F); // EntityLlama - launch.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + launch.moveTo(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.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + launch.moveTo(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.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + launch.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); } Validate.notNull(launch, "Projectile not supported"); @@ -489,7 +489,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { ((T) launch.getBukkitEntity()).setVelocity(velocity); } - world.addEntity(launch); + world.addFreshEntity(launch); return (T) launch.getBukkitEntity(); } @@ -507,7 +507,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public boolean getRemoveWhenFarAway() { - return getHandle() instanceof EntityInsentient && !((EntityInsentient) getHandle()).isPersistent(); + return getHandle() instanceof EntityInsentient && !((EntityInsentient) getHandle()).isPersistenceRequired(); } @Override @@ -525,7 +525,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public void setCanPickupItems(boolean pickup) { if (getHandle() instanceof EntityInsentient) { - ((EntityInsentient) getHandle()).setCanPickupLoot(pickup); + ((EntityInsentient) getHandle()).setCanPickUpLoot(pickup); } else { getHandle().bukkitPickUpLoot = pickup; } @@ -534,7 +534,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public boolean getCanPickupItems() { if (getHandle() instanceof EntityInsentient) { - return ((EntityInsentient) getHandle()).canPickupLoot(); + return ((EntityInsentient) getHandle()).canPickUpLoot(); } else { return getHandle().bukkitPickUpLoot; } @@ -569,7 +569,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { if (!isLeashed()) { return false; } - ((EntityInsentient) getHandle()).unleash(true, false); + ((EntityInsentient) getHandle()).dropLeash(true, false); return true; } @@ -588,18 +588,18 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } unleash(); - ((EntityInsentient) getHandle()).setLeashHolder(((CraftEntity) holder).getHandle(), true); + ((EntityInsentient) getHandle()).setLeashedTo(((CraftEntity) holder).getHandle(), true); return true; } @Override public boolean isGliding() { - return getHandle().getFlag(7); + return getHandle().getSharedFlag(7); } @Override public void setGliding(boolean gliding) { - getHandle().setFlag(7, gliding); + getHandle().setSharedFlag(7, gliding); } @Override @@ -614,7 +614,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public boolean isRiptiding() { - return getHandle().isRiptiding(); + return getHandle().isAutoSpinAttack(); } @Override @@ -626,7 +626,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public boolean isClimbing() { Preconditions.checkState(!getHandle().generation, "Cannot check if climbing during world generation"); - return getHandle().isClimbing(); + return getHandle().onClimbable(); } @Override @@ -637,13 +637,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public void setAI(boolean ai) { if (this.getHandle() instanceof EntityInsentient) { - ((EntityInsentient) this.getHandle()).setNoAI(!ai); + ((EntityInsentient) this.getHandle()).setNoAi(!ai); } } @Override public boolean hasAI() { - return (this.getHandle() instanceof EntityInsentient) ? !((EntityInsentient) this.getHandle()).isNoAI() : false; + return (this.getHandle() instanceof EntityInsentient) ? !((EntityInsentient) this.getHandle()).isNoAi() : false; } @Override @@ -654,7 +654,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { if (getHandle() instanceof EntityHuman) { ((EntityHuman) getHandle()).attack(((CraftEntity) target).getHandle()); } else { - getHandle().attackEntity(((CraftEntity) target).getHandle()); + getHandle().doHurtTarget(((CraftEntity) target).getHandle()); } } @@ -662,14 +662,14 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public void swingMainHand() { Preconditions.checkState(!getHandle().generation, "Cannot swing hand during world generation"); - getHandle().swingHand(EnumHand.MAIN_HAND, true); + getHandle().swing(EnumHand.MAIN_HAND, true); } @Override public void swingOffHand() { Preconditions.checkState(!getHandle().generation, "Cannot swing hand during world generation"); - getHandle().swingHand(EnumHand.OFF_HAND, true); + getHandle().swing(EnumHand.OFF_HAND, true); } @Override @@ -689,17 +689,17 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public <T> T getMemory(MemoryKey<T> memoryKey) { - return (T) getHandle().getBehaviorController().getMemory(CraftMemoryKey.fromMemoryKey(memoryKey)).map(CraftMemoryMapper::fromNms).orElse(null); + return (T) getHandle().getBrain().getMemory(CraftMemoryKey.fromMemoryKey(memoryKey)).map(CraftMemoryMapper::fromNms).orElse(null); } @Override public <T> void setMemory(MemoryKey<T> memoryKey, T t) { - getHandle().getBehaviorController().setMemory(CraftMemoryKey.fromMemoryKey(memoryKey), CraftMemoryMapper.toNms(t)); + getHandle().getBrain().setMemory(CraftMemoryKey.fromMemoryKey(memoryKey), CraftMemoryMapper.toNms(t)); } @Override public EntityCategory getCategory() { - EnumMonsterType type = getHandle().getMonsterType(); // Not actually an enum? + EnumMonsterType type = getHandle().getMobType(); // Not actually an enum? if (type == EnumMonsterType.UNDEFINED) { return EntityCategory.NONE; @@ -724,6 +724,6 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public void setInvisible(boolean invisible) { getHandle().persistentInvisibility = invisible; - getHandle().setFlag(5, invisible); + getHandle().setSharedFlag(5, invisible); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java index 59fddf2181..190ae459b2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java @@ -48,7 +48,7 @@ public class CraftLlama extends CraftChestedHorse implements Llama { Preconditions.checkArgument(1 <= strength && strength <= 5, "strength must be [1,5]"); if (strength == getStrength()) return; getHandle().setStrength(strength); - getHandle().loadChest(); + getHandle().createInventory(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java index 59b65c4ad9..70071d9907 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java @@ -29,11 +29,11 @@ public class CraftLlamaSpit extends AbstractProjectile implements LlamaSpit { @Override public ProjectileSource getShooter() { - return (getHandle().getShooter() != null) ? (ProjectileSource) getHandle().getShooter().getBukkitEntity() : null; + return (getHandle().getOwner() != null) ? (ProjectileSource) getHandle().getOwner().getBukkitEntity() : null; } @Override public void setShooter(ProjectileSource source) { - getHandle().setShooter((source != null) ? ((CraftLivingEntity) source).getHandle() : null); + getHandle().setOwner((source != null) ? ((CraftLivingEntity) source).getHandle() : null); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java index 69415f5a83..4755140e1f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java @@ -77,11 +77,11 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart { public void setDisplayBlock(MaterialData material) { if (material != null) { IBlockData block = CraftMagicNumbers.getBlock(material); - this.getHandle().setDisplayBlock(block); + this.getHandle().setDisplayBlockState(block); } else { // Set block to air (default) and set the flag to not have a display block. - this.getHandle().setDisplayBlock(Blocks.AIR.getBlockData()); - this.getHandle().a(false); + this.getHandle().setDisplayBlockState(Blocks.AIR.defaultBlockState()); + this.getHandle().setCustomDisplay(false); } } @@ -89,33 +89,33 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart { public void setDisplayBlockData(BlockData blockData) { if (blockData != null) { IBlockData block = ((CraftBlockData) blockData).getState(); - this.getHandle().setDisplayBlock(block); + this.getHandle().setDisplayBlockState(block); } else { // Set block to air (default) and set the flag to not have a display block. - this.getHandle().setDisplayBlock(Blocks.AIR.getBlockData()); - this.getHandle().a(false); + this.getHandle().setDisplayBlockState(Blocks.AIR.defaultBlockState()); + this.getHandle().setCustomDisplay(false); } } @Override public MaterialData getDisplayBlock() { - IBlockData blockData = getHandle().getDisplayBlock(); + IBlockData blockData = getHandle().getDisplayBlockState(); return CraftMagicNumbers.getMaterial(blockData); } @Override public BlockData getDisplayBlockData() { - IBlockData blockData = getHandle().getDisplayBlock(); + IBlockData blockData = getHandle().getDisplayBlockState(); return CraftBlockData.fromData(blockData); } @Override public void setDisplayBlockOffset(int offset) { - getHandle().setDisplayBlockOffset(offset); + getHandle().setDisplayOffset(offset); } @Override public int getDisplayBlockOffset() { - return getHandle().getDisplayBlockOffset(); + return getHandle().getDisplayOffset(); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java index b3a5bf9bc7..32d1768d06 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java @@ -34,7 +34,7 @@ public class CraftMinecartCommand extends CraftMinecart implements CommandMineca @Override public void setCommand(String command) { getHandle().getCommandBlock().setCommand(command != null ? command : ""); - getHandle().getDataWatcher().set(EntityMinecartCommandBlock.DATA_ID_COMMAND_NAME, getHandle().getCommandBlock().getCommand()); + getHandle().getEntityData().set(EntityMinecartCommandBlock.DATA_ID_COMMAND_NAME, getHandle().getCommandBlock().getCommand()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java index f7ebca6aed..dadc75bb33 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java @@ -21,17 +21,17 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { EntityInsentient entity = getHandle(); if (target == null) { - entity.setGoalTarget(null, null, false); + entity.setTarget(null, null, false); } else if (target instanceof CraftLivingEntity) { - entity.setGoalTarget(((CraftLivingEntity) target).getHandle(), null, false); + entity.setTarget(((CraftLivingEntity) target).getHandle(), null, false); } } @Override public CraftLivingEntity getTarget() { - if (getHandle().getGoalTarget() == null) return null; + if (getHandle().getTarget() == null) return null; - return (CraftLivingEntity) getHandle().getGoalTarget().getBukkitEntity(); + return (CraftLivingEntity) getHandle().getTarget().getBukkitEntity(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java index 24e2197ac6..a44f815fa2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java @@ -19,14 +19,14 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow { @Override public Variant getVariant() { - return Variant.values()[getHandle().getVariant().ordinal()]; + return Variant.values()[getHandle().getMushroomType().ordinal()]; } @Override public void setVariant(Variant variant) { Preconditions.checkArgument(variant != null, "variant"); - getHandle().setVariant(EntityMushroomCow.Type.values()[variant.ordinal()]); + getHandle().setMushroomType(EntityMushroomCow.Type.values()[variant.ordinal()]); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java index 6ec7cf434b..25e52ae24c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java @@ -18,12 +18,12 @@ public class CraftPhantom extends CraftFlying implements Phantom { @Override public int getSize() { - return getHandle().getSize(); + return getHandle().getPhantomSize(); } @Override public void setSize(int sz) { - getHandle().setSize(sz); + getHandle().setPhantomSize(sz); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java index 363a2a4db5..13592783ad 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java @@ -15,7 +15,7 @@ public class CraftPig extends CraftAnimals implements Pig { @Override public boolean hasSaddle() { - return getHandle().hasSaddle(); + return getHandle().isSaddled(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java index 0b5c4218ac..96ae60834d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java @@ -13,12 +13,12 @@ public class CraftPigZombie extends CraftZombie implements PigZombie { @Override public int getAnger() { - return getHandle().getAnger(); + return getHandle().getRemainingPersistentAngerTime(); } @Override public void setAnger(int level) { - getHandle().setAnger(level); + getHandle().setRemainingPersistentAngerTime(level); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index f7a213551e..21982e5eec 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -149,7 +149,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } public GameProfile getProfile() { - return getHandle().getProfile(); + return getHandle().getGameProfile(); } @Override @@ -162,9 +162,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (value == isOp()) return; if (value) { - server.getHandle().addOp(getProfile()); + server.getHandle().op(getProfile()); } else { - server.getHandle().removeOp(getProfile()); + server.getHandle().deop(getProfile()); } perm.recalculatePermissions(); @@ -179,7 +179,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public InetSocketAddress getAddress() { if (getHandle().connection == null) return null; - SocketAddress addr = getHandle().connection.connection.getSocketAddress(); + SocketAddress addr = getHandle().connection.connection.getRemoteAddress(); if (addr instanceof InetSocketAddress) { return (InetSocketAddress) addr; } else { @@ -201,7 +201,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (getHandle().connection == null) return; for (IChatBaseComponent component : CraftChatMessage.fromString(message)) { - getHandle().connection.sendPacket(new PacketPlayOutChat(component, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID)); + getHandle().connection.send(new PacketPlayOutChat(component, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID)); } } @@ -210,7 +210,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (getHandle().connection == null) return; for (IChatBaseComponent component : CraftChatMessage.fromString(message)) { - getHandle().connection.sendPacket(new PacketPlayOutChat(component, ChatMessageType.CHAT, (sender == null) ? SystemUtils.NIL_UUID : sender)); + getHandle().connection.send(new PacketPlayOutChat(component, ChatMessageType.CHAT, (sender == null) ? SystemUtils.NIL_UUID : sender)); } } @@ -265,7 +265,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { getHandle().listName = name.equals(getName()) ? null : CraftChatMessage.fromStringOrNull(name); for (EntityPlayer player : (List<EntityPlayer>) server.getHandle().players) { if (player.getBukkitEntity().canSee(this)) { - player.connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, getHandle())); + player.connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, getHandle())); } } } @@ -306,7 +306,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (getHandle().connection == null) return; PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter((this.playerListHeader == null) ? new ChatComponentText("") : this.playerListHeader, (this.playerListFooter == null) ? new ChatComponentText("") : this.playerListFooter); - getHandle().connection.sendPacket(packet); + getHandle().connection.send(packet); } @Override @@ -341,7 +341,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (getHandle().connection == null) return; // Do not directly assign here, from the packethandler we'll assign it. - getHandle().connection.sendPacket(new PacketPlayOutSpawnPosition(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), loc.getYaw())); + getHandle().connection.send(new PacketPlayOutSpawnPosition(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), loc.getYaw())); } @Override @@ -400,7 +400,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } float f = (float) Math.pow(2.0D, (note - 12.0D) / 12.0D); - getHandle().connection.sendPacket(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f)); + getHandle().connection.send(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f)); } @Override @@ -462,7 +462,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { break; } float f = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D); - getHandle().connection.sendPacket(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f)); + getHandle().connection.send(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f)); } @Override @@ -480,7 +480,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (loc == null || sound == null || category == null || getHandle().connection == null) return; PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), loc.getX(), loc.getY(), loc.getZ(), volume, pitch); - getHandle().connection.sendPacket(packet); + getHandle().connection.send(packet); } @Override @@ -488,7 +488,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (loc == null || sound == null || category == null || getHandle().connection == null) return; PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), new Vec3D(loc.getX(), loc.getY(), loc.getZ()), volume, pitch); - getHandle().connection.sendPacket(packet); + getHandle().connection.send(packet); } @Override @@ -510,14 +510,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void stopSound(String sound, org.bukkit.SoundCategory category) { if (getHandle().connection == null) return; - getHandle().connection.sendPacket(new PacketPlayOutStopSound(new MinecraftKey(sound), category == null ? net.minecraft.sounds.SoundCategory.MASTER : net.minecraft.sounds.SoundCategory.valueOf(category.name()))); + getHandle().connection.send(new PacketPlayOutStopSound(new MinecraftKey(sound), category == null ? net.minecraft.sounds.SoundCategory.MASTER : net.minecraft.sounds.SoundCategory.valueOf(category.name()))); } @Override public void stopAllSounds() { if (getHandle().connection == null) return; - getHandle().connection.sendPacket(new PacketPlayOutStopSound(null, null)); + getHandle().connection.send(new PacketPlayOutStopSound(null, null)); } @Override @@ -526,7 +526,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { int packetData = effect.getId(); PacketPlayOutWorldEvent packet = new PacketPlayOutWorldEvent(packetData, new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), data, false); - getHandle().connection.sendPacket(packet); + getHandle().connection.send(packet); } @Override @@ -547,7 +547,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { Preconditions.checkArgument(block != null, "Block cannot be null"); Preconditions.checkArgument(block.getWorld().equals(getWorld()), "Cannot break blocks across worlds"); - return getHandle().gameMode.breakBlock(new BlockPosition(block.getX(), block.getY(), block.getZ())); + return getHandle().gameMode.destroyBlock(new BlockPosition(block.getX(), block.getY(), block.getZ())); } @Override @@ -555,7 +555,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (getHandle().connection == null) return; PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), CraftMagicNumbers.getBlock(material, data)); - getHandle().connection.sendPacket(packet); + getHandle().connection.send(packet); } @Override @@ -563,7 +563,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (getHandle().connection == null) return; PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), ((CraftBlockData) block).getState()); - getHandle().connection.sendPacket(packet); + getHandle().connection.send(packet); } @Override @@ -575,7 +575,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { int stage = (int) (9 * progress); // There are 0 - 9 damage states PacketPlayOutBlockBreakAnimation packet = new PacketPlayOutBlockBreakAnimation(getHandle().getId(), new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), stage); - getHandle().connection.sendPacket(packet); + getHandle().connection.send(packet); } @Override @@ -605,14 +605,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } IChatBaseComponent[] components = CraftSign.sanitizeLines(lines); - TileEntitySign sign = new TileEntitySign(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), Blocks.OAK_SIGN.getBlockData()); - sign.setColor(EnumColor.fromColorIndex(dyeColor.getWoolData())); + TileEntitySign sign = new TileEntitySign(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), Blocks.OAK_SIGN.defaultBlockState()); + sign.setColor(EnumColor.byId(dyeColor.getWoolData())); sign.setHasGlowingText(hasGlowingText); for (int i = 0; i < components.length; i++) { - sign.a(i, components[i]); + sign.setMessage(i, components[i]); } - getHandle().connection.sendPacket(sign.getUpdatePacket()); + getHandle().connection.send(sign.getUpdatePacket()); } @Override @@ -657,12 +657,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { Collection<MapIcon> icons = new ArrayList<MapIcon>(); for (MapCursor cursor : data.cursors) { if (cursor.isVisible()) { - icons.add(new MapIcon(MapIcon.Type.a(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), CraftChatMessage.fromStringOrNull(cursor.getCaption()))); + icons.add(new MapIcon(MapIcon.Type.byIcon(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), CraftChatMessage.fromStringOrNull(cursor.getCaption()))); } } PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), map.getScale().getValue(), map.isLocked(), icons, new WorldMap.b(0, 0, 128, 128, data.buffer)); - getHandle().connection.sendPacket(packet); + getHandle().connection.send(packet); } @Override @@ -721,26 +721,26 @@ public class CraftPlayer extends CraftHumanEntity implements Player { // Close any foreign inventory if (getHandle().containerMenu != getHandle().inventoryMenu) { - getHandle().closeInventory(); + getHandle().closeContainer(); } // Check if the fromWorld and toWorld are the same. if (fromWorld == toWorld) { entity.connection.teleport(to); } else { - server.getHandle().moveToWorld(entity, toWorld, true, to, true); + server.getHandle().respawn(entity, toWorld, true, to, true); } return true; } @Override public void setSneaking(boolean sneak) { - getHandle().setSneaking(sneak); + getHandle().setShiftKeyDown(sneak); } @Override public boolean isSneaking() { - return getHandle().isSneaking(); + return getHandle().isShiftKeyDown(); } @Override @@ -766,13 +766,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Deprecated @Override public void updateInventory() { - getHandle().containerMenu.updateInventory(); + getHandle().containerMenu.sendAllDataToRemote(); } @Override public void setSleepingIgnored(boolean isSleeping) { getHandle().fauxSleeping = isSleeping; - ((CraftWorld) getWorld()).getHandle().everyoneSleeping(); + ((CraftWorld) getWorld()).getHandle().updateSleepingPlayerList(); } @Override @@ -782,14 +782,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public Location getBedSpawnLocation() { - WorldServer world = getHandle().server.getWorldServer(getHandle().getSpawnDimension()); - BlockPosition bed = getHandle().getSpawn(); + WorldServer world = getHandle().server.getLevel(getHandle().getRespawnDimension()); + BlockPosition bed = getHandle().getRespawnPosition(); if (world != null && bed != null) { - Optional<Vec3D> spawnLoc = EntityHuman.getBed(world, bed, getHandle().getSpawnAngle(), getHandle().isSpawnForced(), true); + Optional<Vec3D> spawnLoc = EntityHuman.findRespawnPositionAndUseSpawnBlock(world, bed, getHandle().getRespawnAngle(), getHandle().isRespawnForced(), true); if (spawnLoc.isPresent()) { Vec3D vec = spawnLoc.get(); - return new Location(world.getWorld(), vec.x, vec.y, vec.z, getHandle().getSpawnAngle(), 0); + return new Location(world.getWorld(), vec.x, vec.y, vec.z, getHandle().getRespawnAngle(), 0); } } return null; @@ -805,7 +805,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (location == null) { getHandle().setRespawnPosition(null, null, 0.0F, override, false); } else { - getHandle().setRespawnPosition(((CraftWorld) location.getWorld()).getHandle().getDimensionKey(), new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), location.getYaw(), override, false); + getHandle().setRespawnPosition(((CraftWorld) location.getWorld()).getHandle().dimension(), new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), location.getYaw(), override, false); } } @@ -813,14 +813,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public Location getBedLocation() { Preconditions.checkState(isSleeping(), "Not sleeping"); - BlockPosition bed = getHandle().getSpawn(); + BlockPosition bed = getHandle().getRespawnPosition(); return new Location(getWorld(), bed.getX(), bed.getY(), bed.getZ()); } @Override public boolean hasDiscoveredRecipe(NamespacedKey recipe) { Preconditions.checkArgument(recipe != null, "recipe cannot be null"); - return getHandle().getRecipeBook().hasDiscoveredRecipe(CraftNamespacedKey.toMinecraft(recipe)); + return getHandle().getRecipeBook().contains(CraftNamespacedKey.toMinecraft(recipe)); } @Override @@ -832,92 +832,92 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void incrementStatistic(Statistic statistic) { - CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic); + CraftStatistic.incrementStatistic(getHandle().getStats(), statistic); } @Override public void decrementStatistic(Statistic statistic) { - CraftStatistic.decrementStatistic(getHandle().getStatisticManager(), statistic); + CraftStatistic.decrementStatistic(getHandle().getStats(), statistic); } @Override public int getStatistic(Statistic statistic) { - return CraftStatistic.getStatistic(getHandle().getStatisticManager(), statistic); + return CraftStatistic.getStatistic(getHandle().getStats(), statistic); } @Override public void incrementStatistic(Statistic statistic, int amount) { - CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic, amount); + CraftStatistic.incrementStatistic(getHandle().getStats(), statistic, amount); } @Override public void decrementStatistic(Statistic statistic, int amount) { - CraftStatistic.decrementStatistic(getHandle().getStatisticManager(), statistic, amount); + CraftStatistic.decrementStatistic(getHandle().getStats(), statistic, amount); } @Override public void setStatistic(Statistic statistic, int newValue) { - CraftStatistic.setStatistic(getHandle().getStatisticManager(), statistic, newValue); + CraftStatistic.setStatistic(getHandle().getStats(), statistic, newValue); } @Override public void incrementStatistic(Statistic statistic, Material material) { - CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic, material); + CraftStatistic.incrementStatistic(getHandle().getStats(), statistic, material); } @Override public void decrementStatistic(Statistic statistic, Material material) { - CraftStatistic.decrementStatistic(getHandle().getStatisticManager(), statistic, material); + CraftStatistic.decrementStatistic(getHandle().getStats(), statistic, material); } @Override public int getStatistic(Statistic statistic, Material material) { - return CraftStatistic.getStatistic(getHandle().getStatisticManager(), statistic, material); + return CraftStatistic.getStatistic(getHandle().getStats(), statistic, material); } @Override public void incrementStatistic(Statistic statistic, Material material, int amount) { - CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic, material, amount); + CraftStatistic.incrementStatistic(getHandle().getStats(), statistic, material, amount); } @Override public void decrementStatistic(Statistic statistic, Material material, int amount) { - CraftStatistic.decrementStatistic(getHandle().getStatisticManager(), statistic, material, amount); + CraftStatistic.decrementStatistic(getHandle().getStats(), statistic, material, amount); } @Override public void setStatistic(Statistic statistic, Material material, int newValue) { - CraftStatistic.setStatistic(getHandle().getStatisticManager(), statistic, material, newValue); + CraftStatistic.setStatistic(getHandle().getStats(), statistic, material, newValue); } @Override public void incrementStatistic(Statistic statistic, EntityType entityType) { - CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic, entityType); + CraftStatistic.incrementStatistic(getHandle().getStats(), statistic, entityType); } @Override public void decrementStatistic(Statistic statistic, EntityType entityType) { - CraftStatistic.decrementStatistic(getHandle().getStatisticManager(), statistic, entityType); + CraftStatistic.decrementStatistic(getHandle().getStats(), statistic, entityType); } @Override public int getStatistic(Statistic statistic, EntityType entityType) { - return CraftStatistic.getStatistic(getHandle().getStatisticManager(), statistic, entityType); + return CraftStatistic.getStatistic(getHandle().getStats(), statistic, entityType); } @Override public void incrementStatistic(Statistic statistic, EntityType entityType, int amount) { - CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic, entityType, amount); + CraftStatistic.incrementStatistic(getHandle().getStats(), statistic, entityType, amount); } @Override public void decrementStatistic(Statistic statistic, EntityType entityType, int amount) { - CraftStatistic.decrementStatistic(getHandle().getStatisticManager(), statistic, entityType, amount); + CraftStatistic.decrementStatistic(getHandle().getStats(), statistic, entityType, amount); } @Override public void setStatistic(Statistic statistic, EntityType entityType, int newValue) { - CraftStatistic.setStatistic(getHandle().getStatisticManager(), statistic, entityType, newValue); + CraftStatistic.setStatistic(getHandle().getStats(), statistic, entityType, newValue); } @Override @@ -968,15 +968,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public boolean isWhitelisted() { - return server.getHandle().getWhitelist().isWhitelisted(getProfile()); + return server.getHandle().getWhiteList().isWhiteListed(getProfile()); } @Override public void setWhitelisted(boolean value) { if (value) { - server.getHandle().getWhitelist().add(new WhiteListEntry(getProfile())); + server.getHandle().getWhiteList().add(new WhiteListEntry(getProfile())); } else { - server.getHandle().getWhitelist().remove(getProfile()); + server.getHandle().getWhiteList().remove(getProfile()); } } @@ -988,22 +988,22 @@ public class CraftPlayer extends CraftHumanEntity implements Player { throw new IllegalArgumentException("Mode cannot be null"); } - getHandle().a(EnumGamemode.getById(mode.getValue())); + getHandle().setGameMode(EnumGamemode.byId(mode.getValue())); } @Override public GameMode getGameMode() { - return GameMode.getByValue(getHandle().gameMode.getGameMode().getId()); + return GameMode.getByValue(getHandle().gameMode.getGameModeForPlayer().getId()); } @Override public void giveExp(int exp) { - getHandle().giveExp(exp); + getHandle().giveExperiencePoints(exp); } @Override public void giveExpLevels(int levels) { - getHandle().levelDown(levels); + getHandle().giveExperienceLevels(levels); } @Override @@ -1056,7 +1056,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } PacketPlayOutExperience packet = new PacketPlayOutExperience(progress, getTotalExperience(), level); - getHandle().connection.sendPacket(packet); + getHandle().connection.send(packet); } @Nullable @@ -1095,16 +1095,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { hiddenPlayers.put(player.getUniqueId(), hidingPlugins); // Remove this player from the hidden player's EntityTrackerEntry - PlayerChunkMap tracker = ((WorldServer) entity.level).getChunkProvider().chunkMap; + PlayerChunkMap tracker = ((WorldServer) entity.level).getChunkSource().chunkMap; EntityPlayer other = ((CraftPlayer) player).getHandle(); PlayerChunkMap.EntityTracker entry = tracker.entityMap.get(other.getId()); if (entry != null) { - entry.clear(getHandle()); + entry.removePlayer(getHandle()); } // Remove the hidden player from this player user list, if they're on it if (other.sentListPacket) { - getHandle().connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, other)); + getHandle().connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, other)); } } @@ -1137,10 +1137,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } hiddenPlayers.remove(player.getUniqueId()); - PlayerChunkMap tracker = ((WorldServer) entity.level).getChunkProvider().chunkMap; + PlayerChunkMap tracker = ((WorldServer) entity.level).getChunkSource().chunkMap; EntityPlayer other = ((CraftPlayer) player).getHandle(); - getHandle().connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, other)); + getHandle().connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, other)); PlayerChunkMap.EntityTracker entry = tracker.entityMap.get(other.getId()); if (entry != null && !entry.seenBy.contains(getHandle())) { @@ -1214,15 +1214,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void readExtraData(NBTTagCompound nbttagcompound) { hasPlayedBefore = true; - if (nbttagcompound.hasKey("bukkit")) { + if (nbttagcompound.contains("bukkit")) { NBTTagCompound data = nbttagcompound.getCompound("bukkit"); - if (data.hasKey("firstPlayed")) { + if (data.contains("firstPlayed")) { firstPlayed = data.getLong("firstPlayed"); lastPlayed = data.getLong("lastPlayed"); } - if (data.hasKey("newExp")) { + if (data.contains("newExp")) { EntityPlayer handle = getHandle(); handle.newExp = data.getInt("newExp"); handle.newTotalExp = data.getInt("newTotalExp"); @@ -1234,20 +1234,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } public void setExtraData(NBTTagCompound nbttagcompound) { - if (!nbttagcompound.hasKey("bukkit")) { - nbttagcompound.set("bukkit", new NBTTagCompound()); + if (!nbttagcompound.contains("bukkit")) { + nbttagcompound.put("bukkit", new NBTTagCompound()); } NBTTagCompound data = nbttagcompound.getCompound("bukkit"); EntityPlayer handle = getHandle(); - data.setInt("newExp", handle.newExp); - data.setInt("newTotalExp", handle.newTotalExp); - data.setInt("newLevel", handle.newLevel); - data.setInt("expToDrop", handle.expToDrop); - data.setBoolean("keepLevel", handle.keepLevel); - data.setLong("firstPlayed", getFirstPlayed()); - data.setLong("lastPlayed", System.currentTimeMillis()); - data.setString("lastKnownName", handle.getName()); + data.putInt("newExp", handle.newExp); + data.putInt("newTotalExp", handle.newTotalExp); + data.putInt("newLevel", handle.newLevel); + data.putInt("expToDrop", handle.expToDrop); + data.putBoolean("keepLevel", handle.keepLevel); + data.putLong("firstPlayed", getFirstPlayed()); + data.putLong("lastPlayed", System.currentTimeMillis()); + data.putString("lastKnownName", handle.getScoreboardName()); } @Override @@ -1283,7 +1283,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (channels.contains(channel)) { channel = StandardMessenger.validateAndCorrectChannel(channel); PacketPlayOutCustomPayload packet = new PacketPlayOutCustomPayload(new MinecraftKey(channel), new PacketDataSerializer(Unpooled.wrappedBuffer(message))); - getHandle().connection.sendPacket(packet); + getHandle().connection.send(packet); } } @@ -1296,7 +1296,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void setResourcePack(String url) { Validate.notNull(url, "Resource pack URL cannot be null"); - getHandle().setResourcePack(url, "null", false, null); + getHandle().sendTexturePack(url, "null", false, null); } @Override @@ -1305,7 +1305,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { Validate.notNull(hash, "Resource pack hash cannot be null"); Validate.isTrue(hash.length == 20, "Resource pack hash should be 20 bytes long but was " + hash.length); - getHandle().setResourcePack(url, BaseEncoding.base16().lowerCase().encode(hash), false, null); + getHandle().sendTexturePack(url, BaseEncoding.base16().lowerCase().encode(hash), false, null); } public void addChannel(String channel) { @@ -1344,7 +1344,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } } - getHandle().connection.sendPacket(new PacketPlayOutCustomPayload(new MinecraftKey("register"), new PacketDataSerializer(Unpooled.wrappedBuffer(stream.toByteArray())))); + getHandle().connection.send(new PacketPlayOutCustomPayload(new MinecraftKey("register"), new PacketDataSerializer(Unpooled.wrappedBuffer(stream.toByteArray())))); } } @@ -1379,7 +1379,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (container.getBukkitView().getType() != prop.getType()) { return false; } - container.setContainerData(prop.getId(), value); + container.setData(prop.getId(), value); return true; } @@ -1400,7 +1400,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } getHandle().getAbilities().flying = value; - getHandle().updateAbilities(); + getHandle().onUpdateAbilities(); } @Override @@ -1415,7 +1415,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } getHandle().getAbilities().mayfly = value; - getHandle().updateAbilities(); + getHandle().onUpdateAbilities(); } @Override @@ -1438,7 +1438,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { validateSpeed(value); EntityPlayer player = getHandle(); player.getAbilities().flyingSpeed = value / 2f; - player.updateAbilities(); + player.onUpdateAbilities(); } @@ -1447,8 +1447,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player { validateSpeed(value); EntityPlayer player = getHandle(); player.getAbilities().walkingSpeed = value / 2f; - player.updateAbilities(); - getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(player.getAbilities().walkingSpeed); // SPIGOT-5833: combination of the two in 1.16+ + player.onUpdateAbilities(); + getHandle().getAttribute(GenericAttributes.MOVEMENT_SPEED).setBaseValue(player.getAbilities().walkingSpeed); // SPIGOT-5833: combination of the two in 1.16+ } @Override @@ -1477,13 +1477,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void setMaxHealth(double amount) { super.setMaxHealth(amount); this.health = Math.min(this.health, health); - getHandle().triggerHealthUpdate(); + getHandle().resetSentInfo(); } @Override public void resetMaxHealth() { super.resetMaxHealth(); - getHandle().triggerHealthUpdate(); + getHandle().resetSentInfo(); } @Override @@ -1548,25 +1548,25 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } public void updateScaledHealth(boolean sendHealth) { - AttributeMapBase attributemapserver = getHandle().getAttributeMap(); - Collection<AttributeModifiable> set = attributemapserver.b(); // PAIL: Rename + AttributeMapBase attributemapserver = getHandle().getAttributes(); + Collection<AttributeModifiable> set = attributemapserver.getSyncableAttributes(); injectScaledMaxHealth(set, true); // SPIGOT-3813: Attributes before health if (getHandle().connection != null) { - getHandle().connection.sendPacket(new PacketPlayOutUpdateAttributes(getHandle().getId(), set)); + getHandle().connection.send(new PacketPlayOutUpdateAttributes(getHandle().getId(), set)); if (sendHealth) { sendHealthUpdate(); } } - getHandle().getDataWatcher().set(EntityLiving.DATA_HEALTH_ID, (float) getScaledHealth()); + getHandle().getEntityData().set(EntityLiving.DATA_HEALTH_ID, (float) getScaledHealth()); getHandle().maxHealthCache = getMaxHealth(); } public void sendHealthUpdate() { - getHandle().connection.sendPacket(new PacketPlayOutUpdateHealth(getScaledHealth(), getHandle().getFoodData().getFoodLevel(), getHandle().getFoodData().getSaturationLevel())); + getHandle().connection.send(new PacketPlayOutUpdateHealth(getScaledHealth(), getHandle().getFoodData().getFoodLevel(), getHandle().getFoodData().getSaturationLevel())); } public void injectScaledMaxHealth(Collection<AttributeModifiable> collection, boolean force) { @@ -1580,20 +1580,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } } AttributeModifiable dummy = new AttributeModifiable(GenericAttributes.MAX_HEALTH, (attribute) -> { }); - dummy.setValue(scaledHealth ? healthScale : getMaxHealth()); + dummy.setBaseValue(scaledHealth ? healthScale : getMaxHealth()); collection.add(dummy); } @Override public org.bukkit.entity.Entity getSpectatorTarget() { - Entity followed = getHandle().getSpecatorTarget(); + Entity followed = getHandle().getCamera(); return followed == getHandle() ? null : followed.getBukkitEntity(); } @Override public void setSpectatorTarget(org.bukkit.entity.Entity entity) { Preconditions.checkArgument(getGameMode() == GameMode.SPECTATOR, "Player must be in spectator mode"); - getHandle().setSpectatorTarget((entity == null) ? null : ((CraftEntity) entity).getHandle()); + getHandle().setCamera((entity == null) ? null : ((CraftEntity) entity).getHandle()); } @Override @@ -1604,23 +1604,23 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut) { ClientboundSetTitlesAnimationPacket times = new ClientboundSetTitlesAnimationPacket(fadeIn, stay, fadeOut); - getHandle().connection.sendPacket(times); + getHandle().connection.send(times); if (title != null) { ClientboundSetTitleTextPacket packetTitle = new ClientboundSetTitleTextPacket(CraftChatMessage.fromStringOrNull(title)); - getHandle().connection.sendPacket(packetTitle); + getHandle().connection.send(packetTitle); } if (subtitle != null) { ClientboundSetSubtitleTextPacket packetSubtitle = new ClientboundSetSubtitleTextPacket(CraftChatMessage.fromStringOrNull(subtitle)); - getHandle().connection.sendPacket(packetSubtitle); + getHandle().connection.send(packetSubtitle); } } @Override public void resetTitle() { ClientboundClearTitlesPacket packetReset = new ClientboundClearTitlesPacket(true); - getHandle().connection.sendPacket(packetReset); + getHandle().connection.send(packetReset); } @Override @@ -1684,7 +1684,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { throw new IllegalArgumentException("data should be " + particle.getDataType() + " got " + data.getClass()); } PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(CraftParticle.toNMS(particle, data), true, (float) x, (float) y, (float) z, (float) offsetX, (float) offsetY, (float) offsetZ, (float) extra, count); - getHandle().connection.sendPacket(packetplayoutworldparticles); + getHandle().connection.send(packetplayoutworldparticles); } @@ -1693,8 +1693,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player { Preconditions.checkArgument(advancement != null, "advancement"); CraftAdvancement craft = (CraftAdvancement) advancement; - AdvancementDataPlayer data = getHandle().getAdvancementData(); - AdvancementProgress progress = data.getProgress(craft.getHandle()); + AdvancementDataPlayer data = getHandle().getAdvancements(); + AdvancementProgress progress = data.getOrStartProgress(craft.getHandle()); return new CraftAdvancementProgress(craft, data, progress); } @@ -1718,7 +1718,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void updateCommands() { if (getHandle().connection == null) return; - getHandle().server.getCommandDispatcher().a(getHandle()); + getHandle().server.getCommands().sendCommands(getHandle()); } @Override @@ -1728,7 +1728,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { ItemStack hand = getInventory().getItemInMainHand(); getInventory().setItemInMainHand(book); - getHandle().openBook(org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(book), net.minecraft.world.EnumHand.MAIN_HAND); + getHandle().openItemGui(org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(book), net.minecraft.world.EnumHand.MAIN_HAND); getInventory().setItemInMainHand(hand); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java index 76d726c982..339fcfe7d1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java @@ -19,9 +19,9 @@ public abstract class CraftProjectile extends AbstractProjectile implements Proj @Override public void setShooter(ProjectileSource shooter) { if (shooter instanceof CraftLivingEntity) { - getHandle().setShooter((EntityLiving) ((CraftLivingEntity) shooter).entity); + getHandle().setOwner((EntityLiving) ((CraftLivingEntity) shooter).entity); } else { - getHandle().setShooter(null); + getHandle().setOwner(null); } getHandle().projectileSource = shooter; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java index f5e98f1845..959cc28b0f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java @@ -42,9 +42,9 @@ public class CraftRabbit extends CraftAnimals implements Rabbit { if (getRabbitType() == Type.THE_KILLER_BUNNY) { // Reset goals and target finders. World world = ((CraftWorld) this.getWorld()).getHandle(); - entity.goalSelector = new PathfinderGoalSelector(world.getMethodProfilerSupplier()); - entity.targetSelector = new PathfinderGoalSelector(world.getMethodProfilerSupplier()); - entity.initPathfinder(); + entity.goalSelector = new PathfinderGoalSelector(world.getProfilerSupplier()); + entity.targetSelector = new PathfinderGoalSelector(world.getProfilerSupplier()); + entity.registerGoals(); entity.initializePathFinderGoals(); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java index fe220c0d87..8132e8c396 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java @@ -52,7 +52,7 @@ public abstract class CraftRaider extends CraftMonster implements Raider { @Override public boolean isCanJoinRaid() { - return getHandle().isCanJoinRaid(); + return getHandle().canJoinRaid(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java index 1d84ad8df6..886f57fe55 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java @@ -14,12 +14,12 @@ public class CraftSheep extends CraftAnimals implements Sheep { @Override public DyeColor getColor() { - return DyeColor.getByWoolData((byte) getHandle().getColor().getColorIndex()); + return DyeColor.getByWoolData((byte) getHandle().getColor().getId()); } @Override public void setColor(DyeColor color) { - getHandle().setColor(EnumColor.fromColorIndex(color.getWoolData())); + getHandle().setColor(EnumColor.byId(color.getWoolData())); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java index 7bed85e1ef..65ff12b412 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java @@ -32,23 +32,23 @@ public class CraftShulker extends CraftGolem implements Shulker { @Override public DyeColor getColor() { - return DyeColor.getByWoolData(getHandle().getDataWatcher().get(EntityShulker.DATA_COLOR_ID)); + return DyeColor.getByWoolData(getHandle().getEntityData().get(EntityShulker.DATA_COLOR_ID)); } @Override public void setColor(DyeColor color) { - getHandle().getDataWatcher().set(EntityShulker.DATA_COLOR_ID, (color == null) ? 16 : color.getWoolData()); + getHandle().getEntityData().set(EntityShulker.DATA_COLOR_ID, (color == null) ? 16 : color.getWoolData()); } @Override public float getPeek() { - return (float) getHandle().getPeek() / 100; + return (float) getHandle().getRawPeekAmount() / 100; } @Override public void setPeek(float value) { Preconditions.checkArgument(value >= 0 && value <= 1, "value needs to be in between or equal to 0 and 1"); - getHandle().setPeek((int) (value * 100)); + getHandle().setRawPeekAmount((int) (value * 100)); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java index 1efa3b4bc8..8d409f48a3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java @@ -22,9 +22,9 @@ public class CraftShulkerBullet extends AbstractProjectile implements ShulkerBul @Override public void setShooter(ProjectileSource shooter) { if (shooter instanceof Entity) { - getHandle().setShooter(((CraftEntity) shooter).getHandle()); + getHandle().setOwner(((CraftEntity) shooter).getHandle()); } else { - getHandle().setShooter(null); + getHandle().setOwner(null); } getHandle().projectileSource = shooter; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java index 4c7627b104..72c3b89091 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java @@ -15,10 +15,10 @@ public class CraftSizedFireball extends CraftFireball implements SizedFireball { @Override public ItemStack getDisplayItem() { - if (getHandle().getItem().isEmpty()) { + if (getHandle().getItemRaw().isEmpty()) { return new ItemStack(Material.FIRE_CHARGE); } else { - return CraftItemStack.asBukkitCopy(getHandle().getItem()); + return CraftItemStack.asBukkitCopy(getHandle().getItemRaw()); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java index 17e8af2cc0..b3f1fe6542 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java @@ -2,7 +2,6 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; import net.minecraft.world.entity.monster.EntitySkeleton; -import net.minecraft.world.entity.monster.EntitySkeletonAbstract; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Skeleton; @@ -15,7 +14,7 @@ public class CraftSkeleton extends CraftAbstractSkeleton implements Skeleton { @Override public boolean isConverting() { - return this.getHandle().fw(); // PAIL rename isStrayConverting + return this.getHandle().isFreezeConverting(); } @Override @@ -28,9 +27,9 @@ public class CraftSkeleton extends CraftAbstractSkeleton implements Skeleton { public void setConversionTime(int time) { if (time < 0) { this.getHandle().conversionTime = -1; - this.getHandle().getDataWatcher().set(EntitySkeleton.DATA_STRAY_CONVERSION_ID, false); + this.getHandle().getEntityData().set(EntitySkeleton.DATA_STRAY_CONVERSION_ID, false); } else { - this.getHandle().a(time); // PAIL rename startStrayConversion + this.getHandle().startFreezeConversion(time); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java index 5720bdf64e..d13fef732b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java @@ -17,7 +17,7 @@ public class CraftSnowman extends CraftGolem implements Snowman { @Override public void setDerp(boolean derpMode) { - getHandle().setHasPumpkin(!derpMode); + getHandle().setPumpkin(!derpMode); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java index 63d17fc4f5..83eb3ff0b6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java @@ -24,14 +24,14 @@ public class CraftSpellcaster extends CraftIllager implements Spellcaster { @Override public Spell getSpell() { - return toBukkitSpell(getHandle().getSpell()); + return toBukkitSpell(getHandle().getCurrentSpell()); } @Override public void setSpell(Spell spell) { Preconditions.checkArgument(spell != null, "Use Spell.NONE"); - getHandle().setSpell(toNMSSpell(spell)); + getHandle().setIsCastingSpell(toNMSSpell(spell)); } public static Spell toBukkitSpell(EntityIllagerWizard.Spell spell) { @@ -39,6 +39,6 @@ public class CraftSpellcaster extends CraftIllager implements Spellcaster { } public static EntityIllagerWizard.Spell toNMSSpell(Spell spell) { - return EntityIllagerWizard.Spell.a(spell.ordinal()); + return EntityIllagerWizard.Spell.byId(spell.ordinal()); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java index a75dbd0189..5ce84a6cf2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java @@ -15,17 +15,17 @@ public class CraftStrider extends CraftAnimals implements Strider { @Override public boolean isShivering() { - return getHandle().isShivering(); + return getHandle().isSuffocating(); } @Override public void setShivering(boolean shivering) { - this.getHandle().setShivering(shivering); + this.getHandle().setSuffocating(shivering); } @Override public boolean hasSaddle() { - return getHandle().hasSaddle(); + return getHandle().isSaddled(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java index 4e4ca01691..79bc9adf7e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java @@ -36,12 +36,12 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed { @Override public int getFuseTicks() { - return getHandle().getFuseTicks(); + return getHandle().getFuse(); } @Override public void setFuseTicks(int fuseTicks) { - getHandle().setFuseTicks(fuseTicks); + getHandle().setFuse(fuseTicks); } @Override @@ -61,7 +61,7 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed { @Override public Entity getSource() { - EntityLiving source = getHandle().getSource(); + EntityLiving source = getHandle().getOwner(); return (source != null) ? source.getBukkitEntity() : null; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java index 3ac6623199..8e446699bb 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java @@ -45,14 +45,14 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat @Override public boolean isTamed() { - return getHandle().isTamed(); + return getHandle().isTame(); } @Override public void setOwner(AnimalTamer tamer) { if (tamer != null) { setTamed(true); - getHandle().setGoalTarget(null, null, false); + getHandle().setTarget(null, null, false); setOwnerUUID(tamer.getUniqueId()); } else { setTamed(false); @@ -62,19 +62,19 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat @Override public void setTamed(boolean tame) { - getHandle().setTamed(tame); + getHandle().setTame(tame); if (!tame) { setOwnerUUID(null); } } public boolean isSitting() { - return getHandle().isSitting(); + return getHandle().isInSittingPose(); } public void setSitting(boolean sitting) { - getHandle().setSitting(sitting); - getHandle().setWillSit(sitting); + getHandle().setInSittingPose(sitting); + getHandle().setOrderedToSit(sitting); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java index e56754a38a..77e5890ae4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java @@ -14,10 +14,10 @@ public abstract class CraftThrowableProjectile extends CraftProjectile implement @Override public ItemStack getItem() { - if (getHandle().getItem().isEmpty()) { + if (getHandle().getItemRaw().isEmpty()) { return CraftItemStack.asBukkitCopy(new net.minecraft.world.item.ItemStack(getHandle().getDefaultItemPublic())); } else { - return CraftItemStack.asBukkitCopy(getHandle().getItem()); + return CraftItemStack.asBukkitCopy(getHandle().getItemRaw()); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java index 9a2f5841b0..57c291cf55 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java @@ -23,7 +23,7 @@ public class CraftThrownPotion extends CraftProjectile implements ThrownPotion { @Override public Collection<PotionEffect> getEffects() { ImmutableList.Builder<PotionEffect> builder = ImmutableList.builder(); - for (MobEffect effect : PotionUtil.getEffects(getHandle().getItem())) { + for (MobEffect effect : PotionUtil.getMobEffects(getHandle().getItemRaw())) { builder.add(CraftPotionUtil.toBukkit(effect)); } return builder.build(); @@ -31,7 +31,7 @@ public class CraftThrownPotion extends CraftProjectile implements ThrownPotion { @Override public ItemStack getItem() { - return CraftItemStack.asBukkitCopy(getHandle().getItem()); + return CraftItemStack.asBukkitCopy(getHandle().getItemRaw()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java index 7322b38a69..1c0e59e3ff 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java @@ -41,7 +41,7 @@ public class CraftTippedArrow extends CraftArrow implements Arrow { int effectId = effect.getType().getId(); MobEffect existing = null; for (MobEffect mobEffect : getHandle().effects) { - if (MobEffectList.getId(mobEffect.getMobEffect()) == effectId) { + if (MobEffectList.getId(mobEffect.getEffect()) == effectId) { existing = mobEffect; } } @@ -74,7 +74,7 @@ public class CraftTippedArrow extends CraftArrow implements Arrow { @Override public boolean hasCustomEffect(PotionEffectType type) { for (MobEffect effect : getHandle().effects) { - if (CraftPotionUtil.equals(effect.getMobEffect(), type)) { + if (CraftPotionUtil.equals(effect.getEffect(), type)) { return true; } } @@ -91,7 +91,7 @@ public class CraftTippedArrow extends CraftArrow implements Arrow { int effectId = effect.getId(); MobEffect existing = null; for (MobEffect mobEffect : getHandle().effects) { - if (MobEffectList.getId(mobEffect.getMobEffect()) == effectId) { + if (MobEffectList.getId(mobEffect.getEffect()) == effectId) { existing = mobEffect; } } @@ -106,17 +106,17 @@ public class CraftTippedArrow extends CraftArrow implements Arrow { @Override public void setBasePotionData(PotionData data) { Validate.notNull(data, "PotionData cannot be null"); - getHandle().setType(CraftPotionUtil.fromBukkit(data)); + getHandle().setPotionType(CraftPotionUtil.fromBukkit(data)); } @Override public PotionData getBasePotionData() { - return CraftPotionUtil.toBukkit(getHandle().getType()); + return CraftPotionUtil.toBukkit(getHandle().getPotionType()); } @Override public void setColor(Color color) { - getHandle().setColor(color.asRGB()); + getHandle().setFixedColor(color.asRGB()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java index ccaccffbf5..d6e8217e2d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java @@ -33,6 +33,6 @@ public class CraftVex extends CraftMonster implements Vex { @Override public void setCharging(boolean charging) { - getHandle().setCharging(charging); + getHandle().setIsCharging(charging); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java index aaf225e265..0b34da11d1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -46,18 +46,18 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { @Override public void setProfession(Profession profession) { Validate.notNull(profession); - getHandle().setVillagerData(getHandle().getVillagerData().withProfession(CraftVillager.bukkitToNmsProfession(profession))); + getHandle().setVillagerData(getHandle().getVillagerData().setProfession(CraftVillager.bukkitToNmsProfession(profession))); } @Override public Type getVillagerType() { - return Type.valueOf(IRegistry.VILLAGER_TYPE.getKey(getHandle().getVillagerData().getType()).getKey().toUpperCase(Locale.ROOT)); + return Type.valueOf(IRegistry.VILLAGER_TYPE.getKey(getHandle().getVillagerData().getType()).getPath().toUpperCase(Locale.ROOT)); } @Override public void setVillagerType(Type type) { Validate.notNull(type); - getHandle().setVillagerData(getHandle().getVillagerData().withType(IRegistry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey())))); + getHandle().setVillagerData(getHandle().getVillagerData().setType(IRegistry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey())))); } @Override @@ -69,19 +69,19 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { public void setVillagerLevel(int level) { Preconditions.checkArgument(1 <= level && level <= 5, "level must be between [1, 5]"); - getHandle().setVillagerData(getHandle().getVillagerData().withLevel(level)); + getHandle().setVillagerData(getHandle().getVillagerData().setLevel(level)); } @Override public int getVillagerExperience() { - return getHandle().getExperience(); + return getHandle().getVillagerXp(); } @Override public void setVillagerExperience(int experience) { Preconditions.checkArgument(experience >= 0, "Experience must be positive"); - getHandle().setExperience(experience); + getHandle().setVillagerXp(experience); } @Override @@ -92,12 +92,12 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { Preconditions.checkState(!getHandle().generation, "Cannot sleep during world generation"); BlockPosition position = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - IBlockData iblockdata = getHandle().level.getType(position); + IBlockData iblockdata = getHandle().level.getBlockState(position); if (!(iblockdata.getBlock() instanceof BlockBed)) { return false; } - getHandle().entitySleep(position); + getHandle().startSleeping(position); return true; } @@ -106,16 +106,16 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { Preconditions.checkState(isSleeping(), "Cannot wakeup if not sleeping"); Preconditions.checkState(!getHandle().generation, "Cannot wakeup during world generation"); - getHandle().entityWakeup(); + getHandle().stopSleeping(); } @Override public void shakeHead() { - getHandle().fT(); // PAIL rename shakeHead + getHandle().setUnhappy(); } public static Profession nmsToBukkitProfession(VillagerProfession nms) { - return Profession.valueOf(IRegistry.VILLAGER_PROFESSION.getKey(nms).getKey().toUpperCase(Locale.ROOT)); + return Profession.valueOf(IRegistry.VILLAGER_PROFESSION.getKey(nms).getPath().toUpperCase(Locale.ROOT)); } public static VillagerProfession bukkitToNmsProfession(Profession bukkit) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java index fe7cc3b9dc..3509323f0a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java @@ -39,24 +39,24 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager { @Override public Villager.Profession getVillagerProfession() { - return Villager.Profession.valueOf(IRegistry.VILLAGER_PROFESSION.getKey(getHandle().getVillagerData().getProfession()).getKey().toUpperCase(Locale.ROOT)); + return Villager.Profession.valueOf(IRegistry.VILLAGER_PROFESSION.getKey(getHandle().getVillagerData().getProfession()).getPath().toUpperCase(Locale.ROOT)); } @Override public void setVillagerProfession(Villager.Profession profession) { Validate.notNull(profession); - getHandle().setVillagerData(getHandle().getVillagerData().withProfession(IRegistry.VILLAGER_PROFESSION.get(new MinecraftKey(profession.name().toLowerCase(Locale.ROOT))))); + getHandle().setVillagerData(getHandle().getVillagerData().setProfession(IRegistry.VILLAGER_PROFESSION.get(new MinecraftKey(profession.name().toLowerCase(Locale.ROOT))))); } @Override public Villager.Type getVillagerType() { - return Villager.Type.valueOf(IRegistry.VILLAGER_TYPE.getKey(getHandle().getVillagerData().getType()).getKey().toUpperCase(Locale.ROOT)); + return Villager.Type.valueOf(IRegistry.VILLAGER_TYPE.getKey(getHandle().getVillagerData().getType()).getPath().toUpperCase(Locale.ROOT)); } @Override public void setVillagerType(Villager.Type type) { Validate.notNull(type); - getHandle().setVillagerData(getHandle().getVillagerData().withType(IRegistry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey())))); + getHandle().setVillagerData(getHandle().getVillagerData().setType(IRegistry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey())))); } @Override @@ -75,12 +75,12 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager { public void setConversionTime(int time) { if (time < 0) { getHandle().villagerConversionTime = -1; - getHandle().getDataWatcher().set(EntityZombieVillager.DATA_CONVERTING_ID, false); + getHandle().getEntityData().set(EntityZombieVillager.DATA_CONVERTING_ID, false); getHandle().setPersistenceRequired(false); // CraftBukkit - SPIGOT-4684 update persistence getHandle().conversionStarter = null; getHandle().removeEffect(MobEffects.DAMAGE_BOOST, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); } else { - getHandle().startConversion((UUID) null, time); + getHandle().startConverting((UUID) null, time); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java index 5ff783366c..c220a77064 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java @@ -12,12 +12,12 @@ public class CraftWitherSkull extends CraftFireball implements WitherSkull { @Override public void setCharged(boolean charged) { - getHandle().setCharged(charged); + getHandle().setDangerous(charged); } @Override public boolean isCharged() { - return getHandle().isCharged(); + return getHandle().isDangerous(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java index dc5ba91ebd..63069368a1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java @@ -20,9 +20,9 @@ public class CraftWolf extends CraftTameableAnimal implements Wolf { @Override public void setAngry(boolean angry) { if (angry) { - getHandle().anger(); + getHandle().startPersistentAngerTimer(); } else { - getHandle().pacify(); + getHandle().stopBeingAngry(); } } @@ -38,11 +38,11 @@ public class CraftWolf extends CraftTameableAnimal implements Wolf { @Override public DyeColor getCollarColor() { - return DyeColor.getByWoolData((byte) getHandle().getCollarColor().getColorIndex()); + return DyeColor.getByWoolData((byte) getHandle().getCollarColor().getId()); } @Override public void setCollarColor(DyeColor color) { - getHandle().setCollarColor(EnumColor.fromColorIndex(color.getWoolData())); + getHandle().setCollarColor(EnumColor.byId(color.getWoolData())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java index b37b160ebc..389f88543e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java @@ -61,7 +61,7 @@ public class CraftZombie extends CraftMonster implements Zombie { @Override public boolean isConverting() { - return getHandle().isDrownConverting(); + return getHandle().isUnderWaterConverting(); } @Override @@ -75,9 +75,9 @@ public class CraftZombie extends CraftMonster implements Zombie { public void setConversionTime(int time) { if (time < 0) { getHandle().conversionTime = -1; - getHandle().getDataWatcher().set(EntityZombie.DATA_DROWNED_CONVERSION_ID, false); + getHandle().getEntityData().set(EntityZombie.DATA_DROWNED_CONVERSION_ID, false); } else { - getHandle().startDrownedConversion(time); + getHandle().startUnderWaterConversion(time); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryMapper.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryMapper.java index ed442c198d..e6bf588a5d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryMapper.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryMapper.java @@ -47,10 +47,10 @@ public final class CraftMemoryMapper { } public static Location fromNms(GlobalPos globalPos) { - return new org.bukkit.Location(((CraftServer) Bukkit.getServer()).getServer().getWorldServer(globalPos.getDimensionManager()).getWorld(), globalPos.getBlockPosition().getX(), globalPos.getBlockPosition().getY(), globalPos.getBlockPosition().getZ()); + return new org.bukkit.Location(((CraftServer) Bukkit.getServer()).getServer().getLevel(globalPos.dimension()).getWorld(), globalPos.pos().getX(), globalPos.pos().getY(), globalPos.pos().getZ()); } public static GlobalPos toNms(Location location) { - return GlobalPos.create(((CraftWorld) location.getWorld()).getHandle().getDimensionKey(), new BlockPosition(location.getX(), location.getY(), location.getZ())); + return GlobalPos.of(((CraftWorld) location.getWorld()).getHandle().dimension(), new BlockPosition(location.getX(), location.getY(), location.getZ())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 7daff4c591..c3fc0a4785 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -240,12 +240,12 @@ public class CraftEventFactory { private static boolean canBuild(WorldServer world, Player player, int x, int z) { int spawnSize = Bukkit.getServer().getSpawnRadius(); - if (world.getDimensionKey() != World.OVERWORLD) return true; + if (world.dimension() != World.OVERWORLD) return true; if (spawnSize <= 0) return true; - if (((CraftServer) Bukkit.getServer()).getHandle().getOPs().isEmpty()) return true; + if (((CraftServer) Bukkit.getServer()).getHandle().getOps().isEmpty()) return true; if (player.isOp()) return true; - BlockPosition chunkcoordinates = world.getSpawn(); + BlockPosition chunkcoordinates = world.getSharedSpawnPos(); int distanceFromSpawn = Math.max(Math.abs(x - chunkcoordinates.getX()), Math.abs(z - chunkcoordinates.getZ())); return distanceFromSpawn > spawnSize; @@ -399,13 +399,13 @@ public class CraftEventFactory { if (!event.isCancelled()) { for (EntityItem item : items) { - item.level.addEntity(item); + item.level.addFreshEntity(item); } } } public static EntityPlaceEvent callEntityPlaceEvent(ItemActionContext itemactioncontext, Entity entity) { - return callEntityPlaceEvent(itemactioncontext.getWorld(), itemactioncontext.getClickPosition(), itemactioncontext.getClickedFace(), itemactioncontext.getEntity(), entity); + return callEntityPlaceEvent(itemactioncontext.getLevel(), itemactioncontext.getClickedPos(), itemactioncontext.getClickedFace(), itemactioncontext.getPlayer(), entity); } public static EntityPlaceEvent callEntityPlaceEvent(World world, BlockPosition clickPosition, EnumDirection clickedFace, EntityHuman human, Entity entity) { @@ -584,8 +584,8 @@ public class CraftEventFactory { boolean isNpc = entity instanceof NPC; if (spawnReason != SpawnReason.CUSTOM) { - if (isAnimal && !world.getWorld().getAllowAnimals() || isMonster && !world.getWorld().getAllowMonsters() || isNpc && !world.getCraftServer().getServer().getSpawnNPCs()) { - entity.die(); + if (isAnimal && !world.getWorld().getAllowAnimals() || isMonster && !world.getWorld().getAllowMonsters() || isNpc && !world.getCraftServer().getServer().areNpcsEnabled()) { + entity.discard(); return false; } } @@ -623,12 +623,12 @@ public class CraftEventFactory { if (event != null && (event.isCancelled() || entity.isRemoved())) { Entity vehicle = entity.getVehicle(); if (vehicle != null) { - vehicle.die(); + vehicle.discard(); } - for (Entity passenger : entity.getAllPassengers()) { - passenger.die(); + for (Entity passenger : entity.getIndirectPassengers()) { + passenger.discard(); } - entity.die(); + entity.discard(); return false; } @@ -763,7 +763,7 @@ public class CraftEventFactory { public static boolean handleBlockSpreadEvent(GeneratorAccess world, BlockPosition source, BlockPosition target, IBlockData block, int flag) { // Suppress during worldgen if (!(world instanceof World)) { - world.setTypeAndData(target, block, flag); + world.setBlock(target, block, flag); return true; } @@ -1167,7 +1167,7 @@ public class CraftEventFactory { public static Container callInventoryOpenEvent(EntityPlayer player, Container container, boolean cancelled) { if (player.containerMenu != player.inventoryMenu) { // fire INVENTORY_CLOSE if one already open - player.connection.a(new PacketPlayInCloseWindow(player.containerMenu.containerId)); + player.connection.handleContainerClose(new PacketPlayInCloseWindow(player.containerMenu.containerId)); } CraftServer server = player.level.getCraftServer(); @@ -1214,7 +1214,7 @@ public class CraftEventFactory { BlockFace hitFace = null; if (position.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) { MovingObjectPositionBlock positionBlock = (MovingObjectPositionBlock) position; - hitBlock = CraftBlock.at(entity.level, positionBlock.getBlockPosition()); + hitBlock = CraftBlock.at(entity.level, positionBlock.getBlockPos()); hitFace = CraftBlock.notchToBlockFace(positionBlock.getDirection()); } @@ -1297,7 +1297,7 @@ public class CraftEventFactory { } if (igniter instanceof IProjectile) { - Entity shooter = ((IProjectile) igniter).getShooter(); + Entity shooter = ((IProjectile) igniter).getOwner(); if (shooter != null) { bukkitIgniter = shooter.getBukkitEntity(); } @@ -1482,7 +1482,7 @@ public class CraftEventFactory { BlockPhysicsEvent event = new BlockPhysicsEvent(block, block.getBlockData()); // Suppress during worldgen if (world instanceof World) { - ((World) world).getMinecraftServer().server.getPluginManager().callEvent(event); + ((World) world).getServer().server.getPluginManager().callEvent(event); } return event; } @@ -1575,18 +1575,18 @@ public class CraftEventFactory { * Raid events */ public static boolean callRaidTriggerEvent(Raid raid, EntityPlayer player) { - RaidTriggerEvent event = new RaidTriggerEvent(new CraftRaid(raid), raid.getWorld().getWorld(), player.getBukkitEntity()); + RaidTriggerEvent event = new RaidTriggerEvent(new CraftRaid(raid), raid.getLevel().getWorld(), player.getBukkitEntity()); Bukkit.getPluginManager().callEvent(event); return !event.isCancelled(); } public static void callRaidFinishEvent(Raid raid, List<Player> players) { - RaidFinishEvent event = new RaidFinishEvent(new CraftRaid(raid), raid.getWorld().getWorld(), players); + RaidFinishEvent event = new RaidFinishEvent(new CraftRaid(raid), raid.getLevel().getWorld(), players); Bukkit.getPluginManager().callEvent(event); } public static void callRaidStopEvent(Raid raid, RaidStopEvent.Reason reason) { - RaidStopEvent event = new RaidStopEvent(new CraftRaid(raid), raid.getWorld().getWorld(), reason); + RaidStopEvent event = new RaidStopEvent(new CraftRaid(raid), raid.getLevel().getWorld(), reason); Bukkit.getPluginManager().callEvent(event); } @@ -1596,14 +1596,14 @@ public class CraftEventFactory { for (EntityRaider entityRaider : raiders) { craftRaiders.add((Raider) entityRaider.getBukkitEntity()); } - RaidSpawnWaveEvent event = new RaidSpawnWaveEvent(new CraftRaid(raid), raid.getWorld().getWorld(), craftLeader, craftRaiders); + RaidSpawnWaveEvent event = new RaidSpawnWaveEvent(new CraftRaid(raid), raid.getLevel().getWorld(), craftLeader, craftRaiders); Bukkit.getPluginManager().callEvent(event); } public static LootGenerateEvent callLootGenerateEvent(IInventory inventory, LootTable lootTable, LootTableInfo lootInfo, List<ItemStack> loot, boolean plugin) { - CraftWorld world = lootInfo.getWorld().getWorld(); - Entity entity = lootInfo.getContextParameter(LootContextParameters.THIS_ENTITY); - NamespacedKey key = CraftNamespacedKey.fromMinecraft(world.getHandle().getMinecraftServer().getLootTableRegistry().lootTableToKey.get(lootTable)); + CraftWorld world = lootInfo.getLevel().getWorld(); + Entity entity = lootInfo.getParamOrNull(LootContextParameters.THIS_ENTITY); + NamespacedKey key = CraftNamespacedKey.fromMinecraft(world.getHandle().getServer().getLootTables().lootTableToKey.get(lootTable)); CraftLootTable craftLootTable = new CraftLootTable(key, lootTable); List<org.bukkit.inventory.ItemStack> bukkitLoot = loot.stream().map(CraftItemStack::asCraftMirror).collect(Collectors.toCollection(ArrayList::new)); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java index aea17496ab..cc80893211 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java @@ -2,13 +2,10 @@ package org.bukkit.craftbukkit.generator; import java.lang.ref.WeakReference; import net.minecraft.core.BlockPosition; -import net.minecraft.core.IRegistry; -import net.minecraft.world.level.biome.BiomeBase; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.ITileEntity; import net.minecraft.world.level.block.entity.TileEntity; import net.minecraft.world.level.block.state.IBlockData; -import net.minecraft.world.level.chunk.BiomeStorage; import net.minecraft.world.level.chunk.IChunkAccess; import org.bukkit.Material; import org.bukkit.World; @@ -64,8 +61,7 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData { @Override public Biome getBiome(int x, int y, int z) { - BiomeStorage biomeStorage = getHandle().getBiomeIndex(); - return CraftBlock.biomeBaseToBiome((IRegistry<BiomeBase>) biomeStorage.biomeRegistry, biomeStorage.getBiome(x >> 2, y >> 2, z >> 2)); + return CraftBlock.biomeBaseToBiome(getHandle().biomeRegistry, getHandle().getNoiseBiome(x >> 2, y >> 2, z >> 2)); } @Override @@ -150,11 +146,11 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData { public IBlockData getTypeId(int x, int y, int z) { if (x != (x & 0xf) || y < minHeight || y >= maxHeight || z != (z & 0xf)) { - return Blocks.AIR.getBlockData(); + return Blocks.AIR.defaultBlockState(); } IChunkAccess access = getHandle(); - return access.getType(new BlockPosition(access.getPos().d() + x, y, access.getPos().e() + z)); + return access.getBlockState(new BlockPosition(access.getPos().getMinBlockX() + x, y, access.getPos().getMinBlockZ() + z)); } @Override @@ -168,20 +164,20 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData { } IChunkAccess access = getHandle(); - BlockPosition blockPosition = new BlockPosition(access.getPos().d() + x, y, access.getPos().e() + z); - IBlockData oldBlockData = access.setType(blockPosition, type, false); + BlockPosition blockPosition = new BlockPosition(access.getPos().getMinBlockX() + x, y, access.getPos().getMinBlockZ() + z); + IBlockData oldBlockData = access.setBlockState(blockPosition, type, false); - if (type.isTileEntity()) { - TileEntity tileEntity = ((ITileEntity) type.getBlock()).createTile(blockPosition, type); + if (type.hasBlockEntity()) { + TileEntity tileEntity = ((ITileEntity) type.getBlock()).newBlockEntity(blockPosition, type); // createTile can return null, currently only the case with material MOVING_PISTON if (tileEntity == null) { - access.removeTileEntity(blockPosition); + access.removeBlockEntity(blockPosition); } else { - access.setTileEntity(tileEntity); + access.setBlockEntity(tileEntity); } - } else if (oldBlockData != null && oldBlockData.isTileEntity()) { - access.removeTileEntity(blockPosition); + } else if (oldBlockData != null && oldBlockData.hasBlockEntity()) { + access.removeBlockEntity(blockPosition); } } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java index 2812f2d35f..ed8f86bfe4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java @@ -8,8 +8,8 @@ import java.util.List; import java.util.Random; import net.minecraft.core.BlockPosition; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.server.level.RegionLimitedWorldAccess; import net.minecraft.world.entity.EntityTypes; +import net.minecraft.world.level.ChunkCoordIntPair; import net.minecraft.world.level.GeneratorAccessSeed; import net.minecraft.world.level.biome.BiomeBase; import net.minecraft.world.level.chunk.ChunkStatus; @@ -43,17 +43,17 @@ public class CraftLimitedRegion extends CraftRegionAccessor implements LimitedRe // save them when the population is finished. private final List<net.minecraft.world.entity.Entity> entities = new ArrayList<>(); - public CraftLimitedRegion(RegionLimitedWorldAccess access) { + public CraftLimitedRegion(GeneratorAccessSeed access, ChunkCoordIntPair center) { this.weakAccess = new WeakReference<>(access); - centerChunkX = access.a().x; // PAIL rename getCenter - centerChunkZ = access.a().z; // PAIL rename getCenter + centerChunkX = center.x; + centerChunkZ = center.z; // load entities which are already present for (int x = -(buffer >> 4); x <= (buffer >> 4); x++) { for (int z = -(buffer >> 4); z <= (buffer >> 4); z++) { - ProtoChunk chunk = (ProtoChunk) access.getChunkAt(centerChunkX + x, centerChunkZ + z); - for (NBTTagCompound compound : chunk.z()) { // PAIL rename getGenerationEntities - EntityTypes.a(compound, access.getMinecraftWorld(), (entity) -> { // PAIL rename fromNBTTag + ProtoChunk chunk = (ProtoChunk) access.getChunk(centerChunkX + x, centerChunkZ + z); + for (NBTTagCompound compound : chunk.getEntities()) { + EntityTypes.loadEntityRecursive(compound, access.getMinecraftWorld(), (entity) -> { entity.generation = true; entities.add(entity); return entity; @@ -87,16 +87,16 @@ public class CraftLimitedRegion extends CraftRegionAccessor implements LimitedRe GeneratorAccessSeed access = getHandle(); for (int x = -(buffer >> 4); x <= (buffer >> 4); x++) { for (int z = -(buffer >> 4); z <= (buffer >> 4); z++) { - ProtoChunk chunk = (ProtoChunk) access.getChunkAt(centerChunkX + x, centerChunkZ + z); - chunk.z().clear(); // PAIL rename getGenerationEntities + ProtoChunk chunk = (ProtoChunk) access.getChunk(centerChunkX + x, centerChunkZ + z); + chunk.getEntities().clear(); } } for (net.minecraft.world.entity.Entity entity : entities) { if (entity.isAlive()) { // check if entity is still in region or if it got teleported outside it - Preconditions.checkState(region.contains(entity.locX(), entity.locY(), entity.locZ()), "Entity %s is not in the region", entity); - access.addEntity(entity); + Preconditions.checkState(region.contains(entity.getX(), entity.getY(), entity.getZ()), "Entity %s is not in the region", entity); + access.addFreshEntity(entity); } } } @@ -126,8 +126,8 @@ public class CraftLimitedRegion extends CraftRegionAccessor implements LimitedRe for (int x = -(buffer >> 4); x <= (buffer >> 4); x++) { for (int z = -(buffer >> 4); z <= (buffer >> 4); z++) { - ProtoChunk chunk = (ProtoChunk) getHandle().getChunkAt(centerChunkX + x, centerChunkZ + z); - for (BlockPosition position : chunk.c()) { // PAIL rename getTilePositions + ProtoChunk chunk = (ProtoChunk) getHandle().getChunk(centerChunkX + x, centerChunkZ + z); + for (BlockPosition position : chunk.getBlockEntitiesPos()) { blockStates.add(getBlockState(position.getX(), position.getY(), position.getZ())); } } @@ -145,8 +145,8 @@ public class CraftLimitedRegion extends CraftRegionAccessor implements LimitedRe @Override public void setBiome(int x, int y, int z, BiomeBase biomeBase) { Preconditions.checkArgument(isInRegion(x, y, z), "Coordinates %s, %s, %s are not in the region", x, y, z); - IChunkAccess chunk = getHandle().getChunkAt(x >> 4, z >> 4, ChunkStatus.EMPTY); - chunk.getBiomeIndex().setBiome(x >> 2, y >> 2, z >> 2, biomeBase); + IChunkAccess chunk = getHandle().getChunk(x >> 4, z >> 4, ChunkStatus.EMPTY); + chunk.setBiome(x >> 2, y >> 2, z >> 2, biomeBase); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftWorldInfo.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftWorldInfo.java index 4c0c5e4d1c..2df80e42ff 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftWorldInfo.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftWorldInfo.java @@ -19,12 +19,12 @@ public class CraftWorldInfo implements WorldInfo { private final int maxHeight; public CraftWorldInfo(IWorldDataServer worldDataServer, Convertable.ConversionSession session, World.Environment environment, DimensionManager dimensionManager) { - this.name = worldDataServer.getName(); + this.name = worldDataServer.getLevelName(); this.uuid = WorldUUID.getUUID(session.levelPath.toFile()); this.environment = environment; - this.seed = ((WorldDataServer) worldDataServer).getGeneratorSettings().getSeed(); - this.minHeight = dimensionManager.getMinY(); - this.maxHeight = dimensionManager.getMinY() + dimensionManager.getHeight(); + this.seed = ((WorldDataServer) worldDataServer).worldGenSettings().seed(); + this.minHeight = dimensionManager.minY(); + this.maxHeight = dimensionManager.minY() + dimensionManager.height(); } public CraftWorldInfo(String name, UUID uuid, World.Environment environment, long seed, int minHeight, int maxHeight) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java index 3983425e87..9ce28303b5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java @@ -13,22 +13,26 @@ import net.minecraft.server.level.WorldServer; import net.minecraft.util.random.WeightedRandomList; import net.minecraft.world.entity.EnumCreatureType; import net.minecraft.world.level.BlockColumn; +import net.minecraft.world.level.ChunkCoordIntPair; +import net.minecraft.world.level.GeneratorAccessSeed; import net.minecraft.world.level.LevelHeightAccessor; import net.minecraft.world.level.StructureManager; 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.Climate; import net.minecraft.world.level.biome.WorldChunkManager; import net.minecraft.world.level.block.ITileEntity; import net.minecraft.world.level.block.entity.TileEntity; import net.minecraft.world.level.block.state.IBlockData; -import net.minecraft.world.level.chunk.BiomeStorage; import net.minecraft.world.level.chunk.ChunkSection; import net.minecraft.world.level.chunk.IChunkAccess; import net.minecraft.world.level.chunk.ProtoChunk; import net.minecraft.world.level.levelgen.HeightMap; +import net.minecraft.world.level.levelgen.LegacyRandomSource; import net.minecraft.world.level.levelgen.SeededRandom; import net.minecraft.world.level.levelgen.WorldGenStage; +import net.minecraft.world.level.levelgen.blending.Blender; import net.minecraft.world.level.levelgen.structure.templatesystem.DefinedStructureManager; import org.bukkit.block.Biome; import org.bukkit.craftbukkit.CraftHeightMap; @@ -49,9 +53,9 @@ public class CustomChunkGenerator extends InternalChunkGenerator { @Deprecated private class CustomBiomeGrid implements BiomeGrid { - private final BiomeStorage biome; // SPIGOT-5529: stored in 4x4 grid + private final IChunkAccess biome; - public CustomBiomeGrid(BiomeStorage biome) { + public CustomBiomeGrid(IChunkAccess biome) { this.biome = biome; } @@ -69,7 +73,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator { @Override public Biome getBiome(int x, int y, int z) { - return CraftBlock.biomeBaseToBiome((IRegistry<BiomeBase>) biome.biomeRegistry, biome.getBiome(x >> 2, y >> 2, z >> 2)); + return CraftBlock.biomeBaseToBiome((IRegistry<BiomeBase>) biome.biomeRegistry, biome.getNoiseBiome(x >> 2, y >> 2, z >> 2)); } @Override @@ -80,21 +84,30 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } public CustomChunkGenerator(WorldServer world, net.minecraft.world.level.chunk.ChunkGenerator delegate, ChunkGenerator generator) { - super(delegate.getWorldChunkManager(), delegate.getSettings()); + super(delegate.getBiomeSource(), delegate.getSettings()); this.world = world; this.delegate = delegate; this.generator = generator; } + private static SeededRandom getSeededRandom() { + return new SeededRandom(new LegacyRandomSource(0)); + } + @Override public net.minecraft.world.level.chunk.ChunkGenerator withSeed(long i) { return new CustomChunkGenerator(this.world, delegate.withSeed(i), this.generator); } @Override - public WorldChunkManager getWorldChunkManager() { - return delegate.getWorldChunkManager(); + public WorldChunkManager getBiomeSource() { + return delegate.getBiomeSource(); + } + + @Override + public int getMinY() { + return delegate.getMinY(); } @Override @@ -110,26 +123,26 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } @Override - public void buildBase(RegionLimitedWorldAccess regionlimitedworldaccess, IChunkAccess ichunkaccess) { + public void buildSurface(RegionLimitedWorldAccess regionlimitedworldaccess, StructureManager structuremanager, IChunkAccess ichunkaccess) { if (generator.shouldGenerateSurface()) { - delegate.buildSurface(regionlimitedworldaccess, ichunkaccess); + delegate.buildSurface(regionlimitedworldaccess, structuremanager, ichunkaccess); } CraftChunkData chunkData = new CraftChunkData(this.world.getWorld(), ichunkaccess); - SeededRandom random = new SeededRandom(); + SeededRandom random = getSeededRandom(); int x = ichunkaccess.getPos().x; int z = ichunkaccess.getPos().z; - random.a(x, z); // PAIL rename surfaceSeeded + random.setSeed((long) x * 341873128712L + (long) z * 132897987541L); generator.generateSurface(this.world.getWorld(), random, x, z, chunkData); if (generator.shouldGenerateBedrock()) { - random = new SeededRandom(); - random.a(x, z); // PAIL rename surfaceSeeded - delegate.buildBedrock(ichunkaccess, random); + random = getSeededRandom(); + random.setSeed((long) x * 341873128712L + (long) z * 132897987541L); + // delegate.buildBedrock(ichunkaccess, random); } - random = new SeededRandom(); - random.a(x, z); // PAIL rename surfaceSeeded + random = getSeededRandom(); + random.setSeed((long) x * 341873128712L + (long) z * 132897987541L); generator.generateBedrock(this.world.getWorld(), random, x, z, chunkData); chunkData.breakLink(); @@ -143,7 +156,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator { this.random.setSeed((long) x * 341873128712L + (long) z * 132897987541L); // Get default biome data for chunk - CustomBiomeGrid biomegrid = new CustomBiomeGrid(new BiomeStorage(world.t().d(IRegistry.BIOME_REGISTRY), regionlimitedworldaccess, ichunkaccess.getPos(), this.getWorldChunkManager())); + CustomBiomeGrid biomegrid = new CustomBiomeGrid(ichunkaccess); ChunkData data; try { @@ -176,9 +189,6 @@ public class CustomChunkGenerator extends InternalChunkGenerator { csect[sec] = section; } - // Set biome grid - ((ProtoChunk) ichunkaccess).a(biomegrid.biome); - if (craftData.getTiles() != null) { for (BlockPosition pos : craftData.getTiles()) { int tx = pos.getX(); @@ -186,31 +196,31 @@ public class CustomChunkGenerator extends InternalChunkGenerator { int tz = pos.getZ(); IBlockData block = craftData.getTypeId(tx, ty, tz); - if (block.isTileEntity()) { - TileEntity tile = ((ITileEntity) block.getBlock()).createTile(new BlockPosition((x << 4) + tx, ty, (z << 4) + tz), block); - ichunkaccess.setTileEntity(tile); + if (block.hasBlockEntity()) { + TileEntity tile = ((ITileEntity) block.getBlock()).newBlockEntity(new BlockPosition((x << 4) + tx, ty, (z << 4) + tz), block); + ichunkaccess.setBlockEntity(tile); } } } // Apply captured light blocks for (BlockPosition lightPosition : craftData.getLights()) { - ((ProtoChunk) ichunkaccess).j(new BlockPosition((x << 4) + lightPosition.getX(), lightPosition.getY(), (z << 4) + lightPosition.getZ())); // PAIL rename addLightBlock + ((ProtoChunk) ichunkaccess).addLight(new BlockPosition((x << 4) + lightPosition.getX(), lightPosition.getY(), (z << 4) + lightPosition.getZ())); } } @Override - public void doCarving(long seed, BiomeManager biomemanager, IChunkAccess ichunkaccess, WorldGenStage.Features worldgenstage_features) { + public void applyCarvers(RegionLimitedWorldAccess regionlimitedworldaccess, long seed, BiomeManager biomemanager, StructureManager structuremanager, IChunkAccess ichunkaccess, WorldGenStage.Features worldgenstage_features) { if (generator.shouldGenerateCaves()) { - super.doCarving(seed, biomemanager, ichunkaccess, worldgenstage_features); + delegate.applyCarvers(regionlimitedworldaccess, seed, biomemanager, structuremanager, ichunkaccess, worldgenstage_features); } if (worldgenstage_features == WorldGenStage.Features.LIQUID) { // stage check ensures that the method is only called once CraftChunkData chunkData = new CraftChunkData(this.world.getWorld(), ichunkaccess); - SeededRandom random = new SeededRandom(); + SeededRandom random = getSeededRandom(); int x = ichunkaccess.getPos().x; int z = ichunkaccess.getPos().z; - random.c(seed, 0, 0); // PAIL rename carvingSeeded + random.setDecorationSeed(seed, 0, 0); generator.generateCaves(this.world.getWorld(), random, x, z, chunkData); chunkData.breakLink(); @@ -218,15 +228,15 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } @Override - public CompletableFuture<IChunkAccess> buildNoise(Executor executor, StructureManager structuremanager, IChunkAccess ichunkaccess) { + public CompletableFuture<IChunkAccess> fillFromNoise(Executor executor, Blender blender, StructureManager structuremanager, IChunkAccess ichunkaccess) { CompletableFuture<IChunkAccess> future = null; if (generator.shouldGenerateNoise()) { - future = delegate.buildNoise(executor, structuremanager, ichunkaccess); + future = delegate.fillFromNoise(executor, blender, structuremanager, ichunkaccess); } java.util.function.Function<IChunkAccess, IChunkAccess> function = (ichunkaccess1) -> { CraftChunkData chunkData = new CraftChunkData(this.world.getWorld(), ichunkaccess1); - SeededRandom random = new SeededRandom(); + SeededRandom random = getSeededRandom(); int x = ichunkaccess1.getPos().x; int z = ichunkaccess1.getPos().z; random.setSeed((long) x * 341873128712L + (long) z * 132897987541L); @@ -236,14 +246,14 @@ public class CustomChunkGenerator extends InternalChunkGenerator { return ichunkaccess1; }; - return future == null ? CompletableFuture.supplyAsync(() -> function.apply(ichunkaccess), net.minecraft.SystemUtils.f()) : future.thenApply(function); + return future == null ? CompletableFuture.supplyAsync(() -> function.apply(ichunkaccess), net.minecraft.SystemUtils.backgroundExecutor()) : future.thenApply(function); } @Override public int getBaseHeight(int i, int j, HeightMap.Type heightmap_type, LevelHeightAccessor levelheightaccessor) { if (implementBaseHeight) { try { - SeededRandom random = new SeededRandom(); + SeededRandom random = getSeededRandom(); int xChunk = i >> 4; int zChunk = j >> 4; random.setSeed((long) xChunk * 341873128712L + (long) zChunk * 132897987541L); @@ -258,19 +268,19 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } @Override - public WeightedRandomList<BiomeSettingsMobs.c> getMobsFor(BiomeBase biomebase, StructureManager structuremanager, EnumCreatureType enumcreaturetype, BlockPosition blockposition) { - return delegate.getMobsFor(biomebase, structuremanager, enumcreaturetype, blockposition); + public WeightedRandomList<BiomeSettingsMobs.c> getMobsAt(BiomeBase biomebase, StructureManager structuremanager, EnumCreatureType enumcreaturetype, BlockPosition blockposition) { + return delegate.getMobsAt(biomebase, structuremanager, enumcreaturetype, blockposition); } @Override - public void addDecorations(RegionLimitedWorldAccess regionlimitedworldaccess, StructureManager structuremanager) { - super.addDecorations(regionlimitedworldaccess, structuremanager, generator.shouldGenerateDecorations()); + public void applyBiomeDecoration(GeneratorAccessSeed generatoraccessseed, IChunkAccess ichunkaccess, StructureManager structuremanager) { + super.applyBiomeDecoration(generatoraccessseed, ichunkaccess, structuremanager, generator.shouldGenerateDecorations()); } @Override - public void addMobs(RegionLimitedWorldAccess regionlimitedworldaccess) { + public void spawnOriginalMobs(RegionLimitedWorldAccess regionlimitedworldaccess) { if (generator.shouldGenerateMobs()) { - delegate.addMobs(regionlimitedworldaccess); + delegate.spawnOriginalMobs(regionlimitedworldaccess); } } @@ -280,8 +290,8 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } @Override - public int getGenerationDepth() { - return delegate.getGenerationDepth(); + public int getGenDepth() { + return delegate.getGenDepth(); } @Override @@ -290,7 +300,12 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } @Override - protected Codec<? extends net.minecraft.world.level.chunk.ChunkGenerator> a() { + public Climate.Sampler climateSampler() { + return delegate.climateSampler(); + } + + @Override + protected Codec<? extends net.minecraft.world.level.chunk.ChunkGenerator> codec() { throw new UnsupportedOperationException("Cannot serialize CustomChunkGenerator"); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java index 5dd6454dd8..d86d9ae25c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; import net.minecraft.core.IRegistry; import net.minecraft.world.level.biome.BiomeBase; +import net.minecraft.world.level.biome.Climate; import net.minecraft.world.level.biome.WorldChunkManager; import org.bukkit.block.Biome; import org.bukkit.craftbukkit.block.CraftBlock; @@ -38,18 +39,18 @@ public class CustomWorldChunkManager extends WorldChunkManager { } @Override - protected Codec<? extends WorldChunkManager> a() { + protected Codec<? extends WorldChunkManager> codec() { throw new UnsupportedOperationException("Cannot serialize CustomWorldChunkManager"); } @Override - public WorldChunkManager a(long l) { + public WorldChunkManager withSeed(long l) { // TODO check method further throw new UnsupportedOperationException("Cannot copy CustomWorldChunkManager"); } @Override - public BiomeBase getBiome(int x, int y, int z) { + public BiomeBase getNoiseBiome(int x, int y, int z, Climate.Sampler sampler) { Biome biome = biomeProvider.getBiome(worldInfo, x << 2, y << 2, z << 2); Preconditions.checkArgument(biome != Biome.CUSTOM, "Cannot set the biome to %s", biome); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java index 2f67f59c8e..929730b621 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java @@ -3,6 +3,8 @@ package org.bukkit.craftbukkit.generator; import java.util.HashSet; import java.util.Set; import net.minecraft.core.BlockPosition; +import net.minecraft.core.IRegistry; +import net.minecraft.world.level.biome.BiomeBase; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.chunk.ChunkSection; @@ -23,17 +25,15 @@ public final class OldCraftChunkData implements ChunkGenerator.ChunkData { private final int minHeight; private final int maxHeight; private final ChunkSection[] sections; + private final IRegistry<BiomeBase> biomes; private Set<BlockPosition> tiles; private final Set<BlockPosition> lights = new HashSet<>(); - public OldCraftChunkData(World world) { - this(world.getMinHeight(), world.getMaxHeight()); - } - - /* pp for tests */ OldCraftChunkData(int minHeight, int maxHeight) { + public OldCraftChunkData(int minHeight, int maxHeight, IRegistry<BiomeBase> biomes) { this.minHeight = minHeight; this.maxHeight = maxHeight; - sections = new ChunkSection[(((maxHeight - 1) >> 4) + 1) - (minHeight >> 4)]; + this.biomes = biomes; + this.sections = new ChunkSection[(((maxHeight - 1) >> 4) + 1) - (minHeight >> 4)]; } @Override @@ -127,7 +127,7 @@ public final class OldCraftChunkData implements ChunkGenerator.ChunkData { int offsetBase = y & 0xf; for (int x = xMin; x < xMax; x++) { for (int z = zMin; z < zMax; z++) { - section.setType(x, offsetBase, z, type); + section.setBlockState(x, offsetBase, z, type); } } } @@ -135,13 +135,13 @@ public final class OldCraftChunkData implements ChunkGenerator.ChunkData { public IBlockData getTypeId(int x, int y, int z) { if (x != (x & 0xf) || y < minHeight || y >= maxHeight || z != (z & 0xf)) { - return Blocks.AIR.getBlockData(); + return Blocks.AIR.defaultBlockState(); } ChunkSection section = getChunkSection(y, false); if (section == null) { - return Blocks.AIR.getBlockData(); + return Blocks.AIR.defaultBlockState(); } else { - return section.getType(x, y & 0xf, z); + return section.getBlockState(x, y & 0xf, z); } } @@ -155,16 +155,16 @@ public final class OldCraftChunkData implements ChunkGenerator.ChunkData { return; } ChunkSection section = getChunkSection(y, true); - section.setType(x, y & 0xf, z, type); + section.setBlockState(x, y & 0xf, z, type); // SPIGOT-1753: Capture light blocks, for light updates - if (type.f() > 0) { // PAIL rename getLightEmission + if (type.getLightEmission() > 0) { lights.add(new BlockPosition(x, y, z)); } else { lights.remove(new BlockPosition(x, y, z)); } - if (type.isTileEntity()) { + if (type.hasBlockEntity()) { if (tiles == null) { tiles = new HashSet<>(); } @@ -177,7 +177,7 @@ public final class OldCraftChunkData implements ChunkGenerator.ChunkData { int offset = (y - minHeight) >> 4; ChunkSection section = sections[offset]; if (create && section == null) { - sections[offset] = section = new ChunkSection(offset + (minHeight >> 4)); + sections[offset] = section = new ChunkSection(offset + (minHeight >> 4), biomes); } return section; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftBlastingRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftBlastingRecipe.java index 120fc8b91f..b9a44c781c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftBlastingRecipe.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftBlastingRecipe.java @@ -25,6 +25,6 @@ public class CraftBlastingRecipe extends BlastingRecipe implements CraftRecipe { public void addToCraftingManager() { ItemStack result = this.getResult(); - MinecraftServer.getServer().getCraftingManager().addRecipe(new net.minecraft.world.item.crafting.RecipeBlasting(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); + MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeBlasting(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftCampfireRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftCampfireRecipe.java index 6b8af874a3..0a87d95739 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftCampfireRecipe.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftCampfireRecipe.java @@ -25,6 +25,6 @@ public class CraftCampfireRecipe extends CampfireRecipe implements CraftRecipe { public void addToCraftingManager() { ItemStack result = this.getResult(); - MinecraftServer.getServer().getCraftingManager().addRecipe(new net.minecraft.world.item.crafting.RecipeCampfire(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); + MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeCampfire(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java index f27705779b..4ea3914aaa 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java @@ -17,16 +17,16 @@ public class CraftComplexRecipe implements CraftRecipe, ComplexRecipe { @Override public ItemStack getResult() { - return CraftItemStack.asCraftMirror(recipe.getResult()); + return CraftItemStack.asCraftMirror(recipe.getResultItem()); } @Override public NamespacedKey getKey() { - return CraftNamespacedKey.fromMinecraft(recipe.getKey()); + return CraftNamespacedKey.fromMinecraft(recipe.getId()); } @Override public void addToCraftingManager() { - MinecraftServer.getServer().getCraftingManager().addRecipe(recipe); + MinecraftServer.getServer().getRecipeManager().addRecipe(recipe); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java index 8597ae5dda..94e75866c3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java @@ -160,7 +160,7 @@ public class CraftContainer extends Container { case CHEST: case ENDER_CHEST: case BARREL: - delegate = new ContainerChest(Containers.GENERIC_9x3, windowId, bottom, top, top.getSize() / 9); + delegate = new ContainerChest(Containers.GENERIC_9x3, windowId, bottom, top, top.getContainerSize() / 9); break; case DISPENSER: case DROPPER: @@ -239,57 +239,57 @@ public class CraftContainer extends Container { private void setupWorkbench(IInventory top, IInventory bottom) { // This code copied from ContainerWorkbench - this.a(new Slot(top, 0, 124, 35)); + this.addSlot(new Slot(top, 0, 124, 35)); int row; int col; for (row = 0; row < 3; ++row) { for (col = 0; col < 3; ++col) { - this.a(new Slot(top, 1 + col + row * 3, 30 + col * 18, 17 + row * 18)); + this.addSlot(new Slot(top, 1 + col + row * 3, 30 + col * 18, 17 + row * 18)); } } for (row = 0; row < 3; ++row) { for (col = 0; col < 9; ++col) { - this.a(new Slot(bottom, col + row * 9 + 9, 8 + col * 18, 84 + row * 18)); + this.addSlot(new Slot(bottom, col + row * 9 + 9, 8 + col * 18, 84 + row * 18)); } } for (col = 0; col < 9; ++col) { - this.a(new Slot(bottom, col, 8 + col * 18, 142)); + this.addSlot(new Slot(bottom, col, 8 + col * 18, 142)); } // End copy from ContainerWorkbench } private void setupAnvil(IInventory top, IInventory bottom) { // This code copied from ContainerAnvilAbstract - this.a(new Slot(top, 0, 27, 47)); - this.a(new Slot(top, 1, 76, 47)); - this.a(new Slot(top, 2, 134, 47)); + this.addSlot(new Slot(top, 0, 27, 47)); + this.addSlot(new Slot(top, 1, 76, 47)); + this.addSlot(new Slot(top, 2, 134, 47)); int row; int col; for (row = 0; row < 3; ++row) { for (col = 0; col < 9; ++col) { - this.a(new Slot(bottom, col + row * 9 + 9, 8 + col * 18, 84 + row * 18)); + this.addSlot(new Slot(bottom, col + row * 9 + 9, 8 + col * 18, 84 + row * 18)); } } for (row = 0; row < 9; ++row) { - this.a(new Slot(bottom, row, 8 + row * 18, 142)); + this.addSlot(new Slot(bottom, row, 8 + row * 18, 142)); } // End copy from ContainerAnvilAbstract } @Override - public ItemStack shiftClick(EntityHuman entityhuman, int i) { - return (delegate != null) ? delegate.shiftClick(entityhuman, i) : super.shiftClick(entityhuman, i); + public ItemStack quickMoveStack(EntityHuman entityhuman, int i) { + return (delegate != null) ? delegate.quickMoveStack(entityhuman, i) : super.quickMoveStack(entityhuman, i); } @Override - public boolean canUse(EntityHuman entity) { + public boolean stillValid(EntityHuman entity) { return true; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java index b87b5299b5..dc4cb10f24 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java @@ -157,11 +157,11 @@ public class CraftEntityEquipment implements EntityEquipment { } private ItemStack getEquipment(EnumItemSlot slot) { - return CraftItemStack.asBukkitCopy(entity.getHandle().getEquipment(slot)); + return CraftItemStack.asBukkitCopy(entity.getHandle().getItemBySlot(slot)); } private void setEquipment(EnumItemSlot slot, ItemStack stack, boolean silent) { - entity.getHandle().setSlot(slot, CraftItemStack.asNMSCopy(stack), silent); + entity.getHandle().setItemSlot(slot, CraftItemStack.asNMSCopy(stack), silent); } @Override @@ -250,9 +250,9 @@ public class CraftEntityEquipment implements EntityEquipment { 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.b()] = chance; + ((EntityInsentient) entity.getHandle()).handDropChances[slot.getIndex()] = chance; } else { - ((EntityInsentient) entity.getHandle()).armorDropChances[slot.b()] = chance; + ((EntityInsentient) entity.getHandle()).armorDropChances[slot.getIndex()] = chance; } } @@ -262,9 +262,9 @@ public class CraftEntityEquipment implements EntityEquipment { } if (slot == EnumItemSlot.MAINHAND || slot == EnumItemSlot.OFFHAND) { - return ((EntityInsentient) entity.getHandle()).handDropChances[slot.b()]; + return ((EntityInsentient) entity.getHandle()).handDropChances[slot.getIndex()]; } else { - return ((EntityInsentient) entity.getHandle()).armorDropChances[slot.b()]; + return ((EntityInsentient) entity.getHandle()).armorDropChances[slot.getIndex()]; } } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java index 3f3e66bb5a..c1a04c5dff 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java @@ -25,6 +25,6 @@ public class CraftFurnaceRecipe extends FurnaceRecipe implements CraftRecipe { public void addToCraftingManager() { ItemStack result = this.getResult(); - MinecraftServer.getServer().getCraftingManager().addRecipe(new net.minecraft.world.item.crafting.FurnaceRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); + MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.FurnaceRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java index 1da7c834af..88ae61c145 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -42,7 +42,7 @@ public class CraftInventory implements Inventory { @Override public int getSize() { - return getInventory().getSize(); + return getInventory().getContainerSize(); } @Override @@ -452,7 +452,7 @@ public class CraftInventory implements Inventory { public InventoryType getType() { // Thanks to Droppers extending Dispensers, Blast Furnaces & Smokers extending Furnace, order is important. if (inventory instanceof InventoryCrafting) { - return inventory.getSize() >= 9 ? InventoryType.WORKBENCH : InventoryType.CRAFTING; + return inventory.getContainerSize() >= 9 ? InventoryType.WORKBENCH : InventoryType.CRAFTING; } else if (inventory instanceof PlayerInventory) { return InventoryType.PLAYER; } else if (inventory instanceof TileEntityDropper) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java index d075c191eb..ed33581cf3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java @@ -26,7 +26,7 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn @Override public int getSize() { - return getResultInventory().getSize() + getMatrixInventory().getSize(); + return getResultInventory().getContainerSize() + getMatrixInventory().getContainerSize(); } @Override @@ -63,21 +63,21 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn @Override public CraftItemStack getItem(int index) { - if (index < getResultInventory().getSize()) { + if (index < getResultInventory().getContainerSize()) { net.minecraft.world.item.ItemStack item = getResultInventory().getItem(index); return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); } else { - net.minecraft.world.item.ItemStack item = getMatrixInventory().getItem(index - getResultInventory().getSize()); + net.minecraft.world.item.ItemStack item = getMatrixInventory().getItem(index - getResultInventory().getContainerSize()); return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); } } @Override public void setItem(int index, ItemStack item) { - if (index < getResultInventory().getSize()) { + if (index < getResultInventory().getContainerSize()) { getResultInventory().setItem(index, CraftItemStack.asNMSCopy(item)); } else { - getMatrixInventory().setItem((index - getResultInventory().getSize()), CraftItemStack.asNMSCopy(item)); + getMatrixInventory().setItem((index - getResultInventory().getContainerSize()), CraftItemStack.asNMSCopy(item)); } } @@ -97,11 +97,11 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn @Override public void setMatrix(ItemStack[] contents) { - if (getMatrixInventory().getSize() > contents.length) { - throw new IllegalArgumentException("Invalid inventory size; expected " + getMatrixInventory().getSize() + " or less"); + if (getMatrixInventory().getContainerSize() > contents.length) { + throw new IllegalArgumentException("Invalid inventory size; expected " + getMatrixInventory().getContainerSize() + " or less"); } - for (int i = 0; i < getMatrixInventory().getSize(); i++) { + for (int i = 0; i < getMatrixInventory().getContainerSize(); i++) { if (i < contents.length) { getMatrixInventory().setItem(i, CraftItemStack.asNMSCopy(contents[i])); } else { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java index 370af0da02..45f2a229f0 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java @@ -55,7 +55,7 @@ public class CraftInventoryCustom extends CraftInventory { public MinecraftInventory(InventoryHolder owner, int size, String title) { Validate.notNull(title, "Title cannot be null"); - this.items = NonNullList.a(size, ItemStack.EMPTY); + this.items = NonNullList.withSize(size, ItemStack.EMPTY); this.title = title; this.viewers = new ArrayList<HumanEntity>(); this.owner = owner; @@ -63,7 +63,7 @@ public class CraftInventoryCustom extends CraftInventory { } @Override - public int getSize() { + public int getContainerSize() { return items.size(); } @@ -73,7 +73,7 @@ public class CraftInventoryCustom extends CraftInventory { } @Override - public ItemStack splitStack(int i, int j) { + public ItemStack removeItem(int i, int j) { ItemStack stack = this.getItem(i); ItemStack result; if (stack == ItemStack.EMPTY) return stack; @@ -82,14 +82,14 @@ public class CraftInventoryCustom extends CraftInventory { result = stack; } else { result = CraftItemStack.copyNMSStack(stack, j); - stack.subtract(j); + stack.shrink(j); } - this.update(); + this.setChanged(); return result; } @Override - public ItemStack splitWithoutUpdate(int i) { + public ItemStack removeItemNoUpdate(int i) { ItemStack stack = this.getItem(i); ItemStack result; if (stack == ItemStack.EMPTY) return stack; @@ -98,7 +98,7 @@ public class CraftInventoryCustom extends CraftInventory { result = stack; } else { result = CraftItemStack.copyNMSStack(stack, 1); - stack.subtract(1); + stack.shrink(1); } return result; } @@ -122,10 +122,10 @@ public class CraftInventoryCustom extends CraftInventory { } @Override - public void update() {} + public void setChanged() {} @Override - public boolean a(EntityHuman entityhuman) { + public boolean stillValid(EntityHuman entityhuman) { return true; } @@ -159,7 +159,7 @@ public class CraftInventoryCustom extends CraftInventory { } @Override - public boolean b(int i, ItemStack itemstack) { + public boolean canPlaceItem(int i, ItemStack itemstack) { return true; } @@ -169,12 +169,12 @@ public class CraftInventoryCustom extends CraftInventory { } @Override - public void closeContainer(EntityHuman entityHuman) { + public void stopOpen(EntityHuman entityHuman) { } @Override - public void clear() { + public void clearContent() { items.clear(); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java index 30141a95ca..b6fa37e798 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java @@ -47,8 +47,8 @@ public class CraftInventoryDoubleChest extends CraftInventory implements DoubleC @Override public void setContents(ItemStack[] items) { - if (getInventory().getSize() < items.length) { - throw new IllegalArgumentException("Invalid inventory size; expected " + getInventory().getSize() + " or less"); + if (getInventory().getContainerSize() < items.length) { + throw new IllegalArgumentException("Invalid inventory size; expected " + getInventory().getContainerSize() + " or less"); } ItemStack[] leftItems = new ItemStack[left.getSize()], rightItems = new ItemStack[right.getSize()]; System.arraycopy(items, 0, leftItems, 0, Math.min(left.getSize(), items.length)); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryMerchant.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryMerchant.java index 2dcb6e90d3..979ae513ae 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryMerchant.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryMerchant.java @@ -22,7 +22,7 @@ public class CraftInventoryMerchant extends CraftInventory implements MerchantIn @Override public MerchantRecipe getSelectedRecipe() { - net.minecraft.world.item.trading.MerchantRecipe nmsRecipe = getInventory().getRecipe(); + net.minecraft.world.item.trading.MerchantRecipe nmsRecipe = getInventory().getActiveOffer(); return (nmsRecipe == null) ? null : nmsRecipe.asBukkit(); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java index fb38e69293..55f17e3aa9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java @@ -29,7 +29,7 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i @Override public ItemStack getItemInMainHand() { - return CraftItemStack.asCraftMirror(getInventory().getItemInHand()); + return CraftItemStack.asCraftMirror(getInventory().getSelected()); } @Override @@ -103,14 +103,14 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i // to reverse the order of the index from 8. That means we need 0 to correspond to 8, 1 to correspond to 7, // 2 to correspond to 6, and 3 to correspond to 5. We do this simply by taking the result of (index - 36) and // subtracting that value from 8. - if (index < PlayerInventory.getHotbarSize()) { + if (index < PlayerInventory.getSelectionSize()) { index += 36; } else if (index > 39) { index += 5; // Off hand } else if (index > 35) { index = 8 - (index - 36); } - player.connection.sendPacket(new PacketPlayOutSetSlot(player.inventoryMenu.containerId, player.inventoryMenu.incrementStateId(), index, CraftItemStack.asNMSCopy(item))); + player.connection.send(new PacketPlayOutSetSlot(player.inventoryMenu.containerId, player.inventoryMenu.incrementStateId(), index, CraftItemStack.asNMSCopy(item))); } @Override @@ -175,9 +175,9 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i @Override public void setHeldItemSlot(int slot) { - Validate.isTrue(slot >= 0 && slot < PlayerInventory.getHotbarSize(), "Slot is not between 0 and 8 inclusive"); + Validate.isTrue(slot >= 0 && slot < PlayerInventory.getSelectionSize(), "Slot is not between 0 and 8 inclusive"); this.getInventory().selected = slot; - ((CraftPlayer) this.getHolder()).getHandle().connection.sendPacket(new PacketPlayOutHeldItemSlot(slot)); + ((CraftPlayer) this.getHolder()).getHandle().connection.send(new PacketPlayOutHeldItemSlot(slot)); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index 4457f27b87..59fdd7bf7d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -26,7 +26,7 @@ public final class CraftItemStack extends ItemStack { public static net.minecraft.world.item.ItemStack asNMSCopy(ItemStack original) { if (original instanceof CraftItemStack) { CraftItemStack stack = (CraftItemStack) original; - return stack.handle == null ? net.minecraft.world.item.ItemStack.EMPTY : stack.handle.cloneItemStack(); + return stack.handle == null ? net.minecraft.world.item.ItemStack.EMPTY : stack.handle.copy(); } if (original == null || original.getType() == Material.AIR) { return net.minecraft.world.item.ItemStack.EMPTY; @@ -46,7 +46,7 @@ public final class CraftItemStack extends ItemStack { } public static net.minecraft.world.item.ItemStack copyNMSStack(net.minecraft.world.item.ItemStack original, int amount) { - net.minecraft.world.item.ItemStack stack = original.cloneItemStack(); + net.minecraft.world.item.ItemStack stack = original.copy(); stack.setCount(amount); return stack; } @@ -72,7 +72,7 @@ public final class CraftItemStack extends ItemStack { public static CraftItemStack asCraftCopy(ItemStack original) { if (original instanceof CraftItemStack) { CraftItemStack stack = (CraftItemStack) original; - return new CraftItemStack(stack.handle == null ? null : stack.handle.cloneItemStack()); + return new CraftItemStack(stack.handle == null ? null : stack.handle.copy()); } return new CraftItemStack(original); } @@ -156,14 +156,14 @@ public final class CraftItemStack extends ItemStack { public void setDurability(final short durability) { // Ignore damage if item is null if (handle != null) { - handle.setDamage(durability); + handle.setDamageValue(durability); } } @Override public short getDurability() { if (handle != null) { - return (short) handle.getDamage(); + return (short) handle.getDamageValue(); } else { return -1; } @@ -184,7 +184,7 @@ public final class CraftItemStack extends ItemStack { NBTTagList list = getEnchantmentList(handle); if (list == null) { list = new NBTTagList(); - handle.getTag().set(ENCHANTMENTS.NBT, list); + handle.getTag().put(ENCHANTMENTS.NBT, list); } int size = list.size(); @@ -192,13 +192,13 @@ public final class CraftItemStack extends ItemStack { NBTTagCompound tag = (NBTTagCompound) list.get(i); String id = tag.getString(ENCHANTMENTS_ID.NBT); if (ench.getKey().equals(NamespacedKey.fromString(id))) { - tag.setShort(ENCHANTMENTS_LVL.NBT, (short) level); + tag.putShort(ENCHANTMENTS_LVL.NBT, (short) level); return; } } NBTTagCompound tag = new NBTTagCompound(); - tag.setString(ENCHANTMENTS_ID.NBT, ench.getKey().toString()); - tag.setShort(ENCHANTMENTS_LVL.NBT, (short) level); + tag.putString(ENCHANTMENTS_ID.NBT, ench.getKey().toString()); + tag.putShort(ENCHANTMENTS_LVL.NBT, (short) level); list.add(tag); } @@ -225,7 +225,7 @@ public final class CraftItemStack extends ItemStack { if (handle == null) { return 0; } - return EnchantmentManager.getEnchantmentLevel(CraftEnchantment.getRaw(ench), handle); + return EnchantmentManager.getItemEnchantmentLevel(CraftEnchantment.getRaw(ench), handle); } @Override @@ -268,7 +268,7 @@ public final class CraftItemStack extends ItemStack { listCopy.add(list.get(i)); } } - handle.getTag().set(ENCHANTMENTS.NBT, listCopy); + handle.getTag().put(ENCHANTMENTS.NBT, listCopy); return level; } @@ -279,7 +279,7 @@ public final class CraftItemStack extends ItemStack { } static Map<Enchantment, Integer> getEnchantments(net.minecraft.world.item.ItemStack item) { - NBTTagList list = (item != null && item.hasEnchantments()) ? item.getEnchantments() : null; + NBTTagList list = (item != null && item.isEnchanted()) ? item.getEnchantmentTags() : null; if (list == null || list.size() == 0) { return ImmutableMap.of(); @@ -301,14 +301,14 @@ public final class CraftItemStack extends ItemStack { } static NBTTagList getEnchantmentList(net.minecraft.world.item.ItemStack item) { - return (item != null && item.hasEnchantments()) ? item.getEnchantments() : null; + return (item != null && item.isEnchanted()) ? item.getEnchantmentTags() : null; } @Override public CraftItemStack clone() { CraftItemStack itemStack = (CraftItemStack) super.clone(); if (this.handle != null) { - itemStack.handle = this.handle.cloneItemStack(); + itemStack.handle = this.handle.copy(); } return itemStack; } @@ -588,8 +588,8 @@ public final class CraftItemStack extends ItemStack { ((CraftMetaItem) itemMeta).applyToItem(tag); item.convertStack(((CraftMetaItem) itemMeta).getVersion()); // SpigotCraft#463 this is required now by the Vanilla client, so mimic ItemStack constructor in ensuring it - if (item.getItem() != null && item.getItem().usesDurability()) { - item.setDamage(item.getDamage()); + if (item.getItem() != null && item.getItem().canBeDepleted()) { + item.setDamageValue(item.getDamageValue()); } return true; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java index 00d43e4a77..6bb9ee0171 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java @@ -64,7 +64,7 @@ public class CraftMerchant implements Merchant { @Override public HumanEntity getTrader() { - EntityHuman eh = merchant.getTrader(); + EntityHuman eh = merchant.getTradingPlayer(); return eh == null ? null : eh.getBukkitEntity(); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java index 9da2b9c320..e6c229d306 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java @@ -56,7 +56,7 @@ public class CraftMerchantCustom extends CraftMerchant { } @Override - public EntityHuman getTrader() { + public EntityHuman getTradingPlayer() { return this.tradingPlayer; } @@ -66,13 +66,13 @@ public class CraftMerchantCustom extends CraftMerchant { } @Override - public void a(MerchantRecipe merchantrecipe) { + public void notifyTrade(MerchantRecipe merchantrecipe) { // increase recipe's uses merchantrecipe.increaseUses(); } @Override - public void m(ItemStack itemstack) { + public void notifyTradeUpdated(ItemStack itemstack) { } public IChatBaseComponent getScoreboardDisplayName() { @@ -80,31 +80,31 @@ public class CraftMerchantCustom extends CraftMerchant { } @Override - public World getWorld() { - return this.tradingWorld; - } - - @Override - public int getExperience() { + public int getVillagerXp() { return 0; // xp } @Override - public void setForcedExperience(int i) { + public void overrideXp(int i) { } @Override - public boolean isRegularVillager() { + public boolean showProgressBar() { return false; // is-regular-villager flag (hides some gui elements: xp bar, name suffix) } @Override - public SoundEffect getTradeSound() { + public SoundEffect getNotifyTradeSound() { return SoundEffects.VILLAGER_YES; } @Override - public void a(MerchantRecipeList merchantrecipelist) { + public void overrideOffers(MerchantRecipeList merchantrecipelist) { + } + + @Override + public boolean isClientSide() { + return false; } } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java index c593499aee..23dd7e15a5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java @@ -28,7 +28,7 @@ public class CraftMetaArmorStand extends CraftMetaItem { CraftMetaArmorStand(NBTTagCompound tag) { super(tag); - if (tag.hasKey(ENTITY_TAG.NBT)) { + if (tag.contains(ENTITY_TAG.NBT)) { entityTag = tag.getCompound(ENTITY_TAG.NBT); } } @@ -41,7 +41,7 @@ public class CraftMetaArmorStand extends CraftMetaItem { void deserializeInternal(NBTTagCompound tag, Object context) { super.deserializeInternal(tag, context); - if (tag.hasKey(ENTITY_TAG.NBT)) { + if (tag.contains(ENTITY_TAG.NBT)) { entityTag = tag.getCompound(ENTITY_TAG.NBT); } } @@ -58,7 +58,7 @@ public class CraftMetaArmorStand extends CraftMetaItem { super.applyToItem(tag); if (entityTag != null) { - tag.set(ENTITY_TAG.NBT, entityTag); + tag.put(ENTITY_TAG.NBT, entityTag); } } @@ -123,7 +123,7 @@ public class CraftMetaArmorStand extends CraftMetaItem { CraftMetaArmorStand clone = (CraftMetaArmorStand) super.clone(); if (entityTag != null) { - clone.entityTag = entityTag.clone(); + clone.entityTag = entityTag.copy(); } return clone; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaAxolotlBucket.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaAxolotlBucket.java index eb2445518d..1d0de7f864 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaAxolotlBucket.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaAxolotlBucket.java @@ -34,11 +34,11 @@ public class CraftMetaAxolotlBucket extends CraftMetaItem implements AxolotlBuck CraftMetaAxolotlBucket(NBTTagCompound tag) { super(tag); - if (tag.hasKeyOfType(VARIANT.NBT, CraftMagicNumbers.NBT.TAG_INT)) { + if (tag.contains(VARIANT.NBT, CraftMagicNumbers.NBT.TAG_INT)) { this.variant = tag.getInt(VARIANT.NBT); } - if (tag.hasKey(ENTITY_TAG.NBT)) { + if (tag.contains(ENTITY_TAG.NBT)) { entityTag = tag.getCompound(ENTITY_TAG.NBT); } } @@ -56,7 +56,7 @@ public class CraftMetaAxolotlBucket extends CraftMetaItem implements AxolotlBuck void deserializeInternal(NBTTagCompound tag, Object context) { super.deserializeInternal(tag, context); - if (tag.hasKey(ENTITY_TAG.NBT)) { + if (tag.contains(ENTITY_TAG.NBT)) { entityTag = tag.getCompound(ENTITY_TAG.NBT); } } @@ -73,11 +73,11 @@ public class CraftMetaAxolotlBucket extends CraftMetaItem implements AxolotlBuck super.applyToItem(tag); if (hasVariant()) { - tag.setInt(VARIANT.NBT, variant); + tag.putInt(VARIANT.NBT, variant); } if (entityTag != null) { - tag.set(ENTITY_TAG.NBT, entityTag); + tag.put(ENTITY_TAG.NBT, entityTag); } } @@ -157,7 +157,7 @@ public class CraftMetaAxolotlBucket extends CraftMetaItem implements AxolotlBuck CraftMetaAxolotlBucket clone = (CraftMetaAxolotlBucket) super.clone(); if (entityTag != null) { - clone.entityTag = entityTag.clone(); + clone.entityTag = entityTag.copy(); } return clone; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java index 27e7d79199..439c9b3001 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java @@ -43,15 +43,15 @@ public class CraftMetaBanner extends CraftMetaItem implements BannerMeta { CraftMetaBanner(NBTTagCompound tag) { super(tag); - if (!tag.hasKey("BlockEntityTag")) { + if (!tag.contains("BlockEntityTag")) { return; } NBTTagCompound entityTag = tag.getCompound("BlockEntityTag"); - base = entityTag.hasKey(BASE.NBT) ? DyeColor.getByWoolData((byte) entityTag.getInt(BASE.NBT)) : null; + base = entityTag.contains(BASE.NBT) ? DyeColor.getByWoolData((byte) entityTag.getInt(BASE.NBT)) : null; - if (entityTag.hasKey(PATTERNS.NBT)) { + if (entityTag.contains(PATTERNS.NBT)) { NBTTagList patterns = entityTag.getList(PATTERNS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND); for (int i = 0; i < Math.min(patterns.size(), 20); i++) { NBTTagCompound p = patterns.getCompound(i); @@ -91,20 +91,20 @@ public class CraftMetaBanner extends CraftMetaItem implements BannerMeta { NBTTagCompound entityTag = new NBTTagCompound(); if (base != null) { - entityTag.setInt(BASE.NBT, base.getWoolData()); + entityTag.putInt(BASE.NBT, base.getWoolData()); } NBTTagList newPatterns = new NBTTagList(); for (Pattern p : patterns) { NBTTagCompound compound = new NBTTagCompound(); - compound.setInt(COLOR.NBT, p.getColor().getWoolData()); - compound.setString(PATTERN.NBT, p.getPattern().getIdentifier()); + compound.putInt(COLOR.NBT, p.getColor().getWoolData()); + compound.putString(PATTERN.NBT, p.getPattern().getIdentifier()); newPatterns.add(compound); } - entityTag.set(PATTERNS.NBT, newPatterns); + entityTag.put(PATTERNS.NBT, newPatterns); - tag.set("BlockEntityTag", entityTag); + tag.put("BlockEntityTag", entityTag); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java index 82f6fbb66b..1018ac70f5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java @@ -44,7 +44,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta super(tag); this.material = material; - if (tag.hasKeyOfType(BLOCK_ENTITY_TAG.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { + if (tag.contains(BLOCK_ENTITY_TAG.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { blockEntityTag = tag.getCompound(BLOCK_ENTITY_TAG.NBT); } else { blockEntityTag = null; @@ -67,7 +67,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta super.applyToItem(tag); if (blockEntityTag != null) { - tag.set(BLOCK_ENTITY_TAG.NBT, blockEntityTag); + tag.put(BLOCK_ENTITY_TAG.NBT, blockEntityTag); } } @@ -75,7 +75,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta void deserializeInternal(NBTTagCompound tag, Object context) { super.deserializeInternal(tag, context); - if (tag.hasKeyOfType(BLOCK_ENTITY_TAG.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { + if (tag.contains(BLOCK_ENTITY_TAG.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { blockEntityTag = tag.getCompound(BLOCK_ENTITY_TAG.NBT); } } @@ -202,7 +202,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta public CraftMetaBlockState clone() { CraftMetaBlockState meta = (CraftMetaBlockState) super.clone(); if (blockEntityTag != null) { - meta.blockEntityTag = blockEntityTag.clone(); + meta.blockEntityTag = blockEntityTag.copy(); } return meta; } @@ -218,7 +218,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta if (blockEntityTag != null) { switch (material) { case SHIELD: - blockEntityTag.setString("id", "banner"); + blockEntityTag.putString("id", "banner"); break; case SHULKER_BOX: case WHITE_SHULKER_BOX: @@ -237,11 +237,11 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case GREEN_SHULKER_BOX: case RED_SHULKER_BOX: case BLACK_SHULKER_BOX: - blockEntityTag.setString("id", "shulker_box"); + blockEntityTag.putString("id", "shulker_box"); break; case BEE_NEST: case BEEHIVE: - blockEntityTag.setString("id", "beehive"); + blockEntityTag.putString("id", "beehive"); break; } } @@ -261,12 +261,12 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta blockEntityTag = ((CraftBlockEntityState) blockState).getSnapshotNBT(); // Set shield base if (material == Material.SHIELD) { - blockEntityTag.setInt(CraftMetaBanner.BASE.NBT, ((CraftBanner) blockState).getBaseColor().getWoolData()); + blockEntityTag.putInt(CraftMetaBanner.BASE.NBT, ((CraftBanner) blockState).getBaseColor().getWoolData()); } } private static Material shieldToBannerHack(NBTTagCompound tag) { - if (tag == null || !tag.hasKeyOfType(CraftMetaBanner.BASE.NBT, CraftMagicNumbers.NBT.TAG_INT)) { + if (tag == null || !tag.contains(CraftMetaBanner.BASE.NBT, CraftMagicNumbers.NBT.TAG_INT)) { return Material.WHITE_BANNER; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java index ef61d0233d..ca9ea5eb05 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java @@ -81,23 +81,23 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta { CraftMetaBook(NBTTagCompound tag) { super(tag); - if (tag.hasKey(BOOK_TITLE.NBT)) { + if (tag.contains(BOOK_TITLE.NBT)) { this.title = tag.getString(BOOK_TITLE.NBT); } - if (tag.hasKey(BOOK_AUTHOR.NBT)) { + if (tag.contains(BOOK_AUTHOR.NBT)) { this.author = tag.getString(BOOK_AUTHOR.NBT); } - if (tag.hasKey(RESOLVED.NBT)) { + if (tag.contains(RESOLVED.NBT)) { this.resolved = tag.getBoolean(RESOLVED.NBT); } - if (tag.hasKey(GENERATION.NBT)) { + if (tag.contains(GENERATION.NBT)) { generation = tag.getInt(GENERATION.NBT); } - if (tag.hasKey(BOOK_PAGES.NBT)) { + if (tag.contains(BOOK_PAGES.NBT)) { NBTTagList pages = tag.getList(BOOK_PAGES.NBT, CraftMagicNumbers.NBT.TAG_STRING); this.pages = new ArrayList<String>(pages.size()); @@ -160,27 +160,27 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta { super.applyToItem(itemData); if (hasTitle()) { - itemData.setString(BOOK_TITLE.NBT, this.title); + itemData.putString(BOOK_TITLE.NBT, this.title); } if (hasAuthor()) { - itemData.setString(BOOK_AUTHOR.NBT, this.author); + itemData.putString(BOOK_AUTHOR.NBT, this.author); } if (pages != null) { NBTTagList list = new NBTTagList(); for (String page : pages) { - list.add(NBTTagString.a(page)); + list.add(NBTTagString.valueOf(page)); } - itemData.set(BOOK_PAGES.NBT, list); + itemData.put(BOOK_PAGES.NBT, list); } if (resolved != null) { - itemData.setBoolean(RESOLVED.NBT, resolved); + itemData.putBoolean(RESOLVED.NBT, resolved); } if (generation != null) { - itemData.setInt(GENERATION.NBT, generation); + itemData.putInt(GENERATION.NBT, generation); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java index 53fab77b25..17dfabdd2b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java @@ -40,7 +40,7 @@ public class CraftMetaBundle extends CraftMetaItem implements BundleMeta { CraftMetaBundle(NBTTagCompound tag) { super(tag); - if (tag.hasKeyOfType(ITEMS.NBT, CraftMagicNumbers.NBT.TAG_LIST)) { + if (tag.contains(ITEMS.NBT, CraftMagicNumbers.NBT.TAG_LIST)) { NBTTagList list = tag.getList(ITEMS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND); if (list != null && !list.isEmpty()) { @@ -49,7 +49,7 @@ public class CraftMetaBundle extends CraftMetaItem implements BundleMeta { for (int i = 0; i < list.size(); i++) { NBTTagCompound nbttagcompound1 = list.getCompound(i); - addItem(CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.a(nbttagcompound1))); + addItem(CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.of(nbttagcompound1))); } } } @@ -81,7 +81,7 @@ public class CraftMetaBundle extends CraftMetaItem implements BundleMeta { list.add(saved); } - tag.set(ITEMS.NBT, list); + tag.put(ITEMS.NBT, list); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java index 4a6437f6e5..e7c52fc363 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java @@ -33,7 +33,7 @@ class CraftMetaCharge extends CraftMetaItem implements FireworkEffectMeta { CraftMetaCharge(NBTTagCompound tag) { super(tag); - if (tag.hasKey(EXPLOSION.NBT)) { + if (tag.contains(EXPLOSION.NBT)) { try { effect = CraftMetaFirework.getEffect(tag.getCompound(EXPLOSION.NBT)); } catch (IllegalArgumentException ex) { @@ -62,7 +62,7 @@ class CraftMetaCharge extends CraftMetaItem implements FireworkEffectMeta { super.applyToItem(itemTag); if (hasEffect()) { - itemTag.set(EXPLOSION.NBT, CraftMetaFirework.getExplosion(effect)); + itemTag.put(EXPLOSION.NBT, CraftMetaFirework.getExplosion(effect)); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCompass.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCompass.java index a547ca7de2..9302bc673e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCompass.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCompass.java @@ -53,14 +53,14 @@ public class CraftMetaCompass extends CraftMetaItem implements CompassMeta { CraftMetaCompass(NBTTagCompound tag) { super(tag); - if (tag.hasKey(LODESTONE_DIMENSION.NBT) && tag.hasKey(LODESTONE_POS.NBT)) { + if (tag.contains(LODESTONE_DIMENSION.NBT) && tag.contains(LODESTONE_POS.NBT)) { lodestoneWorld = (NBTTagString) tag.get(LODESTONE_DIMENSION.NBT); NBTTagCompound pos = tag.getCompound(LODESTONE_POS.NBT); lodestoneX = pos.getInt("X"); lodestoneY = pos.getInt("Y"); lodestoneZ = pos.getInt("Z"); } - if (tag.hasKey(LODESTONE_TRACKED.NBT)) { + if (tag.contains(LODESTONE_TRACKED.NBT)) { tracked = tag.getBoolean(LODESTONE_TRACKED.NBT); } } @@ -69,7 +69,7 @@ public class CraftMetaCompass extends CraftMetaItem implements CompassMeta { super(map); String lodestoneWorldString = SerializableMeta.getString(map, LODESTONE_POS_WORLD.BUKKIT, true); if (lodestoneWorldString != null) { - lodestoneWorld = NBTTagString.a(lodestoneWorldString); + lodestoneWorld = NBTTagString.valueOf(lodestoneWorldString); lodestoneX = (Integer) map.get(LODESTONE_POS_X.BUKKIT); lodestoneY = (Integer) map.get(LODESTONE_POS_Y.BUKKIT); lodestoneZ = (Integer) map.get(LODESTONE_POS_Z.BUKKIT); @@ -89,15 +89,15 @@ public class CraftMetaCompass extends CraftMetaItem implements CompassMeta { if (lodestoneWorld != null) { NBTTagCompound pos = new NBTTagCompound(); - pos.setInt("X", lodestoneX); - pos.setInt("Y", lodestoneY); - pos.setInt("Z", lodestoneZ); - tag.set(LODESTONE_POS.NBT, pos); - tag.set(LODESTONE_DIMENSION.NBT, lodestoneWorld); + pos.putInt("X", lodestoneX); + pos.putInt("Y", lodestoneY); + pos.putInt("Z", lodestoneZ); + tag.put(LODESTONE_POS.NBT, pos); + tag.put(LODESTONE_DIMENSION.NBT, lodestoneWorld); } if (tracked != null) { - tag.setBoolean(LODESTONE_TRACKED.NBT, tracked); + tag.putBoolean(LODESTONE_TRACKED.NBT, tracked); } } @@ -132,7 +132,7 @@ public class CraftMetaCompass extends CraftMetaItem implements CompassMeta { return null; } Optional<ResourceKey<net.minecraft.world.level.World>> key = net.minecraft.world.level.World.RESOURCE_KEY_CODEC.parse(DynamicOpsNBT.INSTANCE, lodestoneWorld).result(); - WorldServer worldServer = key.isPresent() ? MinecraftServer.getServer().getWorldServer(key.get()) : null; + WorldServer worldServer = key.isPresent() ? MinecraftServer.getServer().getLevel(key.get()) : null; World world = worldServer != null ? worldServer.getWorld() : null; return new Location(world, lodestoneX, lodestoneY, lodestoneZ); // world may be null here, if the referenced world is not loaded } @@ -143,7 +143,7 @@ public class CraftMetaCompass extends CraftMetaItem implements CompassMeta { if (lodestone == null) { this.lodestoneWorld = null; } else { - ResourceKey<net.minecraft.world.level.World> key = ((CraftWorld) lodestone.getWorld()).getHandle().getDimensionKey(); + ResourceKey<net.minecraft.world.level.World> key = ((CraftWorld) lodestone.getWorld()).getHandle().dimension(); DataResult<NBTBase> dataresult = net.minecraft.world.level.World.RESOURCE_KEY_CODEC.encodeStart(DynamicOpsNBT.INSTANCE, key); this.lodestoneWorld = (NBTTagString) dataresult.get().orThrow(); this.lodestoneX = lodestone.getBlockX(); @@ -191,7 +191,7 @@ public class CraftMetaCompass extends CraftMetaItem implements CompassMeta { if (meta instanceof CraftMetaCompass) { CraftMetaCompass that = (CraftMetaCompass) meta; - return (this.hasLodestone() ? that.hasLodestone() && this.lodestoneWorld.asString().equals(that.lodestoneWorld.asString()) + return (this.hasLodestone() ? that.hasLodestone() && this.lodestoneWorld.getAsString().equals(that.lodestoneWorld.getAsString()) && this.lodestoneX == that.lodestoneX && this.lodestoneY == that.lodestoneY && this.lodestoneZ == that.lodestoneZ : !that.hasLodestone()) && this.tracked == that.tracked; @@ -209,7 +209,7 @@ public class CraftMetaCompass extends CraftMetaItem implements CompassMeta { super.serialize(builder); if (hasLodestone()) { - builder.put(LODESTONE_POS_WORLD.BUKKIT, lodestoneWorld.asString()); + builder.put(LODESTONE_POS_WORLD.BUKKIT, lodestoneWorld.getAsString()); builder.put(LODESTONE_POS_X.BUKKIT, lodestoneX); builder.put(LODESTONE_POS_Y.BUKKIT, lodestoneY); builder.put(LODESTONE_POS_Z.BUKKIT, lodestoneZ); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCrossbow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCrossbow.java index e9965318d2..60af56425b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCrossbow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCrossbow.java @@ -46,7 +46,7 @@ public class CraftMetaCrossbow extends CraftMetaItem implements CrossbowMeta { charged = tag.getBoolean(CHARGED.NBT); - if (tag.hasKeyOfType(CHARGED_PROJECTILES.NBT, CraftMagicNumbers.NBT.TAG_LIST)) { + if (tag.contains(CHARGED_PROJECTILES.NBT, CraftMagicNumbers.NBT.TAG_LIST)) { NBTTagList list = tag.getList(CHARGED_PROJECTILES.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND); if (list != null && !list.isEmpty()) { @@ -55,7 +55,7 @@ public class CraftMetaCrossbow extends CraftMetaItem implements CrossbowMeta { for (int i = 0; i < list.size(); i++) { NBTTagCompound nbttagcompound1 = list.getCompound(i); - chargedProjectiles.add(CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.a(nbttagcompound1))); + chargedProjectiles.add(CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.of(nbttagcompound1))); } } } @@ -83,7 +83,7 @@ public class CraftMetaCrossbow extends CraftMetaItem implements CrossbowMeta { void applyToItem(NBTTagCompound tag) { super.applyToItem(tag); - tag.setBoolean(CHARGED.NBT, charged); + tag.putBoolean(CHARGED.NBT, charged); if (hasChargedProjectiles()) { NBTTagList list = new NBTTagList(); @@ -93,7 +93,7 @@ public class CraftMetaCrossbow extends CraftMetaItem implements CrossbowMeta { list.add(saved); } - tag.set(CHARGED_PROJECTILES.NBT, list); + tag.put(CHARGED_PROJECTILES.NBT, list); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEnchantedBook.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEnchantedBook.java index 424098ebc7..b9d280756f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEnchantedBook.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEnchantedBook.java @@ -35,7 +35,7 @@ class CraftMetaEnchantedBook extends CraftMetaItem implements EnchantmentStorage CraftMetaEnchantedBook(NBTTagCompound tag) { super(tag); - if (!tag.hasKey(STORED_ENCHANTMENTS.NBT)) { + if (!tag.contains(STORED_ENCHANTMENTS.NBT)) { return; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java index ce48b38149..4cf62913f7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaEntityTag.java @@ -28,7 +28,7 @@ public class CraftMetaEntityTag extends CraftMetaItem { CraftMetaEntityTag(NBTTagCompound tag) { super(tag); - if (tag.hasKey(ENTITY_TAG.NBT)) { + if (tag.contains(ENTITY_TAG.NBT)) { entityTag = tag.getCompound(ENTITY_TAG.NBT); } } @@ -41,7 +41,7 @@ public class CraftMetaEntityTag extends CraftMetaItem { void deserializeInternal(NBTTagCompound tag, Object context) { super.deserializeInternal(tag, context); - if (tag.hasKey(ENTITY_TAG.NBT)) { + if (tag.contains(ENTITY_TAG.NBT)) { entityTag = tag.getCompound(ENTITY_TAG.NBT); } } @@ -58,7 +58,7 @@ public class CraftMetaEntityTag extends CraftMetaItem { super.applyToItem(tag); if (entityTag != null) { - tag.set(ENTITY_TAG.NBT, entityTag); + tag.put(ENTITY_TAG.NBT, entityTag); } } @@ -128,7 +128,7 @@ public class CraftMetaEntityTag extends CraftMetaItem { CraftMetaEntityTag clone = (CraftMetaEntityTag) super.clone(); if (entityTag != null) { - clone.entityTag = entityTag.clone(); + clone.entityTag = entityTag.copy(); } return clone; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java index 4016a9edf1..e0b4323f1c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java @@ -75,7 +75,7 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta { CraftMetaFirework(NBTTagCompound tag) { super(tag); - if (!tag.hasKey(FIREWORKS.NBT)) { + if (!tag.contains(FIREWORKS.NBT)) { return; } @@ -83,7 +83,7 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta { power = 0xff & fireworks.getByte(FLIGHT.NBT); - if (!fireworks.hasKey(EXPLOSIONS.NBT)) { + if (!fireworks.contains(EXPLOSIONS.NBT)) { return; } @@ -128,17 +128,17 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta { NBTTagCompound explosion = new NBTTagCompound(); if (effect.hasFlicker()) { - explosion.setBoolean(EXPLOSION_FLICKER.NBT, true); + explosion.putBoolean(EXPLOSION_FLICKER.NBT, true); } if (effect.hasTrail()) { - explosion.setBoolean(EXPLOSION_TRAIL.NBT, true); + explosion.putBoolean(EXPLOSION_TRAIL.NBT, true); } addColors(explosion, EXPLOSION_COLORS, effect.getColors()); addColors(explosion, EXPLOSION_FADE, effect.getFadeColors()); - explosion.setByte(EXPLOSION_TYPE.NBT, (byte) getNBT(effect.getType())); + explosion.putByte(EXPLOSION_TYPE.NBT, (byte) getNBT(effect.getType())); return explosion; } @@ -221,7 +221,7 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta { } NBTTagCompound fireworks = itemTag.getCompound(FIREWORKS.NBT); - itemTag.set(FIREWORKS.NBT, fireworks); + itemTag.put(FIREWORKS.NBT, fireworks); if (hasEffects()) { NBTTagList effects = new NBTTagList(); @@ -230,12 +230,12 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta { } if (effects.size() > 0) { - fireworks.set(EXPLOSIONS.NBT, effects); + fireworks.put(EXPLOSIONS.NBT, effects); } } if (hasPower()) { - fireworks.setByte(FLIGHT.NBT, (byte) power); + fireworks.putByte(FLIGHT.NBT, (byte) power); } } @@ -250,7 +250,7 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta { colorArray[i++] = color.asRGB(); } - compound.setIntArray(key.NBT, colorArray); + compound.putIntArray(key.NBT, colorArray); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index 59973554c0..6f62f67fd6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -21,6 +21,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Base64; import java.util.Collection; import java.util.EnumSet; import java.util.HashMap; @@ -44,7 +45,6 @@ import net.minecraft.nbt.NBTTagString; import net.minecraft.network.chat.ChatComponentText; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.item.ItemBlock; -import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang.Validate; import org.apache.commons.lang3.EnumUtils; import org.bukkit.Material; @@ -324,18 +324,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } CraftMetaItem(NBTTagCompound tag) { - if (tag.hasKey(DISPLAY.NBT)) { + if (tag.contains(DISPLAY.NBT)) { NBTTagCompound display = tag.getCompound(DISPLAY.NBT); - if (display.hasKey(NAME.NBT)) { + if (display.contains(NAME.NBT)) { displayName = display.getString(NAME.NBT); } - if (display.hasKey(LOCNAME.NBT)) { + if (display.contains(LOCNAME.NBT)) { locName = display.getString(LOCNAME.NBT); } - if (display.hasKey(LORE.NBT)) { + if (display.contains(LORE.NBT)) { NBTTagList list = display.getList(LORE.NBT, CraftMagicNumbers.NBT.TAG_STRING); lore = new ArrayList<String>(list.size()); for (int index = 0; index < list.size(); index++) { @@ -345,38 +345,38 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } } - if (tag.hasKeyOfType(CUSTOM_MODEL_DATA.NBT, CraftMagicNumbers.NBT.TAG_INT)) { + if (tag.contains(CUSTOM_MODEL_DATA.NBT, CraftMagicNumbers.NBT.TAG_INT)) { customModelData = tag.getInt(CUSTOM_MODEL_DATA.NBT); } - if (tag.hasKeyOfType(BLOCK_DATA.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { + if (tag.contains(BLOCK_DATA.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { blockData = tag.getCompound(BLOCK_DATA.NBT); } this.enchantments = buildEnchantments(tag, ENCHANTMENTS); this.attributeModifiers = buildModifiers(tag, ATTRIBUTES); - if (tag.hasKey(REPAIR.NBT)) { + if (tag.contains(REPAIR.NBT)) { repairCost = tag.getInt(REPAIR.NBT); } - if (tag.hasKey(HIDEFLAGS.NBT)) { + if (tag.contains(HIDEFLAGS.NBT)) { hideFlag = tag.getInt(HIDEFLAGS.NBT); } - if (tag.hasKey(UNBREAKABLE.NBT)) { + if (tag.contains(UNBREAKABLE.NBT)) { unbreakable = tag.getBoolean(UNBREAKABLE.NBT); } - if (tag.hasKey(DAMAGE.NBT)) { + if (tag.contains(DAMAGE.NBT)) { damage = tag.getInt(DAMAGE.NBT); } - if (tag.hasKey(BUKKIT_CUSTOM_TAG.NBT)) { + if (tag.contains(BUKKIT_CUSTOM_TAG.NBT)) { NBTTagCompound compound = tag.getCompound(BUKKIT_CUSTOM_TAG.NBT); - Set<String> keys = compound.getKeys(); + Set<String> keys = compound.getAllKeys(); for (String key : keys) { persistentDataContainer.put(key, compound.get(key)); } } - Set<String> keys = tag.getKeys(); + Set<String> keys = tag.getAllKeys(); for (String key : keys) { if (!getHandledTags().contains(key)) { unhandledTags.put(key, tag.get(key)); @@ -385,7 +385,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } static Map<Enchantment, Integer> buildEnchantments(NBTTagCompound tag, ItemMetaKey key) { - if (!tag.hasKey(key.NBT)) { + if (!tag.contains(key.NBT)) { return null; } @@ -407,7 +407,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { static Multimap<Attribute, AttributeModifier> buildModifiers(NBTTagCompound tag, ItemMetaKey key) { Multimap<Attribute, AttributeModifier> modifiers = LinkedHashMultimap.create(); - if (!tag.hasKeyOfType(key.NBT, CraftMagicNumbers.NBT.TAG_LIST)) { + if (!tag.contains(key.NBT, CraftMagicNumbers.NBT.TAG_LIST)) { return modifiers; } NBTTagList mods = tag.getList(key.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND); @@ -419,7 +419,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { // 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.a(entry); + net.minecraft.world.entity.ai.attributes.AttributeModifier nmsModifier = net.minecraft.world.entity.ai.attributes.AttributeModifier.load(entry); if (nmsModifier == null) { continue; } @@ -436,7 +436,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { continue; } - if (entry.hasKeyOfType(ATTRIBUTES_SLOT.NBT, CraftMagicNumbers.NBT.TAG_STRING)) { + 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); @@ -445,7 +445,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { EquipmentSlot slot = null; try { - slot = CraftEquipmentSlot.getSlot(EnumItemSlot.fromName(slotName.toLowerCase(Locale.ROOT))); + 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 } @@ -515,11 +515,11 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { String internal = SerializableMeta.getString(map, "internal", true); if (internal != null) { - ByteArrayInputStream buf = new ByteArrayInputStream(Base64.decodeBase64(internal)); + ByteArrayInputStream buf = new ByteArrayInputStream(Base64.getDecoder().decode(internal)); try { - internalTag = NBTCompressedStreamTools.a(buf); + internalTag = NBTCompressedStreamTools.readCompressed(buf); deserializeInternal(internalTag, map); - Set<String> keys = internalTag.getKeys(); + Set<String> keys = internalTag.getAllKeys(); for (String key : keys) { if (!getHandledTags().contains(key)) { unhandledTags.put(key, internalTag.get(key)); @@ -538,7 +538,7 @@ 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.hasKeyOfType(ATTRIBUTES.NBT, CraftMagicNumbers.NBT.TAG_LIST)) { + if (tag.contains(ATTRIBUTES.NBT, CraftMagicNumbers.NBT.TAG_LIST)) { this.attributeModifiers = buildModifiers(tag, ATTRIBUTES); } } @@ -605,10 +605,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @Overridden void applyToItem(NBTTagCompound itemTag) { if (hasDisplayName()) { - setDisplayTag(itemTag, NAME.NBT, NBTTagString.a(displayName)); + setDisplayTag(itemTag, NAME.NBT, NBTTagString.valueOf(displayName)); } if (hasLocalizedName()) { - setDisplayTag(itemTag, LOCNAME.NBT, NBTTagString.a(locName)); + setDisplayTag(itemTag, LOCNAME.NBT, NBTTagString.valueOf(locName)); } if (lore != null) { @@ -616,34 +616,34 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } if (hasCustomModelData()) { - itemTag.setInt(CUSTOM_MODEL_DATA.NBT, customModelData); + itemTag.putInt(CUSTOM_MODEL_DATA.NBT, customModelData); } if (hasBlockData()) { - itemTag.set(BLOCK_DATA.NBT, blockData); + itemTag.put(BLOCK_DATA.NBT, blockData); } if (hideFlag != 0) { - itemTag.setInt(HIDEFLAGS.NBT, hideFlag); + itemTag.putInt(HIDEFLAGS.NBT, hideFlag); } applyEnchantments(enchantments, itemTag, ENCHANTMENTS); applyModifiers(attributeModifiers, itemTag, ATTRIBUTES); if (hasRepairCost()) { - itemTag.setInt(REPAIR.NBT, repairCost); + itemTag.putInt(REPAIR.NBT, repairCost); } if (isUnbreakable()) { - itemTag.setBoolean(UNBREAKABLE.NBT, unbreakable); + itemTag.putBoolean(UNBREAKABLE.NBT, unbreakable); } if (hasDamage()) { - itemTag.setInt(DAMAGE.NBT, damage); + itemTag.putInt(DAMAGE.NBT, damage); } for (Map.Entry<String, NBTBase> e : unhandledTags.entrySet()) { - itemTag.set(e.getKey(), e.getValue()); + itemTag.put(e.getKey(), e.getValue()); } if (!persistentDataContainer.isEmpty()) { @@ -651,9 +651,9 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { Map<String, NBTBase> rawPublicMap = persistentDataContainer.getRaw(); for (Map.Entry<String, NBTBase> nbtBaseEntry : rawPublicMap.entrySet()) { - bukkitCustomCompound.set(nbtBaseEntry.getKey(), nbtBaseEntry.getValue()); + bukkitCustomCompound.put(nbtBaseEntry.getKey(), nbtBaseEntry.getValue()); } - itemTag.set(BUKKIT_CUSTOM_TAG.NBT, bukkitCustomCompound); + itemTag.put(BUKKIT_CUSTOM_TAG.NBT, bukkitCustomCompound); } } @@ -665,7 +665,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { NBTTagList tagList = new NBTTagList(); for (String value : list) { // SPIGOT-5342 - horrible hack as 0 version does not go through the Mojang updater - tagList.add(NBTTagString.a(version <= 0 || version >= 1803 ? value : CraftChatMessage.fromJSONComponent(value))); // SPIGOT-4935 + tagList.add(NBTTagString.valueOf(version <= 0 || version >= 1803 ? value : CraftChatMessage.fromJSONComponent(value))); // SPIGOT-4935 } return tagList; @@ -681,13 +681,13 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) { NBTTagCompound subtag = new NBTTagCompound(); - subtag.setString(ENCHANTMENTS_ID.NBT, entry.getKey().getKey().toString()); - subtag.setShort(ENCHANTMENTS_LVL.NBT, entry.getValue().shortValue()); + subtag.putString(ENCHANTMENTS_ID.NBT, entry.getKey().getKey().toString()); + subtag.putShort(ENCHANTMENTS_LVL.NBT, entry.getValue().shortValue()); list.add(subtag); } - tag.set(key.NBT, list); + tag.put(key.NBT, list); } static void applyModifiers(Multimap<Attribute, AttributeModifier> modifiers, NBTTagCompound tag, ItemMetaKey key) { @@ -711,26 +711,26 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { continue; } - sub.setString(ATTRIBUTES_IDENTIFIER.NBT, name); // Attribute Name + sub.putString(ATTRIBUTES_IDENTIFIER.NBT, name); // Attribute Name if (entry.getValue().getSlot() != null) { EnumItemSlot slot = CraftEquipmentSlot.getNMS(entry.getValue().getSlot()); if (slot != null) { - sub.setString(ATTRIBUTES_SLOT.NBT, slot.getSlotName()); + sub.putString(ATTRIBUTES_SLOT.NBT, slot.getName()); } } list.add(sub); } - tag.set(key.NBT, list); + tag.put(key.NBT, list); } void setDisplayTag(NBTTagCompound tag, String key, NBTBase value) { final NBTTagCompound display = tag.getCompound(DISPLAY.NBT); - if (!tag.hasKey(DISPLAY.NBT)) { - tag.set(DISPLAY.NBT, display); + if (!tag.contains(DISPLAY.NBT)) { + tag.put(DISPLAY.NBT, display); } - display.set(key, value); + display.put(key, value); } @Overridden @@ -913,7 +913,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @Override public BlockData getBlockData(Material material) { - return CraftBlockData.fromData(ItemBlock.getBlockState(CraftMagicNumbers.getBlock(material).getBlockData(), blockData)); + return CraftBlockData.fromData(ItemBlock.getBlockState(CraftMagicNumbers.getBlock(material).defaultBlockState(), blockData)); } @Override @@ -1254,12 +1254,12 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { if (!internalTags.isEmpty()) { NBTTagCompound internal = new NBTTagCompound(); for (Map.Entry<String, NBTBase> e : internalTags.entrySet()) { - internal.set(e.getKey(), e.getValue()); + internal.put(e.getKey(), e.getValue()); } try { ByteArrayOutputStream buf = new ByteArrayOutputStream(); - NBTCompressedStreamTools.a(internal, buf); - builder.put("internal", Base64.encodeBase64String(buf.toByteArray())); + NBTCompressedStreamTools.writeCompressed(internal, buf); + builder.put("internal", Base64.getEncoder().encode(buf.toByteArray())); } catch (IOException ex) { Logger.getLogger(CraftMetaItem.class.getName()).log(Level.SEVERE, null, ex); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java index 317631c396..a2bbe813ef 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java @@ -36,7 +36,7 @@ public class CraftMetaKnowledgeBook extends CraftMetaItem implements KnowledgeBo CraftMetaKnowledgeBook(NBTTagCompound tag) { super(tag); - if (tag.hasKey(BOOK_RECIPES.NBT)) { + if (tag.contains(BOOK_RECIPES.NBT)) { NBTTagList pages = tag.getList(BOOK_RECIPES.NBT, 8); for (int i = 0; i < pages.size(); i++) { @@ -67,9 +67,9 @@ public class CraftMetaKnowledgeBook extends CraftMetaItem implements KnowledgeBo if (hasRecipes()) { NBTTagList list = new NBTTagList(); for (NamespacedKey recipe : this.recipes) { - list.add(NBTTagString.a(recipe.toString())); + list.add(NBTTagString.valueOf(recipe.toString())); } - itemData.set(BOOK_RECIPES.NBT, list); + itemData.put(BOOK_RECIPES.NBT, list); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java index 9624fc13cf..90ca747a39 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java @@ -30,9 +30,9 @@ class CraftMetaLeatherArmor extends CraftMetaItem implements LeatherArmorMeta { CraftMetaLeatherArmor(NBTTagCompound tag) { super(tag); - if (tag.hasKey(DISPLAY.NBT)) { + if (tag.contains(DISPLAY.NBT)) { NBTTagCompound display = tag.getCompound(DISPLAY.NBT); - if (display.hasKey(COLOR.NBT)) { + if (display.contains(COLOR.NBT)) { try { color = Color.fromRGB(display.getInt(COLOR.NBT)); } catch (IllegalArgumentException ex) { @@ -52,7 +52,7 @@ class CraftMetaLeatherArmor extends CraftMetaItem implements LeatherArmorMeta { super.applyToItem(itemTag); if (hasColor()) { - setDisplayTag(itemTag, COLOR.NBT, NBTTagInt.a(color.asRGB())); + setDisplayTag(itemTag, COLOR.NBT, NBTTagInt.valueOf(color.asRGB())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java index 2d7ddc62aa..dc56037614 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java @@ -48,22 +48,22 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta { CraftMetaMap(NBTTagCompound tag) { super(tag); - if (tag.hasKeyOfType(MAP_ID.NBT, CraftMagicNumbers.NBT.TAG_ANY_NUMBER)) { + if (tag.contains(MAP_ID.NBT, CraftMagicNumbers.NBT.TAG_ANY_NUMBER)) { this.mapId = tag.getInt(MAP_ID.NBT); } - if (tag.hasKey(MAP_SCALING.NBT)) { + if (tag.contains(MAP_SCALING.NBT)) { this.scaling = tag.getBoolean(MAP_SCALING.NBT) ? SCALING_TRUE : SCALING_FALSE; } - if (tag.hasKey(DISPLAY.NBT)) { + if (tag.contains(DISPLAY.NBT)) { NBTTagCompound display = tag.getCompound(DISPLAY.NBT); - if (display.hasKey(MAP_LOC_NAME.NBT)) { + if (display.contains(MAP_LOC_NAME.NBT)) { locName = display.getString(MAP_LOC_NAME.NBT); } - if (display.hasKey(MAP_COLOR.NBT)) { + if (display.contains(MAP_COLOR.NBT)) { try { color = Color.fromRGB(display.getInt(MAP_COLOR.NBT)); } catch (IllegalArgumentException ex) { @@ -102,19 +102,19 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta { super.applyToItem(tag); if (hasMapId()) { - tag.setInt(MAP_ID.NBT, getMapId()); + tag.putInt(MAP_ID.NBT, getMapId()); } if (hasScaling()) { - tag.setBoolean(MAP_SCALING.NBT, isScaling()); + tag.putBoolean(MAP_SCALING.NBT, isScaling()); } if (hasLocationName()) { - setDisplayTag(tag, MAP_LOC_NAME.NBT, NBTTagString.a(getLocationName())); + setDisplayTag(tag, MAP_LOC_NAME.NBT, NBTTagString.valueOf(getLocationName())); } if (hasColor()) { - setDisplayTag(tag, MAP_COLOR.NBT, NBTTagInt.a(color.asRGB())); + setDisplayTag(tag, MAP_COLOR.NBT, NBTTagInt.valueOf(color.asRGB())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java index df0dda4665..017b955c5d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java @@ -55,17 +55,17 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { CraftMetaPotion(NBTTagCompound tag) { super(tag); - if (tag.hasKey(DEFAULT_POTION.NBT)) { + if (tag.contains(DEFAULT_POTION.NBT)) { type = CraftPotionUtil.toBukkit(tag.getString(DEFAULT_POTION.NBT)); } - if (tag.hasKey(POTION_COLOR.NBT)) { + if (tag.contains(POTION_COLOR.NBT)) { try { color = Color.fromRGB(tag.getInt(POTION_COLOR.NBT)); } catch (IllegalArgumentException ex) { // Invalid colour } } - if (tag.hasKey(POTION_EFFECTS.NBT)) { + if (tag.contains(POTION_EFFECTS.NBT)) { NBTTagList list = tag.getList(POTION_EFFECTS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND); int length = list.size(); customEffects = new ArrayList<PotionEffect>(length); @@ -81,8 +81,8 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { int amp = effect.getByte(AMPLIFIER.NBT); int duration = effect.getInt(DURATION.NBT); boolean ambient = effect.getBoolean(AMBIENT.NBT); - boolean particles = tag.hasKeyOfType(SHOW_PARTICLES.NBT, CraftMagicNumbers.NBT.TAG_BYTE) ? effect.getBoolean(SHOW_PARTICLES.NBT) : true; - boolean icon = tag.hasKeyOfType(SHOW_ICON.NBT, CraftMagicNumbers.NBT.TAG_BYTE) ? effect.getBoolean(SHOW_ICON.NBT) : particles; + boolean particles = tag.contains(SHOW_PARTICLES.NBT, CraftMagicNumbers.NBT.TAG_BYTE) ? effect.getBoolean(SHOW_PARTICLES.NBT) : true; + boolean icon = tag.contains(SHOW_ICON.NBT, CraftMagicNumbers.NBT.TAG_BYTE) ? effect.getBoolean(SHOW_ICON.NBT) : particles; customEffects.add(new PotionEffect(type, duration, amp, ambient, particles, icon)); } } @@ -114,24 +114,24 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { void applyToItem(NBTTagCompound tag) { super.applyToItem(tag); - tag.setString(DEFAULT_POTION.NBT, CraftPotionUtil.fromBukkit(type)); + tag.putString(DEFAULT_POTION.NBT, CraftPotionUtil.fromBukkit(type)); if (hasColor()) { - tag.setInt(POTION_COLOR.NBT, color.asRGB()); + tag.putInt(POTION_COLOR.NBT, color.asRGB()); } if (customEffects != null) { NBTTagList effectList = new NBTTagList(); - tag.set(POTION_EFFECTS.NBT, effectList); + tag.put(POTION_EFFECTS.NBT, effectList); for (PotionEffect effect : customEffects) { NBTTagCompound effectData = new NBTTagCompound(); - effectData.setByte(ID.NBT, (byte) effect.getType().getId()); - effectData.setByte(AMPLIFIER.NBT, (byte) effect.getAmplifier()); - effectData.setInt(DURATION.NBT, effect.getDuration()); - effectData.setBoolean(AMBIENT.NBT, effect.isAmbient()); - effectData.setBoolean(SHOW_PARTICLES.NBT, effect.hasParticles()); - effectData.setBoolean(SHOW_ICON.NBT, effect.hasIcon()); + effectData.putByte(ID.NBT, (byte) effect.getType().getId()); + effectData.putByte(AMPLIFIER.NBT, (byte) effect.getAmplifier()); + effectData.putInt(DURATION.NBT, effect.getDuration()); + effectData.putBoolean(AMBIENT.NBT, effect.isAmbient()); + effectData.putBoolean(SHOW_PARTICLES.NBT, effect.hasParticles()); + effectData.putBoolean(SHOW_ICON.NBT, effect.hasIcon()); effectList.add(effectData); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java index 0a3b3ff3c0..cc0c0e16fd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java @@ -42,9 +42,9 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { CraftMetaSkull(NBTTagCompound tag) { super(tag); - if (tag.hasKeyOfType(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { - this.setProfile(GameProfileSerializer.deserialize(tag.getCompound(SKULL_OWNER.NBT))); - } else if (tag.hasKeyOfType(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !tag.getString(SKULL_OWNER.NBT).isEmpty()) { + if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { + this.setProfile(GameProfileSerializer.readGameProfile(tag.getCompound(SKULL_OWNER.NBT))); + } else if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !tag.getString(SKULL_OWNER.NBT).isEmpty()) { this.setProfile(new GameProfile(null, tag.getString(SKULL_OWNER.NBT))); } } @@ -60,15 +60,15 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { void deserializeInternal(NBTTagCompound tag, Object context) { super.deserializeInternal(tag, context); - if (tag.hasKeyOfType(SKULL_PROFILE.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { + if (tag.contains(SKULL_PROFILE.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { NBTTagCompound skullTag = tag.getCompound(SKULL_PROFILE.NBT); // convert type of stored Id from String to UUID for backwards compatibility - if (skullTag.hasKeyOfType("Id", CraftMagicNumbers.NBT.TAG_STRING)) { + if (skullTag.contains("Id", CraftMagicNumbers.NBT.TAG_STRING)) { UUID uuid = UUID.fromString(skullTag.getString("Id")); - skullTag.a("Id", uuid); + skullTag.putUUID("Id", uuid); } - this.setProfile(GameProfileSerializer.deserialize(skullTag)); + this.setProfile(GameProfileSerializer.readGameProfile(skullTag)); } } @@ -81,7 +81,7 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { private void setProfile(GameProfile profile) { this.profile = profile; - this.serializedProfile = (profile == null) ? null : GameProfileSerializer.serialize(new NBTTagCompound(), profile); + this.serializedProfile = (profile == null) ? null : GameProfileSerializer.writeGameProfile(new NBTTagCompound(), profile); } @Override @@ -90,11 +90,11 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { if (profile != null) { // SPIGOT-6558: Set initial textures - tag.set(SKULL_OWNER.NBT, serializedProfile); + tag.put(SKULL_OWNER.NBT, serializedProfile); // Fill in textures - TileEntitySkull.a(profile, (filledProfile) -> { + TileEntitySkull.updateGameprofile(profile, (filledProfile) -> { setProfile(filledProfile); - tag.set(SKULL_OWNER.NBT, serializedProfile); + tag.put(SKULL_OWNER.NBT, serializedProfile); }); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java index 72898ee33c..d47676e13f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java @@ -40,7 +40,7 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { CraftMetaSpawnEgg(NBTTagCompound tag) { super(tag); - if (tag.hasKey(ENTITY_TAG.NBT)) { + if (tag.contains(ENTITY_TAG.NBT)) { entityTag = tag.getCompound(ENTITY_TAG.NBT); } } @@ -58,7 +58,7 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { void deserializeInternal(NBTTagCompound tag, Object context) { super.deserializeInternal(tag, context); - if (tag.hasKey(ENTITY_TAG.NBT)) { + if (tag.contains(ENTITY_TAG.NBT)) { entityTag = tag.getCompound(ENTITY_TAG.NBT); if (context instanceof Map) { @@ -83,8 +83,8 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { } // See if we can read a converted ID tag - if (entityTag.hasKey(ENTITY_ID.NBT)) { - this.spawnedType = EntityType.fromName(new MinecraftKey(entityTag.getString(ENTITY_ID.NBT)).getKey()); + if (entityTag.contains(ENTITY_ID.NBT)) { + this.spawnedType = EntityType.fromName(new MinecraftKey(entityTag.getString(ENTITY_ID.NBT)).getPath()); } } } @@ -105,7 +105,7 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { } if (entityTag != null) { - tag.set(ENTITY_TAG.NBT, entityTag); + tag.put(ENTITY_TAG.NBT, entityTag); } } @@ -255,7 +255,7 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { clone.spawnedType = spawnedType; if (entityTag != null) { - clone.entityTag = entityTag.clone(); + clone.entityTag = entityTag.copy(); } return clone; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSuspiciousStew.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSuspiciousStew.java index 37c4352cf9..e403a4c010 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSuspiciousStew.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSuspiciousStew.java @@ -40,7 +40,7 @@ public class CraftMetaSuspiciousStew extends CraftMetaItem implements Suspicious CraftMetaSuspiciousStew(NBTTagCompound tag) { super(tag); - if (tag.hasKey(EFFECTS.NBT)) { + if (tag.contains(EFFECTS.NBT)) { NBTTagList list = tag.getList(EFFECTS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND); int length = list.size(); customEffects = new ArrayList<PotionEffect>(length); @@ -79,12 +79,12 @@ public class CraftMetaSuspiciousStew extends CraftMetaItem implements Suspicious if (customEffects != null) { NBTTagList effectList = new NBTTagList(); - tag.set(EFFECTS.NBT, effectList); + tag.put(EFFECTS.NBT, effectList); for (PotionEffect effect : customEffects) { NBTTagCompound effectData = new NBTTagCompound(); - effectData.setByte(ID.NBT, ((byte) effect.getType().getId())); - effectData.setInt(DURATION.NBT, effect.getDuration()); + effectData.putByte(ID.NBT, ((byte) effect.getType().getId())); + effectData.putInt(DURATION.NBT, effect.getDuration()); effectList.add(effectData); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaTropicalFishBucket.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaTropicalFishBucket.java index 7b7e4907cd..c9e131614c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaTropicalFishBucket.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaTropicalFishBucket.java @@ -37,11 +37,11 @@ class CraftMetaTropicalFishBucket extends CraftMetaItem implements TropicalFishB CraftMetaTropicalFishBucket(NBTTagCompound tag) { super(tag); - if (tag.hasKeyOfType(VARIANT.NBT, CraftMagicNumbers.NBT.TAG_INT)) { + if (tag.contains(VARIANT.NBT, CraftMagicNumbers.NBT.TAG_INT)) { this.variant = tag.getInt(VARIANT.NBT); } - if (tag.hasKey(ENTITY_TAG.NBT)) { + if (tag.contains(ENTITY_TAG.NBT)) { entityTag = tag.getCompound(ENTITY_TAG.NBT); } } @@ -59,7 +59,7 @@ class CraftMetaTropicalFishBucket extends CraftMetaItem implements TropicalFishB void deserializeInternal(NBTTagCompound tag, Object context) { super.deserializeInternal(tag, context); - if (tag.hasKey(ENTITY_TAG.NBT)) { + if (tag.contains(ENTITY_TAG.NBT)) { entityTag = tag.getCompound(ENTITY_TAG.NBT); } } @@ -76,11 +76,11 @@ class CraftMetaTropicalFishBucket extends CraftMetaItem implements TropicalFishB super.applyToItem(tag); if (hasVariant()) { - tag.setInt(VARIANT.NBT, variant); + tag.putInt(VARIANT.NBT, variant); } if (entityTag != null) { - tag.set(ENTITY_TAG.NBT, entityTag); + tag.put(ENTITY_TAG.NBT, entityTag); } } @@ -187,7 +187,7 @@ class CraftMetaTropicalFishBucket extends CraftMetaItem implements TropicalFishB CraftMetaTropicalFishBucket clone = (CraftMetaTropicalFishBucket) super.clone(); if (entityTag != null) { - clone.entityTag = entityTag.clone(); + clone.entityTag = entityTag.copy(); } return clone; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java index 9b7acad5a6..83d6972100 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java @@ -26,7 +26,7 @@ public interface CraftRecipe extends Recipe { throw new IllegalArgumentException("Unknown recipe stack instance " + bukkit); } - stack.buildChoices(); + stack.dissolve(); if (requireNotEmpty && stack.itemStacks.length == 0) { throw new IllegalArgumentException("Recipe requires at least one non-air choice!"); } @@ -35,7 +35,7 @@ public interface CraftRecipe extends Recipe { } public static RecipeChoice toBukkit(RecipeItemStack list) { - list.buildChoices(); + list.dissolve(); if (list.itemStacks.length == 0) { return null; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftResultInventory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftResultInventory.java index 3b676c4853..bf3714e071 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftResultInventory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftResultInventory.java @@ -22,26 +22,26 @@ public class CraftResultInventory extends CraftInventory { @Override public ItemStack getItem(int slot) { - if (slot < getIngredientsInventory().getSize()) { + if (slot < getIngredientsInventory().getContainerSize()) { net.minecraft.world.item.ItemStack item = getIngredientsInventory().getItem(slot); return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); } else { - net.minecraft.world.item.ItemStack item = getResultInventory().getItem(slot - getIngredientsInventory().getSize()); + net.minecraft.world.item.ItemStack item = getResultInventory().getItem(slot - getIngredientsInventory().getContainerSize()); return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); } } @Override public void setItem(int index, ItemStack item) { - if (index < getIngredientsInventory().getSize()) { + if (index < getIngredientsInventory().getContainerSize()) { getIngredientsInventory().setItem(index, CraftItemStack.asNMSCopy(item)); } else { - getResultInventory().setItem((index - getIngredientsInventory().getSize()), CraftItemStack.asNMSCopy(item)); + getResultInventory().setItem((index - getIngredientsInventory().getContainerSize()), CraftItemStack.asNMSCopy(item)); } } @Override public int getSize() { - return getResultInventory().getSize() + getIngredientsInventory().getSize(); + return getResultInventory().getContainerSize() + getIngredientsInventory().getContainerSize(); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java index 5c4b0c07db..8770d62bf5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java @@ -20,7 +20,7 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe { } public CraftShapedRecipe(ItemStack result, ShapedRecipes recipe) { - this(CraftNamespacedKey.fromMinecraft(recipe.getKey()), result); + this(CraftNamespacedKey.fromMinecraft(recipe.getId()), result); this.recipe = recipe; } @@ -47,7 +47,7 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe { String[] shape = this.getShape(); Map<Character, org.bukkit.inventory.RecipeChoice> ingred = this.getChoiceMap(); int width = shape[0].length(); - NonNullList<RecipeItemStack> data = NonNullList.a(shape.length * width, RecipeItemStack.EMPTY); + NonNullList<RecipeItemStack> data = NonNullList.withSize(shape.length * width, RecipeItemStack.EMPTY); for (int i = 0; i < shape.length; i++) { String row = shape[i]; @@ -56,6 +56,6 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe { } } - MinecraftServer.getServer().getCraftingManager().addRecipe(new ShapedRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), width, shape.length, data, CraftItemStack.asNMSCopy(this.getResult()))); + MinecraftServer.getServer().getRecipeManager().addRecipe(new ShapedRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), width, shape.length, data, CraftItemStack.asNMSCopy(this.getResult()))); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java index 82fd9c4935..1f9b5dcbbd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java @@ -20,7 +20,7 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe } public CraftShapelessRecipe(ItemStack result, ShapelessRecipes recipe) { - this(CraftNamespacedKey.fromMinecraft(recipe.getKey()), result); + this(CraftNamespacedKey.fromMinecraft(recipe.getId()), result); this.recipe = recipe; } @@ -39,11 +39,11 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe @Override public void addToCraftingManager() { List<org.bukkit.inventory.RecipeChoice> ingred = this.getChoiceList(); - NonNullList<RecipeItemStack> data = NonNullList.a(ingred.size(), RecipeItemStack.EMPTY); + NonNullList<RecipeItemStack> data = NonNullList.withSize(ingred.size(), RecipeItemStack.EMPTY); for (int i = 0; i < ingred.size(); i++) { data.set(i, toNMS(ingred.get(i), true)); } - MinecraftServer.getServer().getCraftingManager().addRecipe(new ShapelessRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftItemStack.asNMSCopy(this.getResult()), data)); + MinecraftServer.getServer().getRecipeManager().addRecipe(new ShapelessRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftItemStack.asNMSCopy(this.getResult()), data)); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java index 5ca10153c7..4454061228 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java @@ -24,6 +24,6 @@ public class CraftSmithingRecipe extends SmithingRecipe implements CraftRecipe { public void addToCraftingManager() { ItemStack result = this.getResult(); - MinecraftServer.getServer().getCraftingManager().addRecipe(new net.minecraft.world.item.crafting.RecipeSmithing(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result))); + MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeSmithing(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result))); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmokingRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmokingRecipe.java index d2572b2fcb..1bed390afe 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmokingRecipe.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmokingRecipe.java @@ -25,6 +25,6 @@ public class CraftSmokingRecipe extends SmokingRecipe implements CraftRecipe { public void addToCraftingManager() { ItemStack result = this.getResult(); - MinecraftServer.getServer().getCraftingManager().addRecipe(new net.minecraft.world.item.crafting.RecipeSmoking(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); + MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeSmoking(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftStonecuttingRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftStonecuttingRecipe.java index eb5a3c8e8b..544e416dca 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftStonecuttingRecipe.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftStonecuttingRecipe.java @@ -25,6 +25,6 @@ public class CraftStonecuttingRecipe extends StonecuttingRecipe implements Craft public void addToCraftingManager() { ItemStack result = this.getResult(); - MinecraftServer.getServer().getCraftingManager().addRecipe(new net.minecraft.world.item.crafting.RecipeStonecutting(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result))); + MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeStonecutting(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result))); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java index 3401134dd2..e4598a65b8 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java @@ -14,7 +14,7 @@ public class RecipeIterator implements Iterator<Recipe> { private Iterator<IRecipe<?>> current; public RecipeIterator() { - this.recipes = MinecraftServer.getServer().getCraftingManager().recipes.entrySet().iterator(); + this.recipes = MinecraftServer.getServer().getRecipeManager().recipes.entrySet().iterator(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java index d69dc9cbd4..4441713fda 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java @@ -50,7 +50,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public IInventory getTileEntity() { - TileEntityFurnace furnace = new TileEntityFurnaceFurnace(BlockPosition.ZERO, Blocks.FURNACE.getBlockData()); // TODO: customize this if required + TileEntityFurnace furnace = new TileEntityFurnaceFurnace(BlockPosition.ZERO, Blocks.FURNACE.defaultBlockState()); // TODO: customize this if required return furnace; } @@ -71,7 +71,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public IInventory getTileEntity() { - return new TileEntityBrewingStand(BlockPosition.ZERO, Blocks.BREWING_STAND.getBlockData()); + return new TileEntityBrewingStand(BlockPosition.ZERO, Blocks.BREWING_STAND.defaultBlockState()); } @Override @@ -94,7 +94,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public IInventory getTileEntity() { - return new TileEntityDispenser(BlockPosition.ZERO, Blocks.DISPENSER.getBlockData()); + return new TileEntityDispenser(BlockPosition.ZERO, Blocks.DISPENSER.defaultBlockState()); } } @@ -102,7 +102,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public IInventory getTileEntity() { - return new TileEntityDropper(BlockPosition.ZERO, Blocks.DROPPER.getBlockData()); + return new TileEntityDropper(BlockPosition.ZERO, Blocks.DROPPER.defaultBlockState()); } } @@ -110,7 +110,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public IInventory getTileEntity() { - return new TileEntityHopper(BlockPosition.ZERO, Blocks.HOPPER.getBlockData()); + return new TileEntityHopper(BlockPosition.ZERO, Blocks.HOPPER.defaultBlockState()); } } @@ -118,7 +118,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public IInventory getTileEntity() { - return new TileEntityBlastFurnace(BlockPosition.ZERO, Blocks.BLAST_FURNACE.getBlockData()); + return new TileEntityBlastFurnace(BlockPosition.ZERO, Blocks.BLAST_FURNACE.defaultBlockState()); } } @@ -126,7 +126,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public IInventory getTileEntity() { - return new TileEntityLectern(BlockPosition.ZERO, Blocks.LECTERN.getBlockData()).bookAccess; + return new TileEntityLectern(BlockPosition.ZERO, Blocks.LECTERN.defaultBlockState()).bookAccess; } } @@ -134,7 +134,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public IInventory getTileEntity() { - return new TileEntitySmoker(BlockPosition.ZERO, Blocks.SMOKER.getBlockData()); + return new TileEntitySmoker(BlockPosition.ZERO, Blocks.SMOKER.defaultBlockState()); } } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java b/paper-server/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java index ab58b0cac8..ed79cfbfc4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java @@ -72,7 +72,7 @@ public final class CraftLegacy { if (material.isBlock()) { Block block = CraftMagicNumbers.getBlock(material); - IBlockData blockData = block.getBlockData(); + IBlockData blockData = block.defaultBlockState(); // Try exact match first mappedData = dataToMaterial.get(blockData); @@ -81,7 +81,7 @@ public final class CraftLegacy { mappedData = blockToMaterial.get(block); // Fallback to matching item if (mappedData == null) { - mappedData = itemToMaterial.get(block.getItem()); + mappedData = itemToMaterial.get(block.asItem()); } } } else { @@ -106,11 +106,11 @@ public final class CraftLegacy { // Fallback to any block Block convertedBlock = materialToBlock.get(materialData); if (convertedBlock != null) { - return convertedBlock.getBlockData(); + return convertedBlock.defaultBlockState(); } // Return air - return Blocks.AIR.getBlockData(); + return Blocks.AIR.defaultBlockState(); } public static Item fromLegacyData(Material material, short data) { @@ -129,13 +129,13 @@ public final class CraftLegacy { // Try exact match first IBlockData converted = materialToData.get(materialData); if (converted != null) { - return converted.getBlock().getItem(); + return converted.getBlock().asItem(); } // Fallback to any block Block convertedBlock = materialToBlock.get(materialData); if (convertedBlock != null) { - return convertedBlock.getItem(); + return convertedBlock.asItem(); } } @@ -313,8 +313,8 @@ public final class CraftLegacy { SPAWN_EGGS.put((byte) EntityType.ZOMBIFIED_PIGLIN.getTypeId(), Material.ZOMBIFIED_PIGLIN_SPAWN_EGG); SPAWN_EGGS.put((byte) EntityType.ZOMBIE_VILLAGER.getTypeId(), Material.ZOMBIE_VILLAGER_SPAWN_EGG); - SharedConstants.a(); - DispenserRegistry.init(); + SharedConstants.tryDetectVersion(); + DispenserRegistry.bootStrap(); for (Material material : Material.values()) { if (!material.isLegacy()) { @@ -325,8 +325,8 @@ public final class CraftLegacy { if (material.isBlock()) { for (byte data = 0; data < 16; data++) { MaterialData matData = new MaterialData(material, data); - Dynamic blockTag = DataConverterFlattenData.b(material.getId() << 4 | data); - blockTag = DataConverterRegistry.a().update(DataConverterTypes.BLOCK_STATE, blockTag, 100, CraftMagicNumbers.INSTANCE.getDataVersion()); + Dynamic blockTag = DataConverterFlattenData.getTag(material.getId() << 4 | data); + blockTag = DataConverterRegistry.getDataFixer().update(DataConverterTypes.BLOCK_STATE, blockTag, 100, CraftMagicNumbers.INSTANCE.getDataVersion()); // TODO: better skull conversion, chests if (blockTag.get("Name").asString("").contains("%%FILTER_ME%%")) { continue; @@ -337,14 +337,14 @@ public final class CraftLegacy { if (block == null) { continue; } - IBlockData blockData = block.getBlockData(); - BlockStateList states = block.getStates(); + IBlockData blockData = block.defaultBlockState(); + BlockStateList states = block.getStateDefinition(); Optional<NBTTagCompound> propMap = blockTag.getElement("Properties").result(); if (propMap.isPresent()) { NBTTagCompound properties = propMap.get(); - for (String dataKey : properties.getKeys()) { - IBlockState state = states.a(dataKey); + for (String dataKey : properties.getAllKeys()) { + IBlockState state = states.getProperty(dataKey); if (state == null) { if (whitelistedStates.contains(dataKey)) { @@ -354,12 +354,12 @@ public final class CraftLegacy { } Preconditions.checkState(!properties.getString(dataKey).isEmpty(), "Empty data string"); - Optional opt = state.b(properties.getString(dataKey)); + Optional opt = state.getValue(properties.getString(dataKey)); if (!opt.isPresent()) { throw new IllegalStateException("No state value " + properties.getString(dataKey) + " for " + dataKey); } - blockData = blockData.set(state, (Comparable) opt.get()); + blockData = blockData.setValue(state, (Comparable) opt.get()); } } @@ -392,17 +392,17 @@ public final class CraftLegacy { continue; } // Skip non item stacks for now (18w19b) - if (DataConverterMaterialId.a(material.getId()) == null) { + if (DataConverterMaterialId.getItem(material.getId()) == null) { continue; } MaterialData matData = new MaterialData(material, data); NBTTagCompound stack = new NBTTagCompound(); - stack.setInt("id", material.getId()); - stack.setShort("Damage", data); + stack.putInt("id", material.getId()); + stack.putShort("Damage", data); - Dynamic<NBTBase> converted = DataConverterRegistry.a().update(DataConverterTypes.ITEM_STACK, new Dynamic<NBTBase>(DynamicOpsNBT.INSTANCE, stack), -1, CraftMagicNumbers.INSTANCE.getDataVersion()); + Dynamic<NBTBase> converted = DataConverterRegistry.getDataFixer().update(DataConverterTypes.ITEM_STACK, new Dynamic<NBTBase>(DynamicOpsNBT.INSTANCE, stack), -1, CraftMagicNumbers.INSTANCE.getDataVersion()); String newId = converted.get("id").asString(""); // Recover spawn eggs with invalid data diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapCanvas.java b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapCanvas.java index a4bf147e9b..7a7922bb19 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapCanvas.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapCanvas.java @@ -41,7 +41,7 @@ public class CraftMapCanvas implements MapCanvas { return; if (buffer[y * 128 + x] != color) { buffer[y * 128 + x] = color; - mapView.worldMap.flagDirty(x, y); + mapView.worldMap.setColorsDirty(x, y); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java index a33babdf16..aeb286ed54 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java @@ -42,7 +42,7 @@ public class CraftMapRenderer extends MapRenderer { } MapIcon decoration = worldMap.decorations.get(key); - cursors.addCursor(decoration.getX(), decoration.getY(), (byte) (decoration.getRotation() & 15), decoration.getType().a(), true, CraftChatMessage.fromComponent(decoration.getName())); + cursors.addCursor(decoration.getX(), decoration.getY(), (byte) (decoration.getRot() & 15), decoration.getType().getIcon(), true, CraftChatMessage.fromComponent(decoration.getName())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java index caf4972a7a..830a1ab3d7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java @@ -62,14 +62,14 @@ public final class CraftMapView implements MapView { @Override public World getWorld() { ResourceKey<net.minecraft.world.level.World> dimension = worldMap.dimension; - WorldServer world = MinecraftServer.getServer().getWorldServer(dimension); + WorldServer world = MinecraftServer.getServer().getLevel(dimension); return (world == null) ? null : world.getWorld(); } @Override public void setWorld(World world) { - worldMap.dimension = ((CraftWorld) world).getHandle().getDimensionKey(); + worldMap.dimension = ((CraftWorld) world).getHandle().dimension(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java index f342feee4e..88fa07e48b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java @@ -118,7 +118,7 @@ public final class CraftPersistentDataContainer implements PersistentDataContain public NBTTagCompound toTagCompound() { NBTTagCompound tag = new NBTTagCompound(); for (Entry<String, NBTBase> entry : this.customDataTags.entrySet()) { - tag.set(entry.getKey(), entry.getValue()); + tag.put(entry.getKey(), entry.getValue()); } return tag; } @@ -132,7 +132,7 @@ public final class CraftPersistentDataContainer implements PersistentDataContain } public void putAll(NBTTagCompound compound) { - for (String key : compound.getKeys()) { + for (String key : compound.getAllKeys()) { this.customDataTags.put(key, compound.get(key)); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataTypeRegistry.java b/paper-server/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataTypeRegistry.java index 3eedbfd8ba..9a8fe9f414 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataTypeRegistry.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataTypeRegistry.java @@ -114,42 +114,42 @@ public final class CraftPersistentDataTypeRegistry { Primitives */ if (Objects.equals(Byte.class, type)) { - return createAdapter(Byte.class, NBTTagByte.class, NBTTagByte::a, NBTTagByte::asByte); + return createAdapter(Byte.class, NBTTagByte.class, NBTTagByte::valueOf, NBTTagByte::getAsByte); } if (Objects.equals(Short.class, type)) { - return createAdapter(Short.class, NBTTagShort.class, NBTTagShort::a, NBTTagShort::asShort); + return createAdapter(Short.class, NBTTagShort.class, NBTTagShort::valueOf, NBTTagShort::getAsShort); } if (Objects.equals(Integer.class, type)) { - return createAdapter(Integer.class, NBTTagInt.class, NBTTagInt::a, NBTTagInt::asInt); + return createAdapter(Integer.class, NBTTagInt.class, NBTTagInt::valueOf, NBTTagInt::getAsInt); } if (Objects.equals(Long.class, type)) { - return createAdapter(Long.class, NBTTagLong.class, NBTTagLong::a, NBTTagLong::asLong); + return createAdapter(Long.class, NBTTagLong.class, NBTTagLong::valueOf, NBTTagLong::getAsLong); } if (Objects.equals(Float.class, type)) { - return createAdapter(Float.class, NBTTagFloat.class, NBTTagFloat::a, NBTTagFloat::asFloat); + return createAdapter(Float.class, NBTTagFloat.class, NBTTagFloat::valueOf, NBTTagFloat::getAsFloat); } if (Objects.equals(Double.class, type)) { - return createAdapter(Double.class, NBTTagDouble.class, NBTTagDouble::a, NBTTagDouble::asDouble); + return createAdapter(Double.class, NBTTagDouble.class, NBTTagDouble::valueOf, NBTTagDouble::getAsDouble); } /* String */ if (Objects.equals(String.class, type)) { - return createAdapter(String.class, NBTTagString.class, NBTTagString::a, NBTTagString::asString); + return createAdapter(String.class, NBTTagString.class, NBTTagString::valueOf, NBTTagString::getAsString); } /* Primitive Arrays */ if (Objects.equals(byte[].class, type)) { - return createAdapter(byte[].class, NBTTagByteArray.class, array -> new NBTTagByteArray(Arrays.copyOf(array, array.length)), n -> Arrays.copyOf(n.getBytes(), n.size())); + return createAdapter(byte[].class, NBTTagByteArray.class, array -> new NBTTagByteArray(Arrays.copyOf(array, array.length)), n -> Arrays.copyOf(n.getAsByteArray(), n.size())); } if (Objects.equals(int[].class, type)) { - return createAdapter(int[].class, NBTTagIntArray.class, array -> new NBTTagIntArray(Arrays.copyOf(array, array.length)), n -> Arrays.copyOf(n.getInts(), n.size())); + return createAdapter(int[].class, NBTTagIntArray.class, array -> new NBTTagIntArray(Arrays.copyOf(array, array.length)), n -> Arrays.copyOf(n.getAsIntArray(), n.size())); } if (Objects.equals(long[].class, type)) { - return createAdapter(long[].class, NBTTagLongArray.class, array -> new NBTTagLongArray(Arrays.copyOf(array, array.length)), n -> Arrays.copyOf(n.getLongs(), n.size())); + return createAdapter(long[].class, NBTTagLongArray.class, array -> new NBTTagLongArray(Arrays.copyOf(array, array.length)), n -> Arrays.copyOf(n.getAsLongArray(), n.size())); } /* @@ -169,7 +169,7 @@ public final class CraftPersistentDataTypeRegistry { for (int i = 0; i < tag.size(); i++) { CraftPersistentDataContainer container = new CraftPersistentDataContainer(this); NBTTagCompound compound = tag.getCompound(i); - for (String key : compound.getKeys()) { + for (String key : compound.getAllKeys()) { container.put(key, compound.get(key)); } containerArray[i] = container; @@ -185,7 +185,7 @@ public final class CraftPersistentDataTypeRegistry { if (Objects.equals(PersistentDataContainer.class, type)) { return createAdapter(CraftPersistentDataContainer.class, NBTTagCompound.class, CraftPersistentDataContainer::toTagCompound, tag -> { CraftPersistentDataContainer container = new CraftPersistentDataContainer(this); - for (String key : tag.getKeys()) { + for (String key : tag.getAllKeys()) { container.put(key, tag.get(key)); } return container; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionBrewer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionBrewer.java index 7156bd1c89..e3b2df0a19 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionBrewer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionBrewer.java @@ -22,7 +22,7 @@ public class CraftPotionBrewer implements PotionBrewer { if (cache.containsKey(damage)) return cache.get(damage); - List<MobEffect> mcEffects = PotionRegistry.a(CraftPotionUtil.fromBukkit(new PotionData(damage, extended, upgraded))).a(); + List<MobEffect> mcEffects = PotionRegistry.byName(CraftPotionUtil.fromBukkit(new PotionData(damage, extended, upgraded))).getEffects(); ImmutableList.Builder<PotionEffect> builder = new ImmutableList.Builder<PotionEffect>(); for (MobEffect effect : mcEffects) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java index bc11c564d7..b94528e71b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java @@ -95,7 +95,7 @@ public class CraftPotionEffectType extends PotionEffectType { @Override public boolean isInstant() { - return handle.isInstant(); + return handle.isInstantenous(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java b/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java index 94fbf3f54e..dd19622a48 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java @@ -100,16 +100,16 @@ public class CraftPotionUtil { } public static MobEffect fromBukkit(PotionEffect effect) { - MobEffectList type = MobEffectList.fromId(effect.getType().getId()); + MobEffectList type = MobEffectList.byId(effect.getType().getId()); return new MobEffect(type, effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()); } public static PotionEffect toBukkit(MobEffect effect) { - PotionEffectType type = PotionEffectType.getById(MobEffectList.getId(effect.getMobEffect())); + PotionEffectType type = PotionEffectType.getById(MobEffectList.getId(effect.getEffect())); int amp = effect.getAmplifier(); int duration = effect.getDuration(); boolean ambient = effect.isAmbient(); - boolean particles = effect.isShowParticles(); + boolean particles = effect.isVisible(); return new PotionEffect(type, duration, amp, ambient, particles); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java b/paper-server/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java index da8effafdf..8745eef7db 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java @@ -54,7 +54,7 @@ public class CraftBlockProjectileSource implements BlockProjectileSource { @Override public Block getBlock() { - return dispenserBlock.getWorld().getWorld().getBlockAt(dispenserBlock.getPosition().getX(), dispenserBlock.getPosition().getY(), dispenserBlock.getPosition().getZ()); + return dispenserBlock.getLevel().getWorld().getBlockAt(dispenserBlock.getBlockPos().getX(), dispenserBlock.getBlockPos().getY(), dispenserBlock.getBlockPos().getZ()); } @Override @@ -66,63 +66,63 @@ public class CraftBlockProjectileSource implements BlockProjectileSource { public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) { Validate.isTrue(getBlock().getType() == Material.DISPENSER, "Block is no longer dispenser"); // Copied from BlockDispenser.dispense() - SourceBlock isourceblock = new SourceBlock((WorldServer) dispenserBlock.getWorld(), dispenserBlock.getPosition()); + SourceBlock isourceblock = new SourceBlock((WorldServer) dispenserBlock.getLevel(), dispenserBlock.getBlockPos()); // Copied from DispenseBehaviorProjectile - IPosition iposition = BlockDispenser.a(isourceblock); - EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); - net.minecraft.world.level.World world = dispenserBlock.getWorld(); + IPosition iposition = BlockDispenser.getDispensePosition(isourceblock); + EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING); + net.minecraft.world.level.World world = dispenserBlock.getLevel(); net.minecraft.world.entity.Entity launch = null; if (Snowball.class.isAssignableFrom(projectile)) { - launch = new EntitySnowball(world, iposition.getX(), iposition.getY(), iposition.getZ()); + launch = new EntitySnowball(world, iposition.x(), iposition.y(), iposition.z()); } else if (Egg.class.isAssignableFrom(projectile)) { - launch = new EntityEgg(world, iposition.getX(), iposition.getY(), iposition.getZ()); + launch = new EntityEgg(world, iposition.x(), iposition.y(), iposition.z()); } else if (EnderPearl.class.isAssignableFrom(projectile)) { launch = new EntityEnderPearl(world, null); - launch.setPosition(iposition.getX(), iposition.getY(), iposition.getZ()); + launch.setPos(iposition.x(), iposition.y(), iposition.z()); } else if (ThrownExpBottle.class.isAssignableFrom(projectile)) { - launch = new EntityThrownExpBottle(world, iposition.getX(), iposition.getY(), iposition.getZ()); + launch = new EntityThrownExpBottle(world, iposition.x(), iposition.y(), iposition.z()); } else if (ThrownPotion.class.isAssignableFrom(projectile)) { if (LingeringPotion.class.isAssignableFrom(projectile)) { - launch = new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ()); + launch = new EntityPotion(world, iposition.x(), iposition.y(), iposition.z()); ((EntityPotion) launch).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1))); } else { - launch = new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ()); + launch = new EntityPotion(world, iposition.x(), iposition.y(), iposition.z()); ((EntityPotion) launch).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1))); } } else if (AbstractArrow.class.isAssignableFrom(projectile)) { if (TippedArrow.class.isAssignableFrom(projectile)) { - launch = new EntityTippedArrow(world, iposition.getX(), iposition.getY(), iposition.getZ()); - ((EntityTippedArrow) launch).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false))); + launch = new EntityTippedArrow(world, iposition.x(), iposition.y(), iposition.z()); + ((EntityTippedArrow) launch).setPotionType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false))); } else if (SpectralArrow.class.isAssignableFrom(projectile)) { - launch = new EntitySpectralArrow(world, iposition.getX(), iposition.getY(), iposition.getZ()); + launch = new EntitySpectralArrow(world, iposition.x(), iposition.y(), iposition.z()); } else { - launch = new EntityTippedArrow(world, iposition.getX(), iposition.getY(), iposition.getZ()); + launch = new EntityTippedArrow(world, iposition.x(), iposition.y(), iposition.z()); } ((EntityArrow) launch).pickup = EntityArrow.PickupStatus.ALLOWED; ((EntityArrow) launch).projectileSource = this; } else if (Fireball.class.isAssignableFrom(projectile)) { - double d0 = iposition.getX() + (double) ((float) enumdirection.getAdjacentX() * 0.3F); - double d1 = iposition.getY() + (double) ((float) enumdirection.getAdjacentY() * 0.3F); - double d2 = iposition.getZ() + (double) ((float) enumdirection.getAdjacentZ() * 0.3F); + double d0 = iposition.x() + (double) ((float) enumdirection.getStepX() * 0.3F); + double d1 = iposition.y() + (double) ((float) enumdirection.getStepY() * 0.3F); + double d2 = iposition.z() + (double) ((float) enumdirection.getStepZ() * 0.3F); Random random = world.random; - double d3 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentX(); - double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY(); - double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ(); + double d3 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepX(); + double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepY(); + double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepZ(); if (SmallFireball.class.isAssignableFrom(projectile)) { launch = new EntitySmallFireball(world, null, d0, d1, d2); } else if (WitherSkull.class.isAssignableFrom(projectile)) { - launch = EntityTypes.WITHER_SKULL.a(world); - launch.setPosition(d0, d1, d2); + launch = EntityTypes.WITHER_SKULL.create(world); + launch.setPos(d0, d1, d2); double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5); ((EntityFireball) launch).xPower = d3 / d6 * 0.1D; ((EntityFireball) launch).yPower = d4 / d6 * 0.1D; ((EntityFireball) launch).zPower = d5 / d6 * 0.1D; } else { - launch = EntityTypes.FIREBALL.a(world); - launch.setPosition(d0, d1, d2); + launch = EntityTypes.FIREBALL.create(world); + launch.setPos(d0, d1, d2); double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5); ((EntityFireball) launch).xPower = d3 / d6 * 0.1D; @@ -148,14 +148,14 @@ public class CraftBlockProjectileSource implements BlockProjectileSource { b *= 1.25F; } // Copied from DispenseBehaviorProjectile - ((IProjectile) launch).shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), b, a); + ((IProjectile) launch).shoot((double) enumdirection.getStepX(), (double) ((float) enumdirection.getStepY() + 0.1F), (double) enumdirection.getStepZ(), b, a); } if (velocity != null) { ((T) launch.getBukkitEntity()).setVelocity(velocity); } - world.addEntity(launch); + world.addFreshEntity(launch); return (T) launch.getBukkitEntity(); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftObjective.java b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftObjective.java index 8fedca656a..17a0b0428e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftObjective.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftObjective.java @@ -68,13 +68,13 @@ final class CraftObjective extends CraftScoreboardComponent implements Objective ScoreboardObjective objective = this.objective; for (int i = 0; i < CraftScoreboardTranslations.MAX_DISPLAY_SLOT; i++) { - if (board.getObjectiveForSlot(i) == objective) { - board.setDisplaySlot(i, null); + if (board.getDisplayObjective(i) == objective) { + board.setDisplayObjective(i, null); } } if (slot != null) { int slotNumber = CraftScoreboardTranslations.fromBukkitSlot(slot); - board.setDisplaySlot(slotNumber, getHandle()); + board.setDisplayObjective(slotNumber, getHandle()); } } @@ -85,7 +85,7 @@ final class CraftObjective extends CraftScoreboardComponent implements Objective ScoreboardObjective objective = this.objective; for (int i = 0; i < CraftScoreboardTranslations.MAX_DISPLAY_SLOT; i++) { - if (board.getObjectiveForSlot(i) == objective) { + if (board.getDisplayObjective(i) == objective) { return CraftScoreboardTranslations.toBukkitSlot(i); } } @@ -118,7 +118,7 @@ final class CraftObjective extends CraftScoreboardComponent implements Objective @Override public Score getScore(String entry) throws IllegalArgumentException, IllegalStateException { Validate.notNull(entry, "Entry cannot be null"); - Validate.isTrue(entry.length() <= 40, "Score '" + entry + "' is longer than the limit of 40 characters"); + Validate.isTrue(entry.length() <= Short.MAX_VALUE, "Score '" + entry + "' is longer than the limit of 32767 characters"); CraftScoreboard scoreboard = checkState(); return new CraftScore(this, entry); @@ -128,7 +128,7 @@ final class CraftObjective extends CraftScoreboardComponent implements Objective public void unregister() throws IllegalStateException { CraftScoreboard scoreboard = checkState(); - scoreboard.board.unregisterObjective(objective); + scoreboard.board.removeObjective(objective); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java index af86f6d541..d0b0517b1c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java @@ -43,8 +43,8 @@ final class CraftScore implements Score { public int getScore() throws IllegalStateException { Scoreboard board = objective.checkState().board; - if (board.getPlayers().contains(entry)) { // Lazy - Map<ScoreboardObjective, ScoreboardScore> scores = board.getPlayerObjectives(entry); + if (board.getTrackedPlayers().contains(entry)) { // Lazy + Map<ScoreboardObjective, ScoreboardScore> scores = board.getPlayerScores(entry); ScoreboardScore score = scores.get(objective.getHandle()); if (score != null) { // Lazy return score.getScore(); @@ -56,14 +56,14 @@ final class CraftScore implements Score { @Override public void setScore(int score) throws IllegalStateException { - objective.checkState().board.getPlayerScoreForObjective(entry, objective.getHandle()).setScore(score); + objective.checkState().board.getOrCreatePlayerScore(entry, objective.getHandle()).setScore(score); } @Override public boolean isScoreSet() throws IllegalStateException { Scoreboard board = objective.checkState().board; - return board.getPlayers().contains(entry) && board.getPlayerObjectives(entry).containsKey(objective.getHandle()); + return board.getTrackedPlayers().contains(entry) && board.getPlayerScores(entry).containsKey(objective.getHandle()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java index 954389b818..206dcb8a74 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java @@ -40,12 +40,12 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard { Validate.notNull(criteria, "Criteria cannot be null"); Validate.notNull(displayName, "Display name cannot be null"); Validate.notNull(renderType, "RenderType cannot be null"); - Validate.isTrue(name.length() <= 16, "The name '" + name + "' is longer than the limit of 16 characters"); + Validate.isTrue(name.length() <= Short.MAX_VALUE, "The name '" + name + "' is longer than the limit of 32767 characters"); Validate.isTrue(displayName.length() <= 128, "The display name '" + displayName + "' is longer than the limit of 128 characters"); Validate.isTrue(board.getObjective(name) == null, "An objective of name '" + name + "' already exists"); CraftCriteria craftCriteria = CraftCriteria.getFromBukkit(criteria); - ScoreboardObjective objective = board.registerObjective(name, craftCriteria.criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType)); + ScoreboardObjective objective = board.addObjective(name, craftCriteria.criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType)); return new CraftObjective(this, objective); } @@ -84,7 +84,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard { @Override public Objective getObjective(DisplaySlot slot) throws IllegalArgumentException { Validate.notNull(slot, "Display slot cannot be null"); - ScoreboardObjective objective = board.getObjectiveForSlot(CraftScoreboardTranslations.fromBukkitSlot(slot)); + ScoreboardObjective objective = board.getDisplayObjective(CraftScoreboardTranslations.fromBukkitSlot(slot)); if (objective == null) { return null; } @@ -121,7 +121,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard { Validate.notNull(entry, "Entry cannot be null"); for (ScoreboardObjective objective : (Collection<ScoreboardObjective>) this.board.getObjectives()) { - board.resetPlayerScores(entry, objective); + board.resetPlayerScore(entry, objective); } } @@ -129,7 +129,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard { public Team getPlayerTeam(OfflinePlayer player) throws IllegalArgumentException { Validate.notNull(player, "OfflinePlayer cannot be null"); - ScoreboardTeam team = board.getPlayerTeam(player.getName()); + ScoreboardTeam team = board.getPlayersTeam(player.getName()); return team == null ? null : new CraftTeam(this, team); } @@ -137,7 +137,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard { public Team getEntryTeam(String entry) throws IllegalArgumentException { Validate.notNull(entry, "Entry cannot be null"); - ScoreboardTeam team = board.getPlayerTeam(entry); + ScoreboardTeam team = board.getPlayersTeam(entry); return team == null ? null : new CraftTeam(this, team); } @@ -145,13 +145,13 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard { public Team getTeam(String teamName) throws IllegalArgumentException { Validate.notNull(teamName, "Team name cannot be null"); - ScoreboardTeam team = board.getTeam(teamName); + ScoreboardTeam team = board.getPlayerTeam(teamName); return team == null ? null : new CraftTeam(this, team); } @Override public ImmutableSet<Team> getTeams() { - return ImmutableSet.copyOf(Iterables.transform((Collection<ScoreboardTeam>) this.board.getTeams(), new Function<ScoreboardTeam, Team>() { + return ImmutableSet.copyOf(Iterables.transform((Collection<ScoreboardTeam>) this.board.getPlayerTeams(), new Function<ScoreboardTeam, Team>() { @Override public Team apply(ScoreboardTeam input) { @@ -163,16 +163,16 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard { @Override public Team registerNewTeam(String name) throws IllegalArgumentException { Validate.notNull(name, "Team name cannot be null"); - Validate.isTrue(name.length() <= 16, "Team name '" + name + "' is longer than the limit of 16 characters"); - Validate.isTrue(board.getTeam(name) == null, "Team name '" + name + "' is already in use"); + Validate.isTrue(name.length() <= Short.MAX_VALUE, "Team name '" + name + "' is longer than the limit of 32767 characters"); + Validate.isTrue(board.getPlayerTeam(name) == null, "Team name '" + name + "' is already in use"); - return new CraftTeam(this, board.createTeam(name)); + return new CraftTeam(this, board.addPlayerTeam(name)); } @Override public ImmutableSet<OfflinePlayer> getPlayers() { ImmutableSet.Builder<OfflinePlayer> players = ImmutableSet.builder(); - for (Object playerName : board.getPlayers()) { + for (Object playerName : board.getTrackedPlayers()) { players.add(Bukkit.getOfflinePlayer(playerName.toString())); } return players.build(); @@ -181,7 +181,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard { @Override public ImmutableSet<String> getEntries() { ImmutableSet.Builder<String> entries = ImmutableSet.builder(); - for (Object entry : board.getPlayers()) { + for (Object entry : board.getTrackedPlayers()) { entries.add(entry.toString()); } return entries.build(); @@ -190,7 +190,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard { @Override public void clearSlot(DisplaySlot slot) throws IllegalArgumentException { Validate.notNull(slot, "Slot cannot be null"); - board.setDisplaySlot(CraftScoreboardTranslations.fromBukkitSlot(slot), null); + board.setDisplayObjective(CraftScoreboardTranslations.fromBukkitSlot(slot), null); } // CraftBukkit method diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java index 51942cbde1..c63d763068 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java @@ -74,22 +74,22 @@ public final class CraftScoreboardManager implements ScoreboardManager { // Old objective tracking HashSet<ScoreboardObjective> removed = new HashSet<ScoreboardObjective>(); for (int i = 0; i < 3; ++i) { - ScoreboardObjective scoreboardobjective = oldboard.getObjectiveForSlot(i); + ScoreboardObjective scoreboardobjective = oldboard.getDisplayObjective(i); if (scoreboardobjective != null && !removed.contains(scoreboardobjective)) { - entityplayer.connection.sendPacket(new PacketPlayOutScoreboardObjective(scoreboardobjective, 1)); + entityplayer.connection.send(new PacketPlayOutScoreboardObjective(scoreboardobjective, 1)); removed.add(scoreboardobjective); } } // Old team tracking - Iterator<?> iterator = oldboard.getTeams().iterator(); + Iterator<?> iterator = oldboard.getPlayerTeams().iterator(); while (iterator.hasNext()) { ScoreboardTeam scoreboardteam = (ScoreboardTeam) iterator.next(); - entityplayer.connection.sendPacket(PacketPlayOutScoreboardTeam.a(scoreboardteam)); + entityplayer.connection.send(PacketPlayOutScoreboardTeam.createRemovePacket(scoreboardteam)); } // The above is the reverse of the below method. - server.getPlayerList().sendScoreboard((ScoreboardServer) newboard, player.getHandle()); + server.getPlayerList().updateEntireScoreboard((ScoreboardServer) newboard, player.getHandle()); } // CraftBukkit method @@ -101,7 +101,7 @@ public final class CraftScoreboardManager implements ScoreboardManager { public void getScoreboardScores(IScoreboardCriteria criteria, String name, Consumer<ScoreboardScore> consumer) { for (CraftScoreboard scoreboard : scoreboards) { Scoreboard board = scoreboard.board; - board.getObjectivesForCriteria(criteria, name, (score) -> consumer.accept(score)); + board.forAllObjectives(criteria, name, (score) -> consumer.accept(score)); } } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java index 8dc76e3361..35faa6bf2c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java @@ -16,11 +16,11 @@ final class CraftScoreboardTranslations { private CraftScoreboardTranslations() {} static DisplaySlot toBukkitSlot(int i) { - return SLOTS.inverse().get(Scoreboard.getSlotName(i)); + return SLOTS.inverse().get(Scoreboard.getDisplaySlotName(i)); } static int fromBukkitSlot(DisplaySlot slot) { - return Scoreboard.getSlotForName(SLOTS.get(slot)); + return Scoreboard.getDisplaySlotByName(SLOTS.get(slot)); } static RenderType toBukkitRender(IScoreboardCriteria.EnumScoreboardHealthDisplay display) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java index a213c2e3b2..fa542fdc37 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java @@ -50,7 +50,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { public String getPrefix() throws IllegalStateException { CraftScoreboard scoreboard = checkState(); - return CraftChatMessage.fromComponent(team.getPrefix()); + return CraftChatMessage.fromComponent(team.getPlayerPrefix()); } @Override @@ -59,14 +59,14 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { Validate.isTrue(ChatColor.stripColor(prefix).length() <= 64, "Prefix '" + prefix + "' is longer than the limit of 64 characters"); CraftScoreboard scoreboard = checkState(); - team.setPrefix(CraftChatMessage.fromStringOrNull(prefix)); + team.setPlayerPrefix(CraftChatMessage.fromStringOrNull(prefix)); } @Override public String getSuffix() throws IllegalStateException { CraftScoreboard scoreboard = checkState(); - return CraftChatMessage.fromComponent(team.getSuffix()); + return CraftChatMessage.fromComponent(team.getPlayerSuffix()); } @Override @@ -75,7 +75,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { Validate.isTrue(ChatColor.stripColor(suffix).length() <= 64, "Suffix '" + suffix + "' is longer than the limit of 64 characters"); CraftScoreboard scoreboard = checkState(); - team.setSuffix(CraftChatMessage.fromStringOrNull(suffix)); + team.setPlayerSuffix(CraftChatMessage.fromStringOrNull(suffix)); } @Override @@ -97,7 +97,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { public boolean allowFriendlyFire() throws IllegalStateException { CraftScoreboard scoreboard = checkState(); - return team.allowFriendlyFire(); + return team.isAllowFriendlyFire(); } @Override @@ -118,7 +118,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { public void setCanSeeFriendlyInvisibles(boolean enabled) throws IllegalStateException { CraftScoreboard scoreboard = checkState(); - team.setCanSeeFriendlyInvisibles(enabled); + team.setSeeFriendlyInvisibles(enabled); } @Override @@ -140,7 +140,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { CraftScoreboard scoreboard = checkState(); ImmutableSet.Builder<OfflinePlayer> players = ImmutableSet.builder(); - for (String playerName : team.getPlayerNameSet()) { + for (String playerName : team.getPlayers()) { players.add(Bukkit.getOfflinePlayer(playerName)); } return players.build(); @@ -151,7 +151,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { CraftScoreboard scoreboard = checkState(); ImmutableSet.Builder<String> entries = ImmutableSet.builder(); - for (String playerName : team.getPlayerNameSet()) { + for (String playerName : team.getPlayers()) { entries.add(playerName); } return entries.build(); @@ -161,7 +161,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { public int getSize() throws IllegalStateException { CraftScoreboard scoreboard = checkState(); - return team.getPlayerNameSet().size(); + return team.getPlayers().size(); } @Override @@ -189,7 +189,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { Validate.notNull(entry, "Entry cannot be null"); CraftScoreboard scoreboard = checkState(); - if (!team.getPlayerNameSet().contains(entry)) { + if (!team.getPlayers().contains(entry)) { return false; } @@ -209,14 +209,14 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { CraftScoreboard scoreboard = checkState(); - return team.getPlayerNameSet().contains(entry); + return team.getPlayers().contains(entry); } @Override public void unregister() throws IllegalStateException { CraftScoreboard scoreboard = checkState(); - scoreboard.board.removeTeam(team); + scoreboard.board.removePlayerTeam(team); } @Override @@ -286,7 +286,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { @Override CraftScoreboard checkState() throws IllegalStateException { - if (getScoreboard().board.getTeam(team.getName()) == null) { + if (getScoreboard().board.getPlayerTeam(team.getName()) == null) { throw new IllegalStateException("Unregistered scoreboard component"); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftPalette.java b/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftPalette.java index 4402e611ab..6dd3153242 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftPalette.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftPalette.java @@ -18,7 +18,7 @@ public class CraftPalette implements Palette { @Override public List<BlockState> getBlocks() { List<BlockState> blocks = new ArrayList<>(); - for (DefinedStructure.BlockInfo blockInfo : palette.a()) { + for (DefinedStructure.BlockInfo blockInfo : palette.blocks()) { blocks.add(CraftBlockStates.getBlockState(blockInfo.pos, blockInfo.state, blockInfo.nbt)); } return blocks; @@ -26,6 +26,6 @@ public class CraftPalette implements Palette { @Override public int getBlockCount() { - return palette.a().size(); + return palette.blocks().size(); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructure.java b/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructure.java index 21ca4d7b04..7f7f7c541c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructure.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructure.java @@ -55,15 +55,15 @@ public class CraftStructure implements Structure { } DefinedStructureInfo definedstructureinfo = new DefinedStructureInfo() - .a(EnumBlockMirror.valueOf(mirror.name())) // PAIL rename setMirror - .a(EnumBlockRotation.valueOf(structureRotation.name())) // PAIL rename setRotation - .a(!includeEntities) // PAIL rename setIgnoreEntities - .a(new DefinedStructureProcessorRotation(integrity)) // PAIL rename addStructureProcessor - .a(random); // PAIL rename setRandom + .setMirror(EnumBlockMirror.valueOf(mirror.name())) + .setRotation(EnumBlockRotation.valueOf(structureRotation.name())) + .setIgnoreEntities(!includeEntities) + .addProcessor(new DefinedStructureProcessorRotation(integrity)) + .setRandom(random); definedstructureinfo.palette = palette; BlockPosition blockPosition = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - structure.a(((CraftRegionAccessor) regionAccessor).getHandle(), blockPosition, blockPosition, definedstructureinfo, random, 2); // PAIL rename placeInWorld + structure.placeInWorld(((CraftRegionAccessor) regionAccessor).getHandle(), blockPosition, blockPosition, definedstructureinfo, random, 2); } @Override @@ -88,20 +88,20 @@ public class CraftStructure implements Structure { throw new IllegalArgumentException("Size must be at least 1x1x1 but was " + size.getBlockX() + "x" + size.getBlockY() + "x" + size.getBlockZ()); } - structure.a(((CraftWorld) world).getHandle(), new BlockPosition(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ()), new BlockPosition(size.getBlockX(), size.getBlockY(), size.getBlockZ()), includeEntities, Blocks.STRUCTURE_VOID); // PAIL rename fillFromWorld + structure.fillFromWorld(((CraftWorld) world).getHandle(), new BlockPosition(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ()), new BlockPosition(size.getBlockX(), size.getBlockY(), size.getBlockZ()), includeEntities, Blocks.STRUCTURE_VOID); } @Override public BlockVector getSize() { - return new BlockVector(structure.a().getX(), structure.a().getY(), structure.a().getZ()); + return new BlockVector(structure.getSize().getX(), structure.getSize().getY(), structure.getSize().getZ()); } @Override public List<Entity> getEntities() { List<Entity> entities = new ArrayList<>(); for (DefinedStructure.EntityInfo entity : structure.entityInfoList) { - EntityTypes.a(entity.nbt, ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle()).ifPresent(dummyEntity -> { - dummyEntity.setPosition(entity.pos.x, entity.pos.y, entity.pos.z); + EntityTypes.create(entity.nbt, ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle()).ifPresent(dummyEntity -> { + dummyEntity.setPos(entity.pos.x, entity.pos.y, entity.pos.z); entities.add(dummyEntity.getBukkitEntity()); }); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructureManager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructureManager.java index 7748f80d32..fe5da8a81b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructureManager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructureManager.java @@ -59,8 +59,8 @@ public class CraftStructureManager implements StructureManager { Optional<DefinedStructure> structure = structureManager.structureRepository.get(minecraftKey); structure = structure == null ? Optional.empty() : structure; - structure = structure.isPresent() ? structure : structureManager.f(minecraftKey); - structure = structure.isPresent() ? structure : structureManager.e(minecraftKey); + structure = structure.isPresent() ? structure : structureManager.loadFromGenerated(minecraftKey); + structure = structure.isPresent() ? structure : structureManager.loadFromResource(minecraftKey); if (register) { structureManager.structureRepository.put(minecraftKey, structure); @@ -78,7 +78,7 @@ public class CraftStructureManager implements StructureManager { public void saveStructure(NamespacedKey structureKey) { MinecraftKey minecraftKey = createAndValidateMinecraftStructureKey(structureKey); - structureManager.c(minecraftKey); // PAIL rename save + structureManager.save(minecraftKey); } @Override @@ -120,14 +120,14 @@ public class CraftStructureManager implements StructureManager { if (unregister) { structureManager.structureRepository.remove(key); } - Path path = structureManager.b(key, ".nbt"); + Path path = structureManager.createAndValidatePathToStructure(key, ".nbt"); Files.deleteIfExists(path); } @Override public File getStructureFile(NamespacedKey structureKey) { MinecraftKey minecraftKey = createAndValidateMinecraftStructureKey(structureKey); - return structureManager.b(minecraftKey, ".nbt").toFile(); + return structureManager.createAndValidatePathToStructure(minecraftKey, ".nbt").toFile(); } @Override @@ -142,7 +142,7 @@ public class CraftStructureManager implements StructureManager { public Structure loadStructure(InputStream inputStream) throws IOException { Validate.notNull(inputStream, "inputStream cannot be null"); - return new CraftStructure(structureManager.a(inputStream)); + return new CraftStructure(structureManager.readStructure(inputStream)); } @Override @@ -159,8 +159,8 @@ public class CraftStructureManager implements StructureManager { Validate.notNull(outputStream, "outputStream cannot be null"); Validate.notNull(structure, "structure cannot be null"); - NBTTagCompound nbttagcompound = ((CraftStructure) structure).getHandle().a(new NBTTagCompound()); - NBTCompressedStreamTools.a(nbttagcompound, outputStream); + NBTTagCompound nbttagcompound = ((CraftStructure) structure).getHandle().save(new NBTTagCompound()); + NBTCompressedStreamTools.writeCompressed(nbttagcompound, outputStream); } @Override @@ -172,7 +172,7 @@ public class CraftStructureManager implements StructureManager { Validate.notNull(structureKey, "structureKey cannot be null"); MinecraftKey minecraftkey = CraftNamespacedKey.toMinecraft(structureKey); - if (minecraftkey.getKey().contains("//")) { + if (minecraftkey.getPath().contains("//")) { throw new IllegalArgumentException("Resource key for Structures can not contain \"//\""); } return minecraftkey; @@ -180,6 +180,6 @@ public class CraftStructureManager implements StructureManager { @Override public Structure copy(Structure structure) { - return new CraftStructure(structureManager.a(((CraftStructure) structure).getHandle().a(new NBTTagCompound()))); + return new CraftStructure(structureManager.readStructure(((CraftStructure) structure).getHandle().save(new NBTTagCompound()))); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java index e831b9b429..77de68931e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java @@ -17,11 +17,11 @@ public class CraftBlockTag extends CraftTag<Block, Material> { @Override public boolean isTagged(Material item) { - return getHandle().isTagged(CraftMagicNumbers.getBlock(item)); + return getHandle().contains(CraftMagicNumbers.getBlock(item)); } @Override public Set<Material> getValues() { - return Collections.unmodifiableSet(getHandle().getTagged().stream().map((block) -> CraftMagicNumbers.getMaterial(block)).collect(Collectors.toSet())); + return Collections.unmodifiableSet(getHandle().getValues().stream().map((block) -> CraftMagicNumbers.getMaterial(block)).collect(Collectors.toSet())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java index c68fb2d90b..9c1c8f555d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java @@ -19,11 +19,11 @@ public class CraftEntityTag extends CraftTag<EntityTypes<?>, EntityType> { @Override public boolean isTagged(EntityType entity) { - return getHandle().isTagged(IRegistry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(entity.getKey()))); + return getHandle().contains(IRegistry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(entity.getKey()))); } @Override public Set<EntityType> getValues() { - return Collections.unmodifiableSet(getHandle().getTagged().stream().map((nms) -> Registry.ENTITY_TYPE.get(CraftNamespacedKey.fromMinecraft(EntityTypes.getName(nms)))).collect(Collectors.toSet())); + return Collections.unmodifiableSet(getHandle().getValues().stream().map((nms) -> Registry.ENTITY_TYPE.get(CraftNamespacedKey.fromMinecraft(EntityTypes.getKey(nms)))).collect(Collectors.toSet())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftFluidTag.java b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftFluidTag.java index 9d4dbb56e0..6dd5f3736e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftFluidTag.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftFluidTag.java @@ -17,11 +17,11 @@ public class CraftFluidTag extends CraftTag<FluidType, Fluid> { @Override public boolean isTagged(Fluid fluid) { - return getHandle().isTagged(CraftMagicNumbers.getFluid(fluid)); + return getHandle().contains(CraftMagicNumbers.getFluid(fluid)); } @Override public Set<Fluid> getValues() { - return Collections.unmodifiableSet(getHandle().getTagged().stream().map(CraftMagicNumbers::getFluid).collect(Collectors.toSet())); + return Collections.unmodifiableSet(getHandle().getValues().stream().map(CraftMagicNumbers::getFluid).collect(Collectors.toSet())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java index fdcf7c82b6..11e9a103ca 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java @@ -17,11 +17,11 @@ public class CraftItemTag extends CraftTag<Item, Material> { @Override public boolean isTagged(Material item) { - return getHandle().isTagged(CraftMagicNumbers.getItem(item)); + return getHandle().contains(CraftMagicNumbers.getItem(item)); } @Override public Set<Material> getValues() { - return Collections.unmodifiableSet(getHandle().getTagged().stream().map((item) -> CraftMagicNumbers.getMaterial(item)).collect(Collectors.toSet())); + return Collections.unmodifiableSet(getHandle().getValues().stream().map((item) -> CraftMagicNumbers.getMaterial(item)).collect(Collectors.toSet())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftTag.java b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftTag.java index dda83ef77a..68a4bdb85b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftTag.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftTag.java @@ -21,7 +21,7 @@ public abstract class CraftTag<N, B extends Keyed> implements Tag<B> { protected net.minecraft.tags.Tag<N> getHandle() { if (handle == null) { - handle = registry.b(tag); + handle = registry.getTagOrEmpty(tag); } return handle; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java index 25c531ceb8..f61bec1fc9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java @@ -36,36 +36,36 @@ public class BlockStateListPopulator extends DummyGeneratorAccess { } @Override - public IBlockData getType(BlockPosition bp) { + public IBlockData getBlockState(BlockPosition bp) { IBlockData blockData = dataMap.get(bp); - return (blockData != null) ? blockData : world.getType(bp); + return (blockData != null) ? blockData : world.getBlockState(bp); } @Override - public Fluid getFluid(BlockPosition bp) { + public Fluid getFluidState(BlockPosition bp) { IBlockData blockData = dataMap.get(bp); - return (blockData != null) ? blockData.getFluid() : world.getFluid(bp); + return (blockData != null) ? blockData.getFluidState() : world.getFluidState(bp); } @Override - public TileEntity getTileEntity(BlockPosition blockposition) { + public TileEntity getBlockEntity(BlockPosition blockposition) { // The contains is important to check for null values if (entityMap.containsKey(blockposition)) { return entityMap.get(blockposition); } - return world.getTileEntity(blockposition); + return world.getBlockEntity(blockposition); } @Override - public boolean setTypeAndData(BlockPosition position, IBlockData data, int flag) { - position = position.immutableCopy(); + public boolean setBlock(BlockPosition position, IBlockData data, int flag) { + position = position.immutable(); // remove first to keep insertion order list.remove(position); dataMap.put(position, data); - if (data.isTileEntity()) { - entityMap.put(position, ((ITileEntity) data.getBlock()).createTile(position, data)); + if (data.hasBlockEntity()) { + entityMap.put(position, ((ITileEntity) data.getBlock()).newBlockEntity(position, data)); } else { entityMap.put(position, null); } @@ -122,12 +122,12 @@ public class BlockStateListPopulator extends DummyGeneratorAccess { } @Override - public boolean a(BlockPosition blockposition, Predicate<IBlockData> predicate) { - return predicate.test(getType(blockposition)); + public boolean isStateAtPosition(BlockPosition blockposition, Predicate<IBlockData> predicate) { + return predicate.test(getBlockState(blockposition)); } @Override - public DimensionManager getDimensionManager() { - return world.getDimensionManager(); + public DimensionManager dimensionType() { + return world.dimensionType(); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java index 8617e3b95d..03a3e4c3e4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java @@ -146,6 +146,39 @@ public class Commodore case "NETHER": super.visitFieldInsn( opcode, owner, "NETHER_WASTES", desc ); return; + case "TALL_BIRCH_FOREST": + super.visitFieldInsn( opcode, owner, "OLD_GROWTH_BIRCH_FOREST", desc ); + return; + case "GIANT_TREE_TAIGA": + super.visitFieldInsn( opcode, owner, "OLD_GROWTH_PINE_TAIGA", desc ); + return; + case "GIANT_SPRUCE_TAIGA": + super.visitFieldInsn( opcode, owner, "OLD_GROWTH_SPRUCE_TAIGA", desc ); + return; + case "SNOWY_TUNDRA": + super.visitFieldInsn( opcode, owner, "SNOWY_PLAINS", desc ); + return; + case "JUNGLE_EDGE": + super.visitFieldInsn( opcode, owner, "SPARSE_JUNGLE", desc ); + return; + case "STONE_SHORE": + super.visitFieldInsn( opcode, owner, "STONY_SHORE", desc ); + return; + case "MOUNTAINS": + super.visitFieldInsn( opcode, owner, "WINDSWEPT_HILLS", desc ); + return; + case "WOODED_MOUNTAINS": + super.visitFieldInsn( opcode, owner, "WINDSWEPT_FOREST", desc ); + return; + case "GRAVELLY_MOUNTAINS": + super.visitFieldInsn( opcode, owner, "WINDSWEPT_GRAVELLY_HILLS", desc ); + return; + case "SHATTERED_SAVANNA": + super.visitFieldInsn( opcode, owner, "WINDSWEPT_SAVANNA", desc ); + return; + case "WOODED_BADLANDS_PLATEAU": + super.visitFieldInsn( opcode, owner, "WOODED_BADLANDS", desc ); + return; } } @@ -358,6 +391,18 @@ public class Commodore super.visitMethodInsn( opcode, owner, name, desc, itf ); } + + @Override + public void visitLdcInsn(Object value) + { + if ( value instanceof String && ( (String) value ).equals( "com.mysql.jdbc.Driver" ) ) + { + super.visitLdcInsn( "com.mysql.cj.jdbc.Driver" ); + return; + } + + super.visitLdcInsn( value ); + } }; } }, 0 ); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java index 424a3e7e7c..1d917c5eed 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java @@ -46,7 +46,7 @@ public final class CraftChatMessage { // Separate pattern with no group 3, new lines are part of previous string private static final Pattern INCREMENTAL_PATTERN_KEEP_NEWLINES = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-orx])|((?:(?:https?):\\/\\/)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " ]|$))))", Pattern.CASE_INSENSITIVE); // ChatColor.b does not explicitly reset, its more of empty - private static final ChatModifier RESET = ChatModifier.EMPTY.setBold(false).setItalic(false).setUnderline(false).setStrikethrough(false).setRandom(false); + private static final ChatModifier RESET = ChatModifier.EMPTY.withBold(false).withItalic(false).withUnderlined(false).withStrikethrough(false).withObfuscated(false); private final List<IChatBaseComponent> list = new ArrayList<IChatBaseComponent>(); private IChatMutableComponent currentChatComponent = new ChatComponentText(""); @@ -88,31 +88,31 @@ public final class CraftChatMessage { hex.append(c); if (hex.length() == 7) { - modifier = RESET.setColor(ChatHexColor.a(hex.toString())); + modifier = RESET.withColor(ChatHexColor.parseColor(hex.toString())); hex = null; } } else if (format.isFormat() && format != EnumChatFormat.RESET) { switch (format) { case BOLD: - modifier = modifier.setBold(Boolean.TRUE); + modifier = modifier.withBold(Boolean.TRUE); break; case ITALIC: - modifier = modifier.setItalic(Boolean.TRUE); + modifier = modifier.withItalic(Boolean.TRUE); break; case STRIKETHROUGH: - modifier = modifier.setStrikethrough(Boolean.TRUE); + modifier = modifier.withStrikethrough(Boolean.TRUE); break; case UNDERLINE: - modifier = modifier.setUnderline(Boolean.TRUE); + modifier = modifier.withUnderlined(Boolean.TRUE); break; case OBFUSCATED: - modifier = modifier.setRandom(Boolean.TRUE); + modifier = modifier.withObfuscated(Boolean.TRUE); break; default: throw new AssertionError("Unexpected message format"); } } else { // Color resets formatting - modifier = RESET.setColor(format); + modifier = RESET.withColor(format); } needsAdd = true; break; @@ -123,9 +123,9 @@ public final class CraftChatMessage { if (!(match.startsWith("http://") || match.startsWith("https://"))) { match = "http://" + match; } - modifier = modifier.setChatClickable(new ChatClickable(EnumClickAction.OPEN_URL, match)); + modifier = modifier.withClickEvent(new ChatClickable(EnumClickAction.OPEN_URL, match)); appendNewComponent(matcher.end(groupId)); - modifier = modifier.setChatClickable((ChatClickable) null); + modifier = modifier.withClickEvent((ChatClickable) null); } break; case 3: @@ -146,13 +146,13 @@ public final class CraftChatMessage { } private void appendNewComponent(int index) { - IChatBaseComponent addition = new ChatComponentText(message.substring(currentIndex, index)).setChatModifier(modifier); + IChatBaseComponent addition = new ChatComponentText(message.substring(currentIndex, index)).setStyle(modifier); currentIndex = index; if (currentChatComponent == null) { currentChatComponent = new ChatComponentText(""); list.add(currentChatComponent); } - currentChatComponent.addSibling(addition); + currentChatComponent.append(addition); } private IChatBaseComponent[] getOutput() { @@ -181,7 +181,7 @@ public final class CraftChatMessage { } public static String toJSON(IChatBaseComponent component) { - return IChatBaseComponent.ChatSerializer.a(component); + return IChatBaseComponent.ChatSerializer.toJson(component); } public static String toJSONOrNull(IChatBaseComponent component) { @@ -192,7 +192,7 @@ public final class CraftChatMessage { public static IChatBaseComponent fromJSON(String jsonMessage) throws JsonParseException { // Note: This also parses plain Strings to text components. // Note: An empty message (empty, or only consisting of whitespace) results in null rather than a parse exception. - return IChatBaseComponent.ChatSerializer.a(jsonMessage); + return IChatBaseComponent.ChatSerializer.fromJson(jsonMessage); } public static IChatBaseComponent fromJSONOrNull(String jsonMessage) { @@ -294,15 +294,15 @@ public final class CraftChatMessage { boolean hadFormat = false; for (IChatBaseComponent c : component) { - ChatModifier modi = c.getChatModifier(); + ChatModifier modi = c.getStyle(); ChatHexColor color = modi.getColor(); - if (!c.getText().isEmpty() || color != null) { + if (!c.getContents().isEmpty() || color != null) { if (color != null) { if (color.format != null) { out.append(color.format); } else { out.append(ChatColor.COLOR_CHAR).append("x"); - for (char magic : color.b().substring(1).toCharArray()) { + for (char magic : color.serialize().substring(1).toCharArray()) { out.append(ChatColor.COLOR_CHAR).append(magic); } } @@ -328,11 +328,11 @@ public final class CraftChatMessage { out.append(EnumChatFormat.STRIKETHROUGH); hadFormat = true; } - if (modi.isRandom()) { + if (modi.isObfuscated()) { out.append(EnumChatFormat.OBFUSCATED); hadFormat = true; } - c.b((x) -> { + c.visitSelf((x) -> { out.append(x); return Optional.empty(); }); @@ -348,11 +348,11 @@ public final class CraftChatMessage { private static IChatBaseComponent fixComponent(IChatBaseComponent component, Matcher matcher) { if (component instanceof ChatComponentText) { ChatComponentText text = ((ChatComponentText) component); - String msg = text.getText(); + String msg = text.getContents(); if (matcher.reset(msg).find()) { matcher.reset(); - ChatModifier modifier = text.getChatModifier(); + ChatModifier modifier = text.getStyle(); List<IChatBaseComponent> extras = new ArrayList<IChatBaseComponent>(); List<IChatBaseComponent> extrasOld = new ArrayList<IChatBaseComponent>(text.getSiblings()); component = text = new ChatComponentText(""); @@ -366,24 +366,24 @@ public final class CraftChatMessage { } ChatComponentText prev = new ChatComponentText(msg.substring(pos, matcher.start())); - prev.setChatModifier(modifier); + prev.setStyle(modifier); extras.add(prev); ChatComponentText link = new ChatComponentText(matcher.group()); - ChatModifier linkModi = modifier.setChatClickable(new ChatClickable(EnumClickAction.OPEN_URL, match)); - link.setChatModifier(linkModi); + ChatModifier linkModi = modifier.withClickEvent(new ChatClickable(EnumClickAction.OPEN_URL, match)); + link.setStyle(linkModi); extras.add(link); pos = matcher.end(); } ChatComponentText prev = new ChatComponentText(msg.substring(pos)); - prev.setChatModifier(modifier); + prev.setStyle(modifier); extras.add(prev); extras.addAll(extrasOld); for (IChatBaseComponent c : extras) { - text.addSibling(c); + text.append(c); } } } @@ -391,7 +391,7 @@ public final class CraftChatMessage { List<IChatBaseComponent> extras = component.getSiblings(); for (int i = 0; i < extras.size(); i++) { IChatBaseComponent comp = extras.get(i); - if (comp.getChatModifier() != null && comp.getChatModifier().getClickEvent() == null) { + if (comp.getStyle() != null && comp.getStyle().getClickEvent() == null) { extras.set(i, fixComponent(comp, matcher)); } } @@ -402,7 +402,7 @@ public final class CraftChatMessage { Object comp = subs[i]; if (comp instanceof IChatBaseComponent) { IChatBaseComponent c = (IChatBaseComponent) comp; - if (c.getChatModifier() != null && c.getChatModifier().getClickEvent() == null) { + if (c.getStyle() != null && c.getStyle().getClickEvent() == null) { subs[i] = fixComponent(c, matcher); } } else if (comp instanceof String && matcher.reset((String) comp).find()) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftDamageSource.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftDamageSource.java index 4d88de6dc9..cc2ae9421c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftDamageSource.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftDamageSource.java @@ -8,8 +8,8 @@ public final class CraftDamageSource extends DamageSource { CraftDamageSource newSource = new CraftDamageSource(original.msgId); // Check ignoresArmor - if (original.ignoresArmor()) { - newSource.setIgnoreArmor(); + if (original.isBypassArmor()) { + newSource.bypassArmor(); } // Check magic diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftDimensionUtil.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftDimensionUtil.java index f8a2bf6350..13fb568011 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftDimensionUtil.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftDimensionUtil.java @@ -19,6 +19,6 @@ public class CraftDimensionUtil { return World.END; } - return world.getDimensionKey(); + return world.dimension(); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 0a50db0876..46e1de8bb8 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -93,11 +93,11 @@ public final class CraftMagicNumbers implements UnsafeValues { static { for (Block block : IRegistry.BLOCK) { - BLOCK_MATERIAL.put(block, Material.getMaterial(IRegistry.BLOCK.getKey(block).getKey().toUpperCase(Locale.ROOT))); + BLOCK_MATERIAL.put(block, Material.getMaterial(IRegistry.BLOCK.getKey(block).getPath().toUpperCase(Locale.ROOT))); } for (Item item : IRegistry.ITEM) { - ITEM_MATERIAL.put(item, Material.getMaterial(IRegistry.ITEM.getKey(item).getKey().toUpperCase(Locale.ROOT))); + ITEM_MATERIAL.put(item, Material.getMaterial(IRegistry.ITEM.getKey(item).getPath().toUpperCase(Locale.ROOT))); } for (FluidType fluid : IRegistry.FLUID) { @@ -198,11 +198,11 @@ public final class CraftMagicNumbers implements UnsafeValues { return Material.getMaterial(material); } - Dynamic<NBTBase> name = new Dynamic<>(DynamicOpsNBT.INSTANCE, NBTTagString.a("minecraft:" + material.toLowerCase(Locale.ROOT))); - Dynamic<NBTBase> converted = DataConverterRegistry.a().update(DataConverterTypes.ITEM_NAME, name, version, this.getDataVersion()); + Dynamic<NBTBase> name = new Dynamic<>(DynamicOpsNBT.INSTANCE, NBTTagString.valueOf("minecraft:" + material.toLowerCase(Locale.ROOT))); + Dynamic<NBTBase> converted = DataConverterRegistry.getDataFixer().update(DataConverterTypes.ITEM_NAME, name, version, this.getDataVersion()); if (name.equals(converted)) { - converted = DataConverterRegistry.a().update(DataConverterTypes.BLOCK_NAME, name, version, this.getDataVersion()); + converted = DataConverterRegistry.getDataFixer().update(DataConverterTypes.BLOCK_NAME, name, version, this.getDataVersion()); } return Material.matchMaterial(converted.asString("")); @@ -224,12 +224,12 @@ public final class CraftMagicNumbers implements UnsafeValues { * @return string */ public String getMappingsVersion() { - return "f0e3dfc7390de285a4693518dd5bd126"; + return "f926f0531f0874c1b0bcb6f1f7655751"; } @Override public int getDataVersion() { - return SharedConstants.getGameVersion().getWorldVersion(); + return SharedConstants.getCurrentVersion().getWorldVersion(); } @Override @@ -237,7 +237,7 @@ public final class CraftMagicNumbers implements UnsafeValues { net.minecraft.world.item.ItemStack nmsStack = CraftItemStack.asNMSCopy(stack); try { - nmsStack.setTag((NBTTagCompound) MojangsonParser.parse(arguments)); + nmsStack.setTag((NBTTagCompound) MojangsonParser.parseTag(arguments)); } catch (CommandSyntaxException ex) { Logger.getLogger(CraftMagicNumbers.class.getName()).log(Level.SEVERE, null, ex); } @@ -248,7 +248,7 @@ public final class CraftMagicNumbers implements UnsafeValues { } private static File getBukkitDataPackFolder() { - return new File(MinecraftServer.getServer().a(SavedFile.DATAPACK_DIR).toFile(), "bukkit"); + return new File(MinecraftServer.getServer().getWorldPath(SavedFile.DATAPACK_DIR).toFile(), "bukkit"); } @Override @@ -259,10 +259,10 @@ public final class CraftMagicNumbers implements UnsafeValues { MinecraftKey minecraftkey = CraftNamespacedKey.toMinecraft(key); JsonElement jsonelement = AdvancementDataWorld.GSON.fromJson(advancement, JsonElement.class); - JsonObject jsonobject = ChatDeserializer.m(jsonelement, "advancement"); - net.minecraft.advancements.Advancement.SerializedAdvancement nms = net.minecraft.advancements.Advancement.SerializedAdvancement.a(jsonobject, new LootDeserializationContext(minecraftkey, MinecraftServer.getServer().getLootPredicateManager())); + JsonObject jsonobject = ChatDeserializer.convertToJsonObject(jsonelement, "advancement"); + net.minecraft.advancements.Advancement.SerializedAdvancement nms = net.minecraft.advancements.Advancement.SerializedAdvancement.fromJson(jsonobject, new LootDeserializationContext(minecraftkey, MinecraftServer.getServer().getPredicateManager())); if (nms != null) { - MinecraftServer.getServer().getAdvancementData().advancements.a(Maps.newHashMap(Collections.singletonMap(minecraftkey, nms))); + MinecraftServer.getServer().getAdvancements().advancements.add(Maps.newHashMap(Collections.singletonMap(minecraftkey, nms))); Advancement bukkit = Bukkit.getAdvancement(key); if (bukkit != null) { @@ -275,7 +275,7 @@ public final class CraftMagicNumbers implements UnsafeValues { Bukkit.getLogger().log(Level.SEVERE, "Error saving advancement " + key, ex); } - MinecraftServer.getServer().getPlayerList().reload(); + MinecraftServer.getServer().getPlayerList().reloadResources(); return bukkit; } @@ -290,7 +290,7 @@ public final class CraftMagicNumbers implements UnsafeValues { return file.delete(); } - private static final List<String> SUPPORTED_API = Arrays.asList("1.13", "1.14", "1.15", "1.16", "1.17"); + private static final List<String> SUPPORTED_API = Arrays.asList("1.13", "1.14", "1.15", "1.16", "1.17", "1.18"); @Override public void checkSupported(PluginDescriptionFile pdf) throws InvalidPluginException { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java index 1c5d62abcb..dd78d2857b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java @@ -26,7 +26,7 @@ public class CraftNBTTagConfigSerializer { public static Object serialize(NBTBase base) { if (base instanceof NBTTagCompound) { Map<String, Object> innerMap = new HashMap<>(); - for (String key : ((NBTTagCompound) base).getKeys()) { + for (String key : ((NBTTagCompound) base).getAllKeys()) { innerMap.put(key, serialize(((NBTTagCompound) base).get(key))); } @@ -39,7 +39,7 @@ public class CraftNBTTagConfigSerializer { return baseList; } else if (base instanceof NBTTagString) { - return base.asString(); + return base.getAsString(); } else if (base instanceof NBTTagInt) { // No need to check for doubles, those are covered by the double itself return base.toString() + "i"; } @@ -51,7 +51,7 @@ public class CraftNBTTagConfigSerializer { if (object instanceof Map) { NBTTagCompound compound = new NBTTagCompound(); for (Map.Entry<String, Object> entry : ((Map<String, Object>) object).entrySet()) { - compound.set(entry.getKey(), deserialize(entry.getValue())); + compound.put(entry.getKey(), deserialize(entry.getValue())); } return compound; @@ -72,21 +72,21 @@ public class CraftNBTTagConfigSerializer { if (ARRAY.matcher(string).matches()) { try { - return new MojangsonParser(new StringReader(string)).parseArray(); + return new MojangsonParser(new StringReader(string)).readArrayTag(); } catch (CommandSyntaxException e) { throw new RuntimeException("Could not deserialize found list ", e); } } else if (INTEGER.matcher(string).matches()) { //Read integers on our own - return NBTTagInt.a(Integer.parseInt(string.substring(0, string.length() - 1))); + return NBTTagInt.valueOf(Integer.parseInt(string.substring(0, string.length() - 1))); } else if (DOUBLE.matcher(string).matches()) { - return NBTTagDouble.a(Double.parseDouble(string.substring(0, string.length() - 1))); + return NBTTagDouble.valueOf(Double.parseDouble(string.substring(0, string.length() - 1))); } else { - NBTBase nbtBase = MOJANGSON_PARSER.parseLiteral(string); + NBTBase nbtBase = MOJANGSON_PARSER.type(string); if (nbtBase instanceof NBTTagInt) { // If this returns an integer, it did not use our method from above - return NBTTagString.a(nbtBase.asString()); // It then is a string that was falsely read as an int + return NBTTagString.valueOf(nbtBase.getAsString()); // It then is a string that was falsely read as an int } else if (nbtBase instanceof NBTTagDouble) { - return NBTTagString.a(String.valueOf(((NBTTagDouble) nbtBase).asDouble())); // Doubles add "d" at the end + return NBTTagString.valueOf(String.valueOf(((NBTTagDouble) nbtBase).getAsDouble())); // Doubles add "d" at the end } else { return nbtBase; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java index 38e04819df..82eb945736 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java @@ -12,7 +12,7 @@ public final class CraftNamespacedKey { if (string == null || string.isEmpty()) { return null; } - MinecraftKey minecraft = MinecraftKey.a(string); + MinecraftKey minecraft = MinecraftKey.tryParse(string); return (minecraft == null) ? null : fromMinecraft(minecraft); } @@ -21,7 +21,7 @@ public final class CraftNamespacedKey { } public static NamespacedKey fromMinecraft(MinecraftKey minecraft) { - return new NamespacedKey(minecraft.getNamespace(), minecraft.getKey()); + return new NamespacedKey(minecraft.getNamespace(), minecraft.getPath()); } public static MinecraftKey toMinecraft(NamespacedKey key) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftRayTraceResult.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftRayTraceResult.java index 10b05918ef..409d78390e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftRayTraceResult.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftRayTraceResult.java @@ -21,7 +21,7 @@ public final class CraftRayTraceResult { public static RayTraceResult fromNMS(World world, MovingObjectPosition nmsHitResult) { if (nmsHitResult == null || nmsHitResult.getType() == EnumMovingObjectType.MISS) return null; - Vec3D nmsHitPos = nmsHitResult.getPos(); + Vec3D nmsHitPos = nmsHitResult.getLocation(); Vector hitPosition = new Vector(nmsHitPos.x, nmsHitPos.y, nmsHitPos.z); BlockFace hitBlockFace = null; @@ -35,7 +35,7 @@ public final class CraftRayTraceResult { if (nmsHitResult.getType() == EnumMovingObjectType.BLOCK) { MovingObjectPositionBlock blockHitResult = (MovingObjectPositionBlock) nmsHitResult; hitBlockFace = CraftBlock.notchToBlockFace(blockHitResult.getDirection()); - nmsBlockPos = blockHitResult.getBlockPosition(); + nmsBlockPos = blockHitResult.getBlockPos(); } if (nmsBlockPos != null && world != null) { hitBlock = world.getBlockAt(nmsBlockPos.getX(), nmsBlockPos.getY(), nmsBlockPos.getZ()); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftVoxelShape.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftVoxelShape.java index cef9490dda..641e1a44c3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftVoxelShape.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftVoxelShape.java @@ -18,7 +18,7 @@ public final class CraftVoxelShape implements org.bukkit.util.VoxelShape { @Override public Collection<BoundingBox> getBoundingBoxes() { - List<AxisAlignedBB> boxes = shape.toList(); + List<AxisAlignedBB> boxes = shape.toAabbs(); List<BoundingBox> craftBoxes = new ArrayList<>(boxes.size()); for (AxisAlignedBB aabb : boxes) { craftBoxes.add(new BoundingBox(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ)); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java index 4da1c84865..899aa8e5ad 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java @@ -3,7 +3,6 @@ package org.bukkit.craftbukkit.util; import java.util.List; import java.util.Random; import java.util.function.Predicate; -import java.util.stream.Stream; import net.minecraft.core.BlockPosition; import net.minecraft.core.EnumDirection; import net.minecraft.core.IRegistryCustom; @@ -17,8 +16,6 @@ import net.minecraft.world.DifficultyDamageScaler; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.level.GeneratorAccessSeed; -import net.minecraft.world.level.TickList; -import net.minecraft.world.level.TickListEmpty; import net.minecraft.world.level.biome.BiomeBase; import net.minecraft.world.level.biome.BiomeManager; import net.minecraft.world.level.block.Block; @@ -41,6 +38,8 @@ import net.minecraft.world.level.material.FluidType; import net.minecraft.world.level.material.FluidTypes; import net.minecraft.world.level.storage.WorldData; import net.minecraft.world.phys.AxisAlignedBB; +import net.minecraft.world.ticks.LevelTickAccess; +import net.minecraft.world.ticks.TickListEmpty; public class DummyGeneratorAccess implements GeneratorAccessSeed { @@ -50,32 +49,52 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed { } @Override - public TickList<Block> getBlockTickList() { - return TickListEmpty.b(); - } - - @Override - public TickList<FluidType> getFluidTickList() { - return TickListEmpty.b(); - } - - @Override - public WorldData getWorldData() { + public long getSeed() { throw new UnsupportedOperationException("Not supported yet."); } @Override - public DifficultyDamageScaler getDamageScaler(BlockPosition blockposition) { + public List<? extends StructureStart<?>> startsForFeature(SectionPosition sp, StructureGenerator<?> sg) { throw new UnsupportedOperationException("Not supported yet."); } @Override - public MinecraftServer getMinecraftServer() { + public WorldServer getLevel() { throw new UnsupportedOperationException("Not supported yet."); } @Override - public IChunkProvider getChunkProvider() { + public long nextSubTickCount() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public LevelTickAccess<Block> getBlockTicks() { + return TickListEmpty.emptyLevelList(); + } + + @Override + public LevelTickAccess<FluidType> getFluidTicks() { + return TickListEmpty.emptyLevelList(); + } + + @Override + public WorldData getLevelData() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public DifficultyDamageScaler getCurrentDifficultyAt(BlockPosition blockposition) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public MinecraftServer getServer() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public IChunkProvider getChunkSource() { throw new UnsupportedOperationException("Not supported yet."); } @@ -95,27 +114,17 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed { } @Override - public void a(EntityHuman entityhuman, int i, BlockPosition blockposition, int j) { + public void levelEvent(EntityHuman entityhuman, int i, BlockPosition blockposition, int j) { // Used by PowderSnowBlock.removeFluid } @Override - public void a(Entity entity, GameEvent gameevent, BlockPosition blockposition) { + public void gameEvent(Entity entity, GameEvent gameevent, BlockPosition blockposition) { throw new UnsupportedOperationException("Not supported yet."); } @Override - public WorldServer getLevel() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public WorldServer getMinecraftWorld() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public IRegistryCustom t() { + public IRegistryCustom registryAccess() { throw new UnsupportedOperationException("Not supported yet."); } @@ -125,37 +134,37 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed { } @Override - public <T extends Entity> List<T> a(EntityTypeTest<Entity, T> ett, AxisAlignedBB aabb, Predicate<? super T> prdct) { + public <T extends Entity> List<T> getEntities(EntityTypeTest<Entity, T> ett, AxisAlignedBB aabb, Predicate<? super T> prdct) { throw new UnsupportedOperationException("Not supported yet."); } @Override - public List<? extends EntityHuman> getPlayers() { + public List<? extends EntityHuman> players() { throw new UnsupportedOperationException("Not supported yet."); } @Override - public IChunkAccess getChunkAt(int i, int i1, ChunkStatus cs, boolean bln) { + public IChunkAccess getChunk(int i, int i1, ChunkStatus cs, boolean bln) { throw new UnsupportedOperationException("Not supported yet."); } @Override - public int a(HeightMap.Type type, int i, int i1) { + public int getHeight(HeightMap.Type type, int i, int i1) { throw new UnsupportedOperationException("Not supported yet."); } @Override - public int n_() { + public int getSkyDarken() { throw new UnsupportedOperationException("Not supported yet."); } @Override - public BiomeManager r_() { + public BiomeManager getBiomeManager() { throw new UnsupportedOperationException("Not supported yet."); } @Override - public BiomeBase a(int i, int i1, int i2) { + public BiomeBase getUncachedNoiseBiome(int i, int i1, int i2) { throw new UnsupportedOperationException("Not supported yet."); } @@ -170,33 +179,33 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed { } @Override - public DimensionManager getDimensionManager() { + public DimensionManager dimensionType() { throw new UnsupportedOperationException("Not supported yet."); } @Override - public float a(EnumDirection ed, boolean bln) { + public float getShade(EnumDirection ed, boolean bln) { throw new UnsupportedOperationException("Not supported yet."); } @Override - public LightEngine k_() { + public LightEngine getLightEngine() { throw new UnsupportedOperationException("Not supported yet."); } @Override - public TileEntity getTileEntity(BlockPosition blockposition) { + public TileEntity getBlockEntity(BlockPosition blockposition) { throw new UnsupportedOperationException("Not supported yet."); } @Override - public IBlockData getType(BlockPosition blockposition) { - return Blocks.AIR.getBlockData(); // SPIGOT-6515 + public IBlockData getBlockState(BlockPosition blockposition) { + return Blocks.AIR.defaultBlockState(); // SPIGOT-6515 } @Override - public Fluid getFluid(BlockPosition blockposition) { - return FluidTypes.EMPTY.h(); // SPIGOT-6634 + public Fluid getFluidState(BlockPosition blockposition) { + return FluidTypes.EMPTY.defaultFluidState(); // SPIGOT-6634 } @Override @@ -205,37 +214,27 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed { } @Override - public boolean a(BlockPosition bp, Predicate<IBlockData> prdct) { + public boolean isStateAtPosition(BlockPosition bp, Predicate<IBlockData> prdct) { throw new UnsupportedOperationException("Not supported yet."); } @Override - public boolean b(BlockPosition bp, Predicate<Fluid> prdct) { + public boolean isFluidAtPosition(BlockPosition bp, Predicate<Fluid> prdct) { throw new UnsupportedOperationException("Not supported yet."); } @Override - public boolean a(BlockPosition blockposition, IBlockData iblockdata, int i, int j) { + public boolean setBlock(BlockPosition blockposition, IBlockData iblockdata, int i, int j) { return false; } @Override - public boolean a(BlockPosition blockposition, boolean flag) { + public boolean removeBlock(BlockPosition blockposition, boolean flag) { throw new UnsupportedOperationException("Not supported yet."); } @Override - public boolean a(BlockPosition blockposition, boolean flag, Entity entity, int i) { + public boolean destroyBlock(BlockPosition blockposition, boolean flag, Entity entity, int i) { return false; // SPIGOT-6515 } - - @Override - public long getSeed() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public Stream<? extends StructureStart<?>> a(SectionPosition sectionPosition, StructureGenerator<?> structureGenerator) { - throw new UnsupportedOperationException("Not supported yet."); - } } diff --git a/paper-server/src/test/java/org/bukkit/ArtTest.java b/paper-server/src/test/java/org/bukkit/ArtTest.java index 4fc985e4d4..9ad47c1679 100644 --- a/paper-server/src/test/java/org/bukkit/ArtTest.java +++ b/paper-server/src/test/java/org/bukkit/ArtTest.java @@ -24,7 +24,7 @@ public class ArtTest extends AbstractTestingBase { for (MinecraftKey key : IRegistry.MOTIVE.keySet()) { Paintings enumArt = IRegistry.MOTIVE.get(key); - String name = key.getKey(); + String name = key.getPath(); int width = enumArt.getWidth() / UNIT_MULTIPLIER; int height = enumArt.getHeight() / UNIT_MULTIPLIER; diff --git a/paper-server/src/test/java/org/bukkit/BlockDataConversionTest.java b/paper-server/src/test/java/org/bukkit/BlockDataConversionTest.java index a53d0530b7..85e139467d 100644 --- a/paper-server/src/test/java/org/bukkit/BlockDataConversionTest.java +++ b/paper-server/src/test/java/org/bukkit/BlockDataConversionTest.java @@ -23,7 +23,7 @@ public class BlockDataConversionTest extends AbstractTestingBase { public static List<Object[]> args() { List<Object[]> list = new ArrayList<>(); for (Block block : (Iterable<Block>) IRegistry.BLOCK) { - list.add(new Object[]{block.getBlockData()}); + list.add(new Object[]{block.defaultBlockState()}); } return list; } diff --git a/paper-server/src/test/java/org/bukkit/BlockDataTest.java b/paper-server/src/test/java/org/bukkit/BlockDataTest.java index 985bf898de..43d31466d6 100644 --- a/paper-server/src/test/java/org/bukkit/BlockDataTest.java +++ b/paper-server/src/test/java/org/bukkit/BlockDataTest.java @@ -18,7 +18,7 @@ public class BlockDataTest extends AbstractTestingBase { @Test public void testParsing() { - BlockData cakeTest = CraftBlockData.fromData(Blocks.CAKE.getBlockData().set(BlockCake.BITES, 3)); + BlockData cakeTest = CraftBlockData.fromData(Blocks.CAKE.defaultBlockState().setValue(BlockCake.BITES, 3)); BlockData materialString = CraftBlockData.newData(Material.CAKE, "[bites=3]"); Assert.assertThat(materialString, is(cakeTest)); @@ -50,7 +50,7 @@ public class BlockDataTest extends AbstractTestingBase { @Test(expected = IllegalArgumentException.class) public void testMistake() { - BlockData cakeTest = CraftBlockData.fromData(Blocks.CAKE.getBlockData().set(BlockCake.BITES, 3)); + BlockData cakeTest = CraftBlockData.fromData(Blocks.CAKE.defaultBlockState().setValue(BlockCake.BITES, 3)); CraftBlockData.newData(Material.CAKE, cakeTest.toString()); } @@ -67,7 +67,7 @@ public class BlockDataTest extends AbstractTestingBase { @Test public void testClone() { - Cake cakeTest = (Cake) CraftBlockData.fromData(Blocks.CAKE.getBlockData().set(BlockCake.BITES, 3)); + Cake cakeTest = (Cake) CraftBlockData.fromData(Blocks.CAKE.defaultBlockState().setValue(BlockCake.BITES, 3)); Cake clone = (Cake) cakeTest.clone(); Assert.assertFalse("Clone did not return new object", cakeTest == clone); @@ -114,7 +114,7 @@ public class BlockDataTest extends AbstractTestingBase { @Test(expected = IllegalArgumentException.class) public void testCannotMerge1() { Chest one = (Chest) CraftBlockData.newData(null, "minecraft:chest[facing=east,waterlogged=true]"); - Chest two = (Chest) CraftBlockData.fromData(Blocks.CHEST.getBlockData()); + Chest two = (Chest) CraftBlockData.fromData(Blocks.CHEST.defaultBlockState()); one.merge(two); } @@ -146,7 +146,7 @@ public class BlockDataTest extends AbstractTestingBase { Assert.assertFalse(CraftBlockData.newData(null, "minecraft:trapped_chest[facing=east,waterlogged=false]").matches(CraftBlockData.newData(null, "minecraft:chest[waterlogged=true]"))); Assert.assertTrue(CraftBlockData.newData(null, "minecraft:chest[facing=east,waterlogged=true]").matches(CraftBlockData.newData(null, "minecraft:chest[waterlogged=true,facing=east]"))); - Chest one = (Chest) CraftBlockData.fromData(Blocks.CHEST.getBlockData().set(BlockChest.FACING, EnumDirection.EAST)); + Chest one = (Chest) CraftBlockData.fromData(Blocks.CHEST.defaultBlockState().setValue(BlockChest.FACING, EnumDirection.EAST)); Chest two = (Chest) CraftBlockData.newData(null, "minecraft:chest[waterlogged=false]"); Assert.assertTrue(one.matches(two)); @@ -164,7 +164,7 @@ public class BlockDataTest extends AbstractTestingBase { @Test public void testGetAsString2() { - Chest data = (Chest) CraftBlockData.fromData(Blocks.CHEST.getBlockData().set(BlockChest.FACING, EnumDirection.EAST)); + Chest data = (Chest) CraftBlockData.fromData(Blocks.CHEST.defaultBlockState().setValue(BlockChest.FACING, EnumDirection.EAST)); Assert.assertThat(data.getAsString(true), is("minecraft:chest[facing=east,type=single,waterlogged=false]")); Assert.assertThat(data.getAsString(false), is("minecraft:chest[facing=east,type=single,waterlogged=false]")); diff --git a/paper-server/src/test/java/org/bukkit/DyeColorsTest.java b/paper-server/src/test/java/org/bukkit/DyeColorsTest.java index e650cd93d2..933719e762 100644 --- a/paper-server/src/test/java/org/bukkit/DyeColorsTest.java +++ b/paper-server/src/test/java/org/bukkit/DyeColorsTest.java @@ -29,7 +29,7 @@ public class DyeColorsTest extends AbstractTestingBase { @Test public void checkColor() { Color color = dye.getColor(); - float[] nmsColorArray = EnumColor.fromColorIndex(dye.getWoolData()).getColor(); + float[] nmsColorArray = EnumColor.byId(dye.getWoolData()).getTextureDiffuseColors(); Color nmsColor = Color.fromRGB((int) (nmsColorArray[0] * 255), (int) (nmsColorArray[1] * 255), (int) (nmsColorArray[2] * 255)); assertThat(color, is(nmsColor)); } @@ -37,7 +37,7 @@ public class DyeColorsTest extends AbstractTestingBase { @Test public void checkFireworkColor() { Color color = dye.getFireworkColor(); - int nmsColor = EnumColor.fromColorIndex(dye.getWoolData()).getFireworksColor(); + int nmsColor = EnumColor.byId(dye.getWoolData()).getFireworkColor(); assertThat(color, is(Color.fromRGB(nmsColor))); } } diff --git a/paper-server/src/test/java/org/bukkit/LootTablesTest.java b/paper-server/src/test/java/org/bukkit/LootTablesTest.java index 9bfbfb1a32..5f6b547080 100644 --- a/paper-server/src/test/java/org/bukkit/LootTablesTest.java +++ b/paper-server/src/test/java/org/bukkit/LootTablesTest.java @@ -24,7 +24,7 @@ public class LootTablesTest extends AbstractTestingBase { @Test public void testNMS() { - for (MinecraftKey key : net.minecraft.world.level.storage.loot.LootTables.a()) { + for (MinecraftKey key : net.minecraft.world.level.storage.loot.LootTables.all()) { NamespacedKey bukkitKey = CraftNamespacedKey.fromMinecraft(key); LootTables lootTable = Registry.LOOT_TABLES.get(bukkitKey); diff --git a/paper-server/src/test/java/org/bukkit/MaterialTest.java b/paper-server/src/test/java/org/bukkit/MaterialTest.java index 59682a6879..0f40163910 100644 --- a/paper-server/src/test/java/org/bukkit/MaterialTest.java +++ b/paper-server/src/test/java/org/bukkit/MaterialTest.java @@ -38,7 +38,7 @@ public class MaterialTest extends AbstractTestingBase { if (item == null) continue; MinecraftKey id = IRegistry.ITEM.getKey(item); - String name = item.getName(); + String name = item.getDescriptionId(); Material material = materials.remove(id); diff --git a/paper-server/src/test/java/org/bukkit/PerMaterialTest.java b/paper-server/src/test/java/org/bukkit/PerMaterialTest.java index 3190c01952..2dc199c974 100644 --- a/paper-server/src/test/java/org/bukkit/PerMaterialTest.java +++ b/paper-server/src/test/java/org/bukkit/PerMaterialTest.java @@ -68,7 +68,7 @@ public class PerMaterialTest extends AbstractTestingBase { if (material == Material.AIR) { assertFalse(material.isSolid()); } else if (material.isBlock()) { - assertThat(material.isSolid(), is(CraftMagicNumbers.getBlock(material).getBlockData().getMaterial().isSolid())); + assertThat(material.isSolid(), is(CraftMagicNumbers.getBlock(material).defaultBlockState().getMaterial().blocksMotion())); } else { assertFalse(material.isSolid()); } @@ -79,7 +79,7 @@ public class PerMaterialTest extends AbstractTestingBase { if (material.isBlock()) { assertFalse(material.isEdible()); } else { - assertThat(material.isEdible(), is(CraftMagicNumbers.getItem(material).isFood())); + assertThat(material.isEdible(), is(CraftMagicNumbers.getItem(material).isEdible())); } } @@ -96,7 +96,7 @@ public class PerMaterialTest extends AbstractTestingBase { assertThat((int) material.getMaxDurability(), is(0)); } else if (material.isBlock()) { Item item = CraftMagicNumbers.getItem(material); - assertThat((int) material.getMaxDurability(), is(item.getMaxDurability())); + assertThat((int) material.getMaxDurability(), is(item.getMaxDamage())); } } @@ -132,7 +132,7 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void isFlammable() { if (material != Material.AIR && material.isBlock()) { - assertThat(material.isFlammable(), is(CraftMagicNumbers.getBlock(material).getBlockData().getMaterial().isBurnable())); + assertThat(material.isFlammable(), is(CraftMagicNumbers.getBlock(material).defaultBlockState().getMaterial().isFlammable())); } else { assertFalse(material.isFlammable()); } @@ -156,7 +156,7 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void isOccluding() { if (material.isBlock()) { - assertThat(material.isOccluding(), is(CraftMagicNumbers.getBlock(material).getBlockData().isOccluding(BlockAccessAir.INSTANCE, BlockPosition.ZERO))); + assertThat(material.isOccluding(), is(CraftMagicNumbers.getBlock(material).defaultBlockState().isRedstoneConductor(BlockAccessAir.INSTANCE, BlockPosition.ZERO))); } else { assertFalse(material.isOccluding()); } @@ -174,7 +174,7 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void usesDurability() { if (!material.isBlock()) { - assertThat(EnchantmentTarget.BREAKABLE.includes(material), is(CraftMagicNumbers.getItem(material).usesDurability())); + assertThat(EnchantmentTarget.BREAKABLE.includes(material), is(CraftMagicNumbers.getItem(material).canBeDepleted())); } else { assertFalse(EnchantmentTarget.BREAKABLE.includes(material)); } @@ -183,7 +183,7 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void testDurability() { if (!material.isBlock()) { - assertThat(material.getMaxDurability(), is((short) CraftMagicNumbers.getItem(material).getMaxDurability())); + assertThat(material.getMaxDurability(), is((short) CraftMagicNumbers.getItem(material).getMaxDamage())); } else { assertThat(material.getMaxDurability(), is((short) 0)); } @@ -201,7 +201,7 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void testAir() { if (material.isBlock()) { - assertThat(material.isAir(), is(equalTo(CraftMagicNumbers.getBlock(material).getBlockData().isAir()))); + assertThat(material.isAir(), is(equalTo(CraftMagicNumbers.getBlock(material).defaultBlockState().isAir()))); } else { assertThat(material.isAir(), is(equalTo(false))); } @@ -221,7 +221,7 @@ public class PerMaterialTest extends AbstractTestingBase { if (material.isBlock()) { assertThat(material.isInteractable(), is(!CraftMagicNumbers.getBlock(material).getClass() - .getMethod("interact", IBlockData.class, net.minecraft.world.level.World.class, BlockPosition.class, EntityHuman.class, EnumHand.class, MovingObjectPositionBlock.class) + .getMethod("use", IBlockData.class, net.minecraft.world.level.World.class, BlockPosition.class, EntityHuman.class, EnumHand.class, MovingObjectPositionBlock.class) .getDeclaringClass().equals(BlockBase.class))); } else { assertFalse(material.isInteractable()); @@ -231,21 +231,21 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void testBlockHardness() { if (material.isBlock()) { - assertThat(material.getHardness(), is(CraftMagicNumbers.getBlock(material).getBlockData().destroySpeed)); + assertThat(material.getHardness(), is(CraftMagicNumbers.getBlock(material).defaultBlockState().destroySpeed)); } } @Test public void testBlastResistance() { if (material.isBlock()) { - assertThat(material.getBlastResistance(), is(CraftMagicNumbers.getBlock(material).getDurability())); + assertThat(material.getBlastResistance(), is(CraftMagicNumbers.getBlock(material).getExplosionResistance())); } } @Test public void testSlipperiness() { if (material.isBlock()) { - assertThat(material.getSlipperiness(), is(CraftMagicNumbers.getBlock(material).getFrictionFactor())); + assertThat(material.getSlipperiness(), is(CraftMagicNumbers.getBlock(material).getFriction())); } } diff --git a/paper-server/src/test/java/org/bukkit/SoundTest.java b/paper-server/src/test/java/org/bukkit/SoundTest.java index 3e05466c92..18a98c589e 100644 --- a/paper-server/src/test/java/org/bukkit/SoundTest.java +++ b/paper-server/src/test/java/org/bukkit/SoundTest.java @@ -20,7 +20,7 @@ public class SoundTest extends AbstractTestingBase { @Test public void testReverse() { for (MinecraftKey effect : IRegistry.SOUND_EVENT.keySet()) { - assertNotNull(effect + "", Sound.valueOf(effect.getKey().replace('.', '_').toUpperCase(java.util.Locale.ENGLISH))); + assertNotNull(effect + "", Sound.valueOf(effect.getPath().replace('.', '_').toUpperCase(java.util.Locale.ENGLISH))); } } diff --git a/paper-server/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java b/paper-server/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java index d256ab477f..2439ca837e 100644 --- a/paper-server/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java +++ b/paper-server/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java @@ -33,7 +33,7 @@ public class StatisticsAndAchievementsTest extends AbstractTestingBase { HashMultiset<Statistic> statistics = HashMultiset.create(); for (StatisticWrapper wrapper : IRegistry.STAT_TYPE) { for (Object child : wrapper.getRegistry()) { - net.minecraft.stats.Statistic<?> statistic = wrapper.b(child); + net.minecraft.stats.Statistic<?> statistic = wrapper.get(child); String message = String.format("org.bukkit.Statistic is missing: '%s'", statistic); Statistic subject = CraftStatistic.getBukkitStatistic(statistic); @@ -42,7 +42,7 @@ public class StatisticsAndAchievementsTest extends AbstractTestingBase { if (wrapper.getRegistry() == IRegistry.BLOCK || wrapper.getRegistry() == IRegistry.ITEM) { assertNotNull("Material type map missing for " + wrapper.getRegistry().getKey(child), CraftStatistic.getMaterialFromStatistic(statistic)); } else if (wrapper.getRegistry() == IRegistry.ENTITY_TYPE) { - assertNotNull("Entity type map missing for " + EntityTypes.getName((EntityTypes<?>) child), CraftStatistic.getEntityTypeFromStatistic((net.minecraft.stats.Statistic<EntityTypes<?>>) statistic)); + assertNotNull("Entity type map missing for " + EntityTypes.getKey((EntityTypes<?>) child), CraftStatistic.getEntityTypeFromStatistic((net.minecraft.stats.Statistic<EntityTypes<?>>) statistic)); } statistics.add(subject); diff --git a/paper-server/src/test/java/org/bukkit/StructureTypeTest.java b/paper-server/src/test/java/org/bukkit/StructureTypeTest.java index 4522e65e88..eba2479fd7 100644 --- a/paper-server/src/test/java/org/bukkit/StructureTypeTest.java +++ b/paper-server/src/test/java/org/bukkit/StructureTypeTest.java @@ -24,7 +24,7 @@ public class StructureTypeTest extends AbstractTestingBase { @Test public void testMinecraftToBukkit() { for (MinecraftKey key : IRegistry.STRUCTURE_FEATURE.keySet()) { - Assert.assertNotNull(key.getKey(), structures.get(key.getKey())); + Assert.assertNotNull(key.getPath(), structures.get(key.getPath())); } } diff --git a/paper-server/src/test/java/org/bukkit/block/banner/PatternTypeTest.java b/paper-server/src/test/java/org/bukkit/block/banner/PatternTypeTest.java index c7b6eed115..ff4b81d781 100644 --- a/paper-server/src/test/java/org/bukkit/block/banner/PatternTypeTest.java +++ b/paper-server/src/test/java/org/bukkit/block/banner/PatternTypeTest.java @@ -10,9 +10,9 @@ public class PatternTypeTest extends AbstractTestingBase { @Test public void testToBukkit() { for (EnumBannerPatternType nms : EnumBannerPatternType.values()) { - PatternType bukkit = PatternType.getByIdentifier(nms.b()); + PatternType bukkit = PatternType.getByIdentifier(nms.getHashname()); - Assert.assertNotNull("No Bukkit banner for " + nms + " " + nms.b(), bukkit); + Assert.assertNotNull("No Bukkit banner for " + nms + " " + nms.getHashname(), bukkit); } } @@ -21,7 +21,7 @@ public class PatternTypeTest extends AbstractTestingBase { for (PatternType bukkit : PatternType.values()) { EnumBannerPatternType found = null; for (EnumBannerPatternType nms : EnumBannerPatternType.values()) { - if (bukkit.getIdentifier().equals(nms.b())) { + if (bukkit.getIdentifier().equals(nms.getHashname())) { found = nms; break; } diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java index b1e25c3ae4..6cd61efea2 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java @@ -1,6 +1,9 @@ package org.bukkit.craftbukkit.generator; import static org.junit.Assert.*; +import net.minecraft.core.IRegistry; +import net.minecraft.data.RegistryGeneration; +import net.minecraft.world.level.biome.BiomeBase; import org.bukkit.Material; import org.bukkit.block.data.BlockData; import org.bukkit.support.AbstractTestingBase; @@ -10,6 +13,7 @@ public class ChunkDataTest extends AbstractTestingBase { private static final BlockData RED_WOOL = Material.RED_WOOL.createBlockData(); private static final BlockData AIR = Material.AIR.createBlockData(); + private static final IRegistry<BiomeBase> BIOMES = RegistryGeneration.BIOME; private boolean testSetBlock(OldCraftChunkData data, int x, int y, int z, BlockData type, BlockData expected) { data.setBlock(x, y, z, type); @@ -34,21 +38,21 @@ public class ChunkDataTest extends AbstractTestingBase { @Test public void testMinHeight() { - OldCraftChunkData data = new OldCraftChunkData(-128, 128); + OldCraftChunkData data = new OldCraftChunkData(-128, 128, BIOMES); assertTrue("Could not set block below min height", testSetBlock(data, 0, -256, 0, RED_WOOL, AIR)); assertTrue("Could set block above min height", testSetBlock(data, 0, -64, 0, RED_WOOL, RED_WOOL)); } @Test public void testMaxHeight() { - OldCraftChunkData data = new OldCraftChunkData(0, 128); + OldCraftChunkData data = new OldCraftChunkData(0, 128, BIOMES); assertTrue("Could not set block above max height", testSetBlock(data, 0, 128, 0, RED_WOOL, AIR)); assertTrue("Could set block below max height", testSetBlock(data, 0, 127, 0, RED_WOOL, RED_WOOL)); } @Test public void testBoundsCheckingSingle() { - OldCraftChunkData data = new OldCraftChunkData(0, 256); + OldCraftChunkData data = new OldCraftChunkData(0, 256, BIOMES); assertTrue("Can set block inside chunk bounds", testSetBlock(data, 0, 0, 0, RED_WOOL, RED_WOOL)); assertTrue("Can set block inside chunk bounds", testSetBlock(data, 15, 255, 15, RED_WOOL, RED_WOOL)); assertTrue("Can no set block outside chunk bounds", testSetBlock(data, -1, 0, 0, RED_WOOL, AIR)); @@ -61,7 +65,7 @@ public class ChunkDataTest extends AbstractTestingBase { @Test public void testSetRegion() { - OldCraftChunkData data = new OldCraftChunkData(0, 256); + OldCraftChunkData data = new OldCraftChunkData(0, 256, BIOMES); testSetRegion(data, -100, 0, -100, 0, 256, 0, RED_WOOL); // exclusively outside testSetRegion(data, 16, 256, 16, 0, 0, 0, RED_WOOL); // minimum >= maximum testSetRegion(data, 0, 0, 0, 0, 0, 0, RED_WOOL); // minimum == maximum diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java index e206381967..c0253c44d5 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java @@ -162,7 +162,7 @@ public class ItemMetaTest extends AbstractTestingBase { for (Block block : queue) { if (block != null) { - ItemStack stack = CraftItemStack.asNewCraftStack(Item.getItemOf(block)); + ItemStack stack = CraftItemStack.asNewCraftStack(Item.byBlock(block)); // Command blocks aren't unit testable atm if (stack.getType() == Material.COMMAND_BLOCK || stack.getType() == Material.CHAIN_COMMAND_BLOCK || stack.getType() == Material.REPEATING_COMMAND_BLOCK) { @@ -323,7 +323,7 @@ public class ItemMetaTest extends AbstractTestingBase { @Override ItemStack operate(ItemStack cleanStack) { final CraftMetaArmorStand meta = (CraftMetaArmorStand) cleanStack.getItemMeta(); meta.entityTag = new NBTTagCompound(); - meta.entityTag.setBoolean("Small", true); + meta.entityTag.putBoolean("Small", true); cleanStack.setItemMeta(meta); return cleanStack; } @@ -340,7 +340,7 @@ public class ItemMetaTest extends AbstractTestingBase { @Override ItemStack operate(ItemStack cleanStack) { final CraftMetaEntityTag meta = ((CraftMetaEntityTag) cleanStack.getItemMeta()); meta.entityTag = new NBTTagCompound(); - meta.entityTag.setBoolean("Invisible", true); + meta.entityTag.putBoolean("Invisible", true); cleanStack.setItemMeta(meta); return cleanStack; } diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java index b9abed4646..bed586fe7c 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java @@ -12,7 +12,7 @@ public class NMSCraftItemStackTest extends AbstractTestingBase { @Test public void testCloneEnchantedItem() throws Exception { net.minecraft.world.item.ItemStack nmsItemStack = new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.POTION); - nmsItemStack.addEnchantment(Enchantments.SHARPNESS, 1); + nmsItemStack.enchant(Enchantments.SHARPNESS, 1); ItemStack itemStack = CraftItemStack.asCraftMirror(nmsItemStack); ItemStack clone = itemStack.clone(); assertThat(clone.getType(), is(itemStack.getType())); diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java index 02eae5a40d..884a4b9462 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java @@ -83,6 +83,8 @@ public class LegacyTest extends AbstractTestingBase { Material.WAXED_EXPOSED_CUT_COPPER_STAIRS, Material.WAXED_OXIDIZED_COPPER, Material.WAXED_OXIDIZED_CUT_COPPER, Material.WAXED_OXIDIZED_CUT_COPPER_SLAB, Material.WAXED_OXIDIZED_CUT_COPPER_STAIRS, Material.WAXED_WEATHERED_COPPER, Material.WAXED_WEATHERED_CUT_COPPER, Material.WAXED_WEATHERED_CUT_COPPER_SLAB, Material.WAXED_WEATHERED_CUT_COPPER_STAIRS, Material.WEATHERED_COPPER, Material.WEATHERED_CUT_COPPER, Material.WEATHERED_CUT_COPPER_SLAB, Material.WEATHERED_CUT_COPPER_STAIRS, Material.WHITE_CANDLE, Material.WHITE_CANDLE_CAKE, Material.YELLOW_CANDLE, Material.YELLOW_CANDLE_CAKE, Material.POTTED_AZALEA_BUSH, Material.POTTED_FLOWERING_AZALEA_BUSH, + // 1.18 + Material.MUSIC_DISC_OTHERSIDE, // 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/paper-server/src/test/java/org/bukkit/craftbukkit/util/CraftChatMessageTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/util/CraftChatMessageTest.java index acbaa8206b..ab0e7b0175 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/util/CraftChatMessageTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/util/CraftChatMessageTest.java @@ -61,9 +61,9 @@ public class CraftChatMessageTest { } private IChatBaseComponent create(String txt, String... rest) { - IChatMutableComponent cmp = CraftChatMessage.fromString(txt, false)[0].mutableCopy(); + IChatMutableComponent cmp = CraftChatMessage.fromString(txt, false)[0].copy(); for (String s : rest) { - cmp.addSibling(CraftChatMessage.fromString(s, true)[0]); + cmp.append(CraftChatMessage.fromString(s, true)[0]); } return cmp; diff --git a/paper-server/src/test/java/org/bukkit/entity/EntityTypesTest.java b/paper-server/src/test/java/org/bukkit/entity/EntityTypesTest.java index 7ed98bb679..810f1c7049 100644 --- a/paper-server/src/test/java/org/bukkit/entity/EntityTypesTest.java +++ b/paper-server/src/test/java/org/bukkit/entity/EntityTypesTest.java @@ -17,9 +17,9 @@ public class EntityTypesTest extends AbstractTestingBase { Set<EntityType> allBukkit = Arrays.stream(EntityType.values()).filter((b) -> b.getName() != null).collect(Collectors.toSet()); for (EntityTypes<?> nms : IRegistry.ENTITY_TYPE) { - MinecraftKey key = EntityTypes.getName(nms); + MinecraftKey key = EntityTypes.getKey(nms); - EntityType bukkit = EntityType.fromName(key.getKey()); + EntityType bukkit = EntityType.fromName(key.getPath()); Assert.assertNotNull("Missing nms->bukkit " + key, bukkit); Assert.assertTrue("Duplicate entity nms->" + bukkit, allBukkit.remove(bukkit)); diff --git a/paper-server/src/test/java/org/bukkit/entity/memory/CraftMemoryKeyTest.java b/paper-server/src/test/java/org/bukkit/entity/memory/CraftMemoryKeyTest.java index 7de087a8f9..9acdeaf8fa 100644 --- a/paper-server/src/test/java/org/bukkit/entity/memory/CraftMemoryKeyTest.java +++ b/paper-server/src/test/java/org/bukkit/entity/memory/CraftMemoryKeyTest.java @@ -56,7 +56,7 @@ public class CraftMemoryKeyTest extends AbstractTestingBase { @Test public void shouldReturnNullWhenBukkitRepresentationOfKeyisNotAvailableAndSerializerIsNotPresent() { for (MemoryModuleType<?> memoryModuleType : IRegistry.MEMORY_MODULE_TYPE) { - if (!memoryModuleType.getSerializer().isPresent()) { + if (!memoryModuleType.getCodec().isPresent()) { MemoryKey bukkitNoKey = CraftMemoryKey.toMemoryKey(memoryModuleType); Assert.assertNull("MemoryModuleType should be null", bukkitNoKey); } @@ -66,7 +66,7 @@ public class CraftMemoryKeyTest extends AbstractTestingBase { @Test public void shouldReturnAnInstanceOfMemoryKeyWhenBukkitRepresentationOfKeyisAvailableAndSerializerIsPresent() { for (MemoryModuleType<?> memoryModuleType : IRegistry.MEMORY_MODULE_TYPE) { - if (memoryModuleType.getSerializer().isPresent()) { + if (memoryModuleType.getCodec().isPresent()) { MemoryKey bukkitNoKey = CraftMemoryKey.toMemoryKey(memoryModuleType); Assert.assertNotNull("MemoryModuleType should not be null " + IRegistry.MEMORY_MODULE_TYPE.getKey(memoryModuleType), bukkitNoKey); } diff --git a/paper-server/src/test/java/org/bukkit/potion/PotionTest.java b/paper-server/src/test/java/org/bukkit/potion/PotionTest.java index 95eb6bbe33..9ad5d356d1 100644 --- a/paper-server/src/test/java/org/bukkit/potion/PotionTest.java +++ b/paper-server/src/test/java/org/bukkit/potion/PotionTest.java @@ -17,9 +17,9 @@ public class PotionTest extends AbstractTestingBase { public void testEffectCompleteness() throws Throwable { Map<PotionType, String> effects = new EnumMap(PotionType.class); for (Object reg : IRegistry.POTION) { - List<MobEffect> eff = ((PotionRegistry) reg).a(); + List<MobEffect> eff = ((PotionRegistry) reg).getEffects(); if (eff.size() != 1) continue; - int id = MobEffectList.getId(eff.get(0).getMobEffect()); + int id = MobEffectList.getId(eff.get(0).getEffect()); PotionEffectType type = PotionEffectType.getById(id); assertNotNull(String.valueOf(id), PotionEffectType.getById(id)); diff --git a/paper-server/src/test/java/org/bukkit/support/AbstractTestingBase.java b/paper-server/src/test/java/org/bukkit/support/AbstractTestingBase.java index ebf0ed1561..5450d2e684 100644 --- a/paper-server/src/test/java/org/bukkit/support/AbstractTestingBase.java +++ b/paper-server/src/test/java/org/bukkit/support/AbstractTestingBase.java @@ -36,17 +36,17 @@ public abstract class AbstractTestingBase { public static final TagRegistry TAG_REGISTRY; static { - SharedConstants.a(); - DispenserRegistry.init(); + SharedConstants.tryDetectVersion(); + DispenserRegistry.bootStrap(); // Set up resource manager ResourceManager resourceManager = new ResourceManager(EnumResourcePackType.SERVER_DATA); // add tags and loot tables for unit tests - resourceManager.a(TAG_REGISTRY = new TagRegistry(IRegistryCustom.a())); - resourceManager.a(LOOT_TABLE_REGISTRY = new LootTableRegistry(new LootPredicateManager())); + resourceManager.registerReloadListener(TAG_REGISTRY = new TagRegistry(IRegistryCustom.builtin())); + resourceManager.registerReloadListener(LOOT_TABLE_REGISTRY = new LootTableRegistry(new LootPredicateManager())); // Register vanilla pack - resourceManager.a(MoreExecutors.directExecutor(), MoreExecutors.directExecutor(), Collections.singletonList(new ResourcePackVanilla(ResourcePackSourceVanilla.BUILT_IN_METADATA, "minecraft")), CompletableFuture.completedFuture(Unit.INSTANCE)).join(); + resourceManager.reload(MoreExecutors.directExecutor(), MoreExecutors.directExecutor(), Collections.singletonList(new ResourcePackVanilla(ResourcePackSourceVanilla.BUILT_IN_METADATA, "minecraft")), CompletableFuture.completedFuture(Unit.INSTANCE)).join(); // Bind tags - TAG_REGISTRY.a().bind(); + TAG_REGISTRY.getTags().bindToGlobal(); DummyServer.setup(); DummyEnchantments.setup(); diff --git a/paper-server/src/test/java/org/bukkit/support/DummyServer.java b/paper-server/src/test/java/org/bukkit/support/DummyServer.java index 886e462def..b25fb75e83 100644 --- a/paper-server/src/test/java/org/bukkit/support/DummyServer.java +++ b/paper-server/src/test/java/org/bukkit/support/DummyServer.java @@ -93,7 +93,7 @@ public final class DummyServer implements InvocationHandler { @Override public Object handle(DummyServer server, Object[] args) { NamespacedKey key = (NamespacedKey) args[0]; - return new CraftLootTable(key, AbstractTestingBase.LOOT_TABLE_REGISTRY.getLootTable(CraftNamespacedKey.toMinecraft(key))); + return new CraftLootTable(key, AbstractTestingBase.LOOT_TABLE_REGISTRY.get(CraftNamespacedKey.toMinecraft(key))); } } );