From e2f5ea34e9c7f9eb3eb2be422b169679922b2770 Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 11 Jun 2021 15:00:00 +1000 Subject: [PATCH] Update to Minecraft 1.17 --- nms-patches/net/minecraft/CrashReport.patch | 10 +- .../minecraft/advancements/Advancement.patch | 4 +- .../minecraft/advancements/Advancements.patch | 13 +- .../commands/CommandDispatcher.patch | 35 +- .../commands/CommandListenerWrapper.patch | 30 +- .../minecraft/commands/ICommandListener.patch | 8 +- .../commands/arguments/ArgumentEntity.patch | 6 +- .../arguments/blocks/ArgumentBlock.patch | 30 +- .../selector/ArgumentParserSelector.patch | 30 +- .../arguments/selector/EntitySelector.patch | 8 +- .../core/cauldron/CauldronInteraction.patch | 173 ++++ .../core/dispenser/DispenseBehaviorBoat.patch | 10 +- .../core/dispenser/DispenseBehaviorItem.patch | 4 +- .../DispenseBehaviorProjectile.patch | 4 +- .../dispenser/DispenseBehaviorShears.patch | 20 +- .../DispenseBehaviorShulkerBox.patch | 20 +- .../core/dispenser/IDispenseBehavior.patch | 160 ++-- .../minecraft/network/NetworkManager.patch | 6 +- .../network/PacketDataSerializer.patch | 60 +- .../minecraft/network/chat/ChatHexColor.patch | 20 +- .../minecraft/network/chat/ChatModifier.patch | 23 - .../network/chat/IChatBaseComponent.patch | 4 +- .../protocol/PlayerConnectionUtils.patch | 8 +- .../ClientboundInitializeBorderPacket.patch | 15 + .../ClientboundSetBorderCenterPacket.patch | 15 + .../game/PacketPlayInBlockPlace.patch | 2 +- .../protocol/game/PacketPlayInChat.patch | 10 +- .../game/PacketPlayInCloseWindow.patch | 15 - .../protocol/game/PacketPlayInUseItem.patch | 2 +- .../protocol/game/PacketPlayOutChat.patch | 2 +- .../game/PacketPlayOutMultiBlockChange.patch | 8 +- .../game/PacketPlayOutWorldBorder.patch | 15 - .../PacketHandshakingInSetProtocol.patch | 2 +- .../network/syncher/DataWatcher.patch | 15 +- .../server/AdvancementDataPlayer.patch | 14 +- .../minecraft/server/CustomFunctionData.patch | 2 +- .../minecraft/server/DispenserRegistry.patch | 110 ++- nms-patches/net/minecraft/server/Main.patch | 61 +- .../minecraft/server/MinecraftServer.patch | 288 +++--- .../minecraft/server/ScoreboardServer.patch | 84 +- .../server/bossevents/BossBattleCustom.patch | 8 +- .../server/commands/CommandEffect.patch | 10 +- .../server/commands/CommandGamemode.patch | 15 - .../server/commands/CommandGamerule.patch | 8 +- .../server/commands/CommandList.patch | 6 +- .../server/commands/CommandReload.patch | 2 +- .../commands/CommandSpreadPlayers.patch | 16 +- .../server/commands/CommandSummon.patch | 4 +- .../server/commands/CommandTeleport.patch | 34 +- .../server/commands/CommandTime.patch | 6 +- .../server/dedicated/DedicatedServer.patch | 77 +- .../dedicated/DedicatedServerProperties.patch | 33 +- .../dedicated/DedicatedServerSettings.patch | 18 +- .../server/dedicated/PropertyManager.patch | 36 +- .../net/minecraft/server/gui/ServerGUI.patch | 15 +- .../server/level/ChunkMapDistance.patch | 58 +- .../server/level/ChunkProviderServer.patch | 90 +- .../minecraft/server/level/EntityPlayer.patch | 541 +++++------ .../server/level/EntityTrackerEntry.patch | 149 +-- .../minecraft/server/level/PlayerChunk.patch | 82 +- .../server/level/PlayerChunkMap.patch | 155 ++- .../server/level/PlayerInteractManager.patch | 159 ++-- .../level/RegionLimitedWorldAccess.patch | 6 +- .../minecraft/server/level/WorldServer.patch | 533 +++++------ .../server/network/HandshakeListener.patch | 22 +- .../server/network/LegacyPingHandler.patch | 8 +- .../server/network/LoginListener.patch | 71 +- .../server/network/PacketStatusListener.patch | 20 +- .../server/network/PlayerConnection.patch | 879 +++++++++--------- .../server/network/ServerConnection.patch | 20 +- .../server/players/ExpirableListEntry.patch | 14 +- .../minecraft/server/players/JsonList.patch | 43 +- .../NameReferencingFileConverter.patch | 14 +- .../minecraft/server/players/PlayerList.patch | 384 ++++---- .../server/players/SleepStatus.patch | 20 + .../minecraft/server/players/UserCache.patch | 2 +- .../rcon/RemoteControlCommandListener.patch | 4 +- .../minecraft/stats/RecipeBookServer.patch | 14 +- .../stats/ServerStatisticManager.patch | 6 +- .../util/datafix/DataConverterRegistry.patch | 28 +- .../util/worldupdate/WorldUpgrader.patch | 69 +- .../net/minecraft/world/ChestLock.patch | 2 +- .../net/minecraft/world/IInventory.patch | 6 +- .../minecraft/world/InventoryLargeChest.patch | 22 +- .../world/InventorySubcontainer.patch | 12 +- .../world/damagesource/DamageSource.patch | 8 +- .../EntityDamageSourceIndirect.patch | 4 +- .../world/effect/MobEffectList.patch | 19 +- .../minecraft/world/effect/MobEffects.patch | 4 +- .../net/minecraft/world/entity/Entity.patch | 375 ++++---- .../world/entity/EntityAgeable.patch | 28 +- .../world/entity/EntityAreaEffectCloud.patch | 36 +- .../world/entity/EntityCreature.patch | 6 +- .../world/entity/EntityExperienceOrb.patch | 76 +- .../world/entity/EntityInsentient.patch | 173 ++-- .../world/entity/EntityLightning.patch | 83 +- .../minecraft/world/entity/EntityLiving.patch | 399 ++++---- .../minecraft/world/entity/EntityTypes.patch | 37 +- .../world/entity/IEntityAngerable.patch | 10 +- .../world/entity/IEntitySelector.patch | 6 +- .../world/entity/SaddleStorage.patch | 8 +- .../ai/attributes/AttributeRanged.patch | 4 +- .../ai/attributes/GenericAttributes.patch | 4 +- .../behavior/BehaviorAttackTargetForget.patch | 8 +- .../ai/behavior/BehaviorAttackTargetSet.patch | 6 +- .../entity/ai/behavior/BehaviorFarm.patch | 60 +- .../ai/behavior/BehaviorInteractDoor.patch | 24 +- .../entity/ai/behavior/BehaviorMakeLove.patch | 4 +- .../entity/ai/behavior/BehaviorUtil.patch | 12 +- .../ai/behavior/BehaviorWorkComposter.patch | 14 +- .../ai/goal/PathfinderGoalBreakDoor.patch | 12 +- .../ai/goal/PathfinderGoalEatTile.patch | 30 +- .../ai/goal/PathfinderGoalFollowOwner.patch | 16 +- .../entity/ai/goal/PathfinderGoalPanic.patch | 8 +- .../ai/goal/PathfinderGoalRemoveBlock.patch | 10 +- .../entity/ai/goal/PathfinderGoalSit.patch | 8 +- .../entity/ai/goal/PathfinderGoalTame.patch | 10 +- .../entity/ai/goal/PathfinderGoalTempt.patch | 39 +- .../target/PathfinderGoalDefendVillage.patch | 4 +- .../target/PathfinderGoalHurtByTarget.patch | 14 +- ...athfinderGoalNearestAttackableTarget.patch | 6 +- .../PathfinderGoalOwnerHurtByTarget.patch | 6 +- .../PathfinderGoalOwnerHurtTarget.patch | 6 +- .../ai/goal/target/PathfinderGoalTarget.patch | 26 +- .../world/entity/ambient/EntityBat.patch | 26 +- .../world/entity/animal/Bucketable.patch | 41 + .../world/entity/animal/EntityAnimal.patch | 33 +- .../world/entity/animal/EntityBee.patch | 93 +- .../world/entity/animal/EntityCat.patch | 62 +- .../world/entity/animal/EntityChicken.patch | 18 +- .../world/entity/animal/EntityCow.patch | 8 +- .../world/entity/animal/EntityDolphin.patch | 30 +- .../world/entity/animal/EntityFish.patch | 52 +- .../world/entity/animal/EntityFox.patch | 93 +- .../world/entity/animal/EntityIronGolem.patch | 6 +- .../entity/animal/EntityMushroomCow.patch | 36 +- .../world/entity/animal/EntityOcelot.patch | 30 +- .../world/entity/animal/EntityPanda.patch | 40 +- .../world/entity/animal/EntityParrot.patch | 30 +- .../world/entity/animal/EntityPig.patch | 2 +- .../entity/animal/EntityPufferFish.patch | 16 +- .../world/entity/animal/EntityRabbit.patch | 24 +- .../world/entity/animal/EntitySheep.patch | 39 +- .../world/entity/animal/EntitySnowman.patch | 32 +- .../world/entity/animal/EntityTurtle.patch | 37 +- .../world/entity/animal/EntityWolf.patch | 28 +- .../world/entity/animal/axolotl/Axolotl.patch | 56 ++ .../world/entity/animal/goat/Goat.patch | 47 + .../animal/horse/EntityHorseAbstract.patch | 50 +- .../animal/horse/EntityLlamaTrader.patch | 8 +- .../horse/PathfinderGoalHorseTrap.patch | 10 +- .../boss/enderdragon/EntityEnderCrystal.patch | 28 +- .../boss/enderdragon/EntityEnderDragon.patch | 53 +- .../phases/DragonControllerManager.patch | 20 +- .../entity/boss/wither/EntityWither.patch | 60 +- .../entity/decoration/EntityArmorStand.patch | 102 +- .../entity/decoration/EntityHanging.patch | 54 +- .../entity/decoration/EntityItemFrame.patch | 28 +- .../world/entity/decoration/EntityLeash.patch | 25 +- .../entity/decoration/EntityPainting.patch | 6 +- .../entity/item/EntityFallingBlock.patch | 49 +- .../world/entity/item/EntityItem.patch | 56 +- .../world/entity/item/EntityTNTPrimed.patch | 26 +- .../entity/monster/EntityCaveSpider.patch | 4 +- .../world/entity/monster/EntityCreeper.patch | 48 +- .../world/entity/monster/EntityEnderman.patch | 35 +- .../world/entity/monster/EntityGhast.patch | 9 +- .../entity/monster/EntityGuardianElder.patch | 6 +- .../monster/EntityIllagerIllusioner.patch | 22 +- .../entity/monster/EntityIllagerWizard.patch | 6 +- .../world/entity/monster/EntityPhantom.patch | 4 +- .../entity/monster/EntityPigZombie.patch | 24 +- .../world/entity/monster/EntityPillager.patch | 2 +- .../world/entity/monster/EntityRavager.patch | 8 +- .../world/entity/monster/EntityShulker.patch | 41 +- .../entity/monster/EntitySilverfish.patch | 32 +- .../monster/EntitySkeletonAbstract.patch | 12 +- .../entity/monster/EntitySkeletonWither.patch | 4 +- .../world/entity/monster/EntitySlime.patch | 16 +- .../world/entity/monster/EntitySpider.patch | 4 +- .../world/entity/monster/EntityStrider.patch | 6 +- .../world/entity/monster/EntityVex.patch | 8 +- .../world/entity/monster/EntityZombie.patch | 58 +- .../entity/monster/EntityZombieHusk.patch | 6 +- .../entity/monster/EntityZombieVillager.patch | 57 +- .../entity/monster/piglin/EntityPiglin.patch | 69 +- .../monster/piglin/EntityPiglinAbstract.patch | 10 +- .../entity/monster/piglin/PiglinAI.patch | 123 ++- .../world/entity/npc/EntityVillager.patch | 62 +- .../entity/npc/EntityVillagerAbstract.patch | 16 +- .../entity/npc/EntityVillagerTrader.patch | 10 +- .../world/entity/npc/MobSpawnerTrader.patch | 8 +- .../world/entity/player/EntityHuman.patch | 186 ++-- .../world/entity/player/PlayerInventory.patch | 45 +- .../world/entity/projectile/EntityArrow.patch | 33 +- .../world/entity/projectile/EntityEgg.patch | 20 +- .../entity/projectile/EntityEnderPearl.patch | 46 +- .../entity/projectile/EntityEnderSignal.patch | 12 +- .../entity/projectile/EntityEvokerFangs.patch | 4 +- .../entity/projectile/EntityFireball.patch | 22 +- .../projectile/EntityFireballFireball.patch | 8 +- .../entity/projectile/EntityFireworks.patch | 34 +- .../entity/projectile/EntityFishingHook.patch | 82 +- .../projectile/EntityLargeFireball.patch | 29 +- .../entity/projectile/EntityLlamaSpit.patch | 12 +- .../entity/projectile/EntityPotion.patch | 60 +- .../entity/projectile/EntityProjectile.patch | 2 +- .../EntityProjectileThrowable.patch | 8 +- .../projectile/EntityShulkerBullet.patch | 28 +- .../projectile/EntitySmallFireball.patch | 14 +- .../projectile/EntitySpectralArrow.patch | 4 +- .../projectile/EntityThrownExpBottle.patch | 18 +- .../projectile/EntityThrownTrident.patch | 10 +- .../entity/projectile/EntityTippedArrow.patch | 26 +- .../entity/projectile/EntityWitherSkull.patch | 18 +- .../world/entity/projectile/IProjectile.patch | 23 +- .../world/entity/raid/EntityRaider.patch | 30 +- .../world/entity/raid/PersistentRaid.patch | 12 +- .../minecraft/world/entity/raid/Raid.patch | 64 +- .../world/entity/vehicle/EntityBoat.patch | 66 +- .../vehicle/EntityMinecartAbstract.patch | 106 +-- .../vehicle/EntityMinecartCommandBlock.patch | 4 +- .../vehicle/EntityMinecartContainer.patch | 19 +- .../minecraft/world/food/FoodMetaData.patch | 32 +- .../minecraft/world/inventory/Container.patch | 156 ++-- .../world/inventory/ContainerAccess.patch | 2 +- .../world/inventory/ContainerAnvil.patch | 83 +- .../inventory/ContainerAnvilAbstract.patch | 4 +- .../world/inventory/ContainerBeacon.patch | 21 +- .../inventory/ContainerBrewingStand.patch | 15 +- .../inventory/ContainerCartography.patch | 24 +- .../world/inventory/ContainerChest.patch | 11 +- .../world/inventory/ContainerDispenser.patch | 24 +- .../inventory/ContainerEnchantTable.patch | 61 +- .../world/inventory/ContainerFurnace.patch | 37 +- .../world/inventory/ContainerGrindstone.patch | 24 +- .../world/inventory/ContainerHopper.patch | 7 +- .../world/inventory/ContainerHorse.patch | 10 +- .../world/inventory/ContainerLectern.patch | 28 +- .../world/inventory/ContainerLoom.patch | 33 +- .../world/inventory/ContainerMerchant.patch | 30 +- .../world/inventory/ContainerPlayer.patch | 49 +- .../world/inventory/ContainerShulkerBox.patch | 11 +- .../world/inventory/ContainerSmithing.patch | 32 +- .../inventory/ContainerStonecutter.patch | 33 +- .../world/inventory/ContainerWorkbench.patch | 71 +- .../world/inventory/Containers.patch | 23 +- .../inventory/InventoryCraftResult.patch | 8 +- .../world/inventory/InventoryCrafting.patch | 10 +- .../world/inventory/InventoryEnderChest.patch | 7 +- .../world/inventory/InventoryMerchant.patch | 8 +- .../world/inventory/SlotFurnaceResult.patch | 12 +- .../net/minecraft/world/item/ItemArmor.patch | 12 +- .../minecraft/world/item/ItemArmorStand.patch | 6 +- .../net/minecraft/world/item/ItemBlock.patch | 36 +- .../net/minecraft/world/item/ItemBoat.patch | 10 +- .../minecraft/world/item/ItemBoneMeal.patch | 2 +- .../net/minecraft/world/item/ItemBow.patch | 10 +- .../net/minecraft/world/item/ItemBucket.patch | 60 +- .../world/item/ItemChorusFruit.patch | 4 +- .../minecraft/world/item/ItemCrossbow.patch | 6 +- .../minecraft/world/item/ItemDebugStick.patch | 2 +- .../net/minecraft/world/item/ItemDye.patch | 18 +- .../net/minecraft/world/item/ItemEgg.patch | 10 +- .../minecraft/world/item/ItemEndCrystal.patch | 4 +- .../minecraft/world/item/ItemEnderEye.patch | 2 +- .../minecraft/world/item/ItemEnderPearl.patch | 8 +- .../minecraft/world/item/ItemFireball.patch | 36 +- .../minecraft/world/item/ItemFishingRod.patch | 18 +- .../world/item/ItemFlintAndSteel.patch | 30 +- .../minecraft/world/item/ItemHanging.patch | 10 +- .../net/minecraft/world/item/ItemLeash.patch | 16 +- .../minecraft/world/item/ItemMilkBucket.patch | 2 +- .../minecraft/world/item/ItemMinecart.patch | 20 +- .../minecraft/world/item/ItemMonsterEgg.patch | 4 +- .../net/minecraft/world/item/ItemPotion.patch | 2 +- .../net/minecraft/world/item/ItemRecord.patch | 2 +- .../world/item/ItemSkullPlayer.patch | 11 +- .../minecraft/world/item/ItemSnowball.patch | 14 +- .../net/minecraft/world/item/ItemStack.patch | 55 +- .../minecraft/world/item/ItemTrident.patch | 18 +- .../minecraft/world/item/ItemWorldMap.patch | 23 +- .../world/item/crafting/CraftingManager.patch | 36 +- .../world/item/crafting/FurnaceRecipe.patch | 10 +- .../world/item/crafting/IRecipe.patch | 8 +- .../world/item/crafting/IRecipeComplex.patch | 2 +- .../world/item/crafting/RecipeBlasting.patch | 10 +- .../world/item/crafting/RecipeCampfire.patch | 10 +- .../world/item/crafting/RecipeItemStack.patch | 21 +- .../world/item/crafting/RecipeSmithing.patch | 14 +- .../world/item/crafting/RecipeSmoking.patch | 10 +- .../item/crafting/RecipeStonecutting.patch | 12 +- .../world/item/crafting/ShapedRecipes.patch | 12 +- .../item/crafting/ShapelessRecipes.patch | 4 +- .../enchantment/EnchantmentWeaponDamage.patch | 8 +- .../world/item/enchantment/Enchantments.patch | 4 +- .../world/item/trading/IMerchant.patch | 2 +- .../world/item/trading/MerchantRecipe.patch | 8 +- .../level/CommandBlockListenerAbstract.patch | 8 +- .../net/minecraft/world/level/Explosion.patch | 95 +- .../net/minecraft/world/level/GameRules.patch | 59 +- .../world/level/GeneratorAccess.patch | 6 +- .../minecraft/world/level/IBlockAccess.patch | 25 +- .../world/level/MobSpawnerAbstract.patch | 22 +- .../net/minecraft/world/level/RayTrace.patch | 16 +- .../world/level/SpawnerCreature.patch | 48 +- .../world/level/TickListServer.patch | 14 +- .../net/minecraft/world/level/World.patch | 158 ++-- .../minecraft/world/level/WorldAccess.patch | 9 +- .../world/level/block/AzaleaBlock.patch | 46 + .../minecraft/world/level/block/Block.patch | 12 +- .../world/level/block/BlockBamboo.patch | 28 +- .../level/block/BlockBambooSapling.patch | 6 +- .../world/level/block/BlockBed.patch | 6 +- .../world/level/block/BlockBeehive.patch | 2 +- .../level/block/BlockButtonAbstract.patch | 21 +- .../world/level/block/BlockCactus.patch | 6 +- .../world/level/block/BlockCake.patch | 4 +- .../world/level/block/BlockCampfire.patch | 20 +- .../world/level/block/BlockCauldron.patch | 176 ---- .../world/level/block/BlockChest.patch | 26 +- .../world/level/block/BlockChorusFlower.patch | 8 +- .../world/level/block/BlockCocoa.patch | 6 +- .../world/level/block/BlockCommand.patch | 8 +- .../world/level/block/BlockComposter.patch | 92 +- .../level/block/BlockConcretePowder.patch | 21 +- .../world/level/block/BlockCoral.patch | 4 +- .../world/level/block/BlockCoralFan.patch | 8 +- .../world/level/block/BlockCoralFanWall.patch | 8 +- .../world/level/block/BlockCoralPlant.patch | 8 +- .../world/level/block/BlockCrops.patch | 14 +- .../level/block/BlockDaylightDetector.patch | 12 +- .../level/block/BlockDiodeAbstract.patch | 6 +- .../level/block/BlockDirtSnowSpreadable.patch | 6 +- .../world/level/block/BlockDispenser.patch | 15 +- .../world/level/block/BlockDoor.patch | 8 +- .../world/level/block/BlockDragonEgg.patch | 4 +- .../world/level/block/BlockDropper.patch | 6 +- .../world/level/block/BlockEnderPortal.patch | 10 +- .../world/level/block/BlockFenceGate.patch | 2 +- .../world/level/block/BlockFire.patch | 22 +- .../world/level/block/BlockFireAbstract.patch | 12 +- .../world/level/block/BlockFluids.patch | 46 +- .../world/level/block/BlockFungi.patch | 4 +- .../world/level/block/BlockGrass.patch | 2 +- .../world/level/block/BlockGrowingTop.patch | 10 +- .../world/level/block/BlockJukeBox.patch | 2 +- .../world/level/block/BlockLeaves.patch | 6 +- .../world/level/block/BlockLectern.patch | 4 +- .../world/level/block/BlockLever.patch | 6 +- .../world/level/block/BlockMagma.patch | 6 +- .../level/block/BlockMinecartDetector.patch | 6 +- .../world/level/block/BlockMobSpawner.patch | 2 +- .../world/level/block/BlockMonsterEggs.patch | 8 +- .../world/level/block/BlockMushroom.patch | 22 +- .../world/level/block/BlockNetherWart.patch | 2 +- .../world/level/block/BlockObserver.patch | 8 +- .../world/level/block/BlockOre.patch | 8 +- .../world/level/block/BlockPlant.patch | 2 +- .../world/level/block/BlockPortal.patch | 8 +- .../world/level/block/BlockPoweredRail.patch | 4 +- .../block/BlockPressurePlateAbstract.patch | 6 +- .../block/BlockPressurePlateBinary.patch | 2 +- .../block/BlockPressurePlateWeighted.patch | 10 +- .../level/block/BlockPumpkinCarved.patch | 2 +- .../level/block/BlockRedstoneComparator.patch | 12 +- .../world/level/block/BlockRedstoneLamp.patch | 8 +- .../world/level/block/BlockRedstoneOre.patch | 30 +- .../level/block/BlockRedstoneTorch.patch | 6 +- .../world/level/block/BlockRedstoneWire.patch | 15 +- .../world/level/block/BlockReed.patch | 2 +- .../world/level/block/BlockSapling.patch | 11 +- .../world/level/block/BlockScaffolding.patch | 12 +- .../world/level/block/BlockSnow.patch | 2 +- .../world/level/block/BlockSoil.patch | 16 +- .../world/level/block/BlockSponge.patch | 24 +- .../world/level/block/BlockStem.patch | 16 +- .../level/block/BlockSweetBerryBush.patch | 20 +- .../world/level/block/BlockTNT.patch | 8 +- .../world/level/block/BlockTallPlant.patch | 2 +- .../world/level/block/BlockTrapdoor.patch | 8 +- .../world/level/block/BlockTripwire.patch | 6 +- .../world/level/block/BlockTripwireHook.patch | 4 +- .../world/level/block/BlockTurtleEgg.patch | 58 +- .../world/level/block/BlockVine.patch | 10 +- .../world/level/block/BlockWitherRose.patch | 2 +- .../world/level/block/BlockWitherSkull.patch | 4 +- .../level/block/BuddingAmethystBlock.patch | 11 + .../world/level/block/CaveVines.patch | 48 + .../world/level/block/CaveVinesBlock.patch | 11 + .../level/block/CaveVinesPlantBlock.patch | 11 + .../level/block/ChangeOverTimeBlock.patch | 11 + .../level/block/LayeredCauldronBlock.patch | 85 ++ .../world/level/block/LightningRodBlock.patch | 42 + .../world/level/block/MultifaceBlock.patch | 47 + .../level/block/PointedDripstoneBlock.patch | 90 ++ .../world/level/block/PowderSnowBlock.patch | 16 + .../world/level/block/RootedDirtBlock.patch | 10 + .../world/level/block/SculkSensorBlock.patch | 52 ++ .../entity/ContainerOpenersCounter.patch | 58 ++ .../world/level/block/entity/TileEntity.patch | 39 +- .../level/block/entity/TileEntityBanner.patch | 12 +- .../level/block/entity/TileEntityBarrel.patch | 16 +- .../level/block/entity/TileEntityBeacon.patch | 100 +- .../block/entity/TileEntityBeehive.patch | 80 +- .../block/entity/TileEntityBrewingStand.patch | 78 +- .../block/entity/TileEntityCampfire.patch | 18 +- .../level/block/entity/TileEntityChest.patch | 90 +- .../block/entity/TileEntityCommand.patch | 6 +- .../block/entity/TileEntityConduit.patch | 44 +- .../block/entity/TileEntityContainer.patch | 6 +- .../block/entity/TileEntityDispenser.patch | 11 +- .../block/entity/TileEntityEndGateway.patch | 38 +- .../block/entity/TileEntityFurnace.patch | 147 +-- .../level/block/entity/TileEntityHopper.patch | 76 +- .../block/entity/TileEntityLectern.patch | 38 +- .../block/entity/TileEntityShulkerBox.patch | 42 +- .../level/block/entity/TileEntitySign.patch | 93 +- .../grower/WorldGenMegaTreeProvider.patch | 6 +- .../block/grower/WorldGenTreeProvider.patch | 8 +- .../level/block/piston/BlockPiston.patch | 12 +- .../state/properties/BlockStateInteger.patch | 2 +- .../world/level/border/WorldBorder.patch | 14 +- .../world/level/chunk/BiomeStorage.patch | 12 +- .../minecraft/world/level/chunk/Chunk.patch | 201 ++-- .../world/level/chunk/ChunkGenerator.patch | 26 +- .../world/level/chunk/ChunkStatus.patch | 16 +- .../chunk/storage/ChunkRegionLoader.patch | 59 +- .../level/chunk/storage/IChunkLoader.patch | 6 +- .../level/chunk/storage/RegionFile.patch | 64 +- .../level/chunk/storage/RegionFileCache.patch | 32 +- .../levelgen/ChunkGeneratorAbstract.patch | 32 - .../level/levelgen/GeneratorSettings.patch | 36 +- .../level/levelgen/MobSpawnerPatrol.patch | 2 +- .../world/level/levelgen/NoiseSampler.patch | 23 + .../level/levelgen/StructureSettings.patch | 24 +- .../structure/PersistentStructureLegacy.patch | 20 +- .../levelgen/structure/WorldGenWitchHut.patch | 12 +- .../templatesystem/DefinedStructure.patch | 22 +- .../DefinedStructureManager.patch | 11 - .../level/material/FluidTypeFlowing.patch | 8 +- .../world/level/material/FluidTypeLava.patch | 6 +- .../world/level/portal/BlockPortalShape.patch | 62 +- .../level/portal/PortalTravelAgent.patch | 58 +- .../level/portal/ShapeDetectorShape.patch | 14 +- .../world/level/saveddata/maps/WorldMap.patch | 133 +-- .../world/level/storage/Convertable.patch | 56 +- .../world/level/storage/WorldDataServer.patch | 75 +- .../world/level/storage/WorldNBTStorage.patch | 2 +- .../world/level/storage/loot/LootTable.patch | 6 +- .../storage/loot/LootTableRegistry.patch | 24 +- .../loot/entries/LootEntryAbstract.patch | 20 - .../loot/functions/LootEnchantFunction.patch | 8 +- .../parameters/LootContextParameters.patch | 4 +- ...ItemConditionRandomChanceWithLooting.patch | 2 +- pom.xml | 123 ++- .../org/bukkit/craftbukkit/CraftChunk.java | 57 +- .../craftbukkit/CraftChunkSnapshot.java | 41 +- .../bukkit/craftbukkit/CraftCrashReport.java | 6 +- .../craftbukkit/CraftOfflinePlayer.java | 2 +- .../org/bukkit/craftbukkit/CraftParticle.java | 52 +- .../org/bukkit/craftbukkit/CraftRaid.java | 2 +- .../org/bukkit/craftbukkit/CraftServer.java | 75 +- .../bukkit/craftbukkit/CraftStatistic.java | 7 +- .../org/bukkit/craftbukkit/CraftWorld.java | 202 ++-- .../java/org/bukkit/craftbukkit/Main.java | 8 +- .../bukkit/craftbukkit/block/CraftBanner.java | 10 +- .../bukkit/craftbukkit/block/CraftBarrel.java | 12 +- .../bukkit/craftbukkit/block/CraftBeacon.java | 14 +- .../craftbukkit/block/CraftBeehive.java | 4 +- .../bukkit/craftbukkit/block/CraftBlock.java | 6 +- .../block/CraftBlockEntityState.java | 7 +- .../craftbukkit/block/CraftBlockState.java | 4 +- .../craftbukkit/block/CraftBrewingStand.java | 4 +- .../craftbukkit/block/CraftCampfire.java | 8 +- .../bukkit/craftbukkit/block/CraftChest.java | 21 +- .../craftbukkit/block/CraftContainer.java | 10 +- .../block/CraftCreatureSpawner.java | 5 +- .../craftbukkit/block/CraftFurnace.java | 12 +- .../craftbukkit/block/CraftLectern.java | 4 +- .../craftbukkit/block/CraftSculkSensor.java | 29 + .../craftbukkit/block/CraftShulkerBox.java | 4 +- .../bukkit/craftbukkit/block/CraftSign.java | 16 +- .../bukkit/craftbukkit/block/CraftSkull.java | 2 +- .../block/CraftStructureBlock.java | 14 +- .../block/data/CraftBlockData.java | 30 +- .../block/data/type/CraftBigDripleaf.java | 19 + .../block/data/type/CraftCandle.java | 24 + .../block/data/type/CraftCaveVinesPlant.java | 19 + .../data/type/CraftPointedDripstone.java | 35 + .../block/data/type/CraftSculkSensor.java | 19 + .../block/impl/CraftAmethystCluster.java | 48 + .../block/impl/CraftBigDripleaf.java | 62 ++ .../block/impl/CraftBigDripleafStem.java | 48 + .../craftbukkit/block/impl/CraftCandle.java | 62 ++ .../block/impl/CraftCandleCake.java | 29 + .../block/impl/CraftCaveVines.java | 48 + .../block/impl/CraftCaveVinesPlant.java | 29 + .../block/impl/CraftGlowLichen.java | 79 ++ .../block/impl/CraftHangingRoots.java | 29 + .../impl/CraftInfestedRotatedPillar.java | 34 + .../block/impl/CraftLayeredCauldron.java | 34 + .../craftbukkit/block/impl/CraftLight.java | 48 + .../block/impl/CraftLightningRod.java | 62 ++ .../block/impl/CraftMinecartDetector.java | 16 +- .../block/impl/CraftMinecartTrack.java | 16 +- .../block/impl/CraftPointedDripstone.java | 59 ++ .../block/impl/CraftPowderSnowCauldron.java | 34 + .../block/impl/CraftPoweredRail.java | 16 +- .../block/impl/CraftSculkSensor.java | 62 ++ .../block/impl/CraftSmallDripleaf.java | 48 + ...llSeaGrass.java => CraftTallSeagrass.java} | 8 +- .../block/impl/CraftWeatheringCopperSlab.java | 43 + .../impl/CraftWeatheringCopperStair.java | 76 ++ .../bukkit/craftbukkit/boss/CraftBossBar.java | 16 +- .../craftbukkit/boss/CraftDragonBattle.java | 14 +- .../command/CraftBlockCommandSender.java | 2 +- .../CraftRemoteConsoleCommandSender.java | 2 +- .../command/VanillaCommandWrapper.java | 2 +- .../enchantments/CraftEnchantment.java | 6 +- .../entity/CraftAbstractHorse.java | 2 +- .../craftbukkit/entity/CraftAnimals.java | 6 +- .../craftbukkit/entity/CraftArmorStand.java | 2 +- .../bukkit/craftbukkit/entity/CraftArrow.java | 8 +- .../craftbukkit/entity/CraftAxolotl.java | 50 + .../bukkit/craftbukkit/entity/CraftBee.java | 2 +- .../craftbukkit/entity/CraftComplexPart.java | 2 +- .../craftbukkit/entity/CraftCreeper.java | 8 +- .../craftbukkit/entity/CraftEnderDragon.java | 6 +- .../craftbukkit/entity/CraftEnderSignal.java | 12 +- .../craftbukkit/entity/CraftEndermite.java | 4 +- .../craftbukkit/entity/CraftEntity.java | 90 +- .../craftbukkit/entity/CraftFallingBlock.java | 2 +- .../craftbukkit/entity/CraftFireball.java | 2 +- .../craftbukkit/entity/CraftFirework.java | 12 +- .../craftbukkit/entity/CraftFishHook.java | 14 +- .../bukkit/craftbukkit/entity/CraftFox.java | 12 +- .../entity/CraftGlowItemFrame.java | 27 + .../craftbukkit/entity/CraftGlowSquid.java | 39 + .../bukkit/craftbukkit/entity/CraftGoat.java | 37 + .../craftbukkit/entity/CraftHanging.java | 4 +- .../craftbukkit/entity/CraftHoglin.java | 6 +- .../bukkit/craftbukkit/entity/CraftHorse.java | 2 +- .../craftbukkit/entity/CraftHumanEntity.java | 74 +- .../craftbukkit/entity/CraftItemFrame.java | 8 +- .../entity/CraftLargeFireball.java | 2 +- .../entity/CraftLightningStrike.java | 2 +- .../craftbukkit/entity/CraftLivingEntity.java | 56 +- .../bukkit/craftbukkit/entity/CraftLlama.java | 2 +- .../craftbukkit/entity/CraftMarker.java | 27 + .../entity/CraftMinecartCommand.java | 2 +- .../bukkit/craftbukkit/entity/CraftMob.java | 8 +- .../craftbukkit/entity/CraftPainting.java | 8 +- .../bukkit/craftbukkit/entity/CraftPig.java | 14 +- .../craftbukkit/entity/CraftPiglin.java | 2 +- .../entity/CraftPiglinAbstract.java | 6 +- .../craftbukkit/entity/CraftPlayer.java | 226 ++--- .../craftbukkit/entity/CraftRaider.java | 2 +- .../craftbukkit/entity/CraftShulker.java | 12 +- .../craftbukkit/entity/CraftStrider.java | 14 +- .../craftbukkit/entity/CraftTNTPrimed.java | 4 +- .../craftbukkit/entity/CraftTrident.java | 4 +- .../craftbukkit/entity/CraftVillager.java | 2 +- .../entity/CraftVillagerZombie.java | 16 +- .../craftbukkit/entity/CraftWither.java | 4 +- .../craftbukkit/entity/CraftZombie.java | 6 +- .../entity/memory/CraftMemoryMapper.java | 4 + .../craftbukkit/event/CraftEventFactory.java | 109 ++- .../craftbukkit/generator/CraftChunkData.java | 31 +- .../generator/CustomChunkGenerator.java | 38 +- .../craftbukkit/inventory/CraftContainer.java | 61 +- .../inventory/CraftEntityEquipment.java | 8 +- .../inventory/CraftInventoryAnvil.java | 6 +- .../inventory/CraftInventoryCrafting.java | 2 +- .../inventory/CraftInventoryCustom.java | 10 +- .../inventory/CraftInventoryDoubleChest.java | 16 +- .../inventory/CraftInventoryMerchant.java | 2 +- .../inventory/CraftInventoryPlayer.java | 16 +- .../inventory/CraftInventorySmithing.java | 2 +- .../inventory/CraftItemFactory.java | 3 + .../craftbukkit/inventory/CraftItemStack.java | 9 +- .../inventory/CraftMerchantCustom.java | 10 +- .../inventory/CraftMerchantRecipe.java | 14 +- .../inventory/CraftMetaBlockState.java | 77 +- .../inventory/CraftMetaBundle.java | 186 ++++ .../inventory/CraftMetaCompass.java | 4 +- .../craftbukkit/inventory/CraftMetaItem.java | 4 +- .../craftbukkit/inventory/CraftMetaSkull.java | 7 +- .../craftbukkit/inventory/CraftRecipe.java | 14 +- .../inventory/CraftShapedRecipe.java | 2 +- .../inventory/CraftShapelessRecipe.java | 2 +- .../util/CraftTileInventoryConverter.java | 18 +- .../craftbukkit/legacy/CraftLegacy.java | 4 +- .../craftbukkit/map/CraftMapRenderer.java | 4 +- .../bukkit/craftbukkit/map/CraftMapView.java | 18 +- .../CraftBlockProjectileSource.java | 18 +- .../craftbukkit/scoreboard/CraftCriteria.java | 6 +- .../scoreboard/CraftScoreboardManager.java | 4 +- .../bukkit/craftbukkit/util/Commodore.java | 3 + .../craftbukkit/util/CraftChatMessage.java | 6 +- .../craftbukkit/util/CraftDamageSource.java | 2 +- .../craftbukkit/util/CraftDimensionUtil.java | 10 +- .../craftbukkit/util/CraftMagicNumbers.java | 12 +- .../util/DummyGeneratorAccess.java | 38 +- src/test/java/org/bukkit/BiomeTest.java | 6 +- src/test/java/org/bukkit/GameEventTest.java | 19 + src/test/java/org/bukkit/ParticleTest.java | 4 + src/test/java/org/bukkit/PerMaterialTest.java | 7 +- .../bukkit/StatisticsAndAchievementsTest.java | 2 +- .../craftbukkit/generator/ChunkDataTest.java | 13 +- .../craftbukkit/inventory/ItemMetaTest.java | 9 + .../inventory/NMSCraftItemStackTest.java | 2 +- .../bukkit/craftbukkit/legacy/LegacyTest.java | 19 + .../bukkit/entity/EnderDragonPhaseTest.java | 4 +- .../entity/memory/CraftMemoryKeyTest.java | 2 +- src/test/java/org/bukkit/map/MapTest.java | 4 +- .../bukkit/support/AbstractTestingBase.java | 10 +- .../org/bukkit/support/DummyEnchantments.java | 2 +- src/test/java/org/bukkit/support/Util.java | 31 - 619 files changed, 10708 insertions(+), 8451 deletions(-) create mode 100644 nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch delete mode 100644 nms-patches/net/minecraft/network/chat/ChatModifier.patch create mode 100644 nms-patches/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.patch create mode 100644 nms-patches/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.patch delete mode 100644 nms-patches/net/minecraft/network/protocol/game/PacketPlayInCloseWindow.patch delete mode 100644 nms-patches/net/minecraft/network/protocol/game/PacketPlayOutWorldBorder.patch delete mode 100644 nms-patches/net/minecraft/server/commands/CommandGamemode.patch create mode 100644 nms-patches/net/minecraft/server/players/SleepStatus.patch create mode 100644 nms-patches/net/minecraft/world/entity/animal/Bucketable.patch create mode 100644 nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch create mode 100644 nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch create mode 100644 nms-patches/net/minecraft/world/level/block/AzaleaBlock.patch delete mode 100644 nms-patches/net/minecraft/world/level/block/BlockCauldron.patch create mode 100644 nms-patches/net/minecraft/world/level/block/BuddingAmethystBlock.patch create mode 100644 nms-patches/net/minecraft/world/level/block/CaveVines.patch create mode 100644 nms-patches/net/minecraft/world/level/block/CaveVinesBlock.patch create mode 100644 nms-patches/net/minecraft/world/level/block/CaveVinesPlantBlock.patch create mode 100644 nms-patches/net/minecraft/world/level/block/ChangeOverTimeBlock.patch create mode 100644 nms-patches/net/minecraft/world/level/block/LayeredCauldronBlock.patch create mode 100644 nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch create mode 100644 nms-patches/net/minecraft/world/level/block/MultifaceBlock.patch create mode 100644 nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch create mode 100644 nms-patches/net/minecraft/world/level/block/PowderSnowBlock.patch create mode 100644 nms-patches/net/minecraft/world/level/block/RootedDirtBlock.patch create mode 100644 nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch create mode 100644 nms-patches/net/minecraft/world/level/block/entity/ContainerOpenersCounter.patch delete mode 100644 nms-patches/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.patch create mode 100644 nms-patches/net/minecraft/world/level/levelgen/NoiseSampler.patch delete mode 100644 nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureManager.patch delete mode 100644 nms-patches/net/minecraft/world/level/storage/loot/entries/LootEntryAbstract.patch create mode 100644 src/main/java/org/bukkit/craftbukkit/block/CraftSculkSensor.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBigDripleaf.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCandle.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCaveVinesPlant.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPointedDripstone.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSculkSensor.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftAmethystCluster.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleaf.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleafStem.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftCandle.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftCandleCake.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftCaveVines.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftCaveVinesPlant.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftGlowLichen.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftHangingRoots.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftInfestedRotatedPillar.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftLayeredCauldron.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftLight.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftLightningRod.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftPointedDripstone.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftPowderSnowCauldron.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftSculkSensor.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftSmallDripleaf.java rename src/main/java/org/bukkit/craftbukkit/block/impl/{CraftTallSeaGrass.java => CraftTallSeagrass.java} (77%) create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperSlab.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperStair.java create mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java create mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftGlowItemFrame.java create mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftGlowSquid.java create mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftGoat.java create mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftMarker.java create mode 100644 src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java create mode 100644 src/test/java/org/bukkit/GameEventTest.java delete mode 100644 src/test/java/org/bukkit/support/Util.java diff --git a/nms-patches/net/minecraft/CrashReport.patch b/nms-patches/net/minecraft/CrashReport.patch index ba2b8b921..7b223b64c 100644 --- a/nms-patches/net/minecraft/CrashReport.patch +++ b/nms-patches/net/minecraft/CrashReport.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/CrashReport.java +++ b/net/minecraft/CrashReport.java -@@ -68,6 +68,7 @@ - - return String.format("%d total; %s", list.size(), list.stream().collect(Collectors.joining(" "))); - }); -+ this.d.a("CraftBukkit Information", (CrashReportCallable) new org.bukkit.craftbukkit.CraftCrashReport()); // CraftBukkit +@@ -31,6 +31,7 @@ + public CrashReport(String s, Throwable throwable) { + this.title = s; + this.exception = throwable; ++ this.systemReport.a("CraftBukkit Information", new org.bukkit.craftbukkit.CraftCrashReport()); // CraftBukkit } public String a() { diff --git a/nms-patches/net/minecraft/advancements/Advancement.patch b/nms-patches/net/minecraft/advancements/Advancement.patch index 9cdb7960f..963fa13e6 100644 --- a/nms-patches/net/minecraft/advancements/Advancement.patch +++ b/nms-patches/net/minecraft/advancements/Advancement.patch @@ -7,8 +7,8 @@ + public final org.bukkit.advancement.Advancement bukkit = new org.bukkit.craftbukkit.advancement.CraftAdvancement(this); // CraftBukkit public Advancement(MinecraftKey minecraftkey, @Nullable Advancement advancement, @Nullable AdvancementDisplay advancementdisplay, AdvancementRewards advancementrewards, Map map, String[][] astring) { - this.key = minecraftkey; -@@ -222,7 +223,7 @@ + this.id = minecraftkey; +@@ -233,7 +234,7 @@ } public Advancement b(MinecraftKey minecraftkey) { diff --git a/nms-patches/net/minecraft/advancements/Advancements.patch b/nms-patches/net/minecraft/advancements/Advancements.patch index 74e1b52fa..e54379663 100644 --- a/nms-patches/net/minecraft/advancements/Advancements.patch +++ b/nms-patches/net/minecraft/advancements/Advancements.patch @@ -1,6 +1,15 @@ --- a/net/minecraft/advancements/Advancements.java +++ b/net/minecraft/advancements/Advancements.java -@@ -73,7 +73,7 @@ +@@ -79,7 +79,7 @@ + entry = (Entry) iterator.next(); + MinecraftKey minecraftkey = (MinecraftKey) entry.getKey(); + Advancement.SerializedAdvancement advancement_serializedadvancement = (Advancement.SerializedAdvancement) entry.getValue(); +- Map map1 = this.advancements; ++ Map map1 = this.advancements; // CraftBukkit - decompile error + + Objects.requireNonNull(this.advancements); + if (advancement_serializedadvancement.a(map1::get)) { +@@ -116,7 +116,7 @@ } } @@ -8,4 +17,4 @@ + // Advancements.LOGGER.info("Loaded {} advancements", this.advancements.size()); // CraftBukkit - moved to AdvancementDataWorld#reload } - public Iterable b() { + public void a() { diff --git a/nms-patches/net/minecraft/commands/CommandDispatcher.patch b/nms-patches/net/minecraft/commands/CommandDispatcher.patch index ef71fa55f..0f62a9a3e 100644 --- a/nms-patches/net/minecraft/commands/CommandDispatcher.patch +++ b/nms-patches/net/minecraft/commands/CommandDispatcher.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/CommandDispatcher.java +++ b/net/minecraft/commands/CommandDispatcher.java -@@ -102,12 +102,21 @@ +@@ -103,6 +103,14 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -15,27 +15,28 @@ public class CommandDispatcher { private static final Logger LOGGER = LogManager.getLogger(); - private final com.mojang.brigadier.CommandDispatcher b = new com.mojang.brigadier.CommandDispatcher(); +@@ -114,6 +122,7 @@ + private final com.mojang.brigadier.CommandDispatcher dispatcher = new com.mojang.brigadier.CommandDispatcher(); public CommandDispatcher(CommandDispatcher.ServerType commanddispatcher_servertype) { + this(); // CraftBukkit - CommandAdvancement.a(this.b); - CommandAttribute.a(this.b); - CommandExecute.a(this.b); -@@ -188,17 +197,61 @@ + CommandAdvancement.a(this.dispatcher); + CommandAttribute.a(this.dispatcher); + CommandExecute.a(this.dispatcher); +@@ -195,17 +204,61 @@ } - this.b.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> { -- CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.b.getPath(commandnode1), this.b.getPath(commandnode2), collection); + 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 }); -- this.b.setConsumer((commandcontext, flag, i) -> { +- this.dispatcher.setConsumer((commandcontext, flag, i) -> { - ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag, i); + } + + // CraftBukkit start + public CommandDispatcher() { -+ this.b.setConsumer((commandcontext, flag1, i) -> { ++ this.dispatcher.setConsumer((commandcontext, flag1, i) -> { + ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag1, i); }); } @@ -88,7 +89,7 @@ stringreader.skip(); } -@@ -222,7 +275,7 @@ +@@ -229,7 +282,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) -> { @@ -97,7 +98,7 @@ }); if (j > 10) { -@@ -272,11 +325,36 @@ +@@ -279,11 +332,36 @@ } public void a(EntityPlayer entityplayer) { @@ -114,8 +115,8 @@ + // Now build the global commands in a second pass RootCommandNode rootcommandnode = new RootCommandNode(); - map.put(this.b.getRoot(), rootcommandnode); - this.a(this.b.getRoot(), rootcommandnode, entityplayer.getCommandListener(), (Map) map); + map.put(this.dispatcher.getRoot(), rootcommandnode); + this.a(this.dispatcher.getRoot(), rootcommandnode, entityplayer.getCommandListener(), (Map) map); + + Collection bukkit = new LinkedHashSet<>(); + for (CommandNode node : rootcommandnode.getChildren()) { @@ -132,10 +133,10 @@ + } + } + // CraftBukkit end - entityplayer.playerConnection.sendPacket(new PacketPlayOutCommands(rootcommandnode)); + entityplayer.connection.sendPacket(new PacketPlayOutCommands(rootcommandnode)); } -@@ -287,7 +365,7 @@ +@@ -294,7 +372,7 @@ CommandNode commandnode2 = (CommandNode) iterator.next(); if (commandnode2.canUse(commandlistenerwrapper)) { @@ -144,7 +145,7 @@ argumentbuilder.requires((icompletionprovider) -> { return true; -@@ -310,7 +388,7 @@ +@@ -317,7 +395,7 @@ argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect())); } diff --git a/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch b/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch index f7ead9df2..f430b1410 100644 --- a/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch +++ b/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch @@ -8,16 +8,16 @@ + public class CommandListenerWrapper implements ICompletionProvider { - public static final SimpleCommandExceptionType a = new SimpleCommandExceptionType(new ChatMessage("permissions.requires.player")); + public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(new ChatMessage("permissions.requires.player")); @@ -53,6 +55,7 @@ - private final ResultConsumer l; - private final ArgumentAnchor.Anchor m; - private final Vec2F n; + private final ResultConsumer consumer; + private final ArgumentAnchor.Anchor anchor; + private final Vec2F rotation; + public volatile CommandNode currentCommand; // CraftBukkit 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) -> { -@@ -149,9 +152,23 @@ +@@ -153,9 +156,23 @@ @Override public boolean hasPermission(int i) { @@ -28,36 +28,36 @@ + } + // CraftBukkit end + - return this.f >= i; + return this.permissionLevel >= i; } + // CraftBukkit start + public boolean hasPermission(int i, String bukkitPermission) { + // World is null when loading functions -+ return ((getWorld() == null || !getWorld().getServer().ignoreVanillaPermissions) && this.f >= i) || getBukkitSender().hasPermission(bukkitPermission); ++ return ((getWorld() == null || !getWorld().getServer().ignoreVanillaPermissions) && this.permissionLevel >= i) || getBukkitSender().hasPermission(bukkitPermission); + } + // CraftBukkit end + public Vec3D getPosition() { - return this.d; + return this.worldPosition; } -@@ -213,7 +230,7 @@ +@@ -217,7 +234,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -- if (entityplayer != this.base && this.i.getPlayerList().isOp(entityplayer.getProfile())) { -+ if (entityplayer != this.base && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit - entityplayer.sendMessage(ichatmutablecomponent, SystemUtils.b); +- if (entityplayer != this.source && this.server.getPlayerList().isOp(entityplayer.getProfile())) { ++ if (entityplayer != this.source && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit + entityplayer.sendMessage(ichatmutablecomponent, SystemUtils.NIL_UUID); } } -@@ -273,4 +290,10 @@ +@@ -277,4 +294,10 @@ public IRegistryCustom q() { - return this.i.getCustomRegistry(); + return this.server.getCustomRegistry(); } + + // CraftBukkit start + public org.bukkit.command.CommandSender getBukkitSender() { -+ return base.getBukkitSender(this); ++ return source.getBukkitSender(this); + } + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/commands/ICommandListener.patch b/nms-patches/net/minecraft/commands/ICommandListener.patch index f5c90c937..726bc17dc 100644 --- a/nms-patches/net/minecraft/commands/ICommandListener.patch +++ b/nms-patches/net/minecraft/commands/ICommandListener.patch @@ -14,10 +14,10 @@ }; void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid); -@@ -32,4 +39,6 @@ - boolean shouldSendFailure(); - - boolean shouldBroadcastCommands(); +@@ -36,4 +43,6 @@ + default boolean c_() { + return false; + } + + org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper); // CraftBukkit } diff --git a/nms-patches/net/minecraft/commands/arguments/ArgumentEntity.patch b/nms-patches/net/minecraft/commands/arguments/ArgumentEntity.patch index 4e1b63cb8..7818666e2 100644 --- a/nms-patches/net/minecraft/commands/arguments/ArgumentEntity.patch +++ b/nms-patches/net/minecraft/commands/arguments/ArgumentEntity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/ArgumentEntity.java +++ b/net/minecraft/commands/arguments/ArgumentEntity.java -@@ -93,9 +93,15 @@ +@@ -95,9 +95,15 @@ } public EntitySelector parse(StringReader stringreader) throws CommandSyntaxException { @@ -15,5 +15,5 @@ - EntitySelector entityselector = argumentparserselector.parse(); + EntitySelector entityselector = argumentparserselector.parse(overridePermissions); // CraftBukkit - if (entityselector.a() > 1 && this.h) { - if (this.i) { + if (entityselector.a() > 1 && this.single) { + if (this.playersOnly) { diff --git a/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch b/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch index 2674169a9..379459963 100644 --- a/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch +++ b/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/commands/arguments/blocks/ArgumentBlock.java +++ b/net/minecraft/commands/arguments/blocks/ArgumentBlock.java -@@ -55,7 +55,7 @@ +@@ -61,7 +61,7 @@ }; - private final StringReader i; - private final boolean j; -- private final Map, Comparable> k = Maps.newHashMap(); -+ private final Map, Comparable> k = Maps.newLinkedHashMap(); // CraftBukkit - stable - private final Map l = Maps.newHashMap(); - private MinecraftKey m = new MinecraftKey(""); - private BlockStateList n; -@@ -231,7 +231,7 @@ + private final StringReader reader; + private final boolean forTesting; +- private final Map, Comparable> properties = Maps.newHashMap(); ++ private final Map, Comparable> properties = Maps.newLinkedHashMap(); // CraftBukkit - stable + private final Map vagueProperties = Maps.newHashMap(); + private MinecraftKey id = new MinecraftKey(""); + private BlockStateList definition; +@@ -237,7 +237,7 @@ Iterator iterator = iblockstate.getValues().iterator(); while (iterator.hasNext()) { @@ -18,16 +18,16 @@ if (t0 instanceof Integer) { suggestionsbuilder.suggest((Integer) t0); -@@ -500,7 +500,7 @@ +@@ -506,7 +506,7 @@ Optional optional = iblockstate.b(s); if (optional.isPresent()) { -- this.o = (IBlockData) this.o.set(iblockstate, (Comparable) optional.get()); -+ this.o = (IBlockData) this.o.set(iblockstate, (T) optional.get()); // CraftBukkit - decompile error - this.k.put(iblockstate, optional.get()); +- this.state = (IBlockData) this.state.set(iblockstate, (Comparable) optional.get()); ++ this.state = (IBlockData) this.state.set(iblockstate, (T) optional.get()); // CraftBukkit - decompile error + this.properties.put(iblockstate, (Comparable) optional.get()); } else { - this.i.setCursor(i); -@@ -534,7 +534,7 @@ + this.reader.setCursor(i); +@@ -540,7 +540,7 @@ private static > void a(StringBuilder stringbuilder, IBlockState iblockstate, Comparable comparable) { stringbuilder.append(iblockstate.getName()); stringbuilder.append('='); diff --git a/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch b/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch index a89f264fc..03f13fe98 100644 --- a/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch +++ b/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch @@ -1,28 +1,28 @@ --- a/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java +++ b/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java -@@ -137,7 +137,7 @@ - axisalignedbb = this.a(this.v == null ? 0.0D : this.v, this.w == null ? 0.0D : this.w, this.x == null ? 0.0D : this.x); +@@ -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); } - Function function; + Function function; // CraftBukkit - decompile error - if (this.s == null && this.t == null && this.u == null) { + if (this.x == null && this.y == null && this.z == null) { function = (vec3d) -> { -@@ -198,8 +198,10 @@ +@@ -206,8 +206,10 @@ }; } - protected void parseSelector() throws CommandSyntaxException { -- this.checkPermissions = true; +- this.usesSelectors = true; + // CraftBukkit start + protected void parseSelector(boolean overridePermissions) throws CommandSyntaxException { -+ this.checkPermissions = !overridePermissions; ++ this.usesSelectors = !overridePermissions; + // CraftBukkit end - this.G = this::d; - if (!this.l.canRead()) { - throw ArgumentParserSelector.d.createWithContext(this.l); -@@ -453,6 +455,12 @@ + this.suggestions = this::d; + if (!this.reader.canRead()) { + throw ArgumentParserSelector.ERROR_MISSING_SELECTOR_TYPE.createWithContext(this.reader); +@@ -465,6 +467,12 @@ } public EntitySelector parse() throws CommandSyntaxException { @@ -32,13 +32,13 @@ + + public EntitySelector parse(boolean overridePermissions) throws CommandSyntaxException { + // CraftBukkit end - this.E = this.l.getCursor(); - this.G = this::b; - if (this.l.canRead() && this.l.peek() == '@') { -@@ -461,7 +469,7 @@ + this.startPosition = this.reader.getCursor(); + this.suggestions = this::b; + if (this.reader.canRead() && this.reader.peek() == '@') { +@@ -473,7 +481,7 @@ } - this.l.skip(); + this.reader.skip(); - this.parseSelector(); + this.parseSelector(overridePermissions); // CraftBukkit } else { diff --git a/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch b/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch index 708581b9e..06ffb3ce2 100644 --- a/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch +++ b/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/net/minecraft/commands/arguments/selector/EntitySelector.java -@@ -75,7 +75,7 @@ +@@ -90,7 +90,7 @@ } private void e(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException { -- if (this.checkPermissions && !commandlistenerwrapper.hasPermission(2)) { -+ if (this.checkPermissions && !commandlistenerwrapper.hasPermission(2, "minecraft.command.selector")) { // CraftBukkit - throw ArgumentEntity.f.create(); +- 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/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch b/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch new file mode 100644 index 000000000..ef9a83a08 --- /dev/null +++ b/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch @@ -0,0 +1,173 @@ +--- 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; + import net.minecraft.world.level.gameevent.GameEvent; + ++// CraftBukkit start ++import org.bukkit.event.block.CauldronLevelChangeEvent; ++// CraftBukkit end ++ + public interface CauldronInteraction { + + Map EMPTY = a(); +@@ -52,6 +56,11 @@ + return EnumInteractionResult.PASS; + } else { + if (!world.isClientSide) { ++ // CraftBukkit start ++ if (!LayeredCauldronBlock.decreaseLevel(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 @@ + + entityhuman.a(enumhand, itemstack1); + entityhuman.a(StatisticList.CLEAN_SHULKER_BOX); +- LayeredCauldronBlock.e(iblockdata, world, blockposition); ++ // LayeredCauldronBlock.e(iblockdata, world, blockposition); // CraftBukkit + } + + return EnumInteractionResult.a(world.isClientSide); +@@ -71,6 +80,11 @@ + return EnumInteractionResult.PASS; + } else { + if (!world.isClientSide) { ++ // CraftBukkit start ++ if (!LayeredCauldronBlock.decreaseLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) { ++ return EnumInteractionResult.SUCCESS; ++ } ++ // CraftBukkit end + ItemStack itemstack1 = itemstack.cloneItemStack(); + + itemstack1.setCount(1); +@@ -88,7 +102,7 @@ + } + + entityhuman.a(StatisticList.CLEAN_BANNER); +- LayeredCauldronBlock.e(iblockdata, world, blockposition); ++ // LayeredCauldronBlock.e(iblockdata, world, blockposition); // CraftBukkit + } + + return EnumInteractionResult.a(world.isClientSide); +@@ -106,9 +120,14 @@ + return EnumInteractionResult.PASS; + } else { + if (!world.isClientSide) { ++ // CraftBukkit start ++ if (!LayeredCauldronBlock.decreaseLevel(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 + } + + return EnumInteractionResult.a(world.isClientSide); +@@ -117,7 +136,7 @@ + }; + + static Object2ObjectOpenHashMap a() { +- return (Object2ObjectOpenHashMap) SystemUtils.a((Object) (new Object2ObjectOpenHashMap()), (object2objectopenhashmap) -> { ++ return SystemUtils.a((new Object2ObjectOpenHashMap<>()), (object2objectopenhashmap) -> { // CraftBukkit - decompile error + object2objectopenhashmap.defaultReturnValue((iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { + return EnumInteractionResult.PASS; + }); +@@ -133,12 +152,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)) { ++ 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 + world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.a((Entity) null, GameEvent.FLUID_PLACE, blockposition); + } +@@ -154,12 +178,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)) { ++ 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 + world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.a((Entity) null, GameEvent.FLUID_PICKUP, blockposition); + } +@@ -169,10 +198,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 (!world.isClientSide) { ++ // CraftBukkit start ++ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata.a(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 + world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.a((Entity) null, GameEvent.FLUID_PLACE, blockposition); + } +@@ -244,12 +278,17 @@ + return EnumInteractionResult.PASS; + } else { + if (!world.isClientSide) { ++ // CraftBukkit start ++ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.CAULDRON.getBlockData(), 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 + world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.a((Entity) null, GameEvent.FLUID_PICKUP, blockposition); + } +@@ -260,12 +299,17 @@ + + static EnumInteractionResult a(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)) { ++ return EnumInteractionResult.SUCCESS; ++ } ++ // 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 + world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.a((Entity) null, GameEvent.FLUID_PLACE, blockposition); + } diff --git a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch index ee8d1e2e0..7376fe8ff 100644 --- a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch +++ b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch @@ -11,7 +11,7 @@ + public class DispenseBehaviorBoat extends DispenseBehaviorItem { - private final DispenseBehaviorItem b = new DispenseBehaviorItem(); + private final DispenseBehaviorItem defaultDispenseItemBehavior = new DispenseBehaviorItem(); @@ -39,12 +44,40 @@ d3 = 0.0D; } @@ -37,8 +37,8 @@ + itemstack.add(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { + idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } @@ -47,8 +47,8 @@ + EntityBoat entityboat = new EntityBoat(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); + // CraftBukkit end - entityboat.setType(this.c); - entityboat.yaw = enumdirection.o(); + entityboat.setType(this.type); + entityboat.setYRot(enumdirection.o()); - worldserver.addEntity(entityboat); - itemstack.subtract(1); + if (!worldserver.addEntity(entityboat)) itemstack.add(1); // CraftBukkit diff --git a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorItem.patch b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorItem.patch index decde82fa..b8fd895dc 100644 --- a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorItem.patch +++ b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorItem.patch @@ -59,8 +59,8 @@ + if (!event.getItem().getType().equals(craftItem.getType())) { + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior.getClass() != DispenseBehaviorItem.class) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior.getClass() != DispenseBehaviorItem.class) { + idispensebehavior.dispense(isourceblock, eventStack); + } else { + world.addEntity(entityitem); diff --git a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorProjectile.patch b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorProjectile.patch index 6fb0b8475..ad9d7c96c 100644 --- a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorProjectile.patch +++ b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorProjectile.patch @@ -39,8 +39,8 @@ + itemstack.add(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { + idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } diff --git a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch index 4e0155872..d2b3420f3 100644 --- a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch +++ b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/core/dispenser/DispenseBehaviorShears.java +++ b/net/minecraft/core/dispenser/DispenseBehaviorShears.java -@@ -23,6 +23,12 @@ - import net.minecraft.world.level.block.state.IBlockData; +@@ -25,6 +25,12 @@ + import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AxisAlignedBB; +// CraftBukkit start @@ -13,7 +13,7 @@ public class DispenseBehaviorShears extends DispenseBehaviorMaybe { public DispenseBehaviorShears() {} -@@ -30,11 +36,34 @@ +@@ -32,11 +38,34 @@ @Override protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { WorldServer worldserver = isourceblock.getWorld(); @@ -33,15 +33,15 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { + idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } + // CraftBukkit end - if (!worldserver.s_()) { + if (!worldserver.isClientSide()) { BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); - this.a(a((WorldServer) worldserver, blockposition) || b((WorldServer) worldserver, blockposition)); @@ -49,16 +49,16 @@ if (this.a() && itemstack.isDamaged(1, worldserver.getRandom(), (EntityPlayer) null)) { itemstack.setCount(0); } -@@ -60,7 +89,7 @@ +@@ -63,7 +92,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 list = worldserver.a(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.g); + List list = worldserver.a(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.NO_SPECTATORS); Iterator iterator = list.iterator(); -@@ -71,6 +100,11 @@ +@@ -74,6 +103,11 @@ IShearable ishearable = (IShearable) entityliving; if (ishearable.canShear()) { @@ -68,5 +68,5 @@ + } + // CraftBukkit end ishearable.shear(SoundCategory.BLOCKS); + worldserver.a((Entity) null, GameEvent.SHEAR, blockposition); return true; - } diff --git a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.patch b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.patch index 0ed0860b2..b1cc565a5 100644 --- a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.patch +++ b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.java +++ b/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.java -@@ -10,6 +10,11 @@ - import net.minecraft.world.item.context.BlockActionContextDirectional; - import net.minecraft.world.level.block.BlockDispenser; +@@ -12,6 +12,11 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -11,8 +11,8 @@ + public class DispenseBehaviorShulkerBox extends DispenseBehaviorMaybe { - public DispenseBehaviorShulkerBox() {} -@@ -24,6 +29,30 @@ + 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; @@ -32,14 +32,14 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { + idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } + // CraftBukkit end + - this.a(((ItemBlock) item).a((BlockActionContext) (new BlockActionContextDirectional(isourceblock.getWorld(), blockposition, enumdirection, itemstack, enumdirection1))).a()); - } - + try { + this.a(((ItemBlock) item).a((BlockActionContext) (new BlockActionContextDirectional(isourceblock.getWorld(), blockposition, enumdirection, itemstack, enumdirection1))).a()); + } catch (Exception exception) { diff --git a/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch b/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch index d1abc8f29..f4c623c7a 100644 --- a/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch +++ b/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/core/dispenser/IDispenseBehavior.java +++ b/net/minecraft/core/dispenser/IDispenseBehavior.java -@@ -74,6 +74,19 @@ - import net.minecraft.world.phys.AxisAlignedBB; - import net.minecraft.world.phys.MovingObjectPositionBlock; +@@ -79,6 +79,20 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; +// CraftBukkit start ++import net.minecraft.world.item.ItemBucket; +import net.minecraft.world.level.block.BlockSapling; +import net.minecraft.world.level.block.IFluidContainer; +import net.minecraft.world.level.material.Material; @@ -19,8 +20,8 @@ + public interface IDispenseBehavior { - IDispenseBehavior NONE = (isourceblock, itemstack) -> { -@@ -114,7 +127,7 @@ + Logger LOGGER = LogManager.getLogger(); +@@ -120,7 +134,7 @@ BlockDispenser.a((IMaterial) Items.EGG, (IDispenseBehavior) (new DispenseBehaviorProjectile() { @Override protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) { @@ -29,7 +30,7 @@ entityegg.setItem(itemstack); }); } -@@ -122,7 +135,7 @@ +@@ -128,7 +142,7 @@ BlockDispenser.a((IMaterial) Items.SNOWBALL, (IDispenseBehavior) (new DispenseBehaviorProjectile() { @Override protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) { @@ -38,7 +39,7 @@ entitysnowball.setItem(itemstack); }); } -@@ -130,7 +143,7 @@ +@@ -136,7 +150,7 @@ BlockDispenser.a((IMaterial) Items.EXPERIENCE_BOTTLE, (IDispenseBehavior) (new DispenseBehaviorProjectile() { @Override protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) { @@ -47,7 +48,7 @@ entitythrownexpbottle.setItem(itemstack); }); } -@@ -151,7 +164,7 @@ +@@ -157,7 +171,7 @@ return (new DispenseBehaviorProjectile() { @Override protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) { @@ -56,7 +57,7 @@ entitypotion.setItem(itemstack1); }); } -@@ -174,7 +187,7 @@ +@@ -180,7 +194,7 @@ return (new DispenseBehaviorProjectile() { @Override protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) { @@ -65,9 +66,9 @@ entitypotion.setItem(itemstack1); }); } -@@ -197,8 +210,36 @@ +@@ -203,14 +217,42 @@ EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); - EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).a(itemstack.getTag()); + EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).a(itemstack.getTag()); + // CraftBukkit start + WorldServer worldserver = isourceblock.getWorld(); @@ -89,21 +90,28 @@ + itemstack.add(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { + idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } + - entitytypes.spawnCreature(isourceblock.getWorld(), itemstack, (EntityHuman) null, isourceblock.getBlockPosition().shift(enumdirection), EnumMobSpawn.DISPENSER, enumdirection != EnumDirection.UP, false); + try { + entitytypes.spawnCreature(isourceblock.getWorld(), itemstack, (EntityHuman) null, isourceblock.getBlockPosition().shift(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 + return ItemStack.EMPTY; + } + - itemstack.subtract(1); + // itemstack.subtract(1); // Handled during event processing + // CraftBukkit end + isourceblock.getWorld().a(GameEvent.ENTITY_PLACE, isourceblock.getBlockPosition()); return itemstack; } - }; -@@ -216,12 +257,40 @@ +@@ -229,12 +271,40 @@ EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); WorldServer worldserver = isourceblock.getWorld(); @@ -127,8 +135,8 @@ + itemstack.add(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { + idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } @@ -138,14 +146,14 @@ 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.yaw = enumdirection.o(); + entityarmorstand.setYRot(enumdirection.o()); worldserver.addEntity(entityarmorstand); - itemstack.subtract(1); + // itemstack.subtract(1); // CraftBukkit - Handled during event processing return itemstack; } })); -@@ -322,12 +391,41 @@ +@@ -335,12 +405,41 @@ @Override public ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); @@ -169,8 +177,8 @@ + itemstack.add(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { + idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } @@ -188,12 +196,14 @@ return itemstack; } -@@ -350,10 +448,39 @@ +@@ -362,12 +461,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(); +- EntitySmallFireball entitysmallfireball = new EntitySmallFireball(worldserver, d0, d1, d2, d3, d4, d5); -- worldserver.addEntity((Entity) SystemUtils.a((Object) (new EntitySmallFireball(worldserver, d0, d1, d2, d3, d4, d5)), (entitysmallfireball) -> { -- entitysmallfireball.setItem(itemstack); +- worldserver.addEntity((Entity) SystemUtils.a((Object) entitysmallfireball, (entitysmallfireball1) -> { +- entitysmallfireball1.setItem(itemstack); - })); - itemstack.subtract(1); + // CraftBukkit start @@ -215,8 +225,8 @@ + itemstack.add(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { + idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } @@ -232,7 +242,7 @@ return itemstack; } -@@ -377,9 +504,52 @@ +@@ -391,9 +518,52 @@ BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); WorldServer worldserver = isourceblock.getWorld(); @@ -242,7 +252,7 @@ + int z = blockposition.getZ(); + IBlockData iblockdata = worldserver.getType(blockposition); + Material material = iblockdata.getMaterial(); -+ if (worldserver.isEmpty(blockposition) || !material.isBuildable() || material.isReplaceable() || ((iblockdata.getBlock() instanceof IFluidContainer) && ((IFluidContainer) iblockdata.getBlock()).canPlace(worldserver, blockposition, iblockdata, itembucket.fluidType))) { ++ 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()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + @@ -258,19 +268,19 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { + idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } + -+ itembucket = (ItemBucket) CraftItemStack.asNMSCopy(event.getItem()).getItem(); ++ dispensiblecontaineritem = (DispensibleContainerItem) CraftItemStack.asNMSCopy(event.getItem()).getItem(); + } + // CraftBukkit end + - if (itembucket.a((EntityHuman) null, (World) worldserver, blockposition, (MovingObjectPositionBlock) null)) { - itembucket.a((World) worldserver, itemstack, blockposition); + if (dispensiblecontaineritem.a((EntityHuman) null, worldserver, blockposition, (MovingObjectPositionBlock) null)) { + dispensiblecontaineritem.a((EntityHuman) null, worldserver, itemstack, blockposition); - return new ItemStack(Items.BUCKET); + // CraftBukkit start - Handle stacked buckets + Item item = Items.BUCKET; @@ -279,24 +289,25 @@ + itemstack.setItem(Items.BUCKET); + itemstack.setCount(1); + } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) { -+ this.b.dispense(isourceblock, new ItemStack(item)); ++ this.defaultDispenseItemBehavior.dispense(isourceblock, new ItemStack(item)); + } + // CraftBukkit end + return itemstack; } else { - return this.b.dispense(isourceblock, itemstack); + return this.defaultDispenseItemBehavior.dispense(isourceblock, itemstack); } -@@ -403,13 +573,39 @@ +@@ -419,7 +589,7 @@ Block block = iblockdata.getBlock(); if (block instanceof IFluidSource) { -- FluidType fluidtype = ((IFluidSource) block).removeFluid(worldserver, blockposition, iblockdata); -+ FluidType fluidtype = ((IFluidSource) block).removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit +- ItemStack itemstack1 = ((IFluidSource) block).removeFluid(worldserver, blockposition, iblockdata); ++ ItemStack itemstack1 = ((IFluidSource) block).removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit - if (!(fluidtype instanceof FluidTypeFlowing)) { + if (itemstack1.isEmpty()) { return super.a(isourceblock, itemstack); - } else { - Item item = fluidtype.a(); +@@ -427,6 +597,32 @@ + worldserver.a((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()); @@ -314,20 +325,20 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { + idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } + -+ fluidtype = ((IFluidSource) block).removeFluid(worldserver, blockposition, iblockdata); // From above ++ itemstack1 = ((IFluidSource) block).removeFluid(worldserver, blockposition, iblockdata); // From above + // CraftBukkit end + itemstack.subtract(1); if (itemstack.isEmpty()) { return new ItemStack(item); -@@ -431,13 +627,41 @@ +@@ -448,14 +644,42 @@ protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { WorldServer worldserver = isourceblock.getWorld(); @@ -347,8 +358,8 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { + idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } @@ -362,15 +373,17 @@ if (BlockFireAbstract.a((World) worldserver, blockposition, enumdirection)) { - worldserver.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) worldserver, blockposition)); +- worldserver.a((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); + } + // CraftBukkit end - } else if (BlockCampfire.h(iblockdata)) { - worldserver.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockProperties.r, true)); - } else if (iblockdata.getBlock() instanceof BlockTNT) { -@@ -460,12 +684,62 @@ + } else if (!BlockCampfire.h(iblockdata) && !CandleBlock.g(iblockdata) && !CandleCakeBlock.g(iblockdata)) { + if (iblockdata.getBlock() instanceof BlockTNT) { + BlockTNT.a((World) worldserver, blockposition); +@@ -481,12 +705,62 @@ this.a(true); WorldServer worldserver = isourceblock.getWorld(); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); @@ -390,8 +403,8 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { + idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } @@ -403,7 +416,7 @@ if (!ItemBoneMeal.a(itemstack, (World) worldserver, blockposition) && !ItemBoneMeal.a(itemstack, (World) worldserver, blockposition, (EnumDirection) null)) { this.a(false); } else if (!worldserver.isClientSide) { - worldserver.triggerEffect(2005, blockposition, 0); + worldserver.triggerEffect(1505, blockposition, 0); } + // CraftBukkit start + worldserver.captureTreeGeneration = false; @@ -433,12 +446,12 @@ return itemstack; } -@@ -475,11 +749,40 @@ +@@ -496,12 +770,41 @@ protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { WorldServer worldserver = isourceblock.getWorld(); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); - EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); -+ // EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); ++ // 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); @@ -459,8 +472,8 @@ + itemstack.add(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { + idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } @@ -470,13 +483,14 @@ + // CraftBukkit end worldserver.addEntity(entitytntprimed); - worldserver.playSound((EntityHuman) null, entitytntprimed.locX(), entitytntprimed.locY(), entitytntprimed.locZ(), SoundEffects.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); + 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 return itemstack; } })); -@@ -503,6 +806,30 @@ +@@ -525,6 +828,30 @@ EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); @@ -496,8 +510,8 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { + idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } @@ -505,9 +519,9 @@ + // CraftBukkit end + if (worldserver.isEmpty(blockposition) && BlockWitherSkull.b((World) worldserver, blockposition, itemstack)) { - worldserver.setTypeAndData(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.getBlockData().set(BlockSkull.a, enumdirection.n() == EnumDirection.EnumAxis.Y ? 0 : enumdirection.opposite().get2DRotationValue() * 4), 3); - TileEntity tileentity = worldserver.getTileEntity(blockposition); -@@ -527,6 +854,30 @@ + 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 +877,30 @@ BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN; @@ -527,8 +541,8 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { + idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } @@ -538,7 +552,7 @@ if (worldserver.isEmpty(blockposition) && blockpumpkincarved.a((IWorldReader) worldserver, blockposition)) { if (!worldserver.isClientSide) { worldserver.setTypeAndData(blockposition, blockpumpkincarved.getBlockData(), 3); -@@ -574,6 +925,30 @@ +@@ -599,6 +950,30 @@ BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); IBlockData iblockdata = worldserver.getType(blockposition); @@ -558,8 +572,8 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { + idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } @@ -567,5 +581,5 @@ + // CraftBukkit end + if (iblockdata.a((Tag) TagsBlock.BEEHIVES, (blockbase_blockdata) -> { - return blockbase_blockdata.b(BlockBeehive.b); - }) && (Integer) iblockdata.get(BlockBeehive.b) >= 5) { + return blockbase_blockdata.b(BlockBeehive.HONEY_LEVEL); + }) && (Integer) iblockdata.get(BlockBeehive.HONEY_LEVEL) >= 5) { diff --git a/nms-patches/net/minecraft/network/NetworkManager.patch b/nms-patches/net/minecraft/network/NetworkManager.patch index 8d747772b..af44ec6f7 100644 --- a/nms-patches/net/minecraft/network/NetworkManager.patch +++ b/nms-patches/net/minecraft/network/NetworkManager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/NetworkManager.java +++ b/net/minecraft/network/NetworkManager.java -@@ -137,7 +137,7 @@ +@@ -156,7 +156,7 @@ } private static void a(Packet packet, PacketListener packetlistener) { @@ -9,12 +9,12 @@ } public void setPacketListener(PacketListener packetlistener) { -@@ -247,7 +247,7 @@ +@@ -268,7 +268,7 @@ public void close(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. - this.m = ichatbasecomponent; + this.disconnectedReason = ichatbasecomponent; } diff --git a/nms-patches/net/minecraft/network/PacketDataSerializer.patch b/nms-patches/net/minecraft/network/PacketDataSerializer.patch index 94c816fe8..a8354ab44 100644 --- a/nms-patches/net/minecraft/network/PacketDataSerializer.patch +++ b/nms-patches/net/minecraft/network/PacketDataSerializer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/PacketDataSerializer.java +++ b/net/minecraft/network/PacketDataSerializer.java -@@ -39,6 +39,8 @@ +@@ -54,6 +54,8 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.Vec3D; @@ -8,17 +8,59 @@ + public class PacketDataSerializer extends ByteBuf { - private final ByteBuf a; -@@ -167,7 +169,7 @@ + private static final int MAX_VARINT_SIZE = 5; +@@ -112,7 +114,7 @@ + + public > C a(IntFunction intfunction, Function function) { + int i = this.j(); +- 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)); +@@ -123,7 +125,7 @@ + + public void a(Collection collection, BiConsumer biconsumer) { + this.d(collection.size()); +- Iterator iterator = collection.iterator(); ++ Iterator iterator = collection.iterator(); // CraftBukkit - decompile error + + while (iterator.hasNext()) { + T t0 = iterator.next(); +@@ -134,7 +136,7 @@ + } + + public List a(Function function) { +- return (List) this.a(Lists::newArrayListWithCapacity, function); ++ return (List) this.a((java.util.function.IntFunction) Lists::newArrayListWithCapacity, function); // CraftBukkit - decompile error + } + + public IntList a() { +@@ -150,12 +152,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 > M a(IntFunction intfunction, Function function, Function function1) { + int i = this.j(); +- 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); +@@ -330,7 +332,7 @@ } public > T a(Class oclass) { -- return ((Enum[]) oclass.getEnumConstants())[this.i()]; -+ return ((T[]) oclass.getEnumConstants())[this.i()]; // CraftBukkit - fix decompile error +- return ((Enum[]) oclass.getEnumConstants())[this.j()]; ++ return ((T[]) oclass.getEnumConstants())[this.j()]; // CraftBukkit - fix decompile error } public PacketDataSerializer a(Enum oenum) { -@@ -244,7 +246,7 @@ +@@ -407,7 +409,7 @@ } else { try { NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this))); @@ -27,7 +69,7 @@ throw new EncoderException(ioexception); } } -@@ -281,7 +283,7 @@ +@@ -444,7 +446,7 @@ } public PacketDataSerializer a(ItemStack itemstack) { @@ -36,10 +78,10 @@ this.writeBoolean(false); } else { this.writeBoolean(true); -@@ -310,6 +312,11 @@ +@@ -473,6 +475,11 @@ ItemStack itemstack = new ItemStack(Item.getById(i), b0); - itemstack.setTag(this.l()); + itemstack.setTag(this.m()); + // CraftBukkit start + if (itemstack.getTag() != null) { + CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); diff --git a/nms-patches/net/minecraft/network/chat/ChatHexColor.patch b/nms-patches/net/minecraft/network/chat/ChatHexColor.patch index 1b1fdc4ed..92dae2511 100644 --- a/nms-patches/net/minecraft/network/chat/ChatHexColor.patch +++ b/nms-patches/net/minecraft/network/chat/ChatHexColor.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/network/chat/ChatHexColor.java +++ b/net/minecraft/network/chat/ChatHexColor.java -@@ -11,7 +11,7 @@ - public final class ChatHexColor { +@@ -12,7 +12,7 @@ - private static final Map a = (Map) Stream.of(EnumChatFormat.values()).filter(EnumChatFormat::d).collect(ImmutableMap.toImmutableMap(Function.identity(), (enumchatformat) -> { + private static final String CUSTOM_COLOR_PREFIX = "#"; + private static final Map 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 b = (Map) ChatHexColor.a.values().stream().collect(ImmutableMap.toImmutableMap((chathexcolor) -> { + private static final Map NAMED_COLORS = (Map) ChatHexColor.LEGACY_FORMAT_TO_COLOR.values().stream().collect(ImmutableMap.toImmutableMap((chathexcolor) -> { return chathexcolor.name; -@@ -19,16 +19,22 @@ - private final int rgb; +@@ -20,16 +20,22 @@ + private final int value; @Nullable public final String name; + // CraftBukkit start @@ -19,17 +19,17 @@ - private ChatHexColor(int i, String s) { + private ChatHexColor(int i, String s, EnumChatFormat format) { - this.rgb = i; + this.value = i; this.name = s; + this.format = format; } private ChatHexColor(int i) { - this.rgb = i; + this.value = i; this.name = null; + this.format = null; } + // CraftBukkit end - public String b() { - return this.name != null ? this.name : this.c(); + public int a() { + return this.value; diff --git a/nms-patches/net/minecraft/network/chat/ChatModifier.patch b/nms-patches/net/minecraft/network/chat/ChatModifier.patch deleted file mode 100644 index 09c2d6f88..000000000 --- a/nms-patches/net/minecraft/network/chat/ChatModifier.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/net/minecraft/network/chat/ChatModifier.java -+++ b/net/minecraft/network/chat/ChatModifier.java -@@ -118,6 +118,20 @@ - return new ChatModifier(this.color, this.bold, obool, this.underlined, this.strikethrough, this.obfuscated, this.clickEvent, this.hoverEvent, this.insertion, this.font); - } - -+ // CraftBukkit start -+ public ChatModifier setStrikethrough(@Nullable Boolean obool) { -+ return new ChatModifier(this.color, this.bold, this.italic, this.underlined, obool, this.obfuscated, this.clickEvent, this.hoverEvent, this.insertion, this.font); -+ } -+ -+ public ChatModifier setUnderline(@Nullable Boolean obool) { -+ return new ChatModifier(this.color, this.bold, this.italic, obool, this.strikethrough, this.obfuscated, this.clickEvent, this.hoverEvent, this.insertion, this.font); -+ } -+ -+ public ChatModifier setRandom(@Nullable Boolean obool) { -+ return new ChatModifier(this.color, this.bold, this.italic, this.underlined, this.strikethrough, obool, this.clickEvent, this.hoverEvent, this.insertion, this.font); -+ } -+ // CraftBukkit end -+ - public ChatModifier setChatClickable(@Nullable ChatClickable chatclickable) { - return new ChatModifier(this.color, this.bold, this.italic, this.underlined, this.strikethrough, this.obfuscated, chatclickable, this.hoverEvent, this.insertion, this.font); - } diff --git a/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch b/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch index 3f88e48f6..c38085d29 100644 --- a/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch +++ b/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/network/chat/IChatBaseComponent.java +++ b/net/minecraft/network/chat/IChatBaseComponent.java -@@ -27,7 +27,23 @@ - import net.minecraft.util.ChatDeserializer; +@@ -29,7 +29,23 @@ import net.minecraft.util.ChatTypeAdapterFactory; + import net.minecraft.util.FormattedString; -public interface IChatBaseComponent extends Message, IChatFormatted { +// CraftBukkit start diff --git a/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch b/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch index 5736dc94d..b73a409f7 100644 --- a/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch +++ b/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch @@ -12,7 +12,7 @@ public class PlayerConnectionUtils { private static final Logger LOGGER = LogManager.getLogger(); -@@ -18,6 +23,7 @@ +@@ -20,6 +25,7 @@ public static void ensureMainThread(Packet packet, T t0, IAsyncTaskHandler iasynctaskhandler) throws CancelledPacketHandleException { if (!iasynctaskhandler.isMainThread()) { iasynctaskhandler.execute(() -> { @@ -20,13 +20,13 @@ if (t0.a().isConnected()) { packet.a(t0); } else { -@@ -26,6 +32,10 @@ +@@ -28,6 +34,10 @@ }); - throw CancelledPacketHandleException.INSTANCE; + throw CancelledPacketHandleException.RUNNING_ON_DIFFERENT_THREAD; + // CraftBukkit start - SPIGOT-5477, MC-142590 + } else if (MinecraftServer.getServer().hasStopped() || (t0 instanceof PlayerConnection && ((PlayerConnection) t0).processedDisconnect)) { -+ throw CancelledPacketHandleException.INSTANCE; ++ throw CancelledPacketHandleException.RUNNING_ON_DIFFERENT_THREAD; + // CraftBukkit end } } diff --git a/nms-patches/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.patch b/nms-patches/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.patch new file mode 100644 index 000000000..c451f9d7b --- /dev/null +++ b/nms-patches/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java ++++ b/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java +@@ -27,8 +27,10 @@ + } + + public ClientboundInitializeBorderPacket(WorldBorder worldborder) { +- 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(); ++ // CraftBukkit end + this.oldSize = worldborder.getSize(); + this.newSize = worldborder.k(); + this.lerpTime = worldborder.j(); diff --git a/nms-patches/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.patch b/nms-patches/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.patch new file mode 100644 index 000000000..3c0fefce7 --- /dev/null +++ b/nms-patches/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java ++++ b/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java +@@ -10,8 +10,10 @@ + private final double newCenterZ; + + public ClientboundSetBorderCenterPacket(WorldBorder worldborder) { +- 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(); ++ // CraftBukkit end + } + + public ClientboundSetBorderCenterPacket(PacketDataSerializer packetdataserializer) { diff --git a/nms-patches/net/minecraft/network/protocol/game/PacketPlayInBlockPlace.patch b/nms-patches/net/minecraft/network/protocol/game/PacketPlayInBlockPlace.patch index 167ba7ae8..760a854cd 100644 --- a/nms-patches/net/minecraft/network/protocol/game/PacketPlayInBlockPlace.patch +++ b/nms-patches/net/minecraft/network/protocol/game/PacketPlayInBlockPlace.patch @@ -4,4 +4,4 @@ +// mc-dev import package net.minecraft.network.protocol.game; - import java.io.IOException; + import net.minecraft.network.PacketDataSerializer; diff --git a/nms-patches/net/minecraft/network/protocol/game/PacketPlayInChat.patch b/nms-patches/net/minecraft/network/protocol/game/PacketPlayInChat.patch index 2be8c200a..cbd53fda4 100644 --- a/nms-patches/net/minecraft/network/protocol/game/PacketPlayInChat.patch +++ b/nms-patches/net/minecraft/network/protocol/game/PacketPlayInChat.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/network/protocol/game/PacketPlayInChat.java +++ b/net/minecraft/network/protocol/game/PacketPlayInChat.java -@@ -20,7 +20,7 @@ +@@ -17,7 +17,7 @@ + } - @Override - public void a(PacketDataSerializer packetdataserializer) throws IOException { -- this.a = packetdataserializer.e(256); -+ this.a = org.apache.commons.lang3.StringUtils.normalizeSpace(packetdataserializer.e(256)); // CraftBukkit - see PlayerConnection + public PacketPlayInChat(PacketDataSerializer packetdataserializer) { +- this.message = packetdataserializer.e(256); ++ this.message = org.apache.commons.lang3.StringUtils.normalizeSpace(packetdataserializer.e(256)); // CraftBukkit - see PlayerConnection } @Override diff --git a/nms-patches/net/minecraft/network/protocol/game/PacketPlayInCloseWindow.patch b/nms-patches/net/minecraft/network/protocol/game/PacketPlayInCloseWindow.patch deleted file mode 100644 index 65269fb77..000000000 --- a/nms-patches/net/minecraft/network/protocol/game/PacketPlayInCloseWindow.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/network/protocol/game/PacketPlayInCloseWindow.java -+++ b/net/minecraft/network/protocol/game/PacketPlayInCloseWindow.java -@@ -10,6 +10,12 @@ - - public PacketPlayInCloseWindow() {} - -+ // CraftBukkit start -+ public PacketPlayInCloseWindow(int id) { -+ this.id = id; -+ } -+ // CraftBukkit end -+ - public void a(PacketListenerPlayIn packetlistenerplayin) { - packetlistenerplayin.a(this); - } diff --git a/nms-patches/net/minecraft/network/protocol/game/PacketPlayInUseItem.patch b/nms-patches/net/minecraft/network/protocol/game/PacketPlayInUseItem.patch index 89b95bdab..9475518bd 100644 --- a/nms-patches/net/minecraft/network/protocol/game/PacketPlayInUseItem.patch +++ b/nms-patches/net/minecraft/network/protocol/game/PacketPlayInUseItem.patch @@ -4,4 +4,4 @@ +// mc-dev import package net.minecraft.network.protocol.game; - import java.io.IOException; + import net.minecraft.network.PacketDataSerializer; diff --git a/nms-patches/net/minecraft/network/protocol/game/PacketPlayOutChat.patch b/nms-patches/net/minecraft/network/protocol/game/PacketPlayOutChat.patch index 912f8c201..c43e616de 100644 --- a/nms-patches/net/minecraft/network/protocol/game/PacketPlayOutChat.patch +++ b/nms-patches/net/minecraft/network/protocol/game/PacketPlayOutChat.patch @@ -4,4 +4,4 @@ +// mc-dev import package net.minecraft.network.protocol.game; - import java.io.IOException; + import java.util.UUID; diff --git a/nms-patches/net/minecraft/network/protocol/game/PacketPlayOutMultiBlockChange.patch b/nms-patches/net/minecraft/network/protocol/game/PacketPlayOutMultiBlockChange.patch index 258e6468d..56a792118 100644 --- a/nms-patches/net/minecraft/network/protocol/game/PacketPlayOutMultiBlockChange.patch +++ b/nms-patches/net/minecraft/network/protocol/game/PacketPlayOutMultiBlockChange.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/network/protocol/game/PacketPlayOutMultiBlockChange.java +++ b/net/minecraft/network/protocol/game/PacketPlayOutMultiBlockChange.java -@@ -31,7 +31,7 @@ +@@ -32,7 +32,7 @@ short short0 = (Short) shortiterator.next(); - this.b[i] = short0; -- this.c[i] = chunksection.getType(SectionPosition.a(short0), SectionPosition.b(short0), SectionPosition.c(short0)); -+ this.c[i] = (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.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 } } diff --git a/nms-patches/net/minecraft/network/protocol/game/PacketPlayOutWorldBorder.patch b/nms-patches/net/minecraft/network/protocol/game/PacketPlayOutWorldBorder.patch deleted file mode 100644 index 8c73743e1..000000000 --- a/nms-patches/net/minecraft/network/protocol/game/PacketPlayOutWorldBorder.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/network/protocol/game/PacketPlayOutWorldBorder.java -+++ b/net/minecraft/network/protocol/game/PacketPlayOutWorldBorder.java -@@ -21,8 +21,10 @@ - - public PacketPlayOutWorldBorder(WorldBorder worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction packetplayoutworldborder_enumworldborderaction) { - this.a = packetplayoutworldborder_enumworldborderaction; -- this.c = worldborder.getCenterX(); -- this.d = worldborder.getCenterZ(); -+ // CraftBukkit start - multiply out nether border -+ this.c = worldborder.getCenterX() * worldborder.world.getDimensionManager().getCoordinateScale(); -+ this.d = worldborder.getCenterZ() * worldborder.world.getDimensionManager().getCoordinateScale(); -+ // CraftBukkit end - this.f = worldborder.getSize(); - this.e = worldborder.k(); - this.g = worldborder.j(); diff --git a/nms-patches/net/minecraft/network/protocol/handshake/PacketHandshakingInSetProtocol.patch b/nms-patches/net/minecraft/network/protocol/handshake/PacketHandshakingInSetProtocol.patch index 2b804a209..9e5f50457 100644 --- a/nms-patches/net/minecraft/network/protocol/handshake/PacketHandshakingInSetProtocol.patch +++ b/nms-patches/net/minecraft/network/protocol/handshake/PacketHandshakingInSetProtocol.patch @@ -4,4 +4,4 @@ +// mc-dev import package net.minecraft.network.protocol.handshake; - import java.io.IOException; + import net.minecraft.SharedConstants; diff --git a/nms-patches/net/minecraft/network/syncher/DataWatcher.patch b/nms-patches/net/minecraft/network/syncher/DataWatcher.patch index a588c366e..e4e1d6d16 100644 --- a/nms-patches/net/minecraft/network/syncher/DataWatcher.patch +++ b/nms-patches/net/minecraft/network/syncher/DataWatcher.patch @@ -1,16 +1,25 @@ --- a/net/minecraft/network/syncher/DataWatcher.java +++ b/net/minecraft/network/syncher/DataWatcher.java -@@ -134,6 +134,13 @@ +@@ -141,6 +141,13 @@ } + // CraftBukkit start - add method from above + public void markDirty(DataWatcherObject datawatcherobject) { + this.b(datawatcherobject).a(true); -+ this.g = true; ++ this.isDirty = true; + } + // CraftBukkit end + public boolean a() { - return this.g; + 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())); + } else { +- datawatcher_item.a(datawatcher_item1.b()); ++ datawatcher_item.a((T) datawatcher_item1.b()); // CraftBukkit - decompile error + } + } + diff --git a/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch b/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch index 0a582f0dd..c3b8bdfd6 100644 --- a/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch +++ b/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch @@ -4,20 +4,20 @@ Advancement advancement = advancementdataworld.a((MinecraftKey) entry.getKey()); if (advancement == null) { -- AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.f); +- AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.file); + // CraftBukkit start + if (entry.getKey().getNamespace().equals("minecraft")) { -+ AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.f); ++ AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.file); + } + // CraftBukkit end } else { this.a(advancement, (AdvancementProgress) entry.getValue()); } -@@ -296,6 +300,7 @@ - this.j.add(advancement); +@@ -276,6 +280,7 @@ + this.progressChanged.add(advancement); flag = true; if (!flag1 && advancementprogress.isDone()) { -+ this.player.world.getServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit)); // CraftBukkit ++ this.player.level.getServer().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.world.getGameRules().getBoolean(GameRules.ANNOUNCE_ADVANCEMENTS)) { - this.e.sendMessage(new ChatMessage("chat.type.advancement." + advancement.c().e().a(), new Object[]{this.player.getScoreboardDisplayName(), advancement.j()}), ChatMessageType.SYSTEM, SystemUtils.b); + 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); diff --git a/nms-patches/net/minecraft/server/CustomFunctionData.patch b/nms-patches/net/minecraft/server/CustomFunctionData.patch index 3011b3c60..bc1e2ce15 100644 --- a/nms-patches/net/minecraft/server/CustomFunctionData.patch +++ b/nms-patches/net/minecraft/server/CustomFunctionData.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/CustomFunctionData.java +++ b/net/minecraft/server/CustomFunctionData.java -@@ -36,7 +36,7 @@ +@@ -44,7 +44,7 @@ } public CommandDispatcher getCommandDispatcher() { diff --git a/nms-patches/net/minecraft/server/DispenserRegistry.patch b/nms-patches/net/minecraft/server/DispenserRegistry.patch index 74bb56c6c..c06dd3a70 100644 --- a/nms-patches/net/minecraft/server/DispenserRegistry.patch +++ b/nms-patches/net/minecraft/server/DispenserRegistry.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/DispenserRegistry.java +++ b/net/minecraft/server/DispenserRegistry.java -@@ -26,6 +26,12 @@ +@@ -28,6 +28,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -12,8 +12,32 @@ + public class DispenserRegistry { - public static final PrintStream a = System.out; -@@ -50,6 +56,69 @@ + public static final PrintStream STDOUT = System.out; +@@ -38,6 +44,23 @@ + + public static void init() { + if (!DispenserRegistry.isBootstrapped) { ++ // CraftBukkit start ++ String name = DispenserRegistry.class.getSimpleName(); ++ switch (name) { ++ case "DispenserRegistry": ++ break; ++ case "Bootstrap": ++ System.err.println("***************************************************************************"); ++ System.err.println("*** WARNING: This server jar may only be used for development purposes. ***"); ++ System.err.println("***************************************************************************"); ++ break; ++ default: ++ System.err.println("**********************************************************************"); ++ System.err.println("*** WARNING: This server jar is unsupported, use at your own risk. ***"); ++ System.err.println("**********************************************************************"); ++ break; ++ } ++ // CraftBukkit end + DispenserRegistry.isBootstrapped = true; + if (IRegistry.REGISTRY.keySet().isEmpty()) { + throw new IllegalStateException("Unable to load registries"); +@@ -55,6 +78,69 @@ TagStatic.b(); d(); } @@ -34,51 +58,51 @@ + 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'}}"); -+ DataConverterMaterialId.ID_MAPPING.put(323, "minecraft:oak_sign"); ++ 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\'}}"}); + -+ DataConverterMaterialId.ID_MAPPING.put(409, "minecraft:prismarine_shard"); -+ DataConverterMaterialId.ID_MAPPING.put(410, "minecraft:prismarine_crystals"); -+ DataConverterMaterialId.ID_MAPPING.put(411, "minecraft:rabbit"); -+ DataConverterMaterialId.ID_MAPPING.put(412, "minecraft:cooked_rabbit"); -+ DataConverterMaterialId.ID_MAPPING.put(413, "minecraft:rabbit_stew"); -+ DataConverterMaterialId.ID_MAPPING.put(414, "minecraft:rabbit_foot"); -+ DataConverterMaterialId.ID_MAPPING.put(415, "minecraft:rabbit_hide"); -+ DataConverterMaterialId.ID_MAPPING.put(416, "minecraft:armor_stand"); ++ DataConverterMaterialId.ITEM_NAMES.put(409, "minecraft:prismarine_shard"); ++ DataConverterMaterialId.ITEM_NAMES.put(410, "minecraft:prismarine_crystals"); ++ DataConverterMaterialId.ITEM_NAMES.put(411, "minecraft:rabbit"); ++ DataConverterMaterialId.ITEM_NAMES.put(412, "minecraft:cooked_rabbit"); ++ DataConverterMaterialId.ITEM_NAMES.put(413, "minecraft:rabbit_stew"); ++ DataConverterMaterialId.ITEM_NAMES.put(414, "minecraft:rabbit_foot"); ++ DataConverterMaterialId.ITEM_NAMES.put(415, "minecraft:rabbit_hide"); ++ DataConverterMaterialId.ITEM_NAMES.put(416, "minecraft:armor_stand"); + -+ DataConverterMaterialId.ID_MAPPING.put(423, "minecraft:mutton"); -+ DataConverterMaterialId.ID_MAPPING.put(424, "minecraft:cooked_mutton"); -+ DataConverterMaterialId.ID_MAPPING.put(425, "minecraft:banner"); -+ DataConverterMaterialId.ID_MAPPING.put(426, "minecraft:end_crystal"); -+ DataConverterMaterialId.ID_MAPPING.put(427, "minecraft:spruce_door"); -+ DataConverterMaterialId.ID_MAPPING.put(428, "minecraft:birch_door"); -+ DataConverterMaterialId.ID_MAPPING.put(429, "minecraft:jungle_door"); -+ DataConverterMaterialId.ID_MAPPING.put(430, "minecraft:acacia_door"); -+ DataConverterMaterialId.ID_MAPPING.put(431, "minecraft:dark_oak_door"); -+ DataConverterMaterialId.ID_MAPPING.put(432, "minecraft:chorus_fruit"); -+ DataConverterMaterialId.ID_MAPPING.put(433, "minecraft:chorus_fruit_popped"); -+ DataConverterMaterialId.ID_MAPPING.put(434, "minecraft:beetroot"); -+ DataConverterMaterialId.ID_MAPPING.put(435, "minecraft:beetroot_seeds"); -+ DataConverterMaterialId.ID_MAPPING.put(436, "minecraft:beetroot_soup"); -+ DataConverterMaterialId.ID_MAPPING.put(437, "minecraft:dragon_breath"); -+ DataConverterMaterialId.ID_MAPPING.put(438, "minecraft:splash_potion"); -+ DataConverterMaterialId.ID_MAPPING.put(439, "minecraft:spectral_arrow"); -+ DataConverterMaterialId.ID_MAPPING.put(440, "minecraft:tipped_arrow"); -+ DataConverterMaterialId.ID_MAPPING.put(441, "minecraft:lingering_potion"); -+ DataConverterMaterialId.ID_MAPPING.put(442, "minecraft:shield"); -+ DataConverterMaterialId.ID_MAPPING.put(443, "minecraft:elytra"); -+ DataConverterMaterialId.ID_MAPPING.put(444, "minecraft:spruce_boat"); -+ DataConverterMaterialId.ID_MAPPING.put(445, "minecraft:birch_boat"); -+ DataConverterMaterialId.ID_MAPPING.put(446, "minecraft:jungle_boat"); -+ DataConverterMaterialId.ID_MAPPING.put(447, "minecraft:acacia_boat"); -+ DataConverterMaterialId.ID_MAPPING.put(448, "minecraft:dark_oak_boat"); -+ DataConverterMaterialId.ID_MAPPING.put(449, "minecraft:totem_of_undying"); -+ DataConverterMaterialId.ID_MAPPING.put(450, "minecraft:shulker_shell"); -+ DataConverterMaterialId.ID_MAPPING.put(452, "minecraft:iron_nugget"); -+ DataConverterMaterialId.ID_MAPPING.put(453, "minecraft:knowledge_book"); ++ DataConverterMaterialId.ITEM_NAMES.put(423, "minecraft:mutton"); ++ DataConverterMaterialId.ITEM_NAMES.put(424, "minecraft:cooked_mutton"); ++ DataConverterMaterialId.ITEM_NAMES.put(425, "minecraft:banner"); ++ DataConverterMaterialId.ITEM_NAMES.put(426, "minecraft:end_crystal"); ++ DataConverterMaterialId.ITEM_NAMES.put(427, "minecraft:spruce_door"); ++ DataConverterMaterialId.ITEM_NAMES.put(428, "minecraft:birch_door"); ++ DataConverterMaterialId.ITEM_NAMES.put(429, "minecraft:jungle_door"); ++ DataConverterMaterialId.ITEM_NAMES.put(430, "minecraft:acacia_door"); ++ DataConverterMaterialId.ITEM_NAMES.put(431, "minecraft:dark_oak_door"); ++ DataConverterMaterialId.ITEM_NAMES.put(432, "minecraft:chorus_fruit"); ++ DataConverterMaterialId.ITEM_NAMES.put(433, "minecraft:chorus_fruit_popped"); ++ DataConverterMaterialId.ITEM_NAMES.put(434, "minecraft:beetroot"); ++ DataConverterMaterialId.ITEM_NAMES.put(435, "minecraft:beetroot_seeds"); ++ DataConverterMaterialId.ITEM_NAMES.put(436, "minecraft:beetroot_soup"); ++ DataConverterMaterialId.ITEM_NAMES.put(437, "minecraft:dragon_breath"); ++ DataConverterMaterialId.ITEM_NAMES.put(438, "minecraft:splash_potion"); ++ DataConverterMaterialId.ITEM_NAMES.put(439, "minecraft:spectral_arrow"); ++ DataConverterMaterialId.ITEM_NAMES.put(440, "minecraft:tipped_arrow"); ++ DataConverterMaterialId.ITEM_NAMES.put(441, "minecraft:lingering_potion"); ++ DataConverterMaterialId.ITEM_NAMES.put(442, "minecraft:shield"); ++ DataConverterMaterialId.ITEM_NAMES.put(443, "minecraft:elytra"); ++ DataConverterMaterialId.ITEM_NAMES.put(444, "minecraft:spruce_boat"); ++ DataConverterMaterialId.ITEM_NAMES.put(445, "minecraft:birch_boat"); ++ DataConverterMaterialId.ITEM_NAMES.put(446, "minecraft:jungle_boat"); ++ DataConverterMaterialId.ITEM_NAMES.put(447, "minecraft:acacia_boat"); ++ DataConverterMaterialId.ITEM_NAMES.put(448, "minecraft:dark_oak_boat"); ++ DataConverterMaterialId.ITEM_NAMES.put(449, "minecraft:totem_of_undying"); ++ DataConverterMaterialId.ITEM_NAMES.put(450, "minecraft:shulker_shell"); ++ DataConverterMaterialId.ITEM_NAMES.put(452, "minecraft:iron_nugget"); ++ DataConverterMaterialId.ITEM_NAMES.put(453, "minecraft:knowledge_book"); + -+ DataConverterSpawnEgg.ID_MAPPING[23] = "Arrow"; ++ DataConverterSpawnEgg.ID_TO_ENTITY[23] = "Arrow"; + // CraftBukkit end } } diff --git a/nms-patches/net/minecraft/server/Main.patch b/nms-patches/net/minecraft/server/Main.patch index 96c2a42d8..8c5089649 100644 --- a/nms-patches/net/minecraft/server/Main.patch +++ b/nms-patches/net/minecraft/server/Main.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -54,13 +54,20 @@ +@@ -58,6 +58,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -13,16 +13,18 @@ public class Main { private static final Logger LOGGER = LogManager.getLogger(); - +@@ -65,8 +71,9 @@ public Main() {} + @DontObfuscate - public static void main(String[] astring) { + public static void main(final OptionSet optionset) { // CraftBukkit - replaces main(String[] astring) + SharedConstants.a(); + /* CraftBukkit start - Replace everything OptionParser optionparser = new OptionParser(); OptionSpec optionspec = optionparser.accepts("nogui"); OptionSpec optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); -@@ -84,21 +91,23 @@ +@@ -90,20 +97,22 @@ optionparser.printHelpOn(System.err); return; } @@ -33,26 +35,21 @@ DispenserRegistry.init(); DispenserRegistry.c(); SystemUtils.l(); - IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.b(); -- Path path = Paths.get("server.properties"); -- DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(iregistrycustom_dimension, path); -+ java.nio.file.Path java_nio_file_path = Paths.get("server.properties"); -+ DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(iregistrycustom_dimension, optionset); // CraftBukkit - CLI argument support + IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.a(); + Path path = Paths.get("server.properties"); +- DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(path); ++ DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(optionset); // CraftBukkit - CLI argument support dedicatedserversettings.save(); -- Path path1 = Paths.get("eula.txt"); -- EULA eula = new EULA(path1); -+ java.nio.file.Path java_nio_file_path1 = Paths.get("eula.txt"); -+ EULA eula = new EULA(java_nio_file_path1); + Path path1 = Paths.get("eula.txt"); + EULA eula = new EULA(path1); - if (optionset.has(optionspec1)) { -- Main.LOGGER.info("Initialized '{}' and '{}'", path.toAbsolutePath(), path1.toAbsolutePath()); + if (optionset.has("initSettings")) { // CraftBukkit -+ Main.LOGGER.info("Initialized '{}' and '{}'", java_nio_file_path.toAbsolutePath(), java_nio_file_path1.toAbsolutePath()); + Main.LOGGER.info("Initialized '{}' and '{}'", path.toAbsolutePath(), path1.toAbsolutePath()); return; } - -@@ -107,24 +116,42 @@ +@@ -113,14 +122,15 @@ return; } @@ -61,15 +58,19 @@ YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY); MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService(); GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository(); - UserCache usercache = new UserCache(gameprofilerepository, new File(file, MinecraftServer.b.getName())); -- String s = (String) Optional.ofNullable(optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.getProperties().levelName); + UserCache usercache = new UserCache(gameprofilerepository, new File(file, MinecraftServer.USERID_CACHE_FILE.getName())); +- String s = (String) Optional.ofNullable((String) optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.getProperties().levelName); + // CraftBukkit start -+ String s = (String) Optional.ofNullable(optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName); ++ 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); MinecraftServer.convertWorld(convertable_conversionsession); + WorldInfo worldinfo = convertable_conversionsession.d(); +@@ -131,13 +141,30 @@ + } + DataPackConfiguration datapackconfiguration = convertable_conversionsession.e(); - boolean flag = optionset.has(optionspec6); + boolean flag = optionset.has("safeMode"); @@ -78,9 +79,9 @@ Main.LOGGER.warn("Safe mode active, only vanilla datapack will be loaded"); } - ResourcePackRepository resourcepackrepository = new ResourcePackRepository(new ResourcePackSource[]{new ResourcePackSourceVanilla(), new ResourcePackSourceFolder(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACKS).toFile(), PackSource.c)}); + ResourcePackRepository resourcepackrepository = new ResourcePackRepository(EnumResourcePackType.SERVER_DATA, new ResourcePackSource[]{new ResourcePackSourceVanilla(), new ResourcePackSourceFolder(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACK_DIR).toFile(), PackSource.WORLD)}); + // CraftBukkit start -+ File bukkitDataPackFolder = new File(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACKS).toFile(), "bukkit"); ++ File bukkitDataPackFolder = new File(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACK_DIR).toFile(), "bukkit"); + if (!bukkitDataPackFolder.exists()) { + bukkitDataPackFolder.mkdirs(); + } @@ -96,18 +97,18 @@ + throw new RuntimeException("Could not initialize Bukkit datapack", ex); + } + // CraftBukkit end - DataPackConfiguration datapackconfiguration1 = MinecraftServer.a(resourcepackrepository, datapackconfiguration == null ? DataPackConfiguration.a : datapackconfiguration, flag); - CompletableFuture completablefuture = DataPackResources.a(resourcepackrepository.f(), CommandDispatcher.ServerType.DEDICATED, dedicatedserversettings.getProperties().functionPermissionLevel, SystemUtils.f(), Runnable::run); + 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); -@@ -139,6 +166,7 @@ +@@ -152,6 +179,7 @@ } - datapackresources.i(); + datapackresources.j(); + /* - RegistryReadOps registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, datapackresources.h(), iregistrycustom_dimension); - Object object = convertable_conversionsession.a((DynamicOps) registryreadops, datapackconfiguration1); + RegistryReadOps registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.INSTANCE, datapackresources.i(), (IRegistryCustom) iregistrycustom_dimension); -@@ -166,21 +194,32 @@ + dedicatedserversettings.getProperties().a((IRegistryCustom) iregistrycustom_dimension); +@@ -181,21 +209,32 @@ } convertable_conversionsession.a((IRegistryCustom) iregistrycustom_dimension, (SaveData) object); @@ -126,7 +127,7 @@ + boolean flag1 = !optionset.has("nogui") && !optionset.nonOptionArguments().contains("nogui"); if (flag1 && !GraphicsEnvironment.isHeadless()) { - dedicatedserver1.bd(); + dedicatedserver1.bi(); } + if (optionset.has("port")) { @@ -142,7 +143,7 @@ Thread thread = new Thread("Server Shutdown Thread") { public void run() { dedicatedserver.safeShutdown(true); -@@ -189,14 +228,15 @@ +@@ -204,14 +243,15 @@ thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER)); Runtime.getRuntime().addShutdownHook(thread); diff --git a/nms-patches/net/minecraft/server/MinecraftServer.patch b/nms-patches/net/minecraft/server/MinecraftServer.patch index a44646d3a..3fd606037 100644 --- a/nms-patches/net/minecraft/server/MinecraftServer.patch +++ b/nms-patches/net/minecraft/server/MinecraftServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -155,6 +155,25 @@ +@@ -166,6 +166,25 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -26,9 +26,9 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant implements IMojangStatistics, ICommandListener, AutoCloseable { public static final Logger LOGGER = LogManager.getLogger(); -@@ -224,6 +243,20 @@ - private final DefinedStructureManager ak; - protected SaveData saveData; +@@ -258,6 +277,20 @@ + private final DefinedStructureManager structureManager; + protected SaveData worldData; + // CraftBukkit start + public DataPackConfiguration datapackconfiguration; @@ -47,7 +47,7 @@ public static S a(Function function) { AtomicReference atomicreference = new AtomicReference(); Thread thread = new Thread(() -> { -@@ -233,21 +266,21 @@ +@@ -267,14 +300,14 @@ thread.setUncaughtExceptionHandler((thread1, throwable) -> { MinecraftServer.LOGGER.error(throwable); }); @@ -59,27 +59,28 @@ return s0; } -- public MinecraftServer(Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, SaveData savedata, ResourcePackRepository resourcepackrepository, Proxy proxy, DataFixer datafixer, DataPackResources datapackresources, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { -+ 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, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { +- public MinecraftServer(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) { ++ 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.m = new GameProfilerSwitcher(SystemUtils.a, this::ai); - this.methodProfiler = GameProfilerDisabled.a; - this.serverPing = new ServerPing(); - this.r = new Random(); - this.serverPort = -1; -- this.worldServer = Maps.newLinkedHashMap(); -+ this.worldServer = Maps.newLinkedHashMap(); // CraftBukkit - keep order, k+v already use identity methods - this.isRunning = true; - this.h = new long[100]; - this.K = ""; -@@ -273,7 +306,34 @@ - this.ak = new DefinedStructureManager(datapackresources.h(), convertable_conversionsession, datafixer); + this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; + this.profiler = this.metricsRecorder.e(); +@@ -286,7 +319,7 @@ + this.status = new ServerPing(); + this.random = new Random(); + this.port = -1; +- this.levels = Maps.newLinkedHashMap(); ++ this.levels = Maps.newLinkedHashMap(); // CraftBukkit - keep order, k+v already use identity methods + this.running = true; + this.tickTimes = new long[100]; + this.resourcePack = ""; +@@ -316,13 +349,40 @@ + this.structureManager = new DefinedStructureManager(datapackresources.i(), convertable_conversionsession, datafixer); this.serverThread = thread; - this.executorService = SystemUtils.f(); + this.executor = SystemUtils.f(); + // CraftBukkit start + this.options = options; + this.datapackconfiguration = datapackconfiguration; -+ this.vanillaCommandDispatcher = datapackresources.commandDispatcher; // CraftBukkit ++ this.vanillaCommandDispatcher = datapackresources.commands; // CraftBukkit + // Try to see if we're actually running in a terminal, disable jline if not + if (System.console() == null && System.getProperty("jline.terminal") == null) { + System.setProperty("jline.terminal", "jline.UnsupportedTerminal"); @@ -106,42 +107,49 @@ + // CraftBukkit end private void initializeScoreboards(WorldPersistentData worldpersistentdata) { - PersistentScoreboard persistentscoreboard = (PersistentScoreboard) worldpersistentdata.a(PersistentScoreboard::new, "scoreboard"); -@@ -286,7 +346,7 @@ + ScoreboardServer scoreboardserver = this.getScoreboard(); + + Objects.requireNonNull(scoreboardserver); +- Function function = scoreboardserver::a; ++ Function function = scoreboardserver::a; // CraftBukkit - decompile error + ScoreboardServer scoreboardserver1 = this.getScoreboard(); + + Objects.requireNonNull(scoreboardserver1); +@@ -333,7 +393,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 a = SystemUtils.getMonotonicMillis(); + private long timeStamp = SystemUtils.getMonotonicMillis(); -@@ -309,48 +369,197 @@ +@@ -362,48 +422,197 @@ } - protected void loadWorld() { - this.loadResourcesZip(); -- this.saveData.a(this.getServerModName(), this.getModded().isPresent()); -- WorldLoadListener worldloadlistener = this.worldLoadListenerFactory.create(11); +- this.worldData.a(this.getServerModName(), this.getModded().isPresent()); +- WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11); + protected void loadWorld(String s) { + // CraftBukkit start -+ Convertable.ConversionSession worldSession = this.convertable; -+ IRegistryCustom.Dimension iregistrycustom_dimension = this.customRegistry; -+ RegistryReadOps registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, this.dataPackResources.h(), iregistrycustom_dimension); ++ Convertable.ConversionSession worldSession = this.storageSource; ++ IRegistryCustom.Dimension iregistrycustom_dimension = this.registryHolder; ++ RegistryReadOps registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.INSTANCE, this.resources.i(), (IRegistryCustom) iregistrycustom_dimension); + WorldDataServer overworldData = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, datapackconfiguration); + if (overworldData == null) { + WorldSettings worldsettings; + GeneratorSettings generatorsettings; + + if (this.isDemoMode()) { -+ worldsettings = MinecraftServer.c; ++ worldsettings = MinecraftServer.DEMO_SETTINGS; + generatorsettings = GeneratorSettings.a((IRegistryCustom) iregistrycustom_dimension); + } else { + DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getDedicatedServerProperties(); + + worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), datapackconfiguration); -+ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.generatorSettings.j() : dedicatedserverproperties.generatorSettings; ++ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.worldGenSettings.j() : dedicatedserverproperties.worldGenSettings; + } + + overworldData = new WorldDataServer(worldsettings, generatorsettings, Lifecycle.stable()); @@ -156,13 +164,13 @@ + WorldServer world; + int dimension = 0; + -+ if (dimensionKey == WorldDimension.THE_NETHER) { ++ if (dimensionKey == WorldDimension.NETHER) { + if (getAllowNether()) { + dimension = -1; + } else { + continue; + } -+ } else if (dimensionKey == WorldDimension.THE_END) { ++ } else if (dimensionKey == WorldDimension.END) { + if (server.getAllowEnd()) { + dimension = 1; + } else { @@ -225,13 +233,13 @@ + GeneratorSettings generatorsettings; + + if (this.isDemoMode()) { -+ worldsettings = MinecraftServer.c; ++ worldsettings = MinecraftServer.DEMO_SETTINGS; + generatorsettings = GeneratorSettings.a((IRegistryCustom) iregistrycustom_dimension); + } else { + DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getDedicatedServerProperties(); + + worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), datapackconfiguration); -+ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.generatorSettings.j() : dedicatedserverproperties.generatorSettings; ++ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.worldGenSettings.j() : dedicatedserverproperties.worldGenSettings; + } + + worlddata = new WorldDataServer(worldsettings, generatorsettings, Lifecycle.stable()); @@ -241,7 +249,7 @@ + net.minecraft.server.Main.convertWorld(worldSession, DataConverterRegistry.a(), options.has("eraseCache"), () -> { + return true; + }, worlddata.getGeneratorSettings().d().d().stream().map((entry1) -> { -+ return ResourceKey.a(IRegistry.K, ((ResourceKey) entry1.getKey()).a()); ++ return ResourceKey.a(IRegistry.DIMENSION_TYPE_REGISTRY, ((ResourceKey) entry1.getKey()).a()); + }).collect(ImmutableSet.toImmutableSet())); + } + @@ -256,35 +264,35 @@ + ChunkGenerator chunkgenerator; + + if (worlddimension == null) { -+ dimensionmanager = (DimensionManager) this.customRegistry.a().d(DimensionManager.OVERWORLD); -+ chunkgenerator = GeneratorSettings.a(customRegistry.b(IRegistry.ay), customRegistry.b(IRegistry.ar), (new Random()).nextLong()); ++ 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()); + } else { + dimensionmanager = worlddimension.b(); + chunkgenerator = worlddimension.c(); + } + -+ ResourceKey worldKey = ResourceKey.a(IRegistry.L, dimensionKey.a()); ++ ResourceKey worldKey = ResourceKey.a(IRegistry.DIMENSION_REGISTRY, dimensionKey.a()); + + if (dimensionKey == WorldDimension.OVERWORLD) { -+ this.saveData = worlddata; -+ this.saveData.setGameType(((DedicatedServer) this).getDedicatedServerProperties().gamemode); // From DedicatedServer.init ++ this.worldData = worlddata; ++ this.worldData.setGameType(((DedicatedServer) this).getDedicatedServerProperties().gamemode); // From DedicatedServer.init + -+ WorldLoadListener worldloadlistener = this.worldLoadListenerFactory.create(11); ++ WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11); + -+ world = new WorldServer(this, this.executorService, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, list, true, org.bukkit.World.Environment.getEnvironment(dimension), gen); ++ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, list, true, org.bukkit.World.Environment.getEnvironment(dimension), gen); + WorldPersistentData worldpersistentdata = world.getWorldPersistentData(); + this.initializeScoreboards(worldpersistentdata); + this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard()); -+ this.persistentCommandStorage = new PersistentCommandStorage(worldpersistentdata); ++ this.commandStorage = new PersistentCommandStorage(worldpersistentdata); + } else { -+ WorldLoadListener worldloadlistener = this.worldLoadListenerFactory.create(11); -+ world = new WorldServer(this, this.executorService, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen); ++ WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11); ++ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen); + } + + worlddata.a(this.getServerModName(), this.getModded().isPresent()); -+ this.initWorld(world, worlddata, saveData, worlddata.getGeneratorSettings()); ++ this.initWorld(world, worlddata, worldData, worlddata.getGeneratorSettings()); + -+ this.worldServer.put(world.getDimensionKey(), world); ++ this.levels.put(world.getDimensionKey(), world); + this.getPlayerList().setPlayerFileData(world); + + if (worlddata.getCustomBossEvents() != null) { @@ -294,21 +302,21 @@ this.updateWorldSettings(); - this.loadSpawn(worldloadlistener); + for (WorldServer worldserver : this.getWorlds()) { -+ this.loadSpawn(worldserver.getChunkProvider().playerChunkMap.worldLoadListener, worldserver); ++ this.loadSpawn(worldserver.getChunkProvider().chunkMap.progressListener, worldserver); + this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(worldserver.getWorld())); + } + + this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD); + this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP)); -+ this.serverConnection.acceptConnections(); ++ this.connection.acceptConnections(); + // CraftBukkit end } protected void updateWorldSettings() {} - protected void a(WorldLoadListener worldloadlistener) { -- IWorldDataServer iworlddataserver = this.saveData.H(); -- GeneratorSettings generatorsettings = this.saveData.getGeneratorSettings(); +- IWorldDataServer iworlddataserver = this.worldData.H(); +- GeneratorSettings generatorsettings = this.worldData.getGeneratorSettings(); + // CraftBukkit start + public void initWorld(WorldServer worldserver, IWorldDataServer iworlddataserver, SaveData saveData, GeneratorSettings generatorsettings) { boolean flag = generatorsettings.isDebugWorld(); @@ -321,8 +329,8 @@ - Object object; - - if (worlddimension == null) { -- dimensionmanager = (DimensionManager) this.customRegistry.a().d(DimensionManager.OVERWORLD); -- object = GeneratorSettings.a(this.customRegistry.b(IRegistry.ay), this.customRegistry.b(IRegistry.ar), (new Random()).nextLong()); +- 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(); @@ -331,28 +339,28 @@ + worldserver.getWorld().getPopulators().addAll(worldserver.generator.getDefaultPopulators(worldserver.getWorld())); } - -- WorldServer worldserver = new WorldServer(this, this.executorService, this.convertable, iworlddataserver, World.OVERWORLD, dimensionmanager, worldloadlistener, (ChunkGenerator) object, flag, j, list, true); +- WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, dimensionmanager, worldloadlistener, (ChunkGenerator) object, flag, j, list, true); - -- this.worldServer.put(World.OVERWORLD, worldserver); +- this.levels.put(World.OVERWORLD, worldserver); - WorldPersistentData worldpersistentdata = worldserver.getWorldPersistentData(); - - this.initializeScoreboards(worldpersistentdata); -- this.persistentCommandStorage = new PersistentCommandStorage(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, true); -@@ -372,31 +581,8 @@ + a(worldserver, iworlddataserver, generatorsettings.c(), flag); +@@ -425,31 +634,8 @@ iworlddataserver.c(true); } - - this.getPlayerList().setPlayerFileData(worldserver); -- if (this.saveData.getCustomBossEvents() != null) { -- this.getBossBattleCustomData().load(this.saveData.getCustomBossEvents()); +- if (this.worldData.getCustomBossEvents() != null) { +- this.getBossBattleCustomData().load(this.worldData.getCustomBossEvents()); - } - - Iterator iterator = registrymaterials.d().iterator(); @@ -362,23 +370,23 @@ - ResourceKey resourcekey = (ResourceKey) entry.getKey(); - - if (resourcekey != WorldDimension.OVERWORLD) { -- ResourceKey resourcekey1 = ResourceKey.a(IRegistry.L, resourcekey.a()); +- ResourceKey resourcekey1 = ResourceKey.a(IRegistry.DIMENSION_REGISTRY, resourcekey.a()); - DimensionManager dimensionmanager1 = ((WorldDimension) entry.getValue()).b(); - ChunkGenerator chunkgenerator = ((WorldDimension) entry.getValue()).c(); -- SecondaryWorldData secondaryworlddata = new SecondaryWorldData(this.saveData, iworlddataserver); -- WorldServer worldserver1 = new WorldServer(this, this.executorService, this.convertable, secondaryworlddata, resourcekey1, dimensionmanager1, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), false); +- 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()))); -- this.worldServer.put(resourcekey1, worldserver1); +- this.levels.put(resourcekey1, worldserver1); - } - } - } + // CraftBukkit end - private static void a(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1, boolean flag2) { - ChunkGenerator chunkgenerator = worldserver.getChunkProvider().getChunkGenerator(); -@@ -412,6 +598,21 @@ + private static void a(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) { + if (flag1) { +@@ -462,6 +648,21 @@ return biomebase.b().b(); }, random); ChunkCoordIntPair chunkcoordintpair = blockposition == null ? new ChunkCoordIntPair(0, 0) : new ChunkCoordIntPair(blockposition); @@ -400,60 +408,58 @@ if (blockposition == null) { MinecraftServer.LOGGER.warn("Unable to find spawn biome"); -@@ -478,8 +679,15 @@ +@@ -536,8 +737,15 @@ iworlddataserver.setGameType(EnumGamemode.SPECTATOR); } - public void loadSpawn(WorldLoadListener worldloadlistener) { -- WorldServer worldserver = this.E(); +- WorldServer worldserver = this.F(); + // CraftBukkit start + public void loadSpawn(WorldLoadListener worldloadlistener, WorldServer worldserver) { + if (!worldserver.getWorld().getKeepSpawnInMemory()) { + return; + } + -+ // WorldServer worldserver = this.E(); ++ // WorldServer worldserver = this.F(); + this.forceTicks = true; + // CraftBukkit end MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.getDimensionKey().a()); BlockPosition blockposition = worldserver.getSpawn(); -@@ -492,17 +700,21 @@ +@@ -550,16 +758,20 @@ chunkproviderserver.addTicket(TicketType.START, new ChunkCoordIntPair(blockposition), 11, Unit.INSTANCE); while (chunkproviderserver.b() != 441) { -- this.nextTick = SystemUtils.getMonotonicMillis() + 10L; +- this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L; - this.sleepForTick(); + // CraftBukkit start -+ // this.nextTick = SystemUtils.getMonotonicMillis() + 10L; ++ // this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L; + this.executeModerately(); + // CraftBukkit end } -- this.nextTick = SystemUtils.getMonotonicMillis() + 10L; +- this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L; - this.sleepForTick(); -- Iterator iterator = this.worldServer.values().iterator(); +- Iterator iterator = this.levels.values().iterator(); - - while (iterator.hasNext()) { - WorldServer worldserver1 = (WorldServer) iterator.next(); -- ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getWorldPersistentData().b(ForcedChunk::new, "chunks"); + // CraftBukkit start -+ // this.nextTick = SystemUtils.getMonotonicMillis() + 10L; ++ // this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L; + this.executeModerately(); + // Iterator iterator = this.worldServer.values().iterator(); + + if (true) { + WorldServer worldserver1 = worldserver; -+ ForcedChunk forcedchunk = (ForcedChunk) worldserver.getWorldPersistentData().b(ForcedChunk::new, "chunks"); + // CraftBukkit end + ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getWorldPersistentData().a(ForcedChunk::b, "chunks"); if (forcedchunk != null) { - LongIterator longiterator = forcedchunk.a().iterator(); -@@ -516,11 +728,18 @@ +@@ -574,11 +786,18 @@ } } -- this.nextTick = SystemUtils.getMonotonicMillis() + 10L; +- this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L; - this.sleepForTick(); + // CraftBukkit start + // this.nextTick = SystemUtils.getMonotonicMillis() + 10L; @@ -471,24 +477,24 @@ } protected void loadResourcesZip() { -@@ -565,12 +784,16 @@ - worldserver.save((IProgressUpdate) null, flag1, worldserver.savingDisabled && !flag2); +@@ -623,12 +842,16 @@ + worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2); } + // CraftBukkit start - moved to WorldServer.save + /* - WorldServer worldserver1 = this.E(); - IWorldDataServer iworlddataserver = this.saveData.H(); + WorldServer worldserver1 = this.F(); + IWorldDataServer iworlddataserver = this.worldData.H(); iworlddataserver.a(worldserver1.getWorldBorder().t()); - this.saveData.setCustomBossEvents(this.getBossBattleCustomData().save()); - this.convertable.a(this.customRegistry, this.saveData, this.getPlayerList().save()); + this.worldData.setCustomBossEvents(this.getBossBattleCustomData().save()); + this.storageSource.a(this.registryHolder, this.worldData, this.getPlayerList().save()); + */ + // CraftBukkit end return flag3; } -@@ -579,8 +802,29 @@ +@@ -637,8 +860,29 @@ this.stop(); } @@ -502,7 +508,7 @@ + } + // CraftBukkit end + - protected void stop() { + public void stop() { + // CraftBukkit start - prevent double stopping on multiple threads + synchronized(stopLock) { + if (hasStopped) return; @@ -518,7 +524,7 @@ if (this.getServerConnection() != null) { this.getServerConnection().b(); } -@@ -589,6 +833,7 @@ +@@ -647,6 +891,7 @@ MinecraftServer.LOGGER.info("Saving players"); this.playerList.savePlayers(); this.playerList.shutdown(); @@ -526,25 +532,27 @@ } MinecraftServer.LOGGER.info("Saving worlds"); -@@ -666,14 +911,16 @@ - while (this.isRunning) { - long i = SystemUtils.getMonotonicMillis() - this.nextTick; +@@ -724,9 +969,10 @@ + while (this.running) { + long i = SystemUtils.getMonotonicMillis() - this.nextTickTime; -- if (i > 2000L && this.nextTick - this.lastOverloadTime >= 15000L) { -+ if (i > 5000L && this.nextTick - this.lastOverloadTime >= 30000L) { // CraftBukkit +- if (i > 2000L && this.nextTickTime - this.lastOverloadWarning >= 15000L) { ++ if (i > 5000L && this.nextTickTime - this.lastOverloadWarning >= 30000L) { // CraftBukkit long j = i / 50L; + if (server.getWarnOnOverload()) // CraftBukkit MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j); - this.nextTick += j * 50L; - this.lastOverloadTime = this.nextTick; + this.nextTickTime += j * 50L; + this.lastOverloadWarning = this.nextTickTime; +@@ -737,6 +983,7 @@ + this.debugCommandProfiler = new MinecraftServer.a(SystemUtils.getMonotonicNanos(), this.tickCount); } + MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit - this.nextTick += 50L; - GameProfilerTick gameprofilertick = GameProfilerTick.a("Server"); - -@@ -719,6 +966,12 @@ + this.nextTickTime += 50L; + this.bi(); + this.profiler.enter("tick"); +@@ -782,6 +1029,12 @@ } catch (Throwable throwable1) { MinecraftServer.LOGGER.error("Exception stopping the server", throwable1); } finally { @@ -557,13 +565,13 @@ this.exit(); } -@@ -727,8 +980,15 @@ +@@ -790,8 +1043,15 @@ } private boolean canSleepForTick() { -- return this.isEntered() || SystemUtils.getMonotonicMillis() < (this.X ? this.W : this.nextTick); +- return this.isEntered() || SystemUtils.getMonotonicMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime); + // CraftBukkit start -+ return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < (this.X ? this.W : this.nextTick); ++ return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime); + } + + private void executeModerately() { @@ -574,23 +582,23 @@ protected void sleepForTick() { this.executeAll(); -@@ -834,7 +1094,7 @@ - this.serverPing.b().a(agameprofile); +@@ -906,7 +1166,7 @@ + this.status.b().a(agameprofile); } -- if (this.ticks % 6000 == 0) { -+ if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit +- if (this.tickCount % 6000 == 0) { ++ if (autosavePeriod > 0 && this.tickCount % autosavePeriod == 0) { // CraftBukkit MinecraftServer.LOGGER.debug("Autosave started"); - this.methodProfiler.enter("save"); + this.profiler.enter("save"); this.playerList.savePlayers(); -@@ -864,22 +1124,39 @@ +@@ -936,22 +1196,39 @@ } - protected void b(BooleanSupplier booleansupplier) { -+ this.server.getScheduler().mainThreadHeartbeat(this.ticks); // CraftBukkit - this.methodProfiler.enter("commandFunctions"); + public void b(BooleanSupplier booleansupplier) { ++ this.server.getScheduler().mainThreadHeartbeat(this.tickCount); // CraftBukkit + this.profiler.enter("commandFunctions"); this.getFunctionData().tick(); - this.methodProfiler.exitEnter("levels"); + this.profiler.exitEnter("levels"); Iterator iterator = this.getWorlds().iterator(); + // CraftBukkit start @@ -600,59 +608,59 @@ + } + + // Send time updates to everyone, it will get the right time from the world the player is in. -+ if (this.ticks % 20 == 0) { ++ if (this.tickCount % 20 == 0) { + for (int i = 0; i < this.getPlayerList().players.size(); ++i) { + EntityPlayer entityplayer = (EntityPlayer) this.getPlayerList().players.get(i); -+ entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(entityplayer.world.getTime(), entityplayer.getPlayerTime(), entityplayer.world.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))); // Add support for per player time ++ entityplayer.connection.sendPacket(new PacketPlayOutUpdateTime(entityplayer.level.getTime(), entityplayer.getPlayerTime(), entityplayer.level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); // Add support for per player time + } + } + while (iterator.hasNext()) { WorldServer worldserver = (WorldServer) iterator.next(); - this.methodProfiler.a(() -> { + this.profiler.a(() -> { return worldserver + " " + worldserver.getDimensionKey().a(); }); + /* Drop global time updates - if (this.ticks % 20 == 0) { - this.methodProfiler.enter("timeSync"); - this.playerList.a((Packet) (new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))), worldserver.getDimensionKey()); - this.methodProfiler.exit(); + 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(); } + // CraftBukkit end */ - this.methodProfiler.enter("tick"); + this.profiler.enter("tick"); -@@ -963,7 +1240,7 @@ - } +@@ -1040,7 +1317,7 @@ + @DontObfuscate public String getServerModName() { - return "vanilla"; + return server.getName(); // CraftBukkit - cb > vanilla! } - public CrashReport b(CrashReport crashreport) { -@@ -1320,16 +1597,17 @@ + public SystemReport b(SystemReport systemreport) { +@@ -1412,16 +1689,17 @@ public CompletableFuture a(Collection collection) { CompletableFuture completablefuture = CompletableFuture.supplyAsync(() -> { - Stream stream = collection.stream(); + Stream stream = collection.stream(); // CraftBukkit - decompile error - ResourcePackRepository resourcepackrepository = this.resourcePackRepository; + ResourcePackRepository resourcepackrepository = this.packRepository; - this.resourcePackRepository.getClass(); + 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 }, this).thenCompose((immutablelist) -> { - return DataPackResources.a(immutablelist, this.j() ? CommandDispatcher.ServerType.DEDICATED : CommandDispatcher.ServerType.INTEGRATED, this.h(), this.executorService, this); + return DataPackResources.a(immutablelist, this.registryHolder, this.k() ? CommandDispatcher.ServerType.DEDICATED : CommandDispatcher.ServerType.INTEGRATED, this.i(), this.executor, this); }).thenAcceptAsync((datapackresources) -> { - this.dataPackResources.close(); - this.dataPackResources = datapackresources; + this.resources.close(); + this.resources = datapackresources; + this.server.syncCommands(); // SPIGOT-5884: Lost on reload - this.resourcePackRepository.a(collection); - this.saveData.a(a(this.resourcePackRepository)); - datapackresources.i(); -@@ -1695,6 +1973,22 @@ + this.packRepository.a(collection); + this.worldData.a(a(this.packRepository)); + datapackresources.j(); +@@ -1766,6 +2044,22 @@ } @@ -672,6 +680,6 @@ + } + // CraftBukkit end + - private void a(@Nullable GameProfilerTick gameprofilertick) { - if (this.O) { - this.O = false; + private void bi() { + if (this.willStartRecordingMetrics) { + this.metricsRecorder = ActiveMetricsRecorder.a(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.k()), SystemUtils.timeSource, SystemUtils.g(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> { diff --git a/nms-patches/net/minecraft/server/ScoreboardServer.patch b/nms-patches/net/minecraft/server/ScoreboardServer.patch index 8de9c327c..7f7fcf3d4 100644 --- a/nms-patches/net/minecraft/server/ScoreboardServer.patch +++ b/nms-patches/net/minecraft/server/ScoreboardServer.patch @@ -1,100 +1,100 @@ --- a/net/minecraft/server/ScoreboardServer.java +++ b/net/minecraft/server/ScoreboardServer.java -@@ -32,7 +32,7 @@ +@@ -34,7 +34,7 @@ public void handleScoreChanged(ScoreboardScore scoreboardscore) { super.handleScoreChanged(scoreboardscore); - if (this.b.contains(scoreboardscore.getObjective())) { -- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, scoreboardscore.getObjective().getName(), scoreboardscore.getPlayerName(), scoreboardscore.getScore())); + 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.b(); -@@ -41,7 +41,7 @@ + this.a(); +@@ -43,7 +43,7 @@ @Override public void handlePlayerRemoved(String s) { super.handlePlayerRemoved(s); -- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, (String) null, s, 0)); +- 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.b(); + this.a(); } -@@ -49,7 +49,7 @@ +@@ -51,7 +51,7 @@ public void a(String s, ScoreboardObjective scoreboardobjective) { super.a(s, scoreboardobjective); - if (this.b.contains(scoreboardobjective)) { -- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, scoreboardobjective.getName(), s, 0)); + 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.b(); -@@ -62,7 +62,7 @@ + this.a(); +@@ -64,7 +64,7 @@ super.setDisplaySlot(i, scoreboardobjective); if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) { if (this.h(scoreboardobjective1) > 0) { -- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); +- this.server.getPlayerList().sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); + this.sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); } else { this.g(scoreboardobjective1); } -@@ -70,7 +70,7 @@ +@@ -72,7 +72,7 @@ if (scoreboardobjective != null) { - if (this.b.contains(scoreboardobjective)) { -- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); + if (this.trackedObjectives.contains(scoreboardobjective)) { +- this.server.getPlayerList().sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); + this.sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); } else { this.e(scoreboardobjective); } -@@ -82,7 +82,7 @@ +@@ -84,7 +84,7 @@ @Override public boolean addPlayerToTeam(String s, ScoreboardTeam scoreboardteam) { if (super.addPlayerToTeam(s, scoreboardteam)) { -- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(s), 3)); -+ this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(s), 3)); - this.b(); +- this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.ADD)); ++ this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.ADD)); + this.a(); return true; } else { -@@ -93,7 +93,7 @@ +@@ -95,7 +95,7 @@ @Override public void removePlayerFromTeam(String s, ScoreboardTeam scoreboardteam) { super.removePlayerFromTeam(s, scoreboardteam); -- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(s), 4)); -+ this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(s), 4)); - this.b(); +- this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.REMOVE)); ++ this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.REMOVE)); + this.a(); } -@@ -107,7 +107,7 @@ +@@ -109,7 +109,7 @@ public void handleObjectiveChanged(ScoreboardObjective scoreboardobjective) { super.handleObjectiveChanged(scoreboardobjective); - if (this.b.contains(scoreboardobjective)) { -- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2)); + if (this.trackedObjectives.contains(scoreboardobjective)) { +- this.server.getPlayerList().sendAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2)); + this.sendAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2)); } - this.b(); -@@ -126,21 +126,21 @@ + this.a(); +@@ -128,21 +128,21 @@ @Override public void handleTeamAdded(ScoreboardTeam scoreboardteam) { super.handleTeamAdded(scoreboardteam); -- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 0)); -+ this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 0)); - this.b(); +- this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, true)); ++ this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, true)); + this.a(); } @Override public void handleTeamChanged(ScoreboardTeam scoreboardteam) { super.handleTeamChanged(scoreboardteam); -- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 2)); -+ this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 2)); - this.b(); +- this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, false)); ++ this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, false)); + this.a(); } @Override public void handleTeamRemoved(ScoreboardTeam scoreboardteam) { super.handleTeamRemoved(scoreboardteam); -- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 1)); -+ this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 1)); - this.b(); +- this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam)); ++ this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam)); + this.a(); } @@ -189,6 +189,7 @@ @@ -113,15 +113,15 @@ Iterator iterator1 = list.iterator(); while (iterator1.hasNext()) { -@@ -245,6 +247,16 @@ - return i; +@@ -257,6 +259,16 @@ + return this.b().b(nbttagcompound); } + // CraftBukkit start - Send to players + private void sendAll(Packet packet) { -+ for (EntityPlayer entityplayer : (List) this.a.getPlayerList().players) { ++ for (EntityPlayer entityplayer : (List) this.server.getPlayerList().players) { + if (entityplayer.getBukkitEntity().getScoreboard().getHandle() == this) { -+ entityplayer.playerConnection.sendPacket(packet); ++ entityplayer.connection.sendPacket(packet); + } + } + } diff --git a/nms-patches/net/minecraft/server/bossevents/BossBattleCustom.patch b/nms-patches/net/minecraft/server/bossevents/BossBattleCustom.patch index e8a5292d5..896ccb39e 100644 --- a/nms-patches/net/minecraft/server/bossevents/BossBattleCustom.patch +++ b/nms-patches/net/minecraft/server/bossevents/BossBattleCustom.patch @@ -11,10 +11,10 @@ + public class BossBattleCustom extends BossBattleServer { - private final MinecraftKey h; - private final Set i = Sets.newHashSet(); - private int j; - private int k = 100; + private final MinecraftKey id; + private final Set players = Sets.newHashSet(); + private int value; + private int max = 100; + // CraftBukkit start + private KeyedBossBar bossBar; + diff --git a/nms-patches/net/minecraft/server/commands/CommandEffect.patch b/nms-patches/net/minecraft/server/commands/CommandEffect.patch index c7a2f22e4..04b9eb3e4 100644 --- a/nms-patches/net/minecraft/server/commands/CommandEffect.patch +++ b/nms-patches/net/minecraft/server/commands/CommandEffect.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/commands/CommandEffect.java +++ b/net/minecraft/server/commands/CommandEffect.java -@@ -71,7 +71,7 @@ +@@ -73,7 +73,7 @@ if (entity instanceof EntityLiving) { MobEffect mobeffect = new MobEffect(mobeffectlist, k, i, false, flag); -- if (((EntityLiving) entity).addEffect(mobeffect)) { -+ if (((EntityLiving) entity).addEffect(mobeffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit +- if (((EntityLiving) entity).addEffect(mobeffect, commandlistenerwrapper.getEntity())) { ++ if (((EntityLiving) entity).addEffect(mobeffect, commandlistenerwrapper.getEntity(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit ++j; } } -@@ -97,7 +97,7 @@ +@@ -99,7 +99,7 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); @@ -18,7 +18,7 @@ ++i; } } -@@ -122,7 +122,7 @@ +@@ -124,7 +124,7 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); diff --git a/nms-patches/net/minecraft/server/commands/CommandGamemode.patch b/nms-patches/net/minecraft/server/commands/CommandGamemode.patch deleted file mode 100644 index a6e32badd..000000000 --- a/nms-patches/net/minecraft/server/commands/CommandGamemode.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/server/commands/CommandGamemode.java -+++ b/net/minecraft/server/commands/CommandGamemode.java -@@ -63,6 +63,12 @@ - - if (entityplayer.playerInteractManager.getGameMode() != enumgamemode) { - entityplayer.a(enumgamemode); -+ // CraftBukkit start - handle event cancelling the change -+ if (entityplayer.playerInteractManager.getGameMode() != enumgamemode) { -+ commandcontext.getSource().sendFailureMessage(new net.minecraft.network.chat.ChatComponentText("Failed to set the gamemode of '" + entityplayer.getName() + "'")); -+ continue; -+ } -+ // CraftBukkit end - a((CommandListenerWrapper) commandcontext.getSource(), entityplayer, enumgamemode); - ++i; - } diff --git a/nms-patches/net/minecraft/server/commands/CommandGamerule.patch b/nms-patches/net/minecraft/server/commands/CommandGamerule.patch index b15ef20f8..ac5aa4d31 100644 --- a/nms-patches/net/minecraft/server/commands/CommandGamerule.patch +++ b/nms-patches/net/minecraft/server/commands/CommandGamerule.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/server/commands/CommandGamerule.java +++ b/net/minecraft/server/commands/CommandGamerule.java -@@ -29,7 +29,7 @@ +@@ -31,7 +31,7 @@ - private static > int b(CommandContext commandcontext, GameRules.GameRuleKey gamerules_gamerulekey) { + static > int a(CommandContext commandcontext, GameRules.GameRuleKey gamerules_gamerulekey) { CommandListenerWrapper commandlistenerwrapper = (CommandListenerWrapper) commandcontext.getSource(); - T t0 = commandlistenerwrapper.getServer().getGameRules().get(gamerules_gamerulekey); + T t0 = commandlistenerwrapper.getWorld().getGameRules().get(gamerules_gamerulekey); // CraftBukkit t0.b(commandcontext, "value"); commandlistenerwrapper.sendMessage(new ChatMessage("commands.gamerule.set", new Object[]{gamerules_gamerulekey.a(), t0.toString()}), true); -@@ -37,7 +37,7 @@ +@@ -39,7 +39,7 @@ } - private static > int b(CommandListenerWrapper commandlistenerwrapper, GameRules.GameRuleKey gamerules_gamerulekey) { + static > int a(CommandListenerWrapper commandlistenerwrapper, GameRules.GameRuleKey gamerules_gamerulekey) { - T t0 = commandlistenerwrapper.getServer().getGameRules().get(gamerules_gamerulekey); + T t0 = commandlistenerwrapper.getWorld().getGameRules().get(gamerules_gamerulekey); // CraftBukkit diff --git a/nms-patches/net/minecraft/server/commands/CommandList.patch b/nms-patches/net/minecraft/server/commands/CommandList.patch index e69728edf..cf9bddb53 100644 --- a/nms-patches/net/minecraft/server/commands/CommandList.patch +++ b/nms-patches/net/minecraft/server/commands/CommandList.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/CommandList.java +++ b/net/minecraft/server/commands/CommandList.java -@@ -36,6 +36,12 @@ +@@ -37,6 +37,12 @@ private static int a(CommandListenerWrapper commandlistenerwrapper, Function function) { PlayerList playerlist = commandlistenerwrapper.getServer().getPlayerList(); List list = playerlist.getPlayers(); @@ -10,6 +10,6 @@ + list = list.stream().filter((ep) -> sender.canSee(ep.getBukkitEntity())).collect(java.util.stream.Collectors.toList()); + } + // CraftBukkit end - IChatMutableComponent ichatmutablecomponent = ChatComponentUtils.b(list, function); + IChatBaseComponent ichatbasecomponent = ChatComponentUtils.b(list, function); - commandlistenerwrapper.sendMessage(new ChatMessage("commands.list.players", new Object[]{list.size(), playerlist.getMaxPlayers(), ichatmutablecomponent}), false); + commandlistenerwrapper.sendMessage(new ChatMessage("commands.list.players", new Object[]{list.size(), playerlist.getMaxPlayers(), ichatbasecomponent}), false); diff --git a/nms-patches/net/minecraft/server/commands/CommandReload.patch b/nms-patches/net/minecraft/server/commands/CommandReload.patch index aa80246d7..4af5a0e99 100644 --- a/nms-patches/net/minecraft/server/commands/CommandReload.patch +++ b/nms-patches/net/minecraft/server/commands/CommandReload.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/CommandReload.java +++ b/net/minecraft/server/commands/CommandReload.java -@@ -42,6 +42,16 @@ +@@ -44,6 +44,16 @@ return collection1; } diff --git a/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch b/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch index 908a245e6..27e25e1ed 100644 --- a/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch +++ b/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/CommandSpreadPlayers.java +++ b/net/minecraft/server/commands/CommandSpreadPlayers.java -@@ -77,7 +77,7 @@ +@@ -80,7 +80,7 @@ if (entity instanceof EntityHuman) { set.add(entity.getScoreboardTeam()); } else { @@ -9,27 +9,27 @@ } } -@@ -286,7 +286,7 @@ +@@ -289,7 +289,7 @@ - for (boolean flag2 = iblockaccess.getType(blockposition_mutableblockposition).isAir(); blockposition_mutableblockposition.getY() > 0; flag2 = flag1) { + 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 if (!flag1 && flag2 && flag) { return blockposition_mutableblockposition.getY() + 1; } -@@ -299,7 +299,7 @@ +@@ -302,7 +302,7 @@ public boolean b(IBlockAccess iblockaccess, int i) { - BlockPosition blockposition = new BlockPosition(this.a, (double) (this.a(iblockaccess, i) - 1), this.b); + 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 Material material = iblockdata.getMaterial(); return blockposition.getY() < i && !material.isLiquid() && material != Material.FIRE; -@@ -309,5 +309,12 @@ - this.a = MathHelper.a(random, d0, d2); - this.b = MathHelper.a(random, d1, d3); +@@ -312,5 +312,12 @@ + this.x = MathHelper.a(random, d0, d2); + this.z = MathHelper.a(random, d1, d3); } + + // CraftBukkit start - add a version of getType which force loads chunks diff --git a/nms-patches/net/minecraft/server/commands/CommandSummon.patch b/nms-patches/net/minecraft/server/commands/CommandSummon.patch index a8fc0d1be..f39ba596e 100644 --- a/nms-patches/net/minecraft/server/commands/CommandSummon.patch +++ b/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 -@@ -64,7 +64,7 @@ +@@ -66,7 +66,7 @@ ((EntityInsentient) entity).prepare(commandlistenerwrapper.getWorld(), commandlistenerwrapper.getWorld().getDamageScaler(entity.getChunkCoordinates()), 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" - throw CommandSummon.b.create(); + throw CommandSummon.ERROR_DUPLICATE_UUID.create(); } else { commandlistenerwrapper.sendMessage(new ChatMessage("commands.summon.success", new Object[]{entity.getScoreboardDisplayName()}), true); diff --git a/nms-patches/net/minecraft/server/commands/CommandTeleport.patch b/nms-patches/net/minecraft/server/commands/CommandTeleport.patch index d00d4e10d..950103f01 100644 --- a/nms-patches/net/minecraft/server/commands/CommandTeleport.patch +++ b/nms-patches/net/minecraft/server/commands/CommandTeleport.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/CommandTeleport.java +++ b/net/minecraft/server/commands/CommandTeleport.java -@@ -35,6 +35,12 @@ +@@ -36,6 +36,12 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; @@ -12,25 +12,23 @@ + public class CommandTeleport { - private static final SimpleCommandExceptionType a = new SimpleCommandExceptionType(new ChatMessage("commands.teleport.invalidPosition")); -@@ -150,9 +156,9 @@ + private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(new ChatMessage("commands.teleport.invalidPosition")); +@@ -160,14 +166,29 @@ } - if (worldserver == entity.world) { -- ((EntityPlayer) entity).playerConnection.a(d0, d1, d2, f, f1, set); -+ ((EntityPlayer) entity).playerConnection.a(d0, d1, d2, f, f1, set, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit + 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 } else { -- ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f, f1); -+ ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f, f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit +- ((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 } - entity.setHeadRotation(f); -@@ -161,6 +167,21 @@ - float f3 = MathHelper.g(f1); - - f3 = MathHelper.a(f3, -90.0F, 90.0F); + entity.setHeadRotation(f2); + } else { + float f4 = MathHelper.a(f3, -90.0F, 90.0F); + // CraftBukkit start - Teleport event -+ Location to = new Location(worldserver.getWorld(), d0, d1, d2, f2, f3); ++ Location to = new Location(worldserver.getWorld(), d0, d1, d2, f2, f4); + EntityTeleportEvent event = new EntityTeleportEvent(entity.getBukkitEntity(), entity.getBukkitEntity().getLocation(), to); + worldserver.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { @@ -41,9 +39,9 @@ + d1 = to.getY(); + d2 = to.getZ(); + f2 = to.getYaw(); -+ f3 = to.getPitch(); ++ f4 = to.getPitch(); + worldserver = ((CraftWorld) to.getWorld()).getHandle(); + // CraftBukkit end - if (worldserver == entity.world) { - entity.setPositionRotation(d0, d1, d2, f2, f3); - entity.setHeadRotation(f2); + + if (worldserver == entity.level) { + entity.setPositionRotation(d0, d1, d2, f2, f4); diff --git a/nms-patches/net/minecraft/server/commands/CommandTime.patch b/nms-patches/net/minecraft/server/commands/CommandTime.patch index 328f5225f..e2ab21606 100644 --- a/nms-patches/net/minecraft/server/commands/CommandTime.patch +++ b/nms-patches/net/minecraft/server/commands/CommandTime.patch @@ -11,8 +11,8 @@ + public class CommandTime { - public static void a(CommandDispatcher commanddispatcher) { -@@ -51,7 +56,13 @@ + public CommandTime() {} +@@ -53,7 +58,13 @@ while (iterator.hasNext()) { WorldServer worldserver = (WorldServer) iterator.next(); @@ -27,7 +27,7 @@ } commandlistenerwrapper.sendMessage(new ChatMessage("commands.time.set", new Object[]{i}), true); -@@ -64,7 +75,13 @@ +@@ -66,7 +77,13 @@ while (iterator.hasNext()) { WorldServer worldserver = (WorldServer) iterator.next(); diff --git a/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch b/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch index 403bb661b..6dea57681 100644 --- a/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch +++ b/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 -@@ -60,6 +60,15 @@ +@@ -64,6 +64,15 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -15,10 +15,10 @@ + public class DedicatedServer extends MinecraftServer implements IMinecraftServer { - private static final Logger LOGGER = LogManager.getLogger(); -@@ -74,8 +83,10 @@ + static final Logger LOGGER = LogManager.getLogger(); +@@ -82,8 +91,10 @@ @Nullable - private final TextFilter r; + private final IChatBaseComponent resourcePackPrompt; - public DedicatedServer(Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, DataPackResources datapackresources, SaveData savedata, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { - super(thread, iregistrycustom_dimension, convertable_conversionsession, savedata, resourcepackrepository, Proxy.NO_PROXY, datafixer, datapackresources, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory); @@ -26,10 +26,10 @@ + public DedicatedServer(joptsimple.OptionSet options, DataPackConfiguration datapackconfiguration, Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, DataPackResources datapackresources, SaveData savedata, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { + super(options, datapackconfiguration, thread, iregistrycustom_dimension, convertable_conversionsession, savedata, resourcepackrepository, Proxy.NO_PROXY, datafixer, datapackresources, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory); + // CraftBukkit end - this.propertyManager = dedicatedserversettings; - this.remoteControlCommandListener = new RemoteControlCommandListener(this); - this.r = null; -@@ -85,13 +96,44 @@ + this.settings = dedicatedserversettings; + this.rconConsoleSource = new RemoteControlCommandListener(this); + this.textFilterClient = TextFilter.a(dedicatedserversettings.getProperties().textFilteringConfig); +@@ -94,13 +105,44 @@ public boolean init() throws IOException { Thread thread = new Thread("Server console handler") { public void run() { @@ -77,7 +77,7 @@ } } catch (IOException ioexception) { DedicatedServer.LOGGER.error("Exception handling console input", ioexception); -@@ -100,6 +142,27 @@ +@@ -109,6 +151,27 @@ } }; @@ -105,21 +105,21 @@ thread.setDaemon(true); thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER)); thread.start(); -@@ -126,7 +189,7 @@ - this.setForceGamemode(dedicatedserverproperties.forceGamemode); +@@ -134,7 +197,7 @@ + this.setMotd(dedicatedserverproperties.motd); super.setIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get()); - this.i(dedicatedserverproperties.enforceWhitelist); -- this.saveData.setGameType(dedicatedserverproperties.gamemode); -+ // this.saveData.setGameType(dedicatedserverproperties.gamemode); // CraftBukkit - moved to world loading + this.h(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; -@@ -150,6 +213,12 @@ +@@ -158,6 +221,12 @@ return false; } + // CraftBukkit start -+ this.a((PlayerList) (new DedicatedPlayerList(this, this.customRegistry, this.worldNBTStorage))); ++ this.a((PlayerList) (new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage))); + server.loadPlugins(); + server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP); + // CraftBukkit end @@ -127,47 +127,46 @@ if (!this.getOnlineMode()) { DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); -@@ -164,7 +233,7 @@ +@@ -172,14 +241,14 @@ if (!NameReferencingFileConverter.e(this)) { return false; } else { -- this.a((PlayerList) (new DedicatedPlayerList(this, this.customRegistry, this.worldNBTStorage))); +- 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.c(dedicatedserverproperties.maxBuildHeight); -@@ -172,7 +241,7 @@ + TileEntitySkull.a(this.getUserCache()); TileEntitySkull.a(this.getMinecraftSessionService()); UserCache.a(this.getOnlineMode()); DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getWorld()); - this.loadWorld(); -+ this.loadWorld(convertable.getLevelName()); // CraftBukkit ++ this.loadWorld(storageSource.getLevelName()); // CraftBukkit long j = SystemUtils.getMonotonicNanos() - i; String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D); -@@ -189,6 +258,7 @@ +@@ -196,6 +265,7 @@ if (dedicatedserverproperties.enableRcon) { DedicatedServer.LOGGER.info("Starting remote control listener"); - this.remoteControlListener = RemoteControlListener.a((IMinecraftServer) this); -+ this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this.remoteControlCommandListener); // CraftBukkit + this.rconThread = RemoteControlListener.a((IMinecraftServer) this); ++ this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this.rconConsoleSource); // CraftBukkit } if (this.getMaxTickTime() > 0L) { -@@ -303,6 +373,7 @@ - this.remoteStatusListener.b(); +@@ -345,6 +415,7 @@ + this.queryThreadGs4.b(); } + System.exit(0); // CraftBukkit } @Override -@@ -331,7 +402,15 @@ - while (!this.serverCommandQueue.isEmpty()) { - ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0); +@@ -378,7 +449,15 @@ + while (!this.consoleInput.isEmpty()) { + ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0); -- this.getCommandDispatcher().a(servercommand.source, servercommand.command); +- this.getCommandDispatcher().a(servercommand.source, servercommand.msg); + // CraftBukkit start - ServerCommand for preprocessing -+ ServerCommandEvent event = new ServerCommandEvent(console, servercommand.command); ++ ServerCommandEvent event = new ServerCommandEvent(console, servercommand.msg); + server.getPluginManager().callEvent(event); + if (event.isCancelled()) continue; + servercommand = new ServerCommand(event.getCommand(), servercommand.source); @@ -178,7 +177,7 @@ } } -@@ -541,14 +620,45 @@ +@@ -583,14 +662,45 @@ @Override public String getPlugins() { @@ -211,24 +210,24 @@ @Override public String executeRemoteCommand(String s) { - this.remoteControlCommandListener.clearMessages(); + this.rconConsoleSource.clearMessages(); this.executeSync(() -> { -- this.getCommandDispatcher().a(this.remoteControlCommandListener.getWrapper(), s); +- this.getCommandDispatcher().a(this.rconConsoleSource.getWrapper(), 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(), remoteControlCommandListener.getWrapper()); ++ ServerCommand serverCommand = new ServerCommand(event.getCommand(), rconConsoleSource.getWrapper()); + server.dispatchServerCommand(remoteConsole, serverCommand); + // CraftBukkit end }); - return this.remoteControlCommandListener.getMessages(); + return this.rconConsoleSource.getMessages(); } -@@ -590,4 +700,15 @@ - public ITextFilter a(EntityPlayer entityplayer) { - return this.r != null ? this.r.a(entityplayer.getProfile()) : null; +@@ -663,4 +773,15 @@ + public IChatBaseComponent bb() { + return this.resourcePackPrompt; } + + // CraftBukkit start diff --git a/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch b/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch index dbf763a92..ebc4dd43c 100644 --- a/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch +++ b/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/dedicated/DedicatedServerProperties.java +++ b/net/minecraft/server/dedicated/DedicatedServerProperties.java -@@ -9,8 +9,14 @@ +@@ -10,8 +10,14 @@ import net.minecraft.world.level.EnumGamemode; import net.minecraft.world.level.levelgen.GeneratorSettings; @@ -15,35 +15,36 @@ 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", ""); -@@ -61,8 +67,10 @@ - public final PropertyManager.EditableProperty whiteList; - public final GeneratorSettings generatorSettings; +@@ -64,8 +70,10 @@ + @Nullable + public GeneratorSettings worldGenSettings; -- public DedicatedServerProperties(Properties properties, IRegistryCustom iregistrycustom) { +- public DedicatedServerProperties(Properties properties) { - super(properties); + // CraftBukkit start -+ public DedicatedServerProperties(Properties properties, IRegistryCustom iregistrycustom, OptionSet optionset) { ++ 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"); -@@ -113,12 +121,14 @@ - this.generatorSettings = GeneratorSettings.a(iregistrycustom, properties); +@@ -112,13 +120,15 @@ + this.whiteList = this.b("white-list", false); } -- public static DedicatedServerProperties load(IRegistryCustom iregistrycustom, Path path) { -- return new DedicatedServerProperties(loadPropertiesFile(path), iregistrycustom); +- public static DedicatedServerProperties load(Path path) { +- return new DedicatedServerProperties(loadPropertiesFile(path)); + // CraftBukkit start -+ public static DedicatedServerProperties load(IRegistryCustom iregistrycustom, Path path, OptionSet optionset) { -+ return new DedicatedServerProperties(loadPropertiesFile(path), iregistrycustom, optionset); ++ public static DedicatedServerProperties load(Path path, OptionSet optionset) { ++ return new DedicatedServerProperties(loadPropertiesFile(path), optionset); } @Override - protected DedicatedServerProperties reload(IRegistryCustom iregistrycustom, Properties properties) { -- return new DedicatedServerProperties(properties, iregistrycustom); +- DedicatedServerProperties dedicatedserverproperties = new DedicatedServerProperties(properties); + protected DedicatedServerProperties reload(IRegistryCustom iregistrycustom, Properties properties, OptionSet optionset) { -+ return new DedicatedServerProperties(properties, iregistrycustom, optionset); ++ DedicatedServerProperties dedicatedserverproperties = new DedicatedServerProperties(properties, optionset); + // CraftBukkit end - } - } + + dedicatedserverproperties.a(iregistrycustom); + return dedicatedserverproperties; diff --git a/nms-patches/net/minecraft/server/dedicated/DedicatedServerSettings.patch b/nms-patches/net/minecraft/server/dedicated/DedicatedServerSettings.patch index c80d143f1..995ba6eb5 100644 --- a/nms-patches/net/minecraft/server/dedicated/DedicatedServerSettings.patch +++ b/nms-patches/net/minecraft/server/dedicated/DedicatedServerSettings.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/dedicated/DedicatedServerSettings.java +++ b/net/minecraft/server/dedicated/DedicatedServerSettings.java -@@ -4,14 +4,21 @@ +@@ -3,14 +3,21 @@ + import java.nio.file.Path; import java.util.function.UnaryOperator; - import net.minecraft.core.IRegistryCustom; +// CraftBukkit start +import java.io.File; @@ -11,16 +11,16 @@ + public class DedicatedServerSettings { - private final Path path; + private final Path source; private DedicatedServerProperties properties; -- public DedicatedServerSettings(IRegistryCustom iregistrycustom, Path path) { -- this.path = path; -- this.properties = DedicatedServerProperties.load(iregistrycustom, path); +- public DedicatedServerSettings(Path path) { +- this.source = path; +- this.properties = DedicatedServerProperties.load(path); + // CraftBukkit start -+ public DedicatedServerSettings(IRegistryCustom iregistrycustom, OptionSet optionset) { -+ this.path = ((File) optionset.valueOf("config")).toPath(); -+ this.properties = DedicatedServerProperties.load(iregistrycustom, path, optionset); ++ public DedicatedServerSettings(OptionSet optionset) { ++ this.source = ((File) optionset.valueOf("config")).toPath(); ++ this.properties = DedicatedServerProperties.load(source, optionset); + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch b/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch index 46cb5dac7..7a1ffdd80 100644 --- a/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch +++ b/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch @@ -32,7 +32,7 @@ public static Properties loadPropertiesFile(Path path) { Properties properties = new Properties(); -@@ -61,6 +76,11 @@ +@@ -58,6 +73,11 @@ public void savePropertiesFile(Path path) { try { @@ -42,9 +42,9 @@ + } + // CraftBukkit end OutputStream outputstream = Files.newOutputStream(path); - Throwable throwable = null; -@@ -92,7 +112,7 @@ + try { +@@ -86,7 +106,7 @@ private static Function a(Function function) { return (s) -> { try { @@ -53,7 +53,7 @@ } catch (NumberFormatException numberformatexception) { return null; } -@@ -111,7 +131,7 @@ +@@ -105,7 +125,7 @@ @Nullable private String c(String s) { @@ -62,7 +62,7 @@ } @Nullable -@@ -139,7 +159,7 @@ +@@ -133,7 +153,7 @@ V v1 = MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0); this.properties.put(s, function1.apply(v1)); @@ -71,7 +71,7 @@ } protected V a(String s, Function function, UnaryOperator unaryoperator, Function function1, V v0) { -@@ -168,7 +188,7 @@ +@@ -162,7 +182,7 @@ } protected int getInt(String s, int i) { @@ -80,7 +80,7 @@ } protected PropertyManager.EditableProperty b(String s, int i) { -@@ -180,7 +200,7 @@ +@@ -174,7 +194,7 @@ } protected long getLong(String s, long i) { @@ -89,7 +89,7 @@ } protected boolean getBoolean(String s, boolean flag) { -@@ -203,7 +223,7 @@ +@@ -197,7 +217,7 @@ return properties; } @@ -98,19 +98,19 @@ public class EditableProperty implements Supplier { -@@ -211,7 +231,7 @@ - private final V c; - private final Function d; +@@ -205,7 +225,7 @@ + private final V value; + private final Function serializer; -- private EditableProperty(String s, Object object, Function function) { -+ private EditableProperty(String s, V object, Function function) { // CraftBukkit - decompile error - this.b = s; - this.c = object; - this.d = function; -@@ -225,7 +245,7 @@ +- EditableProperty(String s, Object object, Function function) { ++ EditableProperty(String s, V object, Function function) { // CraftBukkit - decompile error + this.key = s; + this.value = object; + this.serializer = function; +@@ -219,7 +239,7 @@ Properties properties = PropertyManager.this.a(); - properties.put(this.b, this.d.apply(v0)); + properties.put(this.key, this.serializer.apply(v0)); - return PropertyManager.this.reload(iregistrycustom, properties); + return PropertyManager.this.reload(iregistrycustom, properties, PropertyManager.this.options); // CraftBukkit } diff --git a/nms-patches/net/minecraft/server/gui/ServerGUI.patch b/nms-patches/net/minecraft/server/gui/ServerGUI.patch index 98919073f..5f7fad052 100644 --- a/nms-patches/net/minecraft/server/gui/ServerGUI.patch +++ b/nms-patches/net/minecraft/server/gui/ServerGUI.patch @@ -1,14 +1,23 @@ --- a/net/minecraft/server/gui/ServerGUI.java +++ b/net/minecraft/server/gui/ServerGUI.java -@@ -160,6 +160,7 @@ - this.e.forEach(Runnable::run); +@@ -96,7 +96,7 @@ + private JComponent c() { + JPanel jpanel = new JPanel(new BorderLayout()); + GuiStatsComponent guistatscomponent = new GuiStatsComponent(this.server); +- Collection collection = this.finalizers; ++ Collection collection = this.finalizers; // CraftBukkit - decompile error + + Objects.requireNonNull(guistatscomponent); + collection.add(guistatscomponent::a); +@@ -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) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(() -> { -@@ -175,7 +176,7 @@ +@@ -181,7 +182,7 @@ } try { diff --git a/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch b/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch index a22bcbb1a..a7258366b 100644 --- a/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch +++ b/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch @@ -1,64 +1,64 @@ --- a/net/minecraft/server/level/ChunkMapDistance.java +++ b/net/minecraft/server/level/ChunkMapDistance.java -@@ -65,7 +65,7 @@ +@@ -73,7 +73,7 @@ while (objectiterator.hasNext()) { Entry>> entry = (Entry) objectiterator.next(); - if (((ArraySetSorted) entry.getValue()).removeIf((ticket) -> { + if ((entry.getValue()).removeIf((ticket) -> { // CraftBukkit - decompile error - return ticket.b(this.currentTick); + return ticket.b(this.ticketTickCounter); })) { - this.ticketLevelTracker.update(entry.getLongKey(), getLowestTicketLevel((ArraySetSorted) entry.getValue()), false); -@@ -101,10 +101,25 @@ + this.ticketTracker.update(entry.getLongKey(), getLowestTicketLevel((ArraySetSorted) entry.getValue()), false); +@@ -109,10 +109,25 @@ } - if (!this.pendingChunkUpdates.isEmpty()) { -- this.pendingChunkUpdates.forEach((playerchunk) -> { + if (!this.chunksToUpdateFutures.isEmpty()) { +- this.chunksToUpdateFutures.forEach((playerchunk) -> { + // CraftBukkit start + // Iterate pending chunk updates with protection against concurrent modification exceptions -+ java.util.Iterator iter = this.pendingChunkUpdates.iterator(); -+ int expectedSize = this.pendingChunkUpdates.size(); ++ java.util.Iterator iter = this.chunksToUpdateFutures.iterator(); ++ int expectedSize = this.chunksToUpdateFutures.size(); + do { + PlayerChunk playerchunk = iter.next(); + iter.remove(); + expectedSize--; + - playerchunk.a(playerchunkmap); + playerchunk.a(playerchunkmap, this.mainThreadExecutor); - }); -- this.pendingChunkUpdates.clear(); +- this.chunksToUpdateFutures.clear(); + + // Reset iterator if set was modified using add() -+ if (this.pendingChunkUpdates.size() != expectedSize) { -+ expectedSize = this.pendingChunkUpdates.size(); -+ iter = this.pendingChunkUpdates.iterator(); ++ if (this.chunksToUpdateFutures.size() != expectedSize) { ++ expectedSize = this.chunksToUpdateFutures.size(); ++ iter = this.chunksToUpdateFutures.iterator(); + } + } while (iter.hasNext()); + // CraftBukkit end + return true; } else { - if (!this.l.isEmpty()) { -@@ -140,23 +155,25 @@ + if (!this.ticketsToRelease.isEmpty()) { +@@ -148,23 +163,25 @@ } } -- private void addTicket(long i, Ticket ticket) { -+ private boolean addTicket(long i, Ticket ticket) { // CraftBukkit - void -> boolean +- void addTicket(long i, Ticket ticket) { ++ boolean addTicket(long i, Ticket ticket) { // CraftBukkit - void -> boolean ArraySetSorted> 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.currentTick); + ticket1.a(this.ticketTickCounter); if (ticket.b() < j) { - this.ticketLevelTracker.update(i, ticket.b(), true); + this.ticketTracker.update(i, ticket.b(), true); } + return ticket == ticket1; // CraftBukkit } -- private void removeTicket(long i, Ticket ticket) { -+ private boolean removeTicket(long i, Ticket ticket) { // CraftBukkit - void -> boolean +- void removeTicket(long i, Ticket ticket) { ++ boolean removeTicket(long i, Ticket ticket) { // CraftBukkit - void -> boolean ArraySetSorted> arraysetsorted = this.e(i); + boolean removed = false; // CraftBukkit @@ -68,10 +68,10 @@ } if (arraysetsorted.isEmpty()) { -@@ -164,16 +181,29 @@ +@@ -172,16 +189,29 @@ } - this.ticketLevelTracker.update(i, getLowestTicketLevel(arraysetsorted), false); + this.ticketTracker.update(i, getLowestTicketLevel(arraysetsorted), false); + return removed; // CraftBukkit } @@ -101,16 +101,16 @@ } public void addTicket(TicketType tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { -@@ -216,6 +246,7 @@ +@@ -224,6 +254,7 @@ public void b(SectionPosition sectionposition, EntityPlayer entityplayer) { long i = sectionposition.r().pair(); - ObjectSet objectset = (ObjectSet) this.c.get(i); + ObjectSet objectset = (ObjectSet) this.playersPerChunk.get(i); + if (objectset == null) return; // CraftBukkit - SPIGOT-6208 objectset.remove(entityplayer); if (objectset.isEmpty()) { -@@ -257,6 +288,26 @@ - return this.i.a(); +@@ -300,6 +331,26 @@ + } + // CraftBukkit start @@ -122,7 +122,7 @@ + ArraySetSorted> tickets = entry.getValue(); + if (tickets.remove(target)) { + // copied from removeTicket -+ this.ticketLevelTracker.update(entry.getLongKey(), getLowestTicketLevel(tickets), false); ++ this.ticketTracker.update(entry.getLongKey(), getLowestTicketLevel(tickets), false); + + // can't use entry after it's removed + if (tickets.isEmpty()) { @@ -133,6 +133,6 @@ + } + // CraftBukkit end + - class a extends ChunkMap { + private class a extends ChunkMap { public a() { diff --git a/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch b/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch index 9f436d3ca..755f5f31b 100644 --- a/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch +++ b/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/server/level/ChunkProviderServer.java +++ b/net/minecraft/server/level/ChunkProviderServer.java -@@ -79,6 +79,24 @@ +@@ -83,6 +83,24 @@ this.clearCache(); } + // CraftBukkit start - properly implement isChunkLoaded + public boolean isChunkLoaded(int chunkX, int chunkZ) { -+ PlayerChunk chunk = this.playerChunkMap.getUpdatingChunk(ChunkCoordIntPair.pair(chunkX, chunkZ)); ++ PlayerChunk chunk = this.chunkMap.getUpdatingChunk(ChunkCoordIntPair.pair(chunkX, chunkZ)); + if (chunk == null) { + return false; + } @@ -14,7 +14,7 @@ + } + + public Chunk getChunkUnchecked(int chunkX, int chunkZ) { -+ PlayerChunk chunk = this.playerChunkMap.getUpdatingChunk(ChunkCoordIntPair.pair(chunkX, chunkZ)); ++ PlayerChunk chunk = this.chunkMap.getUpdatingChunk(ChunkCoordIntPair.pair(chunkX, chunkZ)); + if (chunk == null) { + return null; + } @@ -25,16 +25,16 @@ @Override public LightEngineThreaded getLightEngine() { return this.lightEngine; -@@ -123,7 +141,7 @@ +@@ -127,7 +145,7 @@ for (int l = 0; l < 4; ++l) { - if (k == this.cachePos[l] && chunkstatus == this.cacheStatus[l]) { - ichunkaccess = this.cacheChunk[l]; + if (k == this.lastChunkPos[l] && chunkstatus == this.lastChunkStatus[l]) { + ichunkaccess = this.lastChunk[l]; - if (ichunkaccess != null || !flag) { + if (ichunkaccess != null) { // CraftBukkit - the chunk can become accessible in the meantime TODO for non-null chunks it might also make sense to check that the chunk's state hasn't changed in the meantime return ichunkaccess; } } -@@ -169,12 +187,12 @@ +@@ -175,12 +193,12 @@ if (playerchunk == null) { return null; } else { @@ -49,7 +49,7 @@ if (ichunkaccess1 != null) { this.a(k, ichunkaccess1, ChunkStatus.FULL); -@@ -201,7 +219,15 @@ +@@ -228,7 +246,15 @@ int l = 33 + ChunkStatus.a(chunkstatus); PlayerChunk playerchunk = this.getChunk(k); @@ -63,10 +63,10 @@ + } + if (flag && !currentlyUnloading) { + // CraftBukkit end - this.chunkMapDistance.a(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair); + this.distanceManager.a(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair); if (this.a(playerchunk, l)) { - GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler(); -@@ -220,7 +246,7 @@ + GameProfilerFiller gameprofilerfiller = this.level.getMethodProfiler(); +@@ -247,7 +273,7 @@ } private boolean a(@Nullable PlayerChunk playerchunk, int i) { @@ -74,31 +74,17 @@ + return playerchunk == null || playerchunk.oldTicketLevel > i; // CraftBukkit using oldTicketLevel for isLoaded checks } - public boolean isLoaded(int i, int j) { -@@ -282,19 +308,19 @@ - public boolean a(Entity entity) { - long i = ChunkCoordIntPair.pair(MathHelper.floor(entity.locX()) >> 4, MathHelper.floor(entity.locZ()) >> 4); - -- return this.a(i, PlayerChunk::b); -+ return this.a(i, (Function>>) PlayerChunk::b); // CraftBukkit - decompile error + @Override +@@ -307,7 +333,7 @@ } - @Override - public boolean a(ChunkCoordIntPair chunkcoordintpair) { -- return this.a(chunkcoordintpair.pair(), PlayerChunk::b); -+ return this.a(chunkcoordintpair.pair(), (Function>>) PlayerChunk::b); // CraftBukkit - decompile error - } - - @Override - public boolean a(BlockPosition blockposition) { - long i = ChunkCoordIntPair.pair(blockposition.getX() >> 4, blockposition.getZ() >> 4); - + public boolean a(long i) { - return this.a(i, PlayerChunk::a); + return this.a(i, (Function>>) PlayerChunk::a); // CraftBukkit - decompile error } private boolean a(long i, Function>> function) { -@@ -316,11 +342,31 @@ +@@ -329,11 +355,31 @@ @Override public void close() throws IOException { @@ -113,44 +99,46 @@ + } + // CraftBukkit end this.lightEngine.close(); - this.playerChunkMap.close(); + this.chunkMap.close(); } + // CraftBukkit start - modelled on below + public void purgeUnload() { -+ this.world.getMethodProfiler().enter("purge"); -+ this.chunkMapDistance.purgeTickets(); ++ this.level.getMethodProfiler().enter("purge"); ++ this.distanceManager.purgeTickets(); + this.tickDistanceManager(); -+ this.world.getMethodProfiler().exitEnter("unload"); -+ this.playerChunkMap.unloadChunks(() -> true); -+ this.world.getMethodProfiler().exit(); ++ this.level.getMethodProfiler().exitEnter("unload"); ++ this.chunkMap.unloadChunks(() -> true); ++ this.level.getMethodProfiler().exit(); + this.clearCache(); + } + // CraftBukkit end + + @Override public void tick(BooleanSupplier booleansupplier) { - this.world.getMethodProfiler().enter("purge"); - this.chunkMapDistance.purgeTickets(); -@@ -340,12 +386,12 @@ - this.lastTickTime = i; - WorldData worlddata = this.world.getWorldData(); - boolean flag = this.world.isDebugWorld(); -- boolean flag1 = this.world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING); -+ boolean flag1 = this.world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING) && !world.getPlayers().isEmpty(); // CraftBukkit + 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 if (!flag) { - this.world.getMethodProfiler().enter("pollingChunks"); - int k = this.world.getGameRules().getInt(GameRules.RANDOM_TICK_SPEED); + this.level.getMethodProfiler().enter("pollingChunks"); + int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); - boolean flag2 = worlddata.getTime() % 400L == 0L; -+ boolean flag2 = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L; // CraftBukkit ++ boolean flag2 = level.ticksPerAnimalSpawns != 0L && worlddata.getTime() % level.ticksPerAnimalSpawns == 0L; // CraftBukkit - this.world.getMethodProfiler().enter("naturalSpawnCount"); - int l = this.chunkMapDistance.b(); -@@ -532,12 +578,18 @@ + this.level.getMethodProfiler().enter("naturalSpawnCount"); + int l = this.distanceManager.b(); +@@ -548,13 +594,19 @@ + } @Override - protected boolean executeNext() { +- protected boolean executeNext() { + // CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task ++ public boolean executeNext() { + try { if (ChunkProviderServer.this.tickDistanceManager()) { return true; @@ -159,7 +147,7 @@ return super.executeNext(); } + } finally { -+ playerChunkMap.callbackExecutor.run(); ++ chunkMap.callbackExecutor.run(); + } + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/server/level/EntityPlayer.patch b/nms-patches/net/minecraft/server/level/EntityPlayer.patch index aaef17423..760439636 100644 --- a/nms-patches/net/minecraft/server/level/EntityPlayer.patch +++ b/nms-patches/net/minecraft/server/level/EntityPlayer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/EntityPlayer.java +++ b/net/minecraft/server/level/EntityPlayer.java -@@ -135,6 +135,36 @@ +@@ -140,6 +140,36 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -34,12 +34,12 @@ +import org.bukkit.inventory.MainHand; +// CraftBukkit end + - public class EntityPlayer extends EntityHuman implements ICrafting { + public class EntityPlayer extends EntityHuman { private static final Logger LOGGER = LogManager.getLogger(); -@@ -180,6 +210,20 @@ - public int ping; - public boolean viewingCredits; +@@ -187,6 +217,20 @@ + public int latency; + public boolean wonGame; + // CraftBukkit start + public String displayName; @@ -55,26 +55,26 @@ + public Integer clientViewDistance; + // CraftBukkit end + - public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) { - super(worldserver, worldserver.getSpawn(), worldserver.v(), gameprofile); - this.spawnDimension = World.OVERWORLD; -@@ -191,12 +235,56 @@ - this.G = 1.0F; - this.c(worldserver); - this.co = minecraftserver.a(this); + public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile) { + super(worldserver, worldserver.getSpawn(), worldserver.x(), gameprofile); + this.chatVisibility = EnumChatVisibility.FULL; +@@ -253,12 +297,56 @@ + this.advancements = minecraftserver.getPlayerList().f(this); + this.maxUpStep = 1.0F; + this.d(worldserver); + + // CraftBukkit start + this.displayName = this.getName(); -+ this.canPickUpLoot = true; ++ this.bukkitPickUpLoot = true; + this.maxHealthCache = this.getMaxHealth(); - } - ++ } ++ + // 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(); + -+ if (worldserver.getDimensionManager().hasSkyLight() && worldserver.worldDataServer.getGameType() != EnumGamemode.ADVENTURE) { ++ 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())); + @@ -89,7 +89,7 @@ + long k = (long) (i * 2 + 1); + long l = k * k; + int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l; -+ int j1 = this.u(i1); ++ int j1 = this.v(i1); + int k1 = (new Random()).nextInt(i1); + + for (int l1 = 0; l1 < i1; ++l1) { @@ -105,18 +105,18 @@ + } + + return blockposition; -+ } + } + // CraftBukkit end -+ - private void c(WorldServer worldserver) { + + private void d(WorldServer worldserver) { BlockPosition blockposition = worldserver.getSpawn(); - if (worldserver.getDimensionManager().hasSkyLight() && worldserver.getMinecraftServer().getSaveData().getGameType() != EnumGamemode.ADVENTURE) { -+ if (worldserver.getDimensionManager().hasSkyLight() && worldserver.worldDataServer.getGameType() != EnumGamemode.ADVENTURE) { // CraftBukkit ++ 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())); -@@ -262,11 +350,20 @@ +@@ -316,11 +404,20 @@ if (nbttagcompound.hasKeyOfType("recipeBook", 10)) { this.recipeBook.a(nbttagcompound.getCompound("recipeBook"), this.server.getCraftingManager()); } @@ -130,14 +130,14 @@ + String spawnWorld = nbttagcompound.getString("SpawnWorld"); + CraftWorld oldWorld = (CraftWorld) Bukkit.getWorld(spawnWorld); + if (oldWorld != null) { -+ this.spawnDimension = oldWorld.getHandle().getDimensionKey(); ++ this.respawnDimension = oldWorld.getHandle().getDimensionKey(); + } + // CraftBukkit end + if (nbttagcompound.hasKeyOfType("SpawnX", 99) && nbttagcompound.hasKeyOfType("SpawnY", 99) && nbttagcompound.hasKeyOfType("SpawnZ", 99)) { - this.spawn = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ")); - this.spawnForced = nbttagcompound.getBoolean("SpawnForced"); -@@ -300,7 +397,20 @@ + this.respawnPosition = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ")); + this.respawnForced = nbttagcompound.getBoolean("SpawnForced"); +@@ -353,7 +450,20 @@ Entity entity = this.getRootVehicle(); Entity entity1 = this.getVehicle(); @@ -159,16 +159,16 @@ NBTTagCompound nbttagcompound2 = new NBTTagCompound(); NBTTagCompound nbttagcompound3 = new NBTTagCompound(); -@@ -318,7 +428,7 @@ - nbttagcompound.setInt("SpawnZ", this.spawn.getZ()); - nbttagcompound.setBoolean("SpawnForced", this.spawnForced); - nbttagcompound.setFloat("SpawnAngle", this.spawnAngle); -- DataResult dataresult = MinecraftKey.a.encodeStart(DynamicOpsNBT.a, this.spawnDimension.a()); -+ DataResult dataresult = MinecraftKey.a.encodeStart(DynamicOpsNBT.a, this.spawnDimension.a()); // CraftBukkit - decompile error +@@ -371,7 +481,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 dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.respawnDimension.a()); // CraftBukkit - decompile error Logger logger = EntityPlayer.LOGGER; - logger.getClass(); -@@ -326,9 +436,33 @@ + Objects.requireNonNull(logger); +@@ -379,9 +489,33 @@ nbttagcompound.set("SpawnDimension", nbtbase); }); } @@ -178,12 +178,12 @@ + // CraftBukkit start - World fallback code, either respawn location or global spawn + public void spawnIn(World world) { -+ super.spawnIn(world); ++ this.level = world; + if (world == null) { -+ this.dead = false; ++ this.unsetRemoved(); + Vec3D position = null; -+ if (this.spawnDimension != null) { -+ world = this.getWorldServer().getServer().getHandle().getServer().getWorldServer(this.spawnDimension); ++ if (this.respawnDimension != null) { ++ world = this.getWorldServer().getServer().getHandle().getServer().getWorldServer(this.respawnDimension); + if (world != null && this.getSpawn() != null) { + position = EntityHuman.getBed((WorldServer) world, this.getSpawn(), this.getSpawnAngle(), false, false).orElse(null); + } @@ -192,17 +192,17 @@ + world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle(); + position = Vec3D.a(((WorldServer) world).getSpawn()); + } -+ this.world = world; ++ this.level = world; + this.setPosition(position.getX(), position.getY(), position.getZ()); + } -+ this.playerInteractManager.a((WorldServer) world); ++ this.gameMode.a((WorldServer) world); + } + // CraftBukkit end + public void a(int i) { float f = (float) this.getExpToLevel(); float f1 = (f - 1.0F) / f; -@@ -382,6 +516,11 @@ +@@ -440,6 +574,11 @@ @Override public void tick() { @@ -211,20 +211,20 @@ + this.joining = false; + } + // CraftBukkit end - this.playerInteractManager.a(); - --this.invulnerableTicks; - if (this.noDamageTicks > 0) { -@@ -449,7 +588,7 @@ + this.gameMode.a(); + --this.spawnInvulnerableTime; + if (this.invulnerableTime > 0) { +@@ -493,7 +632,7 @@ } - if (this.getHealth() != this.lastHealthSent || this.lastFoodSent != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastSentSaturationZero) { -- this.playerConnection.sendPacket(new PacketPlayOutUpdateHealth(this.getHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel())); -+ this.playerConnection.sendPacket(new PacketPlayOutUpdateHealth(this.getBukkitEntity().getScaledHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel())); // CraftBukkit - this.lastHealthSent = this.getHealth(); - this.lastFoodSent = this.foodData.getFoodLevel(); - this.lastSentSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -480,6 +619,12 @@ - this.a(IScoreboardCriteria.XP, MathHelper.f((float) this.lastExpTotalScored)); + 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.lastSentHealth = this.getHealth(); + this.lastSentFood = this.foodData.getFoodLevel(); + this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; +@@ -524,6 +663,12 @@ + this.a(IScoreboardCriteria.EXPERIENCE, MathHelper.f((float) this.lastRecordedExperience)); } + // CraftBukkit start - Force max health updates @@ -233,56 +233,56 @@ + } + // CraftBukkit end + - if (this.expLevel != this.lastExpLevelScored) { - this.lastExpLevelScored = this.expLevel; - this.a(IScoreboardCriteria.LEVEL, MathHelper.f((float) this.lastExpLevelScored)); -@@ -494,6 +639,16 @@ - CriterionTriggers.p.a(this); + if (this.experienceLevel != this.lastRecordedLevel) { + this.lastRecordedLevel = this.experienceLevel; + this.a(IScoreboardCriteria.LEVEL, MathHelper.f((float) this.lastRecordedLevel)); +@@ -538,6 +683,16 @@ + CriterionTriggers.LOCATION.a(this); } + // CraftBukkit start - initialize oldLevel and fire PlayerLevelChangeEvent + if (this.oldLevel == -1) { -+ this.oldLevel = this.expLevel; ++ this.oldLevel = this.experienceLevel; + } + -+ if (this.oldLevel != this.expLevel) { -+ CraftEventFactory.callPlayerLevelChangeEvent(this.world.getServer().getPlayer((EntityPlayer) this), this.oldLevel, this.expLevel); -+ this.oldLevel = this.expLevel; ++ if (this.oldLevel != this.experienceLevel) { ++ CraftEventFactory.callPlayerLevelChangeEvent(this.level.getServer().getPlayer((EntityPlayer) this), this.oldLevel, this.experienceLevel); ++ this.oldLevel = this.experienceLevel; + } + // CraftBukkit end } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Ticking player"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked"); -@@ -504,7 +659,8 @@ +@@ -548,7 +703,8 @@ } private void a(IScoreboardCriteria iscoreboardcriteria, int i) { - this.getScoreboard().getObjectivesForCriteria(iscoreboardcriteria, this.getName(), (scoreboardscore) -> { + // CraftBukkit - Use our scores instead -+ this.world.getServer().getScoreboardManager().getScoreboardScores(iscoreboardcriteria, this.getName(), (scoreboardscore) -> { ++ this.level.getServer().getScoreboardManager().getScoreboardScores(iscoreboardcriteria, this.getName(), (scoreboardscore) -> { scoreboardscore.setScore(i); }); } -@@ -512,9 +668,46 @@ +@@ -556,9 +712,46 @@ @Override public void die(DamageSource damagesource) { - boolean flag = this.world.getGameRules().getBoolean(GameRules.SHOW_DEATH_MESSAGES); + boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); + // CraftBukkit start - fire PlayerDeathEvent -+ if (this.dead) { ++ if (this.isRemoved()) { + return; + } -+ java.util.List loot = new java.util.ArrayList(this.inventory.getSize()); -+ boolean keepInventory = this.world.getGameRules().getBoolean(GameRules.KEEP_INVENTORY) || this.isSpectator(); ++ java.util.List loot = new java.util.ArrayList(this.getInventory().getSize()); ++ boolean keepInventory = this.level.getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || this.isSpectator(); + + if (!keepInventory) { -+ for (ItemStack item : this.inventory.getContents()) { ++ for (ItemStack item : this.getInventory().getContents()) { + if (!item.isEmpty() && !EnchantmentManager.shouldNotDrop(item)) { + loot.add(CraftItemStack.asCraftMirror(item)); + } + } + } + // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule) -+ this.a(damagesource, this.lastDamageByPlayerTime > 0); ++ this.a(damagesource, this.lastHurtByPlayerTime > 0); + for (org.bukkit.inventory.ItemStack item : this.drops) { + loot.add(item); + } @@ -296,7 +296,7 @@ + org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory); + + // SPIGOT-943 - only call if they have an inventory open -+ if (this.activeContainer != this.defaultContainer) { ++ if (this.containerMenu != this.inventoryMenu) { + this.closeInventory(); + } + @@ -310,20 +310,20 @@ + ichatbasecomponent = org.bukkit.craftbukkit.util.CraftChatMessage.fromStringOrNull(deathMessage); + } - this.playerConnection.a((Packet) (new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, ichatbasecomponent)), (future) -> { + this.connection.a((Packet) (new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), ichatbasecomponent)), (future) -> { if (!future.isSuccess()) { -@@ -548,12 +741,18 @@ - if (this.world.getGameRules().getBoolean(GameRules.FORGIVE_DEAD_PLAYERS)) { - this.eW(); +@@ -592,12 +785,18 @@ + if (this.level.getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) { + this.fH(); } - - if (!this.isSpectator()) { -- this.d(damagesource); +- this.f(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.inventory.clear(); ++ this.getInventory().clear(); } - this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.DEATH_COUNT, this.getName(), ScoreboardScore::incrementScore); @@ -331,42 +331,42 @@ + // CraftBukkit end + + // CraftBukkit - Get our scores instead -+ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.DEATH_COUNT, this.getName(), ScoreboardScore::incrementScore); ++ this.level.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.DEATH_COUNT, this.getName(), ScoreboardScore::incrementScore); EntityLiving entityliving = this.getKillingEntity(); if (entityliving != null) { -@@ -589,10 +788,12 @@ +@@ -634,10 +833,12 @@ String s = this.getName(); String s1 = entity.getName(); -- this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.TOTAL_KILL_COUNT, s, ScoreboardScore::incrementScore); +- this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.KILL_COUNT_ALL, s, ScoreboardScore::incrementScore); + // CraftBukkit - Get our scores instead -+ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.TOTAL_KILL_COUNT, s, ScoreboardScore::incrementScore); ++ this.level.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.KILL_COUNT_ALL, s, ScoreboardScore::incrementScore); if (entity instanceof EntityHuman) { this.a(StatisticList.PLAYER_KILLS); -- this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.PLAYER_KILL_COUNT, s, ScoreboardScore::incrementScore); +- this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.KILL_COUNT_PLAYERS, s, ScoreboardScore::incrementScore); + // CraftBukkit - Get our scores instead -+ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.PLAYER_KILL_COUNT, s, ScoreboardScore::incrementScore); ++ this.level.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.KILL_COUNT_PLAYERS, s, ScoreboardScore::incrementScore); } else { this.a(StatisticList.MOB_KILLS); } -@@ -610,7 +811,8 @@ +@@ -655,7 +856,8 @@ int i = scoreboardteam.getColor().b(); if (i >= 0 && i < aiscoreboardcriteria.length) { - this.getScoreboard().getObjectivesForCriteria(aiscoreboardcriteria[i], s, ScoreboardScore::incrementScore); + // CraftBukkit - Get our scores instead -+ this.world.getServer().getScoreboardManager().getScoreboardScores(aiscoreboardcriteria[i], s, ScoreboardScore::incrementScore); ++ this.level.getServer().getScoreboardManager().getScoreboardScores(aiscoreboardcriteria[i], s, ScoreboardScore::incrementScore); } } -@@ -654,18 +856,20 @@ +@@ -699,18 +901,20 @@ } private boolean canPvP() { - return this.server.getPVP(); + // CraftBukkit - this.server.getPvP() -> this.world.pvpMode -+ return this.world.pvpMode; ++ return this.level.pvpMode; } @Nullable @@ -375,20 +375,20 @@ ShapeDetectorShape shapedetectorshape = super.a(worldserver); + worldserver = (shapedetectorshape == null) ? worldserver : shapedetectorshape.world; // CraftBukkit -- if (shapedetectorshape != null && this.world.getDimensionKey() == World.OVERWORLD && worldserver.getDimensionKey() == World.THE_END) { -+ if (shapedetectorshape != null && this.world.getTypeKey() == DimensionManager.OVERWORLD && worldserver != null && worldserver.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit - Vec3D vec3d = shapedetectorshape.position.add(0.0D, -1.0D, 0.0D); +- if (shapedetectorshape != null && this.level.getDimensionKey() == World.OVERWORLD && worldserver.getDimensionKey() == 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); -- return new ShapeDetectorShape(vec3d, Vec3D.ORIGIN, 90.0F, 0.0F); -+ return new ShapeDetectorShape(vec3d, Vec3D.ORIGIN, 90.0F, 0.0F, worldserver, shapedetectorshape.portalEventInfo); // CraftBukkit +- return new ShapeDetectorShape(vec3d, Vec3D.ZERO, 90.0F, 0.0F); ++ return new ShapeDetectorShape(vec3d, Vec3D.ZERO, 90.0F, 0.0F, worldserver, shapedetectorshape.portalEventInfo); // CraftBukkit } else { return shapedetectorshape; } -@@ -674,11 +878,20 @@ +@@ -719,11 +923,20 @@ @Nullable @Override public Entity b(WorldServer worldserver) { -- this.worldChangeInvuln = true; +- this.isChangingDimension = true; + // CraftBukkit start + return b(worldserver, TeleportCause.UNKNOWN); + } @@ -402,13 +402,13 @@ - ResourceKey resourcekey = worldserver1.getDimensionKey(); + ResourceKey resourcekey = worldserver1.getTypeKey(); // CraftBukkit -- if (resourcekey == World.THE_END && worldserver.getDimensionKey() == World.OVERWORLD) { -+ if (resourcekey == DimensionManager.THE_END && worldserver != null && worldserver.getTypeKey() == DimensionManager.OVERWORLD) { // CraftBukkit -+ this.worldChangeInvuln = true; // CraftBukkit - Moved down from above +- if (resourcekey == World.END && worldserver.getDimensionKey() == 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().removePlayer(this); - if (!this.viewingCredits) { -@@ -689,6 +902,8 @@ + this.getWorldServer().a(this, Entity.RemovalReason.CHANGED_DIMENSION); + if (!this.wonGame) { +@@ -734,6 +947,8 @@ return this; } else { @@ -416,32 +416,32 @@ + /* WorldData worlddata = worldserver.getWorldData(); - this.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.getDimensionManager(), worldserver.getDimensionKey(), BiomeManager.a(worldserver.getSeed()), this.playerInteractManager.getGameMode(), this.playerInteractManager.c(), worldserver.isDebugWorld(), worldserver.isFlatWorld(), true)); -@@ -698,22 +913,52 @@ + this.connection.sendPacket(new PacketPlayOutRespawn(worldserver.getDimensionManager(), worldserver.getDimensionKey(), BiomeManager.a(worldserver.getSeed()), this.gameMode.getGameMode(), this.gameMode.c(), worldserver.isDebugWorld(), worldserver.isFlatWorld(), true)); +@@ -743,22 +958,52 @@ playerlist.d(this); - worldserver1.removePlayer(this); - this.dead = false; + worldserver1.a(this, Entity.RemovalReason.CHANGED_DIMENSION); + this.unsetRemoved(); + */ + // CraftBukkit end ShapeDetectorShape shapedetectorshape = this.a(worldserver); if (shapedetectorshape != null) { worldserver1.getMethodProfiler().enter("moving"); -- if (resourcekey == World.OVERWORLD && worldserver.getDimensionKey() == World.THE_NETHER) { +- if (resourcekey == World.OVERWORLD && worldserver.getDimensionKey() == World.NETHER) { + worldserver = shapedetectorshape.world; // CraftBukkit + if (worldserver == null) { } else // CraftBukkit - empty to fall through to null to event -+ if (resourcekey == DimensionManager.OVERWORLD && worldserver.getTypeKey() == DimensionManager.THE_NETHER) { // CraftBukkit - this.ci = this.getPositionVector(); -- } else if (worldserver.getDimensionKey() == World.THE_END) { -+ } else if (worldserver.getTypeKey() == DimensionManager.THE_END && shapedetectorshape.portalEventInfo != null && shapedetectorshape.portalEventInfo.getCanCreatePortal()) { // CraftBukkit - this.a(worldserver, new BlockPosition(shapedetectorshape.position)); ++ if (resourcekey == DimensionManager.OVERWORLD_LOCATION && worldserver.getTypeKey() == DimensionManager.NETHER_LOCATION) { // CraftBukkit + this.enteredNetherPosition = this.getPositionVector(); +- } else if (worldserver.getDimensionKey() == World.END) { ++ } else if (worldserver.getTypeKey() == DimensionManager.END_LOCATION && shapedetectorshape.portalEventInfo != null && shapedetectorshape.portalEventInfo.getCanCreatePortal()) { // CraftBukkit + this.a(worldserver, new BlockPosition(shapedetectorshape.pos)); } + // CraftBukkit start + } else { + return null; + } + Location enter = this.getBukkitEntity().getLocation(); -+ Location exit = (worldserver == null) ? null : new Location(worldserver.getWorld(), shapedetectorshape.position.x, shapedetectorshape.position.y, shapedetectorshape.position.z, shapedetectorshape.yaw, shapedetectorshape.pitch); ++ Location exit = (worldserver == null) ? null : new Location(worldserver.getWorld(), shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, shapedetectorshape.xRot); + PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, cause); + Bukkit.getServer().getPluginManager().callEvent(tpEvent); + if (tpEvent.isCancelled() || tpEvent.getTo() == null) { @@ -454,36 +454,36 @@ + worldserver1.getMethodProfiler().exit(); + worldserver1.getMethodProfiler().enter("placing"); + if (true) { // CraftBukkit -+ this.worldChangeInvuln = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds ++ this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds + -+ this.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.getDimensionManager(), worldserver.getDimensionKey(), BiomeManager.a(worldserver.getSeed()), this.playerInteractManager.getGameMode(), this.playerInteractManager.c(), worldserver.isDebugWorld(), worldserver.isFlatWorld(), true)); -+ this.playerConnection.sendPacket(new PacketPlayOutServerDifficulty(this.world.getDifficulty(), this.world.getWorldData().isDifficultyLocked())); ++ 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())); + PlayerList playerlist = this.server.getPlayerList(); + + playerlist.d(this); -+ worldserver1.removePlayer(this); -+ this.dead = false; ++ worldserver1.a(this, Entity.RemovalReason.CHANGED_DIMENSION); ++ this.unsetRemoved(); - worldserver1.getMethodProfiler().exit(); - worldserver1.getMethodProfiler().enter("placing"); + // CraftBukkit end this.spawnIn(worldserver); worldserver.addPlayerPortal(this); -- this.setYawPitch(shapedetectorshape.yaw, shapedetectorshape.pitch); -- this.teleportAndSync(shapedetectorshape.position.x, shapedetectorshape.position.y, shapedetectorshape.position.z); -+ this.playerConnection.teleport(exit); // CraftBukkit - use internal teleport without event -+ this.playerConnection.syncPosition(); // CraftBukkit - sync position after changing it (from PortalTravelAgent#findAndteleport) +- this.setYawPitch(shapedetectorshape.yRot, shapedetectorshape.xRot); +- this.teleportAndSync(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.playerInteractManager.a(worldserver); -@@ -732,12 +977,31 @@ + this.connection.sendPacket(new PacketPlayOutAbilities(this.getAbilities())); +@@ -776,12 +1021,31 @@ this.lastSentExp = -1; - this.lastHealthSent = -1.0F; - this.lastFoodSent = -1; + this.lastSentHealth = -1.0F; + this.lastSentFood = -1; + + // CraftBukkit start + PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.getBukkitEntity(), worldserver1.getWorld()); -+ this.world.getServer().getPluginManager().callEvent(changeEvent); ++ this.level.getServer().getPluginManager().callEvent(changeEvent); + // CraftBukkit end } @@ -495,7 +495,7 @@ + @Override + protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, BlockPosition exitPosition, TeleportCause cause, int searchRadius, int creationRadius) { + Location enter = this.getBukkitEntity().getLocation(); -+ Location exit = new Location(exitWorldServer.getWorld(), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ(), yaw, pitch); ++ Location exit = new Location(exitWorldServer.getWorld(), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ(), getYRot(), getXRot()); + PlayerPortalEvent event = new PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause, searchRadius, true, creationRadius); + Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null) { @@ -508,7 +508,7 @@ private void a(WorldServer worldserver, BlockPosition blockposition) { BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.i(); -@@ -754,17 +1018,17 @@ +@@ -798,17 +1062,17 @@ } @Override @@ -521,7 +521,7 @@ + if (optional.isPresent() || !canCreatePortal) { // CraftBukkit return optional; } else { - EnumDirection.EnumAxis enumdirection_enumaxis = (EnumDirection.EnumAxis) this.world.getType(this.ac).d(BlockPortal.AXIS).orElse(EnumDirection.EnumAxis.X); + EnumDirection.EnumAxis enumdirection_enumaxis = (EnumDirection.EnumAxis) this.level.getType(this.portalEntrancePos).d(BlockPortal.AXIS).orElse(EnumDirection.EnumAxis.X); - Optional optional1 = worldserver.getTravelAgent().createPortal(blockposition, enumdirection_enumaxis); + Optional optional1 = worldserver.getTravelAgent().createPortal(blockposition, enumdirection_enumaxis, this, createRadius); // CraftBukkit @@ -531,45 +531,45 @@ } return optional1; -@@ -774,13 +1038,21 @@ +@@ -818,13 +1082,21 @@ public void triggerDimensionAdvancements(WorldServer worldserver) { ResourceKey resourcekey = worldserver.getDimensionKey(); - ResourceKey resourcekey1 = this.world.getDimensionKey(); + ResourceKey resourcekey1 = this.level.getDimensionKey(); + // CraftBukkit start + ResourceKey maindimensionkey = CraftDimensionUtil.getMainDimensionKey(worldserver); -+ ResourceKey maindimensionkey1 = CraftDimensionUtil.getMainDimensionKey(this.world); - -- CriterionTriggers.v.a(this, resourcekey, resourcekey1); -- if (resourcekey == World.THE_NETHER && resourcekey1 == World.OVERWORLD && this.ci != null) { -+ CriterionTriggers.v.a(this, maindimensionkey, maindimensionkey1); -+ if (maindimensionkey != resourcekey || maindimensionkey1 != resourcekey1) { -+ CriterionTriggers.v.a(this, resourcekey, resourcekey1); -+ } ++ ResourceKey maindimensionkey1 = CraftDimensionUtil.getMainDimensionKey(this.level); + -+ if (maindimensionkey == World.THE_NETHER && maindimensionkey1 == World.OVERWORLD && this.ci != null) { ++ CriterionTriggers.CHANGED_DIMENSION.a(this, maindimensionkey, maindimensionkey1); ++ if (maindimensionkey != resourcekey || maindimensionkey1 != resourcekey1) { ++ CriterionTriggers.CHANGED_DIMENSION.a(this, resourcekey, resourcekey1); ++ } + +- CriterionTriggers.CHANGED_DIMENSION.a(this, resourcekey, resourcekey1); +- if (resourcekey == World.NETHER && resourcekey1 == World.OVERWORLD && this.enteredNetherPosition != null) { ++ if (maindimensionkey == World.NETHER && maindimensionkey1 == World.OVERWORLD && this.enteredNetherPosition != null) { + // CraftBukkit end - CriterionTriggers.C.a(this, this.ci); + CriterionTriggers.NETHER_TRAVEL.a(this, this.enteredNetherPosition); } -- if (resourcekey1 != World.THE_NETHER) { -+ if (maindimensionkey1 != World.THE_NETHER) { // CraftBukkit - this.ci = null; +- if (resourcekey1 != World.NETHER) { ++ if (maindimensionkey1 != World.NETHER) { // CraftBukkit + this.enteredNetherPosition = null; } -@@ -808,10 +1080,8 @@ - this.activeContainer.c(); +@@ -852,10 +1124,8 @@ + this.containerMenu.d(); } - @Override - public Either sleep(BlockPosition blockposition) { -- EnumDirection enumdirection = (EnumDirection) this.world.getType(blockposition).get(BlockFacingHorizontal.FACING); +- EnumDirection enumdirection = (EnumDirection) this.level.getType(blockposition).get(BlockFacingHorizontal.FACING); - + // CraftBukkit start - moved bed result checks from below into separate method + private Either getBedResult(BlockPosition blockposition, EnumDirection enumdirection) { if (!this.isSleeping() && this.isAlive()) { - if (!this.world.getDimensionManager().isNatural()) { + if (!this.level.getDimensionManager().isNatural()) { return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE); -@@ -837,7 +1107,36 @@ +@@ -881,7 +1151,36 @@ } } @@ -584,7 +584,7 @@ + + @Override + public Either sleep(BlockPosition blockposition, boolean force) { -+ EnumDirection enumdirection = (EnumDirection) this.world.getType(blockposition).get(BlockFacingHorizontal.FACING); ++ EnumDirection enumdirection = (EnumDirection) this.level.getType(blockposition).get(BlockFacingHorizontal.FACING); + Either bedResult = this.getBedResult(blockposition, enumdirection); + + if (bedResult.left().orElse(null) == EntityHuman.EnumBedResult.OTHER_PROBLEM) { @@ -605,9 +605,9 @@ + { + Either either = super.sleep(blockposition, force).ifRight((unit) -> { this.a(StatisticList.SLEEP_IN_BED); - CriterionTriggers.q.a(this); + CriterionTriggers.SLEPT_IN_BED.a(this); }); -@@ -846,9 +1145,8 @@ +@@ -894,9 +1193,8 @@ return either; } } @@ -618,7 +618,7 @@ } @Override -@@ -875,6 +1173,24 @@ +@@ -923,6 +1221,24 @@ @Override public void wakeup(boolean flag, boolean flag1) { @@ -629,13 +629,13 @@ + + org.bukkit.block.Block bed; + if (bedPosition != null) { -+ bed = this.world.getWorld().getBlockAt(bedPosition.getX(), bedPosition.getY(), bedPosition.getZ()); ++ bed = this.level.getWorld().getBlockAt(bedPosition.getX(), bedPosition.getY(), bedPosition.getZ()); + } else { -+ bed = this.world.getWorld().getBlockAt(player.getLocation()); ++ bed = this.level.getWorld().getBlockAt(player.getLocation()); + } + + PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed, true); -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } @@ -643,8 +643,8 @@ if (this.isSleeping()) { this.getWorldServer().getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutAnimation(this, 2)); } -@@ -946,8 +1262,9 @@ - this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition())); +@@ -1004,8 +1320,9 @@ + this.connection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition())); } - public void nextContainerCounter() { @@ -654,9 +654,9 @@ } @Override -@@ -962,6 +1279,24 @@ +@@ -1020,6 +1337,24 @@ this.nextContainerCounter(); - Container container = itileinventory.createMenu(this.containerCounter, this.inventory, this); + Container container = itileinventory.createMenu(this.containerCounter, this.getInventory(), this); + // CraftBukkit start - Inventory open hook + if (container != null) { @@ -679,27 +679,27 @@ if (container == null) { if (this.isSpectator()) { this.a((IChatBaseComponent) (new ChatMessage("container.spectatorCantOpen")).a(EnumChatFormat.RED), true); -@@ -969,9 +1304,11 @@ +@@ -1027,9 +1362,11 @@ return OptionalInt.empty(); } else { -- this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, container.getType(), itileinventory.getScoreboardDisplayName())); -- container.addSlotListener(this); +- this.connection.sendPacket(new PacketPlayOutOpenWindow(container.containerId, container.getType(), itileinventory.getScoreboardDisplayName())); +- this.initMenu(container); + // CraftBukkit start - this.activeContainer = container; -+ this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, container.getType(), container.getTitle())); + this.containerMenu = container; ++ this.connection.sendPacket(new PacketPlayOutOpenWindow(container.containerId, container.getType(), container.getTitle())); + // CraftBukkit end -+ container.addSlotListener(this); ++ this.initMenu(container); return OptionalInt.of(this.containerCounter); } } -@@ -984,13 +1321,24 @@ +@@ -1042,13 +1379,24 @@ @Override public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { + // CraftBukkit start - Inventory open hook + this.nextContainerCounter(); -+ Container container = new ContainerHorse(this.containerCounter, this.inventory, iinventory, entityhorseabstract); ++ Container container = new ContainerHorse(this.containerCounter, this.getInventory(), iinventory, entityhorseabstract); + container.setTitle(entityhorseabstract.getScoreboardDisplayName()); + container = CraftEventFactory.callInventoryOpenEvent(this, container); + @@ -708,108 +708,99 @@ + return; + } + // CraftBukkit end - if (this.activeContainer != this.defaultContainer) { + if (this.containerMenu != this.inventoryMenu) { this.closeInventory(); } - this.nextContainerCounter(); + // this.nextContainerCounter(); // CraftBukkit - moved up - this.playerConnection.sendPacket(new PacketPlayOutOpenWindowHorse(this.containerCounter, iinventory.getSize(), entityhorseabstract.getId())); -- this.activeContainer = new ContainerHorse(this.containerCounter, this.inventory, iinventory, entityhorseabstract); -+ this.activeContainer = container; // CraftBukkit - this.activeContainer.addSlotListener(this); + this.connection.sendPacket(new PacketPlayOutOpenWindowHorse(this.containerCounter, iinventory.getSize(), entityhorseabstract.getId())); +- this.containerMenu = new ContainerHorse(this.containerCounter, this.getInventory(), iinventory, entityhorseabstract); ++ this.containerMenu = container; // CraftBukkit + this.initMenu(this.containerMenu); } -@@ -1035,6 +1383,11 @@ - public void a(Container container, NonNullList nonnulllist) { - this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist)); - this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried())); -+ // CraftBukkit start - Send a Set Slot to update the crafting result slot -+ if (java.util.EnumSet.of(InventoryType.CRAFTING,InventoryType.WORKBENCH).contains(container.getBukkitView().getType())) { -+ this.playerConnection.sendPacket(new PacketPlayOutSetSlot(container.windowId, 0, container.getSlot(0).getItem())); -+ } -+ // CraftBukkit end - } - - @Override -@@ -1044,6 +1397,7 @@ +@@ -1072,6 +1420,7 @@ @Override public void closeInventory() { + CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit - this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId)); + this.connection.sendPacket(new PacketPlayOutCloseWindow(this.containerMenu.containerId)); this.o(); } -@@ -1078,7 +1432,7 @@ +@@ -1101,7 +1450,7 @@ @Override public void a(Statistic statistic, int i) { - this.serverStatisticManager.b(this, statistic, i); + this.stats.b(this, statistic, i); - this.getScoreboard().getObjectivesForCriteria(statistic, this.getName(), (scoreboardscore) -> { -+ this.world.getServer().getScoreboardManager().getScoreboardScores(statistic, this.getName(), (scoreboardscore) -> { // CraftBukkit - Get our scores instead ++ this.level.getServer().getScoreboardManager().getScoreboardScores(statistic, this.getName(), (scoreboardscore) -> { // CraftBukkit - Get our scores instead scoreboardscore.addScore(i); }); } -@@ -1086,7 +1440,7 @@ +@@ -1109,7 +1458,7 @@ @Override public void a(Statistic statistic) { - this.serverStatisticManager.setStatistic(this, statistic, 0); + this.stats.setStatistic(this, statistic, 0); - this.getScoreboard().getObjectivesForCriteria(statistic, this.getName(), ScoreboardScore::c); -+ this.world.getServer().getScoreboardManager().getScoreboardScores(statistic, this.getName(), ScoreboardScore::c); // CraftBukkit - Get our scores instead ++ this.level.getServer().getScoreboardManager().getScoreboardScores(statistic, this.getName(), ScoreboardScore::c); // CraftBukkit - Get our scores instead } @Override -@@ -1135,7 +1489,16 @@ +@@ -1125,7 +1474,7 @@ + + for (int j = 0; j < i; ++j) { + MinecraftKey minecraftkey = aminecraftkey1[j]; +- Optional optional = this.server.getCraftingManager().getRecipe(minecraftkey); ++ Optional> optional = this.server.getCraftingManager().getRecipe(minecraftkey); // CraftBukkit - decompile error + + Objects.requireNonNull(list); + optional.ifPresent(list::add); +@@ -1160,7 +1509,16 @@ public void triggerHealthUpdate() { - this.lastHealthSent = -1.0E8F; + 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.b : uuid); ++ this.sendMessage(component, (uuid == null) ? SystemUtils.NIL_UUID : uuid); + } } + // CraftBukkit end @Override public void a(IChatBaseComponent ichatbasecomponent, boolean flag) { -@@ -1188,12 +1551,13 @@ +@@ -1215,11 +1573,12 @@ this.lastSentExp = -1; - this.lastHealthSent = -1.0F; - this.lastFoodSent = -1; + this.lastSentHealth = -1.0F; + this.lastSentFood = -1; - this.recipeBook.a((RecipeBook) entityplayer.recipeBook); + // this.recipeBook.a((RecipeBook) entityplayer.recipeBook); // CraftBukkit - this.removeQueue.addAll(entityplayer.removeQueue); - this.cd = entityplayer.cd; - this.ci = entityplayer.ci; + this.seenCredits = entityplayer.seenCredits; + this.enteredNetherPosition = entityplayer.enteredNetherPosition; this.setShoulderEntityLeft(entityplayer.getShoulderEntityLeft()); this.setShoulderEntityRight(entityplayer.getShoulderEntityRight()); + } @Override -@@ -1261,6 +1625,18 @@ - - @Override - public void a(EnumGamemode enumgamemode) { -+ // CraftBukkit start -+ if (enumgamemode == this.playerInteractManager.getGameMode()) { -+ return; -+ } -+ -+ PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(getBukkitEntity(), GameMode.getByValue(enumgamemode.getId())); -+ world.getServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ return; -+ } -+ // CraftBukkit end -+ - this.playerInteractManager.setGameMode(enumgamemode); - this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.d, (float) enumgamemode.getId())); - if (enumgamemode == EnumGamemode.SPECTATOR) { -@@ -1310,7 +1686,20 @@ +@@ -1289,6 +1648,13 @@ + if (!this.gameMode.setGameMode(enumgamemode)) { + return false; + } else { ++ // CraftBukkit start ++ PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(getBukkitEntity(), GameMode.getByValue(enumgamemode.getId())); ++ level.getServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ return false; ++ } ++ // CraftBukkit end + this.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.CHANGE_GAME_MODE, (float) enumgamemode.getId())); + if (enumgamemode == EnumGamemode.SPECTATOR) { + this.releaseShoulderEntities(); +@@ -1341,7 +1707,20 @@ return s; } @@ -820,42 +811,26 @@ + PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(getBukkitEntity(), getMainHand() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT); + this.server.server.getPluginManager().callEvent(event); + } -+ if (!this.locale.equals(packetplayinsettings.locale)) { -+ PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(getBukkitEntity(), packetplayinsettings.locale); ++ if (!this.locale.equals(packetplayinsettings.language)) { ++ PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(getBukkitEntity(), packetplayinsettings.language); + this.server.server.getPluginManager().callEvent(event); + } -+ this.locale = packetplayinsettings.locale; ++ this.locale = packetplayinsettings.language; + this.clientViewDistance = packetplayinsettings.viewDistance; + // CraftBukkit end - this.bY = packetplayinsettings.d(); - this.bZ = packetplayinsettings.e(); - this.getDataWatcher().set(EntityPlayer.bi, (byte) packetplayinsettings.f()); -@@ -1346,13 +1735,13 @@ - if (entity instanceof EntityHuman) { - this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(new int[]{entity.getId()})); - } else { -- this.removeQueue.add(entity.getId()); -+ this.removeQueue.add((Integer) entity.getId()); // CraftBukkit - decompile error + this.chatVisibility = packetplayinsettings.d(); + this.canChatColor = packetplayinsettings.e(); + this.textFilteringEnabled = packetplayinsettings.h(); +@@ -1411,7 +1790,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 } } - - public void d(Entity entity) { -- this.removeQueue.remove(entity.getId()); -+ this.removeQueue.remove((Integer) entity.getId()); // CraftBukkit - decompile error - } - - @Override -@@ -1376,7 +1765,7 @@ - this.spectatedEntity = (Entity) (entity == null ? this : entity); - if (entity1 != this.spectatedEntity) { - this.playerConnection.sendPacket(new PacketPlayOutCamera(this.spectatedEntity)); -- this.enderTeleportTo(this.spectatedEntity.locX(), this.spectatedEntity.locY(), this.spectatedEntity.locZ()); -+ this.playerConnection.a(this.spectatedEntity.locX(), this.spectatedEntity.locY(), this.spectatedEntity.locZ(), this.yaw, this.pitch, TeleportCause.SPECTATE); // CraftBukkit - } - - } -@@ -1405,7 +1794,7 @@ +@@ -1440,7 +1819,7 @@ @Nullable public IChatBaseComponent getPlayerListName() { @@ -864,8 +839,8 @@ } @Override -@@ -1426,9 +1815,16 @@ - return this.advancementDataPlayer; +@@ -1461,9 +1840,16 @@ + return this.advancements; } + // CraftBukkit start @@ -878,10 +853,10 @@ this.setSpectatorTarget(this); this.stopRiding(); + /* CraftBukkit start - replace with bukkit handling for multi-world - if (worldserver == this.world) { - this.playerConnection.a(d0, d1, d2, f, f1); + if (worldserver == this.level) { + this.connection.b(d0, d1, d2, f, f1); } else { -@@ -1449,6 +1845,9 @@ +@@ -1483,6 +1869,9 @@ this.server.getPlayerList().a(this, worldserver); this.server.getPlayerList().updateClient(this); } @@ -891,9 +866,9 @@ } -@@ -1546,4 +1945,144 @@ - public ITextFilter Q() { - return this.co; +@@ -1628,4 +2017,144 @@ + CriterionTriggers.USING_ITEM.a(this, itemstack); + super.a(itemstack); } + + // CraftBukkit start - Add per-player time and weather. @@ -903,10 +878,10 @@ + public long getPlayerTime() { + if (this.relativeTime) { + // Adds timeOffset to the current server time. -+ return this.world.getDayTime() + this.timeOffset; ++ return this.level.getDayTime() + this.timeOffset; + } else { + // Adds timeOffset to the beginning of this day. -+ return this.world.getDayTime() - (this.world.getDayTime() % 24000) + this.timeOffset; ++ return this.level.getDayTime() - (this.level.getDayTime() % 24000) + this.timeOffset; + } + } + @@ -926,9 +901,9 @@ + } + + if (type == WeatherType.DOWNFALL) { -+ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.c, 0)); ++ this.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.STOP_RAINING, 0)); + } else { -+ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.b, 0)); ++ this.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.START_RAINING, 0)); + } + } + @@ -939,20 +914,20 @@ + if (this.weather == null) { + // Vanilla + if (oldRain != newRain) { -+ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, newRain)); ++ this.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, newRain)); + } + } else { + // Plugin + if (pluginRainPositionPrevious != pluginRainPosition) { -+ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, pluginRainPosition)); ++ this.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, pluginRainPosition)); + } + } + + if (oldThunder != newThunder) { + if (weather == WeatherType.DOWNFALL || weather == null) { -+ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.i, newThunder)); ++ this.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, newThunder)); + } else { -+ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.i, 0)); ++ this.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, 0)); + } + } + } @@ -972,7 +947,7 @@ + + public void resetPlayerWeather() { + this.weather = null; -+ this.setPlayerWeather(this.world.getWorldData().hasStorm() ? WeatherType.DOWNFALL : WeatherType.CLEAR, false); ++ this.setPlayerWeather(this.level.getWorldData().hasStorm() ? WeatherType.DOWNFALL : WeatherType.CLEAR, false); + } + + @Override @@ -983,7 +958,7 @@ + // 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.playerConnection.syncPosition(); ++ this.connection.syncPosition(); + } + + @Override @@ -998,32 +973,32 @@ + + public void reset() { + float exp = 0; -+ boolean keepInventory = this.world.getGameRules().getBoolean(GameRules.KEEP_INVENTORY); ++ boolean keepInventory = this.level.getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY); + + if (this.keepLevel || keepInventory) { -+ exp = this.exp; -+ this.newTotalExp = this.expTotal; -+ this.newLevel = this.expLevel; ++ exp = this.experienceProgress; ++ this.newTotalExp = this.totalExperience; ++ this.newLevel = this.experienceLevel; + } + + this.setHealth(this.getMaxHealth()); -+ this.fireTicks = 0; ++ this.remainingFireTicks = 0; + this.fallDistance = 0; + this.foodData = new FoodMetaData(this); -+ this.expLevel = this.newLevel; -+ this.expTotal = this.newTotalExp; -+ this.exp = 0; -+ this.deathTicks = 0; ++ this.experienceLevel = this.newLevel; ++ this.totalExperience = this.newTotalExp; ++ this.experienceProgress = 0; ++ this.deathTime = 0; + this.setArrowCount(0, true); // CraftBukkit - ArrowBodyCountChangeEvent + this.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DEATH); -+ this.updateEffects = true; -+ this.activeContainer = this.defaultContainer; -+ this.killer = null; -+ this.lastDamager = null; ++ this.effectsDirty = true; ++ this.containerMenu = this.inventoryMenu; ++ this.lastHurtByPlayer = null; ++ this.lastHurtByMob = null; + this.combatTracker = new CombatTracker(this); + this.lastSentExp = -1; + if (this.keepLevel || keepInventory) { -+ this.exp = exp; ++ this.experienceProgress = exp; + } else { + this.giveExp(this.newExp); + } diff --git a/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch b/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch index 772af7d23..27520b40a 100644 --- a/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch +++ b/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/server/level/EntityTrackerEntry.java +++ b/net/minecraft/server/level/EntityTrackerEntry.java -@@ -40,6 +40,11 @@ +@@ -42,6 +42,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start ++import net.minecraft.server.network.ServerPlayerConnection; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerVelocityEvent; +// CraftBukkit end @@ -12,44 +13,51 @@ public class EntityTrackerEntry { private static final Logger LOGGER = LogManager.getLogger(); -@@ -60,8 +65,12 @@ - private List p; - private boolean q; - private boolean r; +@@ -63,8 +69,12 @@ + private List lastPassengers; + private boolean wasRiding; + private boolean wasOnGround; + // CraftBukkit start -+ private final Set trackedPlayers; ++ private final Set trackedPlayers; - public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer> consumer) { -+ public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer> consumer, Set trackedPlayers) { ++ public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer> consumer, Set trackedPlayers) { + this.trackedPlayers = trackedPlayers; + // CraftBukkit end - this.m = Vec3D.ORIGIN; - this.p = Collections.emptyList(); - this.b = worldserver; -@@ -81,16 +90,16 @@ + this.ap = Vec3D.ZERO; + this.lastPassengers = Collections.emptyList(); + this.level = worldserver; +@@ -84,22 +94,22 @@ - if (!list.equals(this.p)) { - this.p = list; -- this.f.accept(new PacketPlayOutMount(this.tracker)); -+ this.broadcastIncludingSelf(new PacketPlayOutMount(this.tracker)); // CraftBukkit + if (!list.equals(this.lastPassengers)) { + this.lastPassengers = list; +- this.broadcast.accept(new PacketPlayOutMount(this.entity)); ++ this.broadcastIncludingSelf(new PacketPlayOutMount(this.entity)); // CraftBukkit } -- if (this.tracker instanceof EntityItemFrame && this.tickCounter % 10 == 0) { -+ if (this.tracker instanceof EntityItemFrame /*&& this.tickCounter % 10 == 0*/) { // CraftBukkit - Moved below, should always enter this block - EntityItemFrame entityitemframe = (EntityItemFrame) this.tracker; +- if (this.entity instanceof EntityItemFrame && this.tickCount % 10 == 0) { ++ if (this.entity instanceof EntityItemFrame /*&& this.tickCounter % 10 == 0*/) { // CraftBukkit - Moved below, should always enter this block + EntityItemFrame entityitemframe = (EntityItemFrame) this.entity; ItemStack itemstack = entityitemframe.getItem(); - if (itemstack.getItem() instanceof ItemWorldMap) { -+ if (this.tickCounter % 10 == 0 && itemstack.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.tickCounter % 10 logic here so item frames do not enter the other blocks - WorldMap worldmap = ItemWorldMap.getSavedMap(itemstack, this.b); -- Iterator iterator = this.b.getPlayers().iterator(); -+ Iterator iterator = this.trackedPlayers.iterator(); // CraftBukkit ++ 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); - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -135,6 +144,17 @@ - boolean flag2 = flag1 || this.tickCounter % 60 == 0; - boolean flag3 = Math.abs(i - this.yRot) >= 1 || Math.abs(j - this.xRot) >= 1; + if (worldmap != null) { +- Iterator iterator = this.level.getPlayers().iterator(); ++ Iterator iterator = this.trackedPlayers.iterator(); // CraftBukkit + + while (iterator.hasNext()) { +- EntityPlayer entityplayer = (EntityPlayer) iterator.next(); ++ EntityPlayer entityplayer = iterator.next().d(); // CraftBukkit + + worldmap.a((EntityHuman) entityplayer, itemstack); + Packet packet = worldmap.a(integer, entityplayer); +@@ -142,6 +152,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) { @@ -57,15 +65,15 @@ + } + + if (flag3) { -+ this.yRot = i; -+ this.xRot = j; ++ this.yRotp = i; ++ this.xRotp = j; + } + // CraftBukkit end + - if (this.tickCounter > 0 || this.tracker instanceof EntityArrow) { + if (this.tickCount > 0 || this.entity instanceof EntityArrow) { long k = PacketPlayOutEntity.a(vec3d.x); long l = PacketPlayOutEntity.a(vec3d.y); -@@ -173,6 +193,7 @@ +@@ -180,6 +201,7 @@ } this.c(); @@ -73,28 +81,28 @@ if (flag2) { this.d(); } -@@ -181,6 +202,7 @@ - this.yRot = i; - this.xRot = j; +@@ -188,6 +210,7 @@ + this.yRotp = i; + this.xRotp = j; } + // CraftBukkit end */ - this.q = false; + this.wasRiding = false; } -@@ -196,7 +218,27 @@ +@@ -203,7 +226,27 @@ - ++this.tickCounter; - if (this.tracker.velocityChanged) { -- this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.tracker)); + ++this.tickCount; + if (this.entity.hurtMarked) { +- this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.entity)); + // CraftBukkit start - Create PlayerVelocity event + boolean cancelled = false; + -+ if (this.tracker instanceof EntityPlayer) { -+ Player player = (Player) this.tracker.getBukkitEntity(); ++ if (this.entity instanceof EntityPlayer) { ++ Player player = (Player) this.entity.getBukkitEntity(); + org.bukkit.util.Vector velocity = player.getVelocity(); + + PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone()); -+ this.tracker.world.getServer().getPluginManager().callEvent(event); ++ this.entity.level.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + cancelled = true; @@ -104,70 +112,69 @@ + } + + if (!cancelled) { -+ this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.tracker)); ++ this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.entity)); + } + // CraftBukkit end - this.tracker.velocityChanged = false; + this.entity.hurtMarked = false; } -@@ -211,14 +253,17 @@ - PlayerConnection playerconnection = entityplayer.playerConnection; +@@ -218,13 +261,16 @@ + PlayerConnection playerconnection = entityplayer.connection; - entityplayer.playerConnection.getClass(); + Objects.requireNonNull(entityplayer.connection); - this.a(playerconnection::sendPacket); + this.a(playerconnection::sendPacket, entityplayer); // CraftBukkit - add player - this.tracker.b(entityplayer); - entityplayer.d(this.tracker); + this.entity.c(entityplayer); } - public void a(Consumer> consumer) { + public void a(Consumer> consumer, EntityPlayer entityplayer) { // CraftBukkit - add player - if (this.tracker.dead) { -- EntityTrackerEntry.LOGGER.warn("Fetching packet for removed entity " + this.tracker); + if (this.entity.isRemoved()) { +- EntityTrackerEntry.LOGGER.warn("Fetching packet for removed entity {}", this.entity); + // CraftBukkit start - Remove useless error spam, just return -+ // EntityTrackerEntry.LOGGER.warn("Fetching packet for removed entity " + this.tracker); ++ // EntityTrackerEntry.LOGGER.warn("Fetching packet for removed entity {}", this.entity); + return; + // CraftBukkit end } - Packet packet = this.tracker.P(); -@@ -234,6 +279,12 @@ - if (this.tracker instanceof EntityLiving) { - Collection collection = ((EntityLiving) this.tracker).getAttributeMap().b(); + Packet packet = this.entity.getPacket(); +@@ -240,6 +286,12 @@ + if (this.entity instanceof EntityLiving) { + Collection collection = ((EntityLiving) this.entity).getAttributeMap().b(); + // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health -+ if (this.tracker.getId() == entityplayer.getId()) { -+ ((EntityPlayer) this.tracker).getBukkitEntity().injectScaledMaxHealth(collection, false); ++ if (this.entity.getId() == entityplayer.getId()) { ++ ((EntityPlayer) this.entity).getBukkitEntity().injectScaledMaxHealth(collection, false); + } + // CraftBukkit end + if (!collection.isEmpty()) { - consumer.accept(new PacketPlayOutUpdateAttributes(this.tracker.getId(), collection)); + consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection)); } -@@ -265,8 +316,14 @@ +@@ -271,8 +323,14 @@ if (!list.isEmpty()) { - consumer.accept(new PacketPlayOutEntityEquipment(this.tracker.getId(), list)); + consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list)); } -+ ((EntityLiving) this.tracker).updateEquipment(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending ++ ((EntityLiving) this.entity).updateEquipment(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending } + // CraftBukkit start - Fix for nonsensical head yaw -+ this.headYaw = MathHelper.d(this.tracker.getHeadRotation() * 256.0F / 360.0F); -+ consumer.accept(new PacketPlayOutEntityHeadRotation(this.tracker, (byte) headYaw)); ++ this.yHeadRotp = MathHelper.d(this.entity.getHeadRotation() * 256.0F / 360.0F); ++ consumer.accept(new PacketPlayOutEntityHeadRotation(this.entity, (byte) yHeadRotp)); + // CraftBukkit end + - if (this.tracker instanceof EntityLiving) { - EntityLiving entityliving = (EntityLiving) this.tracker; + if (this.entity instanceof EntityLiving) { + EntityLiving entityliving = (EntityLiving) this.entity; Iterator iterator = entityliving.getEffects().iterator(); -@@ -307,6 +364,11 @@ - Set set = ((EntityLiving) this.tracker).getAttributeMap().getAttributes(); +@@ -313,6 +371,11 @@ + Set set = ((EntityLiving) this.entity).getAttributeMap().getAttributes(); if (!set.isEmpty()) { + // CraftBukkit start - Send scaled max health -+ if (this.tracker instanceof EntityPlayer) { -+ ((EntityPlayer) this.tracker).getBukkitEntity().injectScaledMaxHealth(set, false); ++ if (this.entity instanceof EntityPlayer) { ++ ((EntityPlayer) this.entity).getBukkitEntity().injectScaledMaxHealth(set, false); + } + // CraftBukkit end - this.broadcastIncludingSelf(new PacketPlayOutUpdateAttributes(this.tracker.getId(), set)); + this.broadcastIncludingSelf(new PacketPlayOutUpdateAttributes(this.entity.getId(), set)); } diff --git a/nms-patches/net/minecraft/server/level/PlayerChunk.patch b/nms-patches/net/minecraft/server/level/PlayerChunk.patch index 6877ff396..d68950097 100644 --- a/nms-patches/net/minecraft/server/level/PlayerChunk.patch +++ b/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 -@@ -33,6 +33,10 @@ +@@ -38,6 +38,10 @@ import net.minecraft.world.level.chunk.ProtoChunkExtension; import net.minecraft.world.level.lighting.LightEngine; @@ -10,18 +10,23 @@ + public class PlayerChunk { - public static final Either UNLOADED_CHUNK_ACCESS = Either.right(PlayerChunk.Failure.b); -@@ -65,7 +69,7 @@ - this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; - this.tickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; - this.entityTickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; -- this.chunkSave = CompletableFuture.completedFuture((Object) null); -+ this.chunkSave = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error - this.dirtyBlocks = new ShortSet[16]; - this.location = chunkcoordintpair; + public static final Either UNLOADED_CHUNK = Either.right(PlayerChunk.Failure.UNLOADED); +@@ -75,11 +79,11 @@ + this.fullChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE; + this.tickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE; + this.entityTickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE; +- this.chunkToSave = CompletableFuture.completedFuture((Object) null); ++ this.chunkToSave = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error + this.chunkToSaveHistory = null; + this.blockChangedLightSectionFilter = new BitSet(); + this.skyChangedLightSectionFilter = new BitSet(); +- this.pendingFullStateConfirmation = CompletableFuture.completedFuture((Object) null); ++ this.pendingFullStateConfirmation = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error + this.pos = chunkcoordintpair; + this.levelHeightAccessor = levelheightaccessor; this.lightEngine = lightengine; -@@ -77,6 +81,19 @@ - this.a(i); +@@ -92,6 +96,19 @@ + this.changedBlocksPerSection = new ShortSet[levelheightaccessor.getSectionsCount()]; } + // CraftBukkit start @@ -38,9 +43,9 @@ + // CraftBukkit end + public CompletableFuture> getStatusFutureUnchecked(ChunkStatus chunkstatus) { - CompletableFuture> completablefuture = (CompletableFuture) this.statusFutures.get(chunkstatus.c()); + CompletableFuture> completablefuture = (CompletableFuture) this.futures.get(chunkstatus.c()); -@@ -102,9 +119,9 @@ +@@ -117,9 +134,9 @@ @Nullable public Chunk getChunk() { CompletableFuture> completablefuture = this.a(); @@ -52,25 +57,34 @@ } @Nullable -@@ -135,6 +152,7 @@ +@@ -164,6 +181,7 @@ if (chunk != null) { - byte b0 = (byte) SectionPosition.a(blockposition.getY()); + int i = this.levelHeightAccessor.getSectionIndex(blockposition.getY()); -+ if (b0 < 0 || b0 >= this.dirtyBlocks.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296 - if (this.dirtyBlocks[b0] == null) { - this.p = true; - this.dirtyBlocks[b0] = new ShortArraySet(); -@@ -237,7 +255,7 @@ - CompletableFuture> completablefuture = (CompletableFuture) this.statusFutures.get(i); ++ 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 @@ + CompletableFuture> completablefuture = (CompletableFuture) this.futures.get(i); if (completablefuture != null) { - Either either = (Either) completablefuture.getNow((Object) null); + Either either = (Either) completablefuture.getNow(null); // CraftBukkit - decompile error + boolean flag = either != null && either.right().isPresent(); - if (either == null || either.left().isPresent()) { - return completablefuture; -@@ -292,6 +310,30 @@ - boolean flag1 = this.ticketLevel <= PlayerChunkMap.GOLDEN_TICKET; + if (!flag) { +@@ -341,7 +359,7 @@ + this.pendingFullStateConfirmation = completablefuture1; + completablefuture.thenAccept((either) -> { + either.ifLeft((chunk) -> { +- completablefuture1.complete((Object) null); ++ completablefuture1.complete(null); // CraftBukkit - decompile error + }); + }); + } +@@ -358,6 +376,30 @@ + boolean flag1 = this.ticketLevel <= PlayerChunkMap.MAX_CHUNK_DISTANCE; PlayerChunk.State playerchunk_state = getChunkState(this.oldTicketLevel); PlayerChunk.State playerchunk_state1 = getChunkState(this.ticketLevel); + // CraftBukkit start @@ -89,7 +103,7 @@ + } + }).exceptionally((throwable) -> { + // ensure exceptions are printed, by default this is not the case -+ MinecraftServer.LOGGER.fatal("Failed to schedule unload callback for chunk " + PlayerChunk.this.location, throwable); ++ MinecraftServer.LOGGER.fatal("Failed to schedule unload callback for chunk " + PlayerChunk.this.pos, throwable); + return null; + }); + @@ -100,18 +114,18 @@ CompletableFuture completablefuture; if (flag) { -@@ -323,7 +365,7 @@ +@@ -388,7 +430,7 @@ if (flag2 && !flag3) { completablefuture = this.fullChunkFuture; - this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; + this.fullChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE; - this.a(completablefuture.thenApply((either1) -> { + this.a(((CompletableFuture>) completablefuture).thenApply((either1) -> { // CraftBukkit - decompile error - playerchunkmap.getClass(); + Objects.requireNonNull(playerchunkmap); return either1.ifLeft(playerchunkmap::a); - })); -@@ -361,6 +403,26 @@ + }), "unfull"); +@@ -432,6 +474,26 @@ - this.u.a(this.location, this::k, this.ticketLevel, this::d); + this.onLevelChange.a(this.pos, this::k, this.ticketLevel, this::d); 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. @@ -125,7 +139,7 @@ + } + }).exceptionally((throwable) -> { + // ensure exceptions are printed, by default this is not the case -+ MinecraftServer.LOGGER.fatal("Failed to schedule load callback for chunk " + PlayerChunk.this.location, throwable); ++ MinecraftServer.LOGGER.fatal("Failed to schedule load callback for chunk " + PlayerChunk.this.pos, throwable); + return null; + }); + diff --git a/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch b/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch index a83228228..d2229d45d 100644 --- a/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch +++ b/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch @@ -1,47 +1,43 @@ --- a/net/minecraft/server/level/PlayerChunkMap.java +++ b/net/minecraft/server/level/PlayerChunkMap.java -@@ -89,6 +89,8 @@ +@@ -91,6 +91,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.bukkit.entity.Player; // CraftBukkit + - public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.e { - private static final Logger LOGGER = LogManager.getLogger(); -@@ -119,6 +121,31 @@ - private final Queue A; - private int viewDistance; + private static final byte CHUNK_TYPE_REPLACEABLE = -1; +@@ -129,6 +131,27 @@ + private final Queue unloadQueue; + int viewDistance; + // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback() + public final CallbackExecutor callbackExecutor = new CallbackExecutor(); + public static final class CallbackExecutor implements java.util.concurrent.Executor, Runnable { + -+ private Runnable queued; ++ private final java.util.Queue queue = new java.util.ArrayDeque<>(); + + @Override + public void execute(Runnable runnable) { -+ if (queued != null) { -+ throw new IllegalStateException("Already queued"); -+ } -+ queued = runnable; ++ queue.add(runnable); + } + + @Override + public void run() { -+ Runnable task = queued; -+ queued = null; -+ if (task != null) { ++ Runnable task; ++ while ((task = queue.poll()) != null) { + task.run(); + } + } + }; + // CraftBukkit end + - public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, Supplier supplier, int i, boolean flag) { + public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier supplier, int i, boolean flag) { super(new File(convertable_conversionsession.a(worldserver.getDimensionKey()), "region"), datafixer, flag); - this.visibleChunks = this.updatingChunks.clone(); -@@ -239,9 +266,12 @@ + this.visibleChunkMap = this.updatingChunkMap.clone(); +@@ -279,9 +302,12 @@ return completablefuture1.thenApply((list1) -> { List list2 = Lists.newArrayList(); @@ -56,24 +52,24 @@ final Either either = (Either) iterator.next(); Optional optional = either.left(); -@@ -344,7 +374,7 @@ - PlayerChunkMap.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.w.getName()); +@@ -389,7 +415,7 @@ + PlayerChunkMap.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.storageFolder.getName()); } else { - this.visibleChunks.values().stream().filter(PlayerChunk::hasBeenLoaded).forEach((playerchunk) -> { + 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 if (ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk) { this.saveChunk(ichunkaccess); -@@ -355,7 +385,6 @@ +@@ -400,7 +426,6 @@ } } - protected void unloadChunks(BooleanSupplier booleansupplier) { - GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler(); + GameProfilerFiller gameprofilerfiller = this.level.getMethodProfiler(); -@@ -394,7 +423,7 @@ +@@ -439,7 +464,7 @@ private void a(long i, PlayerChunk playerchunk) { CompletableFuture completablefuture = playerchunk.getChunkSave(); @@ -82,42 +78,40 @@ CompletableFuture completablefuture1 = playerchunk.getChunkSave(); if (completablefuture1 != completablefuture) { -@@ -616,8 +645,23 @@ +@@ -615,7 +640,21 @@ - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); -+ // CraftBukkit start - these are spawned serialized (DefinedStructure) and we don't call an add event below at the moment due to ordering complexities -+ boolean needsRemoval = false; -+ if (chunk.needsDecoration) { -+ net.minecraft.server.dedicated.DedicatedServer server = this.world.getServer().getServer(); -+ if (!server.getSpawnNPCs() && entity instanceof net.minecraft.world.entity.npc.NPC) { -+ entity.die(); -+ needsRemoval = true; -+ } -+ -+ if (!server.getSpawnAnimals() && (entity instanceof net.minecraft.world.entity.animal.EntityAnimal || entity instanceof net.minecraft.world.entity.animal.EntityWaterAnimal)) { -+ entity.die(); -+ needsRemoval = true; -+ } -+ } + private static void a(WorldServer worldserver, List list) { + if (!list.isEmpty()) { +- worldserver.b(EntityTypes.a(list, (World) 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) -> { ++ boolean needsRemoval = false; ++ net.minecraft.server.dedicated.DedicatedServer server = worldserver.getServer().getServer(); ++ if (!server.getSpawnNPCs() && entity instanceof net.minecraft.world.entity.npc.NPC) { ++ entity.die(); ++ needsRemoval = true; ++ } ++ if (!server.getSpawnAnimals() && (entity instanceof net.minecraft.world.entity.animal.EntityAnimal || entity instanceof net.minecraft.world.entity.animal.EntityWaterAnimal)) { ++ entity.die(); ++ needsRemoval = true; ++ } ++ return !needsRemoval; ++ })); ++ // CraftBukkit end + } -- if (!(entity instanceof EntityHuman) && !this.world.addEntityChunk(entity)) { -+ if (!(entity instanceof EntityHuman) && (needsRemoval || !this.world.addEntityChunk(entity))) { -+ // CraftBukkit end - if (list == null) { - list = Lists.newArrayList(new Entity[]{entity}); - } else { -@@ -828,7 +872,8 @@ + } +@@ -843,7 +882,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.chunkDistanceManager.c(entry.getLongKey()), !this.isOutsideOfRange(chunkcoordintpair), optional1.map((chunk) -> { +- 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) -> { + // 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.chunkDistanceManager.c(entry.getLongKey()), !this.isOutsideOfRange(chunkcoordintpair), optional1.map((chunk) -> { - return Stream.of(chunk.getEntitySlices()).mapToInt(EntitySlice::size).sum(); - }).orElse(0), optional1.map((chunk) -> { ++ 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(); -@@ -839,7 +884,7 @@ + }).orElse(0)); + } +@@ -852,7 +892,7 @@ private static String a(CompletableFuture> completablefuture) { try { @@ -126,48 +120,41 @@ return either != null ? (String) either.map((chunk) -> { return "done"; -@@ -857,7 +902,7 @@ +@@ -870,7 +910,7 @@ private NBTTagCompound readChunkData(ChunkCoordIntPair chunkcoordintpair) throws IOException { NBTTagCompound nbttagcompound = this.read(chunkcoordintpair); -- return nbttagcompound == null ? null : this.getChunkData(this.world.getDimensionKey(), this.l, nbttagcompound); -+ return nbttagcompound == null ? null : this.getChunkData(this.world.getTypeKey(), this.l, nbttagcompound, chunkcoordintpair, world); // CraftBukkit +- 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 } boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair) { -@@ -1189,7 +1234,7 @@ - public final Set trackedPlayers = Sets.newHashSet(); +@@ -1233,7 +1273,7 @@ + public final Set seenBy = Sets.newIdentityHashSet(); public EntityTracker(Entity entity, int i, int j, boolean flag) { -- this.trackerEntry = new EntityTrackerEntry(PlayerChunkMap.this.world, entity, j, flag, this::broadcast); -+ this.trackerEntry = new EntityTrackerEntry(PlayerChunkMap.this.world, entity, j, flag, this::broadcast, trackedPlayers); // CraftBukkit - this.tracker = entity; - this.trackingDistance = i; - this.e = SectionPosition.a(entity); -@@ -1242,7 +1287,7 @@ +- this.serverEntity = new EntityTrackerEntry(PlayerChunkMap.this.level, entity, j, flag, this::broadcast); ++ this.serverEntity = new EntityTrackerEntry(PlayerChunkMap.this.level, entity, j, flag, this::broadcast, seenBy); // CraftBukkit + this.entity = entity; + this.range = i; + this.lastSectionPos = SectionPosition.a(entity); +@@ -1286,10 +1326,18 @@ public void updatePlayer(EntityPlayer entityplayer) { - if (entityplayer != this.tracker) { -- Vec3D vec3d = entityplayer.getPositionVector().d(this.trackerEntry.b()); -+ Vec3D vec3d = entityplayer.getPositionVector().d(this.tracker.getPositionVector()); // MC-155077, SPIGOT-5113 + 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.tracker.a(entityplayer); + boolean flag = vec3d.x >= (double) (-i) && vec3d.x <= (double) i && vec3d.z >= (double) (-i) && vec3d.z <= (double) i && this.entity.a(entityplayer); -@@ -1258,6 +1303,17 @@ - } - } - -+ // CraftBukkit start - respect vanish API -+ if (this.tracker instanceof EntityPlayer) { -+ Player player = ((EntityPlayer) this.tracker).getBukkitEntity(); -+ if (!entityplayer.getBukkitEntity().canSee(player)) { -+ flag1 = false; -+ } ++ // CraftBukkit start - respect vanish API ++ if (this.entity instanceof EntityPlayer) { ++ Player player = ((EntityPlayer) this.entity).getBukkitEntity(); ++ if (!entityplayer.getBukkitEntity().canSee(player)) { ++ flag = false; + } -+ -+ entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId())); -+ // CraftBukkit end -+ - if (flag1 && this.trackedPlayers.add(entityplayer)) { - this.trackerEntry.b(entityplayer); - } ++ } ++ // CraftBukkit end + if (flag) { + if (this.seenBy.add(entityplayer.connection)) { + this.serverEntity.b(entityplayer); diff --git a/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch b/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch index 548482678..c1b39170d 100644 --- a/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch +++ b/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 -@@ -26,6 +26,25 @@ +@@ -25,6 +25,25 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -26,49 +26,49 @@ public class PlayerInteractManager { private static final Logger LOGGER = LogManager.getLogger(); -@@ -60,7 +79,7 @@ - this.gamemode = enumgamemode; - enumgamemode.a(this.player.abilities); +@@ -65,7 +84,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.world.everyoneSleeping(); + this.level.everyoneSleeping(); } -@@ -89,7 +108,7 @@ +@@ -87,7 +106,7 @@ } public void a() { -- ++this.currentTick; -+ this.currentTick = MinecraftServer.currentTick; // CraftBukkit; +- ++this.gameTicks; ++ this.gameTicks = MinecraftServer.currentTick; // CraftBukkit; IBlockData iblockdata; - if (this.j) { -@@ -145,9 +164,31 @@ + if (this.hasDelayedDestroy) { +@@ -143,9 +162,31 @@ if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) { - if (!this.world.a((EntityHuman) this.player, blockposition)) { + if (!this.level.a((EntityHuman) this.player, blockposition)) { + // CraftBukkit start - fire PlayerInteractEvent -+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND); - this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.world.getType(blockposition), packetplayinblockdig_enumplayerdigtype, false, "may not interact")); ++ 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")); + // Update any tile entity data for this block -+ TileEntity tileentity = world.getTileEntity(blockposition); ++ TileEntity tileentity = level.getTileEntity(blockposition); + if (tileentity != null) { -+ this.player.playerConnection.sendPacket(tileentity.getUpdatePacket()); ++ this.player.connection.sendPacket(tileentity.getUpdatePacket()); + } + // CraftBukkit end + return; + } + + // CraftBukkit start -+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND); ++ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getItemInHand(), EnumHand.MAIN_HAND); + if (event.isCancelled()) { + // Let the client know the block still exists -+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); ++ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition)); + // Update any tile entity data for this block -+ TileEntity tileentity = this.world.getTileEntity(blockposition); ++ TileEntity tileentity = this.level.getTileEntity(blockposition); + if (tileentity != null) { -+ this.player.playerConnection.sendPacket(tileentity.getUpdatePacket()); ++ this.player.connection.sendPacket(tileentity.getUpdatePacket()); + } return; } @@ -76,40 +76,40 @@ if (this.isCreative()) { this.a(blockposition, packetplayinblockdig_enumplayerdigtype, "creative destroy"); -@@ -163,11 +204,43 @@ +@@ -161,11 +202,43 @@ float f = 1.0F; - iblockdata = this.world.getType(blockposition); + iblockdata = this.level.getType(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.world.getType(blockposition); ++ IBlockData data = this.level.getType(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.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); -+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, bottom ? blockposition.up() : blockposition.down())); ++ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition)); ++ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, bottom ? blockposition.up() : blockposition.down())); + } else if (data.getBlock() instanceof BlockTrapdoor) { -+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); ++ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition)); + } + } else if (!iblockdata.isAir()) { - iblockdata.attack(this.world, blockposition, this.player); - f = iblockdata.getDamage(this.player, this.player.world, blockposition); + iblockdata.attack(this.level, blockposition, this.player); + f = iblockdata.getDamage(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.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); ++ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition)); + } + return; + } -+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.player.inventory.getItemInHand(), f >= 1.0f); ++ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.player.getInventory().getItemInHand(), f >= 1.0f); + + if (blockEvent.isCancelled()) { + // Let the client know the block still exists -+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); ++ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition)); + return; + } + @@ -121,41 +121,40 @@ if (!iblockdata.isAir() && f >= 1.0F) { this.a(blockposition, packetplayinblockdig_enumplayerdigtype, "insta mine"); } else { -@@ -211,7 +284,7 @@ +@@ -209,7 +282,7 @@ } else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) { - this.f = false; - if (!Objects.equals(this.h, blockposition)) { -- PlayerInteractManager.LOGGER.warn("Mismatch in destroy block pos: " + this.h + " " + blockposition); -+ PlayerInteractManager.LOGGER.debug("Mismatch in destroy block pos: " + this.h + " " + blockposition); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled - this.world.a(this.player.getId(), this.h, -1); - this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(this.h, this.world.getType(this.h), packetplayinblockdig_enumplayerdigtype, true, "aborted mismatched destroying")); + 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")); } -@@ -227,17 +300,73 @@ +@@ -225,17 +298,72 @@ if (this.breakBlock(blockposition)) { - this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.world.getType(blockposition), packetplayinblockdig_enumplayerdigtype, true, s)); + this.player.connection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.level.getType(blockposition), packetplayinblockdig_enumplayerdigtype, true, s)); } else { -- this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.world.getType(blockposition), packetplayinblockdig_enumplayerdigtype, false, s)); -+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); // CraftBukkit - SPIGOT-5196 +- 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 } } public boolean breakBlock(BlockPosition blockposition) { - IBlockData iblockdata = this.world.getType(blockposition); + IBlockData iblockdata = this.level.getType(blockposition); + // CraftBukkit start - fire BlockBreakEvent -+ org.bukkit.block.Block bblock = CraftBlock.at(world, blockposition); ++ 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.world, blockposition, (EntityHuman) this.player); ++ boolean isSwordNoBreak = !this.player.getItemInMainHand().getItem().a(iblockdata, this.level, blockposition, (EntityHuman) 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 (world.getTileEntity(blockposition) == null && !isSwordNoBreak) { -+ PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(this.world, blockposition); -+ packet.block = Blocks.AIR.getBlockData(); -+ this.player.playerConnection.sendPacket(packet); ++ if (level.getTileEntity(blockposition) == null && !isSwordNoBreak) { ++ PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(blockposition, Blocks.AIR.getBlockData()); ++ this.player.connection.sendPacket(packet); + } + + event = new BlockBreakEvent(bblock, this.player.getBukkitEntity()); @@ -164,60 +163,60 @@ + event.setCancelled(isSwordNoBreak); + + // Calculate default block experience -+ IBlockData nmsData = this.world.getType(blockposition); ++ IBlockData nmsData = this.level.getType(blockposition); + Block nmsBlock = nmsData.getBlock(); + + ItemStack itemstack = this.player.getEquipment(EnumItemSlot.MAINHAND); + + if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasBlock(nmsBlock.getBlockData())) { -+ event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.world, blockposition, itemstack)); ++ event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.level, blockposition, itemstack)); + } -- if (!this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.world, blockposition, (EntityHuman) this.player)) { -+ this.world.getServer().getPluginManager().callEvent(event); +- if (!this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.level, blockposition, (EntityHuman) this.player)) { ++ this.level.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + if (isSwordNoBreak) { + return false; + } + // Let the client know the block still exists -+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); ++ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition)); + + // Brute force all possible updates + for (EnumDirection dir : EnumDirection.values()) { -+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(dir))); ++ this.player.connection.sendPacket(new PacketPlayOutBlockChange(level, blockposition.shift(dir))); + } + + // Update any tile entity data for this block -+ TileEntity tileentity = this.world.getTileEntity(blockposition); ++ TileEntity tileentity = this.level.getTileEntity(blockposition); + if (tileentity != null) { -+ this.player.playerConnection.sendPacket(tileentity.getUpdatePacket()); ++ this.player.connection.sendPacket(tileentity.getUpdatePacket()); + } + return false; + } + } + // CraftBukkit end + -+ if (false && !this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.world, blockposition, (EntityHuman) this.player)) { // CraftBukkit - false ++ if (false && !this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.level, blockposition, (EntityHuman) this.player)) { // CraftBukkit - false return false; } else { -+ iblockdata = this.world.getType(blockposition); // CraftBukkit - update state from plugins ++ iblockdata = this.level.getType(blockposition); // CraftBukkit - update state from plugins + if (iblockdata.isAir()) return false; // CraftBukkit - A plugin set block to air without cancelling - TileEntity tileentity = this.world.getTileEntity(blockposition); + TileEntity tileentity = this.level.getTileEntity(blockposition); Block block = iblockdata.getBlock(); -@@ -247,6 +376,10 @@ - } else if (this.player.a((World) this.world, blockposition, this.gamemode)) { +@@ -245,6 +373,10 @@ + } else if (this.player.a((World) this.level, blockposition, this.gameModeForPlayer)) { return false; } else { + // CraftBukkit start + org.bukkit.block.BlockState state = bblock.getState(); -+ world.captureDrops = new ArrayList<>(); ++ level.captureDrops = new ArrayList<>(); + // CraftBukkit end - block.a((World) this.world, blockposition, iblockdata, (EntityHuman) this.player); - boolean flag = this.world.a(blockposition, false); + block.a((World) this.level, blockposition, iblockdata, (EntityHuman) this.player); + boolean flag = this.level.a(blockposition, false); -@@ -255,19 +388,32 @@ +@@ -253,19 +385,32 @@ } if (this.isCreative()) { @@ -228,10 +227,10 @@ ItemStack itemstack1 = itemstack.cloneItemStack(); boolean flag1 = this.player.hasBlock(iblockdata); - itemstack.a(this.world, iblockdata, blockposition, this.player); + itemstack.a(this.level, iblockdata, blockposition, this.player); - if (flag && flag1) { + if (flag && flag1 && event.isDropItems()) { // CraftBukkit - Check if block should drop items - block.a(this.world, this.player, blockposition, iblockdata, tileentity, itemstack1); + block.a(this.level, this.player, blockposition, iblockdata, tileentity, itemstack1); } - return true; @@ -239,13 +238,13 @@ + } + // CraftBukkit start + if (event.isDropItems()) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, world.captureDrops); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, level.captureDrops); } -+ world.captureDrops = null; ++ level.captureDrops = null; + + // Drop event experience + if (flag && event != null) { -+ iblockdata.getBlock().dropExperience(this.world, blockposition, event.getExpToDrop()); ++ iblockdata.getBlock().dropExperience(this.level, blockposition, event.getExpToDrop()); + } + + return true; @@ -253,7 +252,7 @@ } } } -@@ -309,12 +455,52 @@ +@@ -307,12 +452,52 @@ } } @@ -269,7 +268,7 @@ + EnumInteractionResult enuminteractionresult = EnumInteractionResult.PASS; + boolean cancelledBlock = false; - if (this.gamemode == EnumGamemode.SPECTATOR) { + if (this.gameModeForPlayer == EnumGamemode.SPECTATOR) { ITileInventory itileinventory = iblockdata.b(world, blockposition); + cancelledBlock = !(itileinventory instanceof ITileInventory); + } @@ -289,24 +288,24 @@ + // 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.playerConnection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down())); ++ entityplayer.connection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down())); + } 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.playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(movingobjectpositionblock.getDirection()).up())); ++ entityplayer.connection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(movingobjectpositionblock.getDirection()).up())); + + // 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.playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.up())); ++ entityplayer.connection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.up())); + } + entityplayer.getBukkitEntity().updateInventory(); // SPIGOT-2867 + enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS; -+ } else if (this.gamemode == EnumGamemode.SPECTATOR) { ++ } else if (this.gameModeForPlayer == EnumGamemode.SPECTATOR) { + ITileInventory itileinventory = iblockdata.b(world, blockposition); if (itileinventory != null) { entityplayer.openContainer(itileinventory); -@@ -328,7 +514,7 @@ +@@ -326,7 +511,7 @@ ItemStack itemstack1 = itemstack.cloneItemStack(); if (!flag1) { @@ -314,8 +313,8 @@ + enuminteractionresult = iblockdata.interact(world, entityplayer, enumhand, movingobjectpositionblock); if (enuminteractionresult.a()) { - CriterionTriggers.M.a(entityplayer, blockposition, itemstack1); -@@ -336,17 +522,17 @@ + CriterionTriggers.ITEM_USED_ON_BLOCK.a(entityplayer, blockposition, itemstack1); +@@ -334,17 +519,17 @@ } } @@ -336,7 +335,7 @@ } if (enuminteractionresult1.a()) { -@@ -354,10 +540,10 @@ +@@ -352,10 +537,10 @@ } return enuminteractionresult1; diff --git a/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch b/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch index 165d4e0b8..388fe7572 100644 --- a/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch +++ b/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/RegionLimitedWorldAccess.java +++ b/net/minecraft/server/level/RegionLimitedWorldAccess.java -@@ -273,6 +273,13 @@ +@@ -308,6 +308,13 @@ @Override public boolean addEntity(Entity entity) { @@ -11,6 +11,6 @@ + @Override + public boolean addEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + // CraftBukkit end - int i = MathHelper.floor(entity.locX() / 16.0D); - int j = MathHelper.floor(entity.locZ() / 16.0D); + int i = SectionPosition.a(entity.cW()); + int j = SectionPosition.a(entity.dc()); diff --git a/nms-patches/net/minecraft/server/level/WorldServer.patch b/nms-patches/net/minecraft/server/level/WorldServer.patch index 622bd5736..20ee793db 100644 --- a/nms-patches/net/minecraft/server/level/WorldServer.patch +++ b/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 -@@ -145,6 +145,21 @@ +@@ -152,6 +152,22 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -8,6 +8,7 @@ +import java.util.logging.Level; +import net.minecraft.world.entity.monster.EntityDrowned; +import net.minecraft.world.level.block.ITileEntity; ++import net.minecraft.world.level.block.entity.TileEntity; +import net.minecraft.world.level.storage.WorldDataServer; +import org.bukkit.Bukkit; +import org.bukkit.WeatherType; @@ -21,21 +22,22 @@ + public class WorldServer extends World implements GeneratorAccessSeed { - public static final BlockPosition a = new BlockPosition(100, 50, 0); -@@ -156,7 +171,7 @@ - private final ChunkProviderServer chunkProvider; - boolean tickingEntities; + public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0); +@@ -160,7 +176,7 @@ + final List players; + private final ChunkProviderServer chunkSource; private final MinecraftServer server; -- public final IWorldDataServer worldDataServer; -+ public final WorldDataServer worldDataServer; // CraftBukkit - type - public boolean savingDisabled; - private boolean everyoneSleeping; - private int emptyTime; -@@ -173,8 +188,23 @@ - private final StructureManager structureManager; - private final boolean Q; +- public final IWorldDataServer serverLevelData; ++ public final WorldDataServer serverLevelData; // CraftBukkit - type + final EntityTickList entityTickList; + private final PersistentEntitySectionManager entityManager; + public boolean noSave; +@@ -180,31 +196,52 @@ + private final StructureManager structureFeatureManager; + private final boolean tickTime; - public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey resourcekey, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List list, boolean flag1) { +- Objects.requireNonNull(minecraftserver); - super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i); + + // CraftBukkit start @@ -44,50 +46,67 @@ + public final UUID uuid; + + public Chunk getChunkIfLoaded(int x, int z) { -+ return this.chunkProvider.getChunkAt(x, z, false); ++ return this.chunkSource.getChunkAt(x, z, false); + } + + // Add env and gen to constructor, WorldData -> WorldDataServer + public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey resourcekey, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) { ++ // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error + super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i, gen, env); + this.pvpMode = minecraftserver.getPVP(); + convertable = convertable_conversionsession; -+ uuid = WorldUUID.getUUID(convertable_conversionsession.folder.toFile()); ++ uuid = WorldUUID.getUUID(convertable_conversionsession.levelPath.toFile()); + // CraftBukkit end - this.nextTickListBlock = new TickListServer<>(this, (block) -> { + this.players = Lists.newArrayList(); + this.entityTickList = new EntityTickList(); +- Predicate predicate = (block) -> { ++ Predicate predicate = (block) -> { // CraftBukkit - decompile eror return block == null || block.getBlockData().isAir(); - }, IRegistry.BLOCK::getKey, this::b); -@@ -186,10 +216,17 @@ - this.Q = flag1; + }; + 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 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.tickTime = flag1; this.server = minecraftserver; - this.mobSpawners = list; -- this.worldDataServer = iworlddataserver; + this.customSpawners = list; +- this.serverLevelData = iworlddataserver; + // CraftBukkit start -+ this.worldDataServer = (WorldDataServer) iworlddataserver; -+ worldDataServer.world = this; ++ this.serverLevelData = (WorldDataServer) iworlddataserver; ++ serverLevelData.world = this; + if (gen != null) { + chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen); + } -+ - this.chunkProvider = new ChunkProviderServer(this, convertable_conversionsession, minecraftserver.getDataFixer(), minecraftserver.getDefinedStructureManager(), executor, chunkgenerator, minecraftserver.getPlayerList().getViewDistance(), minecraftserver.isSyncChunkWrites(), worldloadlistener, () -> { - return minecraftserver.E().getWorldPersistentData(); - }); + // CraftBukkit end - this.portalTravelAgent = new PortalTravelAgent(this); - this.Q(); - this.R(); -@@ -201,14 +238,50 @@ + boolean flag2 = minecraftserver.isSyncChunkWrites(); + DataFixer datafixer = minecraftserver.getDataFixer(); + EntityPersistentStorage entitypersistentstorage = new EntityStorage(this, new File(convertable_conversionsession.a(resourcekey), "entities"), datafixer, flag2, minecraftserver); +@@ -231,15 +268,51 @@ iworlddataserver.setGameType(minecraftserver.getGamemode()); } -- this.structureManager = new StructureManager(this, minecraftserver.getSaveData().getGeneratorSettings()); -+ this.structureManager = new StructureManager(this, this.worldDataServer.getGeneratorSettings()); // CraftBukkit +- this.structureFeatureManager = new StructureManager(this, minecraftserver.getSaveData().getGeneratorSettings()); ++ this.structureFeatureManager = new StructureManager(this, this.serverLevelData.getGeneratorSettings()); // CraftBukkit if (this.getDimensionManager().isCreateDragonBattle()) { -- this.dragonBattle = new EnderDragonBattle(this, minecraftserver.getSaveData().getGeneratorSettings().getSeed(), minecraftserver.getSaveData().C()); -+ this.dragonBattle = new EnderDragonBattle(this, this.worldDataServer.getGeneratorSettings().getSeed(), this.worldDataServer.C()); // CraftBukkit +- 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 } else { - this.dragonBattle = null; + this.dragonFight = null; } + + this.sleepStatus = new SleepStatus(); + this.getServer().addWorld(this.getWorld()); // CraftBukkit + } + @@ -95,13 +114,13 @@ + @Override + public TileEntity getTileEntity(BlockPosition pos, boolean validate) { + TileEntity result = super.getTileEntity(pos, validate); -+ if (!validate || Thread.currentThread() != this.serverThread) { ++ if (!validate || Thread.currentThread() != this.thread) { + // SPIGOT-5378: avoid deadlock, this can be called in loading logic (i.e lighting) but getType() will block on chunk load + return result; + } -+ Block type = getType(pos).getBlock(); - -+ if (result != null && type != Blocks.AIR) { ++ IBlockData type = getType(pos); ++ ++ if (result != null && !type.a(Blocks.AIR)) { + if (!result.getTileType().isValidBlock(type)) { + result = fixTileEntity(pos, type, result); + } @@ -110,15 +129,14 @@ + return result; + } + -+ private TileEntity fixTileEntity(BlockPosition pos, Block type, TileEntity found) { ++ private TileEntity fixTileEntity(BlockPosition pos, IBlockData type, TileEntity found) { + this.getServer().getLogger().log(Level.SEVERE, "Block at {0}, {1}, {2} is {3} but has {4}" + ". " + + "Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.", new Object[]{pos.getX(), pos.getY(), pos.getZ(), type, found}); + + if (type instanceof ITileEntity) { -+ TileEntity replacement = ((ITileEntity) type).createTile(this); ++ TileEntity replacement = ((ITileEntity) type).createTile(pos, type); + if (replacement != null) { -+ replacement.setLocation(this, pos); -+ this.setTileEntity(pos, replacement); ++ this.setTileEntity(replacement); + } + return replacement; + } else { @@ -128,22 +146,22 @@ + // CraftBukkit end public void a(int i, int j, boolean flag, boolean flag1) { - this.worldDataServer.setClearWeatherTime(i); -@@ -299,6 +372,7 @@ + this.serverLevelData.setClearWeatherTime(i); +@@ -331,6 +404,7 @@ this.rainLevel = MathHelper.a(this.rainLevel, 0.0F, 1.0F); } + /* CraftBukkit start - if (this.lastRainLevel != this.rainLevel) { - this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, this.rainLevel)), this.getDimensionKey()); + if (this.oRainLevel != this.rainLevel) { + this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel)), this.getDimensionKey()); } -@@ -317,18 +391,47 @@ - this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, this.rainLevel)); - this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.i, this.thunderLevel)); +@@ -349,16 +423,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)); } + // */ + for (int idx = 0; idx < this.players.size(); ++idx) { -+ if (((EntityPlayer) this.players.get(idx)).world == this) { ++ if (((EntityPlayer) this.players.get(idx)).level == this) { + ((EntityPlayer) this.players.get(idx)).tickWeather(); + } + } @@ -151,28 +169,25 @@ + if (flag != this.isRaining()) { + // Only send weather packets to those affected + for (int idx = 0; idx < this.players.size(); ++idx) { -+ if (((EntityPlayer) this.players.get(idx)).world == this) { ++ if (((EntityPlayer) this.players.get(idx)).level == this) { + ((EntityPlayer) this.players.get(idx)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false); + } + } + } + for (int idx = 0; idx < this.players.size(); ++idx) { -+ if (((EntityPlayer) this.players.get(idx)).world == this) { -+ ((EntityPlayer) this.players.get(idx)).updateWeather(this.lastRainLevel, this.rainLevel, this.lastThunderLevel, this.thunderLevel); ++ if (((EntityPlayer) this.players.get(idx)).level == this) { ++ ((EntityPlayer) this.players.get(idx)).updateWeather(this.oRainLevel, this.rainLevel, this.oThunderLevel, this.thunderLevel); + } + } + // CraftBukkit end - if (this.everyoneSleeping && this.players.stream().noneMatch((entityplayer) -> { -- return !entityplayer.isSpectator() && !entityplayer.isDeeplySleeping(); -+ return !entityplayer.isSpectator() && !entityplayer.isDeeplySleeping() && !entityplayer.fauxSleeping; // CraftBukkit - })) { -- this.everyoneSleeping = false; + 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.worldData.getDayTime() + 24000L; ++ 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.DO_DAYLIGHT_CYCLE)) { -- long l = this.worldData.getDayTime() + 24000L; + if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { +- long l = this.levelData.getDayTime() + 24000L; + getServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { + this.setDayTime(this.getDayTime() + event.getSkipAmount()); @@ -183,49 +198,41 @@ - this.wakeupPlayers(); + if (!event.isCancelled()) { -+ this.everyoneSleeping = false; + this.wakeupPlayers(); + } + // CraftBukkit end - if (this.getGameRules().getBoolean(GameRules.DO_WEATHER_CYCLE)) { + if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE)) { this.clearWeather(); } -@@ -350,7 +453,7 @@ - this.ak(); - this.ticking = false; - gameprofilerfiller.exitEnter("entities"); +@@ -380,7 +483,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(); -@@ -369,6 +472,7 @@ - Entity entity = (Entity) entry.getValue(); - Entity entity1 = entity.getVehicle(); +@@ -396,7 +499,7 @@ -+ /* CraftBukkit start - We prevent spawning in general, so this butchering is not needed - if (!this.server.getSpawnAnimals() && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) { - entity.die(); - } -@@ -376,6 +480,7 @@ - if (!this.server.getSpawnNPCs() && entity instanceof NPC) { - entity.die(); - } -+ // CraftBukkit end */ - - gameprofilerfiller.enter("checkDespawn"); - if (!entity.dead) { -@@ -450,7 +555,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 +564,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); }); } -@@ -477,14 +582,14 @@ - entityhorseskeleton.t(true); +@@ -488,14 +591,14 @@ + entityhorseskeleton.v(true); entityhorseskeleton.setAgeRaw(0); entityhorseskeleton.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); - this.addEntity(entityhorseskeleton); @@ -241,80 +248,63 @@ } } -@@ -495,11 +600,11 @@ +@@ -506,12 +609,12 @@ BiomeBase biomebase = this.getBiome(blockposition); - if (biomebase.a(this, blockposition1)) { + 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 && biomebase.b(this, blockposition)) { -- this.setTypeUpdate(blockposition, Blocks.SNOW.getBlockData()); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.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 + } - if (flag && this.getBiome(blockposition1).c() == BiomeBase.Precipitation.RAIN) { -@@ -546,7 +651,7 @@ - protected BlockPosition a(BlockPosition blockposition) { - BlockPosition blockposition1 = this.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, blockposition); - AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition1, new BlockPosition(blockposition1.getX(), this.getBuildHeight(), blockposition1.getZ()))).g(3.0D); -- List list = this.a(EntityLiving.class, axisalignedbb, (entityliving) -> { -+ List list = this.a(EntityLiving.class, axisalignedbb, (java.util.function.Predicate) (entityliving) -> { // CraftBukkit - decompile error - return entityliving != null && entityliving.isAlive() && this.e(entityliving.getChunkCoordinates()); - }); - -@@ -575,7 +680,7 @@ - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); - -- if (entityplayer.isSpectator()) { -+ if (entityplayer.isSpectator() || (entityplayer.fauxSleeping && !entityplayer.isSleeping())) { // CraftBukkit - ++i; - } else if (entityplayer.isSleeping()) { - ++j; -@@ -593,10 +698,22 @@ + IBlockData iblockdata = this.getType(blockposition1); +@@ -642,10 +745,22 @@ } private void clearWeather() { -- this.worldDataServer.setWeatherDuration(0); +- this.serverLevelData.setWeatherDuration(0); + // CraftBukkit start - this.worldDataServer.setStorm(false); -- this.worldDataServer.setThunderDuration(0); + this.serverLevelData.setStorm(false); +- this.serverLevelData.setThunderDuration(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.worldDataServer.hasStorm()) { -+ this.worldDataServer.setWeatherDuration(0); ++ if (!this.serverLevelData.hasStorm()) { ++ this.serverLevelData.setWeatherDuration(0); + } + // CraftBukkit end - this.worldDataServer.setThundering(false); + this.serverLevelData.setThundering(false); + // CraftBukkit start + // 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.worldDataServer.isThundering()) { -+ this.worldDataServer.setThunderDuration(0); ++ if (!this.serverLevelData.isThundering()) { ++ this.serverLevelData.setThunderDuration(0); + } + // CraftBukkit end } public void resetEmptyTime() { -@@ -637,6 +754,7 @@ +@@ -680,6 +795,7 @@ + }); + gameprofilerfiller.c("tickNonPassenger"); + entity.tick(); ++ entity.postTick(); // CraftBukkit + this.getMethodProfiler().exit(); + Iterator iterator = entity.getPassengers().iterator(); + +@@ -703,6 +819,7 @@ }); - gameprofilerfiller.c("tickNonPassenger"); - entity.tick(); -+ entity.postTick(); // CraftBukkit + gameprofilerfiller.c("tickPassenger"); + entity1.passengerTick(); ++ entity1.postTick(); // CraftBukkit gameprofilerfiller.exit(); - } + Iterator iterator = entity1.getPassengers().iterator(); -@@ -669,6 +787,7 @@ - }); - gameprofilerfiller.c("tickPassenger"); - entity1.passengerTick(); -+ entity1.postTick(); // CraftBukkit - gameprofilerfiller.exit(); - } - -@@ -725,6 +844,7 @@ +@@ -727,6 +844,7 @@ ChunkProviderServer chunkproviderserver = this.getChunkProvider(); if (!flag1) { @@ -322,28 +312,28 @@ if (iprogressupdate != null) { iprogressupdate.a(new ChatMessage("menu.savingLevel")); } -@@ -736,11 +856,19 @@ +@@ -744,11 +862,19 @@ + } - chunkproviderserver.save(flag); } + + // CraftBukkit start - moved from MinecraftServer.saveChunks + WorldServer worldserver1 = this; + -+ worldDataServer.a(worldserver1.getWorldBorder().t()); -+ worldDataServer.setCustomBossEvents(this.server.getBossBattleCustomData().save()); -+ convertable.a(this.server.customRegistry, this.worldDataServer, this.server.getPlayerList().save()); ++ serverLevelData.a(worldserver1.getWorldBorder().t()); ++ serverLevelData.setCustomBossEvents(this.server.getBossBattleCustomData().save()); ++ convertable.a(this.server.registryHolder, this.serverLevelData, this.server.getPlayerList().save()); + // CraftBukkit end } - private void aj() { - if (this.dragonBattle != null) { -- this.server.getSaveData().a(this.dragonBattle.a()); -+ this.worldDataServer.a(this.dragonBattle.a()); // CraftBukkit + private void ap() { + if (this.dragonFight != null) { +- this.server.getSaveData().a(this.dragonFight.a()); ++ this.serverLevelData.a(this.dragonFight.a()); // CraftBukkit } this.getChunkProvider().getWorldPersistentData().a(); -@@ -801,11 +929,24 @@ +@@ -794,15 +920,34 @@ @Override public boolean addEntity(Entity entity) { @@ -370,47 +360,56 @@ } public void addEntityTeleport(Entity entity) { -@@ -855,13 +996,18 @@ - this.registerEntity(entityplayer); +- this.addEntity0(entity); ++ // CraftBukkit start ++ this.addEntity0(entity, CreatureSpawnEvent.SpawnReason.DEFAULT); ++ } ++ ++ public void addEntityTeleport(Entity entity, CreatureSpawnEvent.SpawnReason reason) { ++ this.addEntity0(entity, reason); ++ // CraftBukkit end + } + + public void addPlayerCommand(EntityPlayer entityplayer) { +@@ -830,27 +975,39 @@ + this.a((EntityPlayer) entity, Entity.RemovalReason.DISCARDED); + } + +- this.entityManager.a((EntityAccess) entityplayer); ++ this.entityManager.a(entityplayer); // CraftBukkit - decompile error } - private boolean addEntity0(Entity entity) { + // CraftBukkit start + private boolean addEntity0(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) { - if (entity.dead) { + 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 return false; - } else if (this.isUUIDTaken(entity)) { - return false; } else { +- return this.entityManager.a((EntityAccess) entity); + if (!CraftEventFactory.doEntityAddEventCalling(this, entity, spawnReason)) { + return false; + } + // CraftBukkit end - IChunkAccess ichunkaccess = this.getChunkAt(MathHelper.floor(entity.locX() / 16.0D), MathHelper.floor(entity.locZ() / 16.0D), ChunkStatus.FULL, entity.attachedToPlayer); - - if (!(ichunkaccess instanceof Chunk)) { -@@ -890,7 +1036,7 @@ - if (entity1 == null) { - return false; - } else { -- WorldServer.LOGGER.warn("Trying to add entity with duplicated UUID {}. Existing {}#{}, new: {}#{}", uuid, EntityTypes.getName(entity1.getEntityType()), entity1.getId(), EntityTypes.getName(entity.getEntityType()), entity.getId()); -+ // WorldServer.LOGGER.warn("Trying to add entity with duplicated UUID {}. Existing {}#{}, new: {}#{}", uuid, EntityTypes.getName(entity1.getEntityType()), entity1.getId(), EntityTypes.getName(entity.getEntityType()), entity.getId()); // CraftBukkit - return true; ++ ++ return this.entityManager.a(entity); // CraftBukkit - decompile error } } -@@ -919,10 +1065,16 @@ - } public boolean addAllEntitiesSafely(Entity entity) { +- Stream stream = entity.recursiveStream().map(Entity::getUniqueID); + // CraftBukkit start + return this.addAllEntitiesSafely(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } + + public boolean addAllEntitiesSafely(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + // CraftBukkit end - if (entity.recursiveStream().anyMatch(this::isUUIDTaken)) { ++ Stream stream = entity.recursiveStream().map(Entity::getUniqueID); // CraftBukkit - decompile error + PersistentEntitySectionManager persistententitysectionmanager = this.entityManager; + + Objects.requireNonNull(this.entityManager); + if (stream.anyMatch(persistententitysectionmanager::a)) { return false; } else { - this.addAllEntities(entity); @@ -418,52 +417,8 @@ return true; } } -@@ -973,10 +1125,17 @@ - } - - this.getScoreboard().a(entity); -+ // CraftBukkit start - SPIGOT-5278 -+ if (entity instanceof EntityDrowned) { -+ this.navigators.remove(((EntityDrowned) entity).navigationWater); -+ this.navigators.remove(((EntityDrowned) entity).navigationLand); -+ } else -+ // CraftBukkit end - if (entity instanceof EntityInsentient) { - this.navigators.remove(((EntityInsentient) entity).getNavigation()); - } - -+ entity.valid = false; // CraftBukkit - } - - private void registerEntity(Entity entity) { -@@ -997,9 +1156,16 @@ - - this.entitiesByUUID.put(entity.getUniqueID(), entity); - this.getChunkProvider().addEntity(entity); -+ // CraftBukkit start - SPIGOT-5278 -+ if (entity instanceof EntityDrowned) { -+ this.navigators.add(((EntityDrowned) entity).navigationWater); -+ this.navigators.add(((EntityDrowned) entity).navigationLand); -+ } else -+ // CraftBukkit end - if (entity instanceof EntityInsentient) { - this.navigators.add(((EntityInsentient) entity).getNavigation()); - } -+ entity.valid = true; // CraftBukkit - } - - } -@@ -1015,7 +1181,7 @@ - } - - private void removeEntityFromChunk(Entity entity) { -- IChunkAccess ichunkaccess = this.getChunkAt(entity.chunkX, entity.chunkZ, ChunkStatus.FULL, false); -+ IChunkAccess ichunkaccess = chunkProvider.getChunkUnchecked(entity.chunkX, entity.chunkZ); // CraftBukkit - SPIGOT-5228: getChunkAt won't find the entity's chunk if it has already been unloaded (i.e. if it switched to state INACCESSIBLE). - - if (ichunkaccess instanceof Chunk) { - ((Chunk) ichunkaccess).b(entity); -@@ -1029,10 +1195,32 @@ - this.everyoneSleeping(); +@@ -863,10 +1020,32 @@ + entityplayer.a(entity_removalreason); } + // CraftBukkit start @@ -495,7 +450,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -1041,6 +1229,12 @@ +@@ -875,6 +1054,12 @@ double d1 = (double) blockposition.getY() - entityplayer.locY(); double d2 = (double) blockposition.getZ() - entityplayer.locZ(); @@ -506,17 +461,17 @@ + // CraftBukkit end + if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); + entityplayer.connection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); } -@@ -1079,7 +1273,18 @@ - Iterator iterator = this.navigators.iterator(); +@@ -923,7 +1108,18 @@ + Iterator iterator = this.navigatingMobs.iterator(); while (iterator.hasNext()) { -- NavigationAbstract navigationabstract = (NavigationAbstract) iterator.next(); +- EntityInsentient entityinsentient = (EntityInsentient) iterator.next(); + // CraftBukkit start - fix SPIGOT-6362 -+ NavigationAbstract navigationabstract; ++ EntityInsentient entityinsentient; + try { -+ navigationabstract = (NavigationAbstract) iterator.next(); ++ entityinsentient = (EntityInsentient) iterator.next(); + } catch (java.util.ConcurrentModificationException ex) { + // This can happen because the pathfinder update below may trigger a chunk load, which in turn may cause more navigators to register + // In this case we just run the update again across all the iterators as the chunk will then be loaded @@ -525,10 +480,10 @@ + return; + } + // CraftBukkit end + NavigationAbstract navigationabstract = entityinsentient.getNavigation(); if (!navigationabstract.i()) { - navigationabstract.b(blockposition); -@@ -1101,10 +1306,20 @@ +@@ -946,10 +1142,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) { @@ -549,7 +504,7 @@ if (explosion_effect == Explosion.Effect.NONE) { explosion.clearBlocks(); } -@@ -1169,13 +1384,20 @@ +@@ -1023,13 +1229,20 @@ } public int a(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { @@ -572,85 +527,39 @@ ++j; } } -@@ -1217,7 +1439,7 @@ +@@ -1079,7 +1292,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.worldDataServer.getGeneratorSettings().shouldGenerateMapFeatures() ? null : this.getChunkProvider().getChunkGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag); // CraftBukkit ++ return !this.serverLevelData.getGeneratorSettings().shouldGenerateMapFeatures() ? null : this.getChunkProvider().getChunkGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag); // CraftBukkit } @Nullable -@@ -1255,7 +1477,13 @@ +@@ -1116,11 +1329,21 @@ + @Nullable @Override public WorldMap a(String s) { - return (WorldMap) this.getMinecraftServer().E().getWorldPersistentData().b(() -> { -- return new WorldMap(s); +- return (WorldMap) this.getMinecraftServer().F().getWorldPersistentData().a(WorldMap::b, s); ++ return (WorldMap) this.getMinecraftServer().F().getWorldPersistentData().a((nbttagcompound) -> { + // CraftBukkit start + // We only get here when the data file exists, but is not a valid map -+ WorldMap newMap = new WorldMap(s); ++ WorldMap newMap = WorldMap.b(nbttagcompound); ++ newMap.id = s; + MapInitializeEvent event = new MapInitializeEvent(newMap.mapView); + Bukkit.getServer().getPluginManager().callEvent(event); + return newMap; + // CraftBukkit end - }, s); ++ }, s); } -@@ -1386,9 +1614,9 @@ - reputationhandler.a(reputationevent, entity); + @Override + public void a(String s, WorldMap worldmap) { ++ worldmap.id = s; // CraftBukkit + this.getMinecraftServer().F().getWorldPersistentData().a(s, (PersistentBase) worldmap); } -- public void a(Path path) throws IOException { -+ public void a(java.nio.file.Path java_nio_file_path) throws IOException { - PlayerChunkMap playerchunkmap = this.getChunkProvider().playerChunkMap; -- BufferedWriter bufferedwriter = Files.newBufferedWriter(path.resolve("stats.txt")); -+ BufferedWriter bufferedwriter = Files.newBufferedWriter(java_nio_file_path.resolve("stats.txt")); - Throwable throwable = null; - - try { -@@ -1432,7 +1660,7 @@ - CrashReport crashreport = new CrashReport("Level dump", new Exception("dummy")); - - this.a(crashreport); -- BufferedWriter bufferedwriter1 = Files.newBufferedWriter(path.resolve("example_crash.txt")); -+ BufferedWriter bufferedwriter1 = Files.newBufferedWriter(java_nio_file_path.resolve("example_crash.txt")); - Throwable throwable3 = null; - - try { -@@ -1455,8 +1683,8 @@ - - } - -- Path path1 = path.resolve("chunks.csv"); -- BufferedWriter bufferedwriter2 = Files.newBufferedWriter(path1); -+ java.nio.file.Path java_nio_file_path1 = java_nio_file_path.resolve("chunks.csv"); -+ BufferedWriter bufferedwriter2 = Files.newBufferedWriter(java_nio_file_path1); - Throwable throwable6 = null; - - try { -@@ -1479,8 +1707,8 @@ - - } - -- Path path2 = path.resolve("entities.csv"); -- BufferedWriter bufferedwriter3 = Files.newBufferedWriter(path2); -+ java.nio.file.Path java_nio_file_path2 = java_nio_file_path.resolve("entities.csv"); -+ BufferedWriter bufferedwriter3 = Files.newBufferedWriter(java_nio_file_path2); - Throwable throwable9 = null; - - try { -@@ -1503,8 +1731,8 @@ - - } - -- Path path3 = path.resolve("block_entities.csv"); -- BufferedWriter bufferedwriter4 = Files.newBufferedWriter(path3); -+ java.nio.file.Path java_nio_file_path3 = java_nio_file_path.resolve("block_entities.csv"); -+ BufferedWriter bufferedwriter4 = Files.newBufferedWriter(java_nio_file_path3); - Throwable throwable12 = null; - - try { -@@ -1566,6 +1794,11 @@ +@@ -1432,6 +1655,11 @@ @Override public void update(BlockPosition blockposition, Block block) { if (!this.isDebugWorld()) { @@ -662,53 +571,40 @@ this.applyPhysics(blockposition, block); } -@@ -1580,12 +1813,12 @@ +@@ -1451,12 +1679,12 @@ } public boolean isFlatWorld() { - return this.server.getSaveData().getGeneratorSettings().isFlatWorld(); -+ return this.worldDataServer.getGeneratorSettings().isFlatWorld(); // CraftBukkit ++ return this.serverLevelData.getGeneratorSettings().isFlatWorld(); // CraftBukkit } @Override public long getSeed() { - return this.server.getSaveData().getGeneratorSettings().getSeed(); -+ return this.worldDataServer.getGeneratorSettings().getSeed(); // CraftBukkit ++ return this.serverLevelData.getGeneratorSettings().getSeed(); // CraftBukkit } @Nullable -@@ -1605,9 +1838,9 @@ - - @VisibleForTesting - public String F() { -- return String.format("players: %s, entities: %d [%s], block_entities: %d [%s], block_ticks: %d, fluid_ticks: %d, chunk_source: %s", this.players.size(), this.entitiesById.size(), a((Collection) this.entitiesById.values(), (entity) -> { -+ return String.format("players: %s, entities: %d [%s], block_entities: %d [%s], block_ticks: %d, fluid_ticks: %d, chunk_source: %s", this.players.size(), this.entitiesById.size(), a(this.entitiesById.values(), (entity) -> { // CraftBukkit - decompile error - return IRegistry.ENTITY_TYPE.getKey(entity.getEntityType()); -- }), this.tileEntityListTick.size(), a((Collection) this.tileEntityListTick, (tileentity) -> { -+ }), this.tileEntityListTick.size(), a(this.tileEntityListTick, (tileentity) -> { // CraftBukkit - decompile error - return IRegistry.BLOCK_ENTITY_TYPE.getKey(tileentity.getTileType()); - }), this.getBlockTickList().a(), this.getFluidTickList().a(), this.P()); - } -@@ -1615,7 +1848,7 @@ - private static String a(Collection collection, Function function) { +@@ -1484,7 +1712,7 @@ + private static String a(Iterable iterable, Function function) { try { - Object2IntOpenHashMap object2intopenhashmap = new Object2IntOpenHashMap(); -- Iterator iterator = collection.iterator(); -+ Iterator iterator = collection.iterator(); // CraftBukkit - decompile error + Object2IntOpenHashMap object2intopenhashmap = new Object2IntOpenHashMap(); +- Iterator iterator = iterable.iterator(); ++ Iterator iterator = iterable.iterator(); // CraftBukkit - decompile error while (iterator.hasNext()) { T t0 = iterator.next(); -@@ -1624,7 +1857,8 @@ - object2intopenhashmap.addTo(minecraftkey, 1); +@@ -1493,7 +1721,7 @@ + object2intopenhashmap.addTo(s, 1); } -- return (String) object2intopenhashmap.object2IntEntrySet().stream().sorted(Comparator.comparing(it.unimi.dsi.fastutil.objects.Object2IntMap.Entry::getIntValue).reversed()).limit(5L).map((it_unimi_dsi_fastutil_objects_object2intmap_entry) -> { -+ // CraftBukkit - decompile error -+ return (String) object2intopenhashmap.object2IntEntrySet().stream().sorted(Comparator.comparing(it.unimi.dsi.fastutil.objects.Object2IntMap.Entry::getIntValue).reversed()).limit(5L).map((it_unimi_dsi_fastutil_objects_object2intmap_entry) -> { - return it_unimi_dsi_fastutil_objects_object2intmap_entry.getKey() + ":" + it_unimi_dsi_fastutil_objects_object2intmap_entry.getIntValue(); - }).collect(Collectors.joining(",")); - } catch (Exception exception) { -@@ -1633,16 +1867,32 @@ +- return (String) object2intopenhashmap.object2IntEntrySet().stream().sorted(Comparator.comparing(Entry::getIntValue).reversed()).limit(5L).map((entry) -> { ++ return (String) object2intopenhashmap.object2IntEntrySet().stream().sorted(Comparator.comparing(Entry::getIntValue).reversed()).limit(5L).map((entry) -> { // CraftBukkit - decompile error + String s1 = (String) entry.getKey(); + + return s1 + ":" + entry.getIntValue(); +@@ -1504,17 +1732,33 @@ } public static void a(WorldServer worldserver) { @@ -718,7 +614,7 @@ + + public static void a(WorldServer worldserver, Entity entity) { + // CraftBukkit end - BlockPosition blockposition = WorldServer.a; + BlockPosition blockposition = WorldServer.END_SPAWN_POINT; int i = blockposition.getX(); int j = blockposition.getY() - 2; int k = blockposition.getZ(); @@ -742,4 +638,21 @@ + } + // CraftBukkit end } + + @Override +@@ -1601,6 +1845,7 @@ + } + } + ++ entity.valid = true; // CraftBukkit + } + + public void a(Entity entity) { +@@ -1633,6 +1878,7 @@ + gameeventlistenerregistrar.a(entity.level); + } + ++ entity.valid = false; // CraftBukkit + } + } } diff --git a/nms-patches/net/minecraft/server/network/HandshakeListener.patch b/nms-patches/net/minecraft/server/network/HandshakeListener.patch index 4aa5a4bf7..2deb382cc 100644 --- a/nms-patches/net/minecraft/server/network/HandshakeListener.patch +++ b/nms-patches/net/minecraft/server/network/HandshakeListener.patch @@ -15,25 +15,25 @@ + private static final HashMap throttleTracker = new HashMap(); + private static int throttleCounter = 0; + // CraftBukkit end - private static final IChatBaseComponent a = new ChatComponentText("Ignoring status request"); - private final MinecraftServer b; - private final NetworkManager c; + private static final IChatBaseComponent IGNORE_STATUS_REASON = new ChatComponentText("Ignoring status request"); + private final MinecraftServer server; + private final NetworkManager connection; @@ -27,6 +36,40 @@ switch (packethandshakinginsetprotocol.b()) { case LOGIN: - this.c.setProtocol(EnumProtocol.LOGIN); + this.connection.setProtocol(EnumProtocol.LOGIN); + // CraftBukkit start - Connection throttle + try { + long currentTime = System.currentTimeMillis(); -+ long connectionThrottle = this.b.server.getConnectionThrottle(); -+ InetAddress address = ((java.net.InetSocketAddress) this.c.getSocketAddress()).getAddress(); ++ long connectionThrottle = this.server.server.getConnectionThrottle(); ++ InetAddress address = ((java.net.InetSocketAddress) this.connection.getSocketAddress()).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.c.sendPacket(new PacketLoginOutDisconnect(chatmessage)); -+ this.c.close(chatmessage); ++ this.connection.sendPacket(new PacketLoginOutDisconnect(chatmessage)); ++ this.connection.close(chatmessage); + return; + } + @@ -60,10 +60,10 @@ ChatMessage chatmessage; @@ -40,6 +83,7 @@ - this.c.close(chatmessage); + this.connection.close(chatmessage); } else { - this.c.setPacketListener(new LoginListener(this.b, this.c)); -+ ((LoginListener) this.c.j()).hostname = packethandshakinginsetprotocol.hostname + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname + this.connection.setPacketListener(new LoginListener(this.server, this.connection)); ++ ((LoginListener) this.connection.j()).hostname = packethandshakinginsetprotocol.hostName + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname } break; case STATUS: diff --git a/nms-patches/net/minecraft/server/network/LegacyPingHandler.patch b/nms-patches/net/minecraft/server/network/LegacyPingHandler.patch index e611d0c98..efcac2c2d 100644 --- a/nms-patches/net/minecraft/server/network/LegacyPingHandler.patch +++ b/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 -@@ -35,11 +35,12 @@ - MinecraftServer minecraftserver = this.b.d(); +@@ -36,11 +36,12 @@ + MinecraftServer minecraftserver = this.serverConnectionListener.d(); 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 @@ -14,7 +14,7 @@ this.a(channelhandlercontext, this.a(s)); break; case 1: -@@ -48,7 +49,7 @@ +@@ -49,7 +50,7 @@ } LegacyPingHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort()); @@ -23,7 +23,7 @@ this.a(channelhandlercontext, this.a(s)); break; default: -@@ -67,7 +68,7 @@ +@@ -68,7 +69,7 @@ } LegacyPingHandler.LOGGER.debug("Ping: (1.6) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort()); diff --git a/nms-patches/net/minecraft/server/network/LoginListener.patch b/nms-patches/net/minecraft/server/network/LoginListener.patch index ee14ed5ea..dd690f47a 100644 --- a/nms-patches/net/minecraft/server/network/LoginListener.patch +++ b/nms-patches/net/minecraft/server/network/LoginListener.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/LoginListener.java +++ b/net/minecraft/server/network/LoginListener.java -@@ -35,6 +35,13 @@ +@@ -36,6 +36,13 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -13,16 +13,16 @@ + public class LoginListener implements PacketLoginInListener { - private static final AtomicInteger b = new AtomicInteger(0); -@@ -49,6 +56,7 @@ - private final String j; - private SecretKey loginKey; - private EntityPlayer l; + private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0); +@@ -52,6 +59,7 @@ + private final String serverId; + @Nullable + private EntityPlayer delayedAcceptPlayer; + public String hostname = ""; // CraftBukkit - add field public LoginListener(MinecraftServer minecraftserver, NetworkManager networkmanager) { - this.g = LoginListener.EnumProtocolState.HELLO; -@@ -77,6 +85,20 @@ + this.state = LoginListener.EnumProtocolState.HELLO; +@@ -80,6 +88,20 @@ } @@ -32,8 +32,8 @@ + try { + IChatBaseComponent ichatbasecomponent = new ChatComponentText(s); + LoginListener.LOGGER.info("Disconnecting {}: {}", this.d(), s); -+ this.networkManager.sendPacket(new PacketLoginOutDisconnect(ichatbasecomponent)); -+ this.networkManager.close(ichatbasecomponent); ++ this.connection.sendPacket(new PacketLoginOutDisconnect(ichatbasecomponent)); ++ this.connection.close(ichatbasecomponent); + } catch (Exception exception) { + LoginListener.LOGGER.error("Error whilst disconnecting player", exception); + } @@ -42,14 +42,14 @@ + @Override public NetworkManager a() { - return this.networkManager; -@@ -98,10 +120,12 @@ - this.i = this.a(this.i); + return this.connection; +@@ -101,10 +123,12 @@ + this.gameProfile = this.a(this.gameProfile); } -- IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().attemptLogin(this.networkManager.getSocketAddress(), this.i); +- IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().attemptLogin(this.connection.getSocketAddress(), this.gameProfile); + // CraftBukkit start - fire PlayerLoginEvent -+ EntityPlayer s = this.server.getPlayerList().attemptLogin(this, this.i, hostname); ++ EntityPlayer s = this.server.getPlayerList().attemptLogin(this, this.gameProfile, hostname); - if (ichatbasecomponent != null) { - this.disconnect(ichatbasecomponent); @@ -57,32 +57,29 @@ + // this.disconnect(ichatbasecomponent); + // CraftBukkit end } else { - this.g = LoginListener.EnumProtocolState.ACCEPTED; - if (this.server.ax() >= 0 && !this.networkManager.isLocal()) { -@@ -115,9 +139,9 @@ + this.state = LoginListener.EnumProtocolState.ACCEPTED; + if (this.server.aw() >= 0 && !this.connection.isLocal()) { +@@ -117,7 +141,7 @@ + EntityPlayer entityplayer = this.server.getPlayerList().getPlayer(this.gameProfile.getId()); - if (entityplayer != null) { - this.g = LoginListener.EnumProtocolState.DELAY_ACCEPT; -- this.l = this.server.getPlayerList().processLogin(this.i); -+ this.l = this.server.getPlayerList().processLogin(this.i, s); // CraftBukkit - add player reference - } else { -- this.server.getPlayerList().a(this.networkManager, this.server.getPlayerList().processLogin(this.i)); -+ this.server.getPlayerList().a(this.networkManager, this.server.getPlayerList().processLogin(this.i, s)); // CraftBukkit - add player reference - } - } + try { +- EntityPlayer entityplayer1 = this.server.getPlayerList().processLogin(this.gameProfile); ++ EntityPlayer entityplayer1 = this.server.getPlayerList().processLogin(this.gameProfile, s); // CraftBukkit - add player reference -@@ -175,6 +199,43 @@ + if (entityplayer != null) { + this.state = LoginListener.EnumProtocolState.DELAY_ACCEPT; +@@ -191,6 +215,43 @@ try { - LoginListener.this.i = LoginListener.this.server.getMinecraftSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.a()); - if (LoginListener.this.i != null) { + LoginListener.this.gameProfile = LoginListener.this.server.getMinecraftSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.a()); + if (LoginListener.this.gameProfile != null) { + // CraftBukkit start - fire PlayerPreLoginEvent -+ if (!networkManager.isConnected()) { ++ if (!connection.isConnected()) { + return; + } + -+ String playerName = i.getName(); -+ java.net.InetAddress address = ((java.net.InetSocketAddress) networkManager.getSocketAddress()).getAddress(); -+ java.util.UUID uniqueId = i.getId(); ++ String playerName = gameProfile.getName(); ++ java.net.InetAddress address = ((java.net.InetSocketAddress) connection.getSocketAddress()).getAddress(); ++ java.util.UUID uniqueId = gameProfile.getId(); + final org.bukkit.craftbukkit.CraftServer server = LoginListener.this.server.server; + + AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId); @@ -112,10 +109,10 @@ + } + } + // CraftBukkit end - LoginListener.LOGGER.info("UUID of player {} is {}", LoginListener.this.i.getName(), LoginListener.this.i.getId()); - LoginListener.this.g = LoginListener.EnumProtocolState.READY_TO_ACCEPT; + 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()) { -@@ -194,6 +255,11 @@ +@@ -210,6 +271,11 @@ LoginListener.this.disconnect(new ChatMessage("multiplayer.disconnect.authservers_down")); LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable"); } diff --git a/nms-patches/net/minecraft/server/network/PacketStatusListener.patch b/nms-patches/net/minecraft/server/network/PacketStatusListener.patch index eee161284..d33e9e278 100644 --- a/nms-patches/net/minecraft/server/network/PacketStatusListener.patch +++ b/nms-patches/net/minecraft/server/network/PacketStatusListener.patch @@ -18,21 +18,21 @@ + public class PacketStatusListener implements PacketStatusInListener { - private static final IChatBaseComponent a = new ChatMessage("multiplayer.status.request_handled"); + private static final IChatBaseComponent DISCONNECT_REASON = new ChatMessage("multiplayer.status.request_handled"); @@ -36,8 +48,96 @@ - this.networkManager.close(PacketStatusListener.a); + this.connection.close(PacketStatusListener.DISCONNECT_REASON); } else { - this.d = true; -- this.networkManager.sendPacket(new PacketStatusOutServerInfo(this.minecraftServer.getServerPing())); + this.hasRequestedStatus = true; +- this.connection.sendPacket(new PacketStatusOutServerInfo(this.server.getServerPing())); + // CraftBukkit start + // this.networkManager.sendPacket(new PacketStatusOutServerInfo(this.minecraftServer.getServerPing())); -+ final Object[] players = minecraftServer.getPlayerList().players.toArray(); ++ final Object[] players = server.getPlayerList().players.toArray(); + class ServerListPingEvent extends org.bukkit.event.server.ServerListPingEvent { + -+ CraftIconCache icon = minecraftServer.server.getServerIcon(); ++ CraftIconCache icon = server.server.getServerIcon(); + + ServerListPingEvent() { -+ super(((InetSocketAddress) networkManager.getSocketAddress()).getAddress(), minecraftServer.getMotd(), minecraftServer.getPlayerList().getMaxPlayers()); ++ super(((InetSocketAddress) connection.getSocketAddress()).getAddress(), server.getMotd(), server.getPlayerList().getMaxPlayers()); + } + + @Override @@ -92,7 +92,7 @@ + } + + ServerListPingEvent event = new ServerListPingEvent(); -+ this.minecraftServer.server.getPluginManager().callEvent(event); ++ this.server.server.getPluginManager().callEvent(event); + + java.util.List profiles = new java.util.ArrayList(players.length); + for (Object player : players) { @@ -109,9 +109,9 @@ + ping.setMOTD(CraftChatMessage.fromString(event.getMotd(), true)[0]); + ping.setPlayerSample(playerSample); + int version = SharedConstants.getGameVersion().getProtocolVersion(); -+ ping.setServerInfo(new ServerPing.ServerData(minecraftServer.getServerModName() + " " + minecraftServer.getVersion(), version)); ++ ping.setServerInfo(new ServerPing.ServerData(server.getServerModName() + " " + server.getVersion(), version)); + -+ this.networkManager.sendPacket(new PacketStatusOutServerInfo(ping)); ++ this.connection.sendPacket(new PacketStatusOutServerInfo(ping)); } + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/server/network/PlayerConnection.patch b/nms-patches/net/minecraft/server/network/PlayerConnection.patch index 6b299ff7b..8df42d3b3 100644 --- a/nms-patches/net/minecraft/server/network/PlayerConnection.patch +++ b/nms-patches/net/minecraft/server/network/PlayerConnection.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/server/network/PlayerConnection.java +++ b/net/minecraft/server/network/PlayerConnection.java -@@ -158,6 +158,61 @@ +@@ -158,6 +158,62 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start +import java.util.concurrent.ExecutionException; -+import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; ++import java.util.concurrent.atomic.AtomicInteger; +import net.minecraft.network.protocol.game.PacketPlayOutAttachEntity; +import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; +import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving; @@ -15,6 +15,7 @@ +import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.entity.animal.EntityFish; +import net.minecraft.world.inventory.InventoryClickType; ++import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.crafting.IRecipe; +import net.minecraft.world.level.RayTrace; +import net.minecraft.world.phys.MovingObjectPosition; @@ -59,30 +60,30 @@ +import org.bukkit.util.NumberConversions; +// CraftBukkit end + - public class PlayerConnection implements PacketListenerPlayIn { + public class PlayerConnection implements ServerPlayerConnection, PacketListenerPlayIn { - private static final Logger LOGGER = LogManager.getLogger(); -@@ -168,7 +223,10 @@ - private long lastKeepAlive; - private boolean awaitingKeepAlive; - private long h; -- private int chatThrottle; + static final Logger LOGGER = LogManager.getLogger(); +@@ -169,7 +225,9 @@ + private long keepAliveTime; + private boolean keepAlivePending; + private long keepAliveChallenge; +- private int chatSpamTickCount; + // CraftBukkit start - multithreaded fields -+ private volatile int chatThrottle; -+ private static final AtomicIntegerFieldUpdater chatSpamField = AtomicIntegerFieldUpdater.newUpdater(PlayerConnection.class, "chatThrottle"); ++ private AtomicInteger chatSpamTickCount = new AtomicInteger(); + // CraftBukkit end - private int j; - private final Int2ShortMap k = new Int2ShortOpenHashMap(); - private double l; -@@ -206,8 +264,33 @@ - itextfilter.a(); - } - + private int dropSpamTickCount; + private double firstGoodX; + private double firstGoodY; +@@ -203,7 +261,33 @@ + this.player = entityplayer; + entityplayer.connection = this; + entityplayer.Q().a(); ++ + // CraftBukkit start - add fields and methods -+ this.server = minecraftserver.server; - } - -+ private final org.bukkit.craftbukkit.CraftServer server; ++ this.cserver = minecraftserver.server; ++ } ++ ++ private final org.bukkit.craftbukkit.CraftServer cserver; + public boolean processedDisconnect; + private int lastTick = MinecraftServer.currentTick; + private int allowedPlayerTicks = 1; @@ -102,45 +103,44 @@ + + public CraftPlayer getPlayer() { + return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity(); -+ } + } + // CraftBukkit end -+ + public void tick() { this.syncPosition(); - this.player.lastX = this.player.locX(); -@@ -255,7 +338,7 @@ - this.minecraftServer.getMethodProfiler().enter("keepAlive"); +@@ -252,7 +336,7 @@ + this.server.getMethodProfiler().enter("keepAlive"); long i = SystemUtils.getMonotonicMillis(); -- if (i - this.lastKeepAlive >= 15000L) { -+ if (i - this.lastKeepAlive >= 25000L) { // CraftBukkit - if (this.awaitingKeepAlive) { +- if (i - this.keepAliveTime >= 15000L) { ++ if (i - this.keepAliveTime >= 25000L) { // CraftBukkit + if (this.keepAlivePending) { this.disconnect(new ChatMessage("disconnect.timeout")); } else { -@@ -267,15 +350,21 @@ +@@ -264,15 +348,21 @@ } - this.minecraftServer.getMethodProfiler().exit(); + this.server.getMethodProfiler().exit(); + // CraftBukkit start -+ for (int spam; (spam = this.chatThrottle) > 0 && !chatSpamField.compareAndSet(this, spam, spam - 1); ) ; ++ for (int spam; (spam = this.chatSpamTickCount.get()) > 0 && !chatSpamTickCount.compareAndSet(spam, spam - 1); ) ; + /* Use thread-safe field access instead - if (this.chatThrottle > 0) { - --this.chatThrottle; + if (this.chatSpamTickCount > 0) { + --this.chatSpamTickCount; } + */ + // CraftBukkit end - if (this.j > 0) { - --this.j; + if (this.dropSpamTickCount > 0) { + --this.dropSpamTickCount; } - if (this.player.F() > 0L && this.minecraftServer.getIdleTimeout() > 0 && SystemUtils.getMonotonicMillis() - this.player.F() > (long) (this.minecraftServer.getIdleTimeout() * 1000 * 60)) { + 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 this.disconnect(new ChatMessage("multiplayer.disconnect.idling")); } -@@ -299,16 +388,46 @@ - return this.minecraftServer.a(this.player.getProfile()); +@@ -296,16 +386,46 @@ + return this.server.a(this.player.getProfile()); } + // CraftBukkit start @@ -157,10 +157,10 @@ + } + String leaveMessage = EnumChatFormat.YELLOW + this.player.getName() + " left the game."; + -+ PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), s, leaveMessage); ++ PlayerKickEvent event = new PlayerKickEvent(this.cserver.getPlayer(this.player), s, leaveMessage); + -+ if (this.server.getServer().isRunning()) { -+ this.server.getPluginManager().callEvent(event); ++ if (this.cserver.getServer().isRunning()) { ++ this.cserver.getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -172,31 +172,36 @@ + final IChatBaseComponent ichatbasecomponent = CraftChatMessage.fromString(s, true)[0]; + // CraftBukkit end + - this.networkManager.sendPacket(new PacketPlayOutKickDisconnect(ichatbasecomponent), (future) -> { - this.networkManager.close(ichatbasecomponent); + this.connection.sendPacket(new PacketPlayOutKickDisconnect(ichatbasecomponent), (future) -> { + this.connection.close(ichatbasecomponent); }); + this.a(ichatbasecomponent); // CraftBukkit - fire quit instantly - this.networkManager.stopReading(); - MinecraftServer minecraftserver = this.minecraftServer; - NetworkManager networkmanager = this.networkManager; + this.connection.stopReading(); + MinecraftServer minecraftserver = this.server; + NetworkManager networkmanager = this.connection; - this.networkManager.getClass(); + Objects.requireNonNull(this.connection); - minecraftserver.executeSync(networkmanager::handleDisconnection); + // CraftBukkit - Don't wait + minecraftserver.postToMainThread(networkmanager::handleDisconnection); } - private void a(T t0, Consumer consumer, BiFunction>> bifunction) { -@@ -324,7 +443,7 @@ - ITextFilter itextfilter = this.player.Q(); + private void a(T t0, Consumer consumer, BiFunction> bifunction) { +@@ -323,11 +443,11 @@ + } - if (itextfilter != null) { -- ((CompletableFuture) bifunction.apply(itextfilter, t0)).thenAcceptAsync((optional) -> { -+ (bifunction.apply(itextfilter, t0)).thenAcceptAsync((optional) -> { // CraftBukkit - decompile error - optional.ifPresent(consumer1); - }, iasynctaskhandler); - } else { -@@ -381,7 +500,34 @@ + private void a(String s, Consumer consumer) { +- this.a((Object) s, consumer, ITextFilter::a); ++ this.a(s, consumer, ITextFilter::a); // CraftBukkit - decompile error + } + + private void a(List list, Consumer> consumer) { +- this.a((Object) list, consumer, ITextFilter::a); ++ this.a(list, consumer, ITextFilter::a); // CraftBukkit - decompile error + } + + @Override +@@ -372,7 +492,34 @@ double d9 = entity.getMot().g(); double d10 = d6 * d6 + d7 * d7 + d8 * d8; @@ -207,8 +212,8 @@ + this.allowedPlayerTicks = Math.max(this.allowedPlayerTicks, 1); + this.lastTick = (int) (System.currentTimeMillis() / 50); + -+ ++this.receivedMovePackets; -+ int i = this.receivedMovePackets - this.processedMovePackets; ++ ++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)"); + i = 1; @@ -220,29 +225,29 @@ + allowedPlayerTicks = 20; + } + double speed; -+ if (player.abilities.isFlying) { -+ speed = player.abilities.flySpeed * 20f; ++ if (player.getAbilities().flying) { ++ speed = player.getAbilities().flyingSpeed * 20f; + } else { -+ speed = player.abilities.walkSpeed * 10f; ++ speed = player.getAbilities().walkingSpeed * 10f; + } + 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()) { + // CraftBukkit end PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getDisplayName().getString(), this.player.getDisplayName().getString(), d6, d7, d8); - this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity)); + this.connection.sendPacket(new PacketPlayOutVehicleMove(entity)); return; -@@ -411,14 +557,72 @@ +@@ -402,14 +549,72 @@ } entity.setLocation(d3, d4, d5, f, f1); -+ player.setLocation(d3, d4, d5, this.player.yaw, this.player.pitch); // CraftBukkit ++ player.setLocation(d3, d4, d5, this.player.getYRot(), this.player.getXRot()); // CraftBukkit boolean flag2 = worldserver.getCubes(entity, entity.getBoundingBox().shrink(0.0625D)); if (flag && (flag1 || !flag2)) { entity.setLocation(d0, d1, d2, f, f1); -+ player.setLocation(d0, d1, d2, this.player.yaw, this.player.pitch); // CraftBukkit - this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity)); ++ player.setLocation(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit + this.connection.sendPacket(new PacketPlayOutVehicleMove(entity)); return; } @@ -276,7 +281,7 @@ + if (from.getX() != Double.MAX_VALUE) { + Location oldTo = to.clone(); + PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); -+ this.server.getPluginManager().callEvent(event); ++ this.cserver.getPluginManager().callEvent(event); + + // If the event is cancelled we move the player back to their old location. + if (event.isCancelled()) { @@ -304,39 +309,39 @@ + this.player.getWorldServer().getChunkProvider().movePlayer(this.player); this.player.checkMovement(this.player.locX() - d0, this.player.locY() - d1, this.player.locZ() - d2); - this.D = d11 >= -0.03125D && !this.minecraftServer.getAllowFlight() && this.a(entity); -@@ -437,7 +641,7 @@ + this.clientVehicleIsFloating = d11 >= -0.03125D && !this.server.getAllowFlight() && this.a(entity); +@@ -428,7 +633,7 @@ @Override public void a(PacketPlayInTeleportAccept packetplayinteleportaccept) { PlayerConnectionUtils.ensureMainThread(packetplayinteleportaccept, this, this.player.getWorldServer()); -- if (packetplayinteleportaccept.b() == this.teleportAwait) { -+ if (packetplayinteleportaccept.b() == this.teleportAwait && this.teleportPos != null) { // CraftBukkit - this.player.setLocation(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch); - this.o = this.teleportPos.x; - this.p = this.teleportPos.y; -@@ -447,6 +651,7 @@ +- 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()); + this.lastGoodX = this.awaitingPositionFromClient.x; + this.lastGoodY = this.awaitingPositionFromClient.y; +@@ -438,6 +643,7 @@ } - this.teleportPos = null; + this.awaitingPositionFromClient = null; + this.player.getWorldServer().getChunkProvider().movePlayer(this.player); // CraftBukkit } } -@@ -454,7 +659,7 @@ +@@ -445,7 +651,7 @@ @Override public void a(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) { PlayerConnectionUtils.ensureMainThread(packetplayinrecipedisplayed, this, this.player.getWorldServer()); -- Optional optional = this.minecraftServer.getCraftingManager().getRecipe(packetplayinrecipedisplayed.b()); -+ Optional> optional = this.minecraftServer.getCraftingManager().getRecipe(packetplayinrecipedisplayed.b()); // CraftBukkit - decompile error +- Optional optional = this.server.getCraftingManager().getRecipe(packetplayinrecipedisplayed.b()); ++ Optional> optional = this.server.getCraftingManager().getRecipe(packetplayinrecipedisplayed.b()); // CraftBukkit - decompile error RecipeBookServer recipebookserver = this.player.getRecipeBook(); - optional.ifPresent(recipebookserver::e); -@@ -483,6 +688,12 @@ + Objects.requireNonNull(recipebookserver); +@@ -475,6 +681,12 @@ @Override public void a(PacketPlayInTabComplete packetplayintabcomplete) { PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer()); + // CraftBukkit start -+ if (chatSpamField.addAndGet(this, 1) > 500 && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) { ++ if (chatSpamTickCount.addAndGet(1) > 500 && !this.server.getPlayerList().isOp(this.player.getProfile())) { + this.disconnect(new ChatMessage("disconnect.spam", new Object[0])); + return; + } @@ -344,15 +349,15 @@ StringReader stringreader = new StringReader(packetplayintabcomplete.c()); if (stringreader.canRead() && stringreader.peek() == '/') { -@@ -492,6 +703,7 @@ - ParseResults parseresults = this.minecraftServer.getCommandDispatcher().a().parse(stringreader, this.player.getCommandListener()); +@@ -484,6 +696,7 @@ + ParseResults parseresults = this.server.getCommandDispatcher().a().parse(stringreader, this.player.getCommandListener()); - this.minecraftServer.getCommandDispatcher().a().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { + this.server.getCommandDispatcher().a().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { + if (suggestions.isEmpty()) return; // CraftBukkit - don't send through empty suggestions - prevents [] from showing for plugins with nothing more to offer - this.networkManager.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), suggestions)); + this.connection.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), suggestions)); }); } -@@ -720,6 +932,7 @@ +@@ -716,6 +929,7 @@ if (container instanceof ContainerMerchant) { ContainerMerchant containermerchant = (ContainerMerchant) container; @@ -360,7 +365,7 @@ containermerchant.d(i); containermerchant.g(i); -@@ -729,6 +942,13 @@ +@@ -725,6 +939,13 @@ @Override public void a(PacketPlayInBEdit packetplayinbedit) { @@ -371,66 +376,48 @@ + } + this.lastBookTick = MinecraftServer.currentTick; + // CraftBukkit end - ItemStack itemstack = packetplayinbedit.b(); + int i = packetplayinbedit.d(); - if (itemstack.getItem() == Items.WRITABLE_BOOK) { -@@ -744,13 +964,15 @@ - - NBTTagList nbttaglist = nbttagcompound.getList("pages", 8); - -- int i; -+ // CraftBukkit start - decompile error -+ // int i; - -- for (i = 0; i < nbttaglist.size(); ++i) { -+ for (int i = 0; i < nbttaglist.size(); ++i) { - list.add(nbttaglist.getString(i)); - } - -- i = packetplayinbedit.d(); -+ int i = packetplayinbedit.d(); -+ // CraftBukkit end - if (PlayerInventory.d(i) || i == 40) { - this.a((List) list, flag ? (list1) -> { - this.a((String) list1.get(0), list1.subList(1, list1.size()), i); -@@ -769,7 +991,9 @@ - NBTTagList nbttaglist = new NBTTagList(); - - list.stream().map(NBTTagString::a).forEach(nbttaglist::add); -+ ItemStack old = itemstack.cloneItemStack(); // CraftBukkit - itemstack.a("pages", (NBTBase) nbttaglist); -+ CraftEventFactory.handleEditBookEvent(player, i, old, itemstack); // CraftBukkit + if (PlayerInventory.d(i) || i == 40) { +@@ -787,7 +1008,7 @@ + this.a(list, (s) -> { + return IChatBaseComponent.ChatSerializer.a((IChatBaseComponent) (new ChatComponentText(s))); + }, itemstack1); +- this.player.getInventory().setItem(i, itemstack1); ++ this.player.getInventory().setItem(i, CraftEventFactory.handleEditBookEvent(player, i, itemstack, itemstack1)); // CraftBukkit } } -@@ -798,7 +1022,7 @@ - } +@@ -795,7 +1016,7 @@ + NBTTagList nbttaglist = new NBTTagList(); - itemstack1.a("pages", (NBTBase) nbttaglist); -- this.player.inventory.setItem(i, itemstack1); -+ this.player.inventory.setItem(i, CraftEventFactory.handleEditBookEvent(player, i, itemstack, itemstack1)); // CraftBukkit - } - } + if (this.player.R()) { +- Stream stream = list.stream().map((itextfilter_a) -> { ++ Stream stream = list.stream().map((itextfilter_a) -> { // CraftBukkit - decompile error + return NBTTagString.a((String) unaryoperator.apply(itextfilter_a.b())); + }); -@@ -836,7 +1060,7 @@ +@@ -859,7 +1080,7 @@ } else { WorldServer worldserver = this.player.getWorldServer(); -- if (!this.player.viewingCredits) { -+ if (!this.player.viewingCredits && !this.player.isFrozen()) { // CraftBukkit - if (this.e == 0) { +- if (!this.player.wonGame) { ++ if (!this.player.wonGame && !this.player.isFrozen()) { // CraftBukkit + if (this.tickCount == 0) { this.syncPosition(); } -@@ -846,13 +1070,21 @@ - this.A = this.e; - this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch); +@@ -869,7 +1090,7 @@ + this.awaitingTeleportTime = this.tickCount; + this.b(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); } - + this.allowedPlayerTicks = 20; // CraftBukkit } else { - this.A = this.e; + this.awaitingTeleportTime = this.tickCount; + double d0 = a(packetplayinflying.a(this.player.locX())); +@@ -881,7 +1102,15 @@ if (this.player.isPassenger()) { - this.player.setLocation(this.player.locX(), this.player.locY(), this.player.locZ(), packetplayinflying.a(this.player.yaw), packetplayinflying.b(this.player.pitch)); + this.player.setLocation(this.player.locX(), this.player.locY(), this.player.locZ(), f, f1); this.player.getWorldServer().getChunkProvider().movePlayer(this.player); + this.allowedPlayerTicks = 20; // CraftBukkit } else { @@ -438,15 +425,15 @@ + double prevX = player.locX(); + double prevY = player.locY(); + double prevZ = player.locZ(); -+ float prevYaw = player.yaw; -+ float prevPitch = player.pitch; ++ float prevYaw = player.getYRot(); ++ float prevPitch = player.getXRot(); + // CraftBukkit end - double d0 = this.player.locX(); - double d1 = this.player.locY(); - double d2 = this.player.locZ(); -@@ -877,15 +1109,33 @@ - ++this.receivedMovePackets; - int i = this.receivedMovePackets - this.processedMovePackets; + double d3 = this.player.locX(); + double d4 = this.player.locY(); + double d5 = this.player.locZ(); +@@ -901,15 +1130,33 @@ + ++this.receivedMovePacketCount; + int i = this.receivedMovePacketCount - this.knownMovePacketCount; - if (i > 5) { + // CraftBukkit start - handle custom speeds and skipped ticks @@ -459,40 +446,40 @@ i = 1; } -+ if (packetplayinflying.hasLook || d11 > 0) { ++ if (packetplayinflying.hasRot || d11 > 0) { + allowedPlayerTicks -= 1; + } else { + allowedPlayerTicks = 20; + } + double speed; -+ if (player.abilities.isFlying) { -+ speed = player.abilities.flySpeed * 20f; ++ if (player.getAbilities().flying) { ++ speed = player.getAbilities().flyingSpeed * 20f; + } else { -+ speed = player.abilities.walkSpeed * 10f; ++ speed = player.getAbilities().walkingSpeed * 10f; + } + - if (!this.player.H() && (!this.player.getWorldServer().getGameRules().getBoolean(GameRules.DISABLE_ELYTRA_MOVEMENT_CHECK) || !this.player.isGliding())) { + 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 (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()) { + // CraftBukkit end PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getDisplayName().getString(), d7, d8, d9); - this.a(this.player.locX(), this.player.locY(), this.player.locZ(), this.player.yaw, this.player.pitch); + this.b(this.player.locX(), this.player.locY(), this.player.locZ(), this.player.getYRot(), this.player.getXRot()); return; -@@ -904,6 +1154,7 @@ +@@ -928,6 +1175,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 double d12 = d8; - d7 = d4 - this.player.locX(); -@@ -925,10 +1176,74 @@ - if (!this.player.noclip && !this.player.isSleeping() && (flag1 && worldserver.getCubes(this.player, axisalignedbb) || this.a((IWorldReader) worldserver, axisalignedbb))) { - this.a(d0, d1, d2, f, f1); + d7 = d0 - this.player.locX(); +@@ -949,10 +1197,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); } else { -- this.B = d12 >= -0.03125D && this.player.playerInteractManager.getGameMode() != EnumGamemode.SPECTATOR && !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isGliding() && this.a((Entity) this.player); +- 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); + // CraftBukkit start - fire PlayerMoveEvent + // Rest to old location first + this.player.setLocation(prevX, prevY, prevZ, prevYaw, prevPitch); @@ -509,9 +496,9 @@ + } + + // If the packet contains look information then we update the To location with the correct Yaw & Pitch. -+ if (packetplayinflying.hasLook) { -+ to.setYaw(packetplayinflying.yaw); -+ to.setPitch(packetplayinflying.pitch); ++ if (packetplayinflying.hasRot) { ++ to.setYaw(packetplayinflying.yRot); ++ to.setPitch(packetplayinflying.xRot); + } + + // Prevent 40 event-calls for less than a single pixel of movement >.> @@ -529,7 +516,7 @@ + if (from.getX() != Double.MAX_VALUE) { + Location oldTo = to.clone(); + PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); -+ this.server.getPluginManager().callEvent(event); ++ this.cserver.getPluginManager().callEvent(event); + + // If the event is cancelled we move the player back to their old location. + if (event.isCancelled()) { @@ -553,36 +540,52 @@ + } + } + } -+ this.player.setLocation(d4, d5, d6, f, f1); // Copied from above ++ this.player.setLocation(d0, d1, d2, f, f1); // Copied from above + + // MC-135989, SPIGOT-5564: isRiptiding -+ this.B = d12 >= -0.03125D && this.player.playerInteractManager.getGameMode() != EnumGamemode.SPECTATOR && !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isGliding() && this.a((Entity) this.player) && !this.player.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(); + // CraftBukkit end this.player.getWorldServer().getChunkProvider().movePlayer(this.player); - this.player.a(this.player.locY() - d3, packetplayinflying.b()); + this.player.a(this.player.locY() - d6, packetplayinflying.b()); - this.player.setOnGround(packetplayinflying.b()); + // this.player.setOnGround(packetplayinflying.b()); // CraftBukkit - moved up if (flag) { this.player.fallDistance = 0.0F; } -@@ -957,10 +1272,67 @@ +@@ -980,19 +1292,80 @@ + }); } ++ // 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()); -+ this.a(d0, d1, d2, f, f1, Collections.emptySet()); +- this.a(d0, d1, d2, f, f1, Collections.emptySet(), true); ++ this.a(d0, d1, d2, f, f1, PlayerTeleportEvent.TeleportCause.UNKNOWN); + } + -+ // CraftBukkit start - Delegate to teleport(Location) + 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(), cause); ++ this.a(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 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 a(double d0, double d1, double d2, float f, float f1, Set set) { +- this.a(d0, d1, d2, f, f1, set, false); + this.a(d0, d1, d2, f, f1, set, PlayerTeleportEvent.TeleportCause.UNKNOWN); + } + +- public void a(double d0, double d1, double d2, float f, float f1, Set set, boolean flag) { ++ public void a(double d0, double d1, double d2, float f, float f1, Set set, PlayerTeleportEvent.TeleportCause cause) { ++ this.a(d0, d1, d2, f, f1, set, false, cause); + } + -+ public boolean a(double d0, double d1, double d2, float f, float f1, Set set, PlayerTeleportEvent.TeleportCause cause) { // CraftBukkit - Return event status ++ public boolean a(double d0, double d1, double d2, float f, float f1, Set set, boolean flag, PlayerTeleportEvent.TeleportCause cause) { // CraftBukkit - Return event status + Player player = this.getPlayer(); + Location from = player.getLocation(); + @@ -595,12 +598,12 @@ + Location to = new Location(this.getPlayer().getWorld(), x, y, z, yaw, pitch); + // SPIGOT-5171: Triggered on join + if (from.equals(to)) { -+ this.internalTeleport(d0, d1, d2, f, f1, set); ++ this.internalTeleport(d0, d1, d2, f, f1, set, flag); + return false; // CraftBukkit - Return event status + } + + PlayerTeleportEvent event = new PlayerTeleportEvent(player, from.clone(), to.clone(), cause); -+ this.server.getPluginManager().callEvent(event); ++ this.cserver.getPluginManager().callEvent(event); + + if (event.isCancelled() || !to.equals(event.getTo())) { + set.clear(); // Can't relative teleport @@ -612,15 +615,15 @@ + f1 = to.getPitch(); + } + -+ this.internalTeleport(d0, d1, d2, f, f1, set); ++ this.internalTeleport(d0, d1, d2, f, f1, set, flag); + return event.isCancelled(); // CraftBukkit - Return event status + } + + public void teleport(Location dest) { -+ internalTeleport(dest.getX(), dest.getY(), dest.getZ(), dest.getYaw(), dest.getPitch(), Collections.emptySet()); ++ internalTeleport(dest.getX(), dest.getY(), dest.getZ(), dest.getYaw(), dest.getPitch(), Collections.emptySet(), true); + } + -+ private void internalTeleport(double d0, double d1, double d2, float f, float f1, Set set) { ++ private void internalTeleport(double d0, double d1, double d2, float f, float f1, Set set, boolean flag) { + // CraftBukkit start + if (Float.isNaN(f)) { + f = 0; @@ -634,22 +637,22 @@ 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; -@@ -972,6 +1344,14 @@ - this.teleportAwait = 0; +@@ -1004,6 +1377,14 @@ + this.awaitingTeleport = 0; } + // CraftBukkit start - update last location -+ this.lastPosX = this.teleportPos.x; -+ this.lastPosY = this.teleportPos.y; -+ this.lastPosZ = this.teleportPos.z; ++ this.lastPosX = this.awaitingPositionFromClient.x; ++ this.lastPosY = this.awaitingPositionFromClient.y; ++ this.lastPosZ = this.awaitingPositionFromClient.z; + this.lastYaw = f; + this.lastPitch = f1; + // CraftBukkit end + - this.A = this.e; + this.awaitingTeleportTime = this.tickCount; this.player.setLocation(d0, d1, d2, f, f1); - this.player.playerConnection.sendPacket(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.teleportAwait)); -@@ -980,6 +1360,7 @@ + this.player.connection.sendPacket(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag)); +@@ -1012,6 +1393,7 @@ @Override public void a(PacketPlayInBlockDig packetplayinblockdig) { PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.getWorldServer()); @@ -657,7 +660,7 @@ BlockPosition blockposition = packetplayinblockdig.b(); this.player.resetIdleTimer(); -@@ -990,14 +1371,46 @@ +@@ -1022,14 +1404,46 @@ if (!this.player.isSpectator()) { ItemStack itemstack = this.player.b(EnumHand.OFF_HAND); @@ -667,7 +670,7 @@ + CraftItemStack mainHand = CraftItemStack.asCraftMirror(itemstack); + CraftItemStack offHand = CraftItemStack.asCraftMirror(this.player.b(EnumHand.MAIN_HAND)); + PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(getPlayer(), mainHand.clone(), offHand.clone()); -+ this.server.getPluginManager().callEvent(swapItemsEvent); ++ this.cserver.getPluginManager().callEvent(swapItemsEvent); + if (swapItemsEvent.isCancelled()) { + return; + } @@ -706,7 +709,7 @@ this.player.dropItem(false); } -@@ -1034,6 +1447,7 @@ +@@ -1066,6 +1480,7 @@ @Override public void a(PacketPlayInUseItem packetplayinuseitem) { PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.getWorldServer()); @@ -714,10 +717,10 @@ WorldServer worldserver = this.player.getWorldServer(); EnumHand enumhand = packetplayinuseitem.b(); ItemStack itemstack = this.player.b(enumhand); -@@ -1044,6 +1458,14 @@ - this.player.resetIdleTimer(); - if (blockposition.getY() < this.minecraftServer.getMaxBuildHeight()) { - if (this.teleportPos == 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)) { +@@ -1078,6 +1493,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)) { + // CraftBukkit start - Check if we can actually do something over this large a distance + Location eyeLoc = this.getPlayer().getEyeLocation(); + double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ()); @@ -726,10 +729,10 @@ + } + this.player.clearActiveItem(); // SPIGOT-4706 + // CraftBukkit end - EnumInteractionResult enuminteractionresult = this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); + EnumInteractionResult enuminteractionresult = this.player.gameMode.a(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); - if (enumdirection == EnumDirection.UP && !enuminteractionresult.a() && blockposition.getY() >= this.minecraftServer.getMaxBuildHeight() - 1 && a(this.player, itemstack)) { -@@ -1067,12 +1489,51 @@ + if (enumdirection == EnumDirection.UP && !enuminteractionresult.a() && blockposition.getY() >= i - 1 && a(this.player, itemstack)) { +@@ -1101,12 +1524,51 @@ @Override public void a(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.getWorldServer()); @@ -742,8 +745,8 @@ if (!itemstack.isEmpty()) { + // CraftBukkit start + // Raytrace to look for 'rogue armswings' -+ float f1 = this.player.pitch; -+ float f2 = this.player.yaw; ++ 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(); @@ -755,9 +758,9 @@ + float f6 = MathHelper.sin(-f1 * 0.017453292F); + float f7 = f4 * f5; + float f8 = f3 * f5; -+ double d3 = player.playerInteractManager.getGameMode()== EnumGamemode.CREATIVE ? 5.0D : 4.5D; ++ double d3 = player.gameMode.getGameMode()== EnumGamemode.CREATIVE ? 5.0D : 4.5D; + Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); -+ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.OUTLINE, RayTrace.FluidCollisionOption.NONE, player)); ++ MovingObjectPosition movingobjectposition = this.player.level.rayTrace(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.OUTLINE, RayTrace.FluidCollisionOption.NONE, player)); + + boolean cancelled; + if (movingobjectposition == null || movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.BLOCK) { @@ -765,46 +768,40 @@ + cancelled = event.useItemInHand() == Event.Result.DENY; + } else { + MovingObjectPositionBlock movingobjectpositionblock = (MovingObjectPositionBlock) movingobjectposition; -+ if (player.playerInteractManager.firedInteract && player.playerInteractManager.interactPosition.equals(movingobjectpositionblock.getBlockPosition()) && player.playerInteractManager.interactHand == enumhand && ItemStack.equals(player.playerInteractManager.interactItemStack, itemstack)) { -+ cancelled = player.playerInteractManager.interactResult; ++ if (player.gameMode.firedInteract && player.gameMode.interactPosition.equals(movingobjectpositionblock.getBlockPosition()) && player.gameMode.interactHand == enumhand && ItemStack.equals(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); + cancelled = event.useItemInHand() == Event.Result.DENY; + } -+ player.playerInteractManager.firedInteract = false; ++ player.gameMode.firedInteract = false; + } + + if (cancelled) { + this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524 + return; + } - EnumInteractionResult enuminteractionresult = this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand); + EnumInteractionResult enuminteractionresult = this.player.gameMode.a(this.player, worldserver, itemstack, enumhand); if (enuminteractionresult.b()) { -@@ -1093,7 +1554,7 @@ +@@ -1127,7 +1589,7 @@ Entity entity = packetplayinspectate.a(worldserver); if (entity != null) { -- this.player.a(worldserver, entity.locX(), entity.locY(), entity.locZ(), entity.yaw, entity.pitch); -+ this.player.a(worldserver, entity.locX(), entity.locY(), entity.locZ(), entity.yaw, entity.pitch, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit +- 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 return; } } -@@ -1102,7 +1563,12 @@ +@@ -1142,6 +1604,7 @@ + PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getDisplayName()); + this.disconnect(new ChatMessage("multiplayer.requiredTexturePrompt.disconnect")); + } ++ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.action.ordinal()])); // CraftBukkit + } - @Override -- public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {} -+ // CraftBukkit start -+ public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) { -+ PlayerConnectionUtils.ensureMainThread(packetplayinresourcepackstatus, this, this.player.getWorldServer()); -+ this.server.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.status.ordinal()])); -+ } -+ // CraftBukkit end - - @Override - public void a(PacketPlayInBoatMove packetplayinboatmove) { -@@ -1117,11 +1583,26 @@ +@@ -1161,11 +1624,26 @@ @Override public void a(IChatBaseComponent ichatbasecomponent) { @@ -818,54 +815,54 @@ PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getDisplayName().getString(), ichatbasecomponent.getString()); + // CraftBukkit start - Replace vanilla quit message handling with our own. + /* - this.minecraftServer.invalidatePingSample(); - this.minecraftServer.getPlayerList().sendMessage((new ChatMessage("multiplayer.player.left", new Object[]{this.player.getScoreboardDisplayName()})).a(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.b); + 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.player.p(); -- this.minecraftServer.getPlayerList().disconnect(this.player); -+ String quitMessage = this.minecraftServer.getPlayerList().disconnect(this.player); +- this.server.getPlayerList().disconnect(this.player); ++ String quitMessage = this.server.getPlayerList().disconnect(this.player); + if ((quitMessage != null) && (quitMessage.length() > 0)) { -+ this.minecraftServer.getPlayerList().sendMessage(CraftChatMessage.fromString(quitMessage)); ++ this.server.getPlayerList().sendMessage(CraftChatMessage.fromString(quitMessage)); + } + // CraftBukkit end - ITextFilter itextfilter = this.player.Q(); - - if (itextfilter != null) { -@@ -1153,6 +1634,15 @@ - } - } + this.player.Q().b(); + if (this.isExemptPlayer()) { + PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out"); +@@ -1180,6 +1658,15 @@ + } + public void a(Packet packet, @Nullable GenericFutureListener> 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.position.getX(), packet6.position.getY(), packet6.position.getZ()); ++ this.player.compassTarget = new Location(this.getPlayer().getWorld(), packet6.pos.getX(), packet6.pos.getY(), packet6.pos.getZ()); + } + // CraftBukkit end + try { - this.networkManager.sendPacket(packet, genericfuturelistener); + this.connection.sendPacket(packet, genericfuturelistener); } catch (Throwable throwable) { -@@ -1169,7 +1659,16 @@ +@@ -1196,7 +1683,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.inventory.itemInHandIndex, packetplayinhelditemslot.b()); -+ this.server.getPluginManager().callEvent(event); ++ PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.getInventory().selected, packetplayinhelditemslot.b()); ++ this.cserver.getPluginManager().callEvent(event); + if (event.isCancelled()) { -+ this.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex)); ++ this.sendPacket(new PacketPlayOutHeldItemSlot(this.player.getInventory().selected)); + this.player.resetIdleTimer(); + return; + } + // CraftBukkit end - if (this.player.inventory.itemInHandIndex != packetplayinhelditemslot.b() && this.player.getRaisedHand() == EnumHand.MAIN_HAND) { + if (this.player.getInventory().selected != packetplayinhelditemslot.b() && this.player.getRaisedHand() == EnumHand.MAIN_HAND) { this.player.clearActiveItem(); } -@@ -1178,65 +1677,286 @@ +@@ -1205,11 +1701,18 @@ this.player.resetIdleTimer(); } else { PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getDisplayName().getString()); @@ -877,97 +874,70 @@ public void a(PacketPlayInChat packetplayinchat) { + // CraftBukkit start - async chat + // SPIGOT-3638 -+ if (this.minecraftServer.isStopped()) { ++ if (this.server.isStopped()) { + return; + } + // CraftBukkit end String s = StringUtils.normalizeSpace(packetplayinchat.b()); - if (s.startsWith("/")) { + for (int i = 0; i < s.length(); ++i) { +@@ -1223,20 +1726,42 @@ PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.getWorldServer()); - this.c(s); + this.a(ITextFilter.a.a(s)); } else { -- this.a(s, this::c); -+ this.c(s); // CraftBukkit - filter NYI +- this.a(s, this::a); ++ this.a(ITextFilter.a.a(s)); // CraftBukkit - filter NYI } } - private void c(String s) { + private void a(ITextFilter.a itextfilter_a) { - if (this.player.getChatFlags() == EnumChatVisibility.HIDDEN) { -+ if (this.player.dead || this.player.getChatFlags() == EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales - this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.cannotSend")).a(EnumChatFormat.RED), ChatMessageType.SYSTEM, SystemUtils.b)); ++ 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)); } else { this.player.resetIdleTimer(); - -+ boolean isSync = s.startsWith("/"); // CraftBukkit - for (int i = 0; i < s.length(); ++i) { - if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { -- this.disconnect(new ChatMessage("multiplayer.disconnect.illegal_characters")); -+ // CraftBukkit start - threadsafety -+ if (!s.startsWith("/")) { -+ Waitable waitable = new Waitable() { -+ @Override -+ protected Object evaluate() { -+ PlayerConnection.this.disconnect(new ChatMessage("multiplayer.disconnect.illegal_characters")); -+ return null; -+ } -+ }; -+ -+ this.minecraftServer.processQueue.add(waitable); -+ -+ try { -+ waitable.get(); -+ } catch (InterruptedException e) { -+ Thread.currentThread().interrupt(); -+ } catch (ExecutionException e) { -+ throw new RuntimeException(e); -+ } -+ } else { -+ this.disconnect(new ChatMessage("multiplayer.disconnect.illegal_characters")); -+ } -+ // CraftBukkit end - return; - } - } + String s = itextfilter_a.a(); - if (s.startsWith("/")) { - this.handleCommand(s); + // CraftBukkit start ++ boolean isSync = s.startsWith("/"); + if (isSync) { + try { -+ this.minecraftServer.server.playerCommandState = true; ++ this.server.server.playerCommandState = true; + this.handleCommand(s); + } finally { -+ this.minecraftServer.server.playerCommandState = false; ++ this.server.server.playerCommandState = false; + } + } else if (s.isEmpty()) { + LOGGER.warn(this.player.getName() + " tried to send an empty message"); + } else if (getPlayer().isConversing()) { + final String conversationInput = s; -+ this.minecraftServer.processQueue.add(new Runnable() { ++ this.server.processQueue.add(new Runnable() { + @Override + public void run() { + getPlayer().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.b)); ++ this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.cannotSend")).a(EnumChatFormat.RED), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID)); + } else if (true) { + this.chat(s, true); + // CraftBukkit end - the below is for reference. :) } else { - ChatMessage chatmessage = new ChatMessage("chat.type.text", new Object[]{this.player.getScoreboardDisplayName(), s}); - - this.minecraftServer.getPlayerList().sendMessage(chatmessage, ChatMessageType.CHAT, this.player.getUniqueID()); + String s1 = itextfilter_a.b(); + ChatMessage chatmessage = s1.isEmpty() ? null : new ChatMessage("chat.type.text", new Object[]{this.player.getScoreboardDisplayName(), s1}); +@@ -1247,28 +1772,198 @@ + }, ChatMessageType.CHAT, this.player.getUniqueID()); } -- this.chatThrottle += 20; -- if (this.chatThrottle > 200 && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) { +- this.chatSpamTickCount += 20; +- if (this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getProfile())) { - this.disconnect(new ChatMessage("disconnect.spam")); + // CraftBukkit start - replaced with thread safe throttle + // this.chatThrottle += 20; -+ if (chatSpamField.addAndGet(this, 20) > 200 && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) { ++ if (chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getProfile())) { + if (!isSync) { + Waitable waitable = new Waitable() { + @Override @@ -977,7 +947,7 @@ + } + }; + -+ this.minecraftServer.processQueue.add(waitable); ++ this.server.processQueue.add(waitable); + + try { + waitable.get(); @@ -1007,8 +977,8 @@ + // Do nothing, this is coming from a plugin + } else { + Player player = this.getPlayer(); -+ AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet(minecraftServer)); -+ this.server.getPluginManager().callEvent(event); ++ AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet(server)); ++ this.cserver.getPluginManager().callEvent(event); + + if (PlayerChatEvent.getHandlerList().getRegisteredListeners().length != 0) { + // Evil plugins still listening to deprecated event @@ -1024,9 +994,9 @@ + } + + String message = String.format(queueEvent.getFormat(), queueEvent.getPlayer().getDisplayName(), queueEvent.getMessage()); -+ PlayerConnection.this.minecraftServer.console.sendMessage(message); ++ PlayerConnection.this.server.console.sendMessage(message); + if (((LazyPlayerSet) queueEvent.getRecipients()).isLazy()) { -+ for (EntityPlayer recipient : minecraftServer.getPlayerList().players) { ++ for (EntityPlayer recipient : server.getPlayerList().players) { + recipient.getBukkitEntity().sendMessage(PlayerConnection.this.player.getUniqueID(), message); + } + } else { @@ -1037,7 +1007,7 @@ + return null; + }}; + if (async) { -+ minecraftServer.processQueue.add(waitable); ++ server.processQueue.add(waitable); + } else { + waitable.run(); + } @@ -1054,9 +1024,9 @@ + } + + s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage()); -+ minecraftServer.console.sendMessage(s); ++ server.console.sendMessage(s); + if (((LazyPlayerSet) event.getRecipients()).isLazy()) { -+ for (EntityPlayer recipient : minecraftServer.getPlayerList().players) { ++ for (EntityPlayer recipient : server.getPlayerList().players) { + recipient.getBukkitEntity().sendMessage(PlayerConnection.this.player.getUniqueID(), s); + } + } else { @@ -1070,21 +1040,21 @@ + // CraftBukkit end + private void handleCommand(String s) { -- this.minecraftServer.getCommandDispatcher().a(this.player.getCommandListener(), s); +- this.server.getCommandDispatcher().a(this.player.getCommandListener(), s); + // CraftBukkit start - whole method + this.LOGGER.info(this.player.getName() + " issued server command: " + s); + + CraftPlayer player = this.getPlayer(); + -+ PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(player, s, new LazyPlayerSet(minecraftServer)); -+ this.server.getPluginManager().callEvent(event); ++ PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(player, s, new LazyPlayerSet(server)); ++ this.cserver.getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; + } + + try { -+ if (this.server.dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) { ++ if (this.cserver.dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) { + return; + } + } catch (org.bukkit.command.CommandException ex) { @@ -1102,8 +1072,8 @@ + if (this.player.isFrozen()) return; // CraftBukkit this.player.resetIdleTimer(); + // CraftBukkit start - Raytrace to look for 'rogue armswings' -+ float f1 = this.player.pitch; -+ float f2 = this.player.yaw; ++ 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(); @@ -1115,17 +1085,17 @@ + float f6 = MathHelper.sin(-f1 * 0.017453292F); + float f7 = f4 * f5; + float f8 = f3 * f5; -+ double d3 = player.playerInteractManager.getGameMode()== EnumGamemode.CREATIVE ? 5.0D : 4.5D; ++ double d3 = player.gameMode.getGameMode()== EnumGamemode.CREATIVE ? 5.0D : 4.5D; + Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); -+ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.OUTLINE, RayTrace.FluidCollisionOption.NONE, player)); ++ MovingObjectPosition movingobjectposition = this.player.level.rayTrace(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.inventory.getItemInHand(), EnumHand.MAIN_HAND); ++ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getItemInHand(), EnumHand.MAIN_HAND); + } + + // Arm swing animation + PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer()); -+ this.server.getPluginManager().callEvent(event); ++ this.cserver.getPluginManager().callEvent(event); + + if (event.isCancelled()) return; + // CraftBukkit end @@ -1136,12 +1106,12 @@ public void a(PacketPlayInEntityAction packetplayinentityaction) { PlayerConnectionUtils.ensureMainThread(packetplayinentityaction, this, this.player.getWorldServer()); + // CraftBukkit start -+ if (this.player.dead) return; ++ if (this.player.isRemoved()) return; + switch (packetplayinentityaction.c()) { + case PRESS_SHIFT_KEY: + case RELEASE_SHIFT_KEY: + PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getPlayer(), packetplayinentityaction.c() == PacketPlayInEntityAction.EnumPlayerAction.PRESS_SHIFT_KEY); -+ this.server.getPluginManager().callEvent(event); ++ this.cserver.getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; @@ -1150,7 +1120,7 @@ + case START_SPRINTING: + case STOP_SPRINTING: + PlayerToggleSprintEvent e2 = new PlayerToggleSprintEvent(this.getPlayer(), packetplayinentityaction.c() == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING); -+ this.server.getPluginManager().callEvent(e2); ++ this.cserver.getPluginManager().callEvent(e2); + + if (e2.isCancelled()) { + return; @@ -1161,89 +1131,92 @@ this.player.resetIdleTimer(); IJumpable ijumpable; -@@ -1294,6 +2014,7 @@ +@@ -1326,6 +2021,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(); - Entity entity = packetplayinuseentity.a((World) worldserver); + final Entity entity = packetplayinuseentity.a(worldserver); -@@ -1307,18 +2028,72 @@ - ItemStack itemstack = enumhand != null ? this.player.b(enumhand).cloneItemStack() : ItemStack.b; - Optional optional = Optional.empty(); +@@ -1336,10 +2032,44 @@ -+ ItemStack itemInHand = this.player.b(packetplayinuseentity.c() == null ? EnumHand.MAIN_HAND : packetplayinuseentity.c()); // CraftBukkit + 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(); ++ // CraftBukkit start ++ ItemStack itemInHand = PlayerConnection.this.player.b(enumhand); ++ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient; ++ Item origItem = player.getInventory().getItemInHand() == null ? null : player.getInventory().getItemInHand().getItem(); + -+ if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT -+ || packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) { -+ // CraftBukkit start -+ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient; -+ Item origItem = this.player.inventory.getItemInHand() == null ? null : this.player.inventory.getItemInHand().getItem(); -+ PlayerInteractEntityEvent event; -+ if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) { -+ event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity(), (packetplayinuseentity.c() == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND); -+ } else { -+ Vec3D target = packetplayinuseentity.d(); -+ event = new PlayerInteractAtEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity(), new org.bukkit.util.Vector(target.x, target.y, target.z), (packetplayinuseentity.c() == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND); -+ } -+ this.server.getPluginManager().callEvent(event); ++ cserver.getPluginManager().callEvent(event); + -+ // Fish bucket - SPIGOT-4048 -+ if ((entity instanceof EntityFish && origItem != null && origItem.getItem() == Items.WATER_BUCKET) && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != origItem)) { -+ this.sendPacket(new PacketPlayOutSpawnEntityLiving((EntityFish) entity)); -+ this.player.updateInventory(this.player.activeContainer); -+ } ++ // 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 (triggerLeashUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != origItem)) { -+ // Refresh the current leash state -+ this.sendPacket(new PacketPlayOutAttachEntity(entity, ((EntityInsentient) entity).getLeashHolder())); -+ } ++ if (triggerLeashUpdate && (event.isCancelled() || player.getInventory().getItemInHand() == null || player.getInventory().getItemInHand().getItem() != origItem)) { ++ // Refresh the current leash state ++ sendPacket(new PacketPlayOutAttachEntity(entity, ((EntityInsentient) entity).getLeashHolder())); ++ } + -+ if (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != origItem) { -+ // Refresh the current entity metadata -+ this.sendPacket(new PacketPlayOutEntityMetadata(entity.getId(), entity.getDataWatcher(), true)); -+ } ++ if (event.isCancelled() || player.getInventory().getItemInHand() == null || player.getInventory().getItemInHand().getItem() != origItem) { ++ // Refresh the current entity metadata ++ sendPacket(new PacketPlayOutEntityMetadata(entity.getId(), entity.getDataWatcher(), true)); ++ } + -+ if (event.isCancelled()) { -+ return; -+ } -+ // CraftBukkit end -+ } ++ if (event.isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + - if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) { - optional = Optional.of(this.player.a(entity, enumhand)); -+ // CraftBukkit start -+ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { -+ this.player.updateInventory(this.player.activeContainer); -+ } -+ // CraftBukkit end - } else if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) { - optional = Optional.of(entity.a((EntityHuman) this.player, packetplayinuseentity.d(), enumhand)); -+ // CraftBukkit start -+ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { -+ this.player.updateInventory(this.player.activeContainer); -+ } -+ // CraftBukkit end - } else if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) { -- if (entity instanceof EntityItem || entity instanceof EntityExperienceOrb || entity instanceof EntityArrow || entity == this.player) { -+ if (entity instanceof EntityItem || entity instanceof EntityExperienceOrb || entity instanceof EntityArrow || (entity == this.player && !player.isSpectator())) { // CraftBukkit - this.disconnect(new ChatMessage("multiplayer.disconnect.invalid_entity_attacked")); - PlayerConnection.LOGGER.warn("Player {} tried to attack an invalid entity", this.player.getDisplayName().getString()); - return; + EnumInteractionResult enuminteractionresult = playerconnection_a.run(PlayerConnection.this.player, entity, enumhand); + ++ // CraftBukkit start ++ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { ++ player.containerMenu.updateInventory(); ++ } ++ // CraftBukkit end ++ + if (enuminteractionresult.a()) { + CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.a(PlayerConnection.this.player, itemstack, entity); + if (enuminteractionresult.b()) { +@@ -1351,20 +2081,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)); } - this.player.attack(entity); -+ -+ // CraftBukkit start -+ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { -+ this.player.updateInventory(this.player.activeContainer); -+ } -+ // CraftBukkit end - } + @Override + public void a(EnumHand enumhand, Vec3D vec3d) { + this.a(enumhand, (entityplayer, entity1, enumhand1) -> { + return entity1.a((EntityHuman) 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 + } - if (optional.isPresent() && ((EnumInteractionResult) optional.get()).a()) { -@@ -1365,15 +2140,21 @@ + @Override + public void a() { +- 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(); + PlayerConnection.this.player.attack(entity); ++ ++ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { ++ player.containerMenu.updateInventory(); ++ } ++ // 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()); +@@ -1409,19 +2146,303 @@ @Override public void a(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer()); @@ -1259,32 +1232,28 @@ PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit this.player.resetIdleTimer(); -- if (this.player.activeContainer.windowId == packetplayinwindowclick.b() && this.player.activeContainer.c(this.player)) { +- if (this.player.containerMenu.containerId == packetplayinwindowclick.b()) { - if (this.player.isSpectator()) { -+ if (this.player.activeContainer.windowId == packetplayinwindowclick.b() && this.player.activeContainer.c(this.player) && this.player.activeContainer.canUse(this.player)) { // CraftBukkit ++ if (this.player.containerMenu.containerId == packetplayinwindowclick.b() && this.player.containerMenu.canUse(this.player)) { // CraftBukkit + boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if + if (false/*this.player.isSpectator()*/) { // CraftBukkit - NonNullList nonnulllist = NonNullList.a(); - - for (int i = 0; i < this.player.activeContainer.slots.size(); ++i) { -@@ -1382,8 +2163,285 @@ - - this.player.a(this.player.activeContainer, nonnulllist); + this.player.containerMenu.updateInventory(); } else { -- ItemStack itemstack = this.player.activeContainer.a(packetplayinwindowclick.c(), packetplayinwindowclick.d(), packetplayinwindowclick.g(), this.player); + this.player.containerMenu.g(); +- this.player.containerMenu.a(packetplayinwindowclick.c(), packetplayinwindowclick.d(), packetplayinwindowclick.g(), this.player); + // CraftBukkit start - Call InventoryClickEvent + if (packetplayinwindowclick.c() < -1 && packetplayinwindowclick.c() != -999) { + return; + } + -+ InventoryView inventory = this.player.activeContainer.getBukkitView(); ++ InventoryView inventory = this.player.containerMenu.getBukkitView(); + SlotType type = inventory.getSlotType(packetplayinwindowclick.c()); + + InventoryClickEvent event; + ClickType click = ClickType.UNKNOWN; + InventoryAction action = InventoryAction.UNKNOWN; + -+ ItemStack itemstack = ItemStack.b; ++ ItemStack itemstack = ItemStack.EMPTY; + + switch (packetplayinwindowclick.g()) { + case PICKUP: @@ -1296,16 +1265,16 @@ + if (packetplayinwindowclick.d() == 0 || packetplayinwindowclick.d() == 1) { + action = InventoryAction.NOTHING; // Don't want to repeat ourselves + if (packetplayinwindowclick.c() == -999) { -+ if (!player.inventory.getCarried().isEmpty()) { ++ if (!player.inventoryMenu.getCarried().isEmpty()) { + action = packetplayinwindowclick.d() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR; + } + } else if (packetplayinwindowclick.c() < 0) { + action = InventoryAction.NOTHING; + } else { -+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.c()); ++ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.c()); + if (slot != null) { + ItemStack clickedItem = slot.getItem(); -+ ItemStack cursor = player.inventory.getCarried(); ++ ItemStack cursor = player.inventoryMenu.getCarried(); + if (clickedItem.isEmpty()) { + if (!cursor.isEmpty()) { + action = packetplayinwindowclick.d() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE; @@ -1317,7 +1286,7 @@ + if (clickedItem.doMaterialsMatch(cursor) && ItemStack.equals(clickedItem, cursor)) { + int toPlace = packetplayinwindowclick.d() == 0 ? cursor.getCount() : 1; + toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.getCount()); -+ toPlace = Math.min(toPlace, slot.inventory.getMaxStackSize() - clickedItem.getCount()); ++ toPlace = Math.min(toPlace, slot.container.getMaxStackSize() - clickedItem.getCount()); + if (toPlace == 1) { + action = InventoryAction.PLACE_ONE; + } else if (toPlace == cursor.getCount()) { @@ -1354,7 +1323,7 @@ + if (packetplayinwindowclick.c() < 0) { + action = InventoryAction.NOTHING; + } else { -+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.c()); ++ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.c()); + if (slot != null && slot.isAllowed(this.player) && slot.hasItem()) { + action = InventoryAction.MOVE_TO_OTHER_INVENTORY; + } else { @@ -1366,10 +1335,10 @@ + 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.activeContainer.getSlot(packetplayinwindowclick.c()); ++ Slot clickedSlot = this.player.containerMenu.getSlot(packetplayinwindowclick.c()); + if (clickedSlot.isAllowed(player)) { -+ ItemStack hotbar = this.player.inventory.getItem(packetplayinwindowclick.d()); -+ boolean canCleanSwap = hotbar.isEmpty() || (clickedSlot.inventory == player.inventory && clickedSlot.isAllowed(hotbar)); // the slot will accept the hotbar item ++ 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 (clickedSlot.hasItem()) { + if (canCleanSwap) { + action = InventoryAction.HOTBAR_SWAP; @@ -1392,8 +1361,8 @@ + if (packetplayinwindowclick.c() < 0) { + action = InventoryAction.NOTHING; + } else { -+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.c()); -+ if (slot != null && slot.hasItem() && player.abilities.canInstantlyBuild && player.inventory.getCarried().isEmpty()) { ++ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.c()); ++ if (slot != null && slot.hasItem() && player.getAbilities().instabuild && player.inventoryMenu.getCarried().isEmpty()) { + action = InventoryAction.CLONE_STACK; + } else { + action = InventoryAction.NOTHING; @@ -1408,7 +1377,7 @@ + if (packetplayinwindowclick.c() >= 0) { + if (packetplayinwindowclick.d() == 0) { + click = ClickType.DROP; -+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.c()); ++ 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)) { + action = InventoryAction.DROP_ONE_SLOT; + } else { @@ -1416,7 +1385,7 @@ + } + } else if (packetplayinwindowclick.d() == 1) { + click = ClickType.CONTROL_DROP; -+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.c()); ++ 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)) { + action = InventoryAction.DROP_ALL_SLOT; + } else { @@ -1433,13 +1402,13 @@ + } + break; + case QUICK_CRAFT: -+ itemstack = this.player.activeContainer.a(packetplayinwindowclick.c(), packetplayinwindowclick.d(), packetplayinwindowclick.g(), this.player); ++ this.player.containerMenu.a(packetplayinwindowclick.c(), packetplayinwindowclick.d(), packetplayinwindowclick.g(), this.player); + break; + case PICKUP_ALL: + click = ClickType.DOUBLE_CLICK; + action = InventoryAction.NOTHING; -+ if (packetplayinwindowclick.c() >= 0 && !this.player.inventory.getCarried().isEmpty()) { -+ ItemStack cursor = this.player.inventory.getCarried(); ++ if (packetplayinwindowclick.c() >= 0 && !this.player.inventoryMenu.getCarried().isEmpty()) { ++ ItemStack cursor = this.player.inventoryMenu.getCarried(); + action = InventoryAction.NOTHING; + // Quick check for if we have any of the item + if (inventory.getTopInventory().contains(CraftMagicNumbers.getMaterial(cursor.getItem())) || inventory.getBottomInventory().contains(CraftMagicNumbers.getMaterial(cursor.getItem()))) { @@ -1482,21 +1451,21 @@ + } + + event.setCancelled(cancelled); -+ Container oldContainer = this.player.activeContainer; // SPIGOT-1224 -+ server.getPluginManager().callEvent(event); -+ if (this.player.activeContainer != oldContainer) { ++ Container oldContainer = this.player.containerMenu; // SPIGOT-1224 ++ cserver.getPluginManager().callEvent(event); ++ if (this.player.containerMenu != oldContainer) { + return; + } + + switch (event.getResult()) { + case ALLOW: + case DEFAULT: -+ itemstack = this.player.activeContainer.a(packetplayinwindowclick.c(), packetplayinwindowclick.d(), packetplayinwindowclick.g(), this.player); ++ this.player.containerMenu.a(packetplayinwindowclick.c(), packetplayinwindowclick.d(), packetplayinwindowclick.g(), this.player); + break; + case DENY: + /* Needs enum constructor in InventoryAction + if (action.modifiesOtherSlots()) { - ++ + } else { + if (action.modifiesCursor()) { + this.player.playerConnection.sendPacket(new Packet103SetSlot(-1, -1, this.player.inventory.getCarried())); @@ -1513,7 +1482,7 @@ + case HOTBAR_SWAP: + case COLLECT_TO_CURSOR: + case UNKNOWN: -+ this.player.updateInventory(this.player.activeContainer); ++ this.player.containerMenu.updateInventory(); + break; + // Modified cursor and clicked + case PICKUP_SOME: @@ -1523,19 +1492,19 @@ + case PLACE_SOME: + case PLACE_ONE: + case SWAP_WITH_CURSOR: -+ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.player.inventory.getCarried())); -+ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, packetplayinwindowclick.c(), this.player.activeContainer.getSlot(packetplayinwindowclick.c()).getItem())); ++ this.player.connection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.player.inventoryMenu.getCarried())); ++ this.player.connection.sendPacket(new PacketPlayOutSetSlot(this.player.containerMenu.containerId, packetplayinwindowclick.c(), this.player.containerMenu.getSlot(packetplayinwindowclick.c()).getItem())); + break; + // Modified clicked only + case DROP_ALL_SLOT: + case DROP_ONE_SLOT: -+ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, packetplayinwindowclick.c(), this.player.activeContainer.getSlot(packetplayinwindowclick.c()).getItem())); ++ this.player.connection.sendPacket(new PacketPlayOutSetSlot(this.player.containerMenu.containerId, packetplayinwindowclick.c(), this.player.containerMenu.getSlot(packetplayinwindowclick.c()).getItem())); + break; + // Modified cursor only + case DROP_ALL_CURSOR: + case DROP_ONE_CURSOR: + case CLONE_STACK: -+ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.player.inventory.getCarried())); ++ this.player.connection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.player.inventoryMenu.getCarried())); + break; + // Nothing + case NOTHING: @@ -1547,28 +1516,28 @@ + if (event instanceof CraftItemEvent || event instanceof SmithItemEvent) { + // Need to update the inventory on crafting to + // correctly support custom recipes -+ player.updateInventory(player.activeContainer); ++ player.containerMenu.updateInventory(); + } + } + // CraftBukkit end - if (ItemStack.matches(packetplayinwindowclick.f(), itemstack)) { - this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.b(), packetplayinwindowclick.e(), true)); - this.player.e = true; -@@ -1423,6 +2481,7 @@ + ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.f()).iterator(); + + while (objectiterator.hasNext()) { +@@ -1452,6 +2473,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.activeContainer.windowId == packetplayinenchantitem.b() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { - this.player.activeContainer.a((EntityHuman) this.player, packetplayinenchantitem.c()); -@@ -1455,6 +2514,43 @@ + if (this.player.containerMenu.containerId == packetplayinenchantitem.b() && !this.player.isSpectator()) { + this.player.containerMenu.a((EntityHuman) this.player, packetplayinenchantitem.c()); +@@ -1484,6 +2506,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.defaultContainer.getSlot(packetplayinsetcreativeslot.b()).getItem(), packetplayinsetcreativeslot.getItemStack()))) { // Insist on valid slot ++ if (flag || (flag1 && !ItemStack.matches(this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.b()).getItem(), packetplayinsetcreativeslot.getItemStack()))) { // Insist on valid slot + // CraftBukkit start - Call click event -+ InventoryView inventory = this.player.defaultContainer.getBukkitView(); ++ InventoryView inventory = this.player.inventoryMenu.getBukkitView(); + org.bukkit.inventory.ItemStack item = CraftItemStack.asBukkitCopy(packetplayinsetcreativeslot.getItemStack()); + + SlotType type = SlotType.QUICKBAR; @@ -1582,7 +1551,7 @@ + } + } + InventoryCreativeEvent event = new InventoryCreativeEvent(inventory, type, flag ? -999 : packetplayinsetcreativeslot.b(), item); -+ server.getPluginManager().callEvent(event); ++ cserver.getPluginManager().callEvent(event); + + itemstack = CraftItemStack.asNMSCopy(event.getCursor()); + @@ -1596,8 +1565,8 @@ + case DENY: + // Reset the slot + if (packetplayinsetcreativeslot.b() >= 0) { -+ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.player.defaultContainer.windowId, packetplayinsetcreativeslot.b(), this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.b()).getItem())); -+ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, ItemStack.b)); ++ this.player.connection.sendPacket(new PacketPlayOutSetSlot(this.player.inventoryMenu.containerId, packetplayinsetcreativeslot.b(), this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.b()).getItem())); ++ this.player.connection.sendPacket(new PacketPlayOutSetSlot(-1, -1, ItemStack.EMPTY)); + } + return; + } @@ -1606,71 +1575,73 @@ if (flag1 && flag2) { if (itemstack.isEmpty()) { -@@ -1476,6 +2572,7 @@ - @Override - public void a(PacketPlayInTransaction packetplayintransaction) { - PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.getWorldServer()); -+ if (this.player.isFrozen()) return; // CraftBukkit - int i = this.player.activeContainer.windowId; - - if (i == packetplayintransaction.b() && this.k.getOrDefault(i, (short) (packetplayintransaction.c() + 1)) == packetplayintransaction.c() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { -@@ -1494,6 +2591,7 @@ +@@ -1511,6 +2570,7 @@ } - private void a(PacketPlayInUpdateSign packetplayinupdatesign, List list) { + private void a(PacketPlayInUpdateSign packetplayinupdatesign, List list) { + if (this.player.isFrozen()) return; // CraftBukkit this.player.resetIdleTimer(); WorldServer worldserver = this.player.getWorldServer(); BlockPosition blockposition = packetplayinupdatesign.b(); -@@ -1510,12 +2608,28 @@ +@@ -1527,18 +2587,37 @@ - if (!tileentitysign.d() || tileentitysign.f() != this.player) { + 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 return; } + // CraftBukkit start -+ Player player = this.server.getPlayer(this.player); ++ Player player = this.cserver.getPlayer(this.player); + int x = packetplayinupdatesign.b().getX(); + int y = packetplayinupdatesign.b().getY(); + int z = packetplayinupdatesign.b().getZ(); + String[] lines = new String[4]; + for (int i = 0; i < list.size(); ++i) { -- tileentitysign.a(i, new ChatComponentText((String) list.get(i))); -+ lines[i] = EnumChatFormat.a(new ChatComponentText(EnumChatFormat.a((String) list.get(i))).getString()); - } -+ SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.server.getPlayer(this.player), lines); -+ this.server.getPluginManager().callEvent(event); + 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()); + } 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()); ++ } ++ } ++ SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.cserver.getPlayer(this.player), lines); ++ this.cserver.getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ System.arraycopy(org.bukkit.craftbukkit.block.CraftSign.sanitizeLines(event.getLines()), 0, tileentitysign.lines, 0, 4); ++ IChatBaseComponent[] components = org.bukkit.craftbukkit.block.CraftSign.sanitizeLines(event.getLines()); ++ for (int i = 0; i < components.length; i++) { ++ tileentitysign.a(i, components[i]); + } + tileentitysign.isEditable = false; -+ } + } + // CraftBukkit end tileentitysign.update(); worldserver.notify(blockposition, iblockdata, iblockdata, 3); -@@ -1525,6 +2639,7 @@ +@@ -1548,6 +2627,7 @@ @Override public void a(PacketPlayInKeepAlive packetplayinkeepalive) { + PlayerConnectionUtils.ensureMainThread(packetplayinkeepalive, this, this.player.getWorldServer()); // CraftBukkit - if (this.awaitingKeepAlive && packetplayinkeepalive.b() == this.h) { - int i = (int) (SystemUtils.getMonotonicMillis() - this.lastKeepAlive); + if (this.keepAlivePending && packetplayinkeepalive.b() == this.keepAliveChallenge) { + int i = (int) (SystemUtils.getMonotonicMillis() - this.keepAliveTime); -@@ -1539,7 +2654,17 @@ +@@ -1562,7 +2642,17 @@ @Override public void a(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer()); -- this.player.abilities.isFlying = packetplayinabilities.isFlying() && this.player.abilities.canFly; +- this.player.getAbilities().flying = packetplayinabilities.isFlying() && this.player.getAbilities().mayfly; + // CraftBukkit start -+ if (this.player.abilities.canFly && this.player.abilities.isFlying != packetplayinabilities.isFlying()) { -+ PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this.server.getPlayer(this.player), packetplayinabilities.isFlying()); -+ this.server.getPluginManager().callEvent(event); ++ if (this.player.getAbilities().mayfly && this.player.getAbilities().flying != packetplayinabilities.isFlying()) { ++ PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this.cserver.getPlayer(this.player), packetplayinabilities.isFlying()); ++ this.cserver.getPluginManager().callEvent(event); + if (!event.isCancelled()) { -+ this.player.abilities.isFlying = packetplayinabilities.isFlying(); // Actually set the player's flying status ++ this.player.getAbilities().flying = packetplayinabilities.isFlying(); // Actually set the player's flying status + } else { + this.player.updateAbilities(); // Tell the player their ability was reverted + } @@ -1679,7 +1650,7 @@ } @Override -@@ -1548,8 +2673,50 @@ +@@ -1571,8 +2661,50 @@ this.player.a(packetplayinsettings); } @@ -1692,7 +1663,7 @@ + @Override + public void a(PacketPlayInCustomPayload packetplayincustompayload) { + PlayerConnectionUtils.ensureMainThread(packetplayincustompayload, this, this.player.getWorldServer()); -+ if (packetplayincustompayload.tag.equals(CUSTOM_REGISTER)) { ++ 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")) { @@ -1702,7 +1673,7 @@ + PlayerConnection.LOGGER.error("Couldn\'t register custom payload", ex); + this.disconnect("Invalid payload REGISTER!"); + } -+ } else if (packetplayincustompayload.tag.equals(CUSTOM_UNREGISTER)) { ++ } else if (packetplayincustompayload.identifier.equals(CUSTOM_UNREGISTER)) { + try { + String channels = packetplayincustompayload.data.toString(com.google.common.base.Charsets.UTF_8); + for (String channel : channels.split("\0")) { @@ -1716,7 +1687,7 @@ + try { + byte[] data = new byte[packetplayincustompayload.data.readableBytes()]; + packetplayincustompayload.data.readBytes(data); -+ server.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.tag.toString(), data); ++ cserver.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.identifier.toString(), data); + } catch (Exception ex) { + PlayerConnection.LOGGER.error("Couldn\'t dispatch custom payload", ex); + this.disconnect("Invalid custom payload!"); @@ -1726,7 +1697,7 @@ + } + + public final boolean isDisconnected() { -+ return !this.player.joining && !this.networkManager.isConnected(); ++ return !this.player.joining && !this.connection.isConnected(); + } + // CraftBukkit end diff --git a/nms-patches/net/minecraft/server/network/ServerConnection.patch b/nms-patches/net/minecraft/server/network/ServerConnection.patch index 0aeabee45..6e7aa6b81 100644 --- a/nms-patches/net/minecraft/server/network/ServerConnection.patch +++ b/nms-patches/net/minecraft/server/network/ServerConnection.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/server/network/ServerConnection.java +++ b/net/minecraft/server/network/ServerConnection.java -@@ -87,14 +87,24 @@ - int j = ServerConnection.this.e.k(); +@@ -96,14 +96,24 @@ + int j = ServerConnection.this.server.l(); Object object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND); -- ServerConnection.this.connectedChannels.add(object); -+ ServerConnection.this.connectedChannels.add((NetworkManager) object); // CraftBukkit - decompile error +- 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.e, (NetworkManager) object)); + ((NetworkManager) object).setPacketListener(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 @@ -16,14 +16,14 @@ + // CraftBukkit start + public void acceptConnections() { -+ synchronized (this.listeningChannels) { -+ for (ChannelFuture future : this.listeningChannels) { ++ synchronized (this.channels) { ++ for (ChannelFuture future : this.channels) { + future.channel().config().setAutoRead(true); + } + } + } + // CraftBukkit end + - public void b() { - this.c = false; - Iterator iterator = this.listeningChannels.iterator(); + public SocketAddress a() { + List list = this.channels; + ChannelFuture channelfuture; diff --git a/nms-patches/net/minecraft/server/players/ExpirableListEntry.patch b/nms-patches/net/minecraft/server/players/ExpirableListEntry.patch index 49d534a97..85fbf3f9b 100644 --- a/nms-patches/net/minecraft/server/players/ExpirableListEntry.patch +++ b/nms-patches/net/minecraft/server/players/ExpirableListEntry.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/ExpirableListEntry.java +++ b/net/minecraft/server/players/ExpirableListEntry.java -@@ -24,7 +24,7 @@ +@@ -25,7 +25,7 @@ } protected ExpirableListEntry(T t0, JsonObject jsonobject) { @@ -9,21 +9,17 @@ Date date; -@@ -75,4 +75,26 @@ - jsonobject.addProperty("expires", this.d == null ? "forever" : ExpirableListEntry.a.format(this.d)); - jsonobject.addProperty("reason", this.e); +@@ -80,4 +80,22 @@ + jsonobject.addProperty("expires", this.expires == null ? "forever" : ExpirableListEntry.DATE_FORMAT.format(this.expires)); + jsonobject.addProperty("reason", this.reason); } + + // CraftBukkit start -+ public Date getCreated() { -+ return this.b; -+ } -+ + private static T checkExpiry(T object, JsonObject jsonobject) { + Date expires = null; + + try { -+ expires = jsonobject.has("expires") ? a.parse(jsonobject.get("expires").getAsString()) : null; ++ expires = jsonobject.has("expires") ? DATE_FORMAT.parse(jsonobject.get("expires").getAsString()) : null; + } catch (ParseException ex) { + // Guess we don't have a date + } diff --git a/nms-patches/net/minecraft/server/players/JsonList.patch b/nms-patches/net/minecraft/server/players/JsonList.patch index 410490c85..c8a7aef40 100644 --- a/nms-patches/net/minecraft/server/players/JsonList.patch +++ b/nms-patches/net/minecraft/server/players/JsonList.patch @@ -1,29 +1,29 @@ --- a/net/minecraft/server/players/JsonList.java +++ b/net/minecraft/server/players/JsonList.java -@@ -52,7 +52,7 @@ +@@ -54,7 +54,7 @@ @Nullable public V get(K k0) { this.g(); -- return (JsonListEntry) this.d.get(this.a(k0)); -+ return (V) this.d.get(this.a(k0)); // CraftBukkit - fix decompile error +- return (JsonListEntry) this.map.get(this.a(k0)); ++ return (V) this.map.get(this.a(k0)); // CraftBukkit - fix decompile error } public void remove(K k0) { -@@ -74,6 +74,12 @@ - return (String[]) this.d.keySet().toArray(new String[this.d.size()]); +@@ -76,6 +76,12 @@ + return (String[]) this.map.keySet().toArray(new String[0]); } + // CraftBukkit start + public Collection getValues() { -+ return this.d.values(); ++ return this.map.values(); + } + // CraftBukkit end + public boolean isEmpty() { - return this.d.size() < 1; + return this.map.size() < 1; } -@@ -91,7 +97,7 @@ - Iterator iterator = this.d.values().iterator(); +@@ -93,7 +99,7 @@ + Iterator iterator = this.map.values().iterator(); while (iterator.hasNext()) { - V v0 = (JsonListEntry) iterator.next(); @@ -31,30 +31,35 @@ if (v0.hasExpired()) { list.add(v0.getKey()); -@@ -101,7 +107,7 @@ +@@ -103,7 +109,7 @@ iterator = list.iterator(); while (iterator.hasNext()) { - K k0 = iterator.next(); + K k0 = (K) iterator.next(); // CraftBukkit - decompile error - this.d.remove(this.a(k0)); + this.map.remove(this.a(k0)); } -@@ -121,7 +127,7 @@ +@@ -118,11 +124,11 @@ + + public void save() throws IOException { + JsonArray jsonarray = new JsonArray(); +- Stream stream = this.map.values().stream().map((jsonlistentry) -> { ++ Stream stream = this.map.values().stream().map((jsonlistentry) -> { // CraftBukkit - decompile error JsonObject jsonobject = new JsonObject(); - jsonlistentry.getClass(); + Objects.requireNonNull(jsonlistentry); - return (JsonObject) SystemUtils.a((Object) jsonobject, jsonlistentry::a); + return (JsonObject) SystemUtils.a(jsonobject, jsonlistentry::a); // CraftBukkit - decompile error - }).forEach(jsonarray::add); - BufferedWriter bufferedwriter = Files.newWriter(this.c, StandardCharsets.UTF_8); - Throwable throwable = null; + }); + + Objects.requireNonNull(jsonarray); @@ -165,7 +171,7 @@ JsonListEntry jsonlistentry = this.a(jsonobject); if (jsonlistentry.getKey() != null) { -- this.d.put(this.a(jsonlistentry.getKey()), jsonlistentry); -+ this.d.put(this.a(jsonlistentry.getKey()), (V) jsonlistentry); // CraftBukkit - fix decompile error +- this.map.put(this.a(jsonlistentry.getKey()), jsonlistentry); ++ this.map.put(this.a(jsonlistentry.getKey()), (V) jsonlistentry); // CraftBukkit - fix decompile error } } - } catch (Throwable throwable1) { + } catch (Throwable throwable) { diff --git a/nms-patches/net/minecraft/server/players/NameReferencingFileConverter.patch b/nms-patches/net/minecraft/server/players/NameReferencingFileConverter.patch index 2455a849b..932e11dfa 100644 --- a/nms-patches/net/minecraft/server/players/NameReferencingFileConverter.patch +++ b/nms-patches/net/minecraft/server/players/NameReferencingFileConverter.patch @@ -11,8 +11,8 @@ + public class NameReferencingFileConverter { - private static final Logger LOGGER = LogManager.getLogger(); -@@ -85,7 +90,7 @@ + static final Logger LOGGER = LogManager.getLogger(); +@@ -87,7 +92,7 @@ try { gameprofilebanlist.load(); } catch (IOException ioexception) { @@ -21,7 +21,7 @@ } } -@@ -143,7 +148,7 @@ +@@ -145,7 +150,7 @@ try { ipbanlist.load(); } catch (IOException ioexception) { @@ -30,7 +30,7 @@ } } -@@ -184,7 +189,7 @@ +@@ -186,7 +191,7 @@ try { oplist.load(); } catch (IOException ioexception) { @@ -39,7 +39,7 @@ } } -@@ -228,7 +233,7 @@ +@@ -230,7 +235,7 @@ try { whitelist.load(); } catch (IOException ioexception) { @@ -48,7 +48,7 @@ } } -@@ -351,6 +356,30 @@ +@@ -353,6 +358,30 @@ File file5 = new File(file, s2 + ".dat"); File file6 = new File(file4, s3 + ".dat"); @@ -76,6 +76,6 @@ + } + // CraftBukkit end + - NameReferencingFileConverter.b(file4); + NameReferencingFileConverter.a(file4); if (!file5.renameTo(file6)) { throw new NameReferencingFileConverter.FileConversionException("Could not convert file for " + s2); diff --git a/nms-patches/net/minecraft/server/players/PlayerList.patch b/nms-patches/net/minecraft/server/players/PlayerList.patch index 123b47d15..5146b6b19 100644 --- a/nms-patches/net/minecraft/server/players/PlayerList.patch +++ b/nms-patches/net/minecraft/server/players/PlayerList.patch @@ -1,21 +1,19 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -90,6 +90,27 @@ +@@ -93,6 +93,25 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start +import com.google.common.base.Predicate; -+import com.google.common.collect.Iterables; -+ ++import java.util.stream.Collectors; ++import net.minecraft.network.protocol.game.PacketPlayOutChat; +import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; +import net.minecraft.server.dedicated.DedicatedServer; +import net.minecraft.server.network.LoginListener; -+ ++import org.bukkit.Location; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; -+ -+import org.bukkit.Location; +import org.bukkit.craftbukkit.util.CraftChatMessage; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerChangedWorldEvent; @@ -27,30 +25,30 @@ + public abstract class PlayerList { - public static final File b = new File("banned-players.json"); -@@ -99,14 +120,16 @@ - private static final Logger LOGGER = LogManager.getLogger(); - private static final SimpleDateFormat g = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); + public static final File USERBANLIST_FILE = new File("banned-players.json"); +@@ -103,14 +122,16 @@ + private static final int SEND_PLAYER_INFO_INTERVAL = 600; + private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); private final MinecraftServer server; - public final List players = Lists.newArrayList(); + public final List players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety - private final Map j = Maps.newHashMap(); - private final GameProfileBanList k; - private final IpBanList l; - private final OpList operators; + private final Map playersByUUID = Maps.newHashMap(); + private final GameProfileBanList bans; + private final IpBanList ipBans; + private final OpList ops; private final WhiteList whitelist; -- private final Map o; -- private final Map p; +- private final Map stats; +- private final Map advancements; + // CraftBukkit start + // private final Map o; + // private final Map p; + // CraftBukkit end - public final WorldNBTStorage playerFileData; - private boolean hasWhitelist; - private final IRegistryCustom.Dimension s; -@@ -116,13 +139,23 @@ - private boolean v; - private int w; + public final WorldNBTStorage playerIo; + private boolean doWhiteList; + private final IRegistryCustom.Dimension registryHolder; +@@ -120,13 +141,23 @@ + private static final boolean ALLOW_LOGOUTIVATOR = false; + private int sendAllPlayerInfoIn; + // CraftBukkit start + private CraftServer cserver; @@ -61,20 +59,20 @@ + minecraftserver.reader.addCompleter(new org.bukkit.craftbukkit.command.ConsoleCommandCompleter(minecraftserver.server)); + // CraftBukkit end + - this.k = new GameProfileBanList(PlayerList.b); - this.l = new IpBanList(PlayerList.c); - this.operators = new OpList(PlayerList.d); - this.whitelist = new WhiteList(PlayerList.e); -- this.o = Maps.newHashMap(); -- this.p = Maps.newHashMap(); + this.bans = new GameProfileBanList(PlayerList.USERBANLIST_FILE); + this.ipBans = new IpBanList(PlayerList.IPBANLIST_FILE); + this.ops = new OpList(PlayerList.OPLIST_FILE); + this.whitelist = new WhiteList(PlayerList.WHITELIST_FILE); +- this.stats = Maps.newHashMap(); +- this.advancements = Maps.newHashMap(); + // CraftBukkit start + // this.o = Maps.newHashMap(); + // this.p = Maps.newHashMap(); + // CraftBukkit end this.server = minecraftserver; - this.s = iregistrycustom_dimension; + this.registryHolder = iregistrycustom_dimension; this.maxPlayers = i; -@@ -138,6 +171,12 @@ +@@ -142,6 +173,12 @@ usercache.a(gameprofile); NBTTagCompound nbttagcompound = this.a(entityplayer); ResourceKey resourcekey; @@ -86,8 +84,8 @@ + // CraftBukkit end if (nbttagcompound != null) { - DataResult dataresult = DimensionManager.a(new Dynamic(DynamicOpsNBT.a, nbttagcompound.get("Dimension"))); -@@ -168,7 +207,8 @@ + DataResult dataresult = DimensionManager.a(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("Dimension"))); +@@ -171,7 +208,8 @@ s1 = networkmanager.getSocketAddress().toString(); } @@ -96,16 +94,16 @@ + // 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(); - this.a(entityplayer, (EntityPlayer) null, worldserver1); -@@ -178,6 +218,7 @@ - boolean flag1 = gamerules.getBoolean(GameRules.REDUCED_DEBUG_INFO); + entityplayer.c(nbttagcompound); +@@ -181,6 +219,7 @@ + boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO); - playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), entityplayer.playerInteractManager.c(), BiomeManager.a(worldserver1.getSeed()), worlddata.isHardcore(), this.server.F(), this.s, worldserver1.getDimensionManager(), worldserver1.getDimensionKey(), this.getMaxPlayers(), this.viewDistance, flag1, !flag, worldserver1.isDebugWorld(), worldserver1.isFlatWorld())); + playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.gameMode.getGameMode(), entityplayer.gameMode.c(), BiomeManager.a(worldserver1.getSeed()), worlddata.isHardcore(), this.server.G(), this.registryHolder, worldserver1.getDimensionManager(), worldserver1.getDimensionKey(), this.getMaxPlayers(), this.viewDistance, flag1, !flag, worldserver1.isDebugWorld(), worldserver1.isFlatWorld())); + entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit - playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.a, (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName()))); + 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.abilities)); -@@ -196,19 +237,61 @@ + playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.getAbilities())); +@@ -199,19 +238,61 @@ } else { chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[]{entityplayer.getScoreboardDisplayName(), s}); } @@ -113,10 +111,10 @@ + chatmessage.a(EnumChatFormat.YELLOW); + String joinMessage = CraftChatMessage.fromComponent(chatmessage); -- this.sendMessage(chatmessage.a(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.b); - playerconnection.a(entityplayer.locX(), entityplayer.locY(), entityplayer.locZ(), entityplayer.yaw, entityplayer.pitch); +- this.sendMessage(chatmessage.a(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID); + playerconnection.b(entityplayer.locX(), entityplayer.locY(), entityplayer.locZ(), entityplayer.getYRot(), entityplayer.getXRot()); this.players.add(entityplayer); - this.j.put(entityplayer.getUniqueID(), 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 + @@ -124,7 +122,7 @@ + PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(cserver.getPlayer(entityplayer), joinMessage); + cserver.getPluginManager().callEvent(playerJoinEvent); + -+ if (!entityplayer.playerConnection.networkManager.isConnected()) { ++ if (!entityplayer.connection.connection.isConnected()) { + return; + } + @@ -132,7 +130,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.b)); ++ server.getPlayerList().sendAll(new PacketPlayOutChat(line, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID)); + } + } + // CraftBukkit end @@ -141,26 +139,26 @@ + PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entityplayer); for (int i = 0; i < this.players.size(); ++i) { -- entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{(EntityPlayer) this.players.get(i)})); +- entityplayer.connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{(EntityPlayer) this.players.get(i)})); + EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i); + + if (entityplayer1.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) { -+ entityplayer1.playerConnection.sendPacket(packet); ++ entityplayer1.connection.sendPacket(packet); + } + + if (!entityplayer.getBukkitEntity().canSee(entityplayer1.getBukkitEntity())) { + continue; + } + -+ entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer1})); ++ entityplayer.connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer1})); + } + entityplayer.sentListPacket = true; + // CraftBukkit end + -+ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityplayer.getId(), entityplayer.getDataWatcher(), true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn ++ entityplayer.connection.sendPacket(new PacketPlayOutEntityMetadata(entityplayer.getId(), entityplayer.getDataWatcher(), 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.world == worldserver1 && !worldserver1.getPlayers().contains(entityplayer)) { ++ if (entityplayer.level == worldserver1 && !worldserver1.getPlayers().contains(entityplayer)) { + worldserver1.addPlayerJoin(entityplayer); + this.server.getBossBattleCustomData().a(entityplayer); } @@ -171,8 +169,8 @@ + // CraftBukkit end this.a(entityplayer, worldserver1); if (!this.server.getResourcePack().isEmpty()) { - entityplayer.setResourcePack(this.server.getResourcePack(), this.server.getResourcePackHash()); -@@ -224,8 +307,11 @@ + entityplayer.setResourcePack(this.server.getResourcePack(), this.server.getResourcePackHash(), this.server.aY(), this.server.bb()); +@@ -227,8 +308,11 @@ if (nbttagcompound != null && nbttagcompound.hasKeyOfType("RootVehicle", 10)) { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle"); @@ -186,71 +184,71 @@ }); if (entity != null) { -@@ -268,6 +354,8 @@ +@@ -271,6 +355,8 @@ } entityplayer.syncInventory(); + // CraftBukkit - Moved from above, added world -+ PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), worldserver1.worldDataServer.getName(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ()); ++ PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), worldserver1.serverLevelData.getName(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ()); } public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { -@@ -300,30 +388,31 @@ +@@ -303,30 +389,31 @@ } public void setPlayerFileData(WorldServer worldserver) { -+ if (playerFileData != null) return; // CraftBukkit ++ if (playerIo != null) return; // CraftBukkit worldserver.getWorldBorder().a(new IWorldBorderListener() { @Override public void a(WorldBorder worldborder, double d0) { -- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_SIZE)); -+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_SIZE), worldborder.world); +- PlayerList.this.sendAll(new ClientboundSetBorderSizePacket(worldborder)); ++ PlayerList.this.sendAll(new ClientboundSetBorderSizePacket(worldborder), worldborder.world); // CraftBukkit } @Override public void a(WorldBorder worldborder, double d0, double d1, long i) { -- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.LERP_SIZE)); -+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.LERP_SIZE), worldborder.world); +- PlayerList.this.sendAll(new ClientboundSetBorderLerpSizePacket(worldborder)); ++ PlayerList.this.sendAll(new ClientboundSetBorderLerpSizePacket(worldborder), worldborder.world); // CraftBukkit } @Override public void a(WorldBorder worldborder, double d0, double d1) { -- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_CENTER)); -+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_CENTER), worldborder.world); +- PlayerList.this.sendAll(new ClientboundSetBorderCenterPacket(worldborder)); ++ PlayerList.this.sendAll(new ClientboundSetBorderCenterPacket(worldborder), worldborder.world); // CraftBukkit } @Override public void a(WorldBorder worldborder, int i) { -- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_TIME)); -+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_TIME), worldborder.world); +- PlayerList.this.sendAll(new ClientboundSetBorderWarningDelayPacket(worldborder)); ++ PlayerList.this.sendAll(new ClientboundSetBorderWarningDelayPacket(worldborder), worldborder.world); // CraftBukkit } @Override public void b(WorldBorder worldborder, int i) { -- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_BLOCKS)); -+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_BLOCKS), worldborder.world); +- PlayerList.this.sendAll(new ClientboundSetBorderWarningDistancePacket(worldborder)); ++ PlayerList.this.sendAll(new ClientboundSetBorderWarningDistancePacket(worldborder), worldborder.world); // CraftBukkit } @Override -@@ -351,14 +440,15 @@ +@@ -354,14 +441,15 @@ } protected void savePlayerFile(EntityPlayer entityplayer) { + if (!entityplayer.getBukkitEntity().isPersistent()) return; // CraftBukkit - this.playerFileData.save(entityplayer); -- ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) this.o.get(entityplayer.getUniqueID()); + this.playerIo.save(entityplayer); +- ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) this.stats.get(entityplayer.getUniqueID()); + ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) entityplayer.getStatisticManager(); // CraftBukkit if (serverstatisticmanager != null) { serverstatisticmanager.save(); } -- AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.p.get(entityplayer.getUniqueID()); +- AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.advancements.get(entityplayer.getUniqueID()); + AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit if (advancementdataplayer != null) { advancementdataplayer.b(); -@@ -366,10 +456,24 @@ +@@ -369,10 +457,24 @@ } @@ -262,7 +260,7 @@ + + // 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.activeContainer != entityplayer.defaultContainer) { ++ if (entityplayer.containerMenu != entityplayer.inventoryMenu) { + entityplayer.closeInventory(); + } + @@ -276,19 +274,18 @@ this.savePlayerFile(entityplayer); if (entityplayer.isPassenger()) { Entity entity = entityplayer.getRootVehicle(); -@@ -401,18 +505,66 @@ +@@ -396,18 +498,66 @@ if (entityplayer1 == entityplayer) { - this.j.remove(uuid); -- this.o.remove(uuid); -- this.p.remove(uuid); + this.playersByUUID.remove(uuid); +- this.stats.remove(uuid); +- this.advancements.remove(uuid); + // CraftBukkit start + // this.o.remove(uuid); + // this.p.remove(uuid); + // CraftBukkit end - } - -- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer})); ++ } ++ + // CraftBukkit start + // this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer})); + PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityplayer); @@ -296,15 +293,16 @@ + EntityPlayer entityplayer2 = (EntityPlayer) this.players.get(i); + + if (entityplayer2.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) { -+ entityplayer2.playerConnection.sendPacket(packet); ++ entityplayer2.connection.sendPacket(packet); + } else { + entityplayer2.getBukkitEntity().removeDisconnectingPlayer(entityplayer.getBukkitEntity()); + } -+ } + } + // This removes the scoreboard (and player reference) for the specific player in the manager + cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity()); + // CraftBukkit end -+ + +- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer})); + return playerQuitEvent.getQuitMessage(); // CraftBukkit } @@ -314,7 +312,7 @@ + public EntityPlayer attemptLogin(LoginListener loginlistener, GameProfile gameprofile, String hostname) { ChatMessage chatmessage; -- if (this.k.isBanned(gameprofile)) { +- if (this.bans.isBanned(gameprofile)) { + // Moved from processLogin + UUID uuid = EntityHuman.a(gameprofile); + List list = Lists.newArrayList(); @@ -333,24 +331,24 @@ + while (iterator.hasNext()) { + entityplayer = (EntityPlayer) iterator.next(); + savePlayerFile(entityplayer); // CraftBukkit - Force the player's inventory to be saved -+ entityplayer.playerConnection.disconnect(new ChatMessage("multiplayer.disconnect.duplicate_login", new Object[0])); ++ 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.networkManager.getSocketAddress(); ++ SocketAddress socketaddress = loginlistener.connection.getSocketAddress(); + -+ EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(World.OVERWORLD), gameprofile, new PlayerInteractManager(this.server.getWorldServer(World.OVERWORLD))); ++ EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(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()) { - GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.k.get(gameprofile); + GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile); chatmessage = new ChatMessage("multiplayer.disconnect.banned.reason", new Object[]{gameprofilebanentry.getReason()}); -@@ -420,10 +572,12 @@ - chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned.expiration", new Object[]{PlayerList.g.format(gameprofilebanentry.getExpires())})); +@@ -415,10 +565,12 @@ + chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned.expiration", new Object[]{PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())})); } - return chatmessage; @@ -358,33 +356,33 @@ + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage)); } else if (!this.isWhitelisted(gameprofile)) { - return new ChatMessage("multiplayer.disconnect.not_whitelisted"); -- } else if (this.l.isBanned(socketaddress)) { +- } 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()) { - IpBanEntry ipbanentry = this.l.get(socketaddress); + IpBanEntry ipbanentry = this.ipBans.get(socketaddress); chatmessage = new ChatMessage("multiplayer.disconnect.banned_ip.reason", new Object[]{ipbanentry.getReason()}); -@@ -431,13 +585,25 @@ - chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned_ip.expiration", new Object[]{PlayerList.g.format(ipbanentry.getExpires())})); +@@ -426,13 +578,25 @@ + chatmessage.addSibling(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.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null; -+ // return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null; -+ if (this.players.size() >= this.maxPlayers && !this.f(gameprofile)) { +- 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)) { + event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full"); + } -+ } + } + + cserver.getPluginManager().callEvent(event); + if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) { + loginlistener.disconnect(event.getKickMessage()); + return null; - } ++ } + return entity; } @@ -394,10 +392,10 @@ UUID uuid = EntityHuman.a(gameprofile); List list = Lists.newArrayList(); -@@ -473,14 +639,24 @@ +@@ -459,14 +623,24 @@ } - return new EntityPlayer(this.server, worldserver, gameprofile, (PlayerInteractManager) object); + return new EntityPlayer(this.server, this.server.F(), gameprofile); + */ + return player; + // CraftBukkit end @@ -411,7 +409,7 @@ + public EntityPlayer moveToWorld(EntityPlayer entityplayer, WorldServer worldserver, boolean flag, Location location, boolean avoidSuffocation) { + entityplayer.stopRiding(); // CraftBukkit this.players.remove(entityplayer); - entityplayer.getWorldServer().removePlayer(entityplayer); + entityplayer.getWorldServer().a(entityplayer, Entity.RemovalReason.DISCARDED); BlockPosition blockposition = entityplayer.getSpawn(); float f = entityplayer.getSpawnAngle(); boolean flag1 = entityplayer.isSpawnForced(); @@ -419,24 +417,20 @@ WorldServer worldserver = this.server.getWorldServer(entityplayer.getSpawnDimension()); Optional optional; -@@ -500,6 +676,11 @@ - } +@@ -478,6 +652,11 @@ - EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getProfile(), (PlayerInteractManager) object); + WorldServer worldserver1 = worldserver != null && optional.isPresent() ? worldserver : this.server.F(); + EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getProfile()); + // */ + EntityPlayer entityplayer1 = entityplayer; + org.bukkit.World fromWorld = entityplayer.getBukkitEntity().getWorld(); -+ entityplayer.viewingCredits = false; ++ entityplayer.wonGame = false; + // CraftBukkit end - entityplayer1.playerConnection = entityplayer.playerConnection; + entityplayer1.connection = entityplayer.connection; entityplayer1.copyFrom(entityplayer, flag); -@@ -513,52 +694,113 @@ - entityplayer1.addScoreboardTag(s); - } +@@ -493,49 +672,110 @@ -- this.a(entityplayer1, entityplayer, worldserver1); -+ // this.a(entityplayer1, entityplayer, worldserver1); // CraftBukkit - removed boolean flag2 = false; - if (optional.isPresent()) { @@ -472,30 +466,30 @@ + } else { + Vec3D vec3d1 = Vec3D.c((BaseBlockPosition) blockposition).d(vec3d).d(); + -+ f1 = (float) MathHelper.g(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.g(MathHelper.d(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); ++ + entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), 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.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.a, 0.0F)); ++ entityplayer1.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); + } ++ } + +- f1 = (float) MathHelper.f(MathHelper.d(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); ++ if (location == null) { ++ worldserver1 = this.server.getWorldServer(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); - flag2 = !flag && flag3; - } else if (blockposition != null) { -- entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.a, 0.0F)); -+ if (location == null) { -+ worldserver1 = this.server.getWorldServer(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.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); + Player respawnPlayer = cserver.getPlayer(entityplayer1); + PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !flag2, flag2); + cserver.getPluginManager().callEvent(respawnEvent); @@ -509,48 +503,48 @@ + entityplayer1.forceSetPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + // CraftBukkit end -- while (!worldserver1.getCubes(entityplayer1) && entityplayer1.locY() < 256.0D) { -+ while (avoidSuffocation && !worldserver1.getCubes(entityplayer1) && entityplayer1.locY() < 256.0D) { +- 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()); } + // CraftBukkit start + WorldData worlddata = worldserver1.getWorldData(); -+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver1.getDimensionManager(), worldserver1.getDimensionKey(), BiomeManager.a(worldserver1.getSeed()), entityplayer1.playerInteractManager.getGameMode(), entityplayer1.playerInteractManager.c(), worldserver1.isDebugWorld(), worldserver1.isFlatWorld(), flag)); ++ entityplayer1.connection.sendPacket(new PacketPlayOutRespawn(worldserver1.getDimensionManager(), worldserver1.getDimensionKey(), BiomeManager.a(worldserver1.getSeed()), entityplayer1.gameMode.getGameMode(), entityplayer1.gameMode.c(), worldserver1.isDebugWorld(), worldserver1.isFlatWorld(), flag)); + entityplayer1.spawnIn(worldserver1); -+ entityplayer1.dead = false; -+ entityplayer1.playerConnection.teleport(new Location(worldserver1.getWorld(), entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch)); ++ entityplayer1.unsetRemoved(); ++ entityplayer1.connection.teleport(new Location(worldserver1.getWorld(), entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.getYRot(), entityplayer1.getXRot())); + entityplayer1.setSneaking(false); -- WorldData worlddata = entityplayer1.world.getWorldData(); +- WorldData worlddata = entityplayer1.level.getWorldData(); - -- entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(entityplayer1.world.getDimensionManager(), entityplayer1.world.getDimensionKey(), BiomeManager.a(entityplayer1.getWorldServer().getSeed()), entityplayer1.playerInteractManager.getGameMode(), entityplayer1.playerInteractManager.c(), entityplayer1.getWorldServer().isDebugWorld(), entityplayer1.getWorldServer().isFlatWorld(), flag)); -- entityplayer1.playerConnection.a(entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch); -+ // entityplayer1.playerConnection.a(entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch); - entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(worldserver1.getSpawn(), worldserver1.v())); - entityplayer1.playerConnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); - entityplayer1.playerConnection.sendPacket(new PacketPlayOutExperience(entityplayer1.exp, entityplayer1.expTotal, entityplayer1.expLevel)); +- 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); - this.players.add(entityplayer1); -- this.j.put(entityplayer1.getUniqueID(), entityplayer1); +- this.playersByUUID.put(entityplayer1.getUniqueID(), entityplayer1); - entityplayer1.syncInventory(); -+ if (!entityplayer.playerConnection.isDisconnected()) { ++ if (!entityplayer.connection.isDisconnected()) { + worldserver1.addPlayerRespawn(entityplayer1); + this.players.add(entityplayer1); -+ this.j.put(entityplayer1.getUniqueID(), entityplayer1); ++ this.playersByUUID.put(entityplayer1.getUniqueID(), entityplayer1); + } + // entityplayer1.syncInventory(); entityplayer1.setHealth(entityplayer1.getHealth()); if (flag2) { - entityplayer1.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.BLOCK_RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F)); + entityplayer1.connection.sendPacket(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.playerConnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobEffect)); ++ entityplayer.connection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobEffect)); + } + + // Fire advancement trigger @@ -563,34 +557,34 @@ + } + // Save player file again if they were disconnected -+ if (entityplayer.playerConnection.isDisconnected()) { ++ if (entityplayer.connection.isDisconnected()) { + this.savePlayerFile(entityplayer); + } + // CraftBukkit end return entityplayer1; } -@@ -571,7 +813,18 @@ +@@ -548,7 +788,18 @@ public void tick() { - if (++this.w > 600) { + if (++this.sendAllPlayerInfoIn > 600) { - this.sendAll(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.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, Iterables.filter(this.players, new Predicate() { ++ target.connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players.stream().filter(new Predicate() { + @Override + public boolean apply(EntityPlayer input) { + return target.getBukkitEntity().canSee(input.getBukkitEntity()); + } -+ }))); ++ }).collect(Collectors.toList()))); + } + // CraftBukkit end - this.w = 0; + this.sendAllPlayerInfoIn = 0; } -@@ -584,6 +837,25 @@ +@@ -565,6 +816,25 @@ } @@ -601,30 +595,30 @@ + if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) { + continue; + } -+ ((EntityPlayer) this.players.get(i)).playerConnection.sendPacket(packet); ++ ((EntityPlayer) this.players.get(i)).connection.sendPacket(packet); + } + } + + public void sendAll(Packet packet, World world) { + for (int i = 0; i < world.getPlayers().size(); ++i) { -+ ((EntityPlayer) world.getPlayers().get(i)).playerConnection.sendPacket(packet); ++ ((EntityPlayer) world.getPlayers().get(i)).connection.sendPacket(packet); + } + + } + // CraftBukkit end + public void a(Packet packet, ResourceKey resourcekey) { - for (int i = 0; i < this.players.size(); ++i) { - EntityPlayer entityplayer = (EntityPlayer) this.players.get(i); -@@ -684,6 +956,7 @@ - entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, b0)); + Iterator iterator = this.players.iterator(); + +@@ -667,6 +937,7 @@ + entityplayer.connection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, b0)); } + entityplayer.getBukkitEntity().recalculatePermissions(); // CraftBukkit this.server.getCommandDispatcher().a(entityplayer); } -@@ -716,6 +989,12 @@ +@@ -699,6 +970,12 @@ for (int i = 0; i < this.players.size(); ++i) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(i); @@ -634,23 +628,23 @@ + } + // CraftBukkit end + - if (entityplayer != entityhuman && entityplayer.world.getDimensionKey() == resourcekey) { + if (entityplayer != entityhuman && entityplayer.level.getDimensionKey() == resourcekey) { double d4 = d0 - entityplayer.locX(); double d5 = d1 - entityplayer.locY(); -@@ -755,23 +1034,34 @@ +@@ -738,23 +1015,34 @@ public void reloadWhitelist() {} public void a(EntityPlayer entityplayer, WorldServer worldserver) { -- WorldBorder worldborder = this.server.E().getWorldBorder(); -+ WorldBorder worldborder = entityplayer.world.getWorldBorder(); // CraftBukkit +- WorldBorder worldborder = this.server.F().getWorldBorder(); ++ WorldBorder worldborder = entityplayer.level.getWorldBorder(); // CraftBukkit - entityplayer.playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE)); - entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))); - entityplayer.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(worldserver.getSpawn(), worldserver.v())); + 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())); if (worldserver.isRaining()) { -- 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.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))); + // 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))); @@ -663,62 +657,52 @@ } public void updateClient(EntityPlayer entityplayer) { - entityplayer.updateInventory(entityplayer.defaultContainer); + entityplayer.inventoryMenu.updateInventory(); - entityplayer.triggerHealthUpdate(); + // entityplayer.triggerHealthUpdate(); + entityplayer.getBukkitEntity().updateScaledHealth(); // CraftBukkit - Update scaled health on respawn and worldchange - entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex)); + entityplayer.connection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().selected)); + // CraftBukkit start - from GameRules -+ int i = entityplayer.world.getGameRules().getBoolean(GameRules.REDUCED_DEBUG_INFO) ? 22 : 23; -+ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) i)); -+ float immediateRespawn = entityplayer.world.getGameRules().getBoolean(GameRules.DO_IMMEDIATE_RESPAWN) ? 1.0F: 0.0F; -+ entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.l, immediateRespawn)); ++ int i = entityplayer.level.getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23; ++ entityplayer.connection.sendPacket(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)); + // CraftBukkit end } public int getPlayerCount() { -@@ -824,31 +1114,54 @@ - entityplayer.playerInteractManager.a(this.u, EnumGamemode.NOT_SET); - } - -- entityplayer.playerInteractManager.b(worldserver.getMinecraftServer().getSaveData().getGameType()); -+ entityplayer.playerInteractManager.b(worldserver.worldDataServer.getGameType()); // CraftBukkit +@@ -805,12 +1093,22 @@ } public void shutdown() { - for (int i = 0; i < this.players.size(); ++i) { -- ((EntityPlayer) this.players.get(i)).playerConnection.disconnect(new ChatMessage("multiplayer.disconnect.server_shutdown")); +- ((EntityPlayer) this.players.get(i)).connection.disconnect(new ChatMessage("multiplayer.disconnect.server_shutdown")); + // CraftBukkit start - disconnect safely + for (EntityPlayer player : this.players) { -+ player.playerConnection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message ++ player.connection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message } + // CraftBukkit end -+ -+ } + + } + // CraftBukkit start + public void sendMessage(IChatBaseComponent[] iChatBaseComponents) { + for (IChatBaseComponent component : iChatBaseComponents) { -+ sendMessage(component, ChatMessageType.SYSTEM, SystemUtils.b); ++ sendMessage(component, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID); + } - } ++ } + // CraftBukkit end - ++ public void sendMessage(IChatBaseComponent ichatbasecomponent, ChatMessageType chatmessagetype, UUID uuid) { this.server.sendMessage(ichatbasecomponent, uuid); -- this.sendAll(new PacketPlayOutChat(ichatbasecomponent, chatmessagetype, uuid)); -+ // CraftBukkit start - we run this through our processor first so we can get web links etc -+ this.sendAll(new PacketPlayOutChat(CraftChatMessage.fixComponent(ichatbasecomponent), chatmessagetype, uuid)); -+ // CraftBukkit end -+ } -+ -+ public void sendMessage(IChatBaseComponent ichatbasecomponent) { -+ this.sendMessage(ichatbasecomponent, ChatMessageType.SYSTEM, SystemUtils.b); + Iterator iterator = this.players.iterator(); +@@ -838,16 +1136,23 @@ + } - public ServerStatisticManager getStatisticManager(EntityHuman entityhuman) { - UUID uuid = entityhuman.getUniqueID(); -- ServerStatisticManager serverstatisticmanager = uuid == null ? null : (ServerStatisticManager) this.o.get(uuid); +- ServerStatisticManager serverstatisticmanager = uuid == null ? null : (ServerStatisticManager) this.stats.get(uuid); + // CraftBukkit start + public ServerStatisticManager getStatisticManager(EntityPlayer entityhuman) { + ServerStatisticManager serverstatisticmanager = entityhuman.getStatisticManager(); @@ -731,7 +715,7 @@ + // CraftBukkit end if (serverstatisticmanager == null) { - File file = this.server.a(SavedFile.STATS).toFile(); + File file = this.server.a(SavedFile.PLAYER_STATS_DIR).toFile(); File file1 = new File(file, uuid + ".json"); if (!file1.exists()) { @@ -740,37 +724,37 @@ if (file2.exists() && file2.isFile()) { file2.renameTo(file1); -@@ -856,7 +1169,7 @@ +@@ -855,7 +1160,7 @@ } serverstatisticmanager = new ServerStatisticManager(this.server, file1); -- this.o.put(uuid, serverstatisticmanager); +- this.stats.put(uuid, serverstatisticmanager); + // this.o.put(uuid, serverstatisticmanager); // CraftBukkit } return serverstatisticmanager; -@@ -864,14 +1177,14 @@ +@@ -863,14 +1168,14 @@ public AdvancementDataPlayer f(EntityPlayer entityplayer) { UUID uuid = entityplayer.getUniqueID(); -- AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.p.get(uuid); +- AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.advancements.get(uuid); + AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit if (advancementdataplayer == null) { - File file = this.server.a(SavedFile.ADVANCEMENTS).toFile(); + File file = this.server.a(SavedFile.PLAYER_ADVANCEMENTS_DIR).toFile(); File file1 = new File(file, uuid + ".json"); advancementdataplayer = new AdvancementDataPlayer(this.server.getDataFixer(), this, this.server.getAdvancementData(), file1, entityplayer); -- this.p.put(uuid, advancementdataplayer); +- this.advancements.put(uuid, advancementdataplayer); + // this.p.put(uuid, advancementdataplayer); // CraftBukkit } advancementdataplayer.a(entityplayer); -@@ -907,13 +1220,20 @@ +@@ -906,13 +1211,20 @@ } public void reload() { -- Iterator iterator = this.p.values().iterator(); +- Iterator iterator = this.advancements.values().iterator(); + // CraftBukkit start + /*Iterator iterator = this.p.values().iterator(); @@ -786,5 +770,5 @@ } + // CraftBukkit end - this.sendAll(new PacketPlayOutTags(this.server.getTagRegistry())); + this.sendAll(new PacketPlayOutTags(this.server.getTagRegistry().a((IRegistryCustom) this.registryHolder))); PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(this.server.getCraftingManager().b()); diff --git a/nms-patches/net/minecraft/server/players/SleepStatus.patch b/nms-patches/net/minecraft/server/players/SleepStatus.patch new file mode 100644 index 000000000..731c69e53 --- /dev/null +++ b/nms-patches/net/minecraft/server/players/SleepStatus.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/server/players/SleepStatus.java ++++ b/net/minecraft/server/players/SleepStatus.java +@@ -18,7 +18,7 @@ + } + + public boolean a(int i, List list) { +- int j = (int) list.stream().filter(EntityHuman::isDeeplySleeping).count(); ++ int j = (int) list.stream().filter((eh) -> { return eh.isDeeplySleeping() || eh.fauxSleeping; }).count(); // CraftBukkit + + return j >= this.b(i); + } +@@ -46,7 +46,7 @@ + while (iterator.hasNext()) { + EntityPlayer entityplayer = (EntityPlayer) iterator.next(); + +- if (!entityplayer.isSpectator()) { ++ if (!entityplayer.isSpectator() && !entityplayer.fauxSleeping) { // CraftBukkit + ++this.activePlayers; + if (entityplayer.isSleeping()) { + ++this.sleepingPlayers; diff --git a/nms-patches/net/minecraft/server/players/UserCache.patch b/nms-patches/net/minecraft/server/players/UserCache.patch index a21ba9b68..b2bf0ef54 100644 --- a/nms-patches/net/minecraft/server/players/UserCache.patch +++ b/nms-patches/net/minecraft/server/players/UserCache.patch @@ -5,7 +5,7 @@ package net.minecraft.server.players; import com.google.common.collect.ImmutableList; -@@ -83,7 +84,7 @@ +@@ -92,7 +93,7 @@ } public void onProfileLookupFailed(GameProfile gameprofile, Exception exception) { diff --git a/nms-patches/net/minecraft/server/rcon/RemoteControlCommandListener.patch b/nms-patches/net/minecraft/server/rcon/RemoteControlCommandListener.patch index 9b6277bfd..d647a378c 100644 --- a/nms-patches/net/minecraft/server/rcon/RemoteControlCommandListener.patch +++ b/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 -@@ -36,6 +36,17 @@ - return new CommandListenerWrapper(this, Vec3D.b((BaseBlockPosition) worldserver.getSpawn()), Vec2F.a, worldserver, 4, "Rcon", RemoteControlCommandListener.b, this.server, (Entity) null); +@@ -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); } + // CraftBukkit start - Send a String diff --git a/nms-patches/net/minecraft/stats/RecipeBookServer.patch b/nms-patches/net/minecraft/stats/RecipeBookServer.patch index 15ef87acf..821de7dc8 100644 --- a/nms-patches/net/minecraft/stats/RecipeBookServer.patch +++ b/nms-patches/net/minecraft/stats/RecipeBookServer.patch @@ -8,21 +8,21 @@ + public class RecipeBookServer extends RecipeBook { - private static final Logger LOGGER = LogManager.getLogger(); -@@ -35,7 +37,7 @@ + public static final String RECIPE_BOOK_TAG = "recipeBook"; +@@ -36,7 +38,7 @@ IRecipe irecipe = (IRecipe) iterator.next(); MinecraftKey minecraftkey = irecipe.getKey(); -- if (!this.recipes.contains(minecraftkey) && !irecipe.isComplex()) { -+ if (!this.recipes.contains(minecraftkey) && !irecipe.isComplex() && CraftEventFactory.handlePlayerRecipeListUpdateEvent(entityplayer, minecraftkey)) { // CraftBukkit +- 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); list.add(minecraftkey); -@@ -69,6 +71,7 @@ +@@ -70,6 +72,7 @@ } private void a(PacketPlayOutRecipes.Action packetplayoutrecipes_action, EntityPlayer entityplayer, List list) { -+ if (entityplayer.playerConnection == null) return; // SPIGOT-4478 during PlayerLoginEvent - entityplayer.playerConnection.sendPacket(new PacketPlayOutRecipes(packetplayoutrecipes_action, list, Collections.emptyList(), this.a())); ++ if (entityplayer.connection == null) return; // SPIGOT-4478 during PlayerLoginEvent + entityplayer.connection.sendPacket(new PacketPlayOutRecipes(packetplayoutrecipes_action, list, Collections.emptyList(), this.a())); } diff --git a/nms-patches/net/minecraft/stats/ServerStatisticManager.patch b/nms-patches/net/minecraft/stats/ServerStatisticManager.patch index 3b7f07a52..71b6afb94 100644 --- a/nms-patches/net/minecraft/stats/ServerStatisticManager.patch +++ b/nms-patches/net/minecraft/stats/ServerStatisticManager.patch @@ -5,7 +5,7 @@ package net.minecraft.stats; import com.google.common.collect.Maps; -@@ -158,13 +159,12 @@ +@@ -161,13 +162,12 @@ } private Optional> a(StatisticWrapper statisticwrapper, String s) { @@ -15,9 +15,9 @@ + Optional optional = Optional.ofNullable(MinecraftKey.a(s)); + IRegistry iregistry = statisticwrapper.getRegistry(); -- iregistry.getClass(); +- Objects.requireNonNull(iregistry); - optional = optional.flatMap(iregistry::getOptional); -- statisticwrapper.getClass(); +- Objects.requireNonNull(statisticwrapper); - return optional.map(statisticwrapper::b); + return optional.flatMap(iregistry::getOptional).map(statisticwrapper::b); + // CraftBukkit - decompile error end diff --git a/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch b/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch index 9b839bf65..ecdefd48b 100644 --- a/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch +++ b/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/util/datafix/DataConverterRegistry.java +++ b/net/minecraft/util/datafix/DataConverterRegistry.java -@@ -367,6 +367,18 @@ +@@ -380,6 +380,18 @@ datafixerbuilder.addFixer(new DataConverterItemFrame(schema46, false)); - Schema schema47 = datafixerbuilder.addSchema(1458, DataConverterRegistry.b); + Schema schema47 = datafixerbuilder.addSchema(1458, DataConverterRegistry.SAME_NAMESPACED); + // CraftBukkit start + datafixerbuilder.addFixer(new com.mojang.datafixers.DataFix(schema47, false) { @@ -19,3 +19,27 @@ datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema47, false)); datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema47, false)); datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema47, false)); +@@ -693,17 +705,20 @@ + 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); +- ImmutableMap immutablemap = ImmutableMap.builder().put("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block").put("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block").put("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block").put("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper").put("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper").put("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper").put("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs").put("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs").put("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs").put("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab").put("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab").put("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab").put("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper").put("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper").put("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper").put("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper").put("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs").put("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs").put("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab").put("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab").build(); ++ // CraftBukkit - decompile error ++ ImmutableMap immutablemap = ImmutableMap.builder().put("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block").put("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block").put("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block").put("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper").put("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper").put("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper").put("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs").put("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs").put("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs").put("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab").put("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab").put("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab").put("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper").put("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper").put("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper").put("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper").put("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs").put("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs").put("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab").put("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab").build(); + + datafixerbuilder.addFixer(DataConverterItemName.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))); + Schema schema132 = datafixerbuilder.addSchema(2691, DataConverterRegistry.SAME_NAMESPACED); +- ImmutableMap immutablemap1 = ImmutableMap.builder().put("minecraft:waxed_copper", "minecraft:waxed_copper_block").put("minecraft:oxidized_copper_block", "minecraft:oxidized_copper").put("minecraft:weathered_copper_block", "minecraft:weathered_copper").put("minecraft:exposed_copper_block", "minecraft:exposed_copper").build(); ++ // CraftBukkit - decompile error ++ ImmutableMap immutablemap1 = ImmutableMap.builder().put("minecraft:waxed_copper", "minecraft:waxed_copper_block").put("minecraft:oxidized_copper_block", "minecraft:oxidized_copper").put("minecraft:weathered_copper_block", "minecraft:weathered_copper").put("minecraft:exposed_copper_block", "minecraft:exposed_copper").build(); + + datafixerbuilder.addFixer(DataConverterItemName.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); +- ImmutableMap immutablemap2 = ImmutableMap.builder().put("minecraft:grimstone", "minecraft:deepslate").put("minecraft:grimstone_slab", "minecraft:cobbled_deepslate_slab").put("minecraft:grimstone_stairs", "minecraft:cobbled_deepslate_stairs").put("minecraft:grimstone_wall", "minecraft:cobbled_deepslate_wall").put("minecraft:polished_grimstone", "minecraft:polished_deepslate").put("minecraft:polished_grimstone_slab", "minecraft:polished_deepslate_slab").put("minecraft:polished_grimstone_stairs", "minecraft:polished_deepslate_stairs").put("minecraft:polished_grimstone_wall", "minecraft:polished_deepslate_wall").put("minecraft:grimstone_tiles", "minecraft:deepslate_tiles").put("minecraft:grimstone_tile_slab", "minecraft:deepslate_tile_slab").put("minecraft:grimstone_tile_stairs", "minecraft:deepslate_tile_stairs").put("minecraft:grimstone_tile_wall", "minecraft:deepslate_tile_wall").put("minecraft:grimstone_bricks", "minecraft:deepslate_bricks").put("minecraft:grimstone_brick_slab", "minecraft:deepslate_brick_slab").put("minecraft:grimstone_brick_stairs", "minecraft:deepslate_brick_stairs").put("minecraft:grimstone_brick_wall", "minecraft:deepslate_brick_wall").put("minecraft:chiseled_grimstone", "minecraft:chiseled_deepslate").build(); ++ // CraftBukkit - decompile error ++ ImmutableMap immutablemap2 = ImmutableMap.builder().put("minecraft:grimstone", "minecraft:deepslate").put("minecraft:grimstone_slab", "minecraft:cobbled_deepslate_slab").put("minecraft:grimstone_stairs", "minecraft:cobbled_deepslate_stairs").put("minecraft:grimstone_wall", "minecraft:cobbled_deepslate_wall").put("minecraft:polished_grimstone", "minecraft:polished_deepslate").put("minecraft:polished_grimstone_slab", "minecraft:polished_deepslate_slab").put("minecraft:polished_grimstone_stairs", "minecraft:polished_deepslate_stairs").put("minecraft:polished_grimstone_wall", "minecraft:polished_deepslate_wall").put("minecraft:grimstone_tiles", "minecraft:deepslate_tiles").put("minecraft:grimstone_tile_slab", "minecraft:deepslate_tile_slab").put("minecraft:grimstone_tile_stairs", "minecraft:deepslate_tile_stairs").put("minecraft:grimstone_tile_wall", "minecraft:deepslate_tile_wall").put("minecraft:grimstone_bricks", "minecraft:deepslate_bricks").put("minecraft:grimstone_brick_slab", "minecraft:deepslate_brick_slab").put("minecraft:grimstone_brick_stairs", "minecraft:deepslate_brick_stairs").put("minecraft:grimstone_brick_wall", "minecraft:deepslate_brick_wall").put("minecraft:chiseled_grimstone", "minecraft:chiseled_deepslate").build(); + + datafixerbuilder.addFixer(DataConverterItemName.a(schema133, "Renamed grimstone block items to deepslate", a((Map) immutablemap2))); + datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.b(schema133, "Renamed grimstone blocks to deepslate", a((Map) immutablemap2))); diff --git a/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch b/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch index bfa4037d4..92b747b76 100644 --- a/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch +++ b/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch @@ -11,70 +11,70 @@ public class WorldUpgrader { private static final Logger LOGGER = LogManager.getLogger(); - private static final ThreadFactory b = (new ThreadFactoryBuilder()).setDaemon(true).build(); -- private final ImmutableSet> c; -+ private final ImmutableSet> c; // CraftBukkit - private final boolean d; - private final Convertable.ConversionSession e; - private final Thread f; + private static final ThreadFactory THREAD_FACTORY = (new ThreadFactoryBuilder()).setDaemon(true).build(); +- private final ImmutableSet> levels; ++ private final ImmutableSet> levels; // CraftBukkit + private final boolean eraseCache; + private final Convertable.ConversionSession levelStorage; + private final Thread thread; @@ -49,12 +53,12 @@ - private volatile int k; - private volatile int l; - private volatile int m; -- private final Object2FloatMap> n = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.k())); -+ private final Object2FloatMap> n = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.k())); // CraftBukkit - private volatile IChatBaseComponent o = new ChatMessage("optimizeWorld.stage.counting"); - private static final Pattern p = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$"); - private final WorldPersistentData q; + private volatile int totalChunks; + private volatile int converted; + private volatile int skipped; +- private final Object2FloatMap> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.k())); ++ private final Object2FloatMap> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.k())); // 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; - public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, ImmutableSet> immutableset, boolean flag) { + public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, ImmutableSet> immutableset, boolean flag) { // CraftBukkit - this.c = immutableset; - this.d = flag; - this.g = datafixer; + this.levels = immutableset; + this.eraseCache = flag; + this.dataFixer = datafixer; @@ -82,12 +86,12 @@ private void i() { - this.k = 0; + this.totalChunks = 0; - Builder, ListIterator> builder = ImmutableMap.builder(); + Builder, ListIterator> builder = ImmutableMap.builder(); // CraftBukkit List list; - for (UnmodifiableIterator unmodifiableiterator = this.c.iterator(); unmodifiableiterator.hasNext(); this.k += list.size()) { + for (UnmodifiableIterator unmodifiableiterator = this.levels.iterator(); unmodifiableiterator.hasNext(); this.totalChunks += list.size()) { - ResourceKey resourcekey = (ResourceKey) unmodifiableiterator.next(); + ResourceKey resourcekey = (ResourceKey) unmodifiableiterator.next(); // CraftBukkit list = this.b(resourcekey); builder.put(resourcekey, list.listIterator()); @@ -97,18 +101,18 @@ - this.i = true; + this.finished = true; } else { - float f = (float) this.k; + float f = (float) this.totalChunks; - ImmutableMap, ListIterator> immutablemap = builder.build(); - Builder, IChunkLoader> builder1 = ImmutableMap.builder(); + ImmutableMap, ListIterator> immutablemap = builder.build(); // CraftBukkit + Builder, IChunkLoader> builder1 = ImmutableMap.builder(); // CraftBukkit - UnmodifiableIterator unmodifiableiterator1 = this.c.iterator(); + UnmodifiableIterator unmodifiableiterator1 = this.levels.iterator(); while (unmodifiableiterator1.hasNext()) { - ResourceKey resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); -- File file = this.e.a(resourcekey1); +- File file = this.levelStorage.a(resourcekey1); + ResourceKey resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); // CraftBukkit -+ File file = this.e.a(null); // CraftBukkit ++ File file = this.levelStorage.a((ResourceKey) null); // CraftBukkit - builder1.put(resourcekey1, new IChunkLoader(new File(file, "region"), this.g, true)); + builder1.put(resourcekey1, new IChunkLoader(new File(file, "region"), this.dataFixer, true)); } - ImmutableMap, IChunkLoader> immutablemap1 = builder1.build(); + ImmutableMap, IChunkLoader> immutablemap1 = builder1.build(); // CraftBukkit long i = SystemUtils.getMonotonicMillis(); - this.o = new ChatMessage("optimizeWorld.stage.upgrading"); + this.status = new ChatMessage("optimizeWorld.stage.upgrading"); @@ -120,7 +124,7 @@ float f2; - for (UnmodifiableIterator unmodifiableiterator2 = this.c.iterator(); unmodifiableiterator2.hasNext(); f1 += f2) { + for (UnmodifiableIterator unmodifiableiterator2 = this.levels.iterator(); unmodifiableiterator2.hasNext(); f1 += f2) { - ResourceKey resourcekey2 = (ResourceKey) unmodifiableiterator2.next(); + ResourceKey resourcekey2 = (ResourceKey) unmodifiableiterator2.next(); // CraftBukkit ListIterator listiterator = (ListIterator) immutablemap.get(resourcekey2); @@ -83,7 +83,7 @@ @@ -135,7 +139,7 @@ int j = IChunkLoader.a(nbttagcompound); NBTTagCompound nbttagcompound1 = ichunkloader.getChunkData(resourcekey2, () -> { - return this.q; + return this.overworldDataStorage; - }, nbttagcompound); + }, nbttagcompound, chunkcoordintpair, null); // CraftBukkit NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompound("Level"); @@ -94,9 +94,18 @@ } - private List b(ResourceKey resourcekey) { -- File file = this.e.a(resourcekey); +- File file = this.levelStorage.a(resourcekey); + private List b(ResourceKey resourcekey) { // CraftBukkit -+ File file = this.e.a(null); // CraftBukkit ++ File file = this.levelStorage.a((ResourceKey) null); // CraftBukkit File file1 = new File(file, "region"); File[] afile = file1.listFiles((file2, s) -> { return s.endsWith(".mca"); +@@ -269,7 +273,7 @@ + } + + public ImmutableSet> c() { +- return this.levels; ++ throw new AssertionError("Unsupported"); // CraftBukkit + } + + public float a(ResourceKey resourcekey) { diff --git a/nms-patches/net/minecraft/world/ChestLock.patch b/nms-patches/net/minecraft/world/ChestLock.patch index dd59b51d8..46ebc2373 100644 --- a/nms-patches/net/minecraft/world/ChestLock.patch +++ b/nms-patches/net/minecraft/world/ChestLock.patch @@ -12,7 +12,7 @@ @Immutable public class ChestLock { -@@ -15,7 +20,19 @@ +@@ -16,7 +21,19 @@ } public boolean a(ItemStack itemstack) { diff --git a/nms-patches/net/minecraft/world/IInventory.patch b/nms-patches/net/minecraft/world/IInventory.patch index f5dca44e3..45c87882d 100644 --- a/nms-patches/net/minecraft/world/IInventory.patch +++ b/nms-patches/net/minecraft/world/IInventory.patch @@ -11,8 +11,8 @@ + public interface IInventory extends Clearable { - int getSize(); -@@ -19,9 +24,7 @@ + int LARGE_MAX_STACK_SIZE = 64; +@@ -21,9 +26,7 @@ void setItem(int i, ItemStack itemstack); @@ -23,7 +23,7 @@ void update(); -@@ -60,4 +63,29 @@ +@@ -62,4 +65,29 @@ return false; } diff --git a/nms-patches/net/minecraft/world/InventoryLargeChest.patch b/nms-patches/net/minecraft/world/InventoryLargeChest.patch index 4ac952fe1..d3be7ec5c 100644 --- a/nms-patches/net/minecraft/world/InventoryLargeChest.patch +++ b/nms-patches/net/minecraft/world/InventoryLargeChest.patch @@ -15,8 +15,8 @@ + public class InventoryLargeChest implements IInventory { - public final IInventory left; - public final IInventory right; + public final IInventory container1; + public final IInventory container2; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); @@ -30,14 +30,14 @@ + } + + public void onOpen(CraftHumanEntity who) { -+ this.left.onOpen(who); -+ this.right.onOpen(who); ++ this.container1.onOpen(who); ++ this.container2.onOpen(who); + transaction.add(who); + } + + public void onClose(CraftHumanEntity who) { -+ this.left.onClose(who); -+ this.right.onClose(who); ++ this.container1.onClose(who); ++ this.container2.onClose(who); + transaction.remove(who); + } + @@ -50,13 +50,13 @@ + } + + public void setMaxStackSize(int size) { -+ this.left.setMaxStackSize(size); -+ this.right.setMaxStackSize(size); ++ this.container1.setMaxStackSize(size); ++ this.container2.setMaxStackSize(size); + } + + @Override + public Location getLocation() { -+ return left.getLocation(); // TODO: right? ++ return container1.getLocation(); // TODO: right? + } + // CraftBukkit end + @@ -67,8 +67,8 @@ @Override public int getMaxStackSize() { -- return this.left.getMaxStackSize(); -+ return Math.min(this.left.getMaxStackSize(), this.right.getMaxStackSize()); // CraftBukkit - check both sides +- return this.container1.getMaxStackSize(); ++ return Math.min(this.container1.getMaxStackSize(), this.container2.getMaxStackSize()); // CraftBukkit - check both sides } @Override diff --git a/nms-patches/net/minecraft/world/InventorySubcontainer.patch b/nms-patches/net/minecraft/world/InventorySubcontainer.patch index bfd8a63cb..1e8edf978 100644 --- a/nms-patches/net/minecraft/world/InventorySubcontainer.patch +++ b/nms-patches/net/minecraft/world/InventorySubcontainer.patch @@ -12,9 +12,9 @@ + public class InventorySubcontainer implements IInventory, AutoRecipeOutput { - private final int a; + private final int size; public final NonNullList items; - private List c; + private List listeners; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); @@ -56,8 +56,8 @@ + } + + public InventorySubcontainer(InventorySubcontainer original) { -+ this(original.a); -+ for (int slot = 0; slot < original.a; slot++) { ++ this(original.size); ++ for (int slot = 0; slot < original.size; slot++) { + this.items.set(slot, original.items.get(slot).cloneItemStack()); + } + } @@ -69,6 +69,6 @@ + public InventorySubcontainer(int i, org.bukkit.inventory.InventoryHolder owner) { + this.bukkitOwner = owner; + // CraftBukkit end - this.a = i; - this.items = NonNullList.a(i, ItemStack.b); + this.size = i; + this.items = NonNullList.a(i, ItemStack.EMPTY); } diff --git a/nms-patches/net/minecraft/world/damagesource/DamageSource.patch b/nms-patches/net/minecraft/world/damagesource/DamageSource.patch index 3e2879a3f..74eeac703 100644 --- a/nms-patches/net/minecraft/world/damagesource/DamageSource.patch +++ b/nms-patches/net/minecraft/world/damagesource/DamageSource.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/damagesource/DamageSource.java +++ b/net/minecraft/world/damagesource/DamageSource.java -@@ -46,6 +46,18 @@ - private boolean D; - private boolean E; - public final String translationIndex; +@@ -52,6 +52,18 @@ + private boolean isFall; + private boolean noAggro; + public final String msgId; + // CraftBukkit start + private boolean sweep; + diff --git a/nms-patches/net/minecraft/world/damagesource/EntityDamageSourceIndirect.patch b/nms-patches/net/minecraft/world/damagesource/EntityDamageSourceIndirect.patch index 57169c2a4..5b6a15488 100644 --- a/nms-patches/net/minecraft/world/damagesource/EntityDamageSourceIndirect.patch +++ b/nms-patches/net/minecraft/world/damagesource/EntityDamageSourceIndirect.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/damagesource/EntityDamageSourceIndirect.java +++ b/net/minecraft/world/damagesource/EntityDamageSourceIndirect.java -@@ -37,4 +37,10 @@ +@@ -38,4 +38,10 @@ - return !itemstack.isEmpty() && itemstack.hasName() ? new ChatMessage(s1, new Object[]{entityliving.getScoreboardDisplayName(), ichatbasecomponent, itemstack.C()}) : new ChatMessage(s, new Object[]{entityliving.getScoreboardDisplayName(), ichatbasecomponent}); + return !itemstack.isEmpty() && itemstack.hasName() ? new ChatMessage(s1, new Object[]{entityliving.getScoreboardDisplayName(), ichatbasecomponent, itemstack.G()}) : new ChatMessage(s, new Object[]{entityliving.getScoreboardDisplayName(), ichatbasecomponent}); } + + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/effect/MobEffectList.patch b/nms-patches/net/minecraft/world/effect/MobEffectList.patch index 3cd7a6f46..ce57471cd 100644 --- a/nms-patches/net/minecraft/world/effect/MobEffectList.patch +++ b/nms-patches/net/minecraft/world/effect/MobEffectList.patch @@ -13,16 +13,7 @@ + public class MobEffectList { - private final Map a = Maps.newHashMap(); -@@ -33,7 +40,7 @@ - } - - public static int getId(MobEffectList mobeffectlist) { -- return IRegistry.MOB_EFFECT.a((Object) mobeffectlist); -+ return IRegistry.MOB_EFFECT.a(mobeffectlist); // CraftBukkit - decompile error - } - - protected MobEffectList(MobEffectInfo mobeffectinfo, int i) { + private final Map attributeModifiers = Maps.newHashMap(); @@ -44,26 +51,37 @@ public void tick(EntityLiving entityliving, int i) { if (this == MobEffects.REGENERATION) { @@ -41,7 +32,7 @@ - ((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 } else if (this == MobEffects.SATURATION && entityliving instanceof EntityHuman) { - if (!entityliving.world.isClientSide) { + if (!entityliving.level.isClientSide) { - ((EntityHuman) entityliving).getFoodData().eat(i + 1, 1.0F); + // CraftBukkit start + EntityHuman entityhuman = (EntityHuman) entityliving; @@ -53,11 +44,11 @@ + entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F); + } + -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel)); ++ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel)); + // CraftBukkit end } - } else if ((this != MobEffects.HEAL || entityliving.dj()) && (this != MobEffects.HARM || !entityliving.dj())) { - if (this == MobEffects.HARM && !entityliving.dj() || this == MobEffects.HEAL && entityliving.dj()) { + } 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 { diff --git a/nms-patches/net/minecraft/world/effect/MobEffects.patch b/nms-patches/net/minecraft/world/effect/MobEffects.patch index 5b4ce3a14..e9a9096b4 100644 --- a/nms-patches/net/minecraft/world/effect/MobEffects.patch +++ b/nms-patches/net/minecraft/world/effect/MobEffects.patch @@ -12,6 +12,6 @@ + } + // CraftBukkit end + + public MobEffects() {} + private static MobEffectList a(int i, String s, MobEffectList mobeffectlist) { - return (MobEffectList) IRegistry.a(IRegistry.MOB_EFFECT, i, s, mobeffectlist); - } diff --git a/nms-patches/net/minecraft/world/entity/Entity.patch b/nms-patches/net/minecraft/world/entity/Entity.patch index 3b20012ef..00dcae236 100644 --- a/nms-patches/net/minecraft/world/entity/Entity.patch +++ b/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 -@@ -106,8 +106,58 @@ +@@ -116,8 +116,58 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -33,7 +33,7 @@ +import org.bukkit.plugin.PluginManager; +// CraftBukkit end + - public abstract class Entity implements INamableTileEntity, ICommandListener { + public abstract class Entity implements INamableTileEntity, EntityAccess, ICommandListener { + // CraftBukkit start + private static final int CURRENT_LEVEL = 2; @@ -45,7 +45,7 @@ + + public CraftEntity getBukkitEntity() { + if (bukkitEntity == null) { -+ bukkitEntity = CraftEntity.getEntity(world.getServer(), this); ++ bukkitEntity = CraftEntity.getEntity(level.getServer(), this); + } + return bukkitEntity; + } @@ -57,12 +57,12 @@ + // CraftBukkit end + protected static final Logger LOGGER = LogManager.getLogger(); - private static final AtomicInteger entityCount = new AtomicInteger(); - private static final List c = Collections.emptyList(); -@@ -191,6 +241,21 @@ - private long aB; - private EntitySize size; - private float headHeight; + public static final String ID_TAG = "id"; + public static final String PASSENGERS_TAG = "Passengers"; +@@ -224,6 +274,21 @@ + private float crystalSoundIntensity; + private int lastCrystalSoundPlayTick; + public boolean hasVisualFire; + // CraftBukkit start + public boolean persist = true; + public boolean valid; @@ -71,30 +71,30 @@ + public boolean persistentInvisibility = false; + + public float getBukkitYaw() { -+ return this.yaw; ++ return this.yRot; + } + + public boolean isChunkLoaded() { -+ return world.isChunkLoaded((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4); ++ return level.isChunkLoaded((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4); + } + // CraftBukkit end public Entity(EntityTypes entitytypes, World world) { - this.id = Entity.entityCount.incrementAndGet(); -@@ -297,6 +362,12 @@ - } + this.id = Entity.ENTITY_COUNTER.incrementAndGet(); +@@ -359,6 +424,12 @@ + public void ae() {} public void setPose(EntityPose entitypose) { + // CraftBukkit start + if (entitypose == this.getPose()) { + return; + } -+ this.world.getServer().getPluginManager().callEvent(new EntityPoseChangeEvent(this.getBukkitEntity(), Pose.values()[entitypose.ordinal()])); ++ this.level.getServer().getPluginManager().callEvent(new EntityPoseChangeEvent(this.getBukkitEntity(), Pose.values()[entitypose.ordinal()])); + // CraftBukkit end - this.datawatcher.set(Entity.POSE, entitypose); + this.entityData.set(Entity.DATA_POSE, entitypose); } -@@ -313,6 +384,33 @@ +@@ -375,6 +446,33 @@ } protected void setYawPitch(float f, float f1) { @@ -105,7 +105,7 @@ + + if (f == Float.POSITIVE_INFINITY || f == Float.NEGATIVE_INFINITY) { + if (this instanceof EntityPlayer) { -+ this.world.getServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid yaw"); ++ this.level.getServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid yaw"); + ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite yaw (Hacking?)"); + } + f = 0; @@ -118,25 +118,17 @@ + + if (f1 == Float.POSITIVE_INFINITY || f1 == Float.NEGATIVE_INFINITY) { + if (this instanceof EntityPlayer) { -+ this.world.getServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid pitch"); ++ this.level.getServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid pitch"); + ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite pitch (Hacking?)"); + } + f1 = 0; + } + // CraftBukkit end + - this.yaw = f % 360.0F; - this.pitch = f1 % 360.0F; + this.setYRot(f % 360.0F); + this.setXRot(f1 % 360.0F); } -@@ -320,6 +418,7 @@ - public void setPosition(double d0, double d1, double d2) { - this.setPositionRaw(d0, d1, d2); - this.a(this.size.a(d0, d1, d2)); -+ if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit - } - - protected void af() { -@@ -334,6 +433,15 @@ +@@ -416,6 +514,15 @@ this.entityBaseTick(); } @@ -150,30 +142,30 @@ + // CraftBukkit end + public void entityBaseTick() { - this.world.getMethodProfiler().enter("entityBaseTick"); - if (this.isPassenger() && this.getVehicle().dead) { -@@ -347,7 +455,7 @@ - this.z = this.A; - this.lastPitch = this.pitch; - this.lastYaw = this.yaw; + this.level.getMethodProfiler().enter("entityBaseTick"); + if (this.isPassenger() && this.getVehicle().isRemoved()) { +@@ -429,7 +536,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.aO()) { - this.aP(); + if (this.aV()) { + this.aW(); } -@@ -410,12 +518,44 @@ +@@ -507,7 +614,23 @@ - protected void burnFromLava() { + public void burnFromLava() { if (!this.isFireProof()) { - this.setOnFire(15); + // CraftBukkit start - Fallen in lava TODO: this event spams! -+ if (this instanceof EntityLiving && fireTicks <= 0) { ++ if (this instanceof EntityLiving && remainingFireTicks <= 0) { + // not on fire yet + // TODO: shouldn't be sending null for the block + org.bukkit.block.Block damager = null; // ((WorldServer) this.l).getWorld().getBlockAt(i, j, k); + org.bukkit.entity.Entity damagee = this.getBukkitEntity(); + EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15); -+ this.world.getServer().getPluginManager().callEvent(combustEvent); ++ this.level.getServer().getPluginManager().callEvent(combustEvent); + + if (!combustEvent.isCancelled()) { + this.setOnFire(combustEvent.getDuration(), false); @@ -183,8 +175,10 @@ + this.setOnFire(15, false); + } + // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls - this.damageEntity(DamageSource.LAVA, 4.0F); - } + if (this.damageEntity(DamageSource.LAVA, 4.0F)) { + this.playSound(SoundEffects.GENERIC_BURN, 0.4F, 2.0F + this.random.nextFloat() * 0.4F); + } +@@ -516,6 +639,22 @@ } public void setOnFire(int i) { @@ -195,7 +189,7 @@ + public void setOnFire(int i, boolean callEvent) { + if (callEvent) { + EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), i); -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; @@ -207,114 +201,92 @@ int j = i * 20; if (this instanceof EntityLiving) { -@@ -512,6 +652,28 @@ - block.a((IBlockAccess) this.world, this); - } +@@ -614,6 +753,28 @@ + block.a((IBlockAccess) this.level, this); + } -+ // CraftBukkit start -+ if (positionChanged && getBukkitEntity() instanceof Vehicle) { -+ Vehicle vehicle = (Vehicle) this.getBukkitEntity(); -+ org.bukkit.block.Block bl = this.world.getWorld().getBlockAt(MathHelper.floor(this.locX()), MathHelper.floor(this.locY()), MathHelper.floor(this.locZ())); ++ // 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())); + -+ if (vec3d.x > vec3d1.x) { -+ bl = bl.getRelative(BlockFace.EAST); -+ } else if (vec3d.x < vec3d1.x) { -+ bl = bl.getRelative(BlockFace.WEST); -+ } else if (vec3d.z > vec3d1.z) { -+ bl = bl.getRelative(BlockFace.SOUTH); -+ } else if (vec3d.z < vec3d1.z) { -+ bl = bl.getRelative(BlockFace.NORTH); ++ if (vec3d.x > vec3d1.x) { ++ bl = bl.getRelative(BlockFace.EAST); ++ } else if (vec3d.x < vec3d1.x) { ++ bl = bl.getRelative(BlockFace.WEST); ++ } else if (vec3d.z > vec3d1.z) { ++ bl = bl.getRelative(BlockFace.SOUTH); ++ } else if (vec3d.z < vec3d1.z) { ++ bl = bl.getRelative(BlockFace.NORTH); ++ } ++ ++ if (!bl.getType().isAir()) { ++ VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl); ++ level.getServer().getPluginManager().callEvent(event); ++ } + } ++ // CraftBukkit end + -+ if (!bl.getType().isAir()) { -+ VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl); -+ world.getServer().getPluginManager().callEvent(event); -+ } -+ } -+ // CraftBukkit end -+ - if (this.onGround && !this.bv()) { - block.stepOn(this.world, blockposition, this); - } -@@ -785,6 +947,7 @@ - AxisAlignedBB axisalignedbb = this.getBoundingBox(); - - this.setPositionRaw((axisalignedbb.minX + axisalignedbb.maxX) / 2.0D, axisalignedbb.minY, (axisalignedbb.minZ + axisalignedbb.maxZ) / 2.0D); -+ if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit - } - - protected SoundEffect getSoundSwim() { -@@ -1110,6 +1273,13 @@ - } - - public void spawnIn(World world) { -+ // CraftBukkit start -+ if (world == null) { -+ die(); -+ this.world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle(); -+ return; -+ } -+ // CraftBukkit end - this.world = world; - } - -@@ -1129,6 +1299,7 @@ - this.lastY = d1; - this.lastZ = d4; + if (this.onGround && !this.bE()) { + block.stepOn(this.level, blockposition, iblockdata, this); + } +@@ -1276,6 +1437,7 @@ + this.yo = d1; + this.zo = d4; this.setPosition(d3, d1, d4); -+ world.getChunkAt((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4); // CraftBukkit ++ level.getChunkAt((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4); // CraftBukkit } public void d(Vec3D vec3d) { -@@ -1303,6 +1474,12 @@ +@@ -1466,6 +1628,12 @@ return false; } + // CraftBukkit start - collidable API -+ public boolean canCollideWith(Entity entity) { ++ public boolean canCollideWithBukkit(Entity entity) { + return isCollidable(); + } + // CraftBukkit end + public void a(Entity entity, int i, DamageSource damagesource) { if (entity instanceof EntityPlayer) { - CriterionTriggers.c.a((EntityPlayer) entity, this, damagesource); -@@ -1313,7 +1490,7 @@ - public boolean a_(NBTTagCompound nbttagcompound) { - String s = this.getSaveID(); + CriterionTriggers.ENTITY_KILLED_PLAYER.a((EntityPlayer) entity, this, damagesource); +@@ -1499,7 +1667,7 @@ + } else { + String s = this.getSaveID(); -- if (!this.dead && s != null) { -+ if (this.persist && !this.dead && s != null) { // CraftBukkit - persist flag - nbttagcompound.setString("id", s); - this.save(nbttagcompound); - return true; -@@ -1337,6 +1514,18 @@ +- if (s == null) { ++ if (!this.persist || s == null) { // CraftBukkit - persist flag + return false; + } else { + nbttagcompound.setString("id", s); +@@ -1524,6 +1692,18 @@ Vec3D vec3d = this.getMot(); - nbttagcompound.set("Motion", this.a(vec3d.x, vec3d.y, vec3d.z)); + nbttagcompound.set("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. -+ if (Float.isNaN(this.yaw)) { -+ this.yaw = 0; ++ if (Float.isNaN(this.yRot)) { ++ this.yRot = 0; + } + -+ if (Float.isNaN(this.pitch)) { -+ this.pitch = 0; ++ if (Float.isNaN(this.xRot)) { ++ this.xRot = 0; + } + // CraftBukkit end + - nbttagcompound.set("Rotation", this.a(this.yaw, this.pitch)); + nbttagcompound.set("Rotation", this.newFloatList(this.getYRot(), this.getXRot())); nbttagcompound.setFloat("FallDistance", this.fallDistance); - nbttagcompound.setShort("Fire", (short) this.fireTicks); -@@ -1345,6 +1534,18 @@ + nbttagcompound.setShort("Fire", (short) this.remainingFireTicks); +@@ -1532,6 +1712,18 @@ nbttagcompound.setBoolean("Invulnerable", this.invulnerable); nbttagcompound.setInt("PortalCooldown", this.portalCooldown); nbttagcompound.a("UUID", this.getUniqueID()); + // CraftBukkit start + // PAIL: Check above UUID reads 1.8 properly, ie: UUIDMost / UUIDLeast -+ nbttagcompound.setLong("WorldUUIDLeast", ((WorldServer) this.world).getWorld().getUID().getLeastSignificantBits()); -+ nbttagcompound.setLong("WorldUUIDMost", ((WorldServer) this.world).getWorld().getUID().getMostSignificantBits()); ++ nbttagcompound.setLong("WorldUUIDLeast", ((WorldServer) this.level).getWorld().getUID().getLeastSignificantBits()); ++ nbttagcompound.setLong("WorldUUIDMost", ((WorldServer) this.level).getWorld().getUID().getMostSignificantBits()); + nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL); + if (!this.persist) { + nbttagcompound.setBoolean("Bukkit.persist", this.persist); @@ -326,7 +298,7 @@ IChatBaseComponent ichatbasecomponent = this.getCustomName(); if (ichatbasecomponent != null) { -@@ -1402,6 +1603,11 @@ +@@ -1599,6 +1791,11 @@ } } @@ -338,7 +310,7 @@ return nbttagcompound; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Saving entity NBT"); -@@ -1479,6 +1685,49 @@ +@@ -1680,6 +1877,49 @@ } else { throw new IllegalStateException("Entity has invalid position"); } @@ -350,7 +322,7 @@ + // Reset the persistence for tamed animals + if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) { + EntityInsentient entityinsentient = (EntityInsentient) entity; -+ entityinsentient.persistent = !entityinsentient.isTypeNotPersistent(0); ++ entityinsentient.persistenceRequired = !entityinsentient.isTypeNotPersistent(0); + } + } + this.persist = !nbttagcompound.hasKey("Bukkit.persist") || nbttagcompound.getBoolean("Bukkit.persist"); @@ -375,7 +347,7 @@ + bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(World.OVERWORLD).getWorld(); + } + -+ spawnIn(bworld == null ? null : ((CraftWorld) bworld).getHandle()); ++ ((EntityPlayer) this).spawnIn(bworld == null ? null : ((CraftWorld) bworld).getHandle()); + } + this.getBukkitEntity().readBukkitValues(nbttagcompound); + if (nbttagcompound.hasKey("Bukkit.invisible")) { @@ -388,8 +360,8 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded"); -@@ -1554,9 +1803,22 @@ - } else if (this.world.isClientSide) { +@@ -1755,9 +1995,22 @@ + } else if (this.level.isClientSide) { return null; } else { + // CraftBukkit start - Capture drops for death event @@ -398,7 +370,7 @@ + return null; + } + // CraftBukkit end - EntityItem entityitem = new EntityItem(this.world, this.locX(), this.locY() + (double) f, this.locZ(), itemstack); + EntityItem entityitem = new EntityItem(this.level, this.locX(), this.locY() + (double) f, this.locZ(), itemstack); entityitem.defaultPickupDelay(); + // CraftBukkit start @@ -408,19 +380,19 @@ + return null; + } + // CraftBukkit end - this.world.addEntity(entityitem); + this.level.addEntity(entityitem); return entityitem; } -@@ -1640,7 +1902,7 @@ +@@ -1849,7 +2102,7 @@ - this.setPose(EntityPose.STANDING); - this.vehicle = entity; -- this.vehicle.addPassenger(this); -+ if (!this.vehicle.addPassenger(this)) this.vehicle = null; // CraftBukkit - return true; - } - } -@@ -1665,7 +1927,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) -> { + return entity2 instanceof EntityPlayer; + }).forEach((entity2) -> { +@@ -1880,7 +2133,7 @@ Entity entity = this.vehicle; this.vehicle = null; @@ -429,8 +401,8 @@ } } -@@ -1674,10 +1936,31 @@ - this.bf(); +@@ -1889,10 +2142,31 @@ + this.bo(); } - protected void addPassenger(Entity entity) { @@ -459,10 +431,10 @@ + } + } + // CraftBukkit end - if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.getRidingPassenger() instanceof EntityHuman)) { - this.passengers.add(0, entity); + if (this.passengers.isEmpty()) { + this.passengers = ImmutableList.of(entity); } else { -@@ -1685,15 +1968,36 @@ +@@ -1908,12 +2182,32 @@ } } @@ -493,25 +465,29 @@ + } + } + // CraftBukkit end - this.passengers.remove(entity); - entity.j = 60; + if (this.passengers.size() == 1 && this.passengers.get(0) == entity) { + this.passengers = ImmutableList.of(); + } else { +@@ -1924,6 +2218,7 @@ + + entity.boardingCooldown = 60; } + return true; // CraftBukkit } - protected boolean q(Entity entity) { -@@ -1731,14 +2035,20 @@ + protected boolean o(Entity entity) { +@@ -1974,14 +2269,20 @@ - if (this.inPortal) { + if (this.isInsidePortal) { MinecraftServer minecraftserver = worldserver.getMinecraftServer(); -- ResourceKey resourcekey = this.world.getDimensionKey() == World.THE_NETHER ? World.OVERWORLD : World.THE_NETHER; -+ ResourceKey resourcekey = this.world.getTypeKey() == DimensionManager.THE_NETHER ? World.OVERWORLD : World.THE_NETHER; // CraftBukkit +- ResourceKey resourcekey = this.level.getDimensionKey() == World.NETHER ? World.OVERWORLD : World.NETHER; ++ ResourceKey resourcekey = this.level.getTypeKey() == DimensionManager.NETHER_LOCATION ? World.OVERWORLD : World.NETHER; // CraftBukkit WorldServer worldserver1 = minecraftserver.getWorldServer(resourcekey); -- if (worldserver1 != null && minecraftserver.getAllowNether() && !this.isPassenger() && this.portalTicks++ >= i) { -+ if (true && !this.isPassenger() && this.portalTicks++ >= i) { // CraftBukkit - this.world.getMethodProfiler().enter("portal"); - this.portalTicks = i; +- if (worldserver1 != null && minecraftserver.getAllowNether() && !this.isPassenger() && this.portalTime++ >= i) { ++ if (true && !this.isPassenger() && this.portalTime++ >= i) { // CraftBukkit + this.level.getMethodProfiler().enter("portal"); + this.portalTime = i; this.resetPortalCooldown(); - this.b(worldserver1); + // CraftBukkit start @@ -521,10 +497,10 @@ + this.b(worldserver1); + } + // CraftBukkit end - this.world.getMethodProfiler().exit(); + this.level.getMethodProfiler().exit(); } -@@ -1838,6 +2148,13 @@ +@@ -2099,6 +2400,13 @@ } public void setSwimming(boolean flag) { @@ -538,7 +514,7 @@ this.setFlag(4, flag); } -@@ -1870,8 +2187,12 @@ +@@ -2147,8 +2455,12 @@ return this.getScoreboardTeam() != null ? this.getScoreboardTeam().isAlly(scoreboardteambase) : false; } @@ -552,11 +528,11 @@ } public boolean getFlag(int i) { -@@ -1898,16 +2219,56 @@ +@@ -2175,7 +2487,17 @@ } public void setAirTicks(int i) { -- this.datawatcher.set(Entity.AIR_TICKS, i); +- this.entityData.set(Entity.DATA_AIR_SUPPLY_ID, i); + // CraftBukkit start + EntityAirChangeEvent event = new EntityAirChangeEvent(this.getBukkitEntity(), i); + // Suppress during worldgen @@ -566,19 +542,22 @@ + if (event.isCancelled()) { + return; + } -+ this.datawatcher.set(Entity.AIR_TICKS, event.getAmount()); ++ this.entityData.set(Entity.DATA_AIR_SUPPLY_ID, event.getAmount()); + // CraftBukkit end } + public int getTicksFrozen() { +@@ -2202,11 +2524,41 @@ + public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) { - this.setFireTicks(this.fireTicks + 1); + this.setFireTicks(this.remainingFireTicks + 1); + // CraftBukkit start + final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity(); + final org.bukkit.entity.Entity stormBukkitEntity = entitylightning.getBukkitEntity(); + final PluginManager pluginManager = Bukkit.getPluginManager(); + // CraftBukkit end + - if (this.fireTicks == 0) { + if (this.remainingFireTicks == 0) { - this.setOnFire(8); + // CraftBukkit start - Call a combust event when lightning strikes + EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8); @@ -599,12 +578,12 @@ + } } -- this.damageEntity(DamageSource.LIGHTNING, 5.0F); +- this.damageEntity(DamageSource.LIGHTNING_BOLT, 5.0F); + if (this.isFireProof()) { + return; + } + CraftEventFactory.entityDamage = entitylightning; -+ if (!this.damageEntity(DamageSource.LIGHTNING, 5.0F)) { ++ if (!this.damageEntity(DamageSource.LIGHTNING_BOLT, 5.0F)) { + CraftEventFactory.entityDamage = null; + return; + } @@ -612,7 +591,7 @@ } public void k(boolean flag) { -@@ -2057,15 +2418,32 @@ +@@ -2356,15 +2708,32 @@ @Nullable public Entity b(WorldServer worldserver) { @@ -623,8 +602,8 @@ + @Nullable + public Entity teleportTo(WorldServer worldserver, BlockPosition location) { + // CraftBukkit end - if (this.world instanceof WorldServer && !this.dead) { - this.world.getMethodProfiler().enter("changeDimension"); + if (this.level instanceof WorldServer && !this.isRemoved()) { + this.level.getMethodProfiler().enter("changeDimension"); - this.decouple(); + // CraftBukkit start + // this.decouple(); @@ -632,9 +611,9 @@ + return null; + } + // CraftBukkit end - this.world.getMethodProfiler().enter("reposition"); + 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.ORIGIN, this.yaw, this.pitch, worldserver, null); // CraftBukkit ++ 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 if (shapedetectorshape == null) { return null; @@ -644,55 +623,55 @@ + this.decouple(); + // CraftBukkit end + - this.world.getMethodProfiler().exitEnter("reloading"); + this.level.getMethodProfiler().exitEnter("reloading"); Entity entity = this.getEntityType().a((World) worldserver); -@@ -2074,9 +2452,17 @@ - entity.setPositionRotation(shapedetectorshape.position.x, shapedetectorshape.position.y, shapedetectorshape.position.z, shapedetectorshape.yaw, entity.pitch); - entity.setMot(shapedetectorshape.velocity); +@@ -2373,9 +2742,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.THE_END) { +- if (worldserver.getDimensionKey() == World.END) { - WorldServer.a(worldserver); -+ if (worldserver.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit ++ if (worldserver.getTypeKey() == DimensionManager.END_LOCATION) { // CraftBukkit + WorldServer.a(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. -+ } + } + // CraftBukkit end } - this.bN(); -@@ -2097,13 +2483,18 @@ + this.cc(); +@@ -2396,13 +2773,18 @@ @Nullable protected ShapeDetectorShape a(WorldServer worldserver) { -- boolean flag = this.world.getDimensionKey() == World.THE_END && worldserver.getDimensionKey() == World.OVERWORLD; -- boolean flag1 = worldserver.getDimensionKey() == World.THE_END; +- boolean flag = this.level.getDimensionKey() == World.END && worldserver.getDimensionKey() == World.OVERWORLD; +- boolean flag1 = worldserver.getDimensionKey() == World.END; + // CraftBukkit start + if (worldserver == null) { + return null; + } -+ boolean flag = this.world.getTypeKey() == DimensionManager.THE_END && worldserver.getTypeKey() == DimensionManager.OVERWORLD; // fromEndToOverworld -+ boolean flag1 = worldserver.getTypeKey() == DimensionManager.THE_END; // targetIsEnd ++ boolean flag = this.level.getTypeKey() == DimensionManager.END_LOCATION && worldserver.getTypeKey() == DimensionManager.OVERWORLD_LOCATION; // fromEndToOverworld ++ boolean flag1 = worldserver.getTypeKey() == DimensionManager.END_LOCATION; // targetIsEnd + // CraftBukkit end if (!flag && !flag1) { -- boolean flag2 = worldserver.getDimensionKey() == World.THE_NETHER; -+ boolean flag2 = worldserver.getTypeKey() == DimensionManager.THE_NETHER; // CraftBukkit +- boolean flag2 = worldserver.getDimensionKey() == World.NETHER; ++ boolean flag2 = worldserver.getTypeKey() == DimensionManager.NETHER_LOCATION; // CraftBukkit -- if (this.world.getDimensionKey() != World.THE_NETHER && !flag2) { -+ if (this.world.getTypeKey() != DimensionManager.THE_NETHER && !flag2) { +- if (this.level.getDimensionKey() != World.NETHER && !flag2) { ++ if (this.level.getTypeKey() != DimensionManager.NETHER_LOCATION && !flag2) { return null; } else { WorldBorder worldborder = worldserver.getWorldBorder(); -@@ -2113,8 +2504,16 @@ +@@ -2412,8 +2794,16 @@ double d3 = Math.min(2.9999872E7D, worldborder.h() - 16.0D); - double d4 = DimensionManager.a(this.world.getDimensionManager(), worldserver.getDimensionManager()); + 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)); + // CraftBukkit start + CraftPortalEvent event = callPortalEvent(this, worldserver, blockposition, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16); @@ -705,21 +684,21 @@ - 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) -> { + // CraftBukkit end - IBlockData iblockdata = this.world.getType(this.ac); + IBlockData iblockdata = this.level.getType(this.portalEntrancePos); EnumDirection.EnumAxis enumdirection_enumaxis; Vec3D vec3d; -@@ -2131,8 +2530,8 @@ +@@ -2430,8 +2820,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.yaw, this.pitch); +- return BlockPortalShape.a(worldserver, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.a(this.getPose()), this.getMot(), this.getYRot(), this.getXRot()); - }).orElse((Object) null); -+ return BlockPortalShape.a(worldserverFinal, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.a(this.getPose()), this.getMot(), this.yaw, this.pitch, event); // CraftBukkit ++ return BlockPortalShape.a(worldserverFinal, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.a(this.getPose()), this.getMot(), this.getYRot(), this.getXRot(), event); // CraftBukkit + }).orElse(null); // CraftBuukkit - decompile error } } else { BlockPosition blockposition1; -@@ -2142,8 +2541,15 @@ +@@ -2441,8 +2831,15 @@ } else { blockposition1 = worldserver.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSpawn()); } @@ -730,13 +709,13 @@ + } + 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.yaw, this.pitch); -+ return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getMot(), this.yaw, this.pitch, ((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.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); + // CraftBukkit end } } -@@ -2151,8 +2557,23 @@ +@@ -2450,8 +2847,23 @@ return BlockPortalShape.a(blockutil_rectangle, enumdirection_enumaxis, this.getPositionVector(), this.a(this.getPose())); } @@ -762,11 +741,11 @@ } public boolean canPortal() { -@@ -2338,7 +2759,26 @@ +@@ -2660,7 +3072,26 @@ } - public void a(AxisAlignedBB axisalignedbb) { -- this.boundingBox = axisalignedbb; + public final void a(AxisAlignedBB axisalignedbb) { +- this.bb = axisalignedbb; + // CraftBukkit start - block invalid bounding boxes + double minX = axisalignedbb.minX, + minY = axisalignedbb.minY, @@ -785,7 +764,7 @@ + len = axisalignedbb.maxZ - axisalignedbb.minZ; + if (len < 0) maxZ = minZ; + if (len > 64) maxZ = minZ + 64.0; -+ this.boundingBox = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ); ++ this.bb = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ); + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/entity/EntityAgeable.patch b/nms-patches/net/minecraft/world/entity/EntityAgeable.patch index 273e44c70..58903b2a7 100644 --- a/nms-patches/net/minecraft/world/entity/EntityAgeable.patch +++ b/nms-patches/net/minecraft/world/entity/EntityAgeable.patch @@ -1,35 +1,35 @@ --- a/net/minecraft/world/entity/EntityAgeable.java +++ b/net/minecraft/world/entity/EntityAgeable.java -@@ -17,6 +17,7 @@ - protected int b; - protected int c; - protected int d; +@@ -19,6 +19,7 @@ + protected int age; + protected int forcedAge; + protected int forcedAgeTimer; + public boolean ageLocked; // CraftBukkit protected EntityAgeable(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -100,6 +101,7 @@ +@@ -102,6 +103,7 @@ super.saveData(nbttagcompound); nbttagcompound.setInt("Age", this.getAge()); - nbttagcompound.setInt("ForcedAge", this.c); + nbttagcompound.setInt("ForcedAge", this.forcedAge); + nbttagcompound.setBoolean("AgeLocked", this.ageLocked); // CraftBukkit } @Override -@@ -107,6 +109,7 @@ +@@ -109,6 +111,7 @@ super.loadData(nbttagcompound); this.setAgeRaw(nbttagcompound.getInt("Age")); - this.c = nbttagcompound.getInt("ForcedAge"); + this.forcedAge = nbttagcompound.getInt("ForcedAge"); + this.ageLocked = nbttagcompound.getBoolean("AgeLocked"); // CraftBukkit } @Override -@@ -121,7 +124,7 @@ +@@ -123,7 +126,7 @@ @Override public void movementTick() { super.movementTick(); -- if (this.world.isClientSide) { -+ if (this.world.isClientSide || ageLocked) { // CraftBukkit - if (this.d > 0) { - if (this.d % 4 == 0) { - this.world.addParticle(Particles.HAPPY_VILLAGER, this.d(1.0D), this.cF() + 0.5D, this.g(1.0D), 0.0D, 0.0D, 0.0D); +- 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); diff --git a/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch b/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch index aaf445ea4..d3bcf93fe 100644 --- a/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch +++ b/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityAreaEffectCloud.java +++ b/net/minecraft/world/entity/EntityAreaEffectCloud.java -@@ -33,6 +33,12 @@ +@@ -32,6 +32,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -13,19 +13,19 @@ public class EntityAreaEffectCloud extends Entity { private static final Logger LOGGER = LogManager.getLogger(); -@@ -124,6 +130,22 @@ +@@ -127,6 +133,22 @@ } + // CraftBukkit start accessor methods + public void refreshEffects() { -+ if (!this.hasColor) { -+ this.getDataWatcher().set(EntityAreaEffectCloud.COLOR, PotionUtil.a((Collection) PotionUtil.a(this.potionRegistry, (Collection) this.effects))); // PAIL: rename ++ if (!this.fixedColor) { ++ this.getDataWatcher().set(EntityAreaEffectCloud.DATA_COLOR, PotionUtil.a((Collection) PotionUtil.a(this.potion, (Collection) this.effects))); // PAIL: rename + } + } + + public String getType() { -+ return ((MinecraftKey) IRegistry.POTION.getKey(this.potionRegistry)).toString(); ++ return ((MinecraftKey) IRegistry.POTION.getKey(this.potion)).toString(); + } + + public void setType(String string) { @@ -34,20 +34,20 @@ + // CraftBukkit end + public int getColor() { - return (Integer) this.getDataWatcher().get(EntityAreaEffectCloud.COLOR); + return (Integer) this.getDataWatcher().get(EntityAreaEffectCloud.DATA_COLOR); } -@@ -268,6 +290,7 @@ +@@ -259,6 +281,7 @@ if (!list1.isEmpty()) { - Iterator iterator2 = list1.iterator(); + Iterator iterator1 = list1.iterator(); + List entities = new java.util.ArrayList(); // CraftBukkit - while (iterator2.hasNext()) { - EntityLiving entityliving = (EntityLiving) iterator2.next(); + while (iterator1.hasNext()) { + EntityLiving entityliving = (EntityLiving) iterator1.next(); -@@ -277,6 +300,17 @@ - double d2 = d0 * d0 + d1 * d1; +@@ -268,6 +291,17 @@ + double d8 = d6 * d6 + d7 * d7; - if (d2 <= (double) (f * f)) { + if (d8 <= (double) (f * f)) { + // CraftBukkit start + entities.add((LivingEntity) entityliving.getBukkitEntity()); + } @@ -59,15 +59,15 @@ + if (entity instanceof CraftLivingEntity) { + EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle(); + // CraftBukkit end - this.affectedEntities.put(entityliving, this.ticksLived + this.reapplicationDelay); - Iterator iterator3 = list.iterator(); + this.victims.put(entityliving, this.tickCount + this.reapplicationDelay); + Iterator iterator2 = list.iterator(); -@@ -286,7 +320,7 @@ +@@ -277,7 +311,7 @@ if (mobeffect1.getMobEffect().isInstant()) { mobeffect1.getMobEffect().applyInstantEffect(this, this.getSource(), entityliving, mobeffect1.getAmplifier(), 0.5D); } else { -- entityliving.addEffect(new MobEffect(mobeffect1)); -+ entityliving.addEffect(new MobEffect(mobeffect1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit +- 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/nms-patches/net/minecraft/world/entity/EntityCreature.patch b/nms-patches/net/minecraft/world/entity/EntityCreature.patch index d6d31f295..a9cd9147d 100644 --- a/nms-patches/net/minecraft/world/entity/EntityCreature.patch +++ b/nms-patches/net/minecraft/world/entity/EntityCreature.patch @@ -15,15 +15,15 @@ if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isSitting()) { if (f > 10.0F) { -+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit ++ this.level.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit this.unleash(true, true); } @@ -49,6 +54,7 @@ - this.x(f); + this.y(f); if (f > 10.0F) { -+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit ++ this.level.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit this.unleash(true, true); this.goalSelector.a(PathfinderGoal.Type.MOVE); } else if (f > 6.0F) { diff --git a/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch b/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch index 591e7c1d8..e09353e01 100644 --- a/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch +++ b/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/EntityExperienceOrb.java +++ b/net/minecraft/world/entity/EntityExperienceOrb.java -@@ -16,6 +16,12 @@ - import net.minecraft.world.level.World; +@@ -21,6 +21,12 @@ + import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start @@ -12,63 +12,63 @@ + public class EntityExperienceOrb extends Entity { - public int b; -@@ -50,6 +56,7 @@ + private static final int LIFETIME = 6000; +@@ -59,6 +65,7 @@ @Override public void tick() { super.tick(); -+ EntityHuman prevTarget = this.targetPlayer;// CraftBukkit - store old target - if (this.d > 0) { - --this.d; - } -@@ -86,7 +93,22 @@ - this.targetPlayer = null; ++ EntityHuman prevTarget = this.followingPlayer;// CraftBukkit - store old target + this.xo = this.locX(); + this.yo = this.locY(); + this.zo = this.locZ(); +@@ -84,7 +91,22 @@ + this.followingPlayer = null; } -- if (this.targetPlayer != null) { +- if (this.followingPlayer != null) { + // CraftBukkit start + boolean cancelled = false; -+ if (this.targetPlayer != prevTarget) { -+ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this, targetPlayer, (targetPlayer != null) ? EntityTargetEvent.TargetReason.CLOSEST_PLAYER : EntityTargetEvent.TargetReason.FORGOT_TARGET); ++ if (this.followingPlayer != prevTarget) { ++ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this, followingPlayer, (followingPlayer != null) ? EntityTargetEvent.TargetReason.CLOSEST_PLAYER : EntityTargetEvent.TargetReason.FORGOT_TARGET); + EntityLiving target = (event.getTarget() == null) ? null : ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle(); + cancelled = event.isCancelled(); + + if (cancelled) { -+ targetPlayer = prevTarget; ++ followingPlayer = prevTarget; + } else { -+ targetPlayer = (target instanceof EntityHuman) ? (EntityHuman) target : null; ++ followingPlayer = (target instanceof EntityHuman) ? (EntityHuman) target : null; + } + } + -+ if (this.targetPlayer != null && !cancelled) { ++ if (this.followingPlayer != null && !cancelled) { + // CraftBukkit end - Vec3D vec3d = new Vec3D(this.targetPlayer.locX() - this.locX(), this.targetPlayer.locY() + (double) this.targetPlayer.getHeadHeight() / 2.0D - this.locY(), this.targetPlayer.locZ() - this.locZ()); - double d1 = vec3d.g(); + 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(); -@@ -169,13 +191,19 @@ - if (!itemstack.isEmpty() && itemstack.f()) { - int i = Math.min(this.c(this.value), itemstack.getDamage()); +@@ -225,7 +247,7 @@ + int i = this.a(entityhuman, this.value); -- this.value -= this.b(i); -- itemstack.setDamage(itemstack.getDamage() - i); -+ // CraftBukkit start -+ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(entityhuman, this, itemstack, i); -+ i = event.getRepairAmount(); -+ if (!event.isCancelled()) { -+ this.value -= this.b(i); -+ itemstack.setDamage(itemstack.getDamage() - i); -+ } -+ // CraftBukkit end - } + if (i > 0) { +- entityhuman.giveExp(i); ++ entityhuman.giveExp(CraftEventFactory.callPlayerExpChangeEvent(entityhuman, i).getAmount()); // CraftBukkit - this.value -> event.getAmount() } - if (this.value > 0) { -- entityhuman.giveExp(this.value); -+ entityhuman.giveExp(CraftEventFactory.callPlayerExpChangeEvent(entityhuman, this.value).getAmount()); // CraftBukkit - this.value -> event.getAmount() - } + --this.count; +@@ -243,6 +265,13 @@ + if (entry != null) { + ItemStack itemstack = (ItemStack) entry.getValue(); + int j = Math.min(this.c(this.value), itemstack.getDamage()); ++ // CraftBukkit start ++ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(entityhuman, this, itemstack, j); ++ j = event.getRepairAmount(); ++ if (event.isCancelled()) { ++ return i; ++ } ++ // CraftBukkit end - this.die(); -@@ -197,6 +225,24 @@ + itemstack.setDamage(itemstack.getDamage() - j); + int k = i - this.b(j); +@@ -270,6 +299,24 @@ } public static int getOrbValue(int i) { diff --git a/nms-patches/net/minecraft/world/entity/EntityInsentient.patch b/nms-patches/net/minecraft/world/entity/EntityInsentient.patch index a4e3629e4..cf57e96ac 100644 --- a/nms-patches/net/minecraft/world/entity/EntityInsentient.patch +++ b/nms-patches/net/minecraft/world/entity/EntityInsentient.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityInsentient.java +++ b/net/minecraft/world/entity/EntityInsentient.java -@@ -74,6 +74,19 @@ +@@ -72,6 +72,19 @@ import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.level.storage.loot.LootTableInfo; @@ -19,36 +19,27 @@ + public abstract class EntityInsentient extends EntityLiving { - private static final DataWatcherObject b = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.a); -@@ -92,7 +105,7 @@ - public final float[] dropChanceHand; - private final NonNullList bq; - public final float[] dropChanceArmor; -- private boolean canPickUpLoot; -+ // private boolean canPickUpLoot; // CraftBukkit - moved up to EntityLiving - public boolean persistent; - private final Map bt; - public MinecraftKey lootTableKey; -@@ -105,6 +118,8 @@ - private BlockPosition bz; - private float bA; + private static final DataWatcherObject DATA_MOB_FLAGS_ID = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.BYTE); +@@ -112,6 +125,8 @@ + private BlockPosition restrictCenter; + private float restrictRadius; + public boolean aware = true; // CraftBukkit + protected EntityInsentient(EntityTypes entitytypes, World world) { super(entitytypes, world); - this.bp = NonNullList.a(2, ItemStack.b); -@@ -128,6 +143,9 @@ + this.handItems = NonNullList.a(2, ItemStack.EMPTY); +@@ -135,6 +150,9 @@ this.initPathfinder(); } + // CraftBukkit start - default persistance to type's persistance value -+ this.persistent = !isTypeNotPersistent(0); ++ this.persistenceRequired = !isTypeNotPersistent(0); + // CraftBukkit end } protected void initPathfinder() {} -@@ -208,7 +226,38 @@ +@@ -215,7 +233,38 @@ } public void setGoalTarget(@Nullable EntityLiving entityliving) { @@ -63,14 +54,14 @@ + reason = getGoalTarget().isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED; + } + if (reason == EntityTargetEvent.TargetReason.UNKNOWN) { -+ world.getServer().getLogger().log(java.util.logging.Level.WARNING, "Unknown target reason, please report on the issue tracker", new Exception()); ++ level.getServer().getLogger().log(java.util.logging.Level.WARNING, "Unknown target reason, please report on the issue tracker", new Exception()); + } + CraftLivingEntity ctarget = null; + if (entityliving != null) { + ctarget = (CraftLivingEntity) entityliving.getBukkitEntity(); + } + EntityTargetLivingEntityEvent event = new EntityTargetLivingEntityEvent(this.getBukkitEntity(), ctarget, reason); -+ world.getServer().getPluginManager().callEvent(event); ++ level.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return false; + } @@ -81,13 +72,13 @@ + entityliving = null; + } + } - this.goalTarget = entityliving; + this.target = entityliving; + return true; + // CraftBukkit end } @Override -@@ -425,16 +474,26 @@ +@@ -442,16 +491,26 @@ nbttagcompound.setBoolean("NoAI", this.isNoAI()); } @@ -107,16 +98,16 @@ + } } -- this.persistent = nbttagcompound.getBoolean("PersistenceRequired"); +- this.persistenceRequired = nbttagcompound.getBoolean("PersistenceRequired"); + boolean data = nbttagcompound.getBoolean("PersistenceRequired"); + if (isLevelAtLeast(nbttagcompound, 1) || data) { -+ this.persistent = data; ++ this.persistenceRequired = data; + } + // CraftBukkit end NBTTagList nbttaglist; int i; -@@ -481,6 +540,11 @@ +@@ -498,6 +557,11 @@ } this.setNoAI(nbttagcompound.getBoolean("NoAI")); @@ -128,38 +119,26 @@ } @Override -@@ -488,6 +552,11 @@ - super.a(damagesource, flag); - this.lootTableKey = null; - } -+ // CraftBukkit - start -+ public MinecraftKey getLootTable() { -+ return getDefaultLootTable(); -+ } -+ // CraftBukkit - end - - @Override - protected LootTableInfo.Builder a(boolean flag, DamageSource damagesource) { -@@ -544,7 +613,7 @@ +@@ -561,7 +625,7 @@ protected void b(EntityItem entityitem) { ItemStack itemstack = entityitem.getItemStack(); -- if (this.g(itemstack)) { -+ if (this.g(itemstack, entityitem)) { // CraftBukkit - add item +- if (this.j(itemstack)) { ++ if (this.j(itemstack, entityitem)) { // CraftBukkit - add item this.a(entityitem); this.receive(entityitem, itemstack.getCount()); entityitem.die(); -@@ -553,15 +622,29 @@ +@@ -570,15 +634,29 @@ } - public boolean g(ItemStack itemstack) { + public boolean j(ItemStack itemstack) { + // CraftBukkit start - add item -+ return this.g(itemstack, null); ++ return this.j(itemstack, null); + } + -+ public boolean g(ItemStack itemstack, EntityItem entityitem) { ++ public boolean j(ItemStack itemstack, EntityItem entityitem) { + // CraftBukkit end - EnumItemSlot enumitemslot = j(itemstack); + EnumItemSlot enumitemslot = getEquipmentSlotForItem(itemstack); ItemStack itemstack1 = this.getEquipment(enumitemslot); boolean flag = this.a(itemstack, itemstack1); @@ -175,18 +154,18 @@ if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) { + this.forceDrops = true; // CraftBukkit - this.a(itemstack1); + this.b(itemstack1); + this.forceDrops = false; // CraftBukkit } this.b(enumitemslot, itemstack); -@@ -674,18 +757,18 @@ - EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D); +@@ -691,18 +769,18 @@ + EntityHuman entityhuman = this.level.findNearbyPlayer(this, -1.0D); if (entityhuman != null) { -- double d0 = entityhuman.h(this); -+ double d0 = entityhuman.h((Entity) this); // CraftBukkit - decompile error - int i = this.getEntityType().e().f(); +- double d0 = entityhuman.f(this); ++ double d0 = entityhuman.f((Entity) this); // CraftBukkit - decompile error + int i = this.getEntityType().f().f(); int j = i * i; - if (d0 > (double) j && this.isTypeNotPersistent(d0)) { @@ -194,59 +173,59 @@ this.die(); } - int k = this.getEntityType().e().g(); + int k = this.getEntityType().f().g(); int l = k * k; -- if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > (double) l && this.isTypeNotPersistent(d0)) { -+ if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > (double) l) { // CraftBukkit - remove isTypeNotPersistent() check +- 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) { // CraftBukkit - remove isTypeNotPersistent() check this.die(); } else if (d0 < (double) l) { - this.ticksFarFromPlayer = 0; -@@ -700,6 +783,7 @@ + this.noActionTime = 0; +@@ -717,6 +795,7 @@ @Override protected final void doTick() { - ++this.ticksFarFromPlayer; + ++this.noActionTime; + if (!this.aware) return; // CraftBukkit - this.world.getMethodProfiler().enter("sensing"); - this.bo.a(); - this.world.getMethodProfiler().exit(); -@@ -1088,6 +1172,12 @@ + this.level.getMethodProfiler().enter("sensing"); + this.sensing.a(); + this.level.getMethodProfiler().exit(); +@@ -1100,6 +1179,12 @@ if (!this.isAlive()) { return EnumInteractionResult.PASS; } else if (this.getLeashHolder() == entityhuman) { + // CraftBukkit start - fire PlayerUnleashEntityEvent + if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) { -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder())); ++ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder())); + return EnumInteractionResult.PASS; + } + // CraftBukkit end - this.unleash(true, !entityhuman.abilities.canInstantlyBuild); - return EnumInteractionResult.a(this.world.isClientSide); + this.unleash(true, !entityhuman.getAbilities().instabuild); + return EnumInteractionResult.a(this.level.isClientSide); } else { -@@ -1106,6 +1196,12 @@ +@@ -1118,6 +1203,12 @@ ItemStack itemstack = entityhuman.b(enumhand); - if (itemstack.getItem() == Items.LEAD && this.a(entityhuman)) { + if (itemstack.a(Items.LEAD) && this.a(entityhuman)) { + // CraftBukkit start - fire PlayerLeashEntityEvent + if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) { -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder())); ++ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder())); + return EnumInteractionResult.PASS; + } + // CraftBukkit end this.setLeashHolder(entityhuman, true); itemstack.subtract(1); - return EnumInteractionResult.a(this.world.isClientSide); -@@ -1121,7 +1217,7 @@ + return EnumInteractionResult.a(this.level.isClientSide); +@@ -1133,7 +1224,7 @@ if (itemstack.getItem() instanceof ItemMonsterEgg) { - if (this.world instanceof WorldServer) { + if (this.level instanceof WorldServer) { ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem(); -- Optional optional = itemmonsteregg.a(entityhuman, this, this.getEntityType(), (WorldServer) this.world, this.getPositionVector(), itemstack); -+ Optional optional = itemmonsteregg.a(entityhuman, this, (EntityTypes) this.getEntityType(), (WorldServer) this.world, this.getPositionVector(), itemstack); // CraftBukkit - decompile error +- Optional optional = itemmonsteregg.a(entityhuman, this, this.getEntityType(), (WorldServer) this.level, this.getPositionVector(), itemstack); ++ Optional optional = itemmonsteregg.a(entityhuman, this, (EntityTypes) this.getEntityType(), (WorldServer) this.level, this.getPositionVector(), itemstack); // CraftBukkit - decompile error optional.ifPresent((entityinsentient) -> { this.a(entityhuman, entityinsentient); -@@ -1167,12 +1263,19 @@ - return this.bA != -1.0F; +@@ -1183,12 +1274,19 @@ + return this.restrictRadius != -1.0F; } + // CraftBukkit start @@ -258,55 +237,55 @@ + @Nullable + public T a(EntityTypes entitytypes, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) { + // CraftBukkit end - if (this.dead) { + if (this.isRemoved()) { return null; } else { -- T t0 = (EntityInsentient) entitytypes.a(this.world); -+ T t0 = entitytypes.a(this.world); // CraftBukkit - decompile error +- T t0 = (EntityInsentient) entitytypes.a(this.level); ++ T t0 = entitytypes.a(this.level); // CraftBukkit - decompile error - t0.u(this); + t0.s(this); t0.setBaby(this.isBaby()); -@@ -1204,7 +1307,12 @@ +@@ -1220,7 +1318,12 @@ } } -- this.world.addEntity(t0); +- this.level.addEntity(t0); + // CraftBukkit start + if (CraftEventFactory.callEntityTransformEvent(this, t0, transformReason).isCancelled()) { + return null; + } -+ this.world.addEntity(t0, spawnReason); ++ this.level.addEntity(t0, spawnReason); + // CraftBukkit end if (this.isPassenger()) { Entity entity = this.getVehicle(); -@@ -1224,6 +1332,7 @@ +@@ -1240,6 +1343,7 @@ if (this.leashHolder != null) { if (!this.isAlive() || !this.leashHolder.isAlive()) { -+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit ++ this.level.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit this.unleash(true, true); } -@@ -1240,7 +1349,9 @@ +@@ -1251,7 +1355,9 @@ this.leashHolder = null; - this.by = null; - if (!this.world.isClientSide && flag1) { + this.leashInfoTag = null; + if (!this.level.isClientSide && flag1) { + this.forceDrops = true; // CraftBukkit this.a((IMaterial) Items.LEAD); + this.forceDrops = false; // CraftBukkit } - if (!this.world.isClientSide && flag && this.world instanceof WorldServer) { -@@ -1290,6 +1401,7 @@ + if (!this.level.isClientSide && flag && this.level instanceof WorldServer) { +@@ -1301,6 +1407,7 @@ boolean flag1 = super.a(entity, flag); if (flag1 && this.isLeashed()) { -+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit ++ this.level.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit this.unleash(true, true); } -@@ -1422,7 +1534,14 @@ +@@ -1396,7 +1503,14 @@ int i = EnchantmentManager.getFireAspectEnchantmentLevel(this); if (i > 0) { @@ -322,11 +301,15 @@ } boolean flag = entity.damageEntity(DamageSource.mobAttack(this), f); -@@ -1484,6 +1603,7 @@ +@@ -1464,9 +1578,10 @@ @Override - protected void bN() { - super.bN(); -+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit + protected void cc() { + super.cc(); ++ this.level.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit this.unleash(true, false); + this.by().forEach((itemstack) -> { +- itemstack.setCount(0); ++ if (!itemstack.isEmpty()) itemstack.setCount(0); // CraftBukkit + }); } - } + diff --git a/nms-patches/net/minecraft/world/entity/EntityLightning.patch b/nms-patches/net/minecraft/world/entity/EntityLightning.patch index e99c97b8b..392fad4c1 100644 --- a/nms-patches/net/minecraft/world/entity/EntityLightning.patch +++ b/nms-patches/net/minecraft/world/entity/EntityLightning.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/EntityLightning.java +++ b/net/minecraft/world/entity/EntityLightning.java -@@ -22,6 +22,11 @@ - import net.minecraft.world.level.block.state.IBlockData; +@@ -32,6 +32,11 @@ import net.minecraft.world.phys.AxisAlignedBB; + import net.minecraft.world.phys.Vec3D; +// CraftBukkit start +import net.minecraft.network.protocol.game.PacketPlayOutNamedSoundEffect; @@ -11,65 +11,54 @@ + public class EntityLightning extends Entity { - private int lifeTicks; -@@ -62,7 +67,24 @@ - this.a(4); - } - -- this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); -+ // CraftBukkit start - Use relative location for far away sounds -+ // this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); -+ float pitch = 0.8F + this.random.nextFloat() * 0.2F; -+ int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16; -+ for (EntityPlayer player : (List) (List) this.world.getPlayers()) { -+ double deltaX = this.locX() - player.locX(); -+ double deltaZ = this.locZ() - player.locZ(); -+ 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.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, relativeX, this.locY(), relativeZ, 10000.0F, pitch)); -+ } else { -+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, this.locX(), this.locY(), this.locZ(), 10000.0F, pitch)); -+ } -+ } -+ // CraftBukkit end - this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_LIGHTNING_BOLT_IMPACT, SoundCategory.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F); - } - -@@ -78,7 +100,7 @@ + private static final int START_LIFE = 2; +@@ -132,7 +137,7 @@ } } -- if (this.lifeTicks >= 0) { -+ if (this.lifeTicks >= 0 && !this.isEffect) { // CraftBukkit - add !this.isEffect - if (!(this.world instanceof WorldServer)) { - this.world.c(2); - } else if (!this.isEffect) { -@@ -106,7 +128,11 @@ - IBlockData iblockdata = BlockFireAbstract.a((IBlockAccess) this.world, blockposition); +- if (this.life >= 0) { ++ if (this.life >= 0 && !this.visualOnly) { // CraftBukkit - add !this.isEffect + if (!(this.level instanceof WorldServer)) { + this.level.c(2); + } else if (!this.visualOnly) { +@@ -166,8 +171,12 @@ + IBlockData iblockdata = BlockFireAbstract.a((IBlockAccess) this.level, blockposition); - if (this.world.getType(blockposition).isAir() && iblockdata.canPlace(this.world, blockposition)) { -- this.world.setTypeUpdate(blockposition, iblockdata); + if (this.level.getType(blockposition).isAir() && iblockdata.canPlace(this.level, blockposition)) { +- this.level.setTypeUpdate(blockposition, iblockdata); +- ++this.blocksSetOnFire; + // CraftBukkit start - add "!isEffect" -+ if (!isEffect && !CraftEventFactory.callBlockIgniteEvent(world, blockposition, this).isCancelled()) { -+ this.world.setTypeUpdate(blockposition, iblockdata); ++ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(level, blockposition, this).isCancelled()) { ++ this.level.setTypeUpdate(blockposition, iblockdata); ++ ++this.blocksSetOnFire; + } + // CraftBukkit end } for (int j = 0; j < i; ++j) { -@@ -114,7 +140,11 @@ +@@ -175,8 +184,12 @@ - iblockdata = BlockFireAbstract.a((IBlockAccess) this.world, blockposition1); - if (this.world.getType(blockposition1).isAir() && iblockdata.canPlace(this.world, blockposition1)) { -- this.world.setTypeUpdate(blockposition1, iblockdata); + iblockdata = BlockFireAbstract.a((IBlockAccess) this.level, blockposition1); + if (this.level.getType(blockposition1).isAir() && iblockdata.canPlace(this.level, blockposition1)) { +- this.level.setTypeUpdate(blockposition1, iblockdata); +- ++this.blocksSetOnFire; + // CraftBukkit start - add "!isEffect" -+ if (!isEffect && !CraftEventFactory.callBlockIgniteEvent(world, blockposition1, this).isCancelled()) { -+ this.world.setTypeUpdate(blockposition1, iblockdata); ++ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(level, blockposition1, this).isCancelled()) { ++ this.level.setTypeUpdate(blockposition1, iblockdata); ++ ++this.blocksSetOnFire; + } + // CraftBukkit end } } +@@ -240,8 +253,9 @@ + iblockdata = world.getType(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 + }); + world.triggerEffect(3002, blockposition1, -1); + return Optional.of(blockposition1); diff --git a/nms-patches/net/minecraft/world/entity/EntityLiving.patch b/nms-patches/net/minecraft/world/entity/EntityLiving.patch index 18703b041..8362a4dee 100644 --- a/nms-patches/net/minecraft/world/entity/EntityLiving.patch +++ b/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 -@@ -111,6 +111,30 @@ +@@ -119,6 +119,30 @@ import net.minecraft.world.scores.ScoreboardTeam; import org.apache.logging.log4j.Logger; @@ -30,11 +30,11 @@ + public abstract class EntityLiving extends Entity { - private static final UUID b = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); -@@ -196,6 +220,21 @@ - private float bB; - private float bC; - protected BehaviorController bg; + private static final UUID SPEED_MODIFIER_SPRINTING_UUID = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); +@@ -227,6 +251,21 @@ + private float swimAmount; + private float swimAmountO; + protected BehaviorController brain; + // CraftBukkit start + public int expToDrop; + public int maxAirTicks = 300; @@ -43,7 +43,7 @@ + public final org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes; + public boolean collides = true; + public Set collidableExemptions = new HashSet<>(); -+ public boolean canPickUpLoot; ++ public boolean bukkitPickUpLoot; + + @Override + public float getBukkitYaw() { @@ -53,57 +53,59 @@ protected EntityLiving(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -207,7 +246,9 @@ - this.activeItem = ItemStack.b; - this.by = Optional.empty(); - this.attributeMap = new AttributeMapBase(AttributeDefaults.a(entitytypes)); +@@ -239,7 +278,9 @@ + this.useItem = ItemStack.EMPTY; + this.lastClimbablePos = Optional.empty(); + this.attributes = new AttributeMapBase(AttributeDefaults.a(entitytypes)); - this.setHealth(this.getMaxHealth()); -+ this.craftAttributes = new CraftAttributeMap(attributeMap); // CraftBukkit ++ 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.datawatcher.set(EntityLiving.HEALTH, (float) this.getAttributeInstance(GenericAttributes.MAX_HEALTH).getValue()); - this.i = true; - this.az = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); - this.af(); -@@ -274,7 +315,13 @@ ++ this.entityData.set(EntityLiving.DATA_HEALTH_ID, (float) this.getAttributeInstance(GenericAttributes.MAX_HEALTH).getValue()); + this.blocksBuilding = true; + this.rotA = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); + this.ah(); +@@ -306,7 +347,13 @@ double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D); int i = (int) (150.0D * d1); -- ((WorldServer) this.world).a(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); +- ((WorldServer) this.level).a(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); + // CraftBukkit start - visiblity api + if (this instanceof EntityPlayer) { -+ ((WorldServer) this.world).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.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false); + } else { -+ ((WorldServer) this.world).a(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); ++ ((WorldServer) this.level).a(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); + } + // CraftBukkit end } } -@@ -496,7 +543,7 @@ +@@ -566,7 +613,7 @@ - protected void cU() { - ++this.deathTicks; -- if (this.deathTicks == 20) { -+ if (this.deathTicks >= 20 && !this.dead) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead) - this.die(); - - for (int i = 0; i < 20; ++i) { -@@ -587,7 +634,13 @@ + protected void dB() { + ++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); + } +@@ -658,9 +705,15 @@ } protected void playEquipSound(ItemStack itemstack) { -- if (!itemstack.isEmpty()) { + // CraftBukkit start + this.playEquipSound(itemstack, false); + } + + protected void playEquipSound(ItemStack itemstack, boolean silent) { -+ if (!itemstack.isEmpty() && !silent) { -+ // CraftBukkit end - SoundEffect soundeffect = SoundEffects.ITEM_ARMOR_EQUIP_GENERIC; - Item item = itemstack.getItem(); + SoundEffect soundeffect = itemstack.M(); -@@ -657,6 +710,17 @@ +- if (!itemstack.isEmpty() && soundeffect != null && !this.isSpectator()) { ++ if (!itemstack.isEmpty() && soundeffect != null && !this.isSpectator() && !silent) { ++ // CraftBukkit end + this.a(GameEvent.EQUIP); + this.playSound(soundeffect, 1.0F, 1.0F); + } +@@ -722,6 +775,17 @@ } } @@ -121,7 +123,7 @@ if (nbttagcompound.hasKeyOfType("Health", 99)) { this.setHealth(nbttagcompound.getFloat("Health")); } -@@ -694,9 +758,32 @@ +@@ -759,9 +823,32 @@ } @@ -148,16 +150,16 @@ + // CraftBukkit end + protected void tickPotionEffects() { - Iterator iterator = this.effects.keySet().iterator(); + Iterator iterator = this.activeEffects.keySet().iterator(); + isTickingEffects = true; // CraftBukkit try { while (iterator.hasNext()) { MobEffectList mobeffectlist = (MobEffectList) iterator.next(); -@@ -706,6 +793,12 @@ - this.a(mobeffect, true); +@@ -771,6 +858,12 @@ + this.a(mobeffect, true, (Entity) null); })) { - if (!this.world.isClientSide) { + if (!this.level.isClientSide) { + // CraftBukkit start + EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, mobeffect, null, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.EXPIRATION); + if (event.isCancelled()) { @@ -165,9 +167,9 @@ + } + // CraftBukkit end iterator.remove(); - this.b(mobeffect); + this.a(mobeffect); } -@@ -716,6 +809,17 @@ +@@ -781,6 +874,17 @@ } catch (ConcurrentModificationException concurrentmodificationexception) { ; } @@ -183,10 +185,10 @@ + effectsToProcess.clear(); + // CraftBukkit end - if (this.updateEffects) { - if (!this.world.isClientSide) { -@@ -825,7 +929,13 @@ - this.datawatcher.set(EntityLiving.f, 0); + if (this.effectsDirty) { + if (!this.level.isClientSide) { +@@ -907,7 +1011,13 @@ + this.entityData.set(EntityLiving.DATA_EFFECT_COLOR_ID, 0); } + // CraftBukkit start @@ -196,45 +198,49 @@ + + public boolean removeAllEffects(EntityPotionEffectEvent.Cause cause) { + // CraftBukkit end - if (this.world.isClientSide) { + if (this.level.isClientSide) { return false; } else { -@@ -834,7 +944,14 @@ +@@ -916,7 +1026,14 @@ boolean flag; for (flag = false; iterator.hasNext(); flag = true) { -- this.b((MobEffect) iterator.next()); +- this.a((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.b(effect); ++ this.a(effect); + // CraftBukkit end iterator.remove(); } -@@ -859,18 +976,44 @@ - return (MobEffect) this.effects.get(mobeffectlist); +@@ -945,18 +1062,48 @@ + return this.addEffect(mobeffect, (Entity) null); } + // CraftBukkit start - public boolean addEffect(MobEffect mobeffect) { -+ return addEffect(mobeffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN); ++ public boolean addEffect(MobEffect mobeffect, EntityPotionEffectEvent.Cause cause) { ++ return this.addEffect(mobeffect, (Entity) null, cause); + } + -+ public boolean addEffect(MobEffect mobeffect, EntityPotionEffectEvent.Cause cause) { + public boolean addEffect(MobEffect mobeffect, @Nullable Entity entity) { ++ return this.addEffect(mobeffect, entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN); ++ } ++ ++ public boolean addEffect(MobEffect mobeffect, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause) { + if (isTickingEffects) { + effectsToProcess.add(new ProcessableEffect(mobeffect, cause)); + return true; + } + // CraftBukkit end + - if (!this.d(mobeffect)) { + if (!this.c(mobeffect)) { return false; } else { - MobEffect mobeffect1 = (MobEffect) this.effects.get(mobeffect.getMobEffect()); + MobEffect mobeffect1 = (MobEffect) this.activeEffects.get(mobeffect.getMobEffect()); + // CraftBukkit start + boolean override = false; @@ -249,19 +255,19 @@ + // CraftBukkit end + if (mobeffect1 == null) { - this.effects.put(mobeffect.getMobEffect(), mobeffect); - this.a(mobeffect); + this.activeEffects.put(mobeffect.getMobEffect(), mobeffect); + this.a(mobeffect, entity); return true; - } else if (mobeffect1.b(mobeffect)) { + // CraftBukkit start + } else if (event.isOverride()) { + mobeffect1.b(mobeffect); - this.a(mobeffect1, true); + this.a(mobeffect1, true, entity); + // CraftBukkit end return true; } else { return false; -@@ -894,13 +1037,39 @@ +@@ -993,13 +1140,39 @@ return this.getMonsterType() == EnumMonsterType.UNDEAD; } @@ -278,7 +284,7 @@ + return null; + } + -+ MobEffect effect = this.effects.get(mobeffectlist); ++ MobEffect effect = this.activeEffects.get(mobeffectlist); + if (effect == null) { + return null; + } @@ -288,7 +294,7 @@ + return null; + } + - return (MobEffect) this.effects.remove(mobeffectlist); + return (MobEffect) this.activeEffects.remove(mobeffectlist); } public boolean removeEffect(MobEffectList mobeffectlist) { @@ -301,8 +307,8 @@ + // CraftBukkit end if (mobeffect != null) { - this.b(mobeffect); -@@ -937,20 +1106,55 @@ + this.a(mobeffect); +@@ -1036,20 +1209,55 @@ } @@ -319,7 +325,7 @@ + EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), f, regainReason); + // Suppress during worldgen + if (this.valid) { -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + } + + if (!event.isCancelled()) { @@ -336,7 +342,7 @@ + return (float) ((EntityPlayer) this).getBukkitEntity().getHealth(); + } + // CraftBukkit end - return (Float) this.datawatcher.get(EntityLiving.HEALTH); + return (Float) this.entityData.get(EntityLiving.DATA_HEALTH_ID); } public void setHealth(float f) { @@ -356,31 +362,22 @@ + return; + } + // CraftBukkit end - this.datawatcher.set(EntityLiving.HEALTH, MathHelper.a(f, 0.0F, this.getMaxHealth())); + this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.a(f, 0.0F, this.getMaxHealth())); } -@@ -964,7 +1168,7 @@ +@@ -1063,7 +1271,7 @@ return false; - } else if (this.world.isClientSide) { + } else if (this.level.isClientSide) { return false; -- } else if (this.dl()) { -+ } else if (this.dead || this.killed || this.getHealth() <= 0.0F) { // CraftBukkit - Don't allow entities that got set to dead/killed elsewhere to get damaged and die +- } else if (this.dV()) { ++ } 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; -@@ -976,17 +1180,19 @@ - this.ticksFarFromPlayer = 0; +@@ -1074,10 +1282,11 @@ + + this.noActionTime = 0; float f1 = f; - -- if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { -+ // CraftBukkit - Moved into damageEntity0(DamageSource, float) -+ if (false && (damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { - this.getEquipment(EnumItemSlot.HEAD).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this, (entityliving) -> { - entityliving.broadcastItemBreak(EnumItemSlot.HEAD); - }); - f *= 0.75F; - } - - boolean flag = false; + boolean flag = f > 0.0F && this.applyBlockingModifier(damagesource); // Copied from below float f2 = 0.0F; @@ -391,38 +388,45 @@ this.damageShield(f); f2 = f; f = 0.0F; -@@ -1004,22 +1210,41 @@ - this.av = 1.5F; +@@ -1095,27 +1304,47 @@ + this.animationSpeed = 1.5F; boolean flag1 = true; -- if ((float) this.noDamageTicks > 10.0F) { -+ if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) { // CraftBukkit - restore use of maxNoDamageTicks - if (f <= this.lastDamage) { +- if ((float) this.invulnerableTime > 10.0F) { ++ if ((float) this.invulnerableTime > (float) this.invulnerableDuration / 2.0F) { // CraftBukkit - restore use of maxNoDamageTicks + if (f <= this.lastHurt) { + this.forceExplosionKnockback = true; // CraftBukkit - SPIGOT-949 - for vanilla consistency, cooldown does not prevent explosion knockback return false; } -- this.damageEntity0(damagesource, f - this.lastDamage); +- this.damageEntity0(damagesource, f - this.lastHurt); + // CraftBukkit start -+ if (!this.damageEntity0(damagesource, f - this.lastDamage)) { ++ if (!this.damageEntity0(damagesource, f - this.lastHurt)) { + return false; + } + // CraftBukkit end - this.lastDamage = f; + this.lastHurt = f; flag1 = false; } else { + // CraftBukkit start + if (!this.damageEntity0(damagesource, f)) { + return false; + } - this.lastDamage = f; -- this.noDamageTicks = 20; + this.lastHurt = f; +- this.invulnerableTime = 20; - this.damageEntity0(damagesource, f); -+ this.noDamageTicks = this.maxNoDamageTicks; // CraftBukkit - restore use of maxNoDamageTicks ++ this.invulnerableTime = this.invulnerableDuration; // CraftBukkit - restore use of maxNoDamageTicks + // this.damageEntity0(damagesource, f); + // CraftBukkit end this.hurtDuration = 10; - this.hurtTicks = this.hurtDuration; + this.hurtTime = this.hurtDuration; + } + +- if (damagesource.g() && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { ++ // CraftBukkit - Moved into damageEntity0(DamageSource, float) ++ if (false && damagesource.g() && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { + this.damageHelmet(damagesource, f); + f *= 0.75F; } + // CraftBukkit start @@ -434,21 +438,21 @@ + } + // CraftBukkit end + - this.ap = 0.0F; + this.hurtDir = 0.0F; Entity entity1 = damagesource.getEntity(); -@@ -1140,19 +1365,29 @@ +@@ -1238,19 +1467,29 @@ EnumHand[] aenumhand = EnumHand.values(); int i = aenumhand.length; + // CraftBukkit start -+ ItemStack itemstack1 = ItemStack.b; ++ ItemStack itemstack1 = ItemStack.EMPTY; for (int j = 0; j < i; ++j) { EnumHand enumhand = aenumhand[j]; - ItemStack itemstack1 = this.b(enumhand); + itemstack1 = this.b(enumhand); - if (itemstack1.getItem() == Items.TOTEM_OF_UNDYING) { + if (itemstack1.a(Items.TOTEM_OF_UNDYING)) { itemstack = itemstack1.cloneItemStack(); - itemstack1.subtract(1); + // itemstack1.subtract(1); // CraftBukkit @@ -460,7 +464,7 @@ - if (this instanceof EntityPlayer) { + EntityResurrectEvent event = new EntityResurrectEvent((LivingEntity) this.getBukkitEntity()); + event.setCancelled(itemstack == null); -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + if (!itemstack1.isEmpty()) { @@ -471,21 +475,21 @@ EntityPlayer entityplayer = (EntityPlayer) this; entityplayer.b(StatisticList.ITEM_USED.b(Items.TOTEM_OF_UNDYING)); -@@ -1160,14 +1395,16 @@ +@@ -1258,14 +1497,16 @@ } this.setHealth(1.0F); - this.removeAllEffects(); - this.addEffect(new MobEffect(MobEffects.REGENERATION, 900, 1)); -- this.addEffect(new MobEffect(MobEffects.ABSORBTION, 100, 1)); +- this.addEffect(new MobEffect(MobEffects.ABSORPTION, 100, 1)); - this.addEffect(new MobEffect(MobEffects.FIRE_RESISTANCE, 800, 0)); + // CraftBukkit start + this.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); + this.addEffect(new MobEffect(MobEffects.REGENERATION, 900, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); -+ this.addEffect(new MobEffect(MobEffects.ABSORBTION, 100, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); ++ 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.world.broadcastEntityEffect(this, (byte) 35); + this.level.broadcastEntityEffect(this, (byte) 35); } - return itemstack != null; @@ -493,9 +497,9 @@ } } -@@ -1265,6 +1502,13 @@ +@@ -1374,6 +1615,13 @@ if (!flag) { - EntityItem entityitem = new EntityItem(this.world, this.locX(), this.locY(), this.locZ(), new ItemStack(Items.bt)); + EntityItem entityitem = new EntityItem(this.level, this.locX(), this.locY(), this.locZ(), 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()); @@ -504,15 +508,15 @@ + return; + } + // CraftBukkit end - this.world.addEntity(entityitem); + this.level.addEntity(entityitem); } } -@@ -1284,28 +1528,46 @@ +@@ -1393,21 +1641,40 @@ - boolean flag = this.lastDamageByPlayerTime > 0; + boolean flag = this.lastHurtByPlayerTime > 0; + this.dropInventory(); // CraftBukkit - from below - if (this.cW() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) { + if (this.dD() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { this.a(damagesource, flag); this.dropDeathLoot(damagesource, i, flag); } @@ -531,48 +535,43 @@ - protected void dropExperience() { + // CraftBukkit start + public int getExpReward() { - if (!this.world.isClientSide && (this.alwaysGivesExp() || this.lastDamageByPlayerTime > 0 && this.isDropExperience() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT))) { - int i = this.getExpValue(this.killer); + 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); + return i; + } else { + return 0; + } + } + // CraftBukkit end - ++ + protected void dropExperience() { + // CraftBukkit start - Update getExpReward() above if the removed if() changes! + if (true) { -+ int i = this.expToDrop; - while (i > 0) { - int j = EntityExperienceOrb.getOrbValue(i); - - i -= j; - this.world.addEntity(new EntityExperienceOrb(this.world, this.locX(), this.locY(), this.locZ(), j)); - } ++ EntityExperienceOrb.a((WorldServer) this.level, this.getPositionVector(), this.expToDrop); + this.expToDrop = 0; } + // CraftBukkit end } -@@ -1426,9 +1688,14 @@ - int i = this.e(f, f1); +@@ -1523,9 +1790,14 @@ + int i = this.d(f, f1); if (i > 0) { + // CraftBukkit start -+ if (!this.damageEntity(DamageSource.FALL, (float) i)) { ++ if (!this.damageEntity(damagesource, (float) i)) { + return true; + } + // CraftBukkit end this.playSound(this.getSoundFall(i), 1.0F, 1.0F); this.playBlockStepSound(); -- this.damageEntity(DamageSource.FALL, (float) i); -+ // this.damageEntity(DamageSource.FALL, (float) i); // CraftBukkit - moved up +- this.damageEntity(damagesource, (float) i); ++ // this.damageEntity(damagesource, (float) i); // CraftBukkit - moved up return true; } else { return flag; -@@ -1468,7 +1735,7 @@ +@@ -1574,7 +1846,7 @@ protected float applyArmorModifier(DamageSource damagesource, float f) { if (!damagesource.ignoresArmor()) { @@ -581,17 +580,17 @@ f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.b(GenericAttributes.ARMOR_TOUGHNESS)); } -@@ -1481,7 +1748,8 @@ +@@ -1587,7 +1859,8 @@ } else { int i; -- if (this.hasEffect(MobEffects.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { +- if (this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { + // CraftBukkit - Moved to damageEntity0(DamageSource, float) -+ if (false && this.hasEffect(MobEffects.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { - i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; ++ if (false && this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { + i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f1 = f * (float) j; -@@ -1512,28 +1780,173 @@ +@@ -1618,29 +1891,172 @@ } } @@ -608,7 +607,7 @@ + Function hardHat = new Function() { + @Override + public Double apply(Double f) { -+ if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !EntityLiving.this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { ++ if (damagesource.g() && !EntityLiving.this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { + return -(f - (f * 0.75F)); + + } @@ -639,8 +638,8 @@ + Function resistance = new Function() { + @Override + public Double apply(Double f) { -+ if (!damagesource.isStarvation() && EntityLiving.this.hasEffect(MobEffects.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { -+ int i = (EntityLiving.this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; ++ if (!damagesource.isStarvation() && 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; + return -(f - (f1 / 25.0F)); @@ -675,9 +674,12 @@ + 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); @@ -689,15 +691,10 @@ + } + } + } - -- f = Math.max(f - this.getAbsorptionHearts(), 0.0F); -- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f)); -- float f2 = f1 - f; ++ + // Apply damage to helmet -+ if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(EnumItemSlot.HEAD) != null) { -+ this.getEquipment(EnumItemSlot.HEAD).damage((int) (event.getDamage() * 4.0F + this.random.nextFloat() * event.getDamage() * 2.0F), this, (entityliving) -> { -+ entityliving.broadcastItemBreak(EnumItemSlot.HEAD); -+ }); ++ if (damagesource.g() && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { ++ this.damageHelmet(damagesource, f); + } + + // Apply damage to armor @@ -705,12 +702,12 @@ + float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT)); + this.damageArmor(damagesource, armorDamage); + } - ++ + // Apply blocking code // PAIL: steal from above + if (event.getDamage(DamageModifier.BLOCKING) < 0) { -+ this.world.broadcastEntityEffect(this, (byte) 29); // SPIGOT-4635 - shield damage sound ++ this.level.broadcastEntityEffect(this, (byte) 29); // SPIGOT-4635 - shield damage sound + this.damageShield((float) -event.getDamage(DamageModifier.BLOCKING)); -+ Entity entity = damagesource.j(); ++ Entity entity = damagesource.k(); + + if (entity instanceof EntityLiving) { + this.shieldBlock((EntityLiving) entity); @@ -747,13 +744,14 @@ + if (!human) { + this.setAbsorptionHearts(this.getAbsorptionHearts() - f); + } + this.a(GameEvent.ENTITY_DAMAGED, damagesource.getEntity()); + + return true; + } else { + // Duplicate triggers if blocking + if (event.getDamage(DamageModifier.BLOCKING) < 0) { + if (this instanceof EntityPlayer) { -+ CriterionTriggers.h.a((EntityPlayer) this, damagesource, f, originalDamage, true); ++ CriterionTriggers.ENTITY_HURT_PLAYER.a((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)); @@ -761,7 +759,7 @@ + } + + if (damagesource.getEntity() instanceof EntityPlayer) { -+ CriterionTriggers.g.a((EntityPlayer) damagesource.getEntity(), this, damagesource, f, originalDamage, true); ++ CriterionTriggers.PLAYER_HURT_ENTITY.a((EntityPlayer) damagesource.getEntity(), this, damagesource, f, originalDamage, true); + } + + return false; @@ -775,28 +773,27 @@ } public CombatTracker getCombatTracker() { -@@ -1554,9 +1967,19 @@ +@@ -1661,8 +2077,18 @@ } public final void setArrowCount(int i) { -- this.datawatcher.set(EntityLiving.ARROWS_IN_BODY, i); +- this.entityData.set(EntityLiving.DATA_ARROW_COUNT_ID, i); + // CraftBukkit start + setArrowCount(i, false); - } - ++ } ++ + public final void setArrowCount(int i, boolean flag) { + ArrowBodyCountChangeEvent event = CraftEventFactory.callArrowBodyCountChangeEvent(this, getArrowCount(), i, flag); + if (event.isCancelled()) { + return; + } -+ this.datawatcher.set(EntityLiving.ARROWS_IN_BODY, event.getNewAmount()); -+ } -+ // CraftBukkit end -+ - public final int dz() { - return (Integer) this.datawatcher.get(EntityLiving.bi); ++ this.entityData.set(EntityLiving.DATA_ARROW_COUNT_ID, event.getNewAmount()); } -@@ -1684,6 +2107,12 @@ ++ // CraftBukkit end + + public final int eh() { + return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID); +@@ -1958,6 +2384,12 @@ public abstract ItemStack getEquipment(EnumItemSlot enumitemslot); @@ -809,64 +806,57 @@ @Override public abstract void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack); -@@ -1906,6 +2335,7 @@ +@@ -2202,6 +2634,7 @@ } - if (this.onGround && !this.world.isClientSide) { + if (this.onGround && !this.level.isClientSide) { + if (getFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit this.setFlag(7, false); } } else { -@@ -2411,6 +2841,7 @@ +@@ -2732,6 +3165,7 @@ } - if (!this.world.isClientSide) { + if (!this.level.isClientSide) { + if (flag != this.getFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, flag).isCancelled()) // CraftBukkit this.setFlag(7, flag); } -@@ -2531,6 +2962,7 @@ - } - - public boolean hasLineOfSight(Entity entity) { -+ if (this.world != entity.world) return false; // CraftBukkit - SPIGOT-5675, SPIGOT-5798, MC-149563 - Vec3D vec3d = new Vec3D(this.locX(), this.getHeadY(), this.locZ()); - Vec3D vec3d1 = new Vec3D(entity.locX(), entity.getHeadY(), entity.locZ()); - -@@ -2548,13 +2980,20 @@ +@@ -2899,14 +3333,21 @@ @Override public boolean isInteractable() { -- return !this.dead; -+ return !this.dead && this.collides; // CraftBukkit +- 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 -+ } -+ + } + + // CraftBukkit start - collidable API + @Override -+ public boolean canCollideWith(Entity entity) { ++ public boolean canCollideWithBukkit(Entity entity) { + return isCollidable() && this.collides != this.collidableExemptions.contains(entity.getUniqueID()); - } ++ } + // CraftBukkit end - ++ @Override protected void velocityChanged() { -@@ -2748,7 +3187,25 @@ + this.hurtMarked = this.random.nextDouble() >= this.b(GenericAttributes.KNOCKBACK_RESISTANCE); +@@ -3104,7 +3545,25 @@ } else { - if (!this.activeItem.isEmpty() && this.isHandRaised()) { - this.b(this.activeItem, 16); -- ItemStack itemstack = this.activeItem.a(this.world, this); + if (!this.useItem.isEmpty() && this.isHandRaised()) { + this.b(this.useItem, 16); +- ItemStack itemstack = this.useItem.a(this.level, this); + // CraftBukkit start - fire PlayerItemConsumeEvent + ItemStack itemstack; + if (this instanceof EntityPlayer) { -+ org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.activeItem); ++ org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.useItem); + PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem); -+ world.getServer().getPluginManager().callEvent(event); ++ level.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + // Update client @@ -875,15 +865,15 @@ + return; + } + -+ itemstack = (craftItem.equals(event.getItem())) ? this.activeItem.a(this.world, this) : CraftItemStack.asNMSCopy(event.getItem()).a(world, this); ++ itemstack = (craftItem.equals(event.getItem())) ? this.useItem.a(this.level, this) : CraftItemStack.asNMSCopy(event.getItem()).a(level, this); + } else { -+ itemstack = this.activeItem.a(this.world, this); ++ itemstack = this.useItem.a(this.level, this); + } + // CraftBukkit end - if (itemstack != this.activeItem) { + if (itemstack != this.useItem) { this.a(enumhand, itemstack); -@@ -2816,6 +3273,12 @@ +@@ -3176,6 +3635,12 @@ } public boolean a(double d0, double d1, double d2, boolean flag) { @@ -896,7 +886,7 @@ double d3 = this.locX(); double d4 = this.locY(); double d5 = this.locZ(); -@@ -2840,16 +3303,41 @@ +@@ -3200,16 +3665,41 @@ } if (flag2) { @@ -914,8 +904,8 @@ + + if (flag1) { + if (!(this instanceof EntityPlayer)) { -+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.world.getWorld(), d3, d4, d5), new Location(this.world.getWorld(), d0, d6, d2)); -+ this.world.getServer().getPluginManager().callEvent(teleport); ++ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.level.getWorld(), d3, d4, d5), new Location(this.level.getWorld(), d0, d6, d2)); ++ this.level.getServer().getPluginManager().callEvent(teleport); + if (!teleport.isCancelled()) { + Location to = teleport.getTo(); + this.enderTeleportTo(to.getX(), to.getY(), to.getZ()); @@ -924,7 +914,7 @@ + } + } else { + // player teleport event is called in the underlining code -+ if (((EntityPlayer) this).playerConnection.a(d0, d6, d2, this.yaw, this.pitch, java.util.Collections.emptySet(), cause)) { ++ if (((EntityPlayer) this).connection.a(d0, d6, d2, this.getYRot(), this.getXRot(), java.util.Collections.emptySet(), false, cause)) { + return Optional.empty(); + } + } @@ -941,7 +931,7 @@ } else { if (flag) { world.broadcastEntityEffect(this, (byte) 46); -@@ -2859,7 +3347,7 @@ +@@ -3219,7 +3709,7 @@ ((EntityCreature) this).getNavigation().o(); } @@ -950,16 +940,25 @@ } } -@@ -2940,7 +3428,7 @@ +@@ -3302,7 +3792,7 @@ } public void entityWakeup() { - Optional optional = this.getBedPosition(); + Optional optional = this.getBedPosition(); // CraftBukkit - decompile error - World world = this.world; + World world = this.level; - this.world.getClass(); -@@ -3011,7 +3499,7 @@ + java.util.Objects.requireNonNull(this.level); +@@ -3334,7 +3824,7 @@ + + @Nullable + public EnumDirection eW() { +- BlockPosition blockposition = (BlockPosition) this.getBedPosition().orElse((Object) null); ++ BlockPosition blockposition = (BlockPosition) this.getBedPosition().orElse(null); // CraftBukkit - decompile error + + return blockposition != null ? BlockBed.a((IBlockAccess) this.level, blockposition) : null; + } +@@ -3383,7 +3873,7 @@ Pair pair = (Pair) iterator.next(); if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) { diff --git a/nms-patches/net/minecraft/world/entity/EntityTypes.patch b/nms-patches/net/minecraft/world/entity/EntityTypes.patch index b7734c10e..01c131496 100644 --- a/nms-patches/net/minecraft/world/entity/EntityTypes.patch +++ b/nms-patches/net/minecraft/world/entity/EntityTypes.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/world/entity/EntityTypes.java +++ b/net/minecraft/world/entity/EntityTypes.java -@@ -142,7 +142,7 @@ - public class EntityTypes { - +@@ -152,7 +152,7 @@ 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 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 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 ARMOR_STAND = a("armor_stand", EntityTypes.Builder.a(EntityArmorStand::new, EnumCreatureType.MISC).a(0.5F, 1.975F).trackingRange(10)); public static final EntityTypes ARROW = a("arrow", EntityTypes.Builder.a(EntityTippedArrow::new, EnumCreatureType.MISC).a(0.5F, 0.5F).trackingRange(4).updateInterval(20)); - public static final EntityTypes BAT = a("bat", EntityTypes.Builder.a(EntityBat::new, EnumCreatureType.AMBIENT).a(0.5F, 0.9F).trackingRange(5)); -@@ -267,7 +267,7 @@ - private MinecraftKey bq; - private final EntitySize br; + public static final EntityTypes AXOLOTL = a("axolotl", EntityTypes.Builder.a(Axolotl::new, EnumCreatureType.UNDERGROUND_WATER_CREATURE).a(0.75F, 0.42F).trackingRange(10)); +@@ -282,7 +282,7 @@ + private MinecraftKey lootTable; + private final EntitySize dimensions; - private static EntityTypes a(String s, EntityTypes.Builder entitytypes_builder) { + private static EntityTypes a(String s, EntityTypes.Builder entitytypes_builder) { // CraftBukkit - decompile error return (EntityTypes) IRegistry.a((IRegistry) IRegistry.ENTITY_TYPE, s, (Object) entitytypes_builder.a(s)); } -@@ -299,10 +299,18 @@ +@@ -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) { @@ -33,12 +33,12 @@ if (t0 != null) { - worldserver.addAllEntities(t0); + worldserver.addAllEntities(t0, spawnReason); -+ return !t0.dead ? t0 : null; // Don't return an entity when CreatureSpawnEvent is canceled ++ return !t0.isRemoved() ? t0 : null; // Don't return an entity when CreatureSpawnEvent is canceled + // CraftBukkit end } return t0; -@@ -338,7 +346,7 @@ +@@ -353,7 +361,7 @@ t0.setCustomName(ichatbasecomponent); } @@ -47,7 +47,7 @@ return t0; } } -@@ -481,7 +489,7 @@ +@@ -512,7 +520,7 @@ } return entity; @@ -55,9 +55,18 @@ + }).orElse(null); // CraftBukkit - decompile error } - private static Optional b(NBTTagCompound nbttagcompound, World world) { -@@ -533,7 +541,7 @@ - this.g = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC; + public static Stream a(final List list, final World world) { +@@ -569,7 +577,7 @@ + + @Nullable + public T a(Entity entity) { +- return entity.getEntityType() == this ? entity : null; ++ return entity.getEntityType() == this ? (T) entity : null; // CraftBukkit - decompile error + } + + @Override +@@ -596,7 +604,7 @@ + this.canSpawnFarFromPlayer = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC; } - public static EntityTypes.Builder a(EntityTypes.b entitytypes_b, EnumCreatureType enumcreaturetype) { diff --git a/nms-patches/net/minecraft/world/entity/IEntityAngerable.patch b/nms-patches/net/minecraft/world/entity/IEntityAngerable.patch index d2dd6ec88..2c73911e9 100644 --- a/nms-patches/net/minecraft/world/entity/IEntityAngerable.patch +++ b/nms-patches/net/minecraft/world/entity/IEntityAngerable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/IEntityAngerable.java +++ b/net/minecraft/world/entity/IEntityAngerable.java -@@ -103,7 +103,7 @@ +@@ -108,7 +108,7 @@ default void pacify() { this.setLastDamager((EntityLiving) null); this.setAngerTarget((UUID) null); @@ -9,12 +9,12 @@ this.setAnger(0); } -@@ -113,6 +113,8 @@ +@@ -121,6 +121,8 @@ void setGoalTarget(@Nullable EntityLiving entityliving); -+ boolean setGoalTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent); // CraftBukkit ++ boolean setGoalTarget(@Nullable EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent); // CraftBukkit + + boolean c(EntityLiving entityliving); + @Nullable - EntityLiving getGoalTarget(); - } diff --git a/nms-patches/net/minecraft/world/entity/IEntitySelector.patch b/nms-patches/net/minecraft/world/entity/IEntitySelector.patch index f755c3452..0595c7678 100644 --- a/nms-patches/net/minecraft/world/entity/IEntitySelector.patch +++ b/nms-patches/net/minecraft/world/entity/IEntitySelector.patch @@ -3,9 +3,9 @@ @@ -42,7 +42,7 @@ ScoreboardTeamBase.EnumTeamPush scoreboardteambase_enumteampush = scoreboardteambase == null ? ScoreboardTeamBase.EnumTeamPush.ALWAYS : scoreboardteambase.getCollisionRule(); - return (Predicate) (scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.NEVER ? Predicates.alwaysFalse() : IEntitySelector.g.and((entity1) -> { + return (Predicate) (scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.NEVER ? Predicates.alwaysFalse() : IEntitySelector.NO_SPECTATORS.and((entity1) -> { - if (!entity1.isCollidable()) { -+ if (!entity1.canCollideWith(entity) || !entity.canCollideWith(entity1)) { // CraftBukkit - collidable API ++ if (!entity1.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(entity1)) { // CraftBukkit - collidable API return false; - } else if (entity.world.isClientSide && (!(entity1 instanceof EntityHuman) || !((EntityHuman) entity1).ez())) { + } else if (entity.level.isClientSide && (!(entity1 instanceof EntityHuman) || !((EntityHuman) entity1).fh())) { return false; diff --git a/nms-patches/net/minecraft/world/entity/SaddleStorage.patch b/nms-patches/net/minecraft/world/entity/SaddleStorage.patch index 7f7468574..9ab005915 100644 --- a/nms-patches/net/minecraft/world/entity/SaddleStorage.patch +++ b/nms-patches/net/minecraft/world/entity/SaddleStorage.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/SaddleStorage.java +++ b/net/minecraft/world/entity/SaddleStorage.java -@@ -38,6 +38,15 @@ +@@ -40,6 +40,15 @@ } } + // CraftBukkit add setBoostTicks(int) + public void setBoostTicks(int ticks) { + this.boosting = true; -+ this.currentBoostTicks = 0; -+ this.boostTicks = ticks; -+ this.dataWatcher.set(this.dataWatcherBoostTicks, this.boostTicks); ++ this.boostTime = 0; ++ this.boostTimeTotal = ticks; ++ this.entityData.set(this.boostTimeAccessor, this.boostTimeTotal); + } + // CraftBukkit end + diff --git a/nms-patches/net/minecraft/world/entity/ai/attributes/AttributeRanged.patch b/nms-patches/net/minecraft/world/entity/ai/attributes/AttributeRanged.patch index e513acad6..9a848218c 100644 --- a/nms-patches/net/minecraft/world/entity/ai/attributes/AttributeRanged.patch +++ b/nms-patches/net/minecraft/world/entity/ai/attributes/AttributeRanged.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/ai/attributes/AttributeRanged.java +++ b/net/minecraft/world/entity/ai/attributes/AttributeRanged.java -@@ -22,6 +22,8 @@ +@@ -30,6 +30,8 @@ @Override public double a(double d0) { + if (d0 != d0) return getDefault(); // CraftBukkit + - d0 = MathHelper.a(d0, this.a, this.maximum); + d0 = MathHelper.a(d0, this.minValue, this.maxValue); return d0; } diff --git a/nms-patches/net/minecraft/world/entity/ai/attributes/GenericAttributes.patch b/nms-patches/net/minecraft/world/entity/ai/attributes/GenericAttributes.patch index 8c95a657a..1a84234af 100644 --- a/nms-patches/net/minecraft/world/entity/ai/attributes/GenericAttributes.patch +++ b/nms-patches/net/minecraft/world/entity/ai/attributes/GenericAttributes.patch @@ -5,8 +5,8 @@ package net.minecraft.world.entity.ai.attributes; import net.minecraft.core.IRegistry; -@@ -19,6 +20,6 @@ - public static final AttributeBase JUMP_STRENGTH = a("horse.jump_strength", (new AttributeRanged("attribute.name.horse.jump_strength", 0.7D, 0.0D, 2.0D)).a(true)); +@@ -21,6 +22,6 @@ + public GenericAttributes() {} private static AttributeBase a(String s, AttributeBase attributebase) { - return (AttributeBase) IRegistry.a(IRegistry.ATTRIBUTE, s, (Object) attributebase); diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.patch index 9143810ac..c7993c393 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.patch @@ -12,11 +12,11 @@ + public class BehaviorAttackTargetForget extends Behavior { - private final Predicate b; -@@ -60,6 +66,17 @@ + private static final int TIMEOUT_TO_GET_WITHIN_ATTACK_RANGE = 200; +@@ -77,6 +83,17 @@ } - private void d(E e0) { + protected void a(E e0) { + // CraftBukkit start + EntityLiving old = e0.getBehaviorController().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null); + EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(e0, null, (old != null && !old.isAlive()) ? EntityTargetEvent.TargetReason.TARGET_DIED : EntityTargetEvent.TargetReason.FORGOT_TARGET); @@ -28,6 +28,6 @@ + return; + } + // CraftBukkit end + this.onTargetErased.accept(e0); e0.getBehaviorController().removeMemory(MemoryModuleType.ATTACK_TARGET); } - } diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.patch index c5689ca8a..b48ec555b 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.patch @@ -13,13 +13,13 @@ + public class BehaviorAttackTargetSet extends Behavior { - private final Predicate b; + private final Predicate canAttackPredicate; @@ -38,13 +45,21 @@ } protected void a(WorldServer worldserver, E e0, long i) { -- ((Optional) this.c.apply(e0)).ifPresent((entityliving) -> { -+ (this.c.apply(e0)).ifPresent((entityliving) -> { // CraftBukkit - decompile error +- ((Optional) this.targetFinderFunction.apply(e0)).ifPresent((entityliving) -> { ++ (this.targetFinderFunction.apply(e0)).ifPresent((entityliving) -> { // CraftBukkit - decompile error this.a(e0, entityliving); }); } diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFarm.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFarm.patch index dcd65c856..ddbbf1ee6 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFarm.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFarm.patch @@ -1,55 +1,55 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java -@@ -78,8 +78,8 @@ +@@ -80,8 +80,8 @@ protected void a(WorldServer worldserver, EntityVillager entityvillager, long i) { - if (i > this.c && this.farmBlock != null) { -- entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(this.farmBlock))); -- entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(new BehaviorTarget(this.farmBlock), 0.5F, 1))); -+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(this.farmBlock))); // CraftBukkit - decompile error -+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(new BehaviorTarget(this.farmBlock), 0.5F, 1))); // CraftBukkit - decompile error + 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 } } -@@ -99,7 +99,11 @@ - Block block1 = worldserver.getType(this.farmBlock.down()).getBlock(); +@@ -101,7 +101,11 @@ + Block block1 = worldserver.getType(this.aboveFarmlandPos.down()).getBlock(); if (block instanceof BlockCrops && ((BlockCrops) block).isRipe(iblockdata)) { -- worldserver.a(this.farmBlock, true, entityvillager); +- worldserver.a(this.aboveFarmlandPos, true, entityvillager); + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.farmBlock, Blocks.AIR.getBlockData()).isCancelled()) { -+ worldserver.a(this.farmBlock, true, entityvillager); ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, Blocks.AIR.getBlockData()).isCancelled()) { ++ worldserver.a(this.aboveFarmlandPos, true, entityvillager); + } + // CraftBukkit end } if (iblockdata.isAir() && block1 instanceof BlockSoil && entityvillager.canPlant()) { -@@ -110,19 +114,28 @@ +@@ -112,19 +116,28 @@ boolean flag = false; if (!itemstack.isEmpty()) { + // CraftBukkit start + Block planted = null; - if (itemstack.getItem() == Items.WHEAT_SEEDS) { -- worldserver.setTypeAndData(this.farmBlock, Blocks.WHEAT.getBlockData(), 3); + if (itemstack.a(Items.WHEAT_SEEDS)) { +- worldserver.setTypeAndData(this.aboveFarmlandPos, Blocks.WHEAT.getBlockData(), 3); + planted = Blocks.WHEAT; flag = true; - } else if (itemstack.getItem() == Items.POTATO) { -- worldserver.setTypeAndData(this.farmBlock, Blocks.POTATOES.getBlockData(), 3); + } else if (itemstack.a(Items.POTATO)) { +- worldserver.setTypeAndData(this.aboveFarmlandPos, Blocks.POTATOES.getBlockData(), 3); + planted = Blocks.POTATOES; flag = true; - } else if (itemstack.getItem() == Items.CARROT) { -- worldserver.setTypeAndData(this.farmBlock, Blocks.CARROTS.getBlockData(), 3); + } else if (itemstack.a(Items.CARROT)) { +- worldserver.setTypeAndData(this.aboveFarmlandPos, Blocks.CARROTS.getBlockData(), 3); + planted = Blocks.CARROTS; flag = true; - } else if (itemstack.getItem() == Items.BEETROOT_SEEDS) { -- worldserver.setTypeAndData(this.farmBlock, Blocks.BEETROOTS.getBlockData(), 3); + } else if (itemstack.a(Items.BEETROOT_SEEDS)) { +- worldserver.setTypeAndData(this.aboveFarmlandPos, Blocks.BEETROOTS.getBlockData(), 3); + planted = Blocks.BEETROOTS; flag = true; } + -+ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.farmBlock, planted.getBlockData()).isCancelled()) { -+ worldserver.setTypeAndData(this.farmBlock, planted.getBlockData(), 3); ++ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, planted.getBlockData()).isCancelled()) { ++ worldserver.setTypeAndData(this.aboveFarmlandPos, planted.getBlockData(), 3); + } else { + flag = false; + } @@ -57,14 +57,14 @@ } if (flag) { -@@ -141,8 +154,8 @@ - this.farmBlock = this.a(worldserver); - if (this.farmBlock != null) { - this.c = i + 20L; -- entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(new BehaviorTarget(this.farmBlock), 0.5F, 1))); -- entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(this.farmBlock))); -+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(new BehaviorTarget(this.farmBlock), 0.5F, 1))); // CraftBukkit - decompile error -+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(this.farmBlock))); // CraftBukkit - decompile error +@@ -143,8 +156,8 @@ + this.aboveFarmlandPos = this.a(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 } } } diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.patch index a7193e45e..e59bb6bf1 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.patch @@ -1,43 +1,43 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.java -@@ -66,6 +66,13 @@ +@@ -69,6 +69,13 @@ BlockDoor blockdoor = (BlockDoor) iblockdata.getBlock(); if (!blockdoor.h(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.world, blockposition)); -+ entityliving.world.getServer().getPluginManager().callEvent(event); ++ 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.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } + // CraftBukkit end - blockdoor.setDoor(worldserver, iblockdata, blockposition, true); + blockdoor.setDoor(entityliving, worldserver, iblockdata, blockposition, true); } -@@ -79,6 +86,13 @@ +@@ -82,6 +89,13 @@ BlockDoor blockdoor1 = (BlockDoor) iblockdata1.getBlock(); if (!blockdoor1.h(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.world, blockposition)); -+ entityliving.world.getServer().getPluginManager().callEvent(event); ++ 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.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } + // CraftBukkit end - blockdoor1.setDoor(worldserver, iblockdata1, blockposition1, true); + blockdoor1.setDoor(entityliving, worldserver, iblockdata1, blockposition1, true); this.c(worldserver, entityliving, blockposition1); } -@@ -127,7 +141,7 @@ +@@ -130,7 +144,7 @@ private static boolean a(WorldServer worldserver, EntityLiving entityliving, BlockPosition blockposition) { BehaviorController behaviorcontroller = entityliving.getBehaviorController(); -- return !behaviorcontroller.hasMemory(MemoryModuleType.MOBS) ? false : ((List) behaviorcontroller.getMemory(MemoryModuleType.MOBS).get()).stream().filter((entityliving1) -> { -+ return !behaviorcontroller.hasMemory(MemoryModuleType.MOBS) ? false : (behaviorcontroller.getMemory(MemoryModuleType.MOBS).get()).stream().filter((entityliving1) -> { // CraftBukkit - decompile error +- 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(); }).filter((entityliving1) -> { return blockposition.a((IPosition) entityliving1.getPositionVector(), 2.0D); -@@ -169,7 +183,7 @@ +@@ -172,7 +186,7 @@ if (behaviorcontroller.getMemory(MemoryModuleType.DOORS_TO_CLOSE).isPresent()) { ((Set) behaviorcontroller.getMemory(MemoryModuleType.DOORS_TO_CLOSE).get()).add(globalpos); } else { diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.patch index 44bcab15b..5c05098fd 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.java -@@ -110,11 +110,16 @@ +@@ -112,11 +112,16 @@ if (entityvillager2 == null) { return Optional.empty(); } else { @@ -20,7 +20,7 @@ worldserver.broadcastEntityEffect(entityvillager2, (byte) 12); return Optional.of(entityvillager2); } -@@ -123,6 +128,6 @@ +@@ -125,6 +130,6 @@ private void a(WorldServer worldserver, EntityVillager entityvillager, BlockPosition blockposition) { GlobalPos globalpos = GlobalPos.create(worldserver.getDimensionKey(), blockposition); diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorUtil.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorUtil.patch index e8601ed1b..8b9c9cd8e 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorUtil.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorUtil.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorUtil.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorUtil.java -@@ -54,7 +54,7 @@ +@@ -62,7 +62,7 @@ } public static void a(EntityLiving entityliving, EntityLiving entityliving1) { @@ -9,7 +9,7 @@ } private static void b(EntityLiving entityliving, EntityLiving entityliving1, float f) { -@@ -67,18 +67,19 @@ +@@ -75,18 +75,19 @@ public static void a(EntityLiving entityliving, Entity entity, float f, int i) { MemoryTarget memorytarget = new MemoryTarget(new BehaviorPositionEntity(entity, false), f, i); @@ -31,20 +31,20 @@ public static void a(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.world, entityliving.locX(), d0, entityliving.locZ(), itemstack); + EntityItem entityitem = new EntityItem(entityliving.level, entityliving.locX(), d0, entityliving.locZ(), itemstack); float f = 0.3F; -@@ -87,12 +88,19 @@ +@@ -95,12 +96,19 @@ vec3d1 = vec3d1.d().a(0.30000001192092896D); entityitem.setMot(vec3d1); entityitem.defaultPickupDelay(); + // CraftBukkit start + org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(entityliving.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); -+ entityitem.world.getServer().getPluginManager().callEvent(event); ++ entityitem.level.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } + // CraftBukkit end - entityliving.world.addEntity(entityitem); + entityliving.level.addEntity(entityitem); } public static SectionPosition a(WorldServer worldserver, SectionPosition sectionposition, int i) { diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter.patch index 714e9292a..f84244a46 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter.java -@@ -24,7 +24,7 @@ +@@ -23,7 +23,7 @@ public BehaviorWorkComposter() {} @Override @@ -9,21 +9,21 @@ Optional optional = entityvillager.getBehaviorController().getMemory(MemoryModuleType.JOB_SITE); if (optional.isPresent()) { -@@ -43,7 +43,7 @@ +@@ -42,7 +42,7 @@ BlockPosition blockposition = globalpos.getBlockPosition(); - if ((Integer) iblockdata.get(BlockComposter.a) == 8) { -- iblockdata = BlockComposter.d(iblockdata, (World) worldserver, blockposition); -+ iblockdata = BlockComposter.d(iblockdata, (World) worldserver, blockposition, entityvillager); // CraftBukkit + if ((Integer) iblockdata.get(BlockComposter.LEVEL) == 8) { +- iblockdata = BlockComposter.d(iblockdata, worldserver, blockposition); ++ iblockdata = BlockComposter.d(iblockdata, worldserver, blockposition, entityvillager); // CraftBukkit } int i = 20; -@@ -68,7 +68,7 @@ +@@ -67,7 +67,7 @@ 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.a) == 7) { + if ((Integer) iblockdata1.get(BlockComposter.LEVEL) == 7) { this.a(worldserver, iblockdata, blockposition, iblockdata1); return; diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.patch b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.patch index 723798083..c593aaf22 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.java +++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.java -@@ -71,6 +71,12 @@ +@@ -72,6 +72,12 @@ } - if (this.a == this.f() && this.a(this.entity.world.getDifficulty())) { + if (this.breakTime == this.f() && this.a(this.mob.level.getDifficulty())) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreakDoorEvent(this.entity, this.door).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreakDoorEvent(this.mob, this.doorPos).isCancelled()) { + this.c(); + return; + } + // CraftBukkit end - this.entity.world.a(this.door, false); - this.entity.world.triggerEffect(1021, this.door, 0); - this.entity.world.triggerEffect(2001, this.door, Block.getCombinedId(this.entity.world.getType(this.door))); + 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))); diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.patch b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.patch index 1cb7f76af..e3a040608 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.java +++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.java -@@ -11,6 +11,10 @@ - import net.minecraft.world.level.block.state.IBlockData; +@@ -12,6 +12,10 @@ import net.minecraft.world.level.block.state.predicate.BlockStatePredicate; + import net.minecraft.world.level.gameevent.GameEvent; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -10,24 +10,24 @@ + public class PathfinderGoalEatTile extends PathfinderGoal { - private static final Predicate a = BlockStatePredicate.a(Blocks.GRASS); -@@ -63,7 +67,8 @@ - BlockPosition blockposition = this.b.getChunkCoordinates(); + private static final int EAT_ANIMATION_TICKS = 40; +@@ -65,7 +69,8 @@ + BlockPosition blockposition = this.mob.getChunkCoordinates(); - if (PathfinderGoalEatTile.a.test(this.c.getType(blockposition))) { -- if (this.c.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) { + if (PathfinderGoalEatTile.IS_TALL_GRASS.test(this.level.getType(blockposition))) { +- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + // CraftBukkit -+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, blockposition, Blocks.AIR.getBlockData(), !this.c.getGameRules().getBoolean(GameRules.MOB_GRIEFING)).isCancelled()) { - this.c.b(blockposition, false); ++ if (!CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.getBlockData(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) { + this.level.b(blockposition, false); } -@@ -72,7 +77,8 @@ +@@ -75,7 +80,8 @@ BlockPosition blockposition1 = blockposition.down(); - if (this.c.getType(blockposition1).a(Blocks.GRASS_BLOCK)) { -- if (this.c.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) { + if (this.level.getType(blockposition1).a(Blocks.GRASS_BLOCK)) { +- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + // CraftBukkit -+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, blockposition, Blocks.AIR.getBlockData(), !this.c.getGameRules().getBoolean(GameRules.MOB_GRIEFING)).isCancelled()) { - this.c.triggerEffect(2001, blockposition1, Block.getCombinedId(Blocks.GRASS_BLOCK.getBlockData())); - this.c.setTypeAndData(blockposition1, Blocks.DIRT.getBlockData(), 2); ++ if (!CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, 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); } diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.patch b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.patch index d6a3a5c3e..050251583 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.patch @@ -12,24 +12,24 @@ + public class PathfinderGoalFollowOwner extends PathfinderGoal { - private final EntityTameableAnimal a; -@@ -117,7 +123,18 @@ + public static final int TELEPORT_WHEN_DISTANCE_IS = 12; +@@ -121,7 +127,18 @@ } else if (!this.a(new BlockPosition(i, j, k))) { return false; } else { -- this.a.setPositionRotation((double) i + 0.5D, (double) j, (double) k + 0.5D, this.a.yaw, this.a.pitch); +- this.tamable.setPositionRotation((double) i + 0.5D, (double) j, (double) k + 0.5D, this.tamable.getYRot(), this.tamable.getXRot()); + // CraftBukkit start -+ CraftEntity entity = this.a.getBukkitEntity(); -+ Location to = new Location(entity.getWorld(), (double) i + 0.5D, (double) j, (double) k + 0.5D, this.a.yaw, this.a.pitch); ++ 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()); + EntityTeleportEvent event = new EntityTeleportEvent(entity, entity.getLocation(), to); -+ this.a.world.getServer().getPluginManager().callEvent(event); ++ this.tamable.level.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return false; + } + to = event.getTo(); + -+ this.a.setPositionRotation(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch()); ++ this.tamable.setPositionRotation(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch()); + // CraftBukkit end - this.e.o(); + this.navigation.o(); return true; } diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalPanic.patch b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalPanic.patch index 5bb265fcb..d16a9774f 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalPanic.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalPanic.patch @@ -10,17 +10,17 @@ + public class PathfinderGoalPanic extends PathfinderGoal { - protected final EntityCreature a; + protected final EntityCreature mob; @@ -76,6 +80,12 @@ @Override public boolean b() { + // CraftBukkit start - introduce a temporary timeout hack until this is fixed properly -+ if ((this.a.ticksLived - this.a.hurtTimestamp) > 100) { -+ this.a.setLastDamager((EntityLiving) null); ++ if ((this.mob.tickCount - this.mob.lastHurtByMobTimestamp) > 100) { ++ this.mob.setLastDamager((EntityLiving) null); + return false; + } + // CraftBukkit end - return !this.a.getNavigation().m(); + return !this.mob.getNavigation().m(); } diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.patch b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.patch index 238ac6b18..1e0d76012 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.java +++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.java -@@ -20,6 +20,11 @@ +@@ -21,6 +21,11 @@ import net.minecraft.world.level.chunk.IChunkAccess; import net.minecraft.world.phys.Vec3D; @@ -11,13 +11,13 @@ + public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget { - private final Block g; -@@ -98,6 +103,14 @@ + private final Block blockToRemove; +@@ -100,6 +105,14 @@ } - if (this.i > 60) { + if (this.ticksSinceReachedGoal > 60) { + // CraftBukkit start - Step on eggs -+ EntityInteractEvent event = new EntityInteractEvent(this.entity.getBukkitEntity(), CraftBlock.at(world, blockposition1)); ++ EntityInteractEvent event = new EntityInteractEvent(this.removerMob.getBukkitEntity(), CraftBlock.at(world, blockposition1)); + world.getServer().getPluginManager().callEvent((EntityInteractEvent) event); + + if (event.isCancelled()) { diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.patch b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.patch index 8b9122470..5986cc7dc 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.patch @@ -3,9 +3,9 @@ @@ -22,7 +22,7 @@ @Override public boolean a() { - if (!this.entity.isTamed()) { + if (!this.mob.isTamed()) { - return false; -+ return this.entity.isWillSit() && this.entity.getGoalTarget() == null; // CraftBukkit - Allow sitting for wild animals - } else if (this.entity.aH()) { ++ return this.mob.isWillSit() && this.mob.getGoalTarget() == null; // CraftBukkit - Allow sitting for wild animals + } else if (this.mob.aO()) { return false; - } else if (!this.entity.isOnGround()) { + } else if (!this.mob.isOnGround()) { diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.patch b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.patch index 90e4cc423..3cf9f8ebf 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.java +++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.java @@ -62,7 +62,8 @@ - int i = this.entity.getTemper(); - int j = this.entity.getMaxDomestication(); + int i = this.horse.getTemper(); + int j = this.horse.getMaxDomestication(); -- if (j > 0 && this.entity.getRandom().nextInt(j) < i) { +- if (j > 0 && this.horse.getRandom().nextInt(j) < i) { + // CraftBukkit - fire EntityTameEvent -+ if (j > 0 && this.entity.getRandom().nextInt(j) < i && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this.entity, ((org.bukkit.craftbukkit.entity.CraftHumanEntity) this.entity.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) { - this.entity.i((EntityHuman) entity); ++ 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); return; } diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.patch b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.patch index 649ab5abb..25b172ad1 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.java +++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.java -@@ -11,6 +11,13 @@ - import net.minecraft.world.item.ItemStack; +@@ -8,6 +8,13 @@ + import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.crafting.RecipeItemStack; +// CraftBukkit start @@ -13,32 +13,29 @@ + public class PathfinderGoalTempt extends PathfinderGoal { - private static final PathfinderTargetCondition c = (new PathfinderTargetCondition()).a(10.0D).a().b().d().c(); -@@ -21,7 +28,7 @@ - private double g; - private double h; - private double i; -- protected EntityHuman target; -+ protected EntityLiving target; // CraftBukkit - private int j; - private boolean k; - private final RecipeItemStack l; -@@ -49,7 +56,17 @@ + private static final PathfinderTargetCondition TEMP_TARGETING = PathfinderTargetCondition.b().a(10.0D).d(); +@@ -19,7 +26,7 @@ + private double pz; + private double pRotX; + private double pRotY; +- protected EntityHuman player; ++ protected EntityLiving player; // CraftBukkit + private int calmDown; + private boolean isRunning; + private final RecipeItemStack items; +@@ -41,6 +48,15 @@ return false; } else { - this.target = this.a.world.a(PathfinderGoalTempt.c, (EntityLiving) this.a); -- return this.target == null ? false : this.a(this.target.getItemInMainHand()) || this.a(this.target.getItemInOffHand()); + this.player = this.mob.level.a(this.targetingConditions, (EntityLiving) this.mob); + // CraftBukkit start -+ boolean tempt = this.target == null ? false : this.a(this.target.getItemInMainHand()) || this.a(this.target.getItemInOffHand()); -+ if (tempt) { -+ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this.a, this.target, EntityTargetEvent.TargetReason.TEMPT); ++ if (this.player != null) { ++ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this.mob, this.player, EntityTargetEvent.TargetReason.TEMPT); + if (event.isCancelled()) { + return false; + } -+ this.target = (event.getTarget() == null) ? null : ((CraftLivingEntity) event.getTarget()).getHandle(); ++ this.player = (event.getTarget() == null) ? null : ((CraftLivingEntity) event.getTarget()).getHandle(); + } -+ return tempt; + // CraftBukkit end + return this.player != null; } } - diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.patch b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.patch index e3745bc56..f4b9b4ac6 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.patch @@ -4,8 +4,8 @@ @Override public void c() { -- this.a.setGoalTarget(this.b); -+ this.a.setGoalTarget(this.b, org.bukkit.event.entity.EntityTargetEvent.TargetReason.DEFEND_VILLAGE, true); // CraftBukkit - reason +- this.golem.setGoalTarget(this.potentialTarget); ++ this.golem.setGoalTarget(this.potentialTarget, org.bukkit.event.entity.EntityTargetEvent.TargetReason.DEFEND_VILLAGE, true); // CraftBukkit - reason super.c(); } } diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.patch b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.patch index fd8d35117..6fc18e9c4 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.java +++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.java -@@ -62,7 +62,7 @@ +@@ -64,7 +64,7 @@ @Override public void c() { -- this.e.setGoalTarget(this.e.getLastDamager()); -+ this.e.setGoalTarget(this.e.getLastDamager(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason - this.g = this.e.getGoalTarget(); - this.c = this.e.da(); - this.h = 300; -@@ -109,6 +109,6 @@ +- 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(); + this.unseenMemoryTicks = 300; +@@ -111,6 +111,6 @@ } protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) { diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.patch b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.patch index b16ca00c1..0b2cd58b0 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.patch +++ b/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 -@@ -59,7 +59,7 @@ +@@ -61,7 +61,7 @@ @Override public void c() { -- this.e.setGoalTarget(this.c); -+ this.e.setGoalTarget(this.c, c instanceof EntityPlayer ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit - reason +- 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(); } diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalOwnerHurtByTarget.patch b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalOwnerHurtByTarget.patch index 6376cea8a..668f83be1 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalOwnerHurtByTarget.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalOwnerHurtByTarget.patch @@ -4,8 +4,8 @@ @Override public void c() { -- this.e.setGoalTarget(this.b); -+ this.e.setGoalTarget(this.b, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit - reason - EntityLiving entityliving = this.a.getOwner(); +- this.mob.setGoalTarget(this.ownerLastHurtBy); ++ this.mob.setGoalTarget(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/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalOwnerHurtTarget.patch b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalOwnerHurtTarget.patch index 039eba83b..e1ca9f68a 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalOwnerHurtTarget.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalOwnerHurtTarget.patch @@ -4,8 +4,8 @@ @Override public void c() { -- this.e.setGoalTarget(this.b); -+ this.e.setGoalTarget(this.b, org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit - reason - EntityLiving entityliving = this.a.getOwner(); +- this.mob.setGoalTarget(this.ownerLastHurt); ++ this.mob.setGoalTarget(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/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.patch b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.patch index 6453b6cf9..58a511445 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.java +++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.java -@@ -13,6 +13,8 @@ +@@ -11,6 +11,8 @@ import net.minecraft.world.level.pathfinder.PathPoint; import net.minecraft.world.scores.ScoreboardTeamBase; @@ -8,22 +8,22 @@ + public abstract class PathfinderGoalTarget extends PathfinderGoal { - protected final EntityInsentient e; -@@ -70,7 +72,7 @@ - if (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable) { - return false; - } else { -- this.e.setGoalTarget(entityliving); -+ this.e.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit - return true; + private static final int EMPTY_REACH_CACHE = 0; +@@ -68,7 +70,7 @@ + } } + +- this.mob.setGoalTarget(entityliving); ++ this.mob.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit + return true; } -@@ -91,7 +93,7 @@ + } +@@ -88,7 +90,7 @@ @Override public void d() { -- this.e.setGoalTarget((EntityLiving) null); -+ this.e.setGoalTarget((EntityLiving) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - this.g = null; +- this.mob.setGoalTarget((EntityLiving) null); ++ this.mob.setGoalTarget((EntityLiving) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit + this.targetMob = null; } diff --git a/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch b/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch index 9652a85cc..a81b8ada3 100644 --- a/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch +++ b/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch @@ -8,16 +8,16 @@ + public class EntityBat extends EntityAmbient { - private static final DataWatcherObject b = DataWatcher.a(EntityBat.class, DataWatcherRegistry.a); -@@ -130,16 +132,24 @@ + public static final float FLAP_DEGREES_PER_TICK = 74.48451F; +@@ -138,16 +140,24 @@ } - if (this.world.a(EntityBat.c, (EntityLiving) this) != null) { + if (this.level.a(EntityBat.BAT_RESTING_TARGETING, (EntityLiving) this) != null) { + // CraftBukkit Start - Call BatToggleSleepEvent + if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { + this.setAsleep(false); + if (!flag) { -+ this.world.a((EntityHuman) null, 1025, blockposition, 0); ++ this.level.a((EntityHuman) null, 1025, blockposition, 0); + } + } + // CraftBukkit End @@ -27,22 +27,22 @@ + if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { this.setAsleep(false); if (!flag) { - this.world.a((EntityHuman) null, 1025, blockposition, 0); + this.level.a((EntityHuman) null, 1025, blockposition, 0); } } - } else { - this.setAsleep(false); - if (!flag) { -- this.world.a((EntityHuman) null, 1025, blockposition, 0); +- this.level.a((EntityHuman) null, 1025, blockposition, 0); - } + // CraftBukkit End - Call BatToggleSleepEvent } } else { - if (this.d != null && (!this.world.isEmpty(this.d) || this.d.getY() < 1)) { -@@ -163,7 +173,11 @@ - this.aT = 0.5F; - this.yaw += f1; - if (this.random.nextInt(100) == 0 && this.world.getType(blockposition1).isOccluding(this.world, blockposition1)) { + if (this.targetPosition != null && (!this.level.isEmpty(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); + // CraftBukkit Start - Call BatToggleSleepEvent + if (CraftEventFactory.handleBatToggleSleepEvent(this, false)) { @@ -52,10 +52,10 @@ } } -@@ -193,7 +207,11 @@ +@@ -201,7 +215,11 @@ return false; } else { - if (!this.world.isClientSide && this.isAsleep()) { + if (!this.level.isClientSide && this.isAsleep()) { - this.setAsleep(false); + // CraftBukkit Start - Call BatToggleSleepEvent + if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { diff --git a/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch b/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch new file mode 100644 index 000000000..9c848029a --- /dev/null +++ b/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch @@ -0,0 +1,41 @@ +--- a/net/minecraft/world/entity/animal/Bucketable.java ++++ b/net/minecraft/world/entity/animal/Bucketable.java +@@ -15,6 +15,14 @@ + import net.minecraft.world.item.Items; + import net.minecraft.world.level.World; + ++// CraftBukkit start ++import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; ++import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving; ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.event.player.PlayerBucketEntityEvent; ++// CraftBukkit end ++ + public interface Bucketable { + + boolean isFromBucket(); +@@ -90,10 +98,22 @@ + ItemStack itemstack = entityhuman.b(enumhand); + + if (itemstack.getItem() == Items.WATER_BUCKET && t0.isAlive()) { +- t0.playSound(((Bucketable) t0).t(), 1.0F, 1.0F); ++ // CraftBukkit start ++ // t0.playSound(((Bucketable) t0).t(), 1.0F, 1.0F); // CraftBukkit - moved down + ItemStack itemstack1 = ((Bucketable) t0).getBucketItem(); + + ((Bucketable) t0).setBucketName(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 ++ return Optional.of(EnumInteractionResult.FAIL); ++ } ++ t0.playSound(((Bucketable) t0).t(), 1.0F, 1.0F); ++ // CraftBukkit end + ItemStack itemstack2 = ItemLiquidUtil.a(itemstack, entityhuman, itemstack1, false); + + entityhuman.a(enumhand, itemstack2); diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch b/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch index 58dec6a02..d87568991 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/animal/EntityAnimal.java +++ b/net/minecraft/world/entity/animal/EntityAnimal.java -@@ -27,10 +27,17 @@ - import net.minecraft.world.level.block.Blocks; +@@ -28,11 +28,18 @@ + import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.pathfinder.PathType; +// CraftBukkit start @@ -12,13 +12,14 @@ + public abstract class EntityAnimal extends EntityAgeable { - public int loveTicks; - public UUID breedCause; + static final int PARENT_AGE_AFTER_BREEDING = 6000; + public int inLove; + public UUID loveCause; + public ItemStack breedItem; // CraftBukkit - Add breedItem variable protected EntityAnimal(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -67,6 +74,9 @@ +@@ -69,6 +76,9 @@ } @@ -28,7 +29,7 @@ @Override public boolean damageEntity(DamageSource damagesource, float f) { if (this.isInvulnerable(damagesource)) { -@@ -76,6 +86,7 @@ +@@ -78,6 +88,7 @@ return super.damageEntity(damagesource, f); } } @@ -36,32 +37,32 @@ @Override public float a(BlockPosition blockposition, IWorldReader iworldreader) { -@@ -166,10 +177,17 @@ +@@ -170,10 +181,17 @@ } public void g(@Nullable EntityHuman entityhuman) { -- this.loveTicks = 600; +- this.inLove = 600; + // CraftBukkit start + EntityEnterLoveModeEvent entityEnterLoveModeEvent = CraftEventFactory.callEntityEnterLoveModeEvent(entityhuman, this, 600); + if (entityEnterLoveModeEvent.isCancelled()) { + return; + } -+ this.loveTicks = entityEnterLoveModeEvent.getTicksInLove(); ++ this.inLove = entityEnterLoveModeEvent.getTicksInLove(); + // CraftBukkit end if (entityhuman != null) { - this.breedCause = entityhuman.getUniqueID(); + this.loveCause = entityhuman.getUniqueID(); } -+ this.breedItem = entityhuman.inventory.getItemInHand(); // CraftBukkit ++ this.breedItem = entityhuman.getInventory().getItemInHand(); // CraftBukkit - this.world.broadcastEntityEffect(this, (byte) 18); + this.level.broadcastEntityEffect(this, (byte) 18); } -@@ -209,11 +227,26 @@ +@@ -213,11 +231,26 @@ EntityAgeable entityageable = this.createChild(worldserver, entityanimal); if (entityageable != null) { + // CraftBukkit start - set persistence for tame animals + if (entityageable instanceof EntityTameableAnimal && ((EntityTameableAnimal) entityageable).isTamed()) { -+ entityageable.persistent = true; ++ entityageable.persistenceRequired = true; + } + // CraftBukkit end EntityPlayer entityplayer = this.getBreedCause(); @@ -82,7 +83,7 @@ if (entityplayer != null) { entityplayer.a(StatisticList.ANIMALS_BRED); -@@ -224,12 +257,14 @@ +@@ -228,12 +261,14 @@ entityanimal.setAgeRaw(6000); this.resetLove(); entityanimal.resetLove(); @@ -91,7 +92,7 @@ - worldserver.addAllEntities(entityageable); + worldserver.addAllEntities(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason worldserver.broadcastEntityEffect(this, (byte) 18); - if (worldserver.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) { + if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { - worldserver.addEntity(new EntityExperienceOrb(worldserver, this.locX(), this.locY(), this.locZ(), this.getRandom().nextInt(7) + 1)); + // CraftBukkit start - use event experience + if (experience > 0) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch b/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch index bb209df88..c49aaf24b 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/world/entity/animal/EntityBee.java +++ b/net/minecraft/world/entity/animal/EntityBee.java -@@ -211,7 +211,7 @@ +@@ -243,7 +243,7 @@ } if (b0 > 0) { -- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0)); -+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit +- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this); ++ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } } -@@ -586,11 +586,15 @@ +@@ -642,11 +642,15 @@ + if (this.isInvulnerable(damagesource)) { + return false; } else { - Entity entity = damagesource.getEntity(); - -- if (!this.world.isClientSide) { +- if (!this.level.isClientSide) { + // CraftBukkit start + boolean result = super.damageEntity(damagesource, f); + -+ if (result && !this.world.isClientSide) { - this.bC.l(); ++ if (result && !this.level.isClientSide) { + this.beePollinateGoal.l(); } - return super.damageEntity(damagesource, f); @@ -27,75 +27,30 @@ } } -@@ -611,7 +615,7 @@ - class d extends EntityBee.a { - - private d() { -- super(null); -+ super(); // CraftBukkit - decompile error - } - - @Override -@@ -671,7 +675,7 @@ - class g extends EntityBee.a { - - private g() { -- super(null); -+ super(); // CraftBukkit - decompile error - } - - @Override -@@ -720,7 +724,7 @@ +@@ -1216,7 +1220,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.world.triggerEffect(2005, blockposition, 0); - EntityBee.this.world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(blockstateinteger, (Integer) iblockdata.get(blockstateinteger) + 1)); - EntityBee.this.fi(); -@@ -735,7 +739,7 @@ - class i extends EntityBee.a { - - private i() { -- super(null); -+ super(); // CraftBukkit - decompile error - } - - @Override -@@ -799,7 +803,7 @@ - private int h = 0; - - k() { -- super(null); -+ super(); // CraftBukkit - decompile error - this.a(EnumSet.of(PathfinderGoal.Type.MOVE)); - } - -@@ -983,7 +987,7 @@ - private int c; - - f() { -- super(null); -+ super(); // CraftBukkit - decompile error - this.c = EntityBee.this.world.random.nextInt(10); - this.a(EnumSet.of(PathfinderGoal.Type.MOVE)); - } -@@ -1041,7 +1045,7 @@ - private int f; - - e() { -- super(null); -+ super(); // CraftBukkit - decompile error - this.c = EntityBee.this.world.random.nextInt(10); - this.d = Lists.newArrayList(); - this.e = null; -@@ -1261,7 +1265,7 @@ + EntityBee.this.level.triggerEffect(2005, blockposition, 0); + EntityBee.this.level.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(blockstateinteger, (Integer) iblockdata.get(blockstateinteger) + 1)); + EntityBee.this.fR(); +@@ -1289,7 +1293,7 @@ @Override protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) { - if (entityinsentient instanceof EntityBee && this.e.hasLineOfSight(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 } } +@@ -1298,7 +1302,7 @@ + private static class c extends PathfinderGoalNearestAttackableTarget { + + c(EntityBee entitybee) { +- Objects.requireNonNull(entitybee); ++ // Objects.requireNonNull(entitybee); // CraftBukkit - decompile error + super(entitybee, EntityHuman.class, 10, true, false, entitybee::a_); + } + diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch b/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch index 5d2fb5c3f..fb67bcb19 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch @@ -1,58 +1,60 @@ --- a/net/minecraft/world/entity/animal/EntityCat.java +++ b/net/minecraft/world/entity/animal/EntityCat.java -@@ -78,7 +78,7 @@ - private static final DataWatcherObject bt = DataWatcher.a(EntityCat.class, DataWatcherRegistry.i); - private static final DataWatcherObject bu = DataWatcher.a(EntityCat.class, DataWatcherRegistry.i); - private static final DataWatcherObject bv = DataWatcher.a(EntityCat.class, DataWatcherRegistry.b); -- public static final Map bq = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { -+ public static final Map bq = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error +@@ -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 TEXTURE_BY_TYPE = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { ++ public static final Map 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")); -@@ -404,7 +404,7 @@ +@@ -433,7 +433,7 @@ } - } else if (this.k(itemstack)) { - this.a(entityhuman, itemstack); + } else if (this.n(itemstack)) { + this.a(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.world.broadcastEntityEffect(this, (byte) 7); -@@ -562,7 +562,15 @@ + this.level.broadcastEntityEffect(this, (byte) 7); +@@ -490,7 +490,7 @@ + private static class PathfinderGoalTemptChance extends PathfinderGoalTempt { + + @Nullable +- private EntityHuman selectedPlayer; ++ private EntityLiving selectedPlayer; // CraftBukkit + private final EntityCat cat; + + public PathfinderGoalTemptChance(EntityCat entitycat, double d0, RecipeItemStack recipeitemstack, boolean flag) { +@@ -629,7 +629,15 @@ while (iterator.hasNext()) { ItemStack itemstack = (ItemStack) iterator.next(); -- this.a.world.addEntity(new EntityItem(this.a.world, (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.a.aA * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.a.aA * 0.017453292F), itemstack)); +- 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)); + // CraftBukkit start -+ EntityItem entityitem = new EntityItem(this.a.world, (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.a.aA * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.a.aA * 0.017453292F), itemstack); -+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.a.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); -+ entityitem.world.getServer().getPluginManager().callEvent(event); ++ 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()); ++ entityitem.level.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + continue; + } -+ this.a.world.addEntity(entityitem); ++ this.cat.level.addEntity(entityitem); + // CraftBukkit end } } -@@ -592,7 +600,7 @@ - static class PathfinderGoalTemptChance extends PathfinderGoalTempt { - - @Nullable -- private EntityHuman chosenTarget; -+ private EntityLiving chosenTarget; // CraftBukkit - private final EntityCat d; - - public PathfinderGoalTemptChance(EntityCat entitycat, double d0, RecipeItemStack recipeitemstack, boolean flag) { -@@ -627,9 +635,9 @@ - private final EntityCat i; +@@ -661,10 +669,10 @@ + private final EntityCat cat; public a(EntityCat entitycat, Class oclass, float f, double d0, double d1) { -- Predicate predicate = IEntitySelector.e; +- Predicate predicate = IEntitySelector.NO_CREATIVE_OR_SPECTATOR; + // Predicate predicate = IEntitySelector.e; // CraftBukkit - decompile error +- Objects.requireNonNull(predicate); - super(entitycat, oclass, f, d0, d1, predicate::test); -+ super(entitycat, oclass, f, d0, d1, IEntitySelector.e::test); // CraftBukkit - decompile error - this.i = entitycat; ++ // Objects.requireNonNull(predicate); // CraftBukkit - decompile error ++ super(entitycat, oclass, f, d0, d1, IEntitySelector.NO_CREATIVE_OR_SPECTATOR::test); // CraftBukkit - decompile error + this.cat = entitycat; } diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityChicken.patch b/nms-patches/net/minecraft/world/entity/animal/EntityChicken.patch index 5a56e046b..330b0d969 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityChicken.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityChicken.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/world/entity/animal/EntityChicken.java +++ b/net/minecraft/world/entity/animal/EntityChicken.java -@@ -74,6 +74,11 @@ +@@ -75,6 +75,11 @@ @Override public void movementTick() { + // CraftBukkit start + if (this.isChickenJockey()) { -+ this.persistent = !this.isTypeNotPersistent(0); ++ this.persistenceRequired = !this.isTypeNotPersistent(0); + } + // CraftBukkit end super.movementTick(); - this.br = this.bo; - this.bq = this.bp; -@@ -93,7 +98,9 @@ - this.bo += this.bs * 2.0F; - if (!this.world.isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggLayTime <= 0) { - this.playSound(SoundEffects.ENTITY_CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.oFlap = this.flap; + this.oFlapSpeed = this.flapSpeed; +@@ -94,7 +99,9 @@ + this.flap += this.flapping * 2.0F; + 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.forceDrops = false; // CraftBukkit - this.eggLayTime = this.random.nextInt(6000) + 6000; + this.eggTime = this.random.nextInt(6000) + 6000; } diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch b/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch index 872078adb..3216fbfbd 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch @@ -15,18 +15,18 @@ @@ -82,8 +87,16 @@ ItemStack itemstack = entityhuman.b(enumhand); - if (itemstack.getItem() == Items.BUCKET && !this.isBaby()) { + if (itemstack.a(Items.BUCKET) && !this.isBaby()) { + // CraftBukkit start - Got milk? -+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.world, entityhuman, this.getChunkCoordinates(), this.getChunkCoordinates(), null, itemstack, Items.MILK_BUCKET); ++ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level, entityhuman, this.getChunkCoordinates(), this.getChunkCoordinates(), null, itemstack, Items.MILK_BUCKET); + + if (event.isCancelled()) { + return EnumInteractionResult.PASS; + } + // CraftBukkit end + - entityhuman.playSound(SoundEffects.ENTITY_COW_MILK, 1.0F, 1.0F); + 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 entityhuman.a(enumhand, itemstack1); - return EnumInteractionResult.a(this.world.isClientSide); + return EnumInteractionResult.a(this.level.isClientSide); diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch b/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch index dfe01360f..e15e3634d 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/animal/EntityDolphin.java +++ b/net/minecraft/world/entity/animal/EntityDolphin.java -@@ -173,7 +173,7 @@ - this.goalSelector.a(8, new EntityDolphin.d()); +@@ -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 } - public static AttributeProvider.Builder eM() { -@@ -240,6 +240,12 @@ + public static AttributeProvider.Builder fv() { +@@ -243,6 +243,12 @@ ItemStack itemstack = entityitem.getItemStack(); if (this.canPickup(itemstack)) { @@ -21,31 +21,31 @@ + // CraftBukkit end this.a(entityitem); this.setSlot(EnumItemSlot.MAINHAND, itemstack); - this.dropChanceHand[EnumItemSlot.MAINHAND.b()] = 2.0F; -@@ -387,7 +393,7 @@ + this.handDropChances[EnumItemSlot.MAINHAND.b()] = 2.0F; +@@ -411,7 +417,7 @@ @Override public boolean a() { -- return this.a.gotFish() && this.a.getAirTicks() >= 100; -+ return this.a.gotFish() && this.a.getAirTicks() >= 100 && this.a.world.getWorld().canGenerateStructures(); // MC-151364, SPIGOT-5494: hangs if generate-structures=false +- 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 } @Override -@@ -496,7 +502,7 @@ +@@ -520,7 +526,7 @@ @Override public void c() { -- this.c.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100)); -+ this.c.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit +- 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 -@@ -515,7 +521,7 @@ +@@ -539,7 +545,7 @@ } - if (this.c.isSwimming() && this.c.world.random.nextInt(6) == 0) { -- this.c.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100)); -+ this.c.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit + if (this.player.isSwimming() && this.player.level.random.nextInt(6) == 0) { +- 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 } } diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityFish.patch b/nms-patches/net/minecraft/world/entity/animal/EntityFish.patch index 206cfffa7..7a7fc9d3e 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityFish.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityFish.patch @@ -1,21 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityFish.java +++ b/net/minecraft/world/entity/animal/EntityFish.java -@@ -41,6 +41,14 @@ - import net.minecraft.world.level.block.state.IBlockData; - import net.minecraft.world.phys.Vec3D; - -+// CraftBukkit start -+import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; -+import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving; -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.craftbukkit.inventory.CraftItemStack; -+import org.bukkit.event.player.PlayerBucketFishEvent; -+// CraftBukkit end -+ - public abstract class EntityFish extends EntityWaterAnimal { - - private static final DataWatcherObject FROM_BUCKET = DataWatcher.a(EntityFish.class, DataWatcherRegistry.i); -@@ -70,7 +78,7 @@ +@@ -68,7 +68,7 @@ @Override public boolean isTypeNotPersistent(double d0) { @@ -24,38 +9,11 @@ } @Override -@@ -90,6 +98,7 @@ - +@@ -90,6 +90,7 @@ + @Override public void setFromBucket(boolean flag) { - this.datawatcher.set(EntityFish.FROM_BUCKET, flag); -+ this.persistent = this.isPersistent(); // CraftBukkit - SPIGOT-4106 update persistence + this.entityData.set(EntityFish.FROM_BUCKET, flag); ++ this.persistenceRequired = this.isPersistent(); // CraftBukkit - SPIGOT-4106 update persistence } @Override -@@ -153,11 +162,24 @@ - ItemStack itemstack = entityhuman.b(enumhand); - - if (itemstack.getItem() == Items.WATER_BUCKET && this.isAlive()) { -+ // CraftBukkit start -+ ItemStack itemstack1 = this.eK(); -+ this.k(itemstack1); -+ -+ PlayerBucketFishEvent playerBucketFishEvent = CraftEventFactory.callPlayerFishBucketEvent(this, entityhuman, itemstack, itemstack1); -+ itemstack1 = CraftItemStack.asNMSCopy(playerBucketFishEvent.getFishBucket()); -+ if (playerBucketFishEvent.isCancelled()) { -+ ((EntityPlayer) entityhuman).updateInventory(((EntityPlayer) entityhuman).activeContainer); // We need to update inventory to resync client's bucket -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSpawnEntityLiving(this)); // We need to play out these packets as the client assumes the fish is gone -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutEntityMetadata(this.getId(), datawatcher, true)); // Need to send data such as the display name to client -+ return EnumInteractionResult.FAIL; -+ } -+ // CraftBukkit end - this.playSound(SoundEffects.ITEM_BUCKET_FILL_FISH, 1.0F, 1.0F); - itemstack.subtract(1); -- ItemStack itemstack1 = this.eK(); -+ // ItemStack itemstack1 = this.eK(); // CraftBukkit - moved up - -- this.k(itemstack1); -+ // this.k(itemstack1); // CraftBukkit - moved up - if (!this.world.isClientSide) { - CriterionTriggers.j.a((EntityPlayer) entityhuman, itemstack1); - } diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch b/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch index 1404ae829..3bdcd9ed6 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch @@ -1,17 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityFox.java +++ b/net/minecraft/world/entity/animal/EntityFox.java -@@ -334,8 +334,8 @@ - private List fa() { - List list = Lists.newArrayList(); - -- list.add(((Optional) this.datawatcher.get(EntityFox.FIRST_TRUSTED_PLAYER)).orElse((Object) null)); -- list.add(((Optional) this.datawatcher.get(EntityFox.SECOND_TRUSTED_PLAYER)).orElse((Object) null)); -+ list.add((this.datawatcher.get(EntityFox.FIRST_TRUSTED_PLAYER)).orElse(null)); // CraftBukkit - decompile error -+ list.add((this.datawatcher.get(EntityFox.SECOND_TRUSTED_PLAYER)).orElse(null)); // CraftBukkit - decompile error - return list; - } - -@@ -471,7 +471,8 @@ +@@ -502,7 +502,8 @@ protected void b(EntityItem entityitem) { ItemStack itemstack = entityitem.getItemStack(); @@ -21,46 +10,7 @@ int i = itemstack.getCount(); if (i > 1) { -@@ -993,6 +994,11 @@ - int i = (Integer) iblockdata.get(BlockSweetBerryBush.a); - - iblockdata.set(BlockSweetBerryBush.a, 1); -+ // CraftBukkit start - call EntityChangeBlockEvent -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityFox.this, this.e, iblockdata.set(BlockSweetBerryBush.a, 1)).isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - int j = 1 + EntityFox.this.world.random.nextInt(2) + (i == 3 ? 1 : 0); - ItemStack itemstack = EntityFox.this.getEquipment(EnumItemSlot.MAINHAND); - -@@ -1032,7 +1038,7 @@ - private int f; - - public r() { -- super(null); -+ super(); // CraftBukkit - decompile error - this.a(EnumSet.of(PathfinderGoal.Type.MOVE, PathfinderGoal.Type.LOOK)); - } - -@@ -1084,7 +1090,7 @@ - private int c; - - public t() { -- super(null); -+ super(); // CraftBukkit - decompile error - this.c = EntityFox.this.random.nextInt(140); - this.a(EnumSet.of(PathfinderGoal.Type.MOVE, PathfinderGoal.Type.LOOK, PathfinderGoal.Type.JUMP)); - } -@@ -1195,7 +1201,7 @@ - private EntityLiving k; - private int l; - -- public a(Class oclass, boolean flag, boolean flag1, Predicate predicate) { -+ public a(Class oclass, boolean flag, boolean flag1, Predicate predicate) { // CraftBukkit - decompile error - super(EntityFox.this, oclass, 10, flag, flag1, predicate); - } - -@@ -1275,6 +1281,16 @@ +@@ -857,6 +858,16 @@ if (entityplayer1 != null && entityplayer != entityplayer1) { entityfox.b(entityplayer1.getUniqueID()); } @@ -77,7 +27,7 @@ if (entityplayer2 != null) { entityplayer2.a(StatisticList.ANIMALS_BRED); -@@ -1285,12 +1301,14 @@ +@@ -867,12 +878,14 @@ this.partner.setAgeRaw(6000); this.animal.resetLove(); this.partner.resetLove(); @@ -85,14 +35,43 @@ - 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.b.broadcastEntityEffect(this.animal, (byte) 18); - if (this.b.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) { -- this.b.addEntity(new EntityExperienceOrb(this.b, this.animal.locX(), this.animal.locY(), this.animal.locZ(), this.animal.getRandom().nextInt(7) + 1)); + this.level.broadcastEntityEffect(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)); + // CraftBukkit start - use event experience + if (experience > 0) { -+ this.b.addEntity(new EntityExperienceOrb(this.b, this.animal.locX(), this.animal.locY(), this.animal.locZ(), experience)); ++ this.level.addEntity(new EntityExperienceOrb(this.level, this.animal.locX(), this.animal.locY(), this.animal.locZ(), experience)); + } + // CraftBukkit end } } +@@ -1258,13 +1271,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 b(IBlockData iblockdata) { + int i = (Integer) iblockdata.get(BlockSweetBerryBush.AGE); + + iblockdata.set(BlockSweetBerryBush.AGE, 1); ++ // CraftBukkit start - call EntityChangeBlockEvent ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityFox.this, this.blockPos, iblockdata.set(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); + +@@ -1420,7 +1438,7 @@ + private EntityLiving trustedLastHurt; + private int timestamp; + +- public a(Class oclass, boolean flag, boolean flag1, @Nullable Predicate predicate) { ++ public a(Class oclass, boolean flag, boolean flag1, @Nullable Predicate predicate) { // CraftBukkit - decompile error + super(EntityFox.this, oclass, 10, flag, flag1, predicate); + } + diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityIronGolem.patch b/nms-patches/net/minecraft/world/entity/animal/EntityIronGolem.patch index 81e54c4d9..75546e947 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityIronGolem.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityIronGolem.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/animal/EntityIronGolem.java +++ b/net/minecraft/world/entity/animal/EntityIronGolem.java -@@ -104,7 +104,7 @@ +@@ -106,7 +106,7 @@ @Override - protected void C(Entity entity) { + protected void A(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 } - super.C(entity); + super.A(entity); diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch b/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch index 58b572d7e..945939026 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/animal/EntityMushroomCow.java +++ b/net/minecraft/world/entity/animal/EntityMushroomCow.java -@@ -41,6 +41,11 @@ - import net.minecraft.world.level.block.state.IBlockData; +@@ -42,6 +42,11 @@ + import net.minecraft.world.level.gameevent.GameEvent; import org.apache.commons.lang3.tuple.Pair; +// CraftBukkit start @@ -11,41 +11,41 @@ + public class EntityMushroomCow extends EntityCow implements IShearable { - private static final DataWatcherObject bo = DataWatcher.a(EntityMushroomCow.class, DataWatcherRegistry.d); -@@ -111,6 +116,11 @@ + private static final DataWatcherObject DATA_TYPE = DataWatcher.a(EntityMushroomCow.class, DataWatcherRegistry.STRING); +@@ -113,6 +118,11 @@ this.playSound(soundeffect, 1.0F, 1.0F); - return EnumInteractionResult.a(this.world.isClientSide); - } else if (itemstack.getItem() == Items.SHEARS && this.canShear()) { + return EnumInteractionResult.a(this.level.isClientSide); + } else if (itemstack.a(Items.SHEARS) && this.canShear()) { + // CraftBukkit start + if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { + return EnumInteractionResult.PASS; + } + // CraftBukkit end this.shear(SoundCategory.PLAYERS); - if (!this.world.isClientSide) { - itemstack.damage(1, entityhuman, (entityhuman1) -> { -@@ -157,7 +167,7 @@ - this.world.playSound((EntityHuman) null, (Entity) this, SoundEffects.ENTITY_MOOSHROOM_SHEAR, soundcategory, 1.0F, 1.0F); - if (!this.world.s_()) { - ((WorldServer) this.world).a(Particles.EXPLOSION, this.locX(), this.e(0.5D), this.locZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D); + this.a(GameEvent.SHEAR, (Entity) entityhuman); + if (!this.level.isClientSide) { +@@ -160,7 +170,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.world); + EntityCow entitycow = (EntityCow) EntityTypes.COW.a(this.level); - entitycow.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.yaw, this.pitch); -@@ -173,7 +183,14 @@ + entitycow.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.getYRot(), this.getXRot()); +@@ -176,7 +186,14 @@ } entitycow.setInvulnerable(this.isInvulnerable()); -- this.world.addEntity(entitycow); +- this.level.addEntity(entitycow); + // CraftBukkit start + if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) { + return; + } -+ this.world.addEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); ++ this.level.addEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); + + this.die(); // CraftBukkit - from above + // CraftBukkit end for (int i = 0; i < 5; ++i) { - this.world.addEntity(new EntityItem(this.world, this.locX(), this.e(1.0D), this.locZ(), new ItemStack(this.getVariant().d.getBlock()))); + this.level.addEntity(new EntityItem(this.level, this.locX(), this.e(1.0D), this.locZ(), new ItemStack(this.getVariant().blockState.getBlock()))); diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch b/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch index 9a12983df..15d481d29 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch @@ -1,33 +1,35 @@ --- a/net/minecraft/world/entity/animal/EntityOcelot.java +++ b/net/minecraft/world/entity/animal/EntityOcelot.java -@@ -128,7 +128,7 @@ +@@ -133,7 +133,7 @@ @Override public boolean isTypeNotPersistent(double d0) { -- return !this.isTrusting() && this.ticksLived > 2400; +- return !this.isTrusting() && this.tickCount > 2400; + return !this.isTrusting() /*&& this.ticksLived > 2400*/; // CraftBukkit } - public static AttributeProvider.Builder eK() { + public static AttributeProvider.Builder p() { @@ -182,7 +182,8 @@ - if ((this.br == null || this.br.h()) && !this.isTrusting() && this.k(itemstack) && entityhuman.h((Entity) this) < 9.0D) { - this.a(entityhuman, itemstack); - if (!this.world.isClientSide) { + if ((this.temptGoal == null || this.temptGoal.h()) && !this.isTrusting() && this.n(itemstack) && entityhuman.f((Entity) this) < 9.0D) { + this.a(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.u(true); - this.world.broadcastEntityEffect(this, (byte) 41); -@@ -290,9 +291,9 @@ - private final EntityOcelot i; + this.w(true); + this.level.broadcastEntityEffect(this, (byte) 41); +@@ -312,10 +313,10 @@ + private final EntityOcelot ocelot; public a(EntityOcelot entityocelot, Class oclass, float f, double d0, double d1) { -- Predicate predicate = IEntitySelector.e; -+ // Predicate predicate = IEntitySelector.e; // CraftBukkit - decompile error +- Predicate predicate = IEntitySelector.NO_CREATIVE_OR_SPECTATOR; ++ // Predicate predicate = IEntitySelector.NO_CREATIVE_OR_SPECTATOR; // CraftBukkit - decompile error +- Objects.requireNonNull(predicate); - super(entityocelot, oclass, f, d0, d1, predicate::test); -+ super(entityocelot, oclass, f, d0, d1, IEntitySelector.e::test); // CraftBukkit - decompile error - this.i = entityocelot; ++ // Objects.requireNonNull(predicate); // CraftBukkit - decompile error ++ super(entityocelot, oclass, f, d0, d1, IEntitySelector.NO_CREATIVE_OR_SPECTATOR::test); // CraftBukkit - decompile error + this.ocelot = entityocelot; } diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch b/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch index be5ca253a..9fdb7d512 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch @@ -1,24 +1,38 @@ --- a/net/minecraft/world/entity/animal/EntityPanda.java +++ b/net/minecraft/world/entity/animal/EntityPanda.java -@@ -64,6 +64,8 @@ - import net.minecraft.world.level.block.state.IBlockData; +@@ -65,6 +65,8 @@ + import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.Vec3D; +import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit + public class EntityPanda extends EntityAnimal { - private static final DataWatcherObject bp = DataWatcher.a(EntityPanda.class, DataWatcherRegistry.b); -@@ -500,7 +502,7 @@ + private static final DataWatcherObject UNHAPPY_COUNTER = DataWatcher.a(EntityPanda.class, DataWatcherRegistry.INT); +@@ -525,7 +527,7 @@ @Override protected void b(EntityItem entityitem) { -- if (this.getEquipment(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PICKUP_PREDICATE.test(entityitem)) { -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !(this.getEquipment(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PICKUP_PREDICATE.test(entityitem))).isCancelled()) { // CraftBukkit +- 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(); -@@ -721,7 +723,7 @@ +@@ -881,10 +883,10 @@ + private final EntityPanda panda; + + public c(EntityPanda entitypanda, Class oclass, float f, double d0, double d1) { +- Predicate predicate = IEntitySelector.NO_SPECTATORS; ++ // Predicate predicate = IEntitySelector.NO_SPECTATORS; + +- Objects.requireNonNull(predicate); +- super(entitypanda, oclass, f, d0, d1, predicate::test); ++ // Objects.requireNonNull(predicate); ++ super(entitypanda, oclass, f, d0, d1, IEntitySelector.NO_SPECTATORS::test); + this.panda = entitypanda; + } + +@@ -1131,7 +1133,7 @@ @Override protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) { if (entityinsentient instanceof EntityPanda && ((EntityPanda) entityinsentient).isAggressive()) { @@ -27,15 +41,3 @@ } } -@@ -825,9 +827,9 @@ - private final EntityPanda i; - - public c(EntityPanda entitypanda, Class oclass, float f, double d0, double d1) { -- Predicate predicate = IEntitySelector.g; -+ // Predicate predicate = IEntitySelector.g; // CraftBukkit - decompile error - -- super(entitypanda, oclass, f, d0, d1, predicate::test); -+ super(entitypanda, oclass, f, d0, d1, IEntitySelector.g::test); // CraftBukkit - decompile error - this.i = entitypanda; - } - diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch b/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch index f23b6af94..7c741fc95 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/world/entity/animal/EntityParrot.java +++ b/net/minecraft/world/entity/animal/EntityParrot.java -@@ -74,7 +74,7 @@ - }; - private static final Item bw = Items.COOKIE; - private static final Set bx = Sets.newHashSet(new Item[]{Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS}); -- private static final Map, SoundEffect> by = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { -+ private static final Map, SoundEffect> by = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error - hashmap.put(EntityTypes.BLAZE, SoundEffects.ENTITY_PARROT_IMITATE_BLAZE); - hashmap.put(EntityTypes.CAVE_SPIDER, SoundEffects.ENTITY_PARROT_IMITATE_SPIDER); - hashmap.put(EntityTypes.CREEPER, SoundEffects.ENTITY_PARROT_IMITATE_CREEPER); -@@ -241,7 +241,7 @@ +@@ -75,7 +75,7 @@ + private static final Item POISONOUS_FOOD = Items.COOKIE; + private static final Set 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, SoundEffect> MOB_SOUND_MAP = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { ++ static final Map, 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 @@ } - if (!this.world.isClientSide) { + 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.world.broadcastEntityEffect(this, (byte) 7); + this.level.broadcastEntityEffect(this, (byte) 7); } else { -@@ -255,7 +255,7 @@ +@@ -267,7 +267,7 @@ itemstack.subtract(1); } @@ -27,7 +27,7 @@ if (entityhuman.isCreative() || !this.isInvulnerable()) { this.damageEntity(DamageSource.playerAttack(entityhuman), Float.MAX_VALUE); } -@@ -369,7 +369,7 @@ +@@ -381,7 +381,7 @@ @Override public boolean isCollidable() { @@ -36,7 +36,7 @@ } @Override -@@ -384,7 +384,7 @@ +@@ -396,7 +396,7 @@ if (this.isInvulnerable(damagesource)) { return false; } else { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch b/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch index d2a89e790..3f4eb2652 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch @@ -10,7 +10,7 @@ + public class EntityPig extends EntityAnimal implements ISteerable, ISaddleable { - private static final DataWatcherObject bo = DataWatcher.a(EntityPig.class, DataWatcherRegistry.i); + private static final DataWatcherObject DATA_SADDLE_ID = DataWatcher.a(EntityPig.class, DataWatcherRegistry.BOOLEAN); @@ -251,7 +255,13 @@ } diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch b/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch index 57abdca9f..3910bab00 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/entity/animal/EntityPufferFish.java +++ b/net/minecraft/world/entity/animal/EntityPufferFish.java -@@ -136,7 +136,7 @@ +@@ -144,7 +144,7 @@ int i = this.getPuffState(); if (entityinsentient.damageEntity(DamageSource.mobAttack(this), (float) (1 + i))) { -- entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0)); -+ entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit - this.playSound(SoundEffects.ENTITY_PUFFER_FISH_STING, 1.0F, 1.0F); +- 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); } -@@ -151,7 +151,7 @@ - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.j, 0.0F)); +@@ -159,7 +159,7 @@ + ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.PUFFER_FISH_STING, 0.0F)); } -- entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0)); -+ entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit +- entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this); ++ entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } } diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch b/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch index b3c1d5a0f..8bd3a7203 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/animal/EntityRabbit.java +++ b/net/minecraft/world/entity/animal/EntityRabbit.java -@@ -72,8 +72,14 @@ +@@ -86,8 +86,14 @@ super(entitytypes, world); - this.bi = new EntityRabbit.ControllerJumpRabbit(this); - this.moveController = new EntityRabbit.ControllerMoveRabbit(this); + this.jumpControl = new EntityRabbit.ControllerJumpRabbit(this); + this.moveControl = new EntityRabbit.ControllerMoveRabbit(this); + this.initializePathFinderGoals(); // CraftBukkit - moved code + } + @@ -15,7 +15,7 @@ @Override public void initPathfinder() { -@@ -340,7 +346,7 @@ +@@ -353,7 +359,7 @@ if (i == 99) { this.getAttributeInstance(GenericAttributes.ARMOR).setValue(8.0D); this.goalSelector.a(4, new EntityRabbit.PathfinderGoalKillerRabbitMeleeAttack(this)); @@ -24,27 +24,27 @@ this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityWolf.class, true)); if (!this.hasCustomName()) { -@@ -456,9 +462,23 @@ - Integer integer = (Integer) iblockdata.get(BlockCarrots.AGE); +@@ -556,9 +562,23 @@ + int i = (Integer) iblockdata.get(BlockCarrots.AGE); - if (integer == 0) { + if (i == 0) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.entity, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { + return; + } + // CraftBukkit end world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 2); - world.a(blockposition, true, this.entity); + world.a(blockposition, true, this.rabbit); } else { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent( -+ this.entity, ++ this.rabbit, + blockposition, -+ iblockdata.set(BlockCarrots.AGE, integer - 1) ++ iblockdata.set(BlockCarrots.AGE, i - 1) + ).isCancelled()) { + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCarrots.AGE, integer - 1), 2); + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCarrots.AGE, i - 1), 2); world.triggerEffect(2001, blockposition, Block.getCombinedId(iblockdata)); } diff --git a/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch b/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch index bf5167deb..e16295296 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/animal/EntitySheep.java +++ b/net/minecraft/world/entity/animal/EntitySheep.java -@@ -60,10 +60,18 @@ - import net.minecraft.world.level.block.state.IBlockData; +@@ -64,11 +64,19 @@ + import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.storage.loot.LootTables; +// CraftBukkit start @@ -14,57 +14,60 @@ + public class EntitySheep extends EntityAnimal implements IShearable { - private static final DataWatcherObject bo = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a); -- private static final Map bp = (Map) SystemUtils.a((Object) Maps.newEnumMap(EnumColor.class), (enummap) -> { -+ private static final Map bp = (Map) SystemUtils.a(Maps.newEnumMap(EnumColor.class), (enummap) -> { // CraftBukkit - decompile error + private static final int EAT_ANIMATION_TICKS = 40; + private static final DataWatcherObject DATA_WOOL_ID = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.BYTE); +- private static final Map ITEM_BY_DYE = (Map) SystemUtils.a((Object) Maps.newEnumMap(EnumColor.class), (enummap) -> { ++ private static final Map 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); -@@ -190,6 +198,11 @@ +@@ -223,6 +231,11 @@ - if (itemstack.getItem() == Items.SHEARS) { - if (!this.world.isClientSide && this.canShear()) { + if (itemstack.a(Items.SHEARS)) { + if (!this.level.isClientSide && this.canShear()) { + // 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) -> { - entityhuman1.broadcastItemBreak(enumhand); -@@ -210,7 +223,9 @@ +@@ -244,7 +257,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.bp.get(this.getColor()), 1); + EntityItem entityitem = this.a((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))); -@@ -300,6 +315,12 @@ +@@ -334,6 +349,12 @@ @Override public void blockEaten() { + // CraftBukkit start + SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity()); -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) return; + // CraftBukkit end this.setSheared(false); if (this.isBaby()) { this.setAge(60); -@@ -318,7 +339,7 @@ +@@ -352,8 +373,8 @@ EnumColor enumcolor = ((EntitySheep) entityanimal).getColor(); EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor(); InventoryCrafting inventorycrafting = a(enumcolor, enumcolor1); -- Optional optional = this.world.getCraftingManager().craft(Recipes.CRAFTING, inventorycrafting, this.world).map((recipecrafting) -> { -+ Optional optional = this.world.getCraftingManager().craft(Recipes.CRAFTING, inventorycrafting, this.world).map((recipecrafting) -> { // Eclipse fail - return recipecrafting.a(inventorycrafting); +- Optional optional = this.level.getCraftingManager().craft(Recipes.CRAFTING, inventorycrafting, this.level).map((recipecrafting) -> { +- return recipecrafting.a((IInventory) inventorycrafting); ++ Optional optional = this.level.getCraftingManager().craft(Recipes.CRAFTING, inventorycrafting, this.level).map((recipecrafting) -> { // Eclipse fail ++ return recipecrafting.a(inventorycrafting); // CraftBukkit - decompile error }).map(ItemStack::getItem); -@@ -336,10 +357,18 @@ + Objects.requireNonNull(ItemDye.class); +@@ -370,10 +391,18 @@ public boolean canUse(EntityHuman entityhuman) { return false; } diff --git a/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch b/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch index b5a55af16..98d70e57f 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/animal/EntitySnowman.java +++ b/net/minecraft/world/entity/animal/EntitySnowman.java -@@ -38,6 +38,10 @@ - import net.minecraft.world.level.block.Blocks; - import net.minecraft.world.level.block.state.IBlockData; +@@ -40,6 +40,10 @@ + import net.minecraft.world.level.gameevent.GameEvent; + import net.minecraft.world.phys.Vec3D; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -10,34 +10,34 @@ + public class EntitySnowman extends EntityGolem implements IShearable, IRangedEntity { - private static final DataWatcherObject b = DataWatcher.a(EntitySnowman.class, DataWatcherRegistry.a); -@@ -96,7 +100,7 @@ + private static final DataWatcherObject DATA_PUMPKIN_ID = DataWatcher.a(EntitySnowman.class, DataWatcherRegistry.BYTE); +@@ -100,7 +104,7 @@ int k = MathHelper.floor(this.locZ()); - if (this.world.getBiome(new BlockPosition(i, 0, k)).getAdjustedTemperature(new BlockPosition(i, j, k)) > 1.0F) { -- this.damageEntity(DamageSource.BURN, 1.0F); + 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.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) { -@@ -112,7 +116,7 @@ + if (!this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +@@ -116,7 +120,7 @@ BlockPosition blockposition = new BlockPosition(i, j, k); - if (this.world.getType(blockposition).isAir() && this.world.getBiome(blockposition).getAdjustedTemperature(blockposition) < 0.8F && iblockdata.canPlace(this.world, blockposition)) { -- this.world.setTypeUpdate(blockposition, iblockdata); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.world, blockposition, iblockdata, this); // CraftBukkit + if (this.level.getType(blockposition).isAir() && this.level.getBiome(blockposition).getAdjustedTemperature(blockposition) < 0.8F && iblockdata.canPlace(this.level, blockposition)) { +- this.level.setTypeUpdate(blockposition, iblockdata); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level, blockposition, iblockdata, this); // CraftBukkit } } } -@@ -143,6 +147,11 @@ +@@ -147,6 +151,11 @@ ItemStack itemstack = entityhuman.b(enumhand); - if (itemstack.getItem() == Items.SHEARS && this.canShear()) { + if (itemstack.a(Items.SHEARS) && this.canShear()) { + // CraftBukkit start + if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { + return EnumInteractionResult.PASS; + } + // CraftBukkit end this.shear(SoundCategory.PLAYERS); - if (!this.world.isClientSide) { - itemstack.damage(1, entityhuman, (entityhuman1) -> { + this.a(GameEvent.SHEAR, (Entity) entityhuman); + if (!this.level.isClientSide) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch b/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch index dcf9afedc..f8e87533c 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/animal/EntityTurtle.java +++ b/net/minecraft/world/entity/animal/EntityTurtle.java @@ -314,7 +314,9 @@ - protected void m() { - super.m(); - if (!this.isBaby() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) { + protected void n() { + super.n(); + if (!this.isBaby() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + this.forceDrops = true; // CraftBukkit this.a((IMaterial) Items.SCUTE, 1); + this.forceDrops = false; // CraftBukkit @@ -15,30 +15,21 @@ @Override public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) { + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = entitylightning; // CraftBukkit - this.damageEntity(DamageSource.LIGHTNING, Float.MAX_VALUE); + this.damageEntity(DamageSource.LIGHTNING_BOLT, Float.MAX_VALUE); + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = null; // CraftBukkit } - static class g extends NavigationGuardian { -@@ -500,8 +504,12 @@ - } else if (this.g.bv > 200) { - World world = this.g.world; + private static class e extends ControllerMove { +@@ -487,8 +491,12 @@ + } else if (this.turtle.layEggCounter > 200) { + World world = this.turtle.level; + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.g, this.e.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, this.g.random.nextInt(4) + 1)).isCancelled()) { - world.playSound((EntityHuman) null, blockposition, SoundEffects.ENTITY_TURTLE_LAY_EGG, SoundCategory.BLOCKS, 0.3F, 0.9F + world.random.nextFloat() * 0.2F); - world.setTypeAndData(this.e.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, this.g.random.nextInt(4) + 1), 3); ++ 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()) { + 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); + } + // CraftBukkit end - this.g.setHasEgg(false); - this.g.u(false); - this.g.setLoveTicks(600); -@@ -581,7 +589,7 @@ - --this.e; - return false; - } else { -- this.d = this.b.world.a(EntityTurtle.i.a, (EntityLiving) this.b); -+ this.d = this.b.world.a(this.a, (EntityLiving) this.b); // CraftBukkit - decompile error - return this.d == null ? false : this.a(this.d.getItemInMainHand()) || this.a(this.d.getItemInOffHand()); - } - } + this.turtle.setHasEgg(false); + this.turtle.w(false); + this.turtle.setLoveTicks(600); diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch b/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch index 33445ac29..b1226de5f 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/animal/EntityWolf.java +++ b/net/minecraft/world/entity/animal/EntityWolf.java -@@ -62,6 +62,11 @@ - import net.minecraft.world.level.block.state.IBlockData; +@@ -63,6 +63,11 @@ + import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start @@ -11,18 +11,18 @@ + public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable { - private static final DataWatcherObject br = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.i); -@@ -101,7 +106,7 @@ + private static final DataWatcherObject 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.bq)); - this.targetSelector.a(6, new PathfinderGoalRandomTargetNonTamed<>(this, EntityTurtle.class, false, EntityTurtle.bo)); -@@ -113,6 +118,24 @@ - return EntityInsentient.p().a(GenericAttributes.MOVEMENT_SPEED, 0.30000001192092896D).a(GenericAttributes.MAX_HEALTH, 8.0D).a(GenericAttributes.ATTACK_DAMAGE, 2.0D); + 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); } + // CraftBukkit - add overriden version @@ -46,7 +46,7 @@ @Override protected void initDatawatcher() { super.initDatawatcher(); -@@ -259,7 +282,7 @@ +@@ -287,7 +310,7 @@ } else { Entity entity = damagesource.getEntity(); @@ -55,7 +55,7 @@ if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) { f = (f + 1.0F) / 2.0F; } -@@ -284,7 +307,7 @@ +@@ -312,7 +335,7 @@ super.setTamed(flag); if (flag) { this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(20.0D); @@ -64,16 +64,16 @@ } else { this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(8.0D); } -@@ -308,7 +331,7 @@ +@@ -336,7 +359,7 @@ itemstack.subtract(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()); return EnumInteractionResult.SUCCESS; } - -@@ -319,7 +342,7 @@ +@@ -348,7 +371,7 @@ this.setWillSit(!this.isWillSit()); this.jumping = false; this.navigation.o(); @@ -82,7 +82,7 @@ return EnumInteractionResult.SUCCESS; } -@@ -341,7 +364,8 @@ +@@ -370,7 +393,8 @@ itemstack.subtract(1); } diff --git a/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch b/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch new file mode 100644 index 000000000..c962c8666 --- /dev/null +++ b/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch @@ -0,0 +1,56 @@ +--- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java ++++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java +@@ -68,7 +68,8 @@ + + public static final int TOTAL_PLAYDEAD_TIME = 200; + protected static final ImmutableList>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_ADULT, SensorType.HURT_BY, SensorType.AXOLOTL_ATTACKABLES, SensorType.AXOLOTL_TEMPTATIONS); +- protected static final ImmutableList> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.BREED_TARGET, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT, new MemoryModuleType[]{MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.PLAY_DEAD_TICKS, MemoryModuleType.NEAREST_ATTACKABLE, MemoryModuleType.TEMPTING_PLAYER, MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, MemoryModuleType.IS_TEMPTED, MemoryModuleType.HAS_HUNTING_COOLDOWN}); ++ // CraftBukkit - decompile error ++ protected static final ImmutableList> MEMORY_TYPES = ImmutableList.>of(MemoryModuleType.BREED_TARGET, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT, new MemoryModuleType[]{MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.PLAY_DEAD_TICKS, MemoryModuleType.NEAREST_ATTACKABLE, MemoryModuleType.TEMPTING_PLAYER, MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, MemoryModuleType.IS_TEMPTED, MemoryModuleType.HAS_HUNTING_COOLDOWN}); + private static final DataWatcherObject DATA_VARIANT = DataWatcher.a(Axolotl.class, DataWatcherRegistry.INT); + private static final DataWatcherObject DATA_PLAYING_DEAD = DataWatcher.a(Axolotl.class, DataWatcherRegistry.BOOLEAN); + private static final DataWatcherObject FROM_BUCKET = DataWatcher.a(Axolotl.class, DataWatcherRegistry.BOOLEAN); +@@ -239,6 +240,7 @@ + @Override + public void setFromBucket(boolean flag) { + this.entityData.set(Axolotl.FROM_BUCKET, flag); ++ this.persistenceRequired = this.isPersistent(); // CraftBukkit - SPIGOT-4106 update persistence + } + + @Nullable +@@ -280,7 +282,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); +@@ -422,7 +424,7 @@ + + if (i < 2400) { + i = Math.min(2400, 100 + i); +- entityhuman.addEffect(new MobEffect(MobEffects.REGENERATION, i, 0), this); ++ entityhuman.addEffect(new MobEffect(MobEffects.REGENERATION, i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AXOLOTL); // CraftBukkit + } + + entityhuman.removeEffect(MobEffects.DIG_SLOWDOWN); +@@ -472,7 +474,7 @@ + + @Override + public BehaviorController getBehaviorController() { +- return super.getBehaviorController(); ++ return (BehaviorController) super.getBehaviorController(); // CraftBukkit - decompile error + } + + @Override +@@ -505,7 +507,7 @@ + + @Override + public boolean isTypeNotPersistent(double d0) { +- return !this.isFromBucket() && !this.hasCustomName(); ++ return true; // CraftBukkit + } + + private static class c extends SmoothSwimmingMoveControl { diff --git a/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch b/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch new file mode 100644 index 000000000..b7949ad7e --- /dev/null +++ b/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch @@ -0,0 +1,47 @@ +--- a/net/minecraft/world/entity/animal/goat/Goat.java ++++ b/net/minecraft/world/entity/animal/goat/Goat.java +@@ -50,6 +50,11 @@ + import net.minecraft.world.level.pathfinder.Pathfinder; + import net.minecraft.world.level.pathfinder.PathfinderNormal; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++// CraftBukkit end ++ + public class Goat extends EntityAnimal { + + public static final EntitySize LONG_JUMPING_DIMENSIONS = EntitySize.b(0.9F, 1.3F).a(0.7F); +@@ -123,13 +128,13 @@ + + @Override + public BehaviorController getBehaviorController() { +- return super.getBehaviorController(); ++ return (BehaviorController) super.getBehaviorController(); // 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); +@@ -161,8 +166,15 @@ + ItemStack itemstack = entityhuman.b(enumhand); + + if (itemstack.a(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); ++ ++ 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.a(enumhand, itemstack1); + return EnumInteractionResult.a(this.level.isClientSide); diff --git a/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch b/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch index 089a1a05b..2a02fb3c2 100644 --- a/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch +++ b/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 -@@ -68,6 +68,8 @@ +@@ -70,6 +70,8 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -8,25 +8,25 @@ + public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, IJumpable, ISaddleable { - private static final Predicate bw = (entityliving) -> { -@@ -95,6 +97,7 @@ - private float bK; - protected boolean bu = true; - protected int bv; + public static final int EQUIPMENT_SLOT_OFFSET = 400; +@@ -109,6 +111,7 @@ + private float mouthAnimO; + protected boolean canGallop = true; + protected int gallopSoundCounter; + public int maxDomestication = 100; // CraftBukkit - store max domestication value protected EntityHorseAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -279,7 +282,7 @@ +@@ -293,7 +296,7 @@ public void loadChest() { - InventorySubcontainer inventorysubcontainer = this.inventoryChest; + InventorySubcontainer inventorysubcontainer = this.inventory; -- this.inventoryChest = new InventorySubcontainer(this.getChestSlots()); -+ this.inventoryChest = new InventorySubcontainer(this.getChestSlots(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit +- this.inventory = new InventorySubcontainer(this.getChestSlots()); ++ this.inventory = new InventorySubcontainer(this.getChestSlots(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit if (inventorysubcontainer != null) { inventorysubcontainer.b((IInventoryListener) this); - int i = Math.min(inventorysubcontainer.getSize(), this.inventoryChest.getSize()); -@@ -395,7 +398,7 @@ + int i = Math.min(inventorysubcontainer.getSize(), this.inventory.getSize()); +@@ -409,7 +412,7 @@ } public int getMaxDomestication() { @@ -35,7 +35,7 @@ } @Override -@@ -466,7 +469,7 @@ +@@ -479,7 +482,7 @@ } if (this.getHealth() < this.getMaxHealth() && f > 0.0F) { @@ -44,24 +44,24 @@ flag = true; } -@@ -542,7 +545,7 @@ +@@ -556,7 +559,7 @@ super.movementTick(); - if (!this.world.isClientSide && this.isAlive()) { - if (this.random.nextInt(900) == 0 && this.deathTicks == 0) { + 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.fl()) { -@@ -779,6 +782,7 @@ + if (this.fU()) { +@@ -794,6 +797,7 @@ if (this.getOwnerUUID() != null) { nbttagcompound.a("Owner", this.getOwnerUUID()); } + nbttagcompound.setInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit - if (!this.inventoryChest.getItem(0).isEmpty()) { - nbttagcompound.set("SaddleItem", this.inventoryChest.getItem(0).save(new NBTTagCompound())); -@@ -806,6 +810,11 @@ + if (!this.inventory.getItem(0).isEmpty()) { + nbttagcompound.set("SaddleItem", this.inventory.getItem(0).save(new NBTTagCompound())); +@@ -821,6 +825,11 @@ if (uuid != null) { this.setOwnerUUID(uuid); } @@ -73,7 +73,7 @@ if (nbttagcompound.hasKeyOfType("SaddleItem", 10)) { ItemStack itemstack = ItemStack.a(nbttagcompound.getCompound("SaddleItem")); -@@ -857,6 +866,18 @@ +@@ -903,6 +912,18 @@ @Override public void b(int i) { @@ -89,6 +89,6 @@ + return; + } + // CraftBukkit end - this.canSlide = true; - this.eU(); - this.fn(); + this.allowStandSliding = true; + this.fD(); + this.fW(); diff --git a/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch b/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch index 80fcec46d..10f253b1a 100644 --- a/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch +++ b/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.java +++ b/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.java -@@ -143,7 +143,7 @@ +@@ -152,7 +152,7 @@ @Override public void c() { -- this.e.setGoalTarget(this.c); -+ this.e.setGoalTarget(this.c, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit - Entity entity = this.b.getLeashHolder(); +- this.mob.setGoalTarget(this.ownerLastHurtBy); ++ this.mob.setGoalTarget(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/nms-patches/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.patch b/nms-patches/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.patch index d991c6e88..8cc079d9a 100644 --- a/nms-patches/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.patch +++ b/nms-patches/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.patch @@ -2,15 +2,15 @@ +++ b/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.java @@ -40,19 +40,20 @@ - entitylightning.teleportAndSync(this.a.locX(), this.a.locY(), this.a.locZ()); + entitylightning.teleportAndSync(this.horse.locX(), this.horse.locY(), this.horse.locZ()); entitylightning.setEffect(true); - worldserver.addEntity(entitylightning); + worldserver.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRAP); // CraftBukkit - EntitySkeleton entityskeleton = this.a(difficultydamagescaler, this.a); + EntitySkeleton entityskeleton = this.a(difficultydamagescaler, this.horse); -- entityskeleton.startRiding(this.a); +- entityskeleton.startRiding(this.horse); - worldserver.addAllEntities(entityskeleton); -+ if (entityskeleton != null) entityskeleton.startRiding(this.a); // CraftBukkit ++ if (entityskeleton != null) entityskeleton.startRiding(this.horse); // CraftBukkit + worldserver.addAllEntities(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP); // CraftBukkit for (int i = 0; i < 3; ++i) { @@ -20,7 +20,7 @@ - entityskeleton1.startRiding(entityhorseabstract); + if (entityskeleton1 != null) entityskeleton1.startRiding(entityhorseabstract); // CraftBukkit - entityhorseabstract.i(this.a.getRandom().nextGaussian() * 0.5D, 0.0D, this.a.getRandom().nextGaussian() * 0.5D); + 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 } diff --git a/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch b/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch index 36322cd68..122873c4b 100644 --- a/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch +++ b/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.java +++ b/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.java -@@ -20,6 +20,11 @@ +@@ -22,6 +22,11 @@ import net.minecraft.world.level.block.BlockFireAbstract; import net.minecraft.world.level.dimension.end.EnderDragonBattle; @@ -11,40 +11,40 @@ + public class EntityEnderCrystal extends Entity { - private static final DataWatcherObject> c = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.m); -@@ -55,7 +60,11 @@ + private static final DataWatcherObject> DATA_BEAM_TARGET = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.OPTIONAL_BLOCK_POS); +@@ -57,7 +62,11 @@ BlockPosition blockposition = this.getChunkCoordinates(); - if (((WorldServer) this.world).getDragonBattle() != null && this.world.getType(blockposition).isAir()) { -- this.world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) this.world, blockposition)); + if (((WorldServer) this.level).getDragonBattle() != null && this.level.getType(blockposition).isAir()) { +- this.level.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) this.level, blockposition)); + // CraftBukkit start -+ if (!CraftEventFactory.callBlockIgniteEvent(this.world, blockposition, this).isCancelled()) { -+ this.world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) this.world, blockposition)); ++ if (!CraftEventFactory.callBlockIgniteEvent(this.level, blockposition, this).isCancelled()) { ++ this.level.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) this.level, blockposition)); + } + // CraftBukkit end } } -@@ -95,9 +104,22 @@ +@@ -97,9 +106,22 @@ return false; } else { - if (!this.dead && !this.world.isClientSide) { + if (!this.isRemoved() && !this.level.isClientSide) { + // CraftBukkit start - All non-living entities need this + if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false)) { + return false; + } + // CraftBukkit end - this.die(); + this.a(Entity.RemovalReason.KILLED); if (!damagesource.isExplosion()) { -- this.world.explode((Entity) null, this.locX(), this.locY(), this.locZ(), 6.0F, Explosion.Effect.DESTROY); +- this.level.explode((Entity) null, this.locX(), this.locY(), this.locZ(), 6.0F, Explosion.Effect.DESTROY); + // CraftBukkit start + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 6.0F, false); -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { -+ this.dead = false; ++ this.unsetRemoved(); + return false; + } -+ this.world.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), Explosion.Effect.DESTROY); ++ this.level.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), Explosion.Effect.DESTROY); + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch b/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch index 971b00436..cebdb294a 100644 --- a/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch +++ b/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch @@ -1,12 +1,13 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java +++ b/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java -@@ -51,6 +51,17 @@ +@@ -53,6 +53,18 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Explosion; ++import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.TileEntity; +import net.minecraft.world.level.storage.loot.LootTableInfo; +import net.minecraft.world.level.storage.loot.parameters.LootContextParameters; @@ -18,31 +19,31 @@ public class EntityEnderDragon extends EntityInsentient implements IMonster { private static final Logger LOGGER = LogManager.getLogger(); -@@ -82,6 +93,7 @@ - private final PathPoint[] bJ = new PathPoint[24]; - private final int[] bK = new int[24]; - private final Path bL = new Path(); +@@ -89,6 +101,7 @@ + private final PathPoint[] nodes = new PathPoint[24]; + private final int[] nodeAdjacency = new int[24]; + private final Path openSet = new Path(); + private Explosion explosionSource = new Explosion(null, this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.Effect.DESTROY); // CraftBukkit - reusable source for CraftTNTPrimed.getSource() public EntityEnderDragon(EntityTypes entitytypes, World world) { super(EntityTypes.ENDER_DRAGON, world); -@@ -219,7 +231,7 @@ +@@ -236,7 +249,7 @@ Vec3D vec3d1 = idragoncontroller.g(); - if (vec3d1 != null) { -+ if (vec3d1 != null && idragoncontroller.getControllerPhase() != DragonControllerPhase.HOVER) { // CraftBukkit - Don't move when hovering ++ 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(); -@@ -357,7 +369,14 @@ - if (this.currentEnderCrystal.dead) { - this.currentEnderCrystal = null; - } else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) { +@@ -378,7 +391,14 @@ + if (this.nearestCrystal.isRemoved()) { + this.nearestCrystal = null; + } else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) { - this.setHealth(this.getHealth() + 1.0F); + // CraftBukkit start + EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), 1.0F, EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL); -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + this.setHealth((float) (this.getHealth() + event.getAmount())); @@ -51,7 +52,7 @@ } } -@@ -432,6 +451,9 @@ +@@ -453,6 +473,9 @@ int j1 = MathHelper.floor(axisalignedbb.maxZ); boolean flag = false; boolean flag1 = false; @@ -61,20 +62,20 @@ for (int k1 = i; k1 <= l; ++k1) { for (int l1 = j; l1 <= i1; ++l1) { -@@ -442,7 +464,11 @@ +@@ -462,7 +485,11 @@ if (!iblockdata.isAir() && iblockdata.getMaterial() != Material.FIRE) { - if (this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) && !TagsBlock.DRAGON_IMMUNE.isTagged(block)) { -- flag1 = this.world.a(blockposition, false) || flag1; + if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.a((Tag) TagsBlock.DRAGON_IMMUNE)) { +- flag1 = this.level.a(blockposition, false) || flag1; + // CraftBukkit start - Add blocks to list rather than destroying them -+ // flag1 = this.world.a(blockposition, false) || flag1; ++ // flag1 = this.level.a(blockposition, false) || flag1; + flag1 = true; -+ destroyedBlocks.add(CraftBlock.at(world, blockposition)); ++ destroyedBlocks.add(CraftBlock.at(level, blockposition)); + // CraftBukkit end } else { flag = true; } -@@ -451,6 +477,51 @@ +@@ -471,6 +498,51 @@ } } @@ -94,7 +95,7 @@ + } else if (event.getYield() == 0F) { + // Yield zero ==> no drops + for (org.bukkit.block.Block block : event.blockList()) { -+ this.world.a(new BlockPosition(block.getX(), block.getY(), block.getZ()), false); ++ this.level.a(new BlockPosition(block.getX(), block.getY(), block.getZ()), false); + } + } else { + for (org.bukkit.block.Block block : event.blockList()) { @@ -108,17 +109,17 @@ + + Block nmsBlock = craftBlock.getNMS().getBlock(); + if (nmsBlock.a(explosionSource)) { -+ TileEntity tileentity = nmsBlock.isTileEntity() ? this.world.getTileEntity(blockposition) : null; -+ LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.world)).a(this.world.random).set(LootContextParameters.ORIGIN, Vec3D.a(blockposition)).set(LootContextParameters.TOOL, ItemStack.b).set(LootContextParameters.EXPLOSION_RADIUS, 1.0F / event.getYield()).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity); ++ 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); + + craftBlock.getNMS().a(loottableinfo_builder).forEach((itemstack) -> { -+ Block.a(world, blockposition, itemstack); ++ Block.a(level, blockposition, itemstack); + }); -+ craftBlock.getNMS().dropNaturally((WorldServer) world, blockposition, ItemStack.b); ++ craftBlock.getNMS().dropNaturally((WorldServer) level, blockposition, ItemStack.EMPTY); + } -+ nmsBlock.wasExploded(world, blockposition, explosionSource); ++ nmsBlock.wasExploded(level, blockposition, explosionSource); + -+ this.world.a(blockposition, false); ++ this.level.a(blockposition, false); + } + } + // CraftBukkit end diff --git a/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.patch b/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.patch index 934df4683..6a7ed6118 100644 --- a/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.patch +++ b/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.patch @@ -13,30 +13,30 @@ private static final Logger LOGGER = LogManager.getLogger(); @@ -22,6 +27,19 @@ - this.currentDragonController.e(); + this.currentPhase.e(); } + // CraftBukkit start - Call EnderDragonChangePhaseEvent + EnderDragonChangePhaseEvent event = new EnderDragonChangePhaseEvent( -+ (CraftEnderDragon) this.enderDragon.getBukkitEntity(), -+ (this.currentDragonController == null) ? null : CraftEnderDragon.getBukkitPhase(this.currentDragonController.getControllerPhase()), ++ (CraftEnderDragon) this.dragon.getBukkitEntity(), ++ (this.currentPhase == null) ? null : CraftEnderDragon.getBukkitPhase(this.currentPhase.getControllerPhase()), + CraftEnderDragon.getBukkitPhase(dragoncontrollerphase) + ); -+ this.enderDragon.world.getServer().getPluginManager().callEvent(event); ++ this.dragon.level.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } + dragoncontrollerphase = CraftEnderDragon.getMinecraftPhase(event.getNewPhase()); + // CraftBukkit end + - this.currentDragonController = this.b(dragoncontrollerphase); - if (!this.enderDragon.world.isClientSide) { - this.enderDragon.getDataWatcher().set(EntityEnderDragon.PHASE, dragoncontrollerphase.b()); + this.currentPhase = this.b(dragoncontrollerphase); + if (!this.dragon.level.isClientSide) { + this.dragon.getDataWatcher().set(EntityEnderDragon.DATA_PHASE, dragoncontrollerphase.b()); @@ -43,6 +61,6 @@ - this.dragonControllers[i] = dragoncontrollerphase.a(this.enderDragon); + this.phases[i] = dragoncontrollerphase.a(this.dragon); } -- return this.dragonControllers[i]; -+ return (T) this.dragonControllers[i]; // CraftBukkit - decompile error +- return this.phases[i]; ++ return (T) this.phases[i]; // CraftBukkit - decompile error } } diff --git a/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch b/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch index d1b222dc1..686e365d9 100644 --- a/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch +++ b/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/wither/EntityWither.java +++ b/net/minecraft/world/entity/boss/wither/EntityWither.java -@@ -52,6 +52,17 @@ +@@ -54,6 +54,17 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.Vec3D; @@ -15,29 +15,29 @@ +import org.bukkit.event.entity.ExplosionPrimeEvent; +// CraftBukkit end + - public class EntityWither extends EntityMonster implements IRangedEntity { + public class EntityWither extends EntityMonster implements PowerableMob, IRangedEntity { - private static final DataWatcherObject b = DataWatcher.a(EntityWither.class, DataWatcherRegistry.b); -@@ -234,16 +245,40 @@ - i = this.getInvul() - 1; + private static final DataWatcherObject DATA_TARGET_A = DataWatcher.a(EntityWither.class, DataWatcherRegistry.INT); +@@ -238,16 +249,40 @@ + this.bossEvent.setProgress(1.0F - (float) i / 220.0F); if (i <= 0) { - Explosion.Effect explosion_effect = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE; + 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); + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false); -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ this.world.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect); ++ this.level.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect); + } + // CraftBukkit end -- this.world.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), 7.0F, false, explosion_effect); +- this.level.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), 7.0F, false, explosion_effect); if (!this.isSilent()) { -- this.world.b(1023, this.getChunkCoordinates(), 0); +- this.level.b(1023, this.getChunkCoordinates(), 0); + // CraftBukkit start - Use relative location for far away sounds + // this.world.b(1023, new BlockPosition(this), 0); -+ int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16; ++ int viewDistance = ((WorldServer) this.level).getServer().getViewDistance() * 16; + for (EntityPlayer player : (List) MinecraftServer.getServer().getPlayerList().players) { + double deltaX = this.locX() - player.locX(); + double deltaZ = this.locZ() - player.locZ(); @@ -46,9 +46,9 @@ + double deltaLength = Math.sqrt(distanceSquared); + double relativeX = player.locX() + (deltaX / deltaLength) * viewDistance; + double relativeZ = player.locZ() + (deltaZ / deltaLength) * viewDistance; -+ player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1023, new BlockPosition((int) relativeX, (int) this.locY(), (int) relativeZ), 0, true)); ++ player.connection.sendPacket(new PacketPlayOutWorldEvent(1023, new BlockPosition((int) relativeX, (int) this.locY(), (int) relativeZ), 0, true)); + } else { -+ player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1023, this.getChunkCoordinates(), 0, true)); ++ player.connection.sendPacket(new PacketPlayOutWorldEvent(1023, this.getChunkCoordinates(), 0, true)); + } + } + // CraftBukkit end @@ -56,26 +56,22 @@ } this.setInvul(i); - if (this.ticksLived % 10 == 0) { + if (this.tickCount % 10 == 0) { - this.heal(10.0F); + this.heal(10.0F, EntityRegainHealthEvent.RegainReason.WITHER_SPAWN); // CraftBukkit } } else { -@@ -295,9 +330,11 @@ - if (entityliving != this && entityliving.isAlive() && this.hasLineOfSight(entityliving)) { - if (entityliving instanceof EntityHuman) { - if (!((EntityHuman) entityliving).abilities.isInvulnerable) { -+ if (CraftEventFactory.callEntityTargetLivingEvent(this, entityliving, EntityTargetEvent.TargetReason.CLOSEST_PLAYER).isCancelled()) continue; // CraftBukkit - this.setHeadTarget(i, entityliving.getId()); - } - } else { -+ if (CraftEventFactory.callEntityTargetLivingEvent(this, entityliving, EntityTargetEvent.TargetReason.CLOSEST_ENTITY).isCancelled()) continue; // CraftBukkit - this.setHeadTarget(i, entityliving.getId()); - } - break; -@@ -333,6 +370,11 @@ - IBlockData iblockdata = this.world.getType(blockposition); +@@ -292,6 +327,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()); + } + } +@@ -322,6 +358,11 @@ + IBlockData iblockdata = this.level.getType(blockposition); if (c(iblockdata)) { + // CraftBukkit start @@ -83,15 +79,15 @@ + continue; + } + // CraftBukkit end - flag = this.world.a(blockposition, true, this) || flag; + flag = this.level.a(blockposition, true, this) || flag; } } -@@ -346,7 +388,7 @@ +@@ -335,7 +376,7 @@ } - if (this.ticksLived % 20 == 0) { + if (this.tickCount % 20 == 0) { - this.heal(1.0F); + this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit } - this.bossBattle.setProgress(this.getHealth() / this.getMaxHealth()); + this.bossEvent.setProgress(this.getHealth() / this.getMaxHealth()); diff --git a/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch b/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch index 5dfc25bcc..df030058e 100644 --- a/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch +++ b/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/decoration/EntityArmorStand.java +++ b/net/minecraft/world/entity/decoration/EntityArmorStand.java -@@ -39,6 +39,15 @@ - import net.minecraft.world.level.material.EnumPistonReaction; +@@ -44,6 +44,15 @@ + import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start @@ -15,22 +15,22 @@ + public class EntityArmorStand extends EntityLiving { - private static final Vector3f bj = new Vector3f(0.0F, 0.0F, 0.0F); -@@ -89,6 +98,13 @@ + public static final int WOBBLE_TIME = 5; +@@ -106,6 +115,13 @@ this.setPosition(d0, d1, d2); } + // CraftBukkit start - SPIGOT-3607, SPIGOT-3637 + @Override + public float getBukkitYaw() { -+ return this.yaw; ++ return this.getYRot(); + } + // CraftBukkit end + @Override public void updateSize() { double d0 = this.locX(); -@@ -144,13 +160,20 @@ +@@ -161,14 +177,21 @@ @Override public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { @@ -41,6 +41,7 @@ + @Override + public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) { + // CraftBukkit end + this.f(itemstack); switch (enumitemslot.a()) { case HAND: - this.playEquipSound(itemstack); @@ -53,7 +54,7 @@ this.armorItems.set(enumitemslot.b(), itemstack); } -@@ -417,6 +440,21 @@ +@@ -405,6 +428,21 @@ return false; } else { ItemStack itemstack2; @@ -66,107 +67,84 @@ + + EquipmentSlot slot = CraftEquipmentSlot.getSlot(enumitemslot); + PlayerArmorStandManipulateEvent armorStandManipulateEvent = new PlayerArmorStandManipulateEvent(player,self,playerHeldItem,armorStandItem,slot); -+ this.world.getServer().getPluginManager().callEvent(armorStandManipulateEvent); ++ this.level.getServer().getPluginManager().callEvent(armorStandManipulateEvent); + + if (armorStandManipulateEvent.isCancelled()) { + return true; + } + // CraftBukkit end - if (entityhuman.abilities.canInstantlyBuild && itemstack1.isEmpty() && !itemstack.isEmpty()) { + if (entityhuman.getAbilities().instabuild && itemstack1.isEmpty() && !itemstack.isEmpty()) { itemstack2 = itemstack.cloneItemStack(); -@@ -445,12 +483,22 @@ +@@ -433,9 +471,19 @@ public boolean damageEntity(DamageSource damagesource, float f) { - if (!this.world.isClientSide && !this.dead) { + if (!this.level.isClientSide && !this.isRemoved()) { if (DamageSource.OUT_OF_WORLD.equals(damagesource)) { -- this.die(); + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { + return false; + } + // CraftBukkit end -+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() + this.killEntity(); return false; -- } else if (!this.isInvulnerable(damagesource) && !this.armorStandInvisible && !this.isMarker()) { -+ } else if (!this.isInvulnerable(damagesource) && (true || !this.armorStandInvisible) && !this.isMarker()) { // CraftBukkit +- } else if (!this.isInvulnerable(damagesource) && !this.invisible && !this.isMarker()) { ++ } else if (!this.isInvulnerable(damagesource) && (true || !this.invisible) && !this.isMarker()) { // CraftBukkit + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, true, this.armorStandInvisible)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, true, this.invisible)) { + return false; + } + // CraftBukkit end if (damagesource.isExplosion()) { - this.g(damagesource); -- this.die(); -+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() - return false; - } else if (DamageSource.FIRE.equals(damagesource)) { - if (this.isBurning()) { + this.h(damagesource); + this.killEntity(); @@ -475,7 +523,7 @@ - } else if (damagesource.v()) { - this.F(); - this.D(); -- this.die(); -+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() - return flag1; - } else { - long i = this.world.getTime(); -@@ -486,7 +534,7 @@ } else { - this.f(damagesource); - this.D(); -- this.die(); + this.g(damagesource); + this.G(); +- this.killEntity(); + this.die(); // CraftBukkit - SPIGOT-4890: remain as this.die() since above damagesource method will call death event } return true; -@@ -513,7 +561,7 @@ - f1 -= f; - if (f1 <= 0.5F) { - this.g(damagesource); -- this.die(); -+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() - } else { - this.setHealth(f1); - } -@@ -521,13 +569,13 @@ - } - - private void f(DamageSource damagesource) { -- Block.a(this.world, this.getChunkCoordinates(), new ItemStack(Items.ARMOR_STAND)); -+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(new ItemStack(Items.ARMOR_STAND))); // CraftBukkit - add to drops - this.g(damagesource); +@@ -536,13 +584,13 @@ } private void g(DamageSource damagesource) { - this.F(); -- this.d(damagesource); -+ // this.d(damagesource); // CraftBukkit - moved down +- Block.a(this.level, this.getChunkCoordinates(), 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); + } + + private void h(DamageSource damagesource) { + this.H(); +- this.f(damagesource); ++ // this.f(damagesource); // CraftBukkit - moved down ItemStack itemstack; int i; -@@ -535,7 +583,7 @@ +@@ -550,7 +598,7 @@ for (i = 0; i < this.handItems.size(); ++i) { itemstack = (ItemStack) this.handItems.get(i); if (!itemstack.isEmpty()) { -- Block.a(this.world, this.getChunkCoordinates().up(), itemstack); +- Block.a(this.level, this.getChunkCoordinates().up(), itemstack); + drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops - this.handItems.set(i, ItemStack.b); + this.handItems.set(i, ItemStack.EMPTY); } } -@@ -543,10 +591,11 @@ +@@ -558,10 +606,11 @@ for (i = 0; i < this.armorItems.size(); ++i) { itemstack = (ItemStack) this.armorItems.get(i); if (!itemstack.isEmpty()) { -- Block.a(this.world, this.getChunkCoordinates().up(), itemstack); +- Block.a(this.level, this.getChunkCoordinates().up(), itemstack); + drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops - this.armorItems.set(i, ItemStack.b); + this.armorItems.set(i, ItemStack.EMPTY); } } -+ this.d(damagesource); // CraftBukkit - moved from above ++ this.f(damagesource); // CraftBukkit - moved from above } -@@ -647,8 +696,16 @@ +@@ -662,8 +711,16 @@ return this.isSmall(); } @@ -180,6 +158,6 @@ @Override public void killEntity() { + org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, drops); // CraftBukkit - call event - this.die(); + this.a(Entity.RemovalReason.KILLED); } diff --git a/nms-patches/net/minecraft/world/entity/decoration/EntityHanging.patch b/nms-patches/net/minecraft/world/entity/decoration/EntityHanging.patch index b4fe187b9..19ec28608 100644 --- a/nms-patches/net/minecraft/world/entity/decoration/EntityHanging.patch +++ b/nms-patches/net/minecraft/world/entity/decoration/EntityHanging.patch @@ -14,16 +14,16 @@ + public abstract class EntityHanging extends Entity { - protected static final Predicate b = (entity) -> { + protected static final Predicate HANGING_ENTITY = (entity) -> { @@ -57,26 +65,37 @@ protected void updateBoundingBox() { if (this.direction != null) { -- double d0 = (double) this.blockPosition.getX() + 0.5D; -- double d1 = (double) this.blockPosition.getY() + 0.5D; -- double d2 = (double) this.blockPosition.getZ() + 0.5D; +- 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.blockPosition, this.direction, this.getHangingWidth(), this.getHangingHeight())); ++ this.a(calculateBoundingBox(this, this.pos, this.direction, this.getHangingWidth(), this.getHangingHeight())); + // CraftBukkit end + } + } @@ -81,12 +81,12 @@ return i % 32 == 0 ? 0.5D : 0.0D; } -@@ -103,6 +123,24 @@ - if (this.e++ == 100) { - this.e = 0; - if (!this.dead && !this.survives()) { +@@ -100,6 +120,24 @@ + if (this.checkInterval++ == 100) { + this.checkInterval = 0; + if (!this.isRemoved() && !this.survives()) { + // CraftBukkit start - fire break events -+ Material material = this.world.getType(this.getChunkCoordinates()).getMaterial(); ++ Material material = this.level.getType(this.getChunkCoordinates()).getMaterial(); + HangingBreakEvent.RemoveCause cause; + + if (!material.equals(Material.AIR)) { @@ -97,19 +97,19 @@ + } + + HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), cause); -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + -+ if (dead || event.isCancelled()) { ++ if (this.isRemoved() || event.isCancelled()) { + return; + } + // CraftBukkit end this.die(); this.a((Entity) null); } -@@ -166,6 +204,22 @@ +@@ -163,6 +201,22 @@ return false; } else { - if (!this.dead && !this.world.isClientSide) { + if (!this.isRemoved() && !this.level.isClientSide) { + // CraftBukkit start - fire break events + Entity damager = (damagesource instanceof EntityDamageSourceIndirect) ? ((EntityDamageSourceIndirect) damagesource).getProximateDamageSource() : damagesource.getEntity(); + HangingBreakEvent event; @@ -119,41 +119,41 @@ + event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), damagesource.isExplosion() ? HangingBreakEvent.RemoveCause.EXPLOSION : HangingBreakEvent.RemoveCause.DEFAULT); + } + -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + -+ if (this.dead || event.isCancelled()) { ++ if (this.isRemoved() || event.isCancelled()) { + return true; + } + // CraftBukkit end + - this.die(); + this.killEntity(); this.velocityChanged(); this.a(damagesource.getEntity()); -@@ -178,6 +232,18 @@ +@@ -175,6 +229,18 @@ @Override public void move(EnumMoveType enummovetype, Vec3D vec3d) { - if (!this.world.isClientSide && !this.dead && vec3d.g() > 0.0D) { -+ if (this.dead) return; // CraftBukkit + if (!this.level.isClientSide && !this.isRemoved() && vec3d.g() > 0.0D) { ++ if (this.isRemoved()) return; // CraftBukkit + + // CraftBukkit start - fire break events + // TODO - Does this need its own cause? Seems to only be triggered by pistons + HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.PHYSICS); -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + -+ if (this.dead || event.isCancelled()) { ++ if (this.isRemoved() || event.isCancelled()) { + return; + } + // CraftBukkit end + - this.die(); + this.killEntity(); this.a((Entity) null); } -@@ -186,7 +252,7 @@ +@@ -183,7 +249,7 @@ @Override public void i(double d0, double d1, double d2) { -- if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { -+ if (false && !this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { // CraftBukkit - not needed - this.die(); +- 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); } diff --git a/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch b/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch index e299ef2ee..c782d10de 100644 --- a/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch +++ b/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/decoration/EntityItemFrame.java +++ b/net/minecraft/world/entity/decoration/EntityItemFrame.java -@@ -83,16 +83,27 @@ +@@ -91,16 +91,27 @@ @Override protected void updateBoundingBox() { if (this.direction != null) { + // CraftBukkit start code moved in to calculateBoundingBox -+ this.a(calculateBoundingBox(this, this.blockPosition, this.direction, this.getHangingWidth(), this.getHangingHeight())); ++ this.a(calculateBoundingBox(this, this.pos, this.direction, this.getHangingWidth(), this.getHangingHeight())); + // CraftBukkit end + } + } @@ -14,9 +14,9 @@ + public static AxisAlignedBB calculateBoundingBox(@Nullable Entity entity, BlockPosition blockPosition, EnumDirection direction, int width, int height) { + { double d0 = 0.46875D; -- double d1 = (double) this.blockPosition.getX() + 0.5D - (double) this.direction.getAdjacentX() * 0.46875D; -- double d2 = (double) this.blockPosition.getY() + 0.5D - (double) this.direction.getAdjacentY() * 0.46875D; -- double d3 = (double) this.blockPosition.getZ() + 0.5D - (double) this.direction.getAdjacentZ() * 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; - - this.setPositionRaw(d1, d2, d3); - double d4 = (double) this.getHangingWidth(); @@ -37,7 +37,7 @@ switch (enumdirection_enumaxis) { case X: -@@ -108,9 +119,10 @@ +@@ -116,9 +127,10 @@ d4 /= 32.0D; d5 /= 32.0D; d6 /= 32.0D; @@ -49,19 +49,19 @@ @Override public boolean survives() { -@@ -160,6 +172,11 @@ +@@ -168,6 +180,11 @@ return false; } else if (!damagesource.isExplosion() && !this.getItem().isEmpty()) { - if (!this.world.isClientSide) { + if (!this.level.isClientSide) { + // CraftBukkit start - fire EntityDamageEvent -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false) || this.dead) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false) || this.isRemoved()) { + return true; + } + // CraftBukkit end this.b(damagesource.getEntity(), false); - this.playSound(SoundEffects.ENTITY_ITEM_FRAME_REMOVE_ITEM, 1.0F, 1.0F); + this.playSound(this.h(), 1.0F, 1.0F); } -@@ -247,6 +264,12 @@ +@@ -277,6 +294,12 @@ } public void setItem(ItemStack itemstack, boolean flag) { @@ -74,12 +74,12 @@ if (!itemstack.isEmpty()) { itemstack = itemstack.cloneItemStack(); itemstack.setCount(1); -@@ -254,7 +277,7 @@ +@@ -284,7 +307,7 @@ } - this.getDataWatcher().set(EntityItemFrame.ITEM, itemstack); + this.getDataWatcher().set(EntityItemFrame.DATA_ITEM, itemstack); - if (!itemstack.isEmpty()) { + if (!itemstack.isEmpty() && playSound) { // CraftBukkit - this.playSound(SoundEffects.ENTITY_ITEM_FRAME_ADD_ITEM, 1.0F, 1.0F); + this.playSound(this.l(), 1.0F, 1.0F); } diff --git a/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch b/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch index e1e7fb8e1..7db7fc210 100644 --- a/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch +++ b/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch @@ -1,34 +1,25 @@ --- a/net/minecraft/world/entity/decoration/EntityLeash.java +++ b/net/minecraft/world/entity/decoration/EntityLeash.java -@@ -23,6 +23,13 @@ - import net.minecraft.world.level.World; +@@ -25,6 +25,12 @@ import net.minecraft.world.phys.AxisAlignedBB; + import net.minecraft.world.phys.Vec3D; +// CraftBukkit start +import net.minecraft.network.protocol.game.PacketPlayOutAttachEntity; +import net.minecraft.server.level.EntityPlayer; -+import net.minecraft.server.level.WorldServer; +import org.bukkit.craftbukkit.event.CraftEventFactory; +// CraftBukkit end + public class EntityLeash extends EntityHanging { - public EntityLeash(EntityTypes entitytypes, World world) { -@@ -48,6 +55,7 @@ - @Override - protected void updateBoundingBox() { - this.setPositionRaw((double) this.blockPosition.getX() + 0.5D, (double) this.blockPosition.getY() + 0.5D, (double) this.blockPosition.getZ() + 0.5D); -+ if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit - } - - @Override -@@ -94,22 +102,42 @@ + public static final double OFFSET_Y = 0.375D; +@@ -96,22 +102,42 @@ while (iterator.hasNext()) { entityinsentient = (EntityInsentient) iterator.next(); if (entityinsentient.getLeashHolder() == entityhuman) { + // CraftBukkit start + if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman).isCancelled()) { -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(entityinsentient, entityinsentient.getLeashHolder())); ++ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutAttachEntity(entityinsentient, entityinsentient.getLeashHolder())); + continue; + } + // CraftBukkit end @@ -39,12 +30,12 @@ if (!flag) { - this.die(); -- if (entityhuman.abilities.canInstantlyBuild) { +- if (entityhuman.getAbilities().instabuild) { + // CraftBukkit start - Move below + // this.die(); + boolean die = true; + // CraftBukkit end -+ if (true || entityhuman.abilities.canInstantlyBuild) { // CraftBukkit - Process for non-creative as well ++ if (true || entityhuman.getAbilities().instabuild) { // CraftBukkit - Process for non-creative as well iterator = list.iterator(); while (iterator.hasNext()) { @@ -56,7 +47,7 @@ + die = false; + continue; + } -+ entityinsentient.unleash(true, !entityhuman.abilities.canInstantlyBuild); // false -> survival mode boolean ++ entityinsentient.unleash(true, !entityhuman.getAbilities().instabuild); // false -> survival mode boolean + // CraftBukkit end } } diff --git a/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch b/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch index 23de005ae..2809bebd6 100644 --- a/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch +++ b/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/entity/decoration/EntityPainting.java +++ b/net/minecraft/world/entity/decoration/EntityPainting.java -@@ -26,6 +26,10 @@ +@@ -27,6 +27,10 @@ public EntityPainting(EntityTypes entitytypes, World world) { super(entitytypes, world); + // CraftBukkit start - generate a non-null painting -+ List list = Lists.newArrayList(Paintings.a); -+ this.art = (Paintings) list.get(this.random.nextInt(list.size())); ++ List list = Lists.newArrayList(Paintings.KEBAB); ++ this.motive = (Paintings) list.get(this.random.nextInt(list.size())); + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch b/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch index af437d19f..f374d5db4 100644 --- a/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch +++ b/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/EntityFallingBlock.java +++ b/net/minecraft/world/entity/item/EntityFallingBlock.java -@@ -43,6 +43,8 @@ +@@ -45,6 +45,8 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.Vec3D; @@ -8,35 +8,44 @@ + public class EntityFallingBlock extends Entity { - private IBlockData block; -@@ -109,7 +111,7 @@ + private IBlockData blockState; +@@ -114,7 +116,7 @@ - if (this.ticksLived++ == 0) { + if (this.time++ == 0) { blockposition = this.getChunkCoordinates(); -- if (this.world.getType(blockposition).a(block)) { -+ if (this.world.getType(blockposition).a(block) && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { - this.world.a(blockposition, false); - } else if (!this.world.isClientSide) { +- 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); + } else if (!this.level.isClientSide) { this.die(); -@@ -161,6 +163,11 @@ - this.block = (IBlockData) this.block.set(BlockProperties.C, true); +@@ -165,6 +167,11 @@ + this.blockState = (IBlockData) this.blockState.set(BlockProperties.WATERLOGGED, true); } + // CraftBukkit start -+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.block).isCancelled()) { ++ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.blockState).isCancelled()) { + return; + } + // CraftBukkit end - if (this.world.setTypeAndData(blockposition, this.block, 3)) { - if (block instanceof BlockFalling) { - ((BlockFalling) block).a(this.world, blockposition, this.block, iblockdata, this); -@@ -217,7 +224,9 @@ - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); + 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 +245,7 @@ + if (i < 0) { + return false; + } else { +- Predicate predicate; ++ Predicate predicate; // CraftBukkit - decompile error + DamageSource damagesource1; + if (this.blockState.getBlock() instanceof Fallable) { +@@ -254,7 +261,9 @@ + float f2 = (float) Math.min(MathHelper.d((float) i * this.fallDamagePerDistance), this.fallDamageMax); + + this.level.getEntities(this, this.getBoundingBox(), predicate).forEach((entity) -> { + CraftEventFactory.entityDamage = this; // CraftBukkit - entity.damageEntity(damagesource, (float) Math.min(MathHelper.d((float) i * this.fallHurtAmount), this.fallHurtMax)); + entity.damageEntity(damagesource1, f2); + CraftEventFactory.entityDamage = null; // CraftBukkit - } + }); + boolean flag = this.blockState.a((Tag) TagsBlock.ANVIL); - if (flag && (double) this.random.nextFloat() < 0.05000000074505806D + (double) i * 0.05D) { diff --git a/nms-patches/net/minecraft/world/entity/item/EntityItem.patch b/nms-patches/net/minecraft/world/entity/item/EntityItem.patch index 2ac6f4bec..a2c5db706 100644 --- a/nms-patches/net/minecraft/world/entity/item/EntityItem.patch +++ b/nms-patches/net/minecraft/world/entity/item/EntityItem.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/item/EntityItem.java +++ b/net/minecraft/world/entity/item/EntityItem.java -@@ -31,6 +31,12 @@ - import net.minecraft.world.level.World; +@@ -33,6 +33,12 @@ + import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start @@ -12,16 +12,16 @@ + public class EntityItem extends Entity { - private static final DataWatcherObject ITEM = DataWatcher.a(EntityItem.class, DataWatcherRegistry.g); -@@ -40,6 +46,7 @@ + private static final DataWatcherObject DATA_ITEM = DataWatcher.a(EntityItem.class, DataWatcherRegistry.ITEM_STACK); +@@ -45,6 +51,7 @@ private UUID thrower; private UUID owner; - public final float b; + public final float bobOffs; + private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit public EntityItem(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -75,9 +82,12 @@ +@@ -94,9 +101,12 @@ this.die(); } else { super.tick(); @@ -35,10 +35,10 @@ + this.lastTick = MinecraftServer.currentTick; + // CraftBukkit end - this.lastX = this.locX(); - this.lastY = this.locY(); -@@ -133,9 +143,11 @@ - } + this.xo = this.locX(); + this.yo = this.locY(); +@@ -148,9 +158,11 @@ + this.mergeNearby(); } + /* CraftBukkit start - moved up @@ -47,12 +47,12 @@ } + // CraftBukkit end */ - this.impulse |= this.aK(); - if (!this.world.isClientSide) { -@@ -147,6 +159,12 @@ + this.hasImpulse |= this.aR(); + if (!this.level.isClientSide) { +@@ -162,6 +174,12 @@ } - if (!this.world.isClientSide && this.age >= 6000) { + if (!this.level.isClientSide && this.age >= 6000) { + // CraftBukkit start - fire ItemDespawnEvent + if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) { + this.age = 0; @@ -62,7 +62,7 @@ this.die(); } -@@ -222,10 +240,11 @@ +@@ -237,10 +255,11 @@ private static void a(EntityItem entityitem, ItemStack itemstack, ItemStack itemstack1) { ItemStack itemstack2 = a(itemstack, itemstack1, 64); @@ -75,7 +75,7 @@ a(entityitem, itemstack, itemstack1); entityitem.pickupDelay = Math.max(entityitem.pickupDelay, entityitem1.pickupDelay); entityitem.age = Math.min(entityitem.age, entityitem1.age); -@@ -249,6 +268,11 @@ +@@ -264,6 +283,11 @@ } else if (!this.getItemStack().getItem().a(damagesource)) { return false; } else { @@ -85,22 +85,22 @@ + } + // CraftBukkit end this.velocityChanged(); - this.f = (int) ((float) this.f - f); - if (this.f <= 0) { -@@ -310,6 +334,46 @@ + this.health = (int) ((float) this.health - f); + this.a(GameEvent.ENTITY_DAMAGED, damagesource.getEntity()); +@@ -327,6 +351,46 @@ Item item = itemstack.getItem(); int i = itemstack.getCount(); + // CraftBukkit start - fire PlayerPickupItemEvent -+ int canHold = entityhuman.inventory.canHold(itemstack); ++ int canHold = entityhuman.getInventory().canHold(itemstack); + int remaining = i - canHold; + + if (this.pickupDelay <= 0 && canHold > 0) { + itemstack.setCount(canHold); + // Call legacy event + PlayerPickupItemEvent playerEvent = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining); -+ playerEvent.setCancelled(!entityhuman.canPickUpLoot); -+ this.world.getServer().getPluginManager().callEvent(playerEvent); ++ playerEvent.setCancelled(!playerEvent.getPlayer().getCanPickupItems()); ++ this.level.getServer().getPluginManager().callEvent(playerEvent); + if (playerEvent.isCancelled()) { + itemstack.setCount(i); // SPIGOT-5294 - restore count + return; @@ -108,8 +108,8 @@ + + // Call newer event afterwards + EntityPickupItemEvent entityEvent = new EntityPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining); -+ entityEvent.setCancelled(!entityhuman.canPickUpLoot); -+ this.world.getServer().getPluginManager().callEvent(entityEvent); ++ entityEvent.setCancelled(!entityEvent.getEntity().getCanPickupItems()); ++ this.level.getServer().getPluginManager().callEvent(entityEvent); + if (entityEvent.isCancelled()) { + itemstack.setCount(i); // SPIGOT-5294 - restore count + return; @@ -131,16 +131,16 @@ + } + // CraftBukkit end + - if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(entityhuman.getUniqueID())) && entityhuman.inventory.pickup(itemstack)) { + if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(entityhuman.getUniqueID())) && entityhuman.getInventory().pickup(itemstack)) { entityhuman.receive(this, i); if (itemstack.isEmpty()) { -@@ -353,7 +417,9 @@ +@@ -370,7 +434,9 @@ } public void setItemStack(ItemStack itemstack) { + com.google.common.base.Preconditions.checkArgument(!itemstack.isEmpty(), "Cannot drop air"); // CraftBukkit - this.getDataWatcher().set(EntityItem.ITEM, itemstack); -+ this.getDataWatcher().markDirty(EntityItem.ITEM); // CraftBukkit - SPIGOT-4591, must mark dirty + this.getDataWatcher().set(EntityItem.DATA_ITEM, itemstack); ++ this.getDataWatcher().markDirty(EntityItem.DATA_ITEM); // CraftBukkit - SPIGOT-4591, must mark dirty } @Override diff --git a/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch b/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch index 395b4f603..470492d4d 100644 --- a/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch +++ b/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch @@ -8,31 +8,31 @@ + public class EntityTNTPrimed extends Entity { - private static final DataWatcherObject FUSE_TICKS = DataWatcher.a(EntityTNTPrimed.class, DataWatcherRegistry.b); + private static final DataWatcherObject DATA_FUSE_ID = DataWatcher.a(EntityTNTPrimed.class, DataWatcherRegistry.INT); + private static final int DEFAULT_FUSE_TIME = 80; @Nullable - public EntityLiving source; - private int fuseTicks; + public EntityLiving owner; + public float yield = 4; // CraftBukkit - add field + public boolean isIncendiary = false; // CraftBukkit - add field public EntityTNTPrimed(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -72,10 +76,13 @@ +@@ -73,10 +77,13 @@ - --this.fuseTicks; - if (this.fuseTicks <= 0) { + this.setFuseTicks(i); + if (i <= 0) { - this.die(); + // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event + // this.die(); - if (!this.world.isClientSide) { + if (!this.level.isClientSide) { this.explode(); } + this.die(); + // CraftBukkit end } else { - this.aK(); - if (this.world.isClientSide) { -@@ -86,9 +93,16 @@ + this.aR(); + if (this.level.isClientSide) { +@@ -87,9 +94,16 @@ } private void explode() { @@ -40,12 +40,12 @@ + // CraftBukkit start + // float f = 4.0F; -- this.world.explode(this, this.locX(), this.e(0.0625D), this.locZ(), 4.0F, Explosion.Effect.BREAK); +- this.level.explode(this, this.locX(), this.e(0.0625D), this.locZ(), 4.0F, Explosion.Effect.BREAK); + ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ this.world.createExplosion(this, this.locX(), this.e(0.0625D), this.locZ(), event.getRadius(), event.getFire(), Explosion.Effect.BREAK); ++ this.level.createExplosion(this, this.locX(), this.e(0.0625D), this.locZ(), event.getRadius(), event.getFire(), Explosion.Effect.BREAK); + } + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityCaveSpider.patch b/nms-patches/net/minecraft/world/entity/monster/EntityCaveSpider.patch index aef0d4e31..71fd6ae8a 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityCaveSpider.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityCaveSpider.patch @@ -4,8 +4,8 @@ } if (b0 > 0) { -- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0)); -+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit +- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this); ++ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch b/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch index d51fcffdd..1e0d83f60 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/monster/EntityCreeper.java +++ b/net/minecraft/world/entity/monster/EntityCreeper.java -@@ -38,13 +38,19 @@ - import net.minecraft.world.level.IMaterial; +@@ -44,6 +44,12 @@ import net.minecraft.world.level.World; + import net.minecraft.world.level.gameevent.GameEvent; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -10,22 +10,14 @@ +import org.bukkit.event.entity.ExplosionPrimeEvent; +// CraftBukkit end + - public class EntityCreeper extends EntityMonster { + public class EntityCreeper extends EntityMonster implements PowerableMob { - private static final DataWatcherObject b = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.b); - private static final DataWatcherObject POWERED = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.i); - private static final DataWatcherObject d = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.i); - private int bo; -- private int fuseTicks; -+ public int fuseTicks; // PAIL - public int maxFuseTicks = 30; - public int explosionRadius = 3; - private int bs; -@@ -200,9 +206,19 @@ + private static final DataWatcherObject DATA_SWELL_DIR = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.INT); +@@ -219,9 +225,19 @@ @Override public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) { super.onLightningStrike(worldserver, entitylightning); -- this.datawatcher.set(EntityCreeper.POWERED, true); +- this.entityData.set(EntityCreeper.DATA_IS_POWERED, true); + // CraftBukkit start + if (CraftEventFactory.callCreeperPowerEvent(this, entitylightning, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) { + return; @@ -35,50 +27,50 @@ } + public void setPowered(boolean powered) { -+ this.datawatcher.set(EntityCreeper.POWERED, powered); ++ this.entityData.set(EntityCreeper.DATA_IS_POWERED, powered); + } + // CraftBukkit end + @Override protected EnumInteractionResult b(EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.b(enumhand); -@@ -227,10 +243,18 @@ - Explosion.Effect explosion_effect = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE; +@@ -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.killed = true; -- this.world.explode(this, this.locX(), this.locY(), this.locZ(), (float) this.explosionRadius * f, explosion_effect); +- this.dead = true; +- this.level.explode(this, this.locX(), this.locY(), this.locZ(), (float) this.explosionRadius * f, explosion_effect); - this.die(); - this.createEffectCloud(); + // CraftBukkit start + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false); -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { -+ this.killed = true; -+ this.world.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect); ++ this.dead = true; ++ this.level.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect); + this.die(); + this.createEffectCloud(); + } else { -+ fuseTicks = 0; ++ swell = 0; + } + // CraftBukkit end } } -@@ -241,6 +265,7 @@ +@@ -260,6 +284,7 @@ if (!collection.isEmpty()) { - EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.locX(), this.locY(), this.locZ()); + EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level, this.locX(), this.locY(), this.locZ()); + entityareaeffectcloud.setSource(this); // CraftBukkit entityareaeffectcloud.setRadius(2.5F); entityareaeffectcloud.setRadiusOnUse(-0.5F); entityareaeffectcloud.setWaitTime(10); -@@ -254,7 +279,7 @@ +@@ -273,7 +298,7 @@ entityareaeffectcloud.addEffect(new MobEffect(mobeffect)); } -- this.world.addEntity(entityareaeffectcloud); -+ this.world.addEntity(entityareaeffectcloud, CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit +- this.level.addEntity(entityareaeffectcloud); ++ this.level.addEntity(entityareaeffectcloud, CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit } } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch b/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch index d6ce5ff37..68d822e8b 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch @@ -20,38 +20,41 @@ if (entityliving == null) { @@ -120,6 +130,7 @@ - attributemodifiable.b(EntityEnderman.c); + attributemodifiable.b(EntityEnderman.SPEED_MODIFIER_ATTACKING); } } + return true; } -@@ -413,8 +424,12 @@ +@@ -446,9 +457,13 @@ + if (iblockdata2 != null) { + iblockdata2 = Block.b(iblockdata2, (GeneratorAccess) this.enderman.level, blockposition); + if (this.a(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); ++ } ++ // CraftBukkit end + } + + } +@@ -487,9 +502,13 @@ boolean flag = movingobjectpositionblock.getBlockPosition().equals(blockposition); - if (block.a((Tag) TagsBlock.ENDERMAN_HOLDABLE) && flag) { + 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()); + // 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()); + } + // CraftBukkit end } } -@@ -449,8 +464,12 @@ - if (iblockdata2 != null) { - iblockdata2 = Block.b(iblockdata2, (GeneratorAccess) this.a.world, blockposition); - if (this.a(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) { -+ // CraftBukkit start - Place event -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, iblockdata2).isCancelled()) { - world.setTypeAndData(blockposition, iblockdata2, 3); - this.a.setCarried((IBlockData) null); -+ } -+ // CraftBukkit end - } - - } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch b/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch index 449e83901..aa41cb9d7 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch @@ -1,12 +1,11 @@ --- a/net/minecraft/world/entity/monster/EntityGhast.java +++ b/net/minecraft/world/entity/monster/EntityGhast.java -@@ -193,7 +193,8 @@ +@@ -318,6 +318,8 @@ - EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, d2, d3, d4); + EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, d2, d3, d4, this.ghast.getPower()); -- entitylargefireball.yield = this.ghast.getPower(); + // CraftBukkit - set bukkitYield when setting explosionpower -+ entitylargefireball.bukkitYield = entitylargefireball.yield = this.ghast.getPower(); ++ 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.a = -40; + this.chargeTime = -40; diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityGuardianElder.patch b/nms-patches/net/minecraft/world/entity/monster/EntityGuardianElder.patch index fc6007b1a..3cf5d2723 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityGuardianElder.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityGuardianElder.patch @@ -3,9 +3,9 @@ @@ -79,7 +79,7 @@ if (!entityplayer.hasEffect(mobeffectlist) || entityplayer.getEffect(mobeffectlist).getAmplifier() < 2 || entityplayer.getEffect(mobeffectlist).getDuration() < 1200) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.k, this.isSilent() ? 0.0F : 1.0F)); -- entityplayer.addEffect(new MobEffect(mobeffectlist, 6000, 2)); -+ entityplayer.addEffect(new MobEffect(mobeffectlist, 6000, 2), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit + entityplayer.connection.sendPacket(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/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch b/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch index 32b229536..d89713617 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityIllagerIllusioner.java +++ b/net/minecraft/world/entity/monster/EntityIllagerIllusioner.java -@@ -67,7 +67,7 @@ +@@ -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)); @@ -9,16 +9,7 @@ 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)); -@@ -206,7 +206,7 @@ - - @Override - protected void j() { -- EntityIllagerIllusioner.this.getGoalTarget().addEffect(new MobEffect(MobEffects.BLINDNESS, 400)); -+ EntityIllagerIllusioner.this.getGoalTarget().addEffect(new MobEffect(MobEffects.BLINDNESS, 400), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit - } - - @Override -@@ -243,7 +243,7 @@ +@@ -228,7 +228,7 @@ @Override protected void j() { @@ -27,3 +18,12 @@ } @Nullable +@@ -274,7 +274,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 + } + + @Override diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityIllagerWizard.patch b/nms-patches/net/minecraft/world/entity/monster/EntityIllagerWizard.patch index cbbc280b3..95afeab3f 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityIllagerWizard.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityIllagerWizard.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/monster/EntityIllagerWizard.java +++ b/net/minecraft/world/entity/monster/EntityIllagerWizard.java -@@ -156,6 +156,11 @@ +@@ -161,6 +161,11 @@ public void e() { - --this.b; - if (this.b == 0) { + --this.attackWarmupDelay; + if (this.attackWarmupDelay == 0) { + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleEntitySpellCastEvent(EntityIllagerWizard.this, this.getCastSpell())) { + return; diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch b/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch index 7a1b47698..fe9bab48b 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/monster/EntityPhantom.java +++ b/net/minecraft/world/entity/monster/EntityPhantom.java -@@ -243,7 +243,7 @@ +@@ -529,7 +529,7 @@ EntityHuman entityhuman = (EntityHuman) iterator.next(); - if (EntityPhantom.this.a((EntityLiving) entityhuman, PathfinderTargetCondition.a)) { + 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 return true; diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch b/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch index f5a8b728a..740250679 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/monster/EntityPigZombie.java +++ b/net/minecraft/world/entity/monster/EntityPigZombie.java -@@ -69,7 +69,7 @@ - protected void m() { +@@ -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()); @@ -9,25 +9,25 @@ this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, 10, true, false, this::a_)); this.targetSelector.a(3, new PathfinderGoalUniversalAngerReset<>(this, true)); } -@@ -142,7 +142,7 @@ +@@ -144,7 +144,7 @@ }).filter((entitypigzombie) -> { - return !entitypigzombie.r(this.getGoalTarget()); + return !entitypigzombie.p(this.getGoalTarget()); }).forEach((entitypigzombie) -> { - entitypigzombie.setGoalTarget(this.getGoalTarget()); + entitypigzombie.setGoalTarget(this.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit }); } -@@ -151,7 +151,7 @@ +@@ -153,7 +153,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.bo = EntityPigZombie.d.a(this.random); - this.bt = EntityPigZombie.bs.a(this.random); -@@ -161,12 +161,21 @@ + 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); } @@ -37,11 +37,11 @@ @Override public void anger() { -- this.setAnger(EntityPigZombie.bp.a(this.random)); +- this.setAnger(EntityPigZombie.PERSISTENT_ANGER_TIME.a(this.random)); + // CraftBukkit start -+ Entity entity = ((WorldServer) this.world).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.bp.a(this.random)); -+ this.world.getServer().getPluginManager().callEvent(event); ++ 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)); ++ this.level.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + this.setAngerTarget(null); + return; diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch b/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch index 32c928ab1..9ab28efe5 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityPillager.java +++ b/net/minecraft/world/entity/monster/EntityPillager.java -@@ -70,7 +70,7 @@ +@@ -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)); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch b/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch index 752105942..69301ac02 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityRavager.java +++ b/net/minecraft/world/entity/monster/EntityRavager.java -@@ -69,7 +69,7 @@ +@@ -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)); @@ -9,12 +9,12 @@ 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)); -@@ -160,7 +160,7 @@ - IBlockData iblockdata = this.world.getType(blockposition); +@@ -169,7 +169,7 @@ + IBlockData iblockdata = this.level.getType(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.world.a(blockposition, true, this) || flag; + flag = this.level.a(blockposition, true, this) || flag; } } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch b/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch index 8e2290760..fe762bbcf 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityShulker.java +++ b/net/minecraft/world/entity/monster/EntityShulker.java -@@ -47,11 +47,17 @@ +@@ -57,6 +57,12 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -12,29 +12,23 @@ + public class EntityShulker extends EntityGolem implements IMonster { - private static final UUID bp = UUID.fromString("7E0292F2-9434-48D5-A29F-9583AF7DF27F"); - private static final AttributeModifier bq = new AttributeModifier(EntityShulker.bp, "Covered armor bonus", 20.0D, AttributeModifier.Operation.ADDITION); -- protected static final DataWatcherObject b = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.n); -+ public static final DataWatcherObject b = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.n); // PAIL protected -> public, rename ATTACH_FACE - protected static final DataWatcherObject> c = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.m); - protected static final DataWatcherObject d = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.a); - public static final DataWatcherObject COLOR = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.a); -@@ -71,7 +77,7 @@ + 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.e()); + this.goalSelector.a(7, new EntityShulker.f()); this.goalSelector.a(8, new PathfinderGoalRandomLookaround(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 EntityShulker.d(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)); } -@@ -319,6 +325,16 @@ +@@ -405,6 +411,16 @@ EnumDirection enumdirection = this.g(blockposition1); if (enumdirection != null) { + // CraftBukkit start -+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), new Location(this.world.getWorld(), blockposition1.getX(), blockposition1.getY(), blockposition1.getZ())); -+ this.world.getServer().getPluginManager().callEvent(teleport); ++ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), new Location(this.level.getWorld(), blockposition1.getX(), blockposition1.getY(), blockposition1.getZ())); ++ this.level.getServer().getPluginManager().callEvent(teleport); + if (!teleport.isCancelled()) { + Location to = teleport.getTo(); + blockposition1 = new BlockPosition(to.getX(), to.getY(), to.getZ()); @@ -42,14 +36,15 @@ + return false; + } + // CraftBukkit end - this.datawatcher.set(EntityShulker.b, enumdirection); - this.playSound(SoundEffects.ENTITY_SHULKER_TELEPORT, 1.0F, 1.0F); - this.datawatcher.set(EntityShulker.c, Optional.of(blockposition1)); -@@ -359,6 +375,7 @@ + this.decouple(); + this.setAttachFace(enumdirection); + this.playSound(SoundEffects.SHULKER_TELEPORT, 1.0F, 1.0F); +@@ -477,7 +493,7 @@ } - this.g((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D); -+ if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit + entityshulker.d(vec3d); +- this.level.addEntity(entityshulker); ++ this.level.addEntity(entityshulker, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - the mysteries of life } } - + } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch b/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch index 2c79d7445..27207538d 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/monster/EntitySilverfish.java +++ b/net/minecraft/world/entity/monster/EntitySilverfish.java -@@ -45,7 +45,7 @@ - this.goalSelector.a(3, this.b); +@@ -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()); @@ -9,19 +9,7 @@ this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); } -@@ -183,6 +183,11 @@ - IBlockData iblockdata = world.getType(blockposition); - - if (BlockMonsterEggs.h(iblockdata)) { -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, BlockMonsterEggs.c(iblockdata.getBlock())).isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - world.setTypeAndData(blockposition, BlockMonsterEggs.c(iblockdata.getBlock()), 3); - this.a.doSpawnEffect(); - this.a.die(); -@@ -229,6 +234,11 @@ +@@ -171,6 +171,11 @@ Block block = iblockdata.getBlock(); if (block instanceof BlockMonsterEggs) { @@ -30,6 +18,18 @@ + continue; + } + // CraftBukkit end - if (world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) { + if (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { world.a(blockposition1, true, this.silverfish); } else { +@@ -239,6 +244,11 @@ + IBlockData iblockdata = world.getType(blockposition); + + if (BlockMonsterEggs.h(iblockdata)) { ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, BlockMonsterEggs.n(iblockdata)).isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + world.setTypeAndData(blockposition, BlockMonsterEggs.n(iblockdata), 3); + this.mob.doSpawnEffect(); + this.mob.die(); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch b/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch index 1249d5184..bc09c257a 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java +++ b/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java -@@ -196,8 +196,19 @@ - double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2); +@@ -195,8 +195,19 @@ + double d3 = Math.sqrt(d0 * d0 + d2 * d2); - entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.world.getDifficulty().a() * 4)); + entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.level.getDifficulty().a() * 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); + if (event.isCancelled()) { @@ -12,11 +12,11 @@ + } + + if (event.getProjectile() == entityarrow.getBukkitEntity()) { -+ world.addEntity(entityarrow); ++ level.addEntity(entityarrow); + } + // CraftBukkit end - this.playSound(SoundEffects.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); -- this.world.addEntity(entityarrow); + 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 } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonWither.patch b/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonWither.patch index 229ac1266..acba95dea 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonWither.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonWither.patch @@ -4,8 +4,8 @@ return false; } else { if (entity instanceof EntityLiving) { -- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 200)); -+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 200), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit +- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 200), this); ++ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 200), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } return true; diff --git a/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch b/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch index 48c398eb2..fcce696b9 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch @@ -14,8 +14,8 @@ + public class EntitySlime extends EntityInsentient implements IMonster { - private static final DataWatcherObject bo = DataWatcher.a(EntitySlime.class, DataWatcherRegistry.b); -@@ -188,7 +196,7 @@ + private static final DataWatcherObject ID_SIZE = DataWatcher.a(EntitySlime.class, DataWatcherRegistry.INT); +@@ -186,7 +194,7 @@ @Override public EntityTypes getEntityType() { @@ -24,13 +24,13 @@ } @Override -@@ -202,6 +210,19 @@ +@@ -200,6 +208,19 @@ int j = i / 2; int k = 2 + this.random.nextInt(3); + // CraftBukkit start + SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), k); -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled() && event.getCount() > 0) { + k = event.getCount(); @@ -44,11 +44,11 @@ for (int l = 0; l < k; ++l) { float f1 = ((float) (l % 2) - 0.5F) * f; float f2 = ((float) (l / 2) - 0.5F) * f; -@@ -216,8 +237,17 @@ +@@ -214,8 +235,17 @@ 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.world.addEntity(entityslime); +- this.level.addEntity(entityslime); + slimes.add(entityslime); // CraftBukkit + } + @@ -57,9 +57,9 @@ + return; + } + for (EntityLiving living : slimes) { -+ this.world.addEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason ++ this.level.addEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason } + // CraftBukkit end } - super.die(); + super.a(entity_removalreason); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntitySpider.patch b/nms-patches/net/minecraft/world/entity/monster/EntitySpider.patch index 81e3f5883..6973a3db8 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntitySpider.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntitySpider.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/monster/EntitySpider.java +++ b/net/minecraft/world/entity/monster/EntitySpider.java -@@ -175,7 +175,7 @@ - MobEffectList mobeffectlist = ((EntitySpider.GroupDataSpider) object).a; +@@ -176,7 +176,7 @@ + MobEffectList mobeffectlist = ((EntitySpider.GroupDataSpider) object).effect; if (mobeffectlist != null) { - this.addEffect(new MobEffect(mobeffectlist, Integer.MAX_VALUE)); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch b/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch index 664ad7b99..24a022828 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/monster/EntityStrider.java +++ b/net/minecraft/world/entity/monster/EntityStrider.java -@@ -318,7 +318,12 @@ - IBlockData iblockdata1 = this.aN(); +@@ -321,7 +321,12 @@ + 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; - this.setShivering(!flag); @@ -12,5 +12,5 @@ + } + // CraftBukkit end super.tick(); - this.eU(); + this.fD(); this.checkBlockCollisions(); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch b/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch index 7cc8927b6..3a46202cd 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityVex.java +++ b/net/minecraft/world/entity/monster/EntityVex.java -@@ -81,7 +81,7 @@ +@@ -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)); @@ -9,12 +9,12 @@ this.targetSelector.a(2, new EntityVex.b(this)); this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); } -@@ -222,7 +222,7 @@ +@@ -355,7 +355,7 @@ @Override public void c() { -- EntityVex.this.setGoalTarget(EntityVex.this.c.getGoalTarget()); -+ EntityVex.this.setGoalTarget(EntityVex.this.c.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit +- 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(); } } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch b/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch index 3cb65e5cf..b83c24f9e 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch @@ -15,28 +15,28 @@ + public class EntityZombie extends EntityMonster { - private static final UUID b = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); -@@ -84,6 +93,7 @@ - private boolean bs; - private int bt; - public int drownedConversionTime; + private static final UUID SPEED_MODIFIER_BABY_UUID = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); +@@ -89,6 +98,7 @@ + private boolean canBreakDoors; + private int inWaterTime; + public int conversionTime; + private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field public EntityZombie(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -200,7 +210,10 @@ +@@ -205,7 +215,10 @@ public void tick() { - if (!this.world.isClientSide && this.isAlive() && !this.isNoAI()) { + if (!this.level.isClientSide && this.isAlive() && !this.isNoAI()) { if (this.isDrownConverting()) { -- --this.drownedConversionTime; +- --this.conversionTime; + // CraftBukkit start - Use wall time instead of ticks for conversion + int elapsedTicks = MinecraftServer.currentTick - this.lastTick; -+ this.drownedConversionTime -= elapsedTicks; ++ this.conversionTime -= elapsedTicks; + // CraftBukkit end - if (this.drownedConversionTime < 0) { - this.eP(); + if (this.conversionTime < 0) { + this.fy(); } -@@ -217,6 +230,7 @@ +@@ -222,6 +235,7 @@ } super.tick(); @@ -44,15 +44,15 @@ } @Override -@@ -249,6 +263,7 @@ +@@ -254,6 +268,7 @@ } public void startDrownedConversion(int i) { + this.lastTick = MinecraftServer.currentTick; // CraftBukkit - this.drownedConversionTime = i; - this.getDataWatcher().set(EntityZombie.DROWN_CONVERTING, true); + this.conversionTime = i; + this.getDataWatcher().set(EntityZombie.DATA_DROWNED_CONVERSION_ID, true); } -@@ -262,11 +277,15 @@ +@@ -267,11 +282,15 @@ } protected void b(EntityTypes entitytypes) { @@ -60,8 +60,8 @@ + EntityZombie entityzombie = (EntityZombie) this.a(entitytypes, true, EntityTransformEvent.TransformReason.DROWNED, CreatureSpawnEvent.SpawnReason.DROWNED); if (entityzombie != null) { - entityzombie.y(entityzombie.world.getDamageScaler(entityzombie.getChunkCoordinates()).d()); - entityzombie.u(entityzombie.eK() && this.eU()); + entityzombie.z(entityzombie.level.getDamageScaler(entityzombie.getChunkCoordinates()).d()); + entityzombie.w(entityzombie.p() && this.fD()); + // CraftBukkit start - SPIGOT-5208: End conversion to stop event spam + } else { + ((Zombie) getBukkitEntity()).setConversionTime(-1); @@ -69,26 +69,26 @@ } } -@@ -306,9 +325,9 @@ - if (SpawnerCreature.a(entitypositiontypes_surface, (IWorldReader) this.world, blockposition, entitytypes) && EntityPositionTypes.a(entitytypes, worldserver, EnumMobSpawn.REINFORCEMENT, blockposition, this.world.random)) { +@@ -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.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.j((Entity) entityzombie) && this.world.getCubes(entityzombie) && !this.world.containsLiquid(entityzombie.getBoundingBox())) { + 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.world.getDamageScaler(entityzombie.getChunkCoordinates()), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (NBTTagCompound) null); + 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).addModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); - entityzombie.getAttributeInstance(GenericAttributes.SPAWN_REINFORCEMENTS).addModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); + 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)); break; -@@ -329,7 +348,14 @@ - float f = this.world.getDamageScaler(this.getChunkCoordinates()).b(); +@@ -334,7 +353,14 @@ + float f = this.level.getDamageScaler(this.getChunkCoordinates()).b(); if (this.getItemInMainHand().isEmpty() && this.isBurning() && this.random.nextFloat() < f * 0.3F) { - entity.setOnFire(2 * (int) f); + // CraftBukkit start + EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 2 * (int) f); // PAIL: fixme -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + entity.setOnFire(event.getDuration(), false); @@ -97,7 +97,7 @@ } } -@@ -410,7 +436,12 @@ +@@ -415,7 +441,12 @@ } EntityVillager entityvillager = (EntityVillager) entityliving; @@ -111,7 +111,7 @@ entityzombievillager.prepare(worldserver, worldserver.getDamageScaler(entityzombievillager.getChunkCoordinates()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true), (NBTTagCompound) null); entityzombievillager.setVillagerData(entityvillager.getVillagerData()); -@@ -467,7 +498,7 @@ +@@ -472,7 +503,7 @@ entitychicken1.prepare(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null); entitychicken1.setChickenJockey(true); this.startRiding(entitychicken1); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityZombieHusk.patch b/nms-patches/net/minecraft/world/entity/monster/EntityZombieHusk.patch index 681e99a4e..773810d5c 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityZombieHusk.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityZombieHusk.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/world/entity/monster/EntityZombieHusk.java @@ -58,7 +58,7 @@ if (flag && this.getItemInMainHand().isEmpty() && entity instanceof EntityLiving) { - float f = this.world.getDamageScaler(this.getChunkCoordinates()).b(); + float f = this.level.getDamageScaler(this.getChunkCoordinates()).b(); -- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.HUNGER, 140 * (int) f)); -+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.HUNGER, 140 * (int) f), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit +- ((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 } return flag; diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch b/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch index d4f8e0744..388773aa5 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/monster/EntityZombieVillager.java +++ b/net/minecraft/world/entity/monster/EntityZombieVillager.java -@@ -47,6 +47,13 @@ - import net.minecraft.world.level.block.Blocks; +@@ -49,6 +49,13 @@ + import net.minecraft.world.level.gameevent.GameEvent; import org.apache.logging.log4j.Logger; +// CraftBukkit start @@ -13,36 +13,36 @@ + public class EntityZombieVillager extends EntityZombie implements VillagerDataHolder { - public static final DataWatcherObject CONVERTING = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.i); -@@ -56,6 +63,7 @@ - private NBTBase bp; - private NBTTagCompound bq; - private int br; + public static final DataWatcherObject DATA_CONVERTING_ID = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.BOOLEAN); +@@ -62,6 +69,7 @@ + private NBTBase gossips; + private NBTTagCompound tradeOffers; + private int villagerXp; + private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field public EntityZombieVillager(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -72,7 +80,7 @@ +@@ -78,7 +86,7 @@ @Override public void saveData(NBTTagCompound nbttagcompound) { super.saveData(nbttagcompound); -- DataResult dataresult = VillagerData.a.encodeStart(DynamicOpsNBT.a, this.getVillagerData()); -+ DataResult dataresult = VillagerData.a.encodeStart(DynamicOpsNBT.a, this.getVillagerData()); // CraftBukkit - decompile error +- DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); ++ DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); // CraftBukkit - decompile error Logger logger = EntityZombieVillager.LOGGER; - logger.getClass(); -@@ -128,6 +136,10 @@ + Objects.requireNonNull(logger); +@@ -134,6 +142,10 @@ public void tick() { - if (!this.world.isClientSide && this.isAlive() && this.isConverting()) { + if (!this.level.isClientSide && this.isAlive() && this.isConverting()) { int i = this.getConversionProgress(); + // CraftBukkit start - Use wall time instead of ticks for villager conversion + int elapsedTicks = MinecraftServer.currentTick - this.lastTick; + i *= elapsedTicks; + // CraftBukkit end - this.conversionTime -= i; - if (this.conversionTime <= 0) { -@@ -136,6 +148,7 @@ + this.villagerConversionTime -= i; + if (this.villagerConversionTime <= 0) { +@@ -142,6 +154,7 @@ } super.tick(); @@ -50,18 +50,21 @@ } @Override -@@ -179,13 +192,22 @@ - this.conversionPlayer = uuid; - this.conversionTime = i; - this.getDataWatcher().set(EntityZombieVillager.CONVERTING, true); +@@ -186,8 +199,11 @@ + this.conversionStarter = uuid; + this.villagerConversionTime = i; + this.getDataWatcher().set(EntityZombieVillager.DATA_CONVERTING_ID, true); - this.removeEffect(MobEffects.WEAKNESS); -- this.addEffect(new MobEffect(MobEffects.INCREASE_DAMAGE, i, Math.min(this.world.getDifficulty().a() - 1, 0))); +- this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level.getDifficulty().a() - 1, 0))); + // CraftBukkit start -+ this.persistent = true; // CraftBukkit - SPIGOT-4684 update persistence ++ this.persistenceRequired = true; // CraftBukkit - SPIGOT-4684 update persistence + this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); -+ this.addEffect(new MobEffect(MobEffects.INCREASE_DAMAGE, i, Math.min(this.world.getDifficulty().a() - 1, 0)), 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); + // CraftBukkit end - this.world.broadcastEntityEffect(this, (byte) 16); + this.level.broadcastEntityEffect(this, (byte) 16); + } + +@@ -204,7 +220,13 @@ } private void c(WorldServer worldserver) { @@ -76,17 +79,17 @@ EnumItemSlot[] aenumitemslot = EnumItemSlot.values(); int i = aenumitemslot.length; -@@ -200,7 +222,9 @@ +@@ -219,7 +241,9 @@ double d0 = (double) this.e(enumitemslot); if (d0 > 1.0D) { + this.forceDrops = true; // CraftBukkit - this.a(itemstack); + this.b(itemstack); + this.forceDrops = false; // CraftBukkit } } } -@@ -226,7 +250,7 @@ +@@ -245,7 +269,7 @@ } } diff --git a/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch b/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch index dada9f9a5..ad4d4e9df 100644 --- a/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch +++ b/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 -@@ -53,6 +53,18 @@ +@@ -56,6 +56,18 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; @@ -16,18 +16,13 @@ +import net.minecraft.world.item.Item; +// CraftBukkit end + - public class EntityPiglin extends EntityPiglinAbstract implements ICrossbow { + public class EntityPiglin extends EntityPiglinAbstract implements ICrossbow, InventoryCarrier { - private static final DataWatcherObject bp = DataWatcher.a(EntityPiglin.class, DataWatcherRegistry.i); -@@ -60,10 +72,14 @@ - private static final DataWatcherObject br = DataWatcher.a(EntityPiglin.class, DataWatcherRegistry.i); - private static final UUID bs = UUID.fromString("766bfa64-11f3-11ea-8d71-362b9e155667"); - private static final AttributeModifier bt = new AttributeModifier(EntityPiglin.bs, "Baby speed boost", 0.20000000298023224D, AttributeModifier.Operation.MULTIPLY_BASE); -- private final InventorySubcontainer bu = new InventorySubcontainer(8); -+ public final InventorySubcontainer bu = new InventorySubcontainer(8); // PAIL private -> public - public boolean cannotHunt = false; - protected static final ImmutableList>> d = ImmutableList.of(SensorType.c, SensorType.d, SensorType.b, SensorType.f, SensorType.k); - protected static final ImmutableList> bo = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.DOORS_TO_CLOSE, MemoryModuleType.MOBS, MemoryModuleType.VISIBLE_MOBS, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_TARGETABLE_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_NEMSIS, 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}); + private static final DataWatcherObject DATA_BABY_ID = DataWatcher.a(EntityPiglin.class, DataWatcherRegistry.BOOLEAN); +@@ -76,6 +88,10 @@ + public boolean cannotHunt; + protected static final ImmutableList>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.NEAREST_ITEMS, SensorType.HURT_BY, SensorType.PIGLIN_SPECIFIC_SENSOR); + protected static final ImmutableList> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.DOORS_TO_CLOSE, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLINS, MemoryModuleType.NEARBY_ADULT_PIGLINS, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryModuleType.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}); + // CraftBukkit start - Custom bartering and interest list + public Set allowedBarterItems = new HashSet<>(); + public Set interestItems = new HashSet<>(); @@ -35,10 +30,10 @@ public EntityPiglin(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -82,6 +98,14 @@ +@@ -94,6 +110,14 @@ } - nbttagcompound.set("Inventory", this.bu.g()); + nbttagcompound.set("Inventory", this.inventory.g()); + // CraftBukkit start + NBTTagList barterList = new NBTTagList(); + allowedBarterItems.stream().map(IRegistry.ITEM::getKey).map(MinecraftKey::toString).map(NBTTagString::a).forEach(barterList::add); @@ -50,18 +45,18 @@ } @Override -@@ -90,6 +114,10 @@ +@@ -102,6 +126,10 @@ this.setBaby(nbttagcompound.getBoolean("IsBaby")); - this.v(nbttagcompound.getBoolean("CannotHunt")); - this.bu.a(nbttagcompound.getList("Inventory", 10)); + this.x(nbttagcompound.getBoolean("CannotHunt")); + this.inventory.a(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)); + // CraftBukkit end } - @Override -@@ -188,7 +216,7 @@ + @VisibleForDebug +@@ -206,7 +234,7 @@ @Override public BehaviorController getBehaviorController() { @@ -70,41 +65,41 @@ } @Override -@@ -247,7 +275,7 @@ +@@ -265,7 +293,7 @@ @Override protected void mobTick() { - this.world.getMethodProfiler().enter("piglinBrain"); -- this.getBehaviorController().a((WorldServer) this.world, (EntityLiving) this); -+ this.getBehaviorController().a((WorldServer) this.world, (EntityPiglin) this); // CraftBukkit - decompile error - this.world.getMethodProfiler().exit(); + 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(); -@@ -330,7 +358,7 @@ +@@ -349,7 +377,7 @@ } - protected void n(ItemStack itemstack) { -- if (itemstack.getItem() == PiglinAI.a) { -+ if (itemstack.getItem() == PiglinAI.a || allowedBarterItems.contains(itemstack.getItem())) { // CraftBukkit - Changes to accept custom payment items + 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); } else { -@@ -356,8 +384,8 @@ +@@ -375,8 +403,8 @@ if (EnchantmentManager.d(itemstack1)) { return false; } else { -- boolean flag = PiglinAI.a(itemstack.getItem()) || itemstack.getItem() == Items.CROSSBOW; -- boolean flag1 = PiglinAI.a(itemstack1.getItem()) || itemstack1.getItem() == Items.CROSSBOW; -+ boolean flag = PiglinAI.isLovedByPiglin(itemstack.getItem(), this) || itemstack.getItem() == Items.CROSSBOW; // CraftBukkit -+ boolean flag1 = PiglinAI.isLovedByPiglin(itemstack1.getItem(), this) || itemstack1.getItem() == Items.CROSSBOW; // CraftBukkit +- 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 - return flag && !flag1 ? true : (!flag && flag1 ? false : (this.eM() && itemstack.getItem() != Items.CROSSBOW && itemstack1.getItem() == Items.CROSSBOW ? false : super.a(itemstack, itemstack1))); + return flag && !flag1 ? true : (!flag && flag1 ? false : (this.fv() && !itemstack.a(Items.CROSSBOW) && itemstack1.a(Items.CROSSBOW) ? false : super.a(itemstack, itemstack1))); } -@@ -386,7 +414,7 @@ +@@ -405,7 +433,7 @@ @Override protected SoundEffect getSoundAmbient() { -- return this.world.isClientSide ? null : (SoundEffect) PiglinAI.d(this).orElse((Object) null); -+ return this.world.isClientSide ? null : (SoundEffect) PiglinAI.d(this).orElse(null); // CraftBukkit - Decompile error +- 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 } @Override diff --git a/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.patch b/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.patch index 0646697ce..44d7ebae5 100644 --- a/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.patch +++ b/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.java +++ b/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.java -@@ -99,7 +99,7 @@ +@@ -100,7 +100,7 @@ } protected void c(WorldServer worldserver) { @@ -9,12 +9,12 @@ if (entitypigzombie != null) { entitypigzombie.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0)); -@@ -114,7 +114,7 @@ +@@ -117,7 +117,7 @@ @Nullable @Override public EntityLiving getGoalTarget() { -- return (EntityLiving) this.bg.getMemory(MemoryModuleType.ATTACK_TARGET).orElse((Object) null); -+ return (EntityLiving) this.bg.getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null); // CraftBukkit - decompile error +- 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 eO() { + protected boolean fx() { diff --git a/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch b/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch index c48a2789a..9644c9c3d 100644 --- a/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch +++ b/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/PiglinAI.java +++ b/net/minecraft/world/entity/monster/piglin/PiglinAI.java -@@ -72,6 +72,13 @@ +@@ -73,6 +73,13 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParameters; import net.minecraft.world.phys.Vec3D; @@ -13,10 +13,10 @@ + public class PiglinAI { - public static final Item a = Items.GOLD_INGOT; -@@ -114,7 +121,8 @@ + public static final int REPELLENT_DETECTION_RANGE_HORIZONTAL = 8; +@@ -145,7 +152,8 @@ private static void b(EntityPiglin entitypiglin, BehaviorController behaviorcontroller) { - behaviorcontroller.a(Activity.FLIGHT, 10, ImmutableList.of(new BehaviorAttackTargetForget<>((entityliving) -> { + 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 @@ -24,7 +24,7 @@ } private static void c(BehaviorController behaviorcontroller) { -@@ -132,7 +140,8 @@ +@@ -163,7 +171,8 @@ } private static void f(BehaviorController behaviorcontroller) { @@ -34,36 +34,40 @@ } private static BehaviorGateSingle a() { -@@ -140,7 +149,8 @@ +@@ -171,7 +180,8 @@ } private static BehaviorGateSingle 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::g, new BehaviorLookWalk(0.6F, 3)), 2), Pair.of(new BehaviorNop(30, 60), 1))); +- 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) PiglinAI::g, new BehaviorLookWalk(0.6F, 3)), 2), Pair.of(new BehaviorNop(30, 60), 1))); ++ 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) PiglinAI::f, new BehaviorLookWalk(0.6F, 3)), 2), Pair.of(new BehaviorNop(30, 60), 1))); } private static BehaviorWalkAway c() { -@@ -157,10 +167,10 @@ +@@ -188,13 +198,13 @@ protected static void b(EntityPiglin entitypiglin) { BehaviorController 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.FLIGHT, Activity.AVOID, Activity.CELEBRATE, Activity.RIDE, Activity.IDLE)); + 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 if (activity != activity1) { - d(entitypiglin).ifPresent(entitypiglin::a); -@@ -192,25 +202,29 @@ +- Optional optional = d(entitypiglin); ++ Optional optional = d(entitypiglin); // CraftBukkit - decompile error + + Objects.requireNonNull(entitypiglin); + optional.ifPresent(entitypiglin::a); +@@ -226,23 +236,27 @@ n(entitypiglin); ItemStack itemstack; -- if (entityitem.getItemStack().getItem() == Items.GOLD_NUGGET) { +- if (entityitem.getItemStack().a(Items.GOLD_NUGGET)) { + // CraftBukkit start -+ if (entityitem.getItemStack().getItem() == Items.GOLD_NUGGET && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(entitypiglin, entityitem, 0, false).isCancelled()) { ++ 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(); @@ -76,27 +80,25 @@ } + // CraftBukkit end - Item item = itemstack.getItem(); - -- if (a(item)) { -+ if (isLovedByPiglin(item, entitypiglin)) { // CraftBukkit - Changes to allow for custom payment in bartering +- 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(item) && !u(entitypiglin)) { + } else if (c(itemstack) && !u(entitypiglin)) { s(entitypiglin); } else { -- boolean flag = entitypiglin.g(itemstack); -+ boolean flag = entitypiglin.g(itemstack, entityitem); // CraftBukkit +- boolean flag = entitypiglin.j(itemstack); ++ boolean flag = entitypiglin.j(itemstack, entityitem); // CraftBukkit if (!flag) { d(entitypiglin, itemstack); -@@ -246,9 +260,14 @@ +@@ -278,9 +292,14 @@ boolean flag1; - if (entitypiglin.eM()) { -- flag1 = b(itemstack.getItem()); -+ flag1 = isBarterItem(itemstack.getItem(), entitypiglin); // CraftBukkit - Changes to allow custom payment for bartering + if (entitypiglin.fv()) { +- flag1 = b(itemstack); ++ flag1 = isBarterItem(itemstack, entitypiglin); // CraftBukkit - Changes to allow custom payment for bartering if (flag && flag1) { - a(entitypiglin, i(entitypiglin)); + // CraftBukkit start @@ -106,60 +108,58 @@ + } + // CraftBukkit end } else if (!flag1) { - boolean flag2 = entitypiglin.g(itemstack); + boolean flag2 = entitypiglin.j(itemstack); -@@ -261,7 +280,7 @@ +@@ -293,7 +312,7 @@ if (!flag1) { ItemStack itemstack1 = entitypiglin.getItemInMainHand(); -- if (a(itemstack1.getItem())) { -+ if (isLovedByPiglin(itemstack1.getItem(), entitypiglin)) { // CraftBukkit - Changes to allow for custom payment in bartering +- if (a(itemstack1)) { ++ if (isLovedByPiglin(itemstack1, entitypiglin)) { // CraftBukkit - Changes to allow for custom payment in bartering d(entitypiglin, itemstack1); } else { a(entitypiglin, Collections.singletonList(itemstack1)); -@@ -338,15 +357,21 @@ +@@ -370,7 +389,7 @@ return false; } else if (x(entitypiglin) && entitypiglin.getBehaviorController().hasMemory(MemoryModuleType.ATTACK_TARGET)) { return false; -- } else if (b(item)) { -+ } else if (isBarterItem(item, entitypiglin)) { // CraftBukkit +- } else if (b(itemstack)) { ++ } else if (isBarterItem(itemstack, entitypiglin)) { // CraftBukkit return z(entitypiglin); } else { - boolean flag = entitypiglin.l(itemstack); - -- return item == Items.GOLD_NUGGET ? flag : (c(item) ? !u(entitypiglin) && flag : (!a(item) ? entitypiglin.o(itemstack) : z(entitypiglin) && flag)); -+ return item == Items.GOLD_NUGGET ? flag : (c(item) ? !u(entitypiglin) && flag : (!isLovedByPiglin(item, entitypiglin) ? entitypiglin.o(itemstack) : z(entitypiglin) && flag)); //CraftBukkit + boolean flag = entitypiglin.n(itemstack); +@@ -379,6 +398,12 @@ } } + // CraftBukkit start - Added method to allow checking for custom payment items -+ protected static boolean isLovedByPiglin(Item item, EntityPiglin piglin) { -+ return a(item) || (piglin.interestItems.contains(item) || piglin.allowedBarterItems.contains(item)); ++ protected static boolean isLovedByPiglin(ItemStack itemstack, EntityPiglin piglin) { ++ return a(itemstack) || (piglin.interestItems.contains(itemstack.getItem()) || piglin.allowedBarterItems.contains(itemstack.getItem())); + } + // CraftBukkit end + - protected static boolean a(Item item) { - return item.a((Tag) TagsItem.PIGLIN_LOVED); + protected static boolean a(ItemStack itemstack) { + return itemstack.a((Tag) TagsItem.PIGLIN_LOVED); } -@@ -412,7 +437,7 @@ +@@ -444,7 +469,7 @@ } public static void a(EntityHuman entityhuman, boolean flag) { -- List list = entityhuman.world.a(EntityPiglin.class, entityhuman.getBoundingBox().g(16.0D)); -+ List list = entityhuman.world.a(EntityPiglin.class, entityhuman.getBoundingBox().g(16.0D)); // CraftBukkit - decompile error +- List list = entityhuman.level.a(EntityPiglin.class, entityhuman.getBoundingBox().g(16.0D)); ++ List 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.c(entitypiglin, entityhuman); -@@ -442,7 +467,7 @@ + return !flag || BehaviorUtil.b((EntityLiving) entitypiglin, entityhuman); +@@ -474,7 +499,7 @@ } protected static boolean b(EntityPiglin entitypiglin, ItemStack itemstack) { -- return !x(entitypiglin) && !v(entitypiglin) && entitypiglin.eM() && b(itemstack.getItem()); -+ return !x(entitypiglin) && !v(entitypiglin) && entitypiglin.eM() && isBarterItem(itemstack.getItem(), entitypiglin); // CraftBukkit +- return !x(entitypiglin) && !v(entitypiglin) && entitypiglin.fv() && b(itemstack); ++ return !x(entitypiglin) && !v(entitypiglin) && entitypiglin.fv() && isBarterItem(itemstack, entitypiglin); // CraftBukkit } protected static void a(EntityPiglin entitypiglin, EntityLiving entityliving) { -@@ -648,7 +673,7 @@ +@@ -680,7 +705,7 @@ EntityLiving entityliving = (EntityLiving) behaviorcontroller.getMemory(MemoryModuleType.AVOID_TARGET).get(); EntityTypes entitytypes = entityliving.getEntityType(); @@ -168,34 +168,25 @@ } } -@@ -705,6 +730,12 @@ +@@ -741,6 +766,12 @@ return entitypiglin.getBehaviorController().hasMemory(MemoryModuleType.ADMIRING_ITEM); } + // CraftBukkit start - Changes to allow custom payment for bartering -+ private static boolean isBarterItem(Item item, EntityPiglin piglin) { -+ return b(item) || piglin.allowedBarterItems.contains(item); ++ private static boolean isBarterItem(ItemStack itemstack, EntityPiglin piglin) { ++ return b(itemstack) || piglin.allowedBarterItems.contains(itemstack.getItem()); + } + // CraftBukkit end + - private static boolean b(Item item) { - return item == PiglinAI.a; + private static boolean b(ItemStack itemstack) { + return itemstack.a(PiglinAI.BARTERING_ITEM); } -@@ -730,7 +761,7 @@ - } - - public static boolean b(EntityLiving entityliving) { -- return entityliving.getEntityType() == EntityTypes.PLAYER && entityliving.a(PiglinAI::a); -+ return entityliving.getEntityType() == EntityTypes.PLAYER && entityliving.a((java.util.function.Predicate) PiglinAI::a); // CraftBukkit - decompile error - } - - private static boolean x(EntityPiglin entitypiglin) { -@@ -746,7 +777,7 @@ +@@ -778,7 +809,7 @@ } private static boolean z(EntityPiglin entitypiglin) { -- return entitypiglin.getItemInOffHand().isEmpty() || !a(entitypiglin.getItemInOffHand().getItem()); -+ return entitypiglin.getItemInOffHand().isEmpty() || !isLovedByPiglin(entitypiglin.getItemInOffHand().getItem(), entitypiglin); // CraftBukkit - Changes to allow custom payment for bartering +- return entitypiglin.getItemInOffHand().isEmpty() || !a(entitypiglin.getItemInOffHand()); ++ return entitypiglin.getItemInOffHand().isEmpty() || !isLovedByPiglin(entitypiglin.getItemInOffHand(), entitypiglin); // CraftBukkit - Changes to allow custom payment for bartering } - public static boolean a(EntityTypes entitytypes) { + public static boolean a(EntityTypes entitytypes) { diff --git a/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch b/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch index 700a6ab90..0e4f1790e 100644 --- a/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch +++ b/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/EntityVillager.java +++ b/net/minecraft/world/entity/npc/EntityVillager.java -@@ -89,6 +89,14 @@ +@@ -93,6 +93,14 @@ import net.minecraft.world.phys.AxisAlignedBB; import org.apache.logging.log4j.Logger; @@ -14,8 +14,8 @@ + public class EntityVillager extends EntityVillagerAbstract implements ReputationHandler, VillagerDataHolder { - private static final DataWatcherObject br = DataWatcher.a(EntityVillager.class, DataWatcherRegistry.q); -@@ -134,7 +142,7 @@ + private static final DataWatcherObject DATA_VILLAGER_DATA = DataWatcher.a(EntityVillager.class, DataWatcherRegistry.VILLAGER_DATA); +@@ -150,7 +158,7 @@ @Override public BehaviorController getBehaviorController() { @@ -24,26 +24,26 @@ } @Override -@@ -153,7 +161,7 @@ +@@ -169,7 +177,7 @@ public void c(WorldServer worldserver) { BehaviorController behaviorcontroller = this.getBehaviorController(); - behaviorcontroller.b(worldserver, (EntityLiving) this); + behaviorcontroller.b(worldserver, this); // CraftBukkit - decompile error - this.bg = behaviorcontroller.h(); + this.brain = behaviorcontroller.h(); this.a(this.getBehaviorController()); } -@@ -203,7 +211,7 @@ +@@ -219,7 +227,7 @@ @Override protected void mobTick() { - this.world.getMethodProfiler().enter("villagerBrain"); -- this.getBehaviorController().a((WorldServer) this.world, (EntityLiving) this); -+ this.getBehaviorController().a((WorldServer) this.world, this); // CraftBukkit - decompile error - this.world.getMethodProfiler().exit(); - if (this.bF) { - this.bF = false; -@@ -217,7 +225,7 @@ - this.bu = false; + 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 @@ + this.increaseProfessionLevelOnUpdate = false; } - this.addEffect(new MobEffect(MobEffects.REGENERATION, 200, 0)); @@ -51,7 +51,7 @@ } } -@@ -428,7 +436,14 @@ +@@ -444,7 +452,14 @@ while (iterator.hasNext()) { MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next(); @@ -67,16 +67,16 @@ } } -@@ -457,7 +472,7 @@ +@@ -473,7 +488,7 @@ @Override public void saveData(NBTTagCompound nbttagcompound) { super.saveData(nbttagcompound); -- DataResult dataresult = VillagerData.a.encodeStart(DynamicOpsNBT.a, this.getVillagerData()); -+ DataResult dataresult = VillagerData.a.encodeStart(DynamicOpsNBT.a, this.getVillagerData()); // CraftBukkit - decompile error +- DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); ++ DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); // CraftBukkit - decompile error Logger logger = EntityVillager.LOGGER; - logger.getClass(); -@@ -770,7 +785,12 @@ + Objects.requireNonNull(logger); +@@ -813,7 +828,12 @@ } entitywitch.setPersistent(); @@ -87,10 +87,10 @@ + } + worldserver.addAllEntities(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); + // CraftBukkit end - this.fq(); + this.fZ(); this.die(); } else { -@@ -791,6 +811,13 @@ +@@ -834,6 +854,13 @@ return; } @@ -104,7 +104,7 @@ this.a(entityitem); this.receive(entityitem, itemstack.getCount()); ItemStack itemstack1 = inventorysubcontainer.a(itemstack); -@@ -903,7 +930,7 @@ +@@ -946,7 +973,7 @@ if (entityirongolem != null) { if (entityirongolem.a((GeneratorAccess) worldserver, EnumMobSpawn.MOB_SUMMONED) && entityirongolem.a((IWorldReader) worldserver)) { @@ -113,21 +113,21 @@ return entityirongolem; } -@@ -981,7 +1008,7 @@ +@@ -1024,7 +1051,7 @@ @Override public void entitySleep(BlockPosition blockposition) { super.entitySleep(blockposition); -- this.bg.setMemory(MemoryModuleType.LAST_SLEPT, (Object) this.world.getTime()); -+ this.bg.setMemory(MemoryModuleType.LAST_SLEPT, this.world.getTime()); // CraftBukkit - decompile error - this.bg.removeMemory(MemoryModuleType.WALK_TARGET); - this.bg.removeMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); +- 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); } -@@ -989,7 +1016,7 @@ +@@ -1032,7 +1059,7 @@ @Override public void entityWakeup() { super.entityWakeup(); -- this.bg.setMemory(MemoryModuleType.LAST_WOKEN, (Object) this.world.getTime()); -+ this.bg.setMemory(MemoryModuleType.LAST_WOKEN, this.world.getTime()); // CraftBukkit - decompile error +- this.brain.setMemory(MemoryModuleType.LAST_WOKEN, (Object) this.level.getTime()); ++ this.brain.setMemory(MemoryModuleType.LAST_WOKEN, this.level.getTime()); // CraftBukkit - decompile error } private boolean b(long i) { diff --git a/nms-patches/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch b/nms-patches/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch index bc89499db..d877b1633 100644 --- a/nms-patches/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch +++ b/nms-patches/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/npc/EntityVillagerAbstract.java +++ b/net/minecraft/world/entity/npc/EntityVillagerAbstract.java -@@ -32,14 +32,30 @@ - import net.minecraft.world.level.WorldAccess; +@@ -36,8 +36,24 @@ import net.minecraft.world.level.pathfinder.PathType; + import net.minecraft.world.phys.Vec3D; +// CraftBukkit start +import org.bukkit.Bukkit; @@ -12,7 +12,7 @@ +import org.bukkit.event.entity.VillagerAcquireTradeEvent; +// CraftBukkit end + - public abstract class EntityVillagerAbstract extends EntityAgeable implements NPC, IMerchant { + public abstract class EntityVillagerAbstract extends EntityAgeable implements InventoryCarrier, NPC, IMerchant { + // CraftBukkit start + private CraftMerchant craftMerchant; @@ -22,17 +22,19 @@ + return (craftMerchant == null) ? craftMerchant = new CraftMerchant(this) : craftMerchant; + } + // CraftBukkit end - private static final DataWatcherObject bp = DataWatcher.a(EntityVillagerAbstract.class, DataWatcherRegistry.b); - @Nullable + private static final DataWatcherObject DATA_UNHAPPY_COUNTER = DataWatcher.a(EntityVillagerAbstract.class, DataWatcherRegistry.INT); + public static final int VILLAGER_SLOT_OFFSET = 300; + private static final int VILLAGER_INVENTORY_SIZE = 8; +@@ -45,7 +61,7 @@ private EntityHuman tradingPlayer; @Nullable - protected MerchantRecipeList trades; + protected MerchantRecipeList offers; - private final InventorySubcontainer inventory = new InventorySubcontainer(8); + private final InventorySubcontainer inventory = new InventorySubcontainer(8, (org.bukkit.craftbukkit.entity.CraftAbstractVillager) this.getBukkitEntity()); // CraftBukkit add argument public EntityVillagerAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -240,7 +256,16 @@ +@@ -252,7 +268,16 @@ MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.a(this, this.random); if (merchantrecipe != null) { diff --git a/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch b/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch index 598be12eb..9a00ef818 100644 --- a/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch +++ b/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/EntityVillagerTrader.java +++ b/net/minecraft/world/entity/npc/EntityVillagerTrader.java -@@ -46,6 +46,13 @@ +@@ -45,6 +45,13 @@ import net.minecraft.world.level.World; import net.minecraft.world.phys.Vec3D; @@ -13,16 +13,16 @@ + public class EntityVillagerTrader extends EntityVillagerAbstract { - @Nullable -@@ -55,6 +62,7 @@ + private static final int NUMBER_OF_TRADE_OFFERS = 5; +@@ -54,6 +61,7 @@ + public EntityVillagerTrader(EntityTypes entitytypes, World world) { super(entitytypes, world); - this.attachedToPlayer = true; + this.setDespawnDelay(48000); // CraftBukkit - set default from MobSpawnerTrader } @Override -@@ -132,7 +140,16 @@ +@@ -131,7 +139,16 @@ MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.a(this, this.random); if (merchantrecipe != null) { diff --git a/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch b/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch index 4ee857c16..1f64b55ab 100644 --- a/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch +++ b/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/MobSpawnerTrader.java +++ b/net/minecraft/world/entity/npc/MobSpawnerTrader.java -@@ -104,7 +104,7 @@ +@@ -111,7 +111,7 @@ return false; } @@ -9,16 +9,16 @@ if (entityvillagertrader != null) { for (int i = 0; i < 2; ++i) { -@@ -112,7 +112,7 @@ +@@ -119,7 +119,7 @@ } - this.b.a(entityvillagertrader.getUniqueID()); + this.serverLevelData.a(entityvillagertrader.getUniqueID()); - 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); return true; -@@ -127,7 +127,7 @@ +@@ -134,7 +134,7 @@ BlockPosition blockposition = this.a((IWorldReader) worldserver, entityvillagertrader.getChunkCoordinates(), i); if (blockposition != null) { diff --git a/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch b/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch index 9446fff5a..3c8b1c424 100644 --- a/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch +++ b/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 -@@ -110,10 +110,24 @@ +@@ -113,6 +113,19 @@ import net.minecraft.world.scores.ScoreboardTeam; import net.minecraft.world.scores.ScoreboardTeamBase; @@ -19,29 +19,33 @@ + public abstract class EntityHuman extends EntityLiving { - public static final EntitySize bh = EntitySize.b(0.6F, 1.8F); -- private static final Map b = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.bh).put(EntityPose.SLEEPING, EntityHuman.ah).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 String UUID_PREFIX_OFFLINE_PLAYER = "OfflinePlayer:"; +@@ -126,7 +139,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 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(); + // CraftBukkit - decompile error -+ private static final Map b = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.bh).put(EntityPose.SLEEPING, EntityHuman.ah).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 DataWatcherObject c = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c); - private static final DataWatcherObject d = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.b); - protected static final DataWatcherObject bi = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a); -@@ -122,10 +136,10 @@ - protected static final DataWatcherObject bl = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p); - private long e; - public final PlayerInventory inventory = new PlayerInventory(this); -- protected InventoryEnderChest enderChest = new InventoryEnderChest(); -+ protected InventoryEnderChest enderChest = new InventoryEnderChest(this); // CraftBukkit - add "this" to constructor - public final ContainerPlayer defaultContainer; - public Container activeContainer; ++ private static final Map 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(); + private static final int FLY_ACHIEVEMENT_SPEED = 25; + private static final DataWatcherObject DATA_PLAYER_ABSORPTION_ID = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.FLOAT); + private static final DataWatcherObject DATA_SCORE_ID = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.INT); +@@ -136,10 +150,10 @@ + protected static final DataWatcherObject DATA_SHOULDER_RIGHT = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.COMPOUND_TAG); + private long timeEntitySatOnShoulder; + private final PlayerInventory inventory = new PlayerInventory(this); +- protected InventoryEnderChest enderChestInventory = new InventoryEnderChest(); ++ protected InventoryEnderChest enderChestInventory = new InventoryEnderChest(this); // CraftBukkit - add "this" to constructor + public final ContainerPlayer inventoryMenu; + public Container containerMenu; - protected FoodMetaData foodData = new FoodMetaData(); + protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor - protected int br; - public float bs; - public float bt; -@@ -151,6 +165,16 @@ + protected int jumpTriggerTime; + public float oBob; + public float bob; +@@ -166,6 +180,16 @@ @Nullable - public EntityFishingHook hookedFish; + public EntityFishingHook fishing; + // CraftBukkit start + public boolean fauxSleeping; @@ -55,27 +59,36 @@ + public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile) { super(EntityTypes.PLAYER, world); - this.bL = ItemStack.b; -@@ -288,7 +312,7 @@ + this.lastItemInMainHand = ItemStack.EMPTY; +@@ -304,7 +328,7 @@ ItemStack itemstack = this.getEquipment(EnumItemSlot.HEAD); - if (itemstack.getItem() == Items.TURTLE_HELMET && !this.a((Tag) TagsFluid.WATER)) { + if (itemstack.a(Items.TURTLE_HELMET) && !this.a((Tag) 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 } } -@@ -453,7 +477,8 @@ +@@ -496,7 +520,8 @@ - if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.world.getGameRules().getBoolean(GameRules.NATURAL_REGENERATION)) { - if (this.getHealth() < this.getMaxHealth() && this.ticksLived % 20 == 0) { + if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL && this.level.getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { + if (this.getHealth() < this.getMaxHealth() && this.tickCount % 20 == 0) { - this.heal(1.0F); + // CraftBukkit - added regain reason of "REGEN" for filtering purposes. + this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); } - if (this.foodData.c() && this.ticksLived % 10 == 0) { -@@ -638,6 +663,30 @@ + 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 + } + } + +@@ -688,6 +713,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); } @@ -84,7 +97,7 @@ + Item drop = (Item) entityitem.getBukkitEntity(); + + PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop); -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand(); @@ -106,27 +119,27 @@ return entityitem; } } -@@ -764,16 +813,17 @@ +@@ -814,16 +863,17 @@ if (this.isInvulnerable(damagesource)) { return false; - } else if (this.abilities.isInvulnerable && !damagesource.ignoresInvulnerability()) { + } else if (this.abilities.invulnerable && !damagesource.ignoresInvulnerability()) { + this.forceExplosionKnockback = true; // SPIGOT-5258 - Make invulnerable players get knockback from explosions return false; } else { - this.ticksFarFromPlayer = 0; - if (this.dl()) { + this.noActionTime = 0; + if (this.dV()) { return false; } else { - this.releaseShoulderEntities(); + // this.releaseShoulderEntities(); // CraftBukkit - moved down - if (damagesource.s()) { - if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL) { + if (damagesource.w()) { + if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL) { - f = 0.0F; + return false; // CraftBukkit - f = 0.0f -> return false } - if (this.world.getDifficulty() == EnumDifficulty.EASY) { -@@ -785,7 +835,13 @@ + if (this.level.getDifficulty() == EnumDifficulty.EASY) { +@@ -835,7 +885,13 @@ } } @@ -141,7 +154,7 @@ } } } -@@ -800,10 +856,29 @@ +@@ -855,10 +911,29 @@ } public boolean a(EntityHuman entityhuman) { @@ -158,8 +171,8 @@ + } + } else { + // This should never be called, but is implemented anyway -+ org.bukkit.OfflinePlayer thisPlayer = entityhuman.world.getServer().getOfflinePlayer(entityhuman.getName()); -+ team = entityhuman.world.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer); ++ org.bukkit.OfflinePlayer thisPlayer = entityhuman.level.getServer().getOfflinePlayer(entityhuman.getName()); ++ team = entityhuman.level.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer); + if (team == null || team.allowFriendlyFire()) { + return true; + } @@ -169,12 +182,12 @@ + if (this instanceof EntityPlayer) { + return !team.hasPlayer(((EntityPlayer) this).getBukkitEntity()); + } -+ return !team.hasPlayer(this.world.getServer().getOfflinePlayer(this.getName())); ++ return !team.hasPlayer(this.level.getServer().getOfflinePlayer(this.getName())); + // CraftBukkit end } @Override -@@ -840,8 +915,13 @@ +@@ -900,8 +975,13 @@ } } @@ -189,7 +202,7 @@ if (!this.isInvulnerable(damagesource)) { f = this.applyArmorModifier(damagesource, f); f = this.applyMagicModifier(damagesource, f); -@@ -856,7 +936,7 @@ +@@ -916,7 +996,7 @@ } if (f != 0.0F) { @@ -198,7 +211,7 @@ float f3 = this.getHealth(); this.setHealth(this.getHealth() - f); -@@ -867,6 +947,7 @@ +@@ -927,6 +1007,7 @@ } } @@ -206,7 +219,7 @@ } @Override -@@ -1026,7 +1107,7 @@ +@@ -1086,7 +1167,7 @@ f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; @@ -215,7 +228,7 @@ if (f > 0.0F || f1 > 0.0F) { boolean flag = f2 > 0.9F; boolean flag1 = false; -@@ -1065,8 +1146,15 @@ +@@ -1125,8 +1206,15 @@ if (entity instanceof EntityLiving) { f3 = ((EntityLiving) entity).getHealth(); if (j > 0 && !entity.isBurning()) { @@ -233,30 +246,30 @@ } } -@@ -1094,8 +1182,11 @@ +@@ -1154,8 +1242,11 @@ EntityLiving entityliving = (EntityLiving) iterator.next(); - if (entityliving != this && entityliving != entity && !this.r(entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.h((Entity) entityliving) < 9.0D) { + if (entityliving != this && entityliving != entity && !this.p(entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.f((Entity) entityliving) < 9.0D) { + // CraftBukkit start - Only apply knockback if the damage hits + if (entityliving.damageEntity(DamageSource.playerAttack(this).sweep(), f4)) { - entityliving.a(0.4F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F))); + entityliving.p(0.4000000059604645D, (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F))); - entityliving.damageEntity(DamageSource.playerAttack(this), f4); + } + // CraftBukkit end } } -@@ -1104,9 +1195,26 @@ +@@ -1164,9 +1255,26 @@ } - if (entity instanceof EntityPlayer && entity.velocityChanged) { + if (entity instanceof EntityPlayer && entity.hurtMarked) { + // CraftBukkit start - Add Velocity Event + boolean cancelled = false; + Player player = (Player) entity.getBukkitEntity(); + org.bukkit.util.Vector velocity = CraftVector.toBukkit(vec3d); + + PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone()); -+ world.getServer().getPluginManager().callEvent(event); ++ level.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + cancelled = true; @@ -265,15 +278,15 @@ + } + + if (!cancelled) { - ((EntityPlayer) entity).playerConnection.sendPacket(new PacketPlayOutEntityVelocity(entity)); - entity.velocityChanged = false; + ((EntityPlayer) entity).connection.sendPacket(new PacketPlayOutEntityVelocity(entity)); + entity.hurtMarked = false; entity.setMot(vec3d); + } + // CraftBukkit end } if (flag2) { -@@ -1151,7 +1259,14 @@ +@@ -1211,7 +1319,14 @@ this.a(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F)); if (j > 0) { @@ -288,15 +301,15 @@ + // CraftBukkit end } - if (this.world instanceof WorldServer && f5 > 2.0F) { -@@ -1161,12 +1276,17 @@ + if (this.level instanceof WorldServer && f5 > 2.0F) { +@@ -1221,12 +1336,17 @@ } } - this.applyExhaustion(0.1F); + this.applyExhaustion(0.1F, EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent } else { - this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_PLAYER_ATTACK_NODAMAGE, this.getSoundCategory(), 1.0F, 1.0F); + this.level.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.PLAYER_ATTACK_NODAMAGE, this.getSoundCategory(), 1.0F, 1.0F); if (flag4) { entity.extinguish(); } @@ -308,8 +321,8 @@ } } -@@ -1227,6 +1347,12 @@ - } +@@ -1299,6 +1419,12 @@ + public void a(ItemStack itemstack, ItemStack itemstack1, ClickAction clickaction) {} public Either sleep(BlockPosition blockposition) { + // CraftBukkit start @@ -319,9 +332,9 @@ + public Either sleep(BlockPosition blockposition, boolean force) { + // CraftBukkit end this.entitySleep(blockposition); - this.sleepTicks = 0; + this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1311,9 +1437,9 @@ +@@ -1383,9 +1509,9 @@ super.jump(); this.a(StatisticList.JUMP); if (this.isSprinting()) { @@ -333,9 +346,9 @@ } } -@@ -1347,7 +1473,11 @@ +@@ -1419,7 +1545,11 @@ this.setMot(vec3d2.x, d3 * 0.6D, vec3d2.z); - this.aE = f; + this.flyingSpeed = f; this.fallDistance = 0.0F; - this.setFlag(7, false); + // CraftBukkit start @@ -346,22 +359,22 @@ } else { super.g(vec3d); } -@@ -1382,19 +1512,19 @@ - i = Math.round(MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); +@@ -1454,19 +1584,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 } } else if (this.a((Tag) TagsFluid.WATER)) { - i = Math.round(MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); + 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 } } else if (this.isInWater()) { - i = Math.round(MathHelper.sqrt(d0 * d0 + d2 * d2) * 100.0F); + 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); @@ -369,13 +382,13 @@ } } else if (this.isClimbing()) { if (d1 > 0.0D) { -@@ -1405,13 +1535,13 @@ +@@ -1477,13 +1607,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 - } else if (this.bz()) { + } 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 @@ -386,7 +399,7 @@ } } } else if (this.isGliding()) { -@@ -1477,12 +1607,24 @@ +@@ -1549,12 +1679,24 @@ } public void startGliding() { @@ -412,8 +425,8 @@ } @Override -@@ -1572,10 +1714,21 @@ - return this.expLevel >= 30 ? 112 + (this.expLevel - 30) * 9 : (this.expLevel >= 15 ? 37 + (this.expLevel - 15) * 5 : 7 + this.expLevel * 2); +@@ -1644,10 +1786,21 @@ + return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2); } + // CraftBukkit start @@ -423,8 +436,8 @@ + + public void applyExhaustion(float f, EntityExhaustionEvent.ExhaustionReason reason) { + // CraftBukkit end - if (!this.abilities.isInvulnerable) { - if (!this.world.isClientSide) { + if (!this.abilities.invulnerable) { + if (!this.level.isClientSide) { - this.foodData.a(f); + // CraftBukkit start + EntityExhaustionEvent event = CraftEventFactory.callPlayerExhaustionEvent(this, reason, f); @@ -435,7 +448,7 @@ } } -@@ -1649,14 +1802,21 @@ +@@ -1724,15 +1877,22 @@ @Override public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { @@ -446,24 +459,25 @@ + @Override + public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) { + // CraftBukkit end + this.f(itemstack); if (enumitemslot == EnumItemSlot.MAINHAND) { - this.playEquipSound(itemstack); + this.playEquipSound(itemstack, silent); // CraftBukkit - this.inventory.items.set(this.inventory.itemInHandIndex, itemstack); + this.inventory.items.set(this.inventory.selected, itemstack); } else if (enumitemslot == EnumItemSlot.OFFHAND) { - this.playEquipSound(itemstack); + this.playEquipSound(itemstack, silent); // CraftBukkit - this.inventory.extraSlots.set(0, itemstack); + 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); } -@@ -1697,26 +1857,31 @@ +@@ -1773,26 +1933,31 @@ protected void releaseShoulderEntities() { - if (this.e + 20L < this.world.getTime()) { + if (this.timeEntitySatOnShoulder + 20L < this.level.getTime()) { - this.spawnEntityFromShoulder(this.getShoulderEntityLeft()); - this.setShoulderEntityLeft(new NBTTagCompound()); - this.spawnEntityFromShoulder(this.getShoulderEntityRight()); @@ -482,17 +496,17 @@ - private void spawnEntityFromShoulder(NBTTagCompound nbttagcompound) { + private boolean spawnEntityFromShoulder(NBTTagCompound nbttagcompound) { // CraftBukkit void->boolean - if (!this.world.isClientSide && !nbttagcompound.isEmpty()) { -- EntityTypes.a(nbttagcompound, this.world).ifPresent((entity) -> { -+ return EntityTypes.a(nbttagcompound, this.world).map((entity) -> { // CraftBukkit + if (!this.level.isClientSide && !nbttagcompound.isEmpty()) { +- EntityTypes.a(nbttagcompound, this.level).ifPresent((entity) -> { ++ return EntityTypes.a(nbttagcompound, this.level).map((entity) -> { // CraftBukkit if (entity instanceof EntityTameableAnimal) { - ((EntityTameableAnimal) entity).setOwnerUUID(this.uniqueID); + ((EntityTameableAnimal) entity).setOwnerUUID(this.uuid); } entity.setPosition(this.locX(), this.locY() + 0.699999988079071D, this.locZ()); -- ((WorldServer) this.world).addEntitySerialized(entity); +- ((WorldServer) this.level).addEntitySerialized(entity); - }); -+ return ((WorldServer) this.world).addEntitySerialized(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit ++ return ((WorldServer) this.level).addEntitySerialized(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit + }).orElse(true); // CraftBukkit } diff --git a/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch b/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch index a9424210a..c0c2efa69 100644 --- a/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch +++ b/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/player/PlayerInventory.java +++ b/net/minecraft/world/entity/player/PlayerInventory.java @@ -26,6 +26,13 @@ - import net.minecraft.world.level.World; + import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.IBlockData; +// CraftBukkit start @@ -13,18 +13,18 @@ + public class PlayerInventory implements IInventory, INamableTileEntity { - public final NonNullList items; -@@ -37,6 +44,54 @@ - private ItemStack carried; - private int h; + public static final int POP_TIME_DURATION = 5; +@@ -43,6 +50,54 @@ + public final EntityHuman player; + private int timesChanged; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; + + public List getContents() { -+ List combined = new ArrayList(items.size() + armor.size() + extraSlots.size()); -+ for (List sub : this.f) { ++ List combined = new ArrayList(items.size() + armor.size() + offhand.size()); ++ for (List sub : this.compartments) { + combined.addAll(sub); + } + @@ -67,10 +67,10 @@ + // CraftBukkit end + public PlayerInventory(EntityHuman entityhuman) { - this.items = NonNullList.a(36, ItemStack.b); - this.armor = NonNullList.a(4, ItemStack.b); -@@ -62,6 +117,28 @@ - return itemstack.getItem() == itemstack1.getItem() && ItemStack.equals(itemstack, itemstack1); + this.items = NonNullList.a(36, ItemStack.EMPTY); + this.armor = NonNullList.a(4, ItemStack.EMPTY); +@@ -63,6 +118,28 @@ + return !itemstack.isEmpty() && ItemStack.e(itemstack, itemstack1) && itemstack.isStackable() && itemstack.getCount() < itemstack.getMaxStackSize() && itemstack.getCount() < this.getMaxStackSize(); } + // CraftBukkit start - Watch method above! :D @@ -98,26 +98,3 @@ public int getFirstEmptySlotIndex() { for (int i = 0; i < this.items.size(); ++i) { if (((ItemStack) this.items.get(i)).isEmpty()) { -@@ -501,8 +578,9 @@ - ItemStack itemstack = (ItemStack) this.armor.get(i); - - if ((!damagesource.isFire() || !itemstack.getItem().u()) && itemstack.getItem() instanceof ItemArmor) { -+ int finalI = i; // CraftBukkit - decompile error - itemstack.damage((int) f, this.player, (entityhuman) -> { -- entityhuman.broadcastItemBreak(EnumItemSlot.a(EnumItemSlot.Function.ARMOR, i)); -+ entityhuman.broadcastItemBreak(EnumItemSlot.a(EnumItemSlot.Function.ARMOR, finalI)); // CraftBukkit - decompile error - }); - } - } -@@ -538,6 +616,11 @@ - } - - public ItemStack getCarried() { -+ // CraftBukkit start -+ if (this.carried.isEmpty()) { -+ this.setCarried(ItemStack.b); -+ } -+ // CraftBukkit end - return this.carried; - } - diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch index 432cf51e8..c43cf0ff0 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityArrow.java +++ b/net/minecraft/world/entity/projectile/EntityArrow.java -@@ -45,6 +45,12 @@ +@@ -44,6 +44,12 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.shapes.VoxelShape; @@ -12,17 +12,17 @@ + public abstract class EntityArrow extends IProjectile { - private static final DataWatcherObject f = DataWatcher.a(EntityArrow.class, DataWatcherRegistry.a); -@@ -181,7 +187,7 @@ + private static final double ARROW_BASE_DAMAGE = 2.0D; +@@ -210,7 +216,7 @@ } if (object != null && !flag) { - this.a((MovingObjectPosition) object); + this.preOnHit((MovingObjectPosition) object); // CraftBukkit - projectile hit event - this.impulse = true; + this.hasImpulse = true; } -@@ -328,7 +334,13 @@ +@@ -357,7 +363,13 @@ int k = entity.getFireTicks(); if (this.isBurning() && !flag) { @@ -37,28 +37,27 @@ } if (entity.damageEntity(damagesource, (float) i)) { -@@ -495,9 +507,23 @@ +@@ -519,7 +531,22 @@ @Override public void pickup(EntityHuman entityhuman) { - if (!this.world.isClientSide && (this.inGround || this.t()) && this.shake <= 0) { + if (!this.level.isClientSide && (this.inGround || this.t()) && this.shakeTime <= 0) { +- if (this.a(entityhuman)) { + // CraftBukkit start + ItemStack itemstack = this.getItemStack(); -+ if (this.fromPlayer == PickupStatus.ALLOWED && !itemstack.isEmpty() && entityhuman.inventory.canHold(itemstack) > 0) { -+ EntityItem item = new EntityItem(this.world, this.locX(), this.locY(), this.locZ(), itemstack); -+ PlayerPickupArrowEvent event = new PlayerPickupArrowEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), this, item), (org.bukkit.entity.AbstractArrow) this.getBukkitEntity()); ++ 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); ++ PlayerPickupArrowEvent event = new PlayerPickupArrowEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.level.getServer(), this, item), (org.bukkit.entity.AbstractArrow) this.getBukkitEntity()); + // event.setCancelled(!entityhuman.canPickUpLoot); TODO -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; + } + itemstack = item.getItemStack(); + } - boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild || this.t() && this.getShooter().getUniqueID() == entityhuman.getUniqueID(); - -- if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.getItemStack())) { -+ if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(itemstack)) { ++ ++ if ((this.pickup == EntityArrow.PickupStatus.ALLOWED && entityhuman.getInventory().pickup(itemstack)) || (this.pickup == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.getAbilities().instabuild)) { + // CraftBukkit end - flag = false; + entityhuman.receive(this, 1); + this.die(); } - diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch index 6acfa817f..6c25e6bc6 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityEgg.java +++ b/net/minecraft/world/entity/projectile/EntityEgg.java -@@ -10,6 +10,15 @@ +@@ -12,6 +12,15 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.MovingObjectPositionEntity; @@ -16,10 +16,10 @@ public class EntityEgg extends EntityProjectileThrowable { public EntityEgg(EntityTypes entitytypes, World world) { -@@ -34,20 +43,40 @@ +@@ -48,20 +57,40 @@ protected void a(MovingObjectPosition movingobjectposition) { super.a(movingobjectposition); - if (!this.world.isClientSide) { + if (!this.level.isClientSide) { - if (this.random.nextInt(8) == 0) { + boolean hatching = this.random.nextInt(8) == 0; // CraftBukkit + if (true) { @@ -30,7 +30,7 @@ } - for (int i = 0; i < b0; ++i) { -- EntityChicken entitychicken = (EntityChicken) EntityTypes.CHICKEN.a(this.world); +- EntityChicken entitychicken = (EntityChicken) EntityTypes.CHICKEN.a(this.level); + // CraftBukkit start + if (!hatching) { + b0 = 0; @@ -40,7 +40,7 @@ + Entity shooter = this.getShooter(); + if (shooter instanceof EntityPlayer) { + PlayerEggThrowEvent event = new PlayerEggThrowEvent((Player) shooter.getBukkitEntity(), (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, b0, hatchingType); -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + + b0 = event.getNumHatches(); + hatching = event.isHatching(); @@ -48,18 +48,18 @@ + } - entitychicken.setAgeRaw(-24000); -- entitychicken.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.yaw, 0.0F); -- this.world.addEntity(entitychicken); +- entitychicken.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.getYRot(), 0.0F); +- this.level.addEntity(entitychicken); + if (hatching) { + for (int i = 0; i < b0; ++i) { -+ Entity entity = world.getWorld().createEntity(new org.bukkit.Location(world.getWorld(), this.locX(), this.locY(), this.locZ(), this.yaw, 0.0F), hatchingType.getEntityClass()); ++ Entity entity = level.getWorld().createEntity(new org.bukkit.Location(level.getWorld(), this.locX(), this.locY(), this.locZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass()); + if (entity.getBukkitEntity() instanceof Ageable) { + ((Ageable) entity.getBukkitEntity()).setBaby(); + } -+ world.getWorld().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); ++ level.getWorld().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); + } } + // CraftBukkit end } - this.world.broadcastEntityEffect(this, (byte) 3); + this.level.broadcastEntityEffect(this, (byte) 3); diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch index ff439cf93..8be5e916f 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch @@ -14,12 +14,15 @@ public class EntityEnderPearl extends EntityProjectileThrowable { public EntityEnderPearl(EntityTypes entitytypes, World world) { -@@ -52,21 +59,35 @@ +@@ -53,21 +60,34 @@ EntityPlayer entityplayer = (EntityPlayer) entity; - if (entityplayer.playerConnection.a().isConnected() && entityplayer.world == this.world && !entityplayer.isSleeping()) { -- if (this.random.nextFloat() < 0.05F && this.world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING)) { -- EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.a(this.world); + if (entityplayer.connection.a().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.setPositionRotation(entity.locX(), entity.locY(), entity.locZ(), entity.getYRot(), entity.getXRot()); +- this.level.addEntity(entityendermite); + // CraftBukkit start - Fire PlayerTeleportEvent + org.bukkit.craftbukkit.entity.CraftPlayer player = entityplayer.getBukkitEntity(); + org.bukkit.Location location = getBukkitEntity().getLocation(); @@ -29,44 +32,43 @@ + PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL); + Bukkit.getPluginManager().callEvent(teleEvent); + -+ if (!teleEvent.isCancelled() && !entityplayer.playerConnection.isDisconnected()) { -+ if (this.random.nextFloat() < 0.05F && this.world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING)) { -+ EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.a(this.world); - -- entityendermite.setPlayerSpawned(true); -+ entityendermite.setPlayerSpawned(true); - entityendermite.setPositionRotation(entity.locX(), entity.locY(), entity.locZ(), entity.yaw, entity.pitch); -- this.world.addEntity(entityendermite); -- } -+ this.world.addEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL); ++ 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.setPositionRotation(entity.locX(), entity.locY(), entity.locZ(), entity.getYRot(), entity.getXRot()); ++ this.level.addEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL); + } - -- if (entity.isPassenger()) { -- entity.stopRiding(); ++ + if (entity.isPassenger()) { + entity.stopRiding(); + } + -+ entityplayer.playerConnection.teleport(teleEvent.getTo()); ++ entityplayer.connection.teleport(teleEvent.getTo()); + entity.fallDistance = 0.0F; + CraftEventFactory.entityDamage = this; + entity.damageEntity(DamageSource.FALL, 5.0F); + CraftEventFactory.entityDamage = null; } - -- entity.enderTeleportTo(this.locX(), this.locY(), this.locZ()); +- if (entity.isPassenger()) { +- entityplayer.a(this.locX(), this.locY(), this.locZ()); +- } else { +- entity.enderTeleportTo(this.locX(), this.locY(), this.locZ()); +- } +- - entity.fallDistance = 0.0F; - entity.damageEntity(DamageSource.FALL, 5.0F); + // CraftBukkit end } } else if (entity != null) { entity.enderTeleportTo(this.locX(), this.locY(), this.locZ()); -@@ -95,7 +116,7 @@ +@@ -96,7 +116,7 @@ public Entity b(WorldServer worldserver) { Entity entity = this.getShooter(); -- if (entity != null && entity.world.getDimensionKey() != worldserver.getDimensionKey()) { -+ if (entity != null && worldserver != null && entity.world.getDimensionKey() != worldserver.getDimensionKey()) { // CraftBukkit - SPIGOT-6113 +- 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); } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityEnderSignal.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityEnderSignal.patch index bb20422cc..23f6951e0 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityEnderSignal.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityEnderSignal.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/entity/projectile/EntityEnderSignal.java +++ b/net/minecraft/world/entity/projectile/EntityEnderSignal.java -@@ -39,8 +39,8 @@ +@@ -38,8 +38,8 @@ } public void setItem(ItemStack itemstack) { -- if (itemstack.getItem() != Items.ENDER_EYE || itemstack.hasTag()) { -- this.getDataWatcher().set(EntityEnderSignal.b, SystemUtils.a((Object) itemstack.cloneItemStack(), (itemstack1) -> { -+ if (true || itemstack.getItem() != Items.ENDER_EYE || itemstack.hasTag()) { // CraftBukkit - always allow item changing -+ this.getDataWatcher().set(EntityEnderSignal.b, SystemUtils.a(itemstack.cloneItemStack(), (itemstack1) -> { // CraftBukkit - decompile error +- 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 itemstack1.setCount(1); })); } -@@ -156,7 +156,7 @@ +@@ -182,7 +182,7 @@ public void loadData(NBTTagCompound nbttagcompound) { ItemStack itemstack = ItemStack.a(nbttagcompound.getCompound("Item")); diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch index b3670e319..0cf621ef7 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityEvokerFangs.java +++ b/net/minecraft/world/entity/projectile/EntityEvokerFangs.java -@@ -124,7 +124,9 @@ +@@ -130,7 +130,9 @@ if (entityliving.isAlive() && !entityliving.isInvulnerable() && entityliving != entityliving1) { if (entityliving1 == null) { @@ -8,5 +8,5 @@ entityliving.damageEntity(DamageSource.MAGIC, 6.0F); + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = null; // CraftBukkit } else { - if (entityliving1.r(entityliving)) { + if (entityliving1.p(entityliving)) { return; diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch index a35f97523..d257920a1 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityFireball.java +++ b/net/minecraft/world/entity/projectile/EntityFireball.java -@@ -15,11 +15,15 @@ +@@ -14,11 +14,15 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.Vec3D; @@ -8,28 +8,28 @@ + public abstract class EntityFireball extends IProjectile { - public double dirX; - public double dirY; - public double dirZ; + public double xPower; + public double yPower; + public double zPower; + public float bukkitYield = 1; // CraftBukkit + public boolean isIncendiary = true; // CraftBukkit protected EntityFireball(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -29,6 +33,12 @@ +@@ -28,6 +32,12 @@ this(entitytypes, world); - this.setPositionRotation(d0, d1, d2, this.yaw, this.pitch); - this.af(); + this.setPositionRotation(d0, d1, d2, this.getYRot(), this.getXRot()); + this.ah(); + // CraftBukkit start - Added setDirection method + this.setDirection(d3, d4, d5); + } + + public void setDirection(double d3, double d4, double d5) { + // CraftBukkit end - double d6 = (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5); + double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5); if (d6 != 0.0D) { -@@ -63,7 +73,13 @@ +@@ -74,7 +84,13 @@ MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a); if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { @@ -37,14 +37,14 @@ + this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event + + // CraftBukkit start - Fire ProjectileHitEvent -+ if (this.dead) { ++ if (this.isRemoved()) { + CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); + } + // CraftBukkit end } this.checkBlockCollisions(); -@@ -148,6 +164,11 @@ +@@ -159,6 +175,11 @@ Entity entity = damagesource.getEntity(); if (entity != null) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch index 49fad3371..be69451da 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch @@ -3,13 +3,13 @@ @@ -29,7 +29,7 @@ public void setItem(ItemStack itemstack) { - if (itemstack.getItem() != Items.FIRE_CHARGE || itemstack.hasTag()) { -- this.getDataWatcher().set(EntityFireballFireball.e, SystemUtils.a((Object) itemstack.cloneItemStack(), (itemstack1) -> { -+ this.getDataWatcher().set(EntityFireballFireball.e, SystemUtils.a(itemstack.cloneItemStack(), (itemstack1) -> { // CraftBukkit - decompile error + 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); })); } -@@ -61,6 +61,6 @@ +@@ -68,6 +68,6 @@ super.loadData(nbttagcompound); ItemStack itemstack = ItemStack.a(nbttagcompound.getCompound("Item")); diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch index 4d5a32a5a..96e6ee9d8 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch @@ -6,22 +6,22 @@ +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + - public class EntityFireworks extends IProjectile { + public class EntityFireworks extends IProjectile implements ItemSupplier { - public static final DataWatcherObject FIREWORK_ITEM = DataWatcher.a(EntityFireworks.class, DataWatcherRegistry.g); -@@ -130,7 +132,7 @@ + public static final DataWatcherObject DATA_ID_FIREWORKS_ITEM = DataWatcher.a(EntityFireworks.class, DataWatcherRegistry.ITEM_STACK); +@@ -141,7 +143,7 @@ MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a); - if (!this.noclip) { + if (!this.noPhysics) { - this.a(movingobjectposition); + this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event - this.impulse = true; + this.hasImpulse = true; } -@@ -145,7 +147,11 @@ +@@ -156,7 +158,11 @@ } - if (!this.world.isClientSide && this.ticksFlown > this.expectedLifespan) { + if (!this.level.isClientSide && this.life > this.lifetime) { - this.explode(); + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { @@ -31,10 +31,10 @@ } } -@@ -160,7 +166,11 @@ +@@ -172,7 +178,11 @@ protected void a(MovingObjectPositionEntity movingobjectpositionentity) { super.a(movingobjectpositionentity); - if (!this.world.isClientSide) { + if (!this.level.isClientSide) { - this.explode(); + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { @@ -44,10 +44,10 @@ } } -@@ -170,7 +180,11 @@ +@@ -182,7 +192,11 @@ - this.world.getType(blockposition).a(this.world, blockposition, (Entity) this); - if (!this.world.s_() && this.hasExplosions()) { + this.level.getType(blockposition).a(this.level, blockposition, (Entity) this); + if (!this.level.isClientSide() && this.hasExplosions()) { - this.explode(); + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { @@ -57,19 +57,19 @@ } super.a(movingobjectpositionblock); -@@ -196,7 +210,9 @@ +@@ -208,7 +222,9 @@ if (f > 0.0F) { - if (this.ridingEntity != null) { + if (this.attachedToEntity != null) { + CraftEventFactory.entityDamage = this; // CraftBukkit - this.ridingEntity.damageEntity(DamageSource.a(this, this.getShooter()), 5.0F + (float) (nbttaglist.size() * 2)); + this.attachedToEntity.damageEntity(DamageSource.a(this, this.getShooter()), 5.0F + (float) (nbttaglist.size() * 2)); + CraftEventFactory.entityDamage = null; // CraftBukkit } double d0 = 5.0D; -@@ -223,7 +239,9 @@ +@@ -235,7 +251,9 @@ if (flag) { - float f1 = f * (float) Math.sqrt((5.0D - (double) this.g((Entity) entityliving)) / 5.0D); + float f1 = f * (float) Math.sqrt((5.0D - (double) this.e((Entity) entityliving)) / 5.0D); + CraftEventFactory.entityDamage = this; // CraftBukkit entityliving.damageEntity(DamageSource.a(this, this.getShooter()), f1); diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch index 76ecfffcc..94e5aad4a 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch @@ -12,10 +12,10 @@ + public class EntityFishingHook extends IProjectile { - private final Random b; -@@ -63,6 +69,12 @@ - private final int an; - private final int lureLevel; + private final Random syncronizedRandom; +@@ -65,6 +71,12 @@ + private final int luck; + private final int lureSpeed; + // CraftBukkit start - Extra variables to enable modification of fishing wait time, values are minecraft defaults + public int minWaitTime = 100; @@ -23,11 +23,11 @@ + public boolean applyLure = true; + // CraftBukkit end + - private EntityFishingHook(World world, EntityHuman entityhuman, int i, int j) { - super(EntityTypes.FISHING_BOBBER, world); - this.b = new Random(); -@@ -244,7 +256,7 @@ - private void m() { + private EntityFishingHook(EntityTypes 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); - this.a(movingobjectposition); @@ -35,67 +35,67 @@ } @Override -@@ -291,6 +303,10 @@ - this.waitTime = 0; - this.ai = 0; - this.getDataWatcher().set(EntityFishingHook.f, false); +@@ -306,6 +318,10 @@ + this.timeUntilLured = 0; + this.timeUntilHooked = 0; + this.getDataWatcher().set(EntityFishingHook.DATA_BITING, false); + // CraftBukkit start + PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.getOwner().getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT); -+ this.world.getServer().getPluginManager().callEvent(playerFishEvent); ++ this.level.getServer().getPluginManager().callEvent(playerFishEvent); + // CraftBukkit end } } else { float f; -@@ -324,6 +340,13 @@ +@@ -339,6 +355,13 @@ worldserver.a(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); -+ this.world.getServer().getPluginManager().callEvent(playerFishEvent); ++ this.level.getServer().getPluginManager().callEvent(playerFishEvent); + if (playerFishEvent.isCancelled()) { + return; + } + // CraftBukkit end - this.playSound(SoundEffects.ENTITY_FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); + this.playSound(SoundEffects.FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); double d3 = this.locY() + 0.5D; -@@ -360,8 +383,10 @@ - this.ai = MathHelper.nextInt(this.random, 20, 80); +@@ -375,8 +398,10 @@ + this.timeUntilHooked = MathHelper.nextInt(this.random, 20, 80); } } else { -- this.waitTime = MathHelper.nextInt(this.random, 100, 600); -- this.waitTime -= this.lureLevel * 20 * 5; +- this.timeUntilLured = MathHelper.nextInt(this.random, 100, 600); +- this.timeUntilLured -= this.lureSpeed * 20 * 5; + // CraftBukkit start - logic to modify fishing wait time -+ this.waitTime = MathHelper.nextInt(this.random, this.minWaitTime, this.maxWaitTime); -+ this.waitTime -= (this.applyLure) ? this.lureLevel * 20 * 5 : 0; ++ this.timeUntilLured = MathHelper.nextInt(this.random, this.minWaitTime, this.maxWaitTime); ++ this.timeUntilLured -= (this.applyLure) ? this.lureSpeed * 20 * 5 : 0; + // CraftBukkit end } } -@@ -428,6 +453,14 @@ +@@ -443,6 +468,14 @@ int i = 0; - if (this.hooked != null) { + if (this.hookedIn != null) { + // CraftBukkit start -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), this.hooked.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY); -+ this.world.getServer().getPluginManager().callEvent(playerFishEvent); ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), this.hookedIn.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY); ++ this.level.getServer().getPluginManager().callEvent(playerFishEvent); + + if (playerFishEvent.isCancelled()) { + return 0; + } + // CraftBukkit end - this.reel(); - CriterionTriggers.D.a((EntityPlayer) entityhuman, itemstack, this, (Collection) Collections.emptyList()); - this.world.broadcastEntityEffect(this, (byte) 31); -@@ -443,6 +476,15 @@ + 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 @@ while (iterator.hasNext()) { ItemStack itemstack1 = (ItemStack) iterator.next(); - EntityItem entityitem = new EntityItem(this.world, this.locX(), this.locY(), this.locZ(), itemstack1); + EntityItem entityitem = new EntityItem(this.level, this.locX(), this.locY(), this.locZ(), 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); -+ this.world.getServer().getPluginManager().callEvent(playerFishEvent); ++ this.level.getServer().getPluginManager().callEvent(playerFishEvent); + + if (playerFishEvent.isCancelled()) { + return 0; @@ -104,26 +104,26 @@ double d0 = entityhuman.locX() - this.locX(); double d1 = entityhuman.locY() - this.locY(); double d2 = entityhuman.locZ() - this.locZ(); -@@ -450,7 +492,11 @@ +@@ -465,7 +507,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.world.addEntity(entityitem); -- entityhuman.world.addEntity(new EntityExperienceOrb(entityhuman.world, entityhuman.locX(), entityhuman.locY() + 0.5D, entityhuman.locZ() + 0.5D, this.random.nextInt(6) + 1)); + 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)); + // CraftBukkit start - this.random.nextInt(6) + 1 -> playerFishEvent.getExpToDrop() + if (playerFishEvent.getExpToDrop() > 0) { -+ entityhuman.world.addEntity(new EntityExperienceOrb(entityhuman.world, entityhuman.locX(), entityhuman.locY() + 0.5D, entityhuman.locZ() + 0.5D, playerFishEvent.getExpToDrop())); ++ entityhuman.level.addEntity(new EntityExperienceOrb(entityhuman.level, entityhuman.locX(), entityhuman.locY() + 0.5D, entityhuman.locZ() + 0.5D, playerFishEvent.getExpToDrop())); + } + // CraftBukkit end - if (itemstack1.getItem().a((Tag) TagsItem.FISHES)) { + if (itemstack1.a((Tag) TagsItem.FISHES)) { entityhuman.a(StatisticList.FISH_CAUGHT, 1); } -@@ -460,8 +506,25 @@ +@@ -475,8 +521,25 @@ } if (this.onGround) { + // CraftBukkit start + PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND); -+ this.world.getServer().getPluginManager().callEvent(playerFishEvent); ++ this.level.getServer().getPluginManager().callEvent(playerFishEvent); + + if (playerFishEvent.isCancelled()) { + return 0; @@ -134,7 +134,7 @@ + // CraftBukkit start + if (i == 0) { + PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.REEL_IN); -+ this.world.getServer().getPluginManager().callEvent(playerFishEvent); ++ this.level.getServer().getPluginManager().callEvent(playerFishEvent); + if (playerFishEvent.isCancelled()) { + return 0; + } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch index 81d9934cc..b4df54d05 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityLargeFireball.java +++ b/net/minecraft/world/entity/projectile/EntityLargeFireball.java -@@ -11,16 +11,20 @@ +@@ -11,17 +11,21 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.MovingObjectPositionEntity; @@ -8,43 +8,44 @@ + public class EntityLargeFireball extends EntityFireballFireball { - public int yield = 1; + public int explosionPower = 1; public EntityLargeFireball(EntityTypes entitytypes, World world) { super(entitytypes, world); -+ isIncendiary = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING); // CraftBukkit ++ isIncendiary = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit } - public EntityLargeFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) { + public EntityLargeFireball(World world, EntityLiving entityliving, double d0, double d1, double d2, int i) { super(EntityTypes.FIREBALL, entityliving, d0, d1, d2, world); -+ isIncendiary = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING); // CraftBukkit + this.explosionPower = i; ++ isIncendiary = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit } @Override -@@ -29,7 +33,15 @@ - if (!this.world.isClientSide) { - boolean flag = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING); +@@ -30,7 +34,15 @@ + if (!this.level.isClientSide) { + boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); -- this.world.createExplosion((Entity) null, this.locX(), this.locY(), this.locZ(), (float) this.yield, flag, flag ? Explosion.Effect.DESTROY : Explosion.Effect.NONE); +- this.level.createExplosion((Entity) null, this.locX(), this.locY(), this.locZ(), (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.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + // give 'this' instead of (Entity) null so we know what causes the damage -+ this.world.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), flag ? Explosion.Effect.DESTROY : Explosion.Effect.NONE); ++ this.level.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), flag ? Explosion.Effect.DESTROY : Explosion.Effect.NONE); + } + // CraftBukkit end this.die(); } -@@ -60,7 +72,8 @@ +@@ -61,7 +73,8 @@ public void loadData(NBTTagCompound nbttagcompound) { super.loadData(nbttagcompound); if (nbttagcompound.hasKeyOfType("ExplosionPower", 99)) { -- this.yield = nbttagcompound.getInt("ExplosionPower"); +- this.explosionPower = nbttagcompound.getByte("ExplosionPower"); + // CraftBukkit - set bukkitYield when setting explosionpower -+ bukkitYield = this.yield = nbttagcompound.getInt("ExplosionPower"); ++ bukkitYield = this.explosionPower = nbttagcompound.getByte("ExplosionPower"); } } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch index 562b8a14e..10ba71ae9 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch +++ b/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 -@@ -34,7 +34,7 @@ +@@ -33,7 +33,7 @@ + Vec3D vec3d = this.getMot(); MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a); - if (movingobjectposition != null) { -- this.a(movingobjectposition); -+ this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event - } - +- this.a(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; diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch index 856247591..5f7d0a971 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityPotion.java +++ b/net/minecraft/world/entity/projectile/EntityPotion.java -@@ -32,6 +32,16 @@ +@@ -34,6 +34,16 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.MovingObjectPositionEntity; @@ -14,10 +14,10 @@ +import org.bukkit.entity.LivingEntity; +// CraftBukkit end + - public class EntityPotion extends EntityProjectileThrowable { + public class EntityPotion extends EntityProjectileThrowable implements ItemSupplier { - public static final Predicate b = EntityLiving::dO; -@@ -96,7 +106,7 @@ + public static final double SPLASH_RANGE = 4.0D; +@@ -100,7 +110,7 @@ if (flag) { this.splash(); @@ -26,15 +26,15 @@ if (this.isLingering()) { this.a(itemstack, potionregistry); } else { -@@ -133,6 +143,7 @@ +@@ -146,6 +156,7 @@ private void a(List list, @Nullable Entity entity) { AxisAlignedBB axisalignedbb = this.getBoundingBox().grow(4.0D, 2.0D, 4.0D); - List list1 = this.world.a(EntityLiving.class, axisalignedbb); + List list1 = this.level.a(EntityLiving.class, axisalignedbb); + Map affected = new HashMap(); // CraftBukkit if (!list1.isEmpty()) { - Iterator iterator = list1.iterator(); -@@ -150,21 +161,46 @@ + Entity entity1 = this.x(); +@@ -164,21 +175,47 @@ d1 = 1.0D; } @@ -48,6 +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(); + for (LivingEntity victim : event.getAffectedEntities()) { + if (!(victim instanceof CraftLivingEntity)) { + continue; @@ -63,7 +64,7 @@ + MobEffect mobeffect = (MobEffect) iterator1.next(); + MobEffectList mobeffectlist = mobeffect.getMobEffect(); + // CraftBukkit start - Abide by PVP settings - for players only! -+ if (!this.world.pvpMode && this.getShooter() instanceof EntityPlayer && entityliving instanceof EntityPlayer && entityliving != this.getShooter()) { ++ if (!this.level.pvpMode && this.getShooter() instanceof EntityPlayer && entityliving instanceof EntityPlayer && entityliving != this.getShooter()) { + 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) { @@ -87,49 +88,56 @@ - int i = (int) (d1 * (double) mobeffect.getDuration() + 0.5D); - - if (i > 20) { -- entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isShowParticles())); +- entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isShowParticles()), entity1); - } - } + if (i > 20) { -+ entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isShowParticles()), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_SPLASH); // CraftBukkit ++ entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isShowParticles()), entity1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_SPLASH); // CraftBukkit } } } -@@ -200,7 +236,14 @@ +@@ -214,7 +251,14 @@ entityareaeffectcloud.setColor(nbttagcompound.getInt("CustomPotionColor")); } -- this.world.addEntity(entityareaeffectcloud); +- this.level.addEntity(entityareaeffectcloud); + // CraftBukkit start + org.bukkit.event.entity.LingeringPotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callLingeringPotionSplashEvent(this, entityareaeffectcloud); -+ if (!(event.isCancelled() || entityareaeffectcloud.dead)) { -+ this.world.addEntity(entityareaeffectcloud); ++ if (!(event.isCancelled() || entityareaeffectcloud.isRemoved())) { ++ this.level.addEntity(entityareaeffectcloud); + } else { -+ entityareaeffectcloud.dead = true; ++ entityareaeffectcloud.die(); + } + // CraftBukkit end } public boolean isLingering() { -@@ -211,11 +254,19 @@ - IBlockData iblockdata = this.world.getType(blockposition); +@@ -225,13 +269,25 @@ + IBlockData iblockdata = this.level.getType(blockposition); if (iblockdata.a((Tag) TagsBlock.FIRE)) { -- this.world.a(blockposition, false); +- this.level.a(blockposition, false); + // CraftBukkit start + if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { -+ this.world.a(blockposition, false); ++ this.level.a(blockposition, false); ++ } ++ // CraftBukkit end + } else if (AbstractCandleBlock.b(iblockdata)) { +- AbstractCandleBlock.a((EntityHuman) null, iblockdata, (GeneratorAccess) 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); + } + // CraftBukkit end } else if (BlockCampfire.g(iblockdata)) { -- this.world.a((EntityHuman) null, 1009, blockposition, 0); -- BlockCampfire.c((GeneratorAccess) this.world, blockposition, iblockdata); -- this.world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockCampfire.LIT, false)); +- 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)); + // CraftBukkit start + if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.set(BlockCampfire.LIT, false)).isCancelled()) { -+ this.world.a((EntityHuman) null, 1009, blockposition, 0); -+ BlockCampfire.c((GeneratorAccess) this.world, blockposition, iblockdata); -+ this.world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockCampfire.LIT, false)); ++ 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)); + } + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch index 1b906a8ae..152dc6798 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityProjectile.java +++ b/net/minecraft/world/entity/projectile/EntityProjectile.java -@@ -57,7 +57,7 @@ +@@ -67,7 +67,7 @@ } if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS && !flag) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityProjectileThrowable.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityProjectileThrowable.patch index ab7f980e9..04863418e 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityProjectileThrowable.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityProjectileThrowable.patch @@ -3,10 +3,10 @@ @@ -29,8 +29,8 @@ public void setItem(ItemStack itemstack) { - if (itemstack.getItem() != this.getDefaultItem() || itemstack.hasTag()) { -- this.getDataWatcher().set(EntityProjectileThrowable.b, SystemUtils.a((Object) itemstack.cloneItemStack(), (itemstack1) -> { + if (!itemstack.a(this.getDefaultItem()) || itemstack.hasTag()) { +- this.getDataWatcher().set(EntityProjectileThrowable.DATA_ITEM_STACK, (ItemStack) SystemUtils.a((Object) itemstack.cloneItemStack(), (itemstack1) -> { - itemstack1.setCount(1); -+ this.getDataWatcher().set(EntityProjectileThrowable.b, SystemUtils.a(itemstack.cloneItemStack(), (itemstack1) -> { // CraftBukkit - decompile error ++ this.getDataWatcher().set(EntityProjectileThrowable.DATA_ITEM_STACK, (ItemStack) SystemUtils.a(itemstack.cloneItemStack(), (itemstack1) -> { // CraftBukkit - decompile error + if (!itemstack1.isEmpty()) itemstack1.setCount(1); // CraftBukkit })); } @@ -22,5 +22,5 @@ + // CraftBukkit end + public ItemStack getItem() { - return (ItemStack) this.getDataWatcher().get(EntityProjectileThrowable.b); + return (ItemStack) this.getDataWatcher().get(EntityProjectileThrowable.DATA_ITEM_STACK); } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch index 7936a5259..6a0ccc515 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/entity/projectile/EntityShulkerBullet.java +++ b/net/minecraft/world/entity/projectile/EntityShulkerBullet.java -@@ -58,8 +58,21 @@ - this.target = entity; - this.dir = EnumDirection.UP; +@@ -60,8 +60,21 @@ + this.finalTarget = entity; + this.currentMoveDirection = EnumDirection.UP; this.a(enumdirection_enumaxis); + projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit } + // CraftBukkit start + public Entity getTarget() { -+ return this.target; ++ return this.finalTarget; + } + + public void setTarget(Entity e) { -+ this.target = e; -+ this.dir = EnumDirection.UP; ++ this.finalTarget = e; ++ this.currentMoveDirection = EnumDirection.UP; + this.a(EnumDirection.EnumAxis.X); + } + // CraftBukkit end @@ -22,7 +22,7 @@ @Override public SoundCategory getSoundCategory() { return SoundCategory.HOSTILE; -@@ -218,7 +231,7 @@ +@@ -225,7 +238,7 @@ MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a); if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { @@ -31,16 +31,16 @@ } } -@@ -280,7 +293,7 @@ +@@ -292,7 +305,7 @@ if (flag) { this.a(entityliving, entity); if (entity instanceof EntityLiving) { -- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.LEVITATION, 200)); -+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.LEVITATION, 200), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit +- ((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 } } -@@ -306,6 +319,11 @@ +@@ -318,6 +331,11 @@ @Override public boolean damageEntity(DamageSource damagesource, float f) { @@ -49,6 +49,6 @@ + return false; + } + // CraftBukkit end - if (!this.world.isClientSide) { - this.playSound(SoundEffects.ENTITY_SHULKER_BULLET_HURT, 1.0F, 1.0F); - ((WorldServer) this.world).a(Particles.CRIT, this.locX(), this.locY(), this.locZ(), 15, 0.2D, 0.2D, 0.2D, 0.0D); + 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); diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch b/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch index 0ed936798..6a57b49f1 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch @@ -15,7 +15,7 @@ super(EntityTypes.SMALL_FIREBALL, entityliving, d0, d1, d2, world); + // CraftBukkit start + if (this.getShooter() != null && this.getShooter() instanceof EntityInsentient) { -+ isIncendiary = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING); ++ isIncendiary = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); + } + // CraftBukkit end } @@ -28,7 +28,7 @@ - entity.setOnFire(5); + // CraftBukkit start - Entity damage by entity event + combust event + EntityCombustByEntityEvent event = new EntityCombustByEntityEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), entity.getBukkitEntity(), 5); -+ entity.world.getServer().getPluginManager().callEvent(event); ++ entity.level.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + entity.setOnFire(event.getDuration(), false); @@ -38,15 +38,15 @@ if (!flag) { @@ -57,10 +71,10 @@ - if (!this.world.isClientSide) { + if (!this.level.isClientSide) { Entity entity = this.getShooter(); -- if (entity == null || !(entity instanceof EntityInsentient) || this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) { +- if (!(entity instanceof EntityInsentient) || this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (isIncendiary) { // CraftBukkit BlockPosition blockposition = movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()); -- if (this.world.isEmpty(blockposition)) { -+ if (this.world.isEmpty(blockposition) && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, this).isCancelled()) { // CraftBukkit - this.world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) this.world, blockposition)); +- 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)); } } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntitySpectralArrow.patch b/nms-patches/net/minecraft/world/entity/projectile/EntitySpectralArrow.patch index eea9216eb..9c60ba930 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntitySpectralArrow.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntitySpectralArrow.patch @@ -4,8 +4,8 @@ super.a(entityliving); MobEffect mobeffect = new MobEffect(MobEffects.GLOWING, this.duration, 0); -- entityliving.addEffect(mobeffect); -+ entityliving.addEffect(mobeffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit +- entityliving.addEffect(mobeffect, this.x()); ++ entityliving.addEffect(mobeffect, this.x(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit } @Override diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch index 5331b3f23..0c60c6e8a 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch +++ b/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 -@@ -38,9 +38,18 @@ +@@ -39,9 +39,18 @@ protected void a(MovingObjectPosition movingobjectposition) { super.a(movingobjectposition); - if (!this.world.isClientSide) { -- this.world.triggerEffect(2002, this.getChunkCoordinates(), PotionUtil.a(Potions.WATER)); + if (this.level instanceof WorldServer) { +- this.level.triggerEffect(2002, this.getChunkCoordinates(), PotionUtil.a(Potions.WATER)); + // CraftBukkit - moved to after event -+ // this.world.triggerEffect(2002, this.getChunkCoordinates(), PotionUtil.a(Potions.WATER)); - int i = 3 + this.world.random.nextInt(5) + this.world.random.nextInt(5); ++ // this.level.triggerEffect(2002, this.getChunkCoordinates(), PotionUtil.a(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.world.triggerEffect(2002, this.getChunkCoordinates(), PotionUtil.a(Potions.WATER)); ++ this.level.triggerEffect(2002, this.getChunkCoordinates(), PotionUtil.a(Potions.WATER)); + } + // CraftBukkit end + - while (i > 0) { - int j = EntityExperienceOrb.getOrbValue(i); - + EntityExperienceOrb.a((WorldServer) this.level, this.getPositionVector(), i); + this.die(); + } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch index 3d6cf786a..82a873c7a 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/EntityThrownTrident.java +++ b/net/minecraft/world/entity/projectile/EntityThrownTrident.java -@@ -154,7 +154,7 @@ +@@ -157,7 +157,7 @@ entitylightning.d(Vec3D.c((BaseBlockPosition) blockposition)); - entitylightning.d(entity1 instanceof EntityPlayer ? (EntityPlayer) entity1 : null); -- this.world.addEntity(entitylightning); -+ ((WorldServer) this.world).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit - soundeffect = SoundEffects.ITEM_TRIDENT_THUNDER; + entitylightning.b(entity1 instanceof EntityPlayer ? (EntityPlayer) entity1 : null); +- this.level.addEntity(entitylightning); ++ ((WorldServer) this.level).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit + soundeffect = SoundEffects.TRIDENT_THUNDER; f1 = 5.0F; } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch index 6fd53b380..0ea168a49 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch @@ -1,46 +1,46 @@ --- a/net/minecraft/world/entity/projectile/EntityTippedArrow.java +++ b/net/minecraft/world/entity/projectile/EntityTippedArrow.java -@@ -138,6 +138,25 @@ +@@ -142,6 +142,25 @@ } } + // CraftBukkit start accessor methods + public void refreshEffects() { -+ this.getDataWatcher().set(EntityTippedArrow.COLOR, PotionUtil.a((Collection) PotionUtil.a(this.potionRegistry, (Collection) this.effects))); ++ this.getDataWatcher().set(EntityTippedArrow.ID_EFFECT_COLOR, PotionUtil.a((Collection) PotionUtil.a(this.potion, (Collection) this.effects))); + } + + public String getType() { -+ return IRegistry.POTION.getKey(this.potionRegistry).toString(); ++ return IRegistry.POTION.getKey(this.potion).toString(); + } + + public void setType(String string) { -+ this.potionRegistry = IRegistry.POTION.get(new net.minecraft.resources.MinecraftKey(string)); -+ this.getDataWatcher().set(EntityTippedArrow.COLOR, PotionUtil.a((Collection) PotionUtil.a(this.potionRegistry, (Collection) this.effects))); ++ 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))); + } + + public boolean isTipped() { -+ return !(this.effects.isEmpty() && this.potionRegistry == Potions.EMPTY); ++ return !(this.effects.isEmpty() && this.potion == Potions.EMPTY); + } + // CraftBukkit end + public int getColor() { - return (Integer) this.datawatcher.get(EntityTippedArrow.COLOR); + return (Integer) this.entityData.get(EntityTippedArrow.ID_EFFECT_COLOR); } -@@ -205,7 +224,7 @@ +@@ -210,7 +229,7 @@ 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())); -+ entityliving.addEffect(new MobEffect(mobeffect.getMobEffect(), Math.max(mobeffect.getDuration() / 8, 1), mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isShowParticles()), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit +- 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 } if (!this.effects.isEmpty()) { -@@ -213,7 +232,7 @@ +@@ -218,7 +237,7 @@ while (iterator.hasNext()) { mobeffect = (MobEffect) iterator.next(); -- entityliving.addEffect(mobeffect); -+ entityliving.addEffect(mobeffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit +- entityliving.addEffect(mobeffect, entity); ++ entityliving.addEffect(mobeffect, entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit } } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch index f2cc99589..03a10418f 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch @@ -8,7 +8,7 @@ + public class EntityWitherSkull extends EntityFireball { - private static final DataWatcherObject e = DataWatcher.a(EntityWitherSkull.class, DataWatcherRegistry.i); + private static final DataWatcherObject DATA_DANGEROUS = DataWatcher.a(EntityWitherSkull.class, DataWatcherRegistry.BOOLEAN); @@ -64,7 +66,7 @@ if (entity.isAlive()) { this.a(entityliving, entity); @@ -22,23 +22,23 @@ } if (b0 > 0) { -- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1)); -+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit +- ((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 } } @@ -94,7 +96,15 @@ - if (!this.world.isClientSide) { - Explosion.Effect explosion_effect = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE; + if (!this.level.isClientSide) { + Explosion.Effect explosion_effect = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE; -- this.world.createExplosion(this, this.locX(), this.locY(), this.locZ(), 1.0F, false, explosion_effect); +- this.level.createExplosion(this, this.locX(), this.locY(), this.locZ(), 1.0F, false, explosion_effect); + // CraftBukkit start -+ // this.world.createExplosion(this, this.locX(), this.locY(), this.locZ(), 1.0F, false, explosion_effect); ++ // 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.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ this.world.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect); ++ this.level.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect); + } + // CraftBukkit end this.die(); diff --git a/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch b/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch index 3fd477f56..f3ac513e9 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/IProjectile.java +++ b/net/minecraft/world/entity/projectile/IProjectile.java -@@ -15,12 +15,20 @@ +@@ -22,6 +22,10 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -10,9 +10,10 @@ + public abstract class IProjectile extends Entity { - private UUID shooter; - private int c; - private boolean d; + @Nullable +@@ -31,6 +35,10 @@ + private boolean leftOwner; + private boolean hasBeenShot; + // CraftBukkit start + private boolean hitCancelled = false; @@ -21,15 +22,15 @@ IProjectile(EntityTypes entitytypes, World world) { super(entitytypes, world); } -@@ -30,6 +38,7 @@ - this.shooter = entity.getUniqueID(); - this.c = entity.getId(); +@@ -40,6 +48,7 @@ + this.ownerUUID = entity.getUniqueID(); + this.cachedOwner = entity; } + this.projectileSource = (entity != null && entity.getBukkitEntity() instanceof ProjectileSource) ? (ProjectileSource) entity.getBukkitEntity() : null; // CraftBukkit } -@@ -111,6 +120,16 @@ +@@ -143,6 +152,16 @@ this.setMot(this.getMot().add(vec3d.x, entity.isOnGround() ? 0.0D : vec3d.y, vec3d.z)); } @@ -46,7 +47,7 @@ protected void a(MovingObjectPosition movingobjectposition) { MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType(); -@@ -125,6 +144,11 @@ +@@ -161,6 +180,11 @@ protected void a(MovingObjectPositionEntity movingobjectpositionentity) {} protected void a(MovingObjectPositionBlock movingobjectpositionblock) { @@ -55,6 +56,6 @@ + return; + } + // CraftBukkit end - IBlockData iblockdata = this.world.getType(movingobjectpositionblock.getBlockPosition()); + IBlockData iblockdata = this.level.getType(movingobjectpositionblock.getBlockPosition()); - iblockdata.a(this.world, iblockdata, movingobjectpositionblock, this); + iblockdata.a(this.level, iblockdata, movingobjectpositionblock, this); diff --git a/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch b/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch index b3fb21897..c779f35dd 100644 --- a/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch +++ b/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch @@ -3,36 +3,36 @@ @@ -167,7 +167,7 @@ MobEffect mobeffect1 = new MobEffect(MobEffects.BAD_OMEN, 120000, i, false, false, true); - if (!this.world.getGameRules().getBoolean(GameRules.DISABLE_RAIDS)) { + if (!this.level.getGameRules().getBoolean(GameRules.RULE_DISABLE_RAIDS)) { - entityhuman.addEffect(mobeffect1); + entityhuman.addEffect(mobeffect1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN); // CraftBukkit } } } -@@ -434,7 +434,7 @@ +@@ -307,7 +307,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)); + } +@@ -523,7 +523,7 @@ while (iterator.hasNext()) { EntityRaider entityraider = (EntityRaider) iterator.next(); -- entityraider.setGoalTarget(this.c.getGoalTarget()); -+ entityraider.setGoalTarget(this.c.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit +- entityraider.setGoalTarget(this.mob.getGoalTarget()); ++ entityraider.setGoalTarget(this.mob.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit } } -@@ -451,7 +451,7 @@ +@@ -540,7 +540,7 @@ while (iterator.hasNext()) { EntityRaider entityraider = (EntityRaider) iterator.next(); - entityraider.setGoalTarget(entityliving); -+ entityraider.setGoalTarget(this.c.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit ++ entityraider.setGoalTarget(this.mob.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit entityraider.setAggressive(true); } -@@ -525,7 +525,7 @@ - - private final T b; - -- public b(EntityRaider entityraider) { -+ public b(T entityraider) { // CraftBukkit - decompile error - this.b = entityraider; - this.a(EnumSet.of(PathfinderGoal.Type.MOVE)); - } diff --git a/nms-patches/net/minecraft/world/entity/raid/PersistentRaid.patch b/nms-patches/net/minecraft/world/entity/raid/PersistentRaid.patch index 7376ab31e..df5d84d09 100644 --- a/nms-patches/net/minecraft/world/entity/raid/PersistentRaid.patch +++ b/nms-patches/net/minecraft/world/entity/raid/PersistentRaid.patch @@ -5,8 +5,8 @@ if (!raid.isStarted()) { + /* CraftBukkit - moved down - if (!this.raids.containsKey(raid.getId())) { - this.raids.put(raid.getId(), raid); + if (!this.raidMap.containsKey(raid.getId())) { + this.raidMap.put(raid.getId(), raid); } + */ @@ -18,7 +18,7 @@ + // CraftBukkit end } else { entityplayer.removeEffect(MobEffects.BAD_OMEN); - entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) 43)); + entityplayer.connection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) 43)); } if (flag) { @@ -28,10 +28,10 @@ + return null; + } + -+ if (!this.raids.containsKey(raid.getId())) { -+ this.raids.put(raid.getId(), raid); ++ if (!this.raidMap.containsKey(raid.getId())) { ++ this.raidMap.put(raid.getId(), raid); + } + // CraftBukkit end raid.a((EntityHuman) entityplayer); - entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) 43)); + entityplayer.connection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) 43)); if (!raid.c()) { diff --git a/nms-patches/net/minecraft/world/entity/raid/Raid.patch b/nms-patches/net/minecraft/world/entity/raid/Raid.patch index 8e963ea25..5c15ab172 100644 --- a/nms-patches/net/minecraft/world/entity/raid/Raid.patch +++ b/nms-patches/net/minecraft/world/entity/raid/Raid.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java -@@ -153,6 +153,12 @@ +@@ -174,6 +174,12 @@ return this.status == Raid.Status.LOSS; } @@ -10,19 +10,19 @@ + } + // CraftBukkit end + - public World getWorld() { - return this.world; + public float g() { + return this.totalHealth; } -@@ -228,6 +234,7 @@ +@@ -270,6 +276,7 @@ - this.active = this.world.isLoaded(this.center); - if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL) { + this.active = this.level.isLoaded(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; } -@@ -247,13 +254,16 @@ - if (!this.world.a_(this.center)) { +@@ -289,13 +296,16 @@ + if (!this.level.b(this.center)) { if (this.groupsSpawned > 0) { this.status = Raid.Status.LOSS; + org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(this, new java.util.ArrayList<>()); // CraftBukkit @@ -38,7 +38,7 @@ this.stop(); return; } -@@ -327,6 +337,7 @@ +@@ -369,6 +379,7 @@ } if (j > 3) { @@ -46,18 +46,18 @@ this.stop(); break; } -@@ -339,6 +350,7 @@ +@@ -381,6 +392,7 @@ this.status = Raid.Status.VICTORY; - Iterator iterator = this.heroes.iterator(); + Iterator iterator = this.heroesOfTheVillage.iterator(); + List winners = new java.util.ArrayList<>(); // CraftBukkit while (iterator.hasNext()) { UUID uuid = (UUID) iterator.next(); - Entity entity = this.world.getEntity(uuid); -@@ -352,9 +364,11 @@ + Entity entity = this.level.getEntity(uuid); +@@ -394,9 +406,11 @@ entityplayer.a(StatisticList.RAID_WIN); - CriterionTriggers.H.a(entityplayer); + CriterionTriggers.RAID_WIN.a(entityplayer); + winners.add(entityplayer.getBukkitEntity()); // CraftBukkit } } @@ -66,16 +66,16 @@ } } -@@ -362,6 +376,7 @@ +@@ -404,6 +418,7 @@ } else if (this.a()) { - ++this.x; - if (this.x >= 600) { + ++this.celebrationTicks; + if (this.celebrationTicks >= 600) { + org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.FINISHED); // CraftBukkit this.stop(); return; } -@@ -496,6 +511,10 @@ - Raid.Wave[] araid_wave = Raid.Wave.f; +@@ -538,6 +553,10 @@ + Raid.Wave[] araid_wave = Raid.Wave.VALUES; int j = araid_wave.length; + // CraftBukkit start @@ -85,7 +85,7 @@ 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); -@@ -508,9 +527,11 @@ +@@ -550,9 +569,11 @@ entityraider.setPatrolLeader(true); this.a(i, entityraider); flag = true; @@ -94,10 +94,10 @@ this.a(i, entityraider, blockposition, false); + raiders.add(entityraider); // CraftBukkit - if (raid_wave.g == EntityTypes.RAVAGER) { + if (raid_wave.entityType == EntityTypes.RAVAGER) { EntityRaider entityraider1 = null; -@@ -529,6 +550,7 @@ +@@ -571,6 +592,7 @@ this.a(i, entityraider1, blockposition, false); entityraider1.setPositionRotation(blockposition, 0.0F, 0.0F); entityraider1.startRiding(entityraider); @@ -105,7 +105,7 @@ } } } -@@ -538,6 +560,7 @@ +@@ -580,6 +602,7 @@ ++this.groupsSpawned; this.updateProgress(); this.H(); @@ -113,25 +113,25 @@ } public void a(int i, EntityRaider entityraider, @Nullable BlockPosition blockposition, boolean flag) { -@@ -553,7 +576,7 @@ - entityraider.prepare(this.world, this.world.getDamageScaler(blockposition), EnumMobSpawn.EVENT, (GroupDataEntity) null, (NBTTagCompound) null); +@@ -595,7 +618,7 @@ + entityraider.prepare(this.level, this.level.getDamageScaler(blockposition), EnumMobSpawn.EVENT, (GroupDataEntity) null, (NBTTagCompound) null); entityraider.a(i, false); entityraider.setOnGround(true); -- this.world.addAllEntities(entityraider); -+ this.world.addAllEntities(entityraider, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); // CraftBukkit +- this.level.addAllEntities(entityraider); ++ this.level.addAllEntities(entityraider, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); // CraftBukkit } } -@@ -798,6 +821,12 @@ - this.heroes.add(entity.getUniqueID()); +@@ -844,6 +867,12 @@ + this.heroesOfTheVillage.add(entity.getUniqueID()); } + // CraftBukkit start - a method to get all raiders + public java.util.Collection getRaiders() { -+ return this.raiders.values().stream().flatMap(Set::stream).collect(java.util.stream.Collectors.toSet()); ++ return this.groupRaiderMap.values().stream().flatMap(Set::stream).collect(java.util.stream.Collectors.toSet()); + } + // CraftBukkit end + - static enum Wave { + private static enum Status { - VINDICATOR(EntityTypes.VINDICATOR, new int[]{0, 0, 2, 0, 1, 4, 2, 5}), EVOKER(EntityTypes.EVOKER, new int[]{0, 0, 0, 0, 0, 1, 1, 2}), PILLAGER(EntityTypes.PILLAGER, new int[]{0, 4, 3, 3, 4, 4, 4, 2}), WITCH(EntityTypes.WITCH, new int[]{0, 0, 0, 0, 3, 0, 0, 1}), RAVAGER(EntityTypes.RAVAGER, new int[]{0, 0, 0, 1, 0, 1, 0, 2}); + ONGOING, VICTORY, LOSS, STOPPED; diff --git a/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch b/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch index d500f4f2b..b4adf3eb3 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/EntityBoat.java +++ b/net/minecraft/world/entity/vehicle/EntityBoat.java -@@ -48,6 +48,15 @@ +@@ -52,6 +52,15 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -15,10 +15,10 @@ + public class EntityBoat extends Entity { - private static final DataWatcherObject b = DataWatcher.a(EntityBoat.class, DataWatcherRegistry.b); -@@ -82,6 +91,14 @@ - private float aD; - private float aE; + private static final DataWatcherObject DATA_ID_HURT = DataWatcher.a(EntityBoat.class, DataWatcherRegistry.INT); +@@ -92,6 +101,14 @@ + private float bubbleAngle; + private float bubbleAngleO; + // CraftBukkit start + // PAIL: Some of these haven't worked since a few updates, and since 1.9 they are less and less applicable. @@ -30,17 +30,17 @@ + public EntityBoat(EntityTypes entitytypes, World world) { super(entitytypes, world); - this.ah = new float[2]; -@@ -152,6 +169,19 @@ + this.paddlePositions = new float[2]; +@@ -161,6 +178,19 @@ if (this.isInvulnerable(damagesource)) { return false; - } else if (!this.world.isClientSide && !this.dead) { + } else if (!this.level.isClientSide && !this.isRemoved()) { + // CraftBukkit start + Vehicle vehicle = (Vehicle) this.getBukkitEntity(); + org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity(); + + VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f); -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return false; @@ -48,33 +48,33 @@ + // f = event.getDamage(); // TODO Why don't we do this? + // CraftBukkit end + - this.c(-this.o()); + this.c(-this.p()); this.b(10); this.setDamage(this.getDamage() + f * 10.0F); -@@ -159,6 +189,15 @@ - boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; +@@ -169,6 +199,15 @@ + boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).getAbilities().instabuild; if (flag || this.getDamage() > 40.0F) { + // CraftBukkit start + VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); -+ this.world.getServer().getPluginManager().callEvent(destroyEvent); ++ this.level.getServer().getPluginManager().callEvent(destroyEvent); + + if (destroyEvent.isCancelled()) { + this.setDamage(40F); // Maximize damage so this doesn't get triggered again right away + return true; + } + // CraftBukkit end - if (!flag && this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { - this.a((IMaterial) this.g()); + if (!flag && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { + this.a((IMaterial) this.h()); } -@@ -193,9 +232,29 @@ +@@ -204,9 +243,29 @@ public void collide(Entity entity) { if (entity instanceof EntityBoat) { if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) { + // CraftBukkit start + if (!this.isSameVehicle(entity)) { + VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity()); -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; @@ -87,7 +87,7 @@ + // CraftBukkit start + if (!this.isSameVehicle(entity)) { + VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity()); -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; @@ -97,23 +97,23 @@ super.collide(entity); } -@@ -229,6 +288,7 @@ +@@ -257,6 +316,7 @@ return this.getDirection().g(); } + private Location lastLocation; // CraftBukkit @Override public void tick() { - this.ay = this.ax; -@@ -269,6 +329,22 @@ - this.setMot(Vec3D.ORIGIN); + this.oldStatus = this.status; +@@ -297,6 +357,22 @@ + this.setMot(Vec3D.ZERO); } + // CraftBukkit start -+ org.bukkit.Server server = this.world.getServer(); -+ org.bukkit.World bworld = this.world.getWorld(); ++ org.bukkit.Server server = this.level.getServer(); ++ org.bukkit.World bworld = this.level.getWorld(); + -+ Location to = new Location(bworld, this.locX(), this.locY(), this.locZ(), this.yaw, this.pitch); ++ Location to = new Location(bworld, this.locX(), this.locY(), this.locZ(), this.getYRot(), this.getXRot()); + Vehicle vehicle = (Vehicle) this.getBukkitEntity(); + + server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle)); @@ -125,22 +125,22 @@ + lastLocation = vehicle.getLocation(); + // CraftBukkit end + - this.q(); + this.r(); for (int i = 0; i <= 1; ++i) { -@@ -753,6 +829,11 @@ +@@ -801,6 +877,11 @@ - this.b(this.fallDistance, 1.0F); - if (!this.world.isClientSide && !this.dead) { + this.a(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.world.getServer().getPluginManager().callEvent(destroyEvent); ++ this.level.getServer().getPluginManager().callEvent(destroyEvent); + if (!destroyEvent.isCancelled()) { - this.die(); - if (this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { + this.killEntity(); + if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { int i; -@@ -766,6 +847,7 @@ +@@ -814,6 +895,7 @@ } } } diff --git a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch index d4de38ff2..948c02253 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java +++ b/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java -@@ -48,6 +48,15 @@ +@@ -50,6 +50,15 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -15,19 +15,19 @@ + public abstract class EntityMinecartAbstract extends Entity { - private static final DataWatcherObject b = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.b); -@@ -58,7 +67,7 @@ - private static final DataWatcherObject g = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.i); - private static final ImmutableMap> ag = ImmutableMap.of(EntityPose.STANDING, ImmutableList.of(0, 1, -1), EntityPose.CROUCHING, ImmutableList.of(0, 1, -1), EntityPose.SWIMMING, ImmutableList.of(0, 1)); - private boolean ah; -- private static final Map> ai = (Map) SystemUtils.a((Object) Maps.newEnumMap(BlockPropertyTrackPosition.class), (enummap) -> { -+ private static final Map> ai = (Map) SystemUtils.a(Maps.newEnumMap(BlockPropertyTrackPosition.class), (enummap) -> { // CraftBukkit - decompile error + private static final DataWatcherObject DATA_ID_HURT = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.INT); +@@ -61,7 +70,7 @@ + private static final ImmutableMap> 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> EXITS = (Map) SystemUtils.a((Object) Maps.newEnumMap(BlockPropertyTrackPosition.class), (enummap) -> { ++ private static final Map> 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(); -@@ -86,6 +95,17 @@ - private double an; - private double ao; +@@ -92,6 +101,17 @@ + private double lyd; + private double lzd; + // CraftBukkit start + public boolean slowWhenEmpty = true; @@ -42,8 +42,8 @@ + protected EntityMinecartAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); - this.i = true; -@@ -213,6 +233,19 @@ + this.blocksBuilding = true; +@@ -218,6 +238,19 @@ if (this.isInvulnerable(damagesource)) { return false; } else { @@ -52,7 +52,7 @@ + org.bukkit.entity.Entity passenger = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity(); + + VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, f); -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return false; @@ -60,16 +60,16 @@ + + f = (float) event.getDamage(); + // CraftBukkit end - this.d(-this.n()); + this.d(-this.o()); this.c(10); this.velocityChanged(); -@@ -220,6 +253,15 @@ - boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; +@@ -226,6 +259,15 @@ + boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).getAbilities().instabuild; if (flag || this.getDamage() > 40.0F) { + // CraftBukkit start + VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger); -+ this.world.getServer().getPluginManager().callEvent(destroyEvent); ++ this.level.getServer().getPluginManager().callEvent(destroyEvent); + + if (destroyEvent.isCancelled()) { + this.setDamage(40); // Maximize damage so this doesn't get triggered again right away @@ -79,7 +79,7 @@ this.ejectPassengers(); if (flag && !this.hasCustomName()) { this.die(); -@@ -272,6 +314,14 @@ +@@ -285,6 +327,14 @@ @Override public void tick() { @@ -87,48 +87,48 @@ + double prevX = this.locX(); + double prevY = this.locY(); + double prevZ = this.locZ(); -+ float prevYaw = this.yaw; -+ float prevPitch = this.pitch; ++ float prevYaw = this.getYRot(); ++ float prevPitch = this.getXRot(); + // CraftBukkit end + if (this.getType() > 0) { this.c(this.getType() - 1); } -@@ -284,7 +334,7 @@ - this.an(); +@@ -294,7 +344,7 @@ } + this.aj(); - this.doPortalTick(); + // this.doPortalTick(); // CraftBukkit - handled in postTick - if (this.world.isClientSide) { - if (this.aj > 0) { - double d0 = this.locX() + (this.ak - this.locX()) / (double) this.aj; -@@ -347,6 +397,18 @@ + double d0; + + if (this.level.isClientSide) { +@@ -360,6 +410,18 @@ } - this.setYawPitch(this.yaw, this.pitch); + this.setYawPitch(this.getYRot(), this.getXRot()); + // CraftBukkit start -+ org.bukkit.World bworld = this.world.getWorld(); ++ 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.yaw, this.pitch); ++ Location to = new Location(bworld, this.locX(), this.locY(), this.locZ(), this.getYRot(), this.getXRot()); + Vehicle vehicle = (Vehicle) this.getBukkitEntity(); + -+ this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle)); ++ this.level.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle)); + + if (!from.equals(to)) { -+ this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to)); ++ this.level.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to)); + } + // CraftBukkit end - if (this.getMinecartType() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && c(this.getMot()) > 0.01D) { - List list = this.world.getEntities(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D), IEntitySelector.a(this)); + if (this.getMinecartType() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && this.getMot().i() > 0.01D) { + List list = this.level.getEntities(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D), IEntitySelector.a(this)); -@@ -355,8 +417,26 @@ +@@ -368,8 +430,26 @@ Entity entity = (Entity) list.get(l); if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.isVehicle() && !entity.isPassenger()) { + // CraftBukkit start + VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity.getBukkitEntity()); -+ this.world.getServer().getPluginManager().callEvent(collisionEvent); ++ this.level.getServer().getPluginManager().callEvent(collisionEvent); + + if (collisionEvent.isCancelled()) { + continue; @@ -139,7 +139,7 @@ + // CraftBukkit start + if (!this.isSameVehicle(entity)) { + VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity.getBukkitEntity()); -+ this.world.getServer().getPluginManager().callEvent(collisionEvent); ++ this.level.getServer().getPluginManager().callEvent(collisionEvent); + + if (collisionEvent.isCancelled()) { + continue; @@ -149,13 +149,13 @@ entity.collide(this); } } -@@ -368,6 +448,14 @@ +@@ -381,6 +461,14 @@ Entity entity1 = (Entity) iterator.next(); - if (!this.w(entity1) && entity1.isCollidable() && entity1 instanceof EntityMinecartAbstract) { + if (!this.u(entity1) && entity1.isCollidable() && entity1 instanceof EntityMinecartAbstract) { + // CraftBukkit start + VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity1.getBukkitEntity()); -+ this.world.getServer().getPluginManager().callEvent(collisionEvent); ++ this.level.getServer().getPluginManager().callEvent(collisionEvent); + + if (collisionEvent.isCancelled()) { + continue; @@ -164,16 +164,16 @@ entity1.collide(this); } } -@@ -384,7 +472,7 @@ +@@ -397,7 +485,7 @@ } protected double getMaxSpeed() { -- return 0.4D; -+ return this.maxSpeed; // CraftBukkit +- return (this.isInWater() ? 4.0D : 8.0D) / 20.0D; ++ return (this.isInWater() ? this.maxSpeed / 2.0D: this.maxSpeed); // CraftBukkit } public void a(int i, int j, int k, boolean flag) {} -@@ -395,12 +483,16 @@ +@@ -408,12 +496,16 @@ this.setMot(MathHelper.a(vec3d.x, -d0, d0), vec3d.y, MathHelper.a(vec3d.z, -d0, d0)); if (this.onGround) { @@ -192,22 +192,22 @@ } } -@@ -587,7 +679,7 @@ +@@ -604,7 +696,7 @@ } protected void decelerate() { - 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(); - this.setMot(this.getMot().d(d0, 0.0D, d0)); - } -@@ -670,6 +762,14 @@ - if (!this.world.isClientSide) { - if (!entity.noclip && !this.noclip) { - if (!this.w(entity)) { + vec3d = vec3d.d(d0, 0.0D, d0); +@@ -743,6 +835,14 @@ + if (!this.level.isClientSide) { + if (!entity.noPhysics && !this.noPhysics) { + if (!this.u(entity)) { + // CraftBukkit start + VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity()); -+ this.world.getServer().getPluginManager().callEvent(collisionEvent); ++ this.level.getServer().getPluginManager().callEvent(collisionEvent); + + if (collisionEvent.isCancelled()) { + return; @@ -216,7 +216,7 @@ double d0 = entity.locX() - this.locX(); double d1 = entity.locZ() - this.locZ(); double d2 = d0 * d0 + d1 * d1; -@@ -805,4 +905,26 @@ +@@ -922,4 +1022,26 @@ private EnumMinecartType() {} } diff --git a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.patch b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.patch index c1ac735e0..4a1896e99 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.patch +++ b/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 -@@ -120,5 +120,12 @@ +@@ -131,5 +131,12 @@ public CommandListenerWrapper getWrapper() { - return new CommandListenerWrapper(this, EntityMinecartCommandBlock.this.getPositionVector(), EntityMinecartCommandBlock.this.bi(), this.d(), 2, this.getName().getString(), EntityMinecartCommandBlock.this.getScoreboardDisplayName(), this.d().getMinecraftServer(), EntityMinecartCommandBlock.this); + return new CommandListenerWrapper(this, EntityMinecartCommandBlock.this.getPositionVector(), EntityMinecartCommandBlock.this.br(), this.e(), 2, this.getName().getString(), EntityMinecartCommandBlock.this.getScoreboardDisplayName(), this.e().getMinecraftServer(), EntityMinecartCommandBlock.this); } + + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartContainer.patch b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartContainer.patch index 3955811ea..976426515 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartContainer.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartContainer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/EntityMinecartContainer.java +++ b/net/minecraft/world/entity/vehicle/EntityMinecartContainer.java -@@ -29,6 +29,14 @@ +@@ -31,6 +31,14 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParameterSets; import net.minecraft.world.level.storage.loot.parameters.LootContextParameters; @@ -14,8 +14,8 @@ + public abstract class EntityMinecartContainer extends EntityMinecartAbstract implements IInventory, ITileInventory { - private NonNullList items; -@@ -37,15 +45,56 @@ + private NonNullList itemStacks; +@@ -38,14 +46,55 @@ public MinecraftKey lootTable; public long lootTableSeed; @@ -24,7 +24,7 @@ + private int maxStack = MAX_STACK; + + public List getContents() { -+ return this.items; ++ return this.itemStacks; + } + + public void onOpen(CraftHumanEntity who) { @@ -62,15 +62,14 @@ + protected EntityMinecartContainer(EntityTypes entitytypes, World world) { super(entitytypes, world); -- this.items = NonNullList.a(36, ItemStack.b); -+ this.items = NonNullList.a(this.getSize(), ItemStack.b); // CraftBukkit - SPIGOT-3513 - this.c = true; +- this.itemStacks = NonNullList.a(36, ItemStack.EMPTY); ++ this.itemStacks = NonNullList.a(this.getSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513 } protected EntityMinecartContainer(EntityTypes entitytypes, double d0, double d1, double d2, World world) { super(entitytypes, world, d0, d1, d2); -- this.items = NonNullList.a(36, ItemStack.b); -+ this.items = NonNullList.a(this.getSize(), ItemStack.b); // CraftBukkit - SPIGOT-3513 - this.c = true; +- this.itemStacks = NonNullList.a(36, ItemStack.EMPTY); ++ this.itemStacks = NonNullList.a(this.getSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513 } + @Override diff --git a/nms-patches/net/minecraft/world/food/FoodMetaData.patch b/nms-patches/net/minecraft/world/food/FoodMetaData.patch index 4b174f7aa..663443291 100644 --- a/nms-patches/net/minecraft/world/food/FoodMetaData.patch +++ b/nms-patches/net/minecraft/world/food/FoodMetaData.patch @@ -14,14 +14,14 @@ public int foodLevel = 20; public float saturationLevel = 5.0F; public float exhaustionLevel; - private int foodTickTimer; + private int tickTimer; + // CraftBukkit start + private EntityHuman entityhuman; + public int saturatedRegenRate = 10; + public int unsaturatedRegenRate = 80; + public int starvationRate = 80; + // CraftBukkit end - private int e = 20; + private int lastFoodLevel = 20; - public FoodMetaData() {} + public FoodMetaData() { throw new AssertionError("Whoopsie, we missed the bukkit."); } // CraftBukkit start - throw an error @@ -66,17 +66,17 @@ + this.foodLevel = event.getFoodLevel(); + } + -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), this.foodLevel, this.saturationLevel)); ++ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), this.foodLevel, this.saturationLevel)); + // CraftBukkit end } } @@ -49,23 +84,25 @@ - if (flag && this.saturationLevel > 0.0F && entityhuman.eJ() && this.foodLevel >= 20) { - ++this.foodTickTimer; -- if (this.foodTickTimer >= 10) { -+ if (this.foodTickTimer >= this.saturatedRegenRate) { // CraftBukkit + if (flag && this.saturationLevel > 0.0F && entityhuman.ft() && 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); @@ -84,23 +84,23 @@ + 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.foodTickTimer = 0; + this.tickTimer = 0; } - } else if (flag && this.foodLevel >= 18 && entityhuman.eJ()) { - ++this.foodTickTimer; -- if (this.foodTickTimer >= 80) { + } else if (flag && this.foodLevel >= 18 && entityhuman.ft()) { + ++this.tickTimer; +- if (this.tickTimer >= 80) { - entityhuman.heal(1.0F); - this.a(6.0F); -+ if (this.foodTickTimer >= this.unsaturatedRegenRate) { // CraftBukkit - add regen rate manipulation ++ 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 - this.foodTickTimer = 0; + this.tickTimer = 0; } } else if (this.foodLevel <= 0) { - ++this.foodTickTimer; -- if (this.foodTickTimer >= 80) { -+ if (this.foodTickTimer >= this.starvationRate) { // CraftBukkit - add regen rate manipulation + ++this.tickTimer; +- 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); } diff --git a/nms-patches/net/minecraft/world/inventory/Container.patch b/nms-patches/net/minecraft/world/inventory/Container.patch index 25cf789a5..2c42bc1c0 100644 --- a/nms-patches/net/minecraft/world/inventory/Container.patch +++ b/nms-patches/net/minecraft/world/inventory/Container.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/Container.java +++ b/net/minecraft/world/inventory/Container.java -@@ -21,6 +21,20 @@ +@@ -29,6 +29,20 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.TileEntity; @@ -20,10 +20,10 @@ + public abstract class Container { - public NonNullList items = NonNullList.a(); -@@ -35,6 +49,27 @@ - private final List listeners = Lists.newArrayList(); - private final Set k = Sets.newHashSet(); + public static final int SLOT_CLICKED_OUTSIDE = -999; +@@ -57,6 +71,27 @@ + private ContainerSynchronizer synchronizer; + private boolean suppressRemoteUpdates; + // CraftBukkit start + public boolean checkReachable = true; @@ -47,43 +47,57 @@ + // CraftBukkit end + protected Container(@Nullable Containers containers, int i) { - this.e = containers; - this.windowId = i; -@@ -216,6 +251,7 @@ - k = playerinventory.getCarried().getCount(); - Iterator iterator = this.i.iterator(); + this.carried = ItemStack.EMPTY; + this.remoteSlots = NonNullList.a(); +@@ -154,6 +189,15 @@ + + } + ++ // CraftBukkit start ++ public void broadcastCarriedItem() { ++ this.remoteCarried = this.getCarried().cloneItemStack(); ++ if (this.synchronizer != null) { ++ this.synchronizer.sendCarriedChange(this, this.remoteCarried); ++ } ++ } ++ // CraftBukkit end ++ + public void b(ICrafting icrafting) { + this.containerListeners.remove(icrafting); + } +@@ -349,6 +393,7 @@ + l = this.getCarried().getCount(); + Iterator iterator = this.quickcraftSlots.iterator(); + Map draggedSlots = new HashMap(); // CraftBukkit - Store slots from drag in map (raw slot id -> new stack) while (iterator.hasNext()) { Slot slot1 = (Slot) iterator.next(); - ItemStack itemstack3 = playerinventory.getCarried(); -@@ -231,12 +267,48 @@ + ItemStack itemstack2 = this.getCarried(); +@@ -365,12 +410,48 @@ } - k -= itemstack4.getCount() - j1; -- slot1.set(itemstack4); -+ // slot1.set(itemstack4); -+ draggedSlots.put(slot1.rawSlotIndex, itemstack4); // CraftBukkit - Put in map instead of setting - } - } - -- itemstack2.setCount(k); -- playerinventory.setCarried(itemstack2); + l -= itemstack3.getCount() - j1; +- slot1.set(itemstack3); ++ // slot1.set(itemstack3); ++ draggedSlots.put(slot1.index, itemstack3); // CraftBukkit - Put in map instead of setting ++ } ++ } ++ + // CraftBukkit start - InventoryDragEvent + InventoryView view = getBukkitView(); -+ org.bukkit.inventory.ItemStack newcursor = CraftItemStack.asCraftMirror(itemstack2); -+ newcursor.setAmount(k); ++ org.bukkit.inventory.ItemStack newcursor = CraftItemStack.asCraftMirror(itemstack1); ++ newcursor.setAmount(l); + Map eventmap = new HashMap(); + for (Map.Entry ditem : draggedSlots.entrySet()) { + eventmap.put(ditem.getKey(), CraftItemStack.asBukkitCopy(ditem.getValue())); + } + + // It's essential that we set the cursor to the new value here to prevent item duplication if a plugin closes the inventory. -+ ItemStack oldCursor = playerinventory.getCarried(); -+ playerinventory.setCarried(CraftItemStack.asNMSCopy(newcursor)); ++ ItemStack oldCursor = this.getCarried(); ++ this.setCarried(CraftItemStack.asNMSCopy(newcursor)); + -+ InventoryDragEvent event = new InventoryDragEvent(view, (newcursor.getType() != org.bukkit.Material.AIR ? newcursor : null), CraftItemStack.asBukkitCopy(oldCursor), this.dragType == 1, eventmap); -+ entityhuman.world.getServer().getPluginManager().callEvent(event); ++ InventoryDragEvent event = new InventoryDragEvent(view, (newcursor.getType() != org.bukkit.Material.AIR ? newcursor : null), CraftItemStack.asBukkitCopy(oldCursor), this.quickcraftType == 1, eventmap); ++ entityhuman.level.getServer().getPluginManager().callEvent(event); + + // Whether or not a change was made to the inventory that requires an update. + boolean needsUpdate = event.getResult() != Result.DEFAULT; @@ -94,60 +108,74 @@ + } + // The only time the carried item will be set to null is if the inventory is closed by the server. + // If the inventory is closed by the server, then the cursor items are dropped. This is why we change the cursor early. -+ if (playerinventory.getCarried() != null) { -+ playerinventory.setCarried(CraftItemStack.asNMSCopy(event.getCursor())); ++ if (this.getCarried() != null) { ++ this.setCarried(CraftItemStack.asNMSCopy(event.getCursor())); + needsUpdate = true; -+ } + } + } else { -+ playerinventory.setCarried(oldCursor); -+ } -+ ++ this.setCarried(oldCursor); + } + +- itemstack1.setCount(l); +- this.setCarried(itemstack1); + if (needsUpdate && entityhuman instanceof EntityPlayer) { -+ ((EntityPlayer) entityhuman).updateInventory(this); ++ this.updateInventory(); + } + // CraftBukkit end } - this.d(); -@@ -253,8 +325,11 @@ + this.e(); +@@ -388,8 +469,11 @@ if (i == -999) { - if (!playerinventory.getCarried().isEmpty()) { - if (j == 0) { -- entityhuman.drop(playerinventory.getCarried(), true); + if (!this.getCarried().isEmpty()) { + if (clickaction == ClickAction.PRIMARY) { +- entityhuman.drop(this.getCarried(), true); + // CraftBukkit start -+ ItemStack carried = playerinventory.getCarried(); - playerinventory.setCarried(ItemStack.b); ++ ItemStack carried = this.getCarried(); + this.setCarried(ItemStack.EMPTY); + entityhuman.drop(carried, true); + // CraftBukkit start + } else { + entityhuman.drop(this.getCarried().cloneAndSubtract(1), true); } - - if (j == 1) { -@@ -342,6 +417,15 @@ - } - - slot2.d(); -+ // CraftBukkit start - Make sure the client has the right slot contents -+ if (entityhuman instanceof EntityPlayer && slot2.getMaxStackSize() != 64) { -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, slot2.rawSlotIndex, slot2.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).playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, 0, this.getSlot(0).getItem())); -+ } -+ } -+ // CraftBukkit end +@@ -452,6 +536,15 @@ } - } - } else if (inventoryclicktype == InventoryClickType.SWAP) { -@@ -444,8 +528,11 @@ - PlayerInventory playerinventory = entityhuman.inventory; - if (!playerinventory.getCarried().isEmpty()) { -- entityhuman.drop(playerinventory.getCarried(), false); + slot.d(); ++ // 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, 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, 0, this.getSlot(0).getItem())); ++ } ++ } ++ // CraftBukkit end + } + } else { + Slot slot2; +@@ -556,8 +649,11 @@ + + public void b(EntityHuman entityhuman) { + if (!this.getCarried().isEmpty()) { +- entityhuman.drop(this.getCarried(), false); + // CraftBukkit start - SPIGOT-4556 -+ ItemStack carried = playerinventory.getCarried(); - playerinventory.setCarried(ItemStack.b); ++ ItemStack carried = this.getCarried(); + this.setCarried(ItemStack.EMPTY); + entityhuman.drop(carried, false); + // CraftBukkit end } } +@@ -767,6 +863,11 @@ + } + + public ItemStack getCarried() { ++ // CraftBukkit start ++ if (this.carried.isEmpty()) { ++ this.setCarried(ItemStack.EMPTY); ++ } ++ // CraftBukkit end + return this.carried; + } + diff --git a/nms-patches/net/minecraft/world/inventory/ContainerAccess.patch b/nms-patches/net/minecraft/world/inventory/ContainerAccess.patch index 08dcb2564..f799ab850 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerAccess.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerAccess.patch @@ -18,7 +18,7 @@ + } + // CraftBukkit end + - ContainerAccess a = new ContainerAccess() { + ContainerAccess NULL = new ContainerAccess() { @Override public Optional a(BiFunction bifunction) { @@ -17,6 +31,18 @@ diff --git a/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch b/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch index 779aa7ff0..5deeb70f0 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerAnvil.java +++ b/net/minecraft/world/inventory/ContainerAnvil.java -@@ -19,12 +19,20 @@ +@@ -19,6 +19,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -11,79 +11,80 @@ public class ContainerAnvil extends ContainerAnvilAbstract { private static final Logger LOGGER = LogManager.getLogger(); - private int h; - public String renameText; - public final ContainerProperty levelCost; +@@ -34,6 +38,10 @@ + private static final int COST_REPAIR_SACRIFICE = 2; + private static final int COST_INCOMPATIBLE_PENALTY = 1; + private static final int COST_RENAME = 1; + // CraftBukkit start + public int maximumRepairCost = 40; + private CraftInventoryView bukkitEntity; + // CraftBukkit end public ContainerAnvil(int i, PlayerInventory playerinventory) { - this(i, playerinventory, ContainerAccess.a); -@@ -98,7 +106,7 @@ + this(i, playerinventory, ContainerAccess.NULL); +@@ -107,7 +115,7 @@ byte b1 = 0; if (itemstack.isEmpty()) { -- this.resultInventory.setItem(0, ItemStack.b); -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.b); // CraftBukkit - this.levelCost.set(0); +- this.resultSlots.setItem(0, ItemStack.EMPTY); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit + this.cost.set(0); } else { ItemStack itemstack1 = itemstack.cloneItemStack(); -@@ -116,7 +124,7 @@ - if (itemstack1.e() && itemstack1.getItem().a(itemstack, itemstack2)) { - k = Math.min(itemstack1.getDamage(), itemstack1.h() / 4); +@@ -125,7 +133,7 @@ + if (itemstack1.f() && itemstack1.getItem().a(itemstack, itemstack2)) { + k = Math.min(itemstack1.getDamage(), itemstack1.i() / 4); if (k <= 0) { -- this.resultInventory.setItem(0, ItemStack.b); -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.b); // CraftBukkit - this.levelCost.set(0); +- this.resultSlots.setItem(0, ItemStack.EMPTY); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit + this.cost.set(0); return; } -@@ -131,7 +139,7 @@ - this.h = i1; +@@ -140,7 +148,7 @@ + this.repairItemCountCost = i1; } else { - if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.e())) { -- this.resultInventory.setItem(0, ItemStack.b); -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.b); // CraftBukkit - this.levelCost.set(0); + if (!flag && (!itemstack1.a(itemstack2.getItem()) || !itemstack1.f())) { +- this.resultSlots.setItem(0, ItemStack.EMPTY); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit + this.cost.set(0); return; } -@@ -221,7 +229,7 @@ +@@ -230,7 +238,7 @@ } if (flag2 && !flag1) { -- this.resultInventory.setItem(0, ItemStack.b); -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.b); // CraftBukkit - this.levelCost.set(0); +- this.resultSlots.setItem(0, ItemStack.EMPTY); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit + this.cost.set(0); return; } -@@ -245,11 +253,11 @@ - itemstack1 = ItemStack.b; +@@ -254,11 +262,11 @@ + itemstack1 = ItemStack.EMPTY; } -- if (b1 == i && b1 > 0 && this.levelCost.get() >= 40) { -- this.levelCost.set(39); -+ if (b1 == i && b1 > 0 && this.levelCost.get() >= maximumRepairCost) { // CraftBukkit -+ this.levelCost.set(maximumRepairCost - 1); // CraftBukkit +- if (b1 == i && b1 > 0 && this.cost.get() >= 40) { +- this.cost.set(39); ++ if (b1 == i && b1 > 0 && this.cost.get() >= maximumRepairCost) { // CraftBukkit ++ this.cost.set(maximumRepairCost - 1); // CraftBukkit } -- if (this.levelCost.get() >= 40 && !this.player.abilities.canInstantlyBuild) { -+ if (this.levelCost.get() >= maximumRepairCost && !this.player.abilities.canInstantlyBuild) { // CraftBukkit - itemstack1 = ItemStack.b; +- if (this.cost.get() >= 40 && !this.player.getAbilities().instabuild) { ++ if (this.cost.get() >= maximumRepairCost && !this.player.getAbilities().instabuild) { // CraftBukkit + itemstack1 = ItemStack.EMPTY; } -@@ -268,7 +276,7 @@ +@@ -277,7 +285,7 @@ EnchantmentManager.a(map, itemstack1); } -- this.resultInventory.setItem(0, itemstack1); +- this.resultSlots.setItem(0, itemstack1); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), itemstack1); // CraftBukkit - this.c(); + this.d(); } } -@@ -291,4 +299,18 @@ - - this.e(); +@@ -304,4 +312,18 @@ + public int j() { + return this.cost.get(); } + + // CraftBukkit start @@ -94,7 +95,7 @@ + } + + org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryAnvil( -+ containerAccess.getLocation(), this.repairInventory, this.resultInventory, this); ++ access.getLocation(), this.inputSlots, this.resultSlots, this); + bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch b/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch index 422886eaf..3255bc5b3 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/inventory/ContainerAnvilAbstract.java +++ b/net/minecraft/world/inventory/ContainerAnvilAbstract.java -@@ -85,6 +85,7 @@ +@@ -92,6 +92,7 @@ @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return (Boolean) this.containerAccess.a((world, blockposition) -> { + 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; }, true); diff --git a/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch b/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch index 96c61a448..95e156912 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerBeacon.java +++ b/net/minecraft/world/inventory/ContainerBeacon.java -@@ -8,12 +8,21 @@ +@@ -10,6 +10,11 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Blocks; @@ -11,18 +11,19 @@ + public class ContainerBeacon extends Container { - private final IInventory beacon; - private final ContainerBeacon.SlotBeacon d; - private final ContainerAccess containerAccess; - private final IContainerProperties containerProperties; + private static final int PAYMENT_SLOT = 0; +@@ -23,6 +28,10 @@ + private final ContainerBeacon.SlotBeacon paymentSlot; + private final ContainerAccess access; + private final IContainerProperties beaconData; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; + private PlayerInventory player; + // CraftBukkit end public ContainerBeacon(int i, IInventory iinventory) { - this(i, iinventory, new ContainerProperties(3), ContainerAccess.a); -@@ -21,6 +30,7 @@ + this(i, iinventory, new ContainerProperties(3), ContainerAccess.NULL); +@@ -30,6 +39,7 @@ public ContainerBeacon(int i, IInventory iinventory, IContainerProperties icontainerproperties, ContainerAccess containeraccess) { super(Containers.BEACON, i); @@ -30,15 +31,15 @@ this.beacon = new InventorySubcontainer(1) { @Override public boolean b(int j, ItemStack itemstack) { -@@ -70,6 +80,7 @@ +@@ -79,6 +89,7 @@ @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return a(this.containerAccess, entityhuman, Blocks.BEACON); + return a(this.access, entityhuman, Blocks.BEACON); } -@@ -151,4 +162,17 @@ +@@ -178,4 +189,17 @@ return 1; } } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerBrewingStand.patch b/nms-patches/net/minecraft/world/inventory/ContainerBrewingStand.patch index d51714d29..fb3cdf6ed 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerBrewingStand.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerBrewingStand.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerBrewingStand.java +++ b/net/minecraft/world/inventory/ContainerBrewingStand.java -@@ -13,18 +13,29 @@ +@@ -12,6 +12,11 @@ import net.minecraft.world.item.alchemy.PotionRegistry; import net.minecraft.world.item.alchemy.PotionUtil; @@ -11,9 +11,10 @@ + public class ContainerBrewingStand extends Container { - private final IInventory brewingStand; - private final IContainerProperties d; - private final Slot e; + private static final int BOTTLE_SLOT_START = 0; +@@ -28,12 +33,18 @@ + private final IContainerProperties brewingStandData; + private final Slot ingredientSlot; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; @@ -30,7 +31,7 @@ a(iinventory, 5); a(icontainerproperties, 2); this.brewingStand = iinventory; -@@ -52,6 +63,7 @@ +@@ -61,6 +72,7 @@ @Override public boolean canUse(EntityHuman entityhuman) { @@ -38,8 +39,8 @@ return this.brewingStand.a(entityhuman); } -@@ -184,4 +196,17 @@ - return item == Items.POTION || item == Items.SPLASH_POTION || item == Items.LINGERING_POTION || item == Items.GLASS_BOTTLE; +@@ -198,4 +210,17 @@ + return 64; } } + diff --git a/nms-patches/net/minecraft/world/inventory/ContainerCartography.patch b/nms-patches/net/minecraft/world/inventory/ContainerCartography.patch index a3553e1fa..2ecb6f528 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerCartography.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerCartography.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerCartography.java +++ b/net/minecraft/world/inventory/ContainerCartography.java -@@ -13,8 +13,30 @@ +@@ -12,8 +12,30 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.saveddata.maps.WorldMap; @@ -23,15 +23,15 @@ + return bukkitEntity; + } + -+ CraftInventoryCartography inventory = new CraftInventoryCartography(this.inventory, this.resultInventory); ++ CraftInventoryCartography inventory = new CraftInventoryCartography(this.container, this.resultContainer); + bukkitEntity = new CraftInventoryView(this.player, inventory, this); + return bukkitEntity; + } + // CraftBukkit end - private final ContainerAccess containerAccess; - private long e; - public final IInventory inventory; -@@ -32,6 +54,13 @@ + public static final int MAP_SLOT = 0; + 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(); } @@ -43,9 +43,9 @@ + } + // CraftBukkit end }; - this.resultInventory = new InventoryCraftResult() { + this.resultContainer = new InventoryCraftResult() { @Override -@@ -39,6 +68,13 @@ +@@ -45,6 +74,13 @@ ContainerCartography.this.a((IInventory) this); super.update(); } @@ -57,9 +57,9 @@ + } + // CraftBukkit end }; - this.containerAccess = containeraccess; - this.a(new Slot(this.inventory, 0, 15, 15) { -@@ -91,10 +127,12 @@ + this.access = containeraccess; + this.a(new Slot(this.container, 0, 15, 15) { +@@ -95,10 +131,12 @@ this.a(new Slot(playerinventory, j, 8 + j * 18, 142)); } @@ -69,6 +69,6 @@ @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return a(this.containerAccess, entityhuman, Blocks.CARTOGRAPHY_TABLE); + return a(this.access, entityhuman, Blocks.CARTOGRAPHY_TABLE); } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerChest.patch b/nms-patches/net/minecraft/world/inventory/ContainerChest.patch index 9e7c02ef4..8eba2155f 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerChest.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerChest.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerChest.java +++ b/net/minecraft/world/inventory/ContainerChest.java -@@ -6,10 +6,39 @@ +@@ -6,11 +6,40 @@ import net.minecraft.world.entity.player.PlayerInventory; import net.minecraft.world.item.ItemStack; @@ -12,8 +12,9 @@ + public class ContainerChest extends Container { + private static final int SLOTS_PER_ROW = 9; private final IInventory container; - private final int d; + private final int containerRows; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; + private PlayerInventory player; @@ -40,9 +41,9 @@ private ContainerChest(Containers containers, int i, PlayerInventory playerinventory, int j) { this(containers, i, playerinventory, new InventorySubcontainer(9 * j), j); -@@ -55,6 +84,10 @@ +@@ -56,6 +85,10 @@ iinventory.startOpen(playerinventory.player); - int k = (this.d - 4) * 18; + int k = (this.containerRows - 4) * 18; + // CraftBukkit start - Save player + this.player = playerinventory; @@ -51,7 +52,7 @@ int l; int i1; -@@ -78,6 +111,7 @@ +@@ -79,6 +112,7 @@ @Override public boolean canUse(EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/inventory/ContainerDispenser.patch b/nms-patches/net/minecraft/world/inventory/ContainerDispenser.patch index 7d2faa60a..9bc60f986 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerDispenser.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerDispenser.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerDispenser.java +++ b/net/minecraft/world/inventory/ContainerDispenser.java -@@ -6,9 +6,18 @@ +@@ -6,6 +6,11 @@ import net.minecraft.world.entity.player.PlayerInventory; import net.minecraft.world.item.ItemStack; @@ -11,7 +11,11 @@ + public class ContainerDispenser extends Container { - public final IInventory items; + private static final int SLOT_COUNT = 9; +@@ -14,6 +19,10 @@ + private static final int USE_ROW_SLOT_START = 36; + private static final int USE_ROW_SLOT_END = 45; + public final IInventory dispenser; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; + private PlayerInventory player; @@ -19,28 +23,28 @@ public ContainerDispenser(int i, PlayerInventory playerinventory) { this(i, playerinventory, new InventorySubcontainer(9)); -@@ -16,6 +25,10 @@ +@@ -21,6 +30,10 @@ public ContainerDispenser(int i, PlayerInventory playerinventory, IInventory iinventory) { - super(Containers.GENERIC_3X3, i); + super(Containers.GENERIC_3x3, i); + // CraftBukkit start - Save player + this.player = playerinventory; + // CraftBukkit end + a(iinventory, 9); - this.items = iinventory; + this.dispenser = iinventory; iinventory.startOpen(playerinventory.player); -@@ -43,6 +56,7 @@ +@@ -48,6 +61,7 @@ @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return this.items.a(entityhuman); + return this.dispenser.a(entityhuman); } -@@ -84,4 +98,17 @@ +@@ -89,4 +103,17 @@ super.b(entityhuman); - this.items.closeContainer(entityhuman); + this.dispenser.closeContainer(entityhuman); } + + // CraftBukkit start @@ -50,7 +54,7 @@ + return bukkitEntity; + } + -+ CraftInventory inventory = new CraftInventory(this.items); ++ CraftInventory inventory = new CraftInventory(this.dispenser); + bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch b/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch index c2e6b5ead..a0eaacce1 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch @@ -24,15 +24,15 @@ private final IInventory enchantSlots; @@ -29,6 +44,10 @@ public final int[] costs; - public final int[] enchantments; - public final int[] levels; + public final int[] enchantClue; + public final int[] levelClue; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; + private Player player; + // CraftBukkit end public ContainerEnchantTable(int i, PlayerInventory playerinventory) { - this(i, playerinventory, ContainerAccess.a); + this(i, playerinventory, ContainerAccess.NULL); @@ -42,6 +61,13 @@ super.update(); ContainerEnchantTable.this.a((IInventory) this); @@ -45,12 +45,12 @@ + } + // CraftBukkit end }; - this.h = new Random(); - this.i = ContainerProperty.a(); + this.random = new Random(); + this.enchantmentSeed = ContainerProperty.a(); @@ -89,6 +115,9 @@ - this.a(ContainerProperty.a(this.levels, 0)); - this.a(ContainerProperty.a(this.levels, 1)); - this.a(ContainerProperty.a(this.levels, 2)); + this.a(ContainerProperty.a(this.levelClue, 0)); + this.a(ContainerProperty.a(this.levelClue, 1)); + this.a(ContainerProperty.a(this.levelClue, 2)); + // CraftBukkit start + player = (Player) playerinventory.player.getBukkitEntity(); + // CraftBukkit end @@ -63,17 +63,10 @@ - if (!itemstack.isEmpty() && itemstack.canEnchant()) { + if (!itemstack.isEmpty()) { // CraftBukkit - relax condition - this.containerAccess.a((world, blockposition) -> { + this.access.a((world, blockposition) -> { int i = 0; -@@ -152,12 +181,47 @@ - if (list != null && !list.isEmpty()) { - WeightedRandomEnchant weightedrandomenchant = (WeightedRandomEnchant) list.get(this.h.nextInt(list.size())); - -- this.enchantments[j] = IRegistry.ENCHANTMENT.a((Object) weightedrandomenchant.enchantment); -+ this.enchantments[j] = IRegistry.ENCHANTMENT.a(weightedrandomenchant.enchantment); // CraftBukkit - decompile error - this.levels[j] = weightedrandomenchant.level; - } +@@ -158,6 +187,41 @@ } } @@ -81,19 +74,19 @@ + 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.enchantments[j] >= 0) ? org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.ENCHANTMENT.getKey(IRegistry.ENCHANTMENT.fromId(this.enchantments[j])))) : null; -+ offers[j] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.levels[j], this.costs[j]) : null; ++ 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; ++ offers[j] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.levelClue[j], this.costs[j]) : null; + } + -+ PrepareItemEnchantEvent event = new PrepareItemEnchantEvent(player, this.getBukkitView(), containerAccess.getLocation().getBlock(), item, offers, i); ++ PrepareItemEnchantEvent event = new PrepareItemEnchantEvent(player, this.getBukkitView(), access.getLocation().getBlock(), item, offers, i); + event.setCancelled(!itemstack.canEnchant()); + world.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + for (j = 0; j < 3; ++j) { + this.costs[j] = 0; -+ this.enchantments[j] = -1; -+ this.levels[j] = -1; ++ this.enchantClue[j] = -1; ++ this.levelClue[j] = -1; + } + return; + } @@ -102,17 +95,17 @@ + EnchantmentOffer offer = event.getOffers()[j]; + if (offer != null) { + this.costs[j] = offer.getCost(); -+ this.enchantments[j] = IRegistry.ENCHANTMENT.a(IRegistry.ENCHANTMENT.get(CraftNamespacedKey.toMinecraft(offer.getEnchantment().getKey()))); -+ this.levels[j] = offer.getEnchantmentLevel(); ++ this.enchantClue[j] = IRegistry.ENCHANTMENT.getId(IRegistry.ENCHANTMENT.get(CraftNamespacedKey.toMinecraft(offer.getEnchantment().getKey()))); ++ this.levelClue[j] = offer.getEnchantmentLevel(); + } else { + this.costs[j] = 0; -+ this.enchantments[j] = -1; -+ this.levels[j] = -1; ++ this.enchantClue[j] = -1; ++ this.levelClue[j] = -1; + } + } + // CraftBukkit end + - this.c(); + this.d(); }); } else { @@ -184,9 +248,24 @@ @@ -124,7 +117,7 @@ + // CraftBukkit start + if (true || !list.isEmpty()) { + // entityhuman.enchantDone(itemstack, j); // Moved down - boolean flag = itemstack.getItem() == Items.BOOK; + boolean flag = itemstack.a(Items.BOOK); + Map enchants = new java.util.HashMap(); + for (Object obj : list) { + WeightedRandomEnchant instance = (WeightedRandomEnchant) obj; @@ -132,11 +125,11 @@ + } + CraftItemStack item = CraftItemStack.asCraftMirror(itemstack2); + -+ EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.getBukkitEntity(), this.getBukkitView(), containerAccess.getLocation().getBlock(), item, this.costs[i], enchants, i); ++ EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.getBukkitEntity(), this.getBukkitView(), access.getLocation().getBlock(), item, this.costs[i], enchants, i); + world.getServer().getPluginManager().callEvent(event); + + int level = event.getExpLevelCost(); -+ if (event.isCancelled() || (level > entityhuman.expLevel && !entityhuman.abilities.canInstantlyBuild) || event.getEnchantsToAdd().isEmpty()) { ++ if (event.isCancelled() || (level > entityhuman.experienceLevel && !entityhuman.getAbilities().instabuild) || event.getEnchantsToAdd().isEmpty()) { + return; + } @@ -175,18 +168,18 @@ + // CraftBukkit end + + // CraftBukkit - TODO: let plugins change this - if (!entityhuman.abilities.canInstantlyBuild) { + if (!entityhuman.getAbilities().instabuild) { itemstack1.subtract(j); if (itemstack1.isEmpty()) { -@@ -255,6 +347,7 @@ +@@ -265,6 +357,7 @@ @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return a(this.containerAccess, entityhuman, Blocks.ENCHANTING_TABLE); + return a(this.access, entityhuman, Blocks.ENCHANTING_TABLE); } -@@ -306,4 +399,17 @@ +@@ -316,4 +409,17 @@ return itemstack; } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerFurnace.patch b/nms-patches/net/minecraft/world/inventory/ContainerFurnace.patch index 23ad45e6b..a33a4458c 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerFurnace.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerFurnace.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerFurnace.java +++ b/net/minecraft/world/inventory/ContainerFurnace.java -@@ -14,6 +14,11 @@ +@@ -12,6 +12,11 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.block.entity.TileEntityFurnace; @@ -11,10 +11,10 @@ + public abstract class ContainerFurnace extends ContainerRecipeBook { - private final IInventory furnace; -@@ -22,6 +27,22 @@ - private final Recipes f; - private final RecipeBookType g; + public static final int INGREDIENT_SLOT = 0; +@@ -29,6 +34,22 @@ + private final Recipes recipeType; + private final RecipeBookType recipeBookType; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; @@ -26,7 +26,7 @@ + return bukkitEntity; + } + -+ CraftInventoryFurnace inventory = new CraftInventoryFurnace((TileEntityFurnace) this.furnace); ++ CraftInventoryFurnace inventory = new CraftInventoryFurnace((TileEntityFurnace) this.container); + bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } @@ -35,7 +35,7 @@ protected ContainerFurnace(Containers containers, Recipes recipes, RecipeBookType recipebooktype, int i, PlayerInventory playerinventory) { this(containers, recipes, recipebooktype, i, playerinventory, new InventorySubcontainer(3), new ContainerProperties(4)); } -@@ -38,6 +59,7 @@ +@@ -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))); @@ -43,29 +43,20 @@ int j; -@@ -69,7 +91,7 @@ - - @Override - public void a(boolean flag, IRecipe irecipe, EntityPlayer entityplayer) { -- (new AutoRecipeFurnace<>(this)).a(entityplayer, irecipe, flag); -+ (new AutoRecipeFurnace(this)).a(entityplayer, irecipe, flag); // CraftBukkit - decompile error - } - - @Override -@@ -94,6 +116,7 @@ +@@ -102,6 +124,7 @@ @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return this.furnace.a(entityhuman); + return this.container.a(entityhuman); } -@@ -149,7 +172,7 @@ +@@ -157,7 +180,7 @@ } - protected boolean a(ItemStack itemstack) { -- return this.c.getCraftingManager().craft(this.f, new InventorySubcontainer(new ItemStack[]{itemstack}), this.c).isPresent(); -+ return this.c.getCraftingManager().craft((Recipes) this.f, new InventorySubcontainer(new ItemStack[]{itemstack}), this.c).isPresent(); // Eclipse fail + 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) this.recipeType, new InventorySubcontainer(new ItemStack[]{itemstack}), this.level).isPresent(); // Eclipse fail } - protected boolean b(ItemStack itemstack) { + protected boolean d(ItemStack itemstack) { diff --git a/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch b/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch index d0a8ff735..eeca14727 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/ContainerGrindstone.java +++ b/net/minecraft/world/inventory/ContainerGrindstone.java -@@ -17,8 +17,30 @@ - import net.minecraft.world.level.World; +@@ -20,8 +20,30 @@ import net.minecraft.world.level.block.Blocks; + import net.minecraft.world.phys.Vec3D; +// CraftBukkit start +import org.bukkit.Location; @@ -23,15 +23,15 @@ + return bukkitEntity; + } + -+ CraftInventoryGrindstone inventory = new CraftInventoryGrindstone(this.craftInventory, this.resultInventory); ++ CraftInventoryGrindstone inventory = new CraftInventoryGrindstone(this.repairSlots, this.resultSlots); + bukkitEntity = new CraftInventoryView(this.player, inventory, this); + return bukkitEntity; + } + // CraftBukkit end - private final IInventory resultInventory; - private final IInventory craftInventory; - private final ContainerAccess containerAccess; -@@ -36,6 +58,13 @@ + 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); } @@ -43,9 +43,9 @@ + } + // CraftBukkit end }; - this.containerAccess = containeraccess; - this.a(new Slot(this.craftInventory, 0, 49, 19) { -@@ -120,6 +149,7 @@ + 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)); } @@ -53,11 +53,11 @@ } @Override -@@ -247,6 +277,7 @@ +@@ -252,6 +282,7 @@ @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return a(this.containerAccess, entityhuman, Blocks.GRINDSTONE); + return a(this.access, entityhuman, Blocks.GRINDSTONE); } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerHopper.patch b/nms-patches/net/minecraft/world/inventory/ContainerHopper.patch index 614add7d6..d2304db8d 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerHopper.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerHopper.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerHopper.java +++ b/net/minecraft/world/inventory/ContainerHopper.java -@@ -6,10 +6,31 @@ +@@ -6,11 +6,32 @@ import net.minecraft.world.entity.player.PlayerInventory; import net.minecraft.world.item.ItemStack; @@ -11,6 +11,7 @@ + public class ContainerHopper extends Container { + public static final int CONTAINER_SIZE = 5; private final IInventory hopper; + // CraftBukkit start @@ -32,7 +33,7 @@ public ContainerHopper(int i, PlayerInventory playerinventory) { this(i, playerinventory, new InventorySubcontainer(5)); } -@@ -17,6 +38,7 @@ +@@ -18,6 +39,7 @@ public ContainerHopper(int i, PlayerInventory playerinventory, IInventory iinventory) { super(Containers.HOPPER, i); this.hopper = iinventory; @@ -40,7 +41,7 @@ a(iinventory, 5); iinventory.startOpen(playerinventory.player); boolean flag = true; -@@ -41,6 +63,7 @@ +@@ -42,6 +64,7 @@ @Override public boolean canUse(EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch b/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch index 5b8a1202a..c168982e4 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch @@ -11,8 +11,8 @@ + public class ContainerHorse extends Container { - private final IInventory c; - private final EntityHorseAbstract d; + private final IInventory horseContainer; + private final EntityHorseAbstract horse; + // CraftBukkit start + org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity; @@ -24,13 +24,13 @@ + return bukkitEntity; + } + -+ return bukkitEntity = new CraftInventoryView(player.player.getBukkitEntity(), c.getOwner().getInventory(), this); ++ return bukkitEntity = new CraftInventoryView(player.player.getBukkitEntity(), horseContainer.getOwner().getInventory(), this); + } + public ContainerHorse(int i, PlayerInventory playerinventory, IInventory iinventory, final EntityHorseAbstract entityhorseabstract) { super((Containers) null, i); + player = playerinventory; + // CraftBukkit end - this.c = iinventory; - this.d = entityhorseabstract; + this.horseContainer = iinventory; + this.horse = entityhorseabstract; boolean flag = true; diff --git a/nms-patches/net/minecraft/world/inventory/ContainerLectern.patch b/nms-patches/net/minecraft/world/inventory/ContainerLectern.patch index f1b3ede87..e17570cca 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerLectern.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerLectern.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerLectern.java +++ b/net/minecraft/world/inventory/ContainerLectern.java -@@ -5,16 +5,43 @@ +@@ -5,8 +5,33 @@ import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; @@ -26,13 +26,17 @@ + return bukkitEntity; + } + -+ CraftInventoryLectern inventory = new CraftInventoryLectern(this.inventory); ++ CraftInventoryLectern inventory = new CraftInventoryLectern(this.lectern); + bukkitEntity = new CraftInventoryView(this.player, inventory, this); + return bukkitEntity; + } + // CraftBukkit end - private final IInventory inventory; - private final IContainerProperties containerProperties; + private static final int DATA_COUNT = 1; + private static final int SLOT_COUNT = 1; + public static final int BUTTON_PREV_PAGE = 1; +@@ -16,11 +41,13 @@ + private final IInventory lectern; + private final IContainerProperties lecternData; - public ContainerLectern(int i) { - this(i, new InventorySubcontainer(1), new ContainerProperties(1)); @@ -47,7 +51,7 @@ super(Containers.LECTERN, i); a(iinventory, 1); a(icontainerproperties, 1); -@@ -28,6 +55,7 @@ +@@ -34,6 +61,7 @@ } }); this.a(icontainerproperties); @@ -55,7 +59,7 @@ } @Override -@@ -53,6 +81,13 @@ +@@ -59,6 +87,13 @@ return false; } @@ -66,15 +70,15 @@ + return false; + } + // CraftBukkit end - ItemStack itemstack = this.inventory.splitWithoutUpdate(0); + ItemStack itemstack = this.lectern.splitWithoutUpdate(0); - this.inventory.update(); -@@ -75,6 +110,8 @@ + this.lectern.update(); +@@ -81,6 +116,8 @@ @Override public boolean canUse(EntityHuman entityhuman) { -+ if (inventory instanceof LecternInventory && !((LecternInventory) inventory).getLectern().hasBook()) return false; // CraftBukkit ++ if (lectern instanceof LecternInventory && !((LecternInventory) lectern).getLectern().hasBook()) return false; // CraftBukkit + if (!this.checkReachable) return true; // CraftBukkit - return this.inventory.a(entityhuman); + return this.lectern.a(entityhuman); } - } + diff --git a/nms-patches/net/minecraft/world/inventory/ContainerLoom.patch b/nms-patches/net/minecraft/world/inventory/ContainerLoom.patch index 1c6fb8761..86599ad7f 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerLoom.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerLoom.patch @@ -23,17 +23,17 @@ + return bukkitEntity; + } + -+ CraftInventoryLoom inventory = new CraftInventoryLoom(this.craftInventory, this.resultInventory); ++ CraftInventoryLoom inventory = new CraftInventoryLoom(this.inputContainer, this.outputContainer); + bukkitEntity = new CraftInventoryView(this.player, inventory, this); + return bukkitEntity; + } + // CraftBukkit end - private final ContainerAccess containerAccess; - private final ContainerProperty d; - private Runnable e; -@@ -45,6 +67,13 @@ + 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); - ContainerLoom.this.e.run(); + ContainerLoom.this.slotUpdateListener.run(); } + + // CraftBukkit start @@ -43,11 +43,11 @@ + } + // CraftBukkit end }; - this.resultInventory = new InventorySubcontainer(1) { + this.outputContainer = new InventorySubcontainer(1) { @Override -@@ -52,6 +81,13 @@ +@@ -56,6 +85,13 @@ super.update(); - ContainerLoom.this.e.run(); + ContainerLoom.this.slotUpdateListener.run(); } + + // CraftBukkit start @@ -57,22 +57,25 @@ + } + // CraftBukkit end }; - this.containerAccess = containeraccess; - this.f = this.a(new Slot(this.craftInventory, 0, 13, 26) { -@@ -112,10 +148,12 @@ + this.access = containeraccess; + this.bannerSlot = this.a(new Slot(this.inputContainer, 0, 13, 26) { +@@ -116,6 +152,7 @@ } - this.a(this.d); + this.a(this.selectedBannerPatternIndex); + player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit } + public int i() { +@@ -124,6 +161,7 @@ + @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return a(this.containerAccess, entityhuman, Blocks.LOOM); + return a(this.access, entityhuman, Blocks.LOOM); } -@@ -234,6 +272,11 @@ +@@ -246,6 +284,11 @@ if (nbttagcompound.hasKeyOfType("Patterns", 9)) { nbttaglist = nbttagcompound.getList("Patterns", 10); diff --git a/nms-patches/net/minecraft/world/inventory/ContainerMerchant.patch b/nms-patches/net/minecraft/world/inventory/ContainerMerchant.patch index 7aacac9a8..9a5707312 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerMerchant.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerMerchant.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerMerchant.java +++ b/net/minecraft/world/inventory/ContainerMerchant.java -@@ -12,11 +12,26 @@ +@@ -12,6 +12,8 @@ import net.minecraft.world.item.trading.MerchantRecipe; import net.minecraft.world.item.trading.MerchantRecipeList; @@ -8,8 +8,10 @@ + public class ContainerMerchant extends Container { - private final IMerchant merchant; - private final InventoryMerchant inventoryMerchant; + protected static final int PAYMENT1_SLOT = 0; +@@ -31,6 +33,19 @@ + private boolean showProgressBar; + private boolean canRestock; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; @@ -18,7 +20,7 @@ + @Override + public CraftInventoryView getBukkitView() { + if (bukkitEntity == null) { -+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new org.bukkit.craftbukkit.inventory.CraftInventoryMerchant(merchant, inventoryMerchant), this); ++ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new org.bukkit.craftbukkit.inventory.CraftInventoryMerchant(trader, tradeContainer), this); + } + return bukkitEntity; + } @@ -27,20 +29,20 @@ public ContainerMerchant(int i, PlayerInventory playerinventory) { this(i, playerinventory, new MerchantWrapper(playerinventory.player)); } -@@ -28,6 +43,7 @@ - this.a(new Slot(this.inventoryMerchant, 0, 136, 37)); - this.a(new Slot(this.inventoryMerchant, 1, 162, 37)); - this.a((Slot) (new SlotMerchantResult(playerinventory.player, imerchant, this.inventoryMerchant, 2, 220, 37))); +@@ -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.player = playerinventory; // CraftBukkit - save player int j; -@@ -108,7 +124,7 @@ +@@ -154,7 +170,7 @@ } - private void k() { -- if (!this.merchant.getWorld().isClientSide) { -+ if (!this.merchant.getWorld().isClientSide && this.merchant instanceof Entity) { // CraftBukkit - SPIGOT-5035 - Entity entity = (Entity) this.merchant; + private void o() { +- if (!this.trader.getWorld().isClientSide) { ++ if (!this.trader.getWorld().isClientSide && this.trader instanceof Entity) { // CraftBukkit - SPIGOT-5035 + Entity entity = (Entity) this.trader; - this.merchant.getWorld().a(entity.locX(), entity.locY(), entity.locZ(), this.merchant.getTradeSound(), SoundCategory.NEUTRAL, 1.0F, 1.0F, false); + this.trader.getWorld().a(entity.locX(), entity.locY(), entity.locZ(), this.trader.getTradeSound(), SoundCategory.NEUTRAL, 1.0F, 1.0F, false); diff --git a/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch b/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch index 5b38fc924..260908f34 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerPlayer.java +++ b/net/minecraft/world/inventory/ContainerPlayer.java -@@ -11,6 +11,12 @@ +@@ -12,6 +12,12 @@ import net.minecraft.world.item.crafting.IRecipe; import net.minecraft.world.item.enchantment.EnchantmentManager; @@ -12,18 +12,18 @@ + public class ContainerPlayer extends ContainerRecipeBook { - public static final MinecraftKey c = new MinecraftKey("textures/atlas/blocks.png"); -@@ -21,15 +27,28 @@ - public static final MinecraftKey h = new MinecraftKey("item/empty_armor_slot_shield"); - private static final MinecraftKey[] j = new MinecraftKey[]{ContainerPlayer.g, ContainerPlayer.f, ContainerPlayer.e, ContainerPlayer.d}; - private static final EnumItemSlot[] k = new EnumItemSlot[]{EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET}; -- private final InventoryCrafting craftInventory = new InventoryCrafting(this, 2, 2); -- private final InventoryCraftResult resultInventory = new InventoryCraftResult(); + public static final int CONTAINER_ID = 0; +@@ -33,15 +39,28 @@ + public static final MinecraftKey EMPTY_ARMOR_SLOT_SHIELD = new MinecraftKey("item/empty_armor_slot_shield"); + static final MinecraftKey[] TEXTURE_EMPTY_SLOTS = new MinecraftKey[]{ContainerPlayer.EMPTY_ARMOR_SLOT_BOOTS, ContainerPlayer.EMPTY_ARMOR_SLOT_LEGGINGS, ContainerPlayer.EMPTY_ARMOR_SLOT_CHESTPLATE, ContainerPlayer.EMPTY_ARMOR_SLOT_HELMET}; + private static final EnumItemSlot[] SLOT_IDS = new EnumItemSlot[]{EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET}; +- private final InventoryCrafting craftSlots = new InventoryCrafting(this, 2, 2); +- private final InventoryCraftResult resultSlots = new InventoryCraftResult(); + // CraftBukkit start -+ private final InventoryCrafting craftInventory; -+ private final InventoryCraftResult resultInventory; ++ private final InventoryCrafting craftSlots; ++ private final InventoryCraftResult resultSlots; + // CraftBukkit end - public final boolean i; + public final boolean active; private final EntityHuman owner; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; @@ -32,30 +32,21 @@ public ContainerPlayer(PlayerInventory playerinventory, boolean flag, EntityHuman entityhuman) { super((Containers) null, 0); - this.i = flag; + this.active = flag; this.owner = entityhuman; + // CraftBukkit start -+ this.resultInventory = new InventoryCraftResult(); // CraftBukkit - moved to before InventoryCrafting construction -+ this.craftInventory = new InventoryCrafting(this, 2, 2, playerinventory.player); // CraftBukkit - pass player -+ this.craftInventory.resultInventory = this.resultInventory; // CraftBukkit - let InventoryCrafting know about its result slot ++ this.resultSlots = new InventoryCraftResult(); // CraftBukkit - moved to before InventoryCrafting construction ++ this.craftSlots = new InventoryCrafting(this, 2, 2, playerinventory.player); // CraftBukkit - pass player ++ this.craftSlots.resultInventory = this.resultSlots; // CraftBukkit - let InventoryCrafting know about its result slot + 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.craftInventory, this.resultInventory, 0, 154, 28))); + this.a((Slot) (new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 154, 28))); int i; -@@ -96,7 +115,7 @@ - - @Override - public void a(IInventory iinventory) { -- ContainerWorkbench.a(this.windowId, this.owner.world, this.owner, this.craftInventory, this.resultInventory); -+ ContainerWorkbench.a(this.windowId, this.owner.world, this.owner, this.craftInventory, this.resultInventory, this); // CraftBukkit - } - - @Override -@@ -203,4 +222,17 @@ - public InventoryCrafting j() { - return this.craftInventory; +@@ -242,4 +261,17 @@ + public boolean d(int i) { + return i != this.j(); } + + // CraftBukkit start @@ -65,7 +56,7 @@ + return bukkitEntity; + } + -+ CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftInventory, this.resultInventory); ++ CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftSlots, this.resultSlots); + bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerShulkerBox.patch b/nms-patches/net/minecraft/world/inventory/ContainerShulkerBox.patch index da36899a1..42f8ac7e9 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerShulkerBox.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerShulkerBox.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerShulkerBox.java +++ b/net/minecraft/world/inventory/ContainerShulkerBox.java -@@ -6,9 +6,28 @@ +@@ -6,10 +6,29 @@ import net.minecraft.world.entity.player.PlayerInventory; import net.minecraft.world.item.ItemStack; @@ -11,7 +11,8 @@ + public class ContainerShulkerBox extends Container { - private final IInventory c; + private static final int CONTAINER_SIZE = 27; + private final IInventory container; + // CraftBukkit start + private CraftInventoryView bukkitEntity; + private PlayerInventory player; @@ -22,17 +23,17 @@ + return bukkitEntity; + } + -+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new CraftInventory(this.c), this); ++ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new CraftInventory(this.container), this); + return bukkitEntity; + } + // CraftBukkit end public ContainerShulkerBox(int i, PlayerInventory playerinventory) { this(i, playerinventory, new InventorySubcontainer(27)); -@@ -18,6 +37,7 @@ +@@ -19,6 +38,7 @@ super(Containers.SHULKER_BOX, i); a(iinventory, 27); - this.c = iinventory; + this.container = iinventory; + this.player = playerinventory; // CraftBukkit - save player iinventory.startOpen(playerinventory.player); boolean flag = true; diff --git a/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch b/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch index a64f52b1d..30d927fca 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerSmithing.java +++ b/net/minecraft/world/inventory/ContainerSmithing.java -@@ -12,12 +12,17 @@ +@@ -11,12 +11,17 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; @@ -8,37 +8,37 @@ + public class ContainerSmithing extends ContainerAnvilAbstract { - private final World g; + private final World level; @Nullable - private RecipeSmithing h; - private final List i; + private RecipeSmithing selectedRecipe; + private final List recipes; + // CraftBukkit start + private CraftInventoryView bukkitEntity; + // CraftBukkit end public ContainerSmithing(int i, PlayerInventory playerinventory) { - this(i, playerinventory, ContainerAccess.a); -@@ -63,13 +68,15 @@ - List list = this.g.getCraftingManager().b(Recipes.SMITHING, this.repairInventory, this.g); + this(i, playerinventory, ContainerAccess.NULL); +@@ -61,13 +66,15 @@ + List list = this.level.getCraftingManager().b(Recipes.SMITHING, this.inputSlots, this.level); if (list.isEmpty()) { -- this.resultInventory.setItem(0, ItemStack.b); -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.b); // CraftBukkit +- this.resultSlots.setItem(0, ItemStack.EMPTY); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit } else { - this.h = (RecipeSmithing) list.get(0); - ItemStack itemstack = this.h.a(this.repairInventory); + this.selectedRecipe = (RecipeSmithing) list.get(0); + ItemStack itemstack = this.selectedRecipe.a(this.inputSlots); - this.resultInventory.a((IRecipe) this.h); -- this.resultInventory.setItem(0, itemstack); + this.resultSlots.setRecipeUsed(this.selectedRecipe); +- this.resultSlots.setItem(0, itemstack); + // CraftBukkit start + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack); + // CraftBukkit end } } -@@ -85,4 +92,18 @@ +@@ -83,4 +90,18 @@ public boolean a(ItemStack itemstack, Slot slot) { - return slot.inventory != this.resultInventory && super.a(itemstack, slot); + return slot.container != this.resultSlots && super.a(itemstack, slot); } + + // CraftBukkit start @@ -49,7 +49,7 @@ + } + + org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventorySmithing( -+ containerAccess.getLocation(), this.repairInventory, this.resultInventory); ++ access.getLocation(), this.inputSlots, this.resultSlots); + bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch b/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch index 1a577f672..48f7644a2 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerStonecutter.java +++ b/net/minecraft/world/inventory/ContainerStonecutter.java -@@ -16,6 +16,13 @@ +@@ -15,6 +15,13 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.block.Blocks; @@ -13,11 +13,11 @@ + public class ContainerStonecutter extends Container { - private final ContainerAccess containerAccess; -@@ -29,6 +36,21 @@ - private Runnable l; - public final IInventory inventory; - private final InventoryCraftResult resultInventory; + public static final int INPUT_SLOT = 0; +@@ -34,6 +41,21 @@ + Runnable slotUpdateListener; + public final IInventory container; + final InventoryCraftResult resultContainer; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; + private Player player; @@ -28,17 +28,17 @@ + return bukkitEntity; + } + -+ CraftInventoryStonecutter inventory = new CraftInventoryStonecutter(this.inventory, this.resultInventory); ++ CraftInventoryStonecutter inventory = new CraftInventoryStonecutter(this.container, this.resultContainer); + bukkitEntity = new CraftInventoryView(this.player, inventory, this); + return bukkitEntity; + } + // CraftBukkit end public ContainerStonecutter(int i, PlayerInventory playerinventory) { - this(i, playerinventory, ContainerAccess.a); -@@ -48,6 +70,13 @@ + this(i, playerinventory, ContainerAccess.NULL); +@@ -53,6 +75,13 @@ ContainerStonecutter.this.a((IInventory) this); - ContainerStonecutter.this.l.run(); + ContainerStonecutter.this.slotUpdateListener.run(); } + + // CraftBukkit start @@ -48,18 +48,21 @@ + } + // CraftBukkit end }; - this.resultInventory = new InventoryCraftResult(); - this.containerAccess = containeraccess; -@@ -95,10 +124,12 @@ + this.resultContainer = new InventoryCraftResult(); + this.access = containeraccess; +@@ -100,6 +129,7 @@ } - this.a(this.containerProperty); + this.a(this.selectedRecipeIndex); + player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit } + public int i() { +@@ -120,6 +150,7 @@ + @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return a(this.containerAccess, entityhuman, Blocks.STONECUTTER); + return a(this.access, entityhuman, Blocks.STONECUTTER); } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch b/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch index 655755765..8165f0a11 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerWorkbench.java +++ b/net/minecraft/world/inventory/ContainerWorkbench.java -@@ -14,12 +14,21 @@ +@@ -14,6 +14,11 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.block.Blocks; @@ -11,68 +11,53 @@ + public class ContainerWorkbench extends ContainerRecipeBook { - private final InventoryCrafting craftInventory; - private final InventoryCraftResult resultInventory; - public final ContainerAccess containerAccess; - private final EntityHuman f; + public static final int RESULT_SLOT = 0; +@@ -27,6 +32,9 @@ + private final InventoryCraftResult resultSlots; + public final ContainerAccess access; + private final EntityHuman player; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; -+ private PlayerInventory player; + // CraftBukkit end public ContainerWorkbench(int i, PlayerInventory playerinventory) { - this(i, playerinventory, ContainerAccess.a); -@@ -27,8 +36,12 @@ + this(i, playerinventory, ContainerAccess.NULL); +@@ -34,8 +42,11 @@ public ContainerWorkbench(int i, PlayerInventory playerinventory, ContainerAccess containeraccess) { super(Containers.CRAFTING, i); -- this.craftInventory = new InventoryCrafting(this, 3, 3); +- this.craftSlots = new InventoryCrafting(this, 3, 3); + // CraftBukkit start - Switched order of IInventory construction and stored player - this.resultInventory = new InventoryCraftResult(); -+ this.craftInventory = new InventoryCrafting(this, 3, 3, playerinventory.player); // CraftBukkit - pass player -+ this.craftInventory.resultInventory = this.resultInventory; -+ this.player = playerinventory; + this.resultSlots = new InventoryCraftResult(); ++ this.craftSlots = new InventoryCrafting(this, 3, 3, playerinventory.player); // CraftBukkit - pass player ++ this.craftSlots.resultInventory = this.resultSlots; + // CraftBukkit end - this.containerAccess = containeraccess; - this.f = playerinventory.player; - this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 124, 35))); -@@ -54,7 +67,7 @@ + this.access = containeraccess; + this.player = playerinventory.player; + this.a((Slot) (new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 124, 35))); +@@ -71,9 +82,10 @@ + RecipeCrafting recipecrafting = (RecipeCrafting) optional.get(); - } - -- protected static void a(int i, World world, EntityHuman entityhuman, InventoryCrafting inventorycrafting, InventoryCraftResult inventorycraftresult) { -+ protected static void a(int i, World world, EntityHuman entityhuman, InventoryCrafting inventorycrafting, InventoryCraftResult inventorycraftresult, Container container) { // CraftBukkit - if (!world.isClientSide) { - EntityPlayer entityplayer = (EntityPlayer) entityhuman; - ItemStack itemstack = ItemStack.b; -@@ -67,6 +80,7 @@ - itemstack = recipecrafting.a(inventorycrafting); + if (inventorycraftresult.setRecipeUsed(world, entityplayer, recipecrafting)) { +- itemstack = recipecrafting.a((IInventory) inventorycrafting); ++ itemstack = recipecrafting.a(inventorycrafting); // CraftBukkit - decompile error } } + itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, inventorycraftresult, itemstack, container.getBukkitView(), false); // CraftBukkit inventorycraftresult.setItem(0, itemstack); - entityplayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(i, 0, itemstack)); -@@ -76,7 +90,7 @@ - @Override - public void a(IInventory iinventory) { - this.containerAccess.a((world, blockposition) -> { -- a(this.windowId, world, this.f, this.craftInventory, this.resultInventory); -+ a(this.windowId, world, this.f, this.craftInventory, this.resultInventory, this); // CraftBukkit - }); - } - -@@ -106,6 +120,7 @@ + container.a(0, itemstack); +@@ -114,6 +126,7 @@ @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return a(this.containerAccess, entityhuman, Blocks.CRAFTING_TABLE); + return a(this.access, entityhuman, Blocks.CRAFTING_TABLE); } -@@ -180,4 +195,17 @@ - public int h() { - return this.craftInventory.f(); +@@ -202,4 +215,17 @@ + public boolean d(int i) { + return i != this.j(); } + + // CraftBukkit start @@ -82,8 +67,8 @@ + return bukkitEntity; + } + -+ CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftInventory, this.resultInventory); -+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); ++ CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftSlots, this.resultSlots); ++ bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } + // CraftBukkit end diff --git a/nms-patches/net/minecraft/world/inventory/Containers.patch b/nms-patches/net/minecraft/world/inventory/Containers.patch index 2e6d88167..06b80e509 100644 --- a/nms-patches/net/minecraft/world/inventory/Containers.patch +++ b/nms-patches/net/minecraft/world/inventory/Containers.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/Containers.java +++ b/net/minecraft/world/inventory/Containers.java -@@ -2,6 +2,10 @@ - +@@ -3,6 +3,10 @@ import net.minecraft.core.IRegistry; + import net.minecraft.world.entity.player.PlayerInventory; +// CraftBukkit start +import net.minecraft.world.entity.player.PlayerInventory; @@ -10,8 +10,8 @@ + public class Containers { - public static final Containers GENERIC_9X1 = a("generic_9x1", ContainerChest::a); -@@ -21,7 +25,7 @@ + public static final Containers GENERIC_9x1 = a("generic_9x1", ContainerChest::a); +@@ -22,7 +26,7 @@ public static final Containers GRINDSTONE = a("grindstone", ContainerGrindstone::new); public static final Containers HOPPER = a("hopper", ContainerHopper::new); public static final Containers LECTERN = a("lectern", (i, playerinventory) -> { @@ -20,8 +20,8 @@ }); public static final Containers LOOM = a("loom", ContainerLoom::new); public static final Containers MERCHANT = a("merchant", ContainerMerchant::new); -@@ -33,12 +37,17 @@ - private final Containers.Supplier y; +@@ -34,7 +38,7 @@ + private final Containers.Supplier constructor; private static Containers a(String s, Containers.Supplier containers_supplier) { - return (Containers) IRegistry.a(IRegistry.MENU, s, (Object) (new Containers<>(containers_supplier))); @@ -29,14 +29,3 @@ } private Containers(Containers.Supplier containers_supplier) { - this.y = containers_supplier; - } - -- interface Supplier {} -+ // CraftBukkit start -+ interface Supplier { -+ -+ T supply(int id, PlayerInventory playerinventory); -+ } -+ // CraftBukkit end - } diff --git a/nms-patches/net/minecraft/world/inventory/InventoryCraftResult.patch b/nms-patches/net/minecraft/world/inventory/InventoryCraftResult.patch index 5deafc65f..55322ce04 100644 --- a/nms-patches/net/minecraft/world/inventory/InventoryCraftResult.patch +++ b/nms-patches/net/minecraft/world/inventory/InventoryCraftResult.patch @@ -12,15 +12,15 @@ + public class InventoryCraftResult implements IInventory, RecipeHolder { - private final NonNullList items; + private final NonNullList itemStacks; @Nullable - private IRecipe b; + private IRecipe recipeUsed; + // CraftBukkit start + private int maxStack = MAX_STACK; + + public java.util.List getContents() { -+ return this.items; ++ return this.itemStacks; + } + + public org.bukkit.inventory.InventoryHolder getOwner() { @@ -50,5 +50,5 @@ + // CraftBukkit end + public InventoryCraftResult() { - this.items = NonNullList.a(1, ItemStack.b); + this.itemStacks = NonNullList.a(1, ItemStack.EMPTY); } diff --git a/nms-patches/net/minecraft/world/inventory/InventoryCrafting.patch b/nms-patches/net/minecraft/world/inventory/InventoryCrafting.patch index a772db826..2808a1683 100644 --- a/nms-patches/net/minecraft/world/inventory/InventoryCrafting.patch +++ b/nms-patches/net/minecraft/world/inventory/InventoryCrafting.patch @@ -17,8 +17,8 @@ private final NonNullList items; @@ -15,6 +24,68 @@ - private final int c; - public final Container container; + private final int height; + public final Container menu; + // CraftBukkit start - add fields + public List transaction = new java.util.ArrayList(); @@ -63,7 +63,7 @@ + + @Override + public Location getLocation() { -+ return container instanceof ContainerWorkbench ? ((ContainerWorkbench) container).containerAccess.getLocation() : owner.getBukkitEntity().getLocation(); ++ return menu instanceof ContainerWorkbench ? ((ContainerWorkbench) menu).access.getLocation() : owner.getBukkitEntity().getLocation(); + } + + @Override @@ -83,5 +83,5 @@ + // CraftBukkit end + public InventoryCrafting(Container container, int i, int j) { - this.items = NonNullList.a(i * j, ItemStack.b); - this.container = container; + this.items = NonNullList.a(i * j, ItemStack.EMPTY); + this.menu = container; diff --git a/nms-patches/net/minecraft/world/inventory/InventoryEnderChest.patch b/nms-patches/net/minecraft/world/inventory/InventoryEnderChest.patch index 3ff6e1883..b89af3ab9 100644 --- a/nms-patches/net/minecraft/world/inventory/InventoryEnderChest.patch +++ b/nms-patches/net/minecraft/world/inventory/InventoryEnderChest.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/InventoryEnderChest.java +++ b/net/minecraft/world/inventory/InventoryEnderChest.java -@@ -7,12 +7,30 @@ +@@ -8,13 +8,31 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.TileEntityEnderChest; @@ -11,7 +11,8 @@ + public class InventoryEnderChest extends InventorySubcontainer { - private TileEntityEnderChest a; + @Nullable + private TileEntityEnderChest activeChest; + // CraftBukkit start + private final EntityHuman owner; + @@ -21,7 +22,7 @@ + + @Override + public Location getLocation() { -+ return this.a != null ? new Location(this.a.getWorld().getWorld(), this.a.getPosition().getX(), this.a.getPosition().getY(), this.a.getPosition().getZ()) : null; ++ return this.activeChest != null ? new Location(this.activeChest.getWorld().getWorld(), this.activeChest.getPosition().getX(), this.activeChest.getPosition().getY(), this.activeChest.getPosition().getZ()) : null; + } - public InventoryEnderChest() { diff --git a/nms-patches/net/minecraft/world/inventory/InventoryMerchant.patch b/nms-patches/net/minecraft/world/inventory/InventoryMerchant.patch index d362b99ce..e2a058c4d 100644 --- a/nms-patches/net/minecraft/world/inventory/InventoryMerchant.patch +++ b/nms-patches/net/minecraft/world/inventory/InventoryMerchant.patch @@ -18,15 +18,15 @@ private final IMerchant merchant; @@ -20,6 +30,46 @@ - public int selectedIndex; - private int e; + public int selectionHint; + private int futureXp; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; + + public List getContents() { -+ return this.itemsInSlots; ++ return this.itemStacks; + } + + public void onOpen(CraftHumanEntity who) { @@ -62,5 +62,5 @@ + // CraftBukkit end + public InventoryMerchant(IMerchant imerchant) { - this.itemsInSlots = NonNullList.a(3, ItemStack.b); + this.itemStacks = NonNullList.a(3, ItemStack.EMPTY); this.merchant = imerchant; diff --git a/nms-patches/net/minecraft/world/inventory/SlotFurnaceResult.patch b/nms-patches/net/minecraft/world/inventory/SlotFurnaceResult.patch index 08d3badc3..0d556d1ac 100644 --- a/nms-patches/net/minecraft/world/inventory/SlotFurnaceResult.patch +++ b/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 c(ItemStack itemstack) { - itemstack.a(this.a.world, this.a, this.b); - if (!this.a.world.isClientSide && this.inventory instanceof TileEntityFurnace) { -- ((TileEntityFurnace) this.inventory).d(this.a); -+ ((TileEntityFurnace) this.inventory).d(this.a, itemstack, this.b); // CraftBukkit + protected void b_(ItemStack itemstack) { + itemstack.a(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 } - this.b = 0; + this.removeCount = 0; diff --git a/nms-patches/net/minecraft/world/item/ItemArmor.patch b/nms-patches/net/minecraft/world/item/ItemArmor.patch index cc0ce2b7d..29690e486 100644 --- a/nms-patches/net/minecraft/world/item/ItemArmor.patch +++ b/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 -@@ -25,6 +25,11 @@ +@@ -28,6 +28,11 @@ import net.minecraft.world.level.block.BlockDispenser; import net.minecraft.world.phys.AxisAlignedBB; @@ -11,10 +11,10 @@ + public class ItemArmor extends Item implements ItemWearable { - private static final UUID[] j = 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")}; -@@ -51,6 +56,32 @@ + 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,6 +59,32 @@ EntityLiving entityliving = (EntityLiving) list.get(0); - EnumItemSlot enumitemslot = EntityInsentient.j(itemstack); + EnumItemSlot enumitemslot = EntityInsentient.getEquipmentSlotForItem(itemstack); ItemStack itemstack1 = itemstack.cloneAndSubtract(1); + // CraftBukkit start + World world = isourceblock.getWorld(); @@ -35,8 +35,8 @@ + itemstack.add(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != ItemArmor.a) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != ItemArmor.DISPENSE_ITEM_BEHAVIOR) { + idispensebehavior.dispense(isourceblock, eventStack); + return true; + } diff --git a/nms-patches/net/minecraft/world/item/ItemArmorStand.patch b/nms-patches/net/minecraft/world/item/ItemArmorStand.patch index 8dd2db508..d1dee715e 100644 --- a/nms-patches/net/minecraft/world/item/ItemArmorStand.patch +++ b/nms-patches/net/minecraft/world/item/ItemArmorStand.patch @@ -9,6 +9,6 @@ + return EnumInteractionResult.FAIL; + } + // CraftBukkit end - world.addEntity(entityarmorstand); - world.playSound((EntityHuman) null, entityarmorstand.locX(), entityarmorstand.locY(), entityarmorstand.locZ(), SoundEffects.ENTITY_ARMOR_STAND_PLACE, SoundCategory.BLOCKS, 0.75F, 0.8F); - } + 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); diff --git a/nms-patches/net/minecraft/world/item/ItemBlock.patch b/nms-patches/net/minecraft/world/item/ItemBlock.patch index 9dca71cec..ff676d6fe 100644 --- a/nms-patches/net/minecraft/world/item/ItemBlock.patch +++ b/nms-patches/net/minecraft/world/item/ItemBlock.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/ItemBlock.java +++ b/net/minecraft/world/item/ItemBlock.java -@@ -25,6 +25,13 @@ - import net.minecraft.world.level.block.state.properties.IBlockState; +@@ -34,6 +34,13 @@ + import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.shapes.VoxelShapeCollision; +// CraftBukkit start @@ -13,8 +13,8 @@ + public class ItemBlock extends Item { - @Deprecated -@@ -52,6 +59,12 @@ + public static final String BLOCK_ENTITY_TAG = "BlockEntityTag"; +@@ -69,6 +76,12 @@ return EnumInteractionResult.FAIL; } else { IBlockData iblockdata = this.c(blockactioncontext1); @@ -27,10 +27,10 @@ if (iblockdata == null) { return EnumInteractionResult.FAIL; -@@ -69,6 +82,15 @@ +@@ -85,6 +98,15 @@ iblockdata1 = this.a(blockposition, world, itemstack, iblockdata1); this.a(blockposition, world, entityhuman, itemstack, iblockdata1); - block.postPlace(world, blockposition, iblockdata1, entityhuman, itemstack); + iblockdata1.getBlock().postPlace(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()); @@ -41,20 +41,21 @@ + } + // CraftBukkit end if (entityhuman instanceof EntityPlayer) { - CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition, itemstack); + CriterionTriggers.PLACED_BLOCK.a((EntityPlayer) entityhuman, blockposition, itemstack); } -@@ -76,8 +98,8 @@ +@@ -92,9 +114,9 @@ SoundEffectType soundeffecttype = iblockdata1.getStepSound(); - world.playSound(entityhuman, blockposition, this.a(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); -- if (entityhuman == null || !entityhuman.abilities.canInstantlyBuild) { + // world.playSound(entityhuman, blockposition, this.a(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); -+ if ((entityhuman == null || !entityhuman.abilities.canInstantlyBuild) && itemstack != ItemStack.b) { // CraftBukkit + world.a((Entity) entityhuman, GameEvent.BLOCK_PLACE, blockposition); +- if (entityhuman == null || !entityhuman.getAbilities().instabuild) { ++ if ((entityhuman == null || !entityhuman.getAbilities().instabuild) && itemstack != ItemStack.EMPTY) { // CraftBukkit itemstack.subtract(1); } -@@ -113,6 +135,21 @@ +@@ -130,6 +152,21 @@ if (nbttagcompound != null) { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("BlockStateTag"); @@ -76,7 +77,7 @@ BlockStateList blockstatelist = iblockdata.getBlock().getStates(); Iterator iterator = nbttagcompound1.getKeys().iterator(); -@@ -127,11 +164,6 @@ +@@ -144,11 +181,6 @@ } } } @@ -88,7 +89,7 @@ return iblockdata1; } -@@ -144,8 +176,15 @@ +@@ -161,8 +193,15 @@ protected boolean b(BlockActionContext blockactioncontext, IBlockData iblockdata) { EntityHuman entityhuman = blockactioncontext.getEntity(); VoxelShapeCollision voxelshapecollision = entityhuman == null ? VoxelShapeCollision.a() : VoxelShapeCollision.a((Entity) entityhuman); @@ -105,3 +106,12 @@ } protected boolean isCheckCollisions() { +@@ -247,7 +286,7 @@ + + if (nbttagcompound != null) { + NBTTagList nbttaglist = nbttagcompound.getCompound("BlockEntityTag").getList("Items", 10); +- Stream stream = nbttaglist.stream(); ++ Stream stream = nbttaglist.stream(); // CraftBukkit - decompile error + + Objects.requireNonNull(NBTTagCompound.class); + ItemLiquidUtil.a(entityitem, stream.map(NBTTagCompound.class::cast).map(ItemStack::a)); diff --git a/nms-patches/net/minecraft/world/item/ItemBoat.patch b/nms-patches/net/minecraft/world/item/ItemBoat.patch index 374169f7b..40ed84225 100644 --- a/nms-patches/net/minecraft/world/item/ItemBoat.patch +++ b/nms-patches/net/minecraft/world/item/ItemBoat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemBoat.java +++ b/net/minecraft/world/item/ItemBoat.java -@@ -54,6 +54,13 @@ +@@ -56,6 +56,13 @@ } if (movingobjectpositionblock.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) { @@ -13,8 +13,8 @@ + // CraftBukkit end EntityBoat entityboat = new EntityBoat(world, movingobjectpositionblock.getPos().x, movingobjectpositionblock.getPos().y, movingobjectpositionblock.getPos().z); - entityboat.setType(this.b); -@@ -62,7 +69,15 @@ + entityboat.setType(this.type); +@@ -64,7 +71,15 @@ return InteractionResultWrapper.fail(itemstack); } else { if (!world.isClientSide) { @@ -28,6 +28,6 @@ + return InteractionResultWrapper.pass(itemstack); + } + // CraftBukkit end - if (!entityhuman.abilities.canInstantlyBuild) { + world.a((Entity) entityhuman, GameEvent.ENTITY_PLACE, new BlockPosition(movingobjectpositionblock.getPos())); + if (!entityhuman.getAbilities().instabuild) { itemstack.subtract(1); - } diff --git a/nms-patches/net/minecraft/world/item/ItemBoneMeal.patch b/nms-patches/net/minecraft/world/item/ItemBoneMeal.patch index c53009f8f..e42030e13 100644 --- a/nms-patches/net/minecraft/world/item/ItemBoneMeal.patch +++ b/nms-patches/net/minecraft/world/item/ItemBoneMeal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemBoneMeal.java +++ b/net/minecraft/world/item/ItemBoneMeal.java -@@ -28,6 +28,12 @@ +@@ -35,6 +35,12 @@ @Override public EnumInteractionResult a(ItemActionContext itemactioncontext) { diff --git a/nms-patches/net/minecraft/world/item/ItemBow.patch b/nms-patches/net/minecraft/world/item/ItemBow.patch index 74780fa95..d5075ad75 100644 --- a/nms-patches/net/minecraft/world/item/ItemBow.patch +++ b/nms-patches/net/minecraft/world/item/ItemBow.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/ItemBow.java +++ b/net/minecraft/world/item/ItemBow.java -@@ -61,6 +61,14 @@ - if (EnchantmentManager.getEnchantmentLevel(Enchantments.ARROW_FIRE, itemstack) > 0) { +@@ -64,6 +64,14 @@ + if (EnchantmentManager.getEnchantmentLevel(Enchantments.FLAMING_ARROWS, itemstack) > 0) { entityarrow.setOnFire(100); } + // CraftBukkit start @@ -15,8 +15,8 @@ itemstack.damage(1, entityhuman, (entityhuman1) -> { entityhuman1.broadcastItemBreak(entityhuman.getRaisedHand()); -@@ -69,7 +77,16 @@ - entityarrow.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY; +@@ -72,7 +80,16 @@ + entityarrow.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY; } - world.addEntity(entityarrow); @@ -32,4 +32,4 @@ + // CraftBukkit end } - world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (ItemBow.RANDOM.nextFloat() * 0.4F + 1.2F) + f * 0.5F); + 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); diff --git a/nms-patches/net/minecraft/world/item/ItemBucket.patch b/nms-patches/net/minecraft/world/item/ItemBucket.patch index 48ddfaeb4..85cf4e6c9 100644 --- a/nms-patches/net/minecraft/world/item/ItemBucket.patch +++ b/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 -@@ -29,6 +29,16 @@ +@@ -31,6 +31,16 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.MovingObjectPositionBlock; @@ -14,63 +14,65 @@ +import org.bukkit.event.player.PlayerBucketFillEvent; +// CraftBukkit end + - public class ItemBucket extends Item { + public class ItemBucket extends Item implements DispensibleContainerItem { - public final FluidType fluidType; -@@ -59,12 +69,22 @@ - if (this.fluidType == FluidTypes.EMPTY) { + public final FluidType content; +@@ -61,6 +71,16 @@ iblockdata = world.getType(blockposition); if (iblockdata.getBlock() instanceof IFluidSource) { + IFluidSource ifluidsource = (IFluidSource) iblockdata.getBlock(); + // CraftBukkit start -+ FluidType dummyFluid = ((IFluidSource) iblockdata.getBlock()).removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); -+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) world, entityhuman, blockposition, blockposition, movingobjectpositionblock.getDirection(), itemstack, dummyFluid.a()); ++ ItemStack dummyFluid = ifluidsource.removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); ++ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) world, entityhuman, blockposition, blockposition, movingobjectpositionblock.getDirection(), itemstack, dummyFluid.getItem()); + + if (event.isCancelled()) { -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-5163 (see PlayerInteractManager) ++ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-5163 (see PlayerInteractManager) + ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541 + return InteractionResultWrapper.fail(itemstack); + } + // CraftBukkit end - FluidType fluidtype = ((IFluidSource) iblockdata.getBlock()).removeFluid(world, blockposition, iblockdata); + ItemStack itemstack1 = ifluidsource.removeFluid(world, blockposition, iblockdata); - if (fluidtype != FluidTypes.EMPTY) { - entityhuman.b(StatisticList.ITEM_USED.b(this)); - entityhuman.playSound(fluidtype.a((Tag) TagsFluid.LAVA) ? SoundEffects.ITEM_BUCKET_FILL_LAVA : SoundEffects.ITEM_BUCKET_FILL, 1.0F, 1.0F); -- ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, new ItemStack(fluidtype.a())); -+ ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit + if (!itemstack1.isEmpty()) { +@@ -69,7 +89,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 if (!world.isClientSide) { - CriterionTriggers.j.a((EntityPlayer) entityhuman, new ItemStack(fluidtype.a())); -@@ -79,7 +99,7 @@ + CriterionTriggers.FILLED_BUCKET.a((EntityPlayer) entityhuman, itemstack1); +@@ -84,7 +104,7 @@ iblockdata = world.getType(blockposition); - BlockPosition blockposition2 = iblockdata.getBlock() instanceof IFluidContainer && this.fluidType == FluidTypes.WATER ? blockposition : blockposition1; + BlockPosition blockposition2 = iblockdata.getBlock() instanceof IFluidContainer && this.content == FluidTypes.WATER ? blockposition : blockposition1; -- if (this.a(entityhuman, world, blockposition2, movingobjectpositionblock1)) { -+ if (this.a(entityhuman, world, blockposition2, movingobjectpositionblock1, movingobjectpositionblock1.getDirection(), blockposition, itemstack)) { // CraftBukkit - this.a(world, itemstack, blockposition2); +- 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 (entityhuman instanceof EntityPlayer) { - CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition2, itemstack); -@@ -104,6 +124,11 @@ - public void a(World world, ItemStack itemstack, BlockPosition blockposition) {} + CriterionTriggers.PLACED_BLOCK.a((EntityPlayer) entityhuman, blockposition2, itemstack); +@@ -111,6 +131,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 a(EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock, EnumDirection enumdirection, BlockPosition clicked, ItemStack itemstack) { + // CraftBukkit end - if (!(this.fluidType instanceof FluidTypeFlowing)) { + if (!(this.content instanceof FluidTypeFlowing)) { return false; } else { -@@ -113,8 +138,18 @@ - boolean flag = iblockdata.a(this.fluidType); - boolean flag1 = iblockdata.isAir() || flag || block instanceof IFluidContainer && ((IFluidContainer) block).canPlace(world, blockposition, iblockdata, this.fluidType); +@@ -120,8 +145,18 @@ + boolean flag = iblockdata.a(this.content); + boolean flag1 = iblockdata.isAir() || flag || block instanceof IFluidContainer && ((IFluidContainer) block).canPlace(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).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-4238: needed when looking through entity ++ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-4238: needed when looking through entity + ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541 + return false; + } @@ -79,6 +81,6 @@ 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.fluidType.a((Tag) TagsFluid.WATER)) { + } else if (world.getDimensionManager().isNether() && this.content.a((Tag) TagsFluid.WATER)) { int i = blockposition.getX(); int j = blockposition.getY(); diff --git a/nms-patches/net/minecraft/world/item/ItemChorusFruit.patch b/nms-patches/net/minecraft/world/item/ItemChorusFruit.patch index 43951c70c..401a52084 100644 --- a/nms-patches/net/minecraft/world/item/ItemChorusFruit.patch +++ b/nms-patches/net/minecraft/world/item/ItemChorusFruit.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemChorusFruit.java +++ b/net/minecraft/world/item/ItemChorusFruit.java -@@ -33,7 +33,16 @@ +@@ -34,7 +34,16 @@ entityliving.stopRiding(); } @@ -15,6 +15,6 @@ + + if (status.get()) { + // CraftBukkit end - SoundEffect soundeffect = entityliving instanceof EntityFox ? SoundEffects.ENTITY_FOX_TELEPORT : SoundEffects.ITEM_CHORUS_FRUIT_TELEPORT; + SoundEffect soundeffect = entityliving instanceof EntityFox ? SoundEffects.FOX_TELEPORT : SoundEffects.CHORUS_FRUIT_TELEPORT; world.playSound((EntityHuman) null, d0, d1, d2, soundeffect, SoundCategory.PLAYERS, 1.0F, 1.0F); diff --git a/nms-patches/net/minecraft/world/item/ItemCrossbow.patch b/nms-patches/net/minecraft/world/item/ItemCrossbow.patch index 09dc5d865..c92cbc5b7 100644 --- a/nms-patches/net/minecraft/world/item/ItemCrossbow.patch +++ b/nms-patches/net/minecraft/world/item/ItemCrossbow.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemCrossbow.java +++ b/net/minecraft/world/item/ItemCrossbow.java -@@ -97,6 +97,10 @@ +@@ -114,6 +114,10 @@ if (itemstack1.isEmpty() && flag) { itemstack1 = new ItemStack(Items.ARROW); itemstack2 = itemstack1.cloneItemStack(); @@ -11,7 +11,7 @@ } if (!a(entityliving, itemstack, itemstack1, k > 0, flag)) { -@@ -221,11 +225,27 @@ +@@ -238,11 +242,27 @@ vector3fa.a(quaternion); ((IProjectile) object).shoot((double) vector3fa.a(), (double) vector3fa.b(), (double) vector3fa.c(), f1, f2); } @@ -37,6 +37,6 @@ + } + } + // CraftBukkit end - world.playSound((EntityHuman) null, entityliving.locX(), entityliving.locY(), entityliving.locZ(), SoundEffects.ITEM_CROSSBOW_SHOOT, SoundCategory.PLAYERS, 1.0F, f); + world.playSound((EntityHuman) null, entityliving.locX(), entityliving.locY(), entityliving.locZ(), SoundEffects.CROSSBOW_SHOOT, SoundCategory.PLAYERS, 1.0F, f); } } diff --git a/nms-patches/net/minecraft/world/item/ItemDebugStick.patch b/nms-patches/net/minecraft/world/item/ItemDebugStick.patch index b0dca5cd6..0f090a31d 100644 --- a/nms-patches/net/minecraft/world/item/ItemDebugStick.patch +++ b/nms-patches/net/minecraft/world/item/ItemDebugStick.patch @@ -5,7 +5,7 @@ package net.minecraft.world.item; import java.util.Collection; -@@ -91,7 +92,7 @@ +@@ -97,7 +98,7 @@ } private static > IBlockData a(IBlockData iblockdata, IBlockState iblockstate, boolean flag) { diff --git a/nms-patches/net/minecraft/world/item/ItemDye.patch b/nms-patches/net/minecraft/world/item/ItemDye.patch index dea43b22f..49078584e 100644 --- a/nms-patches/net/minecraft/world/item/ItemDye.patch +++ b/nms-patches/net/minecraft/world/item/ItemDye.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemDye.java +++ b/net/minecraft/world/item/ItemDye.java -@@ -8,6 +8,8 @@ +@@ -11,6 +11,8 @@ import net.minecraft.world.entity.animal.EntitySheep; import net.minecraft.world.entity.player.EntityHuman; @@ -8,16 +8,16 @@ + public class ItemDye extends Item { - private static final Map a = Maps.newEnumMap(EnumColor.class); -@@ -26,7 +28,17 @@ - - if (entitysheep.isAlive() && !entitysheep.isSheared() && entitysheep.getColor() != this.b) { - if (!entityhuman.world.isClientSide) { -- entitysheep.setColor(this.b); + private static final Map ITEM_BY_COLOR = Maps.newEnumMap(EnumColor.class); +@@ -30,7 +32,17 @@ + if (entitysheep.isAlive() && !entitysheep.isSheared() && entitysheep.getColor() != this.dyeColor) { + entitysheep.level.playSound(entityhuman, (Entity) entitysheep, SoundEffects.DYE_USE, SoundCategory.PLAYERS, 1.0F, 1.0F); + if (!entityhuman.level.isClientSide) { +- entitysheep.setColor(this.dyeColor); + // CraftBukkit start -+ byte bColor = (byte) this.b.getColorIndex(); ++ byte bColor = (byte) this.dyeColor.getColorIndex(); + SheepDyeWoolEvent event = new SheepDyeWoolEvent((org.bukkit.entity.Sheep) entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByWoolData(bColor)); -+ entitysheep.world.getServer().getPluginManager().callEvent(event); ++ entitysheep.level.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return EnumInteractionResult.PASS; diff --git a/nms-patches/net/minecraft/world/item/ItemEgg.patch b/nms-patches/net/minecraft/world/item/ItemEgg.patch index 722779baa..a43d02d47 100644 --- a/nms-patches/net/minecraft/world/item/ItemEgg.patch +++ b/nms-patches/net/minecraft/world/item/ItemEgg.patch @@ -4,13 +4,13 @@ public InteractionResultWrapper a(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.b(enumhand); -- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemEgg.RANDOM.nextFloat() * 0.4F + 0.8F)); -+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemEgg.RANDOM.nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down +- 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 if (!world.isClientSide) { EntityEgg entityegg = new EntityEgg(world, entityhuman); entityegg.setItem(itemstack); - entityegg.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F); + entityegg.a(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F); - world.addEntity(entityegg); + // CraftBukkit start + if (!world.addEntity(entityegg)) { @@ -21,7 +21,7 @@ + } + // CraftBukkit end } -+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemEgg.RANDOM.nextFloat() * 0.4F + 0.8F)); // CraftBukkit - from above ++ // 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 - from above entityhuman.b(StatisticList.ITEM_USED.b(this)); - if (!entityhuman.abilities.canInstantlyBuild) { + if (!entityhuman.getAbilities().instabuild) { diff --git a/nms-patches/net/minecraft/world/item/ItemEndCrystal.patch b/nms-patches/net/minecraft/world/item/ItemEndCrystal.patch index d2ebf7402..5e61434a7 100644 --- a/nms-patches/net/minecraft/world/item/ItemEndCrystal.patch +++ b/nms-patches/net/minecraft/world/item/ItemEndCrystal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemEndCrystal.java +++ b/net/minecraft/world/item/ItemEndCrystal.java -@@ -45,6 +45,11 @@ +@@ -46,6 +46,11 @@ EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(world, d0 + 0.5D, d1, d2 + 0.5D); entityendercrystal.setShowingBottom(false); @@ -10,5 +10,5 @@ + } + // CraftBukkit end world.addEntity(entityendercrystal); + world.a((Entity) itemactioncontext.getEntity(), GameEvent.ENTITY_PLACE, blockposition1); EnderDragonBattle enderdragonbattle = ((WorldServer) world).getDragonBattle(); - diff --git a/nms-patches/net/minecraft/world/item/ItemEnderEye.patch b/nms-patches/net/minecraft/world/item/ItemEnderEye.patch index cbe435bc1..faeb51ef4 100644 --- a/nms-patches/net/minecraft/world/item/ItemEnderEye.patch +++ b/nms-patches/net/minecraft/world/item/ItemEnderEye.patch @@ -11,5 +11,5 @@ + } + // CraftBukkit end if (entityhuman instanceof EntityPlayer) { - CriterionTriggers.m.a((EntityPlayer) entityhuman, blockposition); + CriterionTriggers.USED_ENDER_EYE.a((EntityPlayer) entityhuman, blockposition); } diff --git a/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch b/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch index 63c7e2387..fec4ced19 100644 --- a/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch +++ b/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch @@ -4,14 +4,14 @@ public InteractionResultWrapper a(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.b(enumhand); -- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.RANDOM.nextFloat() * 0.4F + 0.8F)); +- 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); + // CraftBukkit start - change order if (!world.isClientSide) { EntityEnderPearl entityenderpearl = new EntityEnderPearl(world, entityhuman); entityenderpearl.setItem(itemstack); - entityenderpearl.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F); + entityenderpearl.a(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F); - world.addEntity(entityenderpearl); + if (!world.addEntity(entityenderpearl)) { + if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { @@ -21,10 +21,10 @@ + } } -+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.RANDOM.nextFloat() * 0.4F + 0.8F)); ++ 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); + // CraftBukkit end + entityhuman.b(StatisticList.ITEM_USED.b(this)); - if (!entityhuman.abilities.canInstantlyBuild) { + if (!entityhuman.getAbilities().instabuild) { itemstack.subtract(1); diff --git a/nms-patches/net/minecraft/world/item/ItemFireball.patch b/nms-patches/net/minecraft/world/item/ItemFireball.patch index b4a3e5083..11a75bc98 100644 --- a/nms-patches/net/minecraft/world/item/ItemFireball.patch +++ b/nms-patches/net/minecraft/world/item/ItemFireball.patch @@ -1,26 +1,12 @@ --- a/net/minecraft/world/item/ItemFireball.java +++ b/net/minecraft/world/item/ItemFireball.java -@@ -26,12 +26,28 @@ - boolean flag = false; - - if (BlockCampfire.h(iblockdata)) { -+ // 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().abilities.canInstantlyBuild) { -+ itemactioncontext.getItemStack().subtract(1); -+ } -+ return EnumInteractionResult.PASS; -+ } -+ // CraftBukkit end - this.a(world, blockposition); - world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockCampfire.LIT, true)); - flag = true; - } else { +@@ -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.f())) { + if (BlockFireAbstract.a(world, blockposition, itemactioncontext.g())) { + // 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().abilities.canInstantlyBuild) { ++ if (!itemactioncontext.getEntity().getAbilities().instabuild) { + itemactioncontext.getItemStack().subtract(1); + } + return EnumInteractionResult.PASS; @@ -28,4 +14,18 @@ + // CraftBukkit end this.a(world, blockposition); world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) world, blockposition)); + world.a((Entity) itemactioncontext.getEntity(), 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); ++ } ++ 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); diff --git a/nms-patches/net/minecraft/world/item/ItemFishingRod.patch b/nms-patches/net/minecraft/world/item/ItemFishingRod.patch index e2e63aa8d..1ba65213c 100644 --- a/nms-patches/net/minecraft/world/item/ItemFishingRod.patch +++ b/nms-patches/net/minecraft/world/item/ItemFishingRod.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/item/ItemFishingRod.java +++ b/net/minecraft/world/item/ItemFishingRod.java -@@ -10,6 +10,8 @@ - import net.minecraft.world.item.enchantment.EnchantmentManager; +@@ -12,6 +12,8 @@ import net.minecraft.world.level.World; + import net.minecraft.world.level.gameevent.GameEvent; +import org.bukkit.event.player.PlayerFishEvent; // CraftBukkit + public class ItemFishingRod extends Item implements ItemVanishable { public ItemFishingRod(Item.Info item_info) { -@@ -31,12 +33,23 @@ - - world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (ItemFishingRod.RANDOM.nextFloat() * 0.4F + 0.8F)); +@@ -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); } else { -- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.RANDOM.nextFloat() * 0.4F + 0.8F)); -+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.RANDOM.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.locX(), entityhuman.locY(), entityhuman.locZ(), 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); @@ -26,10 +26,10 @@ + world.getServer().getPluginManager().callEvent(playerFishEvent); + + if (playerFishEvent.isCancelled()) { -+ entityhuman.hookedFish = null; ++ entityhuman.fishing = null; + return InteractionResultWrapper.pass(itemstack); + } -+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.RANDOM.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.addEntity(entityfishinghook); + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/item/ItemFlintAndSteel.patch b/nms-patches/net/minecraft/world/item/ItemFlintAndSteel.patch index 597328422..45d8083af 100644 --- a/nms-patches/net/minecraft/world/item/ItemFlintAndSteel.patch +++ b/nms-patches/net/minecraft/world/item/ItemFlintAndSteel.patch @@ -1,18 +1,9 @@ --- a/net/minecraft/world/item/ItemFlintAndSteel.java +++ b/net/minecraft/world/item/ItemFlintAndSteel.java -@@ -28,7 +28,7 @@ - BlockPosition blockposition = itemactioncontext.getClickPosition(); - IBlockData iblockdata = world.getType(blockposition); - -- if (BlockCampfire.h(iblockdata)) { -+ if (BlockCampfire.h(iblockdata) && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, entityhuman).isCancelled()) { // CraftBukkit - world.playSound(entityhuman, blockposition, SoundEffects.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.RANDOM.nextFloat() * 0.4F + 0.8F); - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockProperties.r, true), 11); - if (entityhuman != null) { -@@ -42,6 +42,14 @@ +@@ -36,6 +36,14 @@ BlockPosition blockposition1 = blockposition.shift(itemactioncontext.getClickedFace()); - if (BlockFireAbstract.a(world, blockposition1, itemactioncontext.f())) { + if (BlockFireAbstract.a(world, blockposition1, itemactioncontext.g())) { + // 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) -> { @@ -21,6 +12,21 @@ + return EnumInteractionResult.PASS; + } + // CraftBukkit end - world.playSound(entityhuman, blockposition1, SoundEffects.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.RANDOM.nextFloat() * 0.4F + 0.8F); + 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); +@@ -55,6 +63,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()); ++ }); ++ 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); diff --git a/nms-patches/net/minecraft/world/item/ItemHanging.patch b/nms-patches/net/minecraft/world/item/ItemHanging.patch index 596a13bed..27130fe5f 100644 --- a/nms-patches/net/minecraft/world/item/ItemHanging.patch +++ b/nms-patches/net/minecraft/world/item/ItemHanging.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/ItemHanging.java +++ b/net/minecraft/world/item/ItemHanging.java -@@ -13,6 +13,11 @@ - import net.minecraft.world.item.context.ItemActionContext; +@@ -15,6 +15,11 @@ import net.minecraft.world.level.World; + import net.minecraft.world.level.gameevent.GameEvent; +// CraftBukkit start +import org.bukkit.entity.Player; @@ -11,8 +11,8 @@ + public class ItemHanging extends Item { - private final EntityTypes a; -@@ -54,6 +59,18 @@ + private final EntityTypes type; +@@ -58,6 +63,18 @@ if (((EntityHanging) object).survives()) { if (!world.isClientSide) { @@ -29,5 +29,5 @@ + } + // CraftBukkit end ((EntityHanging) object).playPlaceSound(); + world.a((Entity) entityhuman, GameEvent.ENTITY_PLACE, blockposition); world.addEntity((Entity) object); - } diff --git a/nms-patches/net/minecraft/world/item/ItemLeash.patch b/nms-patches/net/minecraft/world/item/ItemLeash.patch index c1920256e..b67605831 100644 --- a/nms-patches/net/minecraft/world/item/ItemLeash.patch +++ b/nms-patches/net/minecraft/world/item/ItemLeash.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/ItemLeash.java +++ b/net/minecraft/world/item/ItemLeash.java @@ -14,6 +14,8 @@ - import net.minecraft.world.level.block.Block; + import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.AxisAlignedBB; +import org.bukkit.event.hanging.HangingPlaceEvent; // CraftBukkit @@ -9,10 +9,10 @@ public class ItemLeash extends Item { public ItemLeash(Item.Info item_info) { -@@ -55,7 +57,23 @@ +@@ -55,9 +57,25 @@ if (entityinsentient.getLeashHolder() == entityhuman) { if (entityleash == null) { - entityleash = EntityLeash.a(world, blockposition); + entityleash = EntityLeash.b(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); @@ -23,13 +23,15 @@ + return EnumInteractionResult.PASS; + } + // CraftBukkit end -+ } -+ + entityleash.playPlaceSound(); + } + + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, entityleash, entityhuman).isCancelled()) { + continue; - } ++ } + // CraftBukkit end - ++ entityinsentient.setLeashHolder(entityleash, true); flag = true; + } diff --git a/nms-patches/net/minecraft/world/item/ItemMilkBucket.patch b/nms-patches/net/minecraft/world/item/ItemMilkBucket.patch index b3a9cca20..43f0adc5b 100644 --- a/nms-patches/net/minecraft/world/item/ItemMilkBucket.patch +++ b/nms-patches/net/minecraft/world/item/ItemMilkBucket.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemMilkBucket.java +++ b/net/minecraft/world/item/ItemMilkBucket.java -@@ -29,7 +29,7 @@ +@@ -31,7 +31,7 @@ } if (!world.isClientSide) { diff --git a/nms-patches/net/minecraft/world/item/ItemMinecart.patch b/nms-patches/net/minecraft/world/item/ItemMinecart.patch index c22672a62..6c2de38a7 100644 --- a/nms-patches/net/minecraft/world/item/ItemMinecart.patch +++ b/nms-patches/net/minecraft/world/item/ItemMinecart.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/ItemMinecart.java +++ b/net/minecraft/world/item/ItemMinecart.java -@@ -18,6 +18,11 @@ - import net.minecraft.world.level.block.state.IBlockData; +@@ -20,6 +20,11 @@ import net.minecraft.world.level.block.state.properties.BlockPropertyTrackPosition; + import net.minecraft.world.level.gameevent.GameEvent; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -11,12 +11,12 @@ + public class ItemMinecart extends Item { - private static final IDispenseBehavior a = new DispenseBehaviorItem() { -@@ -56,14 +61,43 @@ + private static final IDispenseBehavior DISPENSE_ITEM_BEHAVIOR = new DispenseBehaviorItem() { +@@ -58,14 +63,43 @@ } } -- EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(worldserver, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).b); +- EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(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); @@ -37,15 +37,15 @@ + itemstack.add(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { + idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } + + itemstack1 = CraftItemStack.asNMSCopy(event.getItem()); -+ EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ((ItemMinecart) itemstack1.getItem()).b); ++ EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ((ItemMinecart) itemstack1.getItem()).type); if (itemstack.hasName()) { entityminecartabstract.setCustomName(itemstack.getName()); @@ -59,7 +59,7 @@ return itemstack; } -@@ -105,7 +139,12 @@ +@@ -107,7 +141,12 @@ entityminecartabstract.setCustomName(itemstack.getName()); } @@ -70,6 +70,6 @@ + } + // CraftBukkit end + if (!world.addEntity(entityminecartabstract)) return EnumInteractionResult.PASS; // CraftBukkit + world.a((Entity) itemactioncontext.getEntity(), GameEvent.ENTITY_PLACE, blockposition); } - itemstack.subtract(1); diff --git a/nms-patches/net/minecraft/world/item/ItemMonsterEgg.patch b/nms-patches/net/minecraft/world/item/ItemMonsterEgg.patch index 274272aa6..9e020d372 100644 --- a/nms-patches/net/minecraft/world/item/ItemMonsterEgg.patch +++ b/nms-patches/net/minecraft/world/item/ItemMonsterEgg.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemMonsterEgg.java +++ b/net/minecraft/world/item/ItemMonsterEgg.java -@@ -167,7 +167,7 @@ +@@ -179,7 +179,7 @@ return Optional.empty(); } else { ((EntityInsentient) object).setPositionRotation(vec3d.getX(), vec3d.getY(), vec3d.getZ(), 0.0F, 0.0F); @@ -9,7 +9,7 @@ if (itemstack.hasName()) { ((EntityInsentient) object).setCustomName(itemstack.getName()); } -@@ -176,7 +176,7 @@ +@@ -188,7 +188,7 @@ itemstack.subtract(1); } diff --git a/nms-patches/net/minecraft/world/item/ItemPotion.patch b/nms-patches/net/minecraft/world/item/ItemPotion.patch index 4039a8c57..8983ad4d6 100644 --- a/nms-patches/net/minecraft/world/item/ItemPotion.patch +++ b/nms-patches/net/minecraft/world/item/ItemPotion.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemPotion.java +++ b/net/minecraft/world/item/ItemPotion.java -@@ -46,7 +46,7 @@ +@@ -52,7 +52,7 @@ if (mobeffect.getMobEffect().isInstant()) { mobeffect.getMobEffect().applyInstantEffect(entityhuman, entityhuman, entityliving, mobeffect.getAmplifier(), 1.0D); } else { diff --git a/nms-patches/net/minecraft/world/item/ItemRecord.patch b/nms-patches/net/minecraft/world/item/ItemRecord.patch index fac390b5a..a8f658d2c 100644 --- a/nms-patches/net/minecraft/world/item/ItemRecord.patch +++ b/nms-patches/net/minecraft/world/item/ItemRecord.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemRecord.java +++ b/net/minecraft/world/item/ItemRecord.java -@@ -37,6 +37,7 @@ +@@ -43,6 +43,7 @@ ItemStack itemstack = itemactioncontext.getItemStack(); if (!world.isClientSide) { diff --git a/nms-patches/net/minecraft/world/item/ItemSkullPlayer.patch b/nms-patches/net/minecraft/world/item/ItemSkullPlayer.patch index 706caa4df..a7fd3d12e 100644 --- a/nms-patches/net/minecraft/world/item/ItemSkullPlayer.patch +++ b/nms-patches/net/minecraft/world/item/ItemSkullPlayer.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/world/item/ItemSkullPlayer.java +++ b/net/minecraft/world/item/ItemSkullPlayer.java -@@ -50,6 +50,15 @@ - nbttagcompound.set("SkullOwner", GameProfileSerializer.serialize(new NBTTagCompound(), gameprofile)); - return true; - } else { +@@ -51,6 +51,16 @@ + TileEntitySkull.a(gameprofile, (gameprofile1) -> { + nbttagcompound.set("SkullOwner", GameProfileSerializer.serialize(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()) { @@ -13,6 +14,6 @@ + } + } + // CraftBukkit end - return false; } + } diff --git a/nms-patches/net/minecraft/world/item/ItemSnowball.patch b/nms-patches/net/minecraft/world/item/ItemSnowball.patch index 96a1ac206..16355ba5a 100644 --- a/nms-patches/net/minecraft/world/item/ItemSnowball.patch +++ b/nms-patches/net/minecraft/world/item/ItemSnowball.patch @@ -4,21 +4,21 @@ public InteractionResultWrapper a(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.b(enumhand); -- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.RANDOM.nextFloat() * 0.4F + 0.8F)); +- 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)); + // CraftBukkit - moved down -+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.RANDOM.nextFloat() * 0.4F + 0.8F)); ++ // 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)); if (!world.isClientSide) { EntitySnowball entitysnowball = new EntitySnowball(world, entityhuman); entitysnowball.setItem(itemstack); - entitysnowball.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F); + entitysnowball.a(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F); - world.addEntity(entitysnowball); + if (world.addEntity(entitysnowball)) { -+ if (!entityhuman.abilities.canInstantlyBuild) { ++ if (!entityhuman.getAbilities().instabuild) { + itemstack.subtract(1); + } + -+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.RANDOM.nextFloat() * 0.4F + 0.8F)); ++ 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)); + } else if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { + ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); + } @@ -28,10 +28,10 @@ entityhuman.b(StatisticList.ITEM_USED.b(this)); + // CraftBukkit start - moved up + /* - if (!entityhuman.abilities.canInstantlyBuild) { + if (!entityhuman.getAbilities().instabuild) { itemstack.subtract(1); } + */ - return InteractionResultWrapper.a(itemstack, world.s_()); + return InteractionResultWrapper.a(itemstack, world.isClientSide()); } diff --git a/nms-patches/net/minecraft/world/item/ItemStack.patch b/nms-patches/net/minecraft/world/item/ItemStack.patch index d8177dd8a..70301487a 100644 --- a/nms-patches/net/minecraft/world/item/ItemStack.patch +++ b/nms-patches/net/minecraft/world/item/ItemStack.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -58,6 +58,39 @@ +@@ -76,6 +76,39 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -39,17 +39,17 @@ + public final class ItemStack { - public static final Codec a = RecordCodecBuilder.create((instance) -> { -@@ -71,7 +104,7 @@ + public static final Codec CODEC = RecordCodecBuilder.create((instance) -> { +@@ -89,7 +122,7 @@ }); private static final Logger LOGGER = LogManager.getLogger(); - public static final ItemStack b = new ItemStack((Item) null); -- public static final DecimalFormat c = (DecimalFormat) SystemUtils.a((Object) (new DecimalFormat("#.##")), (decimalformat) -> { -+ public static final DecimalFormat c = (DecimalFormat) SystemUtils.a((new DecimalFormat("#.##")), (decimalformat) -> { // CraftBukkit - decompile error + 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)); }); - private static final ChatModifier e = ChatModifier.a.setColor(EnumChatFormat.DARK_PURPLE).setItalic(true); -@@ -106,23 +139,42 @@ + public static final String TAG_ENCH = "Enchantments"; +@@ -142,16 +175,30 @@ this.checkEmpty(); } @@ -58,15 +58,15 @@ + if (0 < version && version < CraftMagicNumbers.INSTANCE.getDataVersion()) { + NBTTagCompound savedStack = new NBTTagCompound(); + this.save(savedStack); -+ savedStack = (NBTTagCompound) MinecraftServer.getServer().dataConverterManager.update(DataConverterTypes.ITEM_STACK, new Dynamic(DynamicOpsNBT.a, savedStack), version, CraftMagicNumbers.INSTANCE.getDataVersion()).getValue(); ++ savedStack = (NBTTagCompound) MinecraftServer.getServer().fixerUpper.update(DataConverterTypes.ITEM_STACK, new Dynamic(DynamicOpsNBT.INSTANCE, savedStack), version, CraftMagicNumbers.INSTANCE.getDataVersion()).getValue(); + this.load(savedStack); + } + } + private void checkEmpty() { -+ if (this.j && this == ItemStack.b) throw new AssertionError("TRAP"); // CraftBukkit - this.j = false; - this.j = this.isEmpty(); ++ if (this.emptyCacheFlag && this == ItemStack.EMPTY) throw new AssertionError("TRAP"); // CraftBukkit + this.emptyCacheFlag = false; + this.emptyCacheFlag = this.isEmpty(); } - private ItemStack(NBTTagCompound nbttagcompound) { @@ -76,14 +76,13 @@ this.count = nbttagcompound.getByte("Count"); if (nbttagcompound.hasKeyOfType("tag", 10)) { - this.tag = nbttagcompound.getCompound("tag"); -- this.getItem().b(nbttagcompound); + // CraftBukkit start - make defensive copy as this data may be coming from the save thread + this.tag = (NBTTagCompound) nbttagcompound.getCompound("tag").clone(); -+ this.getItem().b(this.tag); + // CraftBukkit end + this.getItem().b(this.tag); } - if (this.getItem().usesDurability()) { +@@ -159,6 +206,11 @@ this.setDamage(this.getDamage()); } @@ -95,8 +94,8 @@ this.checkEmpty(); } -@@ -152,7 +204,7 @@ - return this.j ? Items.AIR : this.item; +@@ -196,7 +248,7 @@ + return this.getItem() == item; } - public EnumInteractionResult placeItem(ItemActionContext itemactioncontext) { @@ -104,8 +103,8 @@ EntityHuman entityhuman = itemactioncontext.getEntity(); BlockPosition blockposition = itemactioncontext.getClickPosition(); ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getWorld(), blockposition, false); -@@ -160,12 +212,153 @@ - if (entityhuman != null && !entityhuman.abilities.mayBuild && !this.b(itemactioncontext.getWorld().p(), shapedetectorblock)) { +@@ -204,12 +256,153 @@ + if (entityhuman != null && !entityhuman.getAbilities().mayBuild && !this.b(itemactioncontext.getWorld().r(), shapedetectorblock)) { return EnumInteractionResult.PASS; } else { + // CraftBukkit start - handle all block place event logic here @@ -160,7 +159,7 @@ + } + world.captureTreeGeneration = false; - if (entityhuman != null && enuminteractionresult.a()) { + if (entityhuman != null && enuminteractionresult.c()) { - entityhuman.b(StatisticList.ITEM_USED.b(item)); + org.bukkit.event.block.BlockPlaceEvent placeEvent = null; + List blocks = new java.util.ArrayList<>(world.capturedBlockStates.values()); @@ -183,7 +182,7 @@ + // Brute force all possible updates + BlockPosition placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition(); + for (EnumDirection dir : EnumDirection.values()) { -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, placedPos.shift(dir))); ++ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutBlockChange(world, placedPos.shift(dir))); + } + } else { + // Change the stack to its new contents if it hasn't been tampered with. @@ -193,7 +192,7 @@ + } + + for (Map.Entry e : world.capturedTileEntities.entrySet()) { -+ world.setTileEntity(e.getKey(), e.getValue()); ++ world.setTileEntity(e.getValue()); + } + + for (BlockState blockstate : blocks) { @@ -259,7 +258,7 @@ return enuminteractionresult; } -@@ -246,6 +439,21 @@ +@@ -290,6 +483,21 @@ } i -= k; @@ -281,7 +280,7 @@ if (i <= 0) { return false; } -@@ -267,6 +475,11 @@ +@@ -311,6 +519,11 @@ if (this.isDamaged(i, t0.getRandom(), t0 instanceof EntityPlayer ? (EntityPlayer) t0 : null)) { consumer.accept(t0); Item item = this.getItem(); @@ -293,7 +292,7 @@ this.subtract(1); if (t0 instanceof EntityHuman) { -@@ -398,6 +611,17 @@ +@@ -466,6 +679,17 @@ return this.tag; } @@ -311,7 +310,7 @@ public NBTTagCompound getOrCreateTag() { if (this.tag == null) { this.setTag(new NBTTagCompound()); -@@ -561,6 +785,12 @@ +@@ -849,6 +1073,12 @@ } public void setRepairCost(int i) { @@ -324,7 +323,7 @@ this.getOrCreateTag().setInt("RepairCost", i); } -@@ -610,6 +840,13 @@ +@@ -898,6 +1128,13 @@ nbttaglist.add(nbttagcompound); } @@ -335,6 +334,6 @@ + } + // CraftBukkit end + - public IChatBaseComponent C() { + public IChatBaseComponent G() { IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).addSibling(this.getName()); diff --git a/nms-patches/net/minecraft/world/item/ItemTrident.patch b/nms-patches/net/minecraft/world/item/ItemTrident.patch index f094ea688..bc605e877 100644 --- a/nms-patches/net/minecraft/world/item/ItemTrident.patch +++ b/nms-patches/net/minecraft/world/item/ItemTrident.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemTrident.java +++ b/net/minecraft/world/item/ItemTrident.java -@@ -65,9 +65,12 @@ +@@ -68,9 +68,12 @@ if (k <= 0 || entityhuman.isInWaterOrRain()) { if (!world.isClientSide) { @@ -13,8 +13,8 @@ if (k == 0) { EntityThrownTrident entitythrowntrident = new EntityThrownTrident(world, entityhuman, itemstack); -@@ -76,16 +79,39 @@ - entitythrowntrident.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY; +@@ -79,16 +82,39 @@ + entitythrowntrident.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY; } - world.addEntity(entitythrowntrident); @@ -29,12 +29,12 @@ + itemstack.damage(1, entityhuman, (entityhuman1) -> { + entityhuman1.broadcastItemBreak(entityliving.getRaisedHand()); + }); -+ entitythrowntrident.trident = itemstack.cloneItemStack(); // SPIGOT-4511 update since damage call moved ++ entitythrowntrident.tridentItem = itemstack.cloneItemStack(); // SPIGOT-4511 update since damage call moved + // CraftBukkit end + - world.playSound((EntityHuman) null, (Entity) entitythrowntrident, SoundEffects.ITEM_TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F); - if (!entityhuman.abilities.canInstantlyBuild) { - entityhuman.inventory.f(itemstack); + world.playSound((EntityHuman) null, (Entity) entitythrowntrident, SoundEffects.TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F); + if (!entityhuman.getAbilities().instabuild) { + entityhuman.getInventory().g(itemstack); } + // CraftBukkit start - SPIGOT-5458 also need in this branch :( + } else { @@ -51,6 +51,6 @@ + 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)); + event.getPlayer().getServer().getPluginManager().callEvent(event); + // CraftBukkit end - float f = entityhuman.yaw; - float f1 = entityhuman.pitch; + float f = entityhuman.getYRot(); + float f1 = entityhuman.getXRot(); float f2 = -MathHelper.sin(f * 0.017453292F) * MathHelper.cos(f1 * 0.017453292F); diff --git a/nms-patches/net/minecraft/world/item/ItemWorldMap.patch b/nms-patches/net/minecraft/world/item/ItemWorldMap.patch index b796d7087..d4c941060 100644 --- a/nms-patches/net/minecraft/world/item/ItemWorldMap.patch +++ b/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 -@@ -30,6 +30,11 @@ +@@ -34,6 +34,11 @@ import net.minecraft.world.level.material.MaterialMapColor; import net.minecraft.world.level.saveddata.maps.WorldMap; @@ -11,25 +11,24 @@ + public class ItemWorldMap extends ItemWorldMapBase { - public ItemWorldMap(Item.Info item_info) { -@@ -62,7 +67,7 @@ - public static int d(ItemStack itemstack) { + public static final int IMAGE_WIDTH = 128; +@@ -68,7 +73,7 @@ + public static Integer d(ItemStack itemstack) { NBTTagCompound nbttagcompound = itemstack.getTag(); -- return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : 0; +- 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 } - private static WorldMap a(ItemStack itemstack, World world, int i, int j, int k, boolean flag, boolean flag1, ResourceKey resourcekey) { -@@ -72,6 +77,11 @@ - worldmap.a(i, j, k, flag, flag1, resourcekey); - world.a(worldmap); - itemstack.getOrCreateTag().setInt("map", l); -+ + private static int a(World world, int i, int j, int k, boolean flag, boolean flag1, ResourceKey resourcekey) { +@@ -76,6 +81,10 @@ + int l = world.getWorldMapCount(); + + world.a(a(l), worldmap); + // CraftBukkit start + MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView); + Bukkit.getServer().getPluginManager().callEvent(event); + // CraftBukkit end - return worldmap; + return l; } diff --git a/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch b/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch index 7dafb9148..e8ebbdd9c 100644 --- a/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch +++ b/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch @@ -8,17 +8,17 @@ + public class CraftingManager extends ResourceDataJson { - private static final Gson a = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create(); + private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create(); private static final Logger LOGGER = LogManager.getLogger(); - public Map, Map>> recipes = ImmutableMap.of(); + public Map, Object2ObjectLinkedOpenHashMap>> recipes = ImmutableMap.of(); // CraftBukkit - private boolean d; + private boolean hasErrors; public CraftingManager() { @@ -47,7 +49,12 @@ protected void a(Map map, IResourceManager iresourcemanager, GameProfilerFiller gameprofilerfiller) { - this.d = false; + this.hasErrors = false; - Map, Builder>> map1 = Maps.newHashMap(); + // CraftBukkit start - SPIGOT-5667 make sure all types are populated and mutable + Map, Object2ObjectLinkedOpenHashMap>> map1 = Maps.newHashMap(); @@ -29,7 +29,7 @@ Iterator iterator = map.entrySet().iterator(); while (iterator.hasNext()) { -@@ -57,24 +64,42 @@ +@@ -57,28 +64,46 @@ try { IRecipe irecipe = a(minecraftkey, ChatDeserializer.m((JsonElement) entry.getValue(), "top element")); @@ -65,6 +65,10 @@ + } + // CraftBukkit end + + public boolean a() { + return this.hasErrors; + } + public > Optional craft(Recipes recipes, C c0, World world) { - return this.b(recipes).values().stream().flatMap((irecipe) -> { + // CraftBukkit start @@ -77,7 +81,7 @@ } public > List a(Recipes recipes) { -@@ -92,7 +117,7 @@ +@@ -96,7 +121,7 @@ } private > Map> b(Recipes recipes) { @@ -86,7 +90,7 @@ } public > NonNullList c(Recipes recipes, C c0, World world) { -@@ -113,7 +138,7 @@ +@@ -117,7 +142,7 @@ public Optional> getRecipe(MinecraftKey minecraftkey) { return this.recipes.values().stream().map((map) -> { @@ -95,9 +99,23 @@ }).filter(Objects::nonNull).findFirst(); } -@@ -136,4 +161,14 @@ - return new JsonSyntaxException("Invalid or unsupported recipe type '" + s + "'"); - })).a(minecraftkey, jsonobject); +@@ -143,11 +168,11 @@ + + public void a(Iterable> iterable) { + this.hasErrors = false; +- Map, Map>> map = Maps.newHashMap(); ++ Map, Object2ObjectLinkedOpenHashMap>> map = Maps.newHashMap(); // CraftBukkit + + iterable.forEach((irecipe) -> { + Map> map1 = (Map) map.computeIfAbsent(irecipe.g(), (recipes) -> { +- return Maps.newHashMap(); ++ return new Object2ObjectLinkedOpenHashMap<>(); // CraftBukkit + }); + IRecipe irecipe1 = (IRecipe) map1.put(irecipe.getKey(), irecipe); + +@@ -157,4 +182,14 @@ + }); + this.recipes = ImmutableMap.copyOf(map); } + + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/item/crafting/FurnaceRecipe.patch b/nms-patches/net/minecraft/world/item/crafting/FurnaceRecipe.patch index af5b89606..722ddeae6 100644 --- a/nms-patches/net/minecraft/world/item/crafting/FurnaceRecipe.patch +++ b/nms-patches/net/minecraft/world/item/crafting/FurnaceRecipe.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/crafting/FurnaceRecipe.java +++ b/net/minecraft/world/item/crafting/FurnaceRecipe.java -@@ -3,6 +3,14 @@ - import net.minecraft.resources.MinecraftKey; +@@ -4,6 +4,14 @@ import net.minecraft.world.item.ItemStack; + import net.minecraft.world.level.block.Blocks; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftFurnaceRecipe; @@ -15,16 +15,16 @@ public class FurnaceRecipe extends RecipeCooking { public FurnaceRecipe(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { -@@ -13,4 +21,14 @@ +@@ -19,4 +27,14 @@ public RecipeSerializer getRecipeSerializer() { - return RecipeSerializer.p; + return RecipeSerializer.SMELTING_RECIPE; } + + @Override + public Recipe toBukkitRecipe() { + CraftItemStack result = CraftItemStack.asCraftMirror(this.result); + -+ CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); ++ CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); + recipe.setGroup(this.group); + + return recipe; diff --git a/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch b/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch index c9f4d01a8..117f8dcd5 100644 --- a/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch +++ b/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/item/crafting/IRecipe.java +++ b/net/minecraft/world/item/crafting/IRecipe.java -@@ -42,4 +42,6 @@ - RecipeSerializer getRecipeSerializer(); - - Recipes g(); +@@ -61,4 +61,6 @@ + return recipeitemstack.a().length == 0; + }); + } + + org.bukkit.inventory.Recipe toBukkitRecipe(); // CraftBukkit } diff --git a/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch b/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch index 560745f40..5923a75e6 100644 --- a/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch +++ b/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/item/crafting/IRecipeComplex.java @@ -25,4 +25,11 @@ public ItemStack getResult() { - return ItemStack.b; + return ItemStack.EMPTY; } + + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/item/crafting/RecipeBlasting.patch b/nms-patches/net/minecraft/world/item/crafting/RecipeBlasting.patch index f8d6acfcb..3ed5e62ad 100644 --- a/nms-patches/net/minecraft/world/item/crafting/RecipeBlasting.patch +++ b/nms-patches/net/minecraft/world/item/crafting/RecipeBlasting.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/crafting/RecipeBlasting.java +++ b/net/minecraft/world/item/crafting/RecipeBlasting.java -@@ -3,6 +3,14 @@ - import net.minecraft.resources.MinecraftKey; +@@ -4,6 +4,14 @@ import net.minecraft.world.item.ItemStack; + import net.minecraft.world.level.block.Blocks; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftBlastingRecipe; @@ -15,9 +15,9 @@ public class RecipeBlasting extends RecipeCooking { public RecipeBlasting(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { -@@ -13,4 +21,16 @@ +@@ -19,4 +27,16 @@ public RecipeSerializer getRecipeSerializer() { - return RecipeSerializer.q; + return RecipeSerializer.BLASTING_RECIPE; } + + // CraftBukkit start @@ -25,7 +25,7 @@ + public Recipe toBukkitRecipe() { + CraftItemStack result = CraftItemStack.asCraftMirror(this.result); + -+ CraftBlastingRecipe recipe = new CraftBlastingRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); ++ CraftBlastingRecipe recipe = new CraftBlastingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); + recipe.setGroup(this.group); + + return recipe; diff --git a/nms-patches/net/minecraft/world/item/crafting/RecipeCampfire.patch b/nms-patches/net/minecraft/world/item/crafting/RecipeCampfire.patch index 10010627b..9c7cfcb8e 100644 --- a/nms-patches/net/minecraft/world/item/crafting/RecipeCampfire.patch +++ b/nms-patches/net/minecraft/world/item/crafting/RecipeCampfire.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/crafting/RecipeCampfire.java +++ b/net/minecraft/world/item/crafting/RecipeCampfire.java -@@ -3,6 +3,14 @@ - import net.minecraft.resources.MinecraftKey; +@@ -4,6 +4,14 @@ import net.minecraft.world.item.ItemStack; + import net.minecraft.world.level.block.Blocks; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftCampfireRecipe; @@ -15,9 +15,9 @@ public class RecipeCampfire extends RecipeCooking { public RecipeCampfire(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { -@@ -13,4 +21,16 @@ +@@ -19,4 +27,16 @@ public RecipeSerializer getRecipeSerializer() { - return RecipeSerializer.s; + return RecipeSerializer.CAMPFIRE_COOKING_RECIPE; } + + // CraftBukkit start @@ -25,7 +25,7 @@ + public Recipe toBukkitRecipe() { + CraftItemStack result = CraftItemStack.asCraftMirror(this.result); + -+ CraftCampfireRecipe recipe = new CraftCampfireRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); ++ CraftCampfireRecipe recipe = new CraftCampfireRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); + recipe.setGroup(this.group); + + return recipe; diff --git a/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch b/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch index 2d4edf4b5..7ed9bf66c 100644 --- a/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch +++ b/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/item/crafting/RecipeItemStack.java +++ b/net/minecraft/world/item/crafting/RecipeItemStack.java @@ -35,6 +35,7 @@ - private final RecipeItemStack.Provider[] b; - public ItemStack[] choices; - private IntList d; + private final RecipeItemStack.Provider[] values; + public ItemStack[] itemStacks; + private IntList stackingIds; + public boolean exact; // CraftBukkit public RecipeItemStack(Stream stream) { - this.b = (RecipeItemStack.Provider[]) stream.toArray((i) -> { -@@ -67,6 +68,15 @@ + this.values = (RecipeItemStack.Provider[]) stream.toArray((i) -> { +@@ -72,6 +73,15 @@ for (int j = 0; j < i; ++j) { ItemStack itemstack1 = aitemstack[j]; @@ -21,6 +21,15 @@ + continue; + } + // CraftBukkit end - if (itemstack1.getItem() == itemstack.getItem()) { + if (itemstack1.a(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/nms-patches/net/minecraft/world/item/crafting/RecipeSmithing.patch b/nms-patches/net/minecraft/world/item/crafting/RecipeSmithing.patch index 3bc533f53..632e74c8a 100644 --- a/nms-patches/net/minecraft/world/item/crafting/RecipeSmithing.patch +++ b/nms-patches/net/minecraft/world/item/crafting/RecipeSmithing.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/crafting/RecipeSmithing.java +++ b/net/minecraft/world/item/crafting/RecipeSmithing.java -@@ -10,6 +10,14 @@ - import net.minecraft.world.item.ItemStack; +@@ -12,6 +12,14 @@ import net.minecraft.world.level.World; + import net.minecraft.world.level.block.Blocks; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -14,17 +14,17 @@ + public class RecipeSmithing implements IRecipe { - private final RecipeItemStack a; -@@ -65,6 +73,17 @@ - return Recipes.SMITHING; + final RecipeItemStack base; +@@ -84,6 +92,17 @@ + }); } + // CraftBukkit start + @Override + public Recipe toBukkitRecipe() { -+ CraftItemStack result = CraftItemStack.asCraftMirror(this.c); ++ CraftItemStack result = CraftItemStack.asCraftMirror(this.result); + -+ CraftSmithingRecipe recipe = new CraftSmithingRecipe(CraftNamespacedKey.fromMinecraft(this.d), result, CraftRecipe.toBukkit(this.a), CraftRecipe.toBukkit(this.b)); ++ CraftSmithingRecipe recipe = new CraftSmithingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition)); + + return recipe; + } diff --git a/nms-patches/net/minecraft/world/item/crafting/RecipeSmoking.patch b/nms-patches/net/minecraft/world/item/crafting/RecipeSmoking.patch index 4debf4927..147979a56 100644 --- a/nms-patches/net/minecraft/world/item/crafting/RecipeSmoking.patch +++ b/nms-patches/net/minecraft/world/item/crafting/RecipeSmoking.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/crafting/RecipeSmoking.java +++ b/net/minecraft/world/item/crafting/RecipeSmoking.java -@@ -3,6 +3,14 @@ - import net.minecraft.resources.MinecraftKey; +@@ -4,6 +4,14 @@ import net.minecraft.world.item.ItemStack; + import net.minecraft.world.level.block.Blocks; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -15,9 +15,9 @@ public class RecipeSmoking extends RecipeCooking { public RecipeSmoking(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { -@@ -13,4 +21,16 @@ +@@ -19,4 +27,16 @@ public RecipeSerializer getRecipeSerializer() { - return RecipeSerializer.r; + return RecipeSerializer.SMOKING_RECIPE; } + + // CraftBukkit start @@ -25,7 +25,7 @@ + public Recipe toBukkitRecipe() { + CraftItemStack result = CraftItemStack.asCraftMirror(this.result); + -+ CraftSmokingRecipe recipe = new CraftSmokingRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); ++ CraftSmokingRecipe recipe = new CraftSmokingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); + recipe.setGroup(this.group); + + return recipe; diff --git a/nms-patches/net/minecraft/world/item/crafting/RecipeStonecutting.patch b/nms-patches/net/minecraft/world/item/crafting/RecipeStonecutting.patch index bb994f7c0..5f64088fe 100644 --- a/nms-patches/net/minecraft/world/item/crafting/RecipeStonecutting.patch +++ b/nms-patches/net/minecraft/world/item/crafting/RecipeStonecutting.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/crafting/RecipeStonecutting.java +++ b/net/minecraft/world/item/crafting/RecipeStonecutting.java -@@ -5,6 +5,14 @@ - import net.minecraft.world.item.ItemStack; +@@ -6,6 +6,14 @@ import net.minecraft.world.level.World; + import net.minecraft.world.level.block.Blocks; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -15,9 +15,9 @@ public class RecipeStonecutting extends RecipeSingleItem { public RecipeStonecutting(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack) { -@@ -15,4 +23,16 @@ - public boolean a(IInventory iinventory, World world) { - return this.ingredient.test(iinventory.getItem(0)); +@@ -21,4 +29,16 @@ + public ItemStack h() { + return new ItemStack(Blocks.STONECUTTER); } + + // CraftBukkit start @@ -25,7 +25,7 @@ + public Recipe toBukkitRecipe() { + CraftItemStack result = CraftItemStack.asCraftMirror(this.result); + -+ CraftStonecuttingRecipe recipe = new CraftStonecuttingRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient)); ++ CraftStonecuttingRecipe recipe = new CraftStonecuttingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient)); + recipe.setGroup(this.group); + + return recipe; diff --git a/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch b/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch index cc580fa99..c1d9aafa4 100644 --- a/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch +++ b/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/crafting/ShapedRecipes.java +++ b/net/minecraft/world/item/crafting/ShapedRecipes.java -@@ -22,6 +22,13 @@ - import net.minecraft.world.item.ItemStack; +@@ -23,6 +23,13 @@ + import net.minecraft.world.item.Items; import net.minecraft.world.level.World; +// CraftBukkit start @@ -13,8 +13,8 @@ + public class ShapedRecipes implements RecipeCrafting { - private final int width; -@@ -40,6 +47,66 @@ + final int width; +@@ -41,6 +48,66 @@ this.result = itemstack; } @@ -66,7 +66,7 @@ + break; + } + char c = 'a'; -+ for (RecipeItemStack list : this.items) { ++ for (RecipeItemStack list : this.recipeItems) { + RecipeChoice choice = CraftRecipe.toBukkit(list); + if (choice != null) { + recipe.setIngredient(c, choice); @@ -80,4 +80,4 @@ + @Override public MinecraftKey getKey() { - return this.key; + return this.id; diff --git a/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch b/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch index 1de17e0cd..68cd5d8cb 100644 --- a/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch +++ b/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch @@ -12,7 +12,7 @@ + public class ShapelessRecipes implements RecipeCrafting { - private final MinecraftKey key; + private final MinecraftKey id; @@ -28,6 +34,20 @@ this.ingredients = nonnulllist; } @@ -33,4 +33,4 @@ + @Override public MinecraftKey getKey() { - return this.key; + return this.id; diff --git a/nms-patches/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.patch b/nms-patches/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.patch index 397d05ec4..20756e31e 100644 --- a/nms-patches/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.patch +++ b/nms-patches/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.java +++ b/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.java -@@ -60,7 +60,7 @@ - if (this.a == 2 && entityliving1.getMonsterType() == EnumMonsterType.ARTHROPOD) { +@@ -63,7 +63,7 @@ + if (this.type == 2 && i > 0 && entityliving1.getMonsterType() == EnumMonsterType.ARTHROPOD) { int j = 20 + entityliving.getRandom().nextInt(10 * i); -- entityliving1.addEffect(new MobEffect(MobEffects.SLOWER_MOVEMENT, j, 3)); -+ entityliving1.addEffect(new MobEffect(MobEffects.SLOWER_MOVEMENT, j, 3), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit +- entityliving1.addEffect(new MobEffect(MobEffects.MOVEMENT_SLOWDOWN, j, 3)); ++ entityliving1.addEffect(new MobEffect(MobEffects.MOVEMENT_SLOWDOWN, j, 3), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } } diff --git a/nms-patches/net/minecraft/world/item/enchantment/Enchantments.patch b/nms-patches/net/minecraft/world/item/enchantment/Enchantments.patch index 84cff388e..6ebf47518 100644 --- a/nms-patches/net/minecraft/world/item/enchantment/Enchantments.patch +++ b/nms-patches/net/minecraft/world/item/enchantment/Enchantments.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/enchantment/Enchantments.java +++ b/net/minecraft/world/item/enchantment/Enchantments.java -@@ -45,7 +45,15 @@ +@@ -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())); @@ -12,6 +12,8 @@ + } + // CraftBukkit end + + 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 diff --git a/nms-patches/net/minecraft/world/item/trading/IMerchant.patch b/nms-patches/net/minecraft/world/item/trading/IMerchant.patch index 869aef8f6..decc754b3 100644 --- a/nms-patches/net/minecraft/world/item/trading/IMerchant.patch +++ b/nms-patches/net/minecraft/world/item/trading/IMerchant.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/trading/IMerchant.java +++ b/net/minecraft/world/item/trading/IMerchant.java -@@ -51,4 +51,6 @@ +@@ -53,4 +53,6 @@ } } diff --git a/nms-patches/net/minecraft/world/item/trading/MerchantRecipe.patch b/nms-patches/net/minecraft/world/item/trading/MerchantRecipe.patch index 7223cdc7b..ba1888980 100644 --- a/nms-patches/net/minecraft/world/item/trading/MerchantRecipe.patch +++ b/nms-patches/net/minecraft/world/item/trading/MerchantRecipe.patch @@ -8,7 +8,7 @@ + public class MerchantRecipe { - public ItemStack buyingItem1; + public ItemStack baseCostA; @@ -17,6 +19,18 @@ private int demand; public float priceMultiplier; @@ -31,8 +31,8 @@ @@ -78,6 +92,7 @@ public ItemStack getBuyItem1() { - int i = this.buyingItem1.getCount(); -+ if (i <= 0) return ItemStack.b; // CraftBukkit - SPIGOT-5476 - ItemStack itemstack = this.buyingItem1.cloneItemStack(); + 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)); diff --git a/nms-patches/net/minecraft/world/level/CommandBlockListenerAbstract.patch b/nms-patches/net/minecraft/world/level/CommandBlockListenerAbstract.patch index 5d492152f..75efcf6e1 100644 --- a/nms-patches/net/minecraft/world/level/CommandBlockListenerAbstract.patch +++ b/nms-patches/net/minecraft/world/level/CommandBlockListenerAbstract.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/level/CommandBlockListenerAbstract.java +++ b/net/minecraft/world/level/CommandBlockListenerAbstract.java -@@ -30,6 +30,10 @@ +@@ -31,6 +31,10 @@ private IChatBaseComponent lastOutput; private String command = ""; - private IChatBaseComponent customName; + private IChatBaseComponent name; + // CraftBukkit start + @Override + public abstract org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper); + // CraftBukkit end public CommandBlockListenerAbstract() { - this.customName = CommandBlockListenerAbstract.c; -@@ -126,7 +130,7 @@ + this.name = CommandBlockListenerAbstract.DEFAULT_NAME; +@@ -127,7 +131,7 @@ }); diff --git a/nms-patches/net/minecraft/world/level/Explosion.patch b/nms-patches/net/minecraft/world/level/Explosion.patch index eec5ebbc1..843583f2e 100644 --- a/nms-patches/net/minecraft/world/level/Explosion.patch +++ b/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 -@@ -42,6 +42,14 @@ +@@ -43,6 +43,14 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.Vec3D; @@ -14,43 +14,46 @@ + public class Explosion { - private static final ExplosionDamageCalculator a = new ExplosionDamageCalculator(); -@@ -59,11 +67,12 @@ - private final ExplosionDamageCalculator l; - private final List blocks = Lists.newArrayList(); - private final Map n = Maps.newHashMap(); + private static final ExplosionDamageCalculator EXPLOSION_DAMAGE_CALCULATOR = new ExplosionDamageCalculator(); +@@ -61,6 +69,7 @@ + private final ExplosionDamageCalculator damageCalculator; + private final List toBlow; + private final Map hitPlayers; + public boolean wasCanceled = false; // CraftBukkit - add field - public Explosion(World world, @Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) { - this.world = world; + 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 @@ + this.hitPlayers = Maps.newHashMap(); + this.level = world; this.source = entity; -- this.size = f; -+ this.size = (float) Math.max(f, 0.0); // CraftBukkit - clamp bad values - this.posX = d0; - this.posY = d1; - this.posZ = d2; -@@ -113,6 +122,11 @@ +- this.radius = f; ++ this.radius = (float) Math.max(f, 0.0); // CraftBukkit - clamp bad values + this.x = d0; + this.y = d1; + this.z = d2; +@@ -135,6 +144,11 @@ } public void a() { + // CraftBukkit start -+ if (this.size < 0.1F) { ++ if (this.radius < 0.1F) { + return; + } + // CraftBukkit end + this.level.a(this.source, GameEvent.EXPLODE, new BlockPosition(this.x, this.y, this.z)); Set set = Sets.newHashSet(); boolean flag = true; - -@@ -146,7 +160,7 @@ +@@ -174,7 +188,7 @@ f -= ((Float) optional.get() + 0.3F) * 0.3F; } -- if (f > 0.0F && this.l.a(this, this.world, blockposition, iblockdata, f)) { -+ if (f > 0.0F && this.l.a(this, this.world, blockposition, iblockdata, f) && blockposition.getY() < 256 && blockposition.getY() >= 0) { // CraftBukkit - don't wrap explosions +- if (f > 0.0F && this.damageCalculator.a(this, this.level, blockposition, iblockdata, f)) { ++ if (f > 0.0F && this.damageCalculator.a(this, this.level, blockposition, iblockdata, f) && blockposition.getY() < 256 && blockposition.getY() >= 0) { // CraftBukkit - don't wrap explosions set.add(blockposition); } -@@ -190,7 +204,16 @@ +@@ -218,7 +232,16 @@ double d12 = (double) a(vec3d, entity); double d13 = (1.0D - d7) * d12; @@ -68,18 +71,18 @@ double d14 = d13; if (entity instanceof EntityLiving) { -@@ -232,6 +255,51 @@ +@@ -260,6 +283,51 @@ - Collections.shuffle(this.blocks, this.world.random); - Iterator iterator = this.blocks.iterator(); + Collections.shuffle(this.toBlow, this.level.random); + Iterator iterator = this.toBlow.iterator(); + // CraftBukkit start -+ org.bukkit.World bworld = this.world.getWorld(); ++ org.bukkit.World bworld = this.level.getWorld(); + org.bukkit.entity.Entity explode = this.source == null ? null : this.source.getBukkitEntity(); -+ Location location = new Location(bworld, this.posX, this.posY, this.posZ); ++ Location location = new Location(bworld, this.x, this.y, this.z); + + List blockList = Lists.newArrayList(); -+ for (int i1 = this.blocks.size() - 1; i1 >= 0; i1--) { -+ BlockPosition cpos = (BlockPosition) this.blocks.get(i1); ++ for (int i1 = this.toBlow.size() - 1; i1 >= 0; i1--) { ++ BlockPosition cpos = (BlockPosition) this.toBlow.get(i1); + org.bukkit.block.Block bblock = bworld.getBlockAt(cpos.getX(), cpos.getY(), cpos.getZ()); + if (!bblock.getType().isAir()) { + blockList.add(bblock); @@ -91,24 +94,24 @@ + float yield; + + if (explode != null) { -+ EntityExplodeEvent event = new EntityExplodeEvent(explode, location, blockList, this.c == Explosion.Effect.DESTROY ? 1.0F / this.size : 1.0F); -+ this.world.getServer().getPluginManager().callEvent(event); ++ EntityExplodeEvent event = new EntityExplodeEvent(explode, location, blockList, this.blockInteraction == Explosion.Effect.DESTROY ? 1.0F / this.radius : 1.0F); ++ this.level.getServer().getPluginManager().callEvent(event); + cancelled = event.isCancelled(); + bukkitBlocks = event.blockList(); + yield = event.getYield(); + } else { -+ BlockExplodeEvent event = new BlockExplodeEvent(location.getBlock(), blockList, this.c == Explosion.Effect.DESTROY ? 1.0F / this.size : 1.0F); -+ this.world.getServer().getPluginManager().callEvent(event); ++ BlockExplodeEvent event = new BlockExplodeEvent(location.getBlock(), blockList, this.blockInteraction == Explosion.Effect.DESTROY ? 1.0F / this.radius : 1.0F); ++ this.level.getServer().getPluginManager().callEvent(event); + cancelled = event.isCancelled(); + bukkitBlocks = event.blockList(); + yield = event.getYield(); + } + -+ this.blocks.clear(); ++ this.toBlow.clear(); + + for (org.bukkit.block.Block bblock : bukkitBlocks) { + BlockPosition coords = new BlockPosition(bblock.getX(), bblock.getY(), bblock.getZ()); -+ blocks.add(coords); ++ toBlow.add(coords); + } + + if (cancelled) { @@ -116,35 +119,35 @@ + return; + } + // CraftBukkit end -+ iterator = this.blocks.iterator(); ++ iterator = this.toBlow.iterator(); while (iterator.hasNext()) { BlockPosition blockposition = (BlockPosition) iterator.next(); -@@ -246,8 +314,8 @@ - TileEntity tileentity = block.isTileEntity() ? this.world.getTileEntity(blockposition) : null; - LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.world)).a(this.world.random).set(LootContextParameters.ORIGIN, Vec3D.a((BaseBlockPosition) blockposition)).set(LootContextParameters.TOOL, ItemStack.b).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity).setOptional(LootContextParameters.THIS_ENTITY, this.source); +@@ -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); -- if (this.c == Explosion.Effect.DESTROY) { -- loottableinfo_builder.set(LootContextParameters.EXPLOSION_RADIUS, this.size); -+ if (this.c == Explosion.Effect.DESTROY || yield < 1.0F) { // CraftBukkit - add yield +- if (this.blockInteraction == Explosion.Effect.DESTROY) { +- loottableinfo_builder.set(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 } iblockdata.a(loottableinfo_builder).forEach((itemstack) -> { -@@ -277,7 +345,11 @@ +@@ -305,7 +373,11 @@ BlockPosition blockposition2 = (BlockPosition) iterator1.next(); - if (this.d.nextInt(3) == 0 && this.world.getType(blockposition2).isAir() && this.world.getType(blockposition2.down()).i(this.world, blockposition2.down())) { -- this.world.setTypeUpdate(blockposition2, BlockFireAbstract.a((IBlockAccess) this.world, blockposition2)); + 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)); + // CraftBukkit start - Ignition by explosion -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.world, blockposition2.getX(), blockposition2.getY(), blockposition2.getZ(), this).isCancelled()) { -+ this.world.setTypeUpdate(blockposition2, BlockFireAbstract.a((IBlockAccess) this.world, blockposition2)); ++ 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)); + } + // CraftBukkit end } } } -@@ -285,6 +357,7 @@ +@@ -313,6 +385,7 @@ } private static void a(ObjectArrayList> objectarraylist, ItemStack itemstack, BlockPosition blockposition) { diff --git a/nms-patches/net/minecraft/world/level/GameRules.patch b/nms-patches/net/minecraft/world/level/GameRules.patch index bfb8f210b..909345c31 100644 --- a/nms-patches/net/minecraft/world/level/GameRules.patch +++ b/nms-patches/net/minecraft/world/level/GameRules.patch @@ -1,15 +1,24 @@ --- a/net/minecraft/world/level/GameRules.java +++ b/net/minecraft/world/level/GameRules.java -@@ -113,7 +113,7 @@ +@@ -118,7 +118,7 @@ } public > T get(GameRules.GameRuleKey gamerules_gamerulekey) { -- return (GameRules.GameRuleValue) this.J.get(gamerules_gamerulekey); -+ return (T) this.J.get(gamerules_gamerulekey); // CraftBukkit - decompile error +- return (GameRules.GameRuleValue) this.rules.get(gamerules_gamerulekey); ++ return (T) this.rules.get(gamerules_gamerulekey); // CraftBukkit - decompile error } public NBTTagCompound a() { -@@ -144,8 +144,8 @@ +@@ -132,7 +132,7 @@ + + private void a(DynamicLike dynamiclike) { + this.rules.forEach((gamerules_gamerulekey, gamerules_gamerulevalue) -> { +- Optional optional = dynamiclike.get(gamerules_gamerulekey.id).asString().result(); ++ Optional optional = dynamiclike.get(gamerules_gamerulekey.id).asString().result(); // CraftBukkit - decompile error + + Objects.requireNonNull(gamerules_gamerulevalue); + optional.ifPresent(gamerules_gamerulevalue::setValue); +@@ -152,8 +152,8 @@ } private static > void a(GameRules.GameRuleVisitor gamerules_gamerulevisitor, GameRules.GameRuleKey gamerules_gamerulekey, GameRules.GameRuleDefinition gamerules_gameruledefinition) { @@ -19,26 +28,17 @@ + ((GameRules.GameRuleDefinition) gamerules_gameruledefinition).a(gamerules_gamerulevisitor, (GameRules.GameRuleKey) gamerules_gamerulekey); // CraftBukkit - decompile error } - public boolean getBoolean(GameRules.GameRuleKey gamerules_gamerulekey) { -@@ -196,7 +196,7 @@ + public void a(GameRules gamerules, @Nullable MinecraftServer minecraftserver) { +@@ -245,7 +245,7 @@ } - @Override -- protected void setValue(String s) { -+ public void setValue(String s) { // PAIL - protected->public - this.b = Boolean.parseBoolean(s); + public T getValue() { +- return (GameRules.GameRuleValue) this.constructor.apply(this); ++ return this.constructor.apply(this); // CraftBukkit - decompile error } -@@ -251,7 +251,7 @@ - } - - @Override -- protected void setValue(String s) { -+ public void setValue(String s) { // PAIL - protected->public - this.b = c(s); - } - -@@ -305,7 +305,7 @@ + public void a(GameRules.GameRuleVisitor gamerules_gamerulevisitor, GameRules.GameRuleKey gamerules_gamerulekey) { +@@ -275,7 +275,7 @@ } @@ -47,12 +47,21 @@ public abstract String getValue(); -@@ -339,7 +339,7 @@ +@@ -341,7 +341,7 @@ } - public T getValue() { -- return (GameRules.GameRuleValue) this.b.apply(this); -+ return this.b.apply(this); // CraftBukkit - decompile error + @Override +- protected void setValue(String s) { ++ public void setValue(String s) { // PAIL - protected->public + this.value = Boolean.parseBoolean(s); + } + +@@ -406,7 +406,7 @@ + } + + @Override +- protected void setValue(String s) { ++ public void setValue(String s) { // PAIL - protected->public + this.value = c(s); } - public void a(GameRules.GameRuleVisitor gamerules_gamerulevisitor, GameRules.GameRuleKey gamerules_gamerulekey) { diff --git a/nms-patches/net/minecraft/world/level/GeneratorAccess.patch b/nms-patches/net/minecraft/world/level/GeneratorAccess.patch index 5373af994..7a933272c 100644 --- a/nms-patches/net/minecraft/world/level/GeneratorAccess.patch +++ b/nms-patches/net/minecraft/world/level/GeneratorAccess.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/GeneratorAccess.java +++ b/net/minecraft/world/level/GeneratorAccess.java -@@ -57,4 +57,6 @@ - default void triggerEffect(int i, BlockPosition blockposition, int j) { - this.a((EntityHuman) null, i, blockposition, j); +@@ -77,4 +77,6 @@ + default void a(@Nullable Entity entity, GameEvent gameevent, Entity entity1) { + this.a(entity, gameevent, entity1.getChunkCoordinates()); } + + net.minecraft.server.level.WorldServer getMinecraftWorld(); // CraftBukkit diff --git a/nms-patches/net/minecraft/world/level/IBlockAccess.patch b/nms-patches/net/minecraft/world/level/IBlockAccess.patch index e430a7b02..7b8f505ff 100644 --- a/nms-patches/net/minecraft/world/level/IBlockAccess.patch +++ b/nms-patches/net/minecraft/world/level/IBlockAccess.patch @@ -1,17 +1,26 @@ --- a/net/minecraft/world/level/IBlockAccess.java +++ b/net/minecraft/world/level/IBlockAccess.java -@@ -41,8 +41,8 @@ - return BlockPosition.a(axisalignedbb).map(this::getType); +@@ -26,7 +26,7 @@ + default Optional a(BlockPosition blockposition, TileEntityTypes tileentitytypes) { + TileEntity tileentity = this.getTileEntity(blockposition); + +- return tileentity != null && tileentity.getTileType() == tileentitytypes ? Optional.of(tileentity) : Optional.empty(); ++ return tileentity != null && tileentity.getTileType() == tileentitytypes ? (Optional) Optional.of(tileentity) : Optional.empty(); // CraftBukkit - decompile error + } + + IBlockData getType(BlockPosition blockposition); +@@ -58,8 +58,8 @@ + }); } - default MovingObjectPositionBlock rayTrace(RayTrace raytrace) { -- return (MovingObjectPositionBlock) a(raytrace, (raytrace1, blockposition) -> { +- return (MovingObjectPositionBlock) a(raytrace.b(), raytrace.a(), 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(); -@@ -55,6 +55,12 @@ +@@ -72,6 +72,12 @@ double d1 = movingobjectpositionblock1 == null ? Double.MAX_VALUE : raytrace1.b().distanceSquared(movingobjectpositionblock1.getPos()); return d0 <= d1 ? movingobjectpositionblock : movingobjectpositionblock1; @@ -19,14 +28,14 @@ + // CraftBukkit end + + default MovingObjectPositionBlock rayTrace(RayTrace raytrace) { -+ return (MovingObjectPositionBlock) a(raytrace, (raytrace1, blockposition) -> { ++ return (MovingObjectPositionBlock) a(raytrace.b(), raytrace.a(), raytrace, (raytrace1, blockposition) -> { + return this.rayTraceBlock(raytrace1, blockposition); // CraftBukkit - moved into separate method }, (raytrace1) -> { Vec3D vec3d = raytrace1.b().d(raytrace1.a()); -@@ -130,7 +136,7 @@ - double d13 = d10 * (i1 > 0 ? 1.0D - MathHelper.h(d4) : MathHelper.h(d4)); - double d14 = d11 * (j1 > 0 ? 1.0D - MathHelper.h(d5) : MathHelper.h(d5)); +@@ -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)); - Object object; + T object; // CraftBukkit - decompile error diff --git a/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch b/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch index 019f49758..81924a8a1 100644 --- a/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch +++ b/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 -@@ -60,6 +60,7 @@ +@@ -73,6 +73,7 @@ public void setMobName(EntityTypes entitytypes) { - this.spawnData.getEntity().setString("id", IRegistry.ENTITY_TYPE.getKey(entitytypes).toString()); -+ this.mobs.clear(); // CraftBukkit - SPIGOT-3496, MC-92282 + this.nextSpawnData.getEntity().setString("id", IRegistry.ENTITY_TYPE.getKey(entitytypes).toString()); ++ this.spawnPotentials = MobSpawnerAbstract.EMPTY_POTENTIALS; // CraftBukkit - SPIGOT-3496, MC-92282 } - private boolean h() { -@@ -149,7 +150,7 @@ - } + private boolean c(World world, BlockPosition blockposition) { +@@ -156,7 +157,7 @@ } + } -- if (!worldserver.addAllEntitiesSafely(entity)) { -+ if (!worldserver.addAllEntitiesSafely(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER)) { // CraftBukkit - this.i(); - return; - } +- if (!worldserver.addAllEntitiesSafely(entity)) { ++ if (!worldserver.addAllEntitiesSafely(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER)) { // CraftBukkit + this.d(worldserver, blockposition); + return; + } diff --git a/nms-patches/net/minecraft/world/level/RayTrace.patch b/nms-patches/net/minecraft/world/level/RayTrace.patch index 81b83b7c7..79b5b9d4b 100644 --- a/nms-patches/net/minecraft/world/level/RayTrace.patch +++ b/nms-patches/net/minecraft/world/level/RayTrace.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/level/RayTrace.java +++ b/net/minecraft/world/level/RayTrace.java @@ -24,7 +24,7 @@ - this.b = vec3d1; - this.c = raytrace_blockcollisionoption; - this.d = raytrace_fluidcollisionoption; -- this.e = VoxelShapeCollision.a(entity); -+ this.e = (entity == null) ? VoxelShapeCollision.a() : VoxelShapeCollision.a(entity); // CraftBukkit + 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 } public Vec3D a() { -@@ -53,7 +53,7 @@ +@@ -69,7 +69,7 @@ - private final Predicate predicate; + private final Predicate canPick; - private FluidCollisionOption(Predicate predicate) { + private FluidCollisionOption(Predicate predicate) { // CraftBukkit - decompile error - this.predicate = predicate; + this.canPick = predicate; } diff --git a/nms-patches/net/minecraft/world/level/SpawnerCreature.patch b/nms-patches/net/minecraft/world/level/SpawnerCreature.patch index ff1af9c53..b7525f994 100644 --- a/nms-patches/net/minecraft/world/level/SpawnerCreature.patch +++ b/nms-patches/net/minecraft/world/level/SpawnerCreature.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/SpawnerCreature.java +++ b/net/minecraft/world/level/SpawnerCreature.java -@@ -45,6 +45,11 @@ +@@ -47,6 +47,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -12,7 +12,7 @@ public final class SpawnerCreature { private static final Logger LOGGER = LogManager.getLogger(); -@@ -66,7 +71,8 @@ +@@ -73,7 +78,8 @@ if (entity instanceof EntityInsentient) { EntityInsentient entityinsentient = (EntityInsentient) entity; @@ -22,8 +22,8 @@ continue; } } -@@ -101,10 +107,49 @@ - EnumCreatureType[] aenumcreaturetype = SpawnerCreature.c; +@@ -108,10 +114,49 @@ + EnumCreatureType[] aenumcreaturetype = SpawnerCreature.SPAWNING_CATEGORIES; int i = aenumcreaturetype.length; + // CraftBukkit start - Other mob type spawn tick rate @@ -39,7 +39,7 @@ EnumCreatureType enumcreaturetype = aenumcreaturetype[j]; + // CraftBukkit start - Use per-world spawn limits + boolean spawnThisTick = true; -+ int limit = enumcreaturetype.c(); ++ int limit = enumcreaturetype.b(); + switch (enumcreaturetype) { + case MONSTER: + spawnThisTick = spawnMonsterThisTick; @@ -70,10 +70,10 @@ + + if ((flag || !enumcreaturetype.d()) && (flag1 || enumcreaturetype.d()) && (flag2 || !enumcreaturetype.e()) && spawnercreature_d.a(enumcreaturetype, limit)) { + // CraftBukkit end - a(enumcreaturetype, worldserver, chunk, (entitytypes, blockposition, ichunkaccess) -> { - return spawnercreature_d.a(entitytypes, blockposition, ichunkaccess); - }, (entityinsentient, ichunkaccess) -> { -@@ -179,10 +224,14 @@ + Objects.requireNonNull(spawnercreature_d); + SpawnerCreature.c spawnercreature_c = spawnercreature_d::a; + +@@ -196,10 +241,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); @@ -83,7 +83,7 @@ - spawnercreature_a.run(entityinsentient, ichunkaccess); + // CraftBukkit start + worldserver.addAllEntities(entityinsentient, SpawnReason.NATURAL); -+ if (!entityinsentient.dead) { ++ if (!entityinsentient.isRemoved()) { + ++j; + ++k1; + spawnercreature_a.run(entityinsentient, ichunkaccess); @@ -92,25 +92,25 @@ if (j >= entityinsentient.getMaxSpawnGroup()) { return; } -@@ -365,7 +414,7 @@ +@@ -370,7 +419,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 - flag = true; + 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 + flag = true; + } } - } -@@ -488,8 +537,10 @@ - return this.d; +@@ -486,8 +535,10 @@ + return this.unmodifiableMobCategoryCounts; } -- private boolean a(EnumCreatureType enumcreaturetype) { -- int i = enumcreaturetype.c() * this.a / SpawnerCreature.b; +- boolean a(EnumCreatureType enumcreaturetype) { +- int i = enumcreaturetype.b() * this.spawnableChunkCount / SpawnerCreature.MAGIC_NUMBER; + // CraftBukkit start -+ private boolean a(EnumCreatureType enumcreaturetype, int limit) { -+ int i = limit * this.a / SpawnerCreature.b; ++ boolean a(EnumCreatureType enumcreaturetype, int limit) { ++ int i = limit * this.spawnableChunkCount / SpawnerCreature.MAGIC_NUMBER; + // CraftBukkit end - return this.b.getInt(enumcreaturetype) < i; + return this.mobCategoryCounts.getInt(enumcreaturetype) < i; } diff --git a/nms-patches/net/minecraft/world/level/TickListServer.patch b/nms-patches/net/minecraft/world/level/TickListServer.patch index 3c4f08acd..213d7c69a 100644 --- a/nms-patches/net/minecraft/world/level/TickListServer.patch +++ b/nms-patches/net/minecraft/world/level/TickListServer.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/level/TickListServer.java +++ b/net/minecraft/world/level/TickListServer.java -@@ -48,11 +48,17 @@ +@@ -47,11 +47,17 @@ public void b() { - int i = this.nextTickList.size(); + int i = this.tickNextTickList.size(); -- if (i != this.nextTickListHash.size()) { +- if (i != this.tickNextTickSet.size()) { + if (false) { // CraftBukkit throw new IllegalStateException("TickNextTick list out of synch"); } else { @@ -19,13 +19,13 @@ + // CraftBukkit end } - ChunkProviderServer chunkproviderserver = this.e.getChunkProvider(); -@@ -91,7 +97,7 @@ + Iterator> iterator = this.tickNextTickList.iterator(); +@@ -89,7 +95,7 @@ throw new ReportedException(crashreport); } } else { -- this.a(nextticklistentry.a, nextticklistentry.b(), 0); -+ this.a(nextticklistentry.a, (T) nextticklistentry.b(), 0); // CraftBukkit - decompile error +- this.a(nextticklistentry.pos, nextticklistentry.b(), 0); ++ this.a(nextticklistentry.pos, (T) nextticklistentry.b(), 0); // CraftBukkit - decompile error } } diff --git a/nms-patches/net/minecraft/world/level/World.patch b/nms-patches/net/minecraft/world/level/World.patch index 08f06d7d0..34f7fcacf 100644 --- a/nms-patches/net/minecraft/world/level/World.patch +++ b/nms-patches/net/minecraft/world/level/World.patch @@ -1,30 +1,37 @@ --- a/net/minecraft/world/level/World.java +++ b/net/minecraft/world/level/World.java -@@ -62,6 +62,21 @@ +@@ -67,6 +67,28 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start +import java.util.HashMap; +import java.util.Map; -+import net.minecraft.network.protocol.game.PacketPlayOutWorldBorder; ++import net.minecraft.network.protocol.game.ClientboundSetBorderCenterPacket; ++import net.minecraft.network.protocol.game.ClientboundSetBorderLerpSizePacket; ++import net.minecraft.network.protocol.game.ClientboundSetBorderSizePacket; ++import net.minecraft.network.protocol.game.ClientboundSetBorderWarningDelayPacket; ++import net.minecraft.network.protocol.game.ClientboundSetBorderWarningDistancePacket; +import net.minecraft.server.level.WorldServer; +import net.minecraft.world.entity.item.EntityItem; +import net.minecraft.world.level.border.IWorldBorderListener; +import org.bukkit.Bukkit; ++import org.bukkit.Location; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.block.CapturedBlockState; +import org.bukkit.craftbukkit.block.data.CraftBlockData; ++import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.event.block.BlockPhysicsEvent; ++import org.bukkit.event.world.GenericGameEvent; +// CraftBukkit end + public abstract class World implements GeneratorAccess, AutoCloseable { protected static final Logger LOGGER = LogManager.getLogger(); -@@ -93,7 +108,49 @@ +@@ -103,7 +125,49 @@ private final BiomeManager biomeManager; - private final ResourceKey dimensionKey; + private final ResourceKey dimension; - protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, final DimensionManager dimensionmanager, Supplier supplier, boolean flag, boolean flag1, long i) { + // CraftBukkit start Added the following @@ -66,14 +73,14 @@ + this.ticksPerWaterSpawns = this.getServer().getTicksPerWaterSpawns(); // CraftBukkit + this.ticksPerWaterAmbientSpawns = this.getServer().getTicksPerWaterAmbientSpawns(); // CraftBukkit + this.ticksPerAmbientSpawns = this.getServer().getTicksPerAmbientSpawns(); // CraftBukkit -+ this.typeKey = (ResourceKey) this.getServer().getHandle().getServer().customRegistry.a().c(dimensionmanager).orElseThrow(() -> { ++ this.typeKey = (ResourceKey) this.getServer().getHandle().getServer().registryHolder.d(IRegistry.DIMENSION_TYPE_REGISTRY).c(dimensionmanager).orElseThrow(() -> { + return new IllegalStateException("Unregistered dimension type: " + dimensionmanager); + }); + // CraftBukkit end - this.methodProfiler = supplier; - this.worldData = worlddatamutable; - this.x = dimensionmanager; -@@ -103,12 +160,12 @@ + this.profiler = supplier; + this.levelData = worlddatamutable; + this.dimensionType = dimensionmanager; +@@ -113,12 +177,12 @@ this.worldBorder = new WorldBorder() { @Override public double getCenterX() { @@ -88,32 +95,32 @@ } }; } else { -@@ -118,6 +175,35 @@ - this.serverThread = Thread.currentThread(); +@@ -128,6 +192,35 @@ + this.thread = Thread.currentThread(); this.biomeManager = new BiomeManager(this, i, dimensionmanager.getGenLayerZoomer()); - this.debugWorld = flag1; + this.isDebug = flag1; + // CraftBukkit start + getWorldBorder().world = (WorldServer) this; + // From PlayerList.setPlayerFileData + getWorldBorder().a(new IWorldBorderListener() { + public void a(WorldBorder worldborder, double d0) { -+ getServer().getHandle().sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_SIZE), worldborder.world); ++ getServer().getHandle().sendAll(new ClientboundSetBorderSizePacket(worldborder), worldborder.world); + } + + public void a(WorldBorder worldborder, double d0, double d1, long i) { -+ getServer().getHandle().sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.LERP_SIZE), worldborder.world); ++ getServer().getHandle().sendAll(new ClientboundSetBorderLerpSizePacket(worldborder), worldborder.world); + } + + public void a(WorldBorder worldborder, double d0, double d1) { -+ getServer().getHandle().sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_CENTER), worldborder.world); ++ getServer().getHandle().sendAll(new ClientboundSetBorderCenterPacket(worldborder), worldborder.world); + } + + public void a(WorldBorder worldborder, int i) { -+ getServer().getHandle().sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_TIME), worldborder.world); ++ getServer().getHandle().sendAll(new ClientboundSetBorderWarningDelayPacket(worldborder), worldborder.world); + } + + public void b(WorldBorder worldborder, int i) { -+ getServer().getHandle().sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_BLOCKS), worldborder.world); ++ getServer().getHandle().sendAll(new ClientboundSetBorderWarningDistancePacket(worldborder), worldborder.world); + } + + public void b(WorldBorder worldborder, double d0) {} @@ -124,7 +131,7 @@ } @Override -@@ -181,6 +267,17 @@ +@@ -185,6 +278,17 @@ @Override public boolean a(BlockPosition blockposition, IBlockData iblockdata, int i, int j) { @@ -139,10 +146,10 @@ + return true; + } + // CraftBukkit end - if (isOutsideWorld(blockposition)) { + if (this.isOutsideWorld(blockposition)) { return false; } else if (!this.isClientSide && this.isDebugWorld()) { -@@ -188,9 +285,24 @@ +@@ -192,9 +296,24 @@ } else { Chunk chunk = this.getChunkAtWorldCoords(blockposition); Block block = iblockdata.getBlock(); @@ -168,7 +175,7 @@ return false; } else { IBlockData iblockdata2 = this.getType(blockposition); -@@ -201,6 +313,7 @@ +@@ -205,6 +324,7 @@ this.getMethodProfiler().exit(); } @@ -176,7 +183,7 @@ if (iblockdata2 == iblockdata) { if (iblockdata1 != iblockdata2) { this.b(blockposition, iblockdata1, iblockdata2); -@@ -227,12 +340,65 @@ +@@ -231,12 +351,65 @@ this.a(blockposition, iblockdata1, iblockdata2); } @@ -242,7 +249,7 @@ public void a(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {} @Override -@@ -314,6 +480,17 @@ +@@ -326,6 +499,17 @@ IBlockData iblockdata = this.getType(blockposition); try { @@ -260,7 +267,7 @@ iblockdata.doPhysics(this, blockposition, block, blockposition1, false); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours"); -@@ -356,6 +533,14 @@ +@@ -368,6 +552,14 @@ @Override public IBlockData getType(BlockPosition blockposition) { @@ -272,35 +279,10 @@ + } + } + // CraftBukkit end - if (isOutsideWorld(blockposition)) { + if (this.isOutsideWorld(blockposition)) { return Blocks.VOID_AIR.getBlockData(); } else { -@@ -503,9 +688,11 @@ - TileEntity tileentity1 = (TileEntity) this.tileEntityListPending.get(i); - - if (!tileentity1.isRemoved()) { -+ /* CraftBukkit start - Order matters, moved down - if (!this.tileEntityList.contains(tileentity1)) { - this.a(tileentity1); - } -+ // CraftBukkit end */ - - if (this.isLoaded(tileentity1.getPosition())) { - Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition()); -@@ -513,6 +700,12 @@ - - chunk.setTileEntity(tileentity1.getPosition(), tileentity1); - this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3); -+ // CraftBukkit start -+ // From above, don't screw this up - SPIGOT-1746 -+ if (!this.tileEntityList.contains(tileentity1)) { -+ this.a(tileentity1); -+ } -+ // CraftBukkit end - } - } - } -@@ -557,12 +750,25 @@ +@@ -484,7 +676,17 @@ @Nullable @Override @@ -311,41 +293,47 @@ + + @Nullable + public TileEntity getTileEntity(BlockPosition blockposition, boolean validate) { ++ if (capturedTileEntities.containsKey(blockposition)) { ++ return capturedTileEntities.get(blockposition); ++ } + // CraftBukkit end - if (isOutsideWorld(blockposition)) { - return null; - } else if (!this.isClientSide && Thread.currentThread() != this.serverThread) { - return null; - } else { -+ // CraftBukkit start -+ if (capturedTileEntities.containsKey(blockposition)) { -+ return capturedTileEntities.get(blockposition); -+ } -+ // CraftBukkit end -+ - TileEntity tileentity = null; - - if (this.tickingTileEntities) { -@@ -597,6 +803,13 @@ - public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) { - if (!isOutsideWorld(blockposition)) { - if (tileentity != null && !tileentity.isRemoved()) { -+ // CraftBukkit start -+ if (captureBlockStates) { -+ tileentity.setLocation(this, blockposition); -+ capturedTileEntities.put(blockposition.immutableCopy(), tileentity); -+ return; -+ } -+ // CraftBukkit end - if (this.tickingTileEntities) { - tileentity.setLocation(this, blockposition); - Iterator iterator = this.tileEntityListPending.iterator(); -@@ -621,7 +834,7 @@ + return this.isOutsideWorld(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAtWorldCoords(blockposition).a(blockposition, Chunk.EnumTileEntityState.IMMEDIATE)); } - public void removeTileEntity(BlockPosition blockposition) { -- TileEntity tileentity = this.getTileEntity(blockposition); -+ TileEntity tileentity = this.getTileEntity(blockposition, false); // CraftBukkit +@@ -492,6 +694,12 @@ + BlockPosition blockposition = tileentity.getPosition(); - if (tileentity != null && this.tickingTileEntities) { - tileentity.al_(); + if (!this.isOutsideWorld(blockposition)) { ++ // CraftBukkit start ++ if (captureBlockStates) { ++ capturedTileEntities.put(blockposition.immutableCopy(), tileentity); ++ return; ++ } ++ // CraftBukkit end + this.getChunkAtWorldCoords(blockposition).b(tileentity); + } + } +@@ -595,7 +803,7 @@ + + for (int j = 0; j < i; ++j) { + EntityComplexPart entitycomplexpart = aentitycomplexpart[j]; +- T t0 = (Entity) entitytypetest.a((Object) entitycomplexpart); ++ T t0 = entitytypetest.a(entitycomplexpart); + + if (t0 != null && predicate.test(t0)) { + list.add(t0); +@@ -921,6 +1129,14 @@ + public abstract LevelEntityGetter getEntities(); + + protected void a(@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); ++ getServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ return; ++ } ++ 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); diff --git a/nms-patches/net/minecraft/world/level/WorldAccess.patch b/nms-patches/net/minecraft/world/level/WorldAccess.patch index aadedfa99..6a1a92b6f 100644 --- a/nms-patches/net/minecraft/world/level/WorldAccess.patch +++ b/nms-patches/net/minecraft/world/level/WorldAccess.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/WorldAccess.java +++ b/net/minecraft/world/level/WorldAccess.java -@@ -8,6 +8,12 @@ - WorldServer getMinecraftWorld(); +@@ -8,6 +8,17 @@ + WorldServer getLevel(); default void addAllEntities(Entity entity) { - entity.recursiveStream().forEach(this::addEntity); @@ -12,5 +12,10 @@ + default void addAllEntities(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + entity.recursiveStream().forEach((e) -> this.addEntity(e, reason)); + } ++ ++ @Override ++ default WorldServer getMinecraftWorld() { ++ return getLevel(); ++ } + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/level/block/AzaleaBlock.patch b/nms-patches/net/minecraft/world/level/block/AzaleaBlock.patch new file mode 100644 index 000000000..501a20cc4 --- /dev/null +++ b/nms-patches/net/minecraft/world/level/block/AzaleaBlock.patch @@ -0,0 +1,46 @@ +--- a/net/minecraft/world/level/block/AzaleaBlock.java ++++ b/net/minecraft/world/level/block/AzaleaBlock.java +@@ -12,6 +12,13 @@ + import net.minecraft.world.phys.shapes.VoxelShapeCollision; + import net.minecraft.world.phys.shapes.VoxelShapes; + ++// CraftBukkit start ++import org.bukkit.Location; ++import org.bukkit.TreeType; ++import org.bukkit.block.BlockState; ++import org.bukkit.event.world.StructureGrowEvent; ++// CraftBukkit end ++ + public class AzaleaBlock extends BlockPlant implements IBlockFragilePlantElement { + + private static final AzaleaTreeGrower TREE_GROWER = new AzaleaTreeGrower(); +@@ -43,6 +50,29 @@ + + @Override + public void a(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); ++ // CraftBukkit start ++ worldserver.captureTreeGeneration = false; ++ if (worldserver.capturedBlockStates.size() > 0) { ++ TreeType treeType = BlockSapling.treeType; ++ BlockSapling.treeType = null; ++ Location location = new Location(worldserver.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ java.util.List blocks = new java.util.ArrayList<>(worldserver.capturedBlockStates.values()); ++ worldserver.capturedBlockStates.clear(); ++ StructureGrowEvent event = null; ++ if (treeType != null) { ++ event = new StructureGrowEvent(location, treeType, false, null, blocks); ++ org.bukkit.Bukkit.getPluginManager().callEvent(event); ++ } ++ if (event == null || !event.isCancelled()) { ++ for (BlockState blockstate : blocks) { ++ blockstate.update(true); ++ } ++ } ++ } ++ // CraftBukkit end + } + } diff --git a/nms-patches/net/minecraft/world/level/block/Block.patch b/nms-patches/net/minecraft/world/level/block/Block.patch index fbe12a0f6..0efaaccbb 100644 --- a/nms-patches/net/minecraft/world/level/block/Block.patch +++ b/nms-patches/net/minecraft/world/level/block/Block.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -248,7 +248,13 @@ - EntityItem entityitem = new EntityItem(world, (double) blockposition.getX() + d0, (double) blockposition.getY() + d1, (double) blockposition.getZ() + d2, itemstack); +@@ -354,7 +354,13 @@ + EntityItem entityitem = (EntityItem) supplier.get(); entityitem.defaultPickupDelay(); - world.addEntity(entityitem); @@ -15,7 +15,7 @@ } } -@@ -279,7 +285,7 @@ +@@ -380,7 +386,7 @@ public void a(World world, EntityHuman entityhuman, BlockPosition blockposition, IBlockData iblockdata, @Nullable TileEntity tileentity, ItemStack itemstack) { entityhuman.b(StatisticList.BLOCK_MINED.b(this)); @@ -24,8 +24,8 @@ dropItems(iblockdata, world, blockposition, tileentity, entityhuman, itemstack); } -@@ -375,6 +381,12 @@ - return this; +@@ -514,6 +520,12 @@ + return (ImmutableMap) this.stateDefinition.a().stream().collect(ImmutableMap.toImmutableMap(Function.identity(), function)); } + // CraftBukkit start @@ -36,4 +36,4 @@ + public static final class a { - private final IBlockData a; + private final IBlockData first; diff --git a/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch b/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch index 91236e15f..ca745f8e2 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch @@ -1,27 +1,27 @@ --- a/net/minecraft/world/level/block/BlockBamboo.java +++ b/net/minecraft/world/level/block/BlockBamboo.java -@@ -174,7 +174,7 @@ +@@ -187,7 +187,7 @@ BlockPosition blockposition1 = blockposition.up(i); IBlockData iblockdata1 = worldserver.getType(blockposition1); -- if (k >= 16 || (Integer) iblockdata1.get(BlockBamboo.f) == 1 || !worldserver.isEmpty(blockposition1.up())) { -+ if (k >= 16 || !iblockdata1.a(Blocks.BAMBOO) || (Integer) iblockdata1.get(BlockBamboo.f) == 1 || !worldserver.isEmpty(blockposition1.up())) { // CraftBukkit - If the BlockSpreadEvent was cancelled, we have no bamboo here +- 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 return; } -@@ -195,14 +195,18 @@ +@@ -208,14 +208,18 @@ BlockPosition blockposition1 = blockposition.down(2); IBlockData iblockdata2 = world.getType(blockposition1); BlockPropertyBambooSize blockpropertybamboosize = BlockPropertyBambooSize.NONE; + boolean shouldUpdateOthers = false; // CraftBukkit if (i >= 1) { - if (iblockdata1.a(Blocks.BAMBOO) && iblockdata1.get(BlockBamboo.e) != BlockPropertyBambooSize.NONE) { - if (iblockdata1.a(Blocks.BAMBOO) && iblockdata1.get(BlockBamboo.e) != BlockPropertyBambooSize.NONE) { + if (iblockdata1.a(Blocks.BAMBOO) && iblockdata1.get(BlockBamboo.LEAVES) != BlockPropertyBambooSize.NONE) { + if (iblockdata1.a(Blocks.BAMBOO) && iblockdata1.get(BlockBamboo.LEAVES) != BlockPropertyBambooSize.NONE) { blockpropertybamboosize = BlockPropertyBambooSize.LARGE; if (iblockdata2.a(Blocks.BAMBOO)) { -- world.setTypeAndData(blockposition.down(), (IBlockData) iblockdata1.set(BlockBamboo.e, BlockPropertyBambooSize.SMALL), 3); -- world.setTypeAndData(blockposition1, (IBlockData) iblockdata2.set(BlockBamboo.e, BlockPropertyBambooSize.NONE), 3); +- world.setTypeAndData(blockposition.down(), (IBlockData) iblockdata1.set(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3); +- world.setTypeAndData(blockposition1, (IBlockData) iblockdata2.set(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); @@ -30,16 +30,16 @@ } } } else { -@@ -213,7 +217,14 @@ - int j = (Integer) iblockdata.get(BlockBamboo.d) != 1 && !iblockdata2.a(Blocks.BAMBOO) ? 0 : 1; +@@ -226,7 +230,14 @@ + int j = (Integer) iblockdata.get(BlockBamboo.AGE) != 1 && !iblockdata2.a(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.d, j)).set(BlockBamboo.e, blockpropertybamboosize)).set(BlockBamboo.f, k), 3); +- world.setTypeAndData(blockposition.up(), (IBlockData) ((IBlockData) ((IBlockData) this.getBlockData().set(BlockBamboo.AGE, j)).set(BlockBamboo.LEAVES, blockpropertybamboosize)).set(BlockBamboo.STAGE, k), 3); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition.up(), (IBlockData) ((IBlockData) ((IBlockData) this.getBlockData().set(BlockBamboo.d, j)).set(BlockBamboo.e, blockpropertybamboosize)).set(BlockBamboo.f, k), 3)) { ++ 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 (shouldUpdateOthers) { -+ world.setTypeAndData(blockposition.down(), (IBlockData) iblockdata1.set(BlockBamboo.e, BlockPropertyBambooSize.SMALL), 3); -+ world.setTypeAndData(blockposition1, (IBlockData) iblockdata2.set(BlockBamboo.e, BlockPropertyBambooSize.NONE), 3); ++ world.setTypeAndData(blockposition.down(), (IBlockData) iblockdata1.set(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3); ++ world.setTypeAndData(blockposition1, (IBlockData) iblockdata2.set(BlockBamboo.LEAVES, BlockPropertyBambooSize.NONE), 3); + } + } + // CraftBukkit end diff --git a/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch b/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch index 6b36c0b07..47d27d789 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/level/block/BlockBambooSapling.java +++ b/net/minecraft/world/level/block/BlockBambooSapling.java -@@ -86,6 +86,6 @@ +@@ -94,6 +94,6 @@ } protected void a(World world, BlockPosition blockposition) { -- world.setTypeAndData(blockposition.up(), (IBlockData) Blocks.BAMBOO.getBlockData().set(BlockBamboo.e, BlockPropertyBambooSize.SMALL), 3); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition.up(), (IBlockData) Blocks.BAMBOO.getBlockData().set(BlockBamboo.e, BlockPropertyBambooSize.SMALL), 3); // CraftBukkit - BlockSpreadEvent +- 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 } } diff --git a/nms-patches/net/minecraft/world/level/block/BlockBed.patch b/nms-patches/net/minecraft/world/level/block/BlockBed.patch index 37b882839..459e77713 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockBed.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockBed.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockBed.java +++ b/net/minecraft/world/level/block/BlockBed.java -@@ -78,7 +78,8 @@ +@@ -88,7 +88,8 @@ } } @@ -10,7 +10,7 @@ world.a(blockposition, false); BlockPosition blockposition1 = blockposition.shift(((EnumDirection) iblockdata.get(BlockBed.FACING)).opposite()); -@@ -95,7 +96,16 @@ +@@ -105,7 +106,16 @@ return EnumInteractionResult.SUCCESS; } else { @@ -27,7 +27,7 @@ if (entityhuman_enumbedresult != null) { entityhuman.a(entityhuman_enumbedresult.a(), true); } -@@ -106,8 +116,27 @@ +@@ -116,8 +126,27 @@ } } diff --git a/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch b/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch index ef95ba6ea..070ca5931 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockBeehive.java +++ b/net/minecraft/world/level/block/BlockBeehive.java -@@ -97,7 +97,7 @@ +@@ -108,7 +108,7 @@ EntityBee entitybee = (EntityBee) iterator.next(); if (entitybee.getGoalTarget() == null) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch b/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch index 0ef1b4f20..1465f16c0 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockButtonAbstract.java +++ b/net/minecraft/world/level/block/BlockButtonAbstract.java -@@ -26,6 +26,11 @@ +@@ -27,6 +27,11 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -11,8 +11,8 @@ + public abstract class BlockButtonAbstract extends BlockAttachable { - public static final BlockStateBoolean POWERED = BlockProperties.w; -@@ -92,6 +97,19 @@ + public static final BlockStateBoolean POWERED = BlockProperties.POWERED; +@@ -97,6 +102,19 @@ if ((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)) { return EnumInteractionResult.CONSUME; } else { @@ -31,10 +31,10 @@ + // CraftBukkit end this.d(iblockdata, world, blockposition); this.a(entityhuman, world, blockposition, true); - return EnumInteractionResult.a(world.isClientSide); -@@ -142,6 +160,16 @@ - if (this.v) { - this.e(iblockdata, (World) worldserver, blockposition); + world.a((Entity) entityhuman, GameEvent.BLOCK_PRESS, blockposition); +@@ -148,6 +166,16 @@ + if (this.sensitive) { + this.e(iblockdata, worldserver, blockposition); } else { + // CraftBukkit start + org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); @@ -49,7 +49,7 @@ worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, false), 3); this.f(iblockdata, (World) worldserver, blockposition); this.a((EntityHuman) null, worldserver, blockposition, false); -@@ -162,7 +190,44 @@ +@@ -169,11 +197,48 @@ boolean flag = !list.isEmpty(); boolean flag1 = (Boolean) iblockdata.get(BlockButtonAbstract.POWERED); @@ -94,3 +94,8 @@ 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 + } + + if (flag) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockCactus.patch b/nms-patches/net/minecraft/world/level/block/BlockCactus.patch index d1cae0e5a..438b7c85a 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCactus.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCactus.patch @@ -8,8 +8,8 @@ + public class BlockCactus extends Block { - public static final BlockStateInteger AGE = BlockProperties.aj; -@@ -57,7 +59,7 @@ + public static final BlockStateInteger AGE = BlockProperties.AGE_15; +@@ -59,7 +61,7 @@ int j = (Integer) iblockdata.get(BlockCactus.AGE); if (j == 15) { @@ -18,7 +18,7 @@ IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockCactus.AGE, 0); worldserver.setTypeAndData(blockposition, iblockdata1, 4); -@@ -114,7 +116,9 @@ +@@ -116,7 +118,9 @@ @Override public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockCake.patch b/nms-patches/net/minecraft/world/level/block/BlockCake.patch index 9fdae4f3d..06b762173 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCake.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCake.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCake.java +++ b/net/minecraft/world/level/block/BlockCake.java -@@ -58,7 +58,18 @@ +@@ -86,7 +86,18 @@ return EnumInteractionResult.PASS; } else { entityhuman.a(StatisticList.EAT_CAKE_SLICE); @@ -19,4 +19,4 @@ + // CraftBukkit end int i = (Integer) iblockdata.get(BlockCake.BITES); - if (i < 6) { + generatoraccess.a((Entity) entityhuman, GameEvent.EAT, blockposition); diff --git a/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch b/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch index d643964cf..de3f868d7 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/BlockCampfire.java +++ b/net/minecraft/world/level/block/BlockCampfire.java -@@ -186,6 +186,11 @@ - if (flag && !(Boolean) iblockdata.get(BlockCampfire.LIT) && !(Boolean) iblockdata.get(BlockCampfire.d)) { - BlockPosition blockposition = movingobjectpositionblock.getBlockPosition(); +@@ -202,6 +202,11 @@ + BlockPosition blockposition = movingobjectpositionblock.getBlockPosition(); -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, iprojectile).isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockProperties.r, true), 11); - } + if (!world.isClientSide && iprojectile.isBurning() && iprojectile.a(world, blockposition) && !(Boolean) iblockdata.get(BlockCampfire.LIT) && !(Boolean) iblockdata.get(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); } + diff --git a/nms-patches/net/minecraft/world/level/block/BlockCauldron.patch b/nms-patches/net/minecraft/world/level/block/BlockCauldron.patch deleted file mode 100644 index 32e66f3f0..000000000 --- a/nms-patches/net/minecraft/world/level/block/BlockCauldron.patch +++ /dev/null @@ -1,176 +0,0 @@ ---- a/net/minecraft/world/level/block/BlockCauldron.java -+++ b/net/minecraft/world/level/block/BlockCauldron.java -@@ -34,6 +34,8 @@ - import net.minecraft.world.phys.shapes.VoxelShapeCollision; - import net.minecraft.world.phys.shapes.VoxelShapes; - -+import org.bukkit.event.block.CauldronLevelChangeEvent; // CraftBukkit -+ - public class BlockCauldron extends Block { - - public static final BlockStateInteger LEVEL = BlockProperties.ar; -@@ -61,8 +63,13 @@ - float f = (float) blockposition.getY() + (6.0F + (float) (3 * i)) / 16.0F; - - if (!world.isClientSide && entity.isBurning() && i > 0 && entity.locY() <= (double) f) { -+ // CraftBukkit start -+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entity, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH)) { -+ return; -+ } - entity.extinguish(); -- this.a(world, blockposition, iblockdata, i - 1); -+ // this.a(world, blockposition, iblockdata, i - 1); -+ // CraftBukkit end - } - - } -@@ -79,18 +86,27 @@ - - if (item == Items.WATER_BUCKET) { - if (i < 3 && !world.isClientSide) { -+ // CraftBukkit start -+ if (!this.changeLevel(world, blockposition, iblockdata, 3, entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY)) { -+ return EnumInteractionResult.SUCCESS; -+ } - if (!entityhuman.abilities.canInstantlyBuild) { - entityhuman.a(enumhand, new ItemStack(Items.BUCKET)); - } - - entityhuman.a(StatisticList.FILL_CAULDRON); -- this.a(world, blockposition, iblockdata, 3); -+ // this.a(world, blockposition, iblockdata, 3); -+ // CraftBukkit end - world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_BUCKET_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); - } - - return EnumInteractionResult.a(world.isClientSide); - } else if (item == Items.BUCKET) { - if (i == 3 && !world.isClientSide) { -+ // CraftBukkit start -+ if (!this.changeLevel(world, blockposition, iblockdata, 0, entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) { -+ return EnumInteractionResult.SUCCESS; -+ } - if (!entityhuman.abilities.canInstantlyBuild) { - itemstack.subtract(1); - if (itemstack.isEmpty()) { -@@ -101,7 +117,8 @@ - } - - entityhuman.a(StatisticList.USE_CAULDRON); -- this.a(world, blockposition, iblockdata, 0); -+ // this.a(world, blockposition, iblockdata, 0); -+ // CraftBukkit end - world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_BUCKET_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F); - } - -@@ -111,6 +128,10 @@ - - if (item == Items.GLASS_BOTTLE) { - if (i > 0 && !world.isClientSide) { -+ // CraftBukkit start -+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL)) { -+ return EnumInteractionResult.SUCCESS; -+ } - if (!entityhuman.abilities.canInstantlyBuild) { - itemstack1 = PotionUtil.a(new ItemStack(Items.POTION), Potions.WATER); - entityhuman.a(StatisticList.USE_CAULDRON); -@@ -125,12 +146,17 @@ - } - - world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F); -- this.a(world, blockposition, iblockdata, i - 1); -+ // this.a(world, blockposition, iblockdata, i - 1); -+ // CraftBukkit end - } - - return EnumInteractionResult.a(world.isClientSide); - } else if (item == Items.POTION && PotionUtil.d(itemstack) == Potions.WATER) { - if (i < 3 && !world.isClientSide) { -+ // CraftBukkit start -+ if (!this.changeLevel(world, blockposition, iblockdata, i + 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) { -+ return EnumInteractionResult.SUCCESS; -+ } - if (!entityhuman.abilities.canInstantlyBuild) { - itemstack1 = new ItemStack(Items.GLASS_BOTTLE); - entityhuman.a(StatisticList.USE_CAULDRON); -@@ -141,7 +167,8 @@ - } - - world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); -- this.a(world, blockposition, iblockdata, i + 1); -+ // this.a(world, blockposition, iblockdata, i + 1); -+ // CraftBukkit end - } - - return EnumInteractionResult.a(world.isClientSide); -@@ -150,8 +177,13 @@ - IDyeable idyeable = (IDyeable) item; - - if (idyeable.a(itemstack) && !world.isClientSide) { -+ // CraftBukkit start -+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) { -+ return EnumInteractionResult.SUCCESS; -+ } - idyeable.c(itemstack); -- this.a(world, blockposition, iblockdata, i - 1); -+ // this.a(world, blockposition, iblockdata, i - 1); -+ // CraftBukkit end - entityhuman.a(StatisticList.CLEAN_ARMOR); - return EnumInteractionResult.SUCCESS; - } -@@ -159,13 +191,18 @@ - - if (i > 0 && item instanceof ItemBanner) { - if (TileEntityBanner.b(itemstack) > 0 && !world.isClientSide) { -+ // CraftBukkit start -+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) { -+ return EnumInteractionResult.SUCCESS; -+ } - itemstack1 = itemstack.cloneItemStack(); - itemstack1.setCount(1); - TileEntityBanner.c(itemstack1); - entityhuman.a(StatisticList.CLEAN_BANNER); - if (!entityhuman.abilities.canInstantlyBuild) { - itemstack.subtract(1); -- this.a(world, blockposition, iblockdata, i - 1); -+ // this.a(world, blockposition, iblockdata, i - 1); -+ // CraftBukkit end - } - - if (itemstack.isEmpty()) { -@@ -203,9 +240,25 @@ - } - } - -+ // CraftBukkit start - public void a(World world, BlockPosition blockposition, IBlockData iblockdata, int i) { -- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCauldron.LEVEL, MathHelper.clamp(i, 0, 3)), 2); -+ this.changeLevel(world, blockposition, iblockdata, i, null, CauldronLevelChangeEvent.ChangeReason.UNKNOWN); -+ } -+ -+ private boolean changeLevel(World world, BlockPosition blockposition, IBlockData iblockdata, int i, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) { -+ int newLevel = Integer.valueOf(MathHelper.clamp(i, 0, 3)); -+ CauldronLevelChangeEvent event = new CauldronLevelChangeEvent( -+ world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), -+ (entity == null) ? null : entity.getBukkitEntity(), reason, iblockdata.get(BlockCauldron.LEVEL), newLevel -+ ); -+ world.getServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ return false; -+ } -+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCauldron.LEVEL, event.getNewLevel()), 2); - world.updateAdjacentComparators(blockposition, this); -+ return true; -+ // CraftBukkit end - } - - @Override -@@ -217,7 +270,7 @@ - IBlockData iblockdata = world.getType(blockposition); - - if ((Integer) iblockdata.get(BlockCauldron.LEVEL) < 3) { -- world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); -+ this.a(world, blockposition, (IBlockData) iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); // CraftBukkit - } - - } diff --git a/nms-patches/net/minecraft/world/level/block/BlockChest.patch b/nms-patches/net/minecraft/world/level/block/BlockChest.patch index 52364050e..f85841805 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockChest.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockChest.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockChest.java +++ b/net/minecraft/world/level/block/BlockChest.java -@@ -79,24 +79,7 @@ +@@ -88,24 +88,7 @@ public Optional a(final TileEntityChest tileentitychest, final TileEntityChest tileentitychest1) { final InventoryLargeChest inventorylargechest = new InventoryLargeChest(tileentitychest, tileentitychest1); @@ -8,10 +8,10 @@ - @Nullable - @Override - public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) { -- if (tileentitychest.e(entityhuman) && tileentitychest1.e(entityhuman)) { -- tileentitychest.d(playerinventory.player); -- tileentitychest1.d(playerinventory.player); -- return ContainerChest.b(i, playerinventory, inventorylargechest); +- if (tileentitychest.d(entityhuman) && tileentitychest1.d(entityhuman)) { +- tileentitychest.e(playerinventory.player); +- tileentitychest1.e(playerinventory.player); +- return ContainerChest.b(i, playerinventory, (IInventory) inventorylargechest); - } else { - return null; - } @@ -26,7 +26,7 @@ } public Optional a(TileEntityChest tileentitychest) { -@@ -109,6 +92,38 @@ +@@ -118,6 +101,38 @@ } }; @@ -46,10 +46,10 @@ + @Nullable + @Override + public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) { -+ if (tileentitychest.e(entityhuman) && tileentitychest1.e(entityhuman)) { -+ tileentitychest.d(playerinventory.player); -+ tileentitychest1.d(playerinventory.player); -+ return ContainerChest.b(i, playerinventory, inventorylargechest); ++ if (tileentitychest.d(entityhuman) && tileentitychest1.d(entityhuman)) { ++ tileentitychest.e(playerinventory.player); ++ tileentitychest1.e(playerinventory.player); ++ return ContainerChest.b(i, playerinventory, (IInventory) inventorylargechest); + } else { + return null; + } @@ -64,10 +64,10 @@ + protected BlockChest(BlockBase.Info blockbase_info, Supplier> supplier) { super(blockbase_info, supplier); - this.j((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.blockStateList.getBlockData()).set(BlockChest.FACING, EnumDirection.NORTH)).set(BlockChest.c, BlockPropertyChestType.SINGLE)).set(BlockChest.d, false)); -@@ -262,7 +277,7 @@ - } + this.k((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.getBlockData()).set(BlockChest.FACING, EnumDirection.NORTH)).set(BlockChest.TYPE, BlockPropertyChestType.SINGLE)).set(BlockChest.WATERLOGGED, false)); +@@ -276,7 +291,7 @@ + @Override public DoubleBlockFinder.Result a(IBlockData iblockdata, World world, BlockPosition blockposition, boolean flag) { - BiPredicate bipredicate; + BiPredicate bipredicate; // CraftBukkit - decompile error diff --git a/nms-patches/net/minecraft/world/level/block/BlockChorusFlower.patch b/nms-patches/net/minecraft/world/level/block/BlockChorusFlower.patch index 2064a4547..450efd8ff 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockChorusFlower.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockChorusFlower.patch @@ -8,16 +8,16 @@ + public class BlockChorusFlower extends Block { - public static final BlockStateInteger AGE = BlockProperties.ah; + public static final int DEAD_AGE = 5; @@ -84,8 +86,12 @@ } if (flag && b((IWorldReader) worldserver, blockposition1, (EnumDirection) null) && worldserver.isEmpty(blockposition.up(2))) { -- worldserver.setTypeAndData(blockposition, this.b.a((IBlockAccess) worldserver, blockposition), 2); +- worldserver.setTypeAndData(blockposition, this.plant.a((IBlockAccess) worldserver, blockposition), 2); - this.a(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.b.a((IBlockAccess) worldserver, blockposition), 2); ++ worldserver.setTypeAndData(blockposition, this.plant.a((IBlockAccess) worldserver, blockposition), 2); + this.a(worldserver, blockposition1, i); + } + // CraftBukkit end @@ -40,7 +40,7 @@ } if (flag2) { - worldserver.setTypeAndData(blockposition, this.b.a((IBlockAccess) worldserver, blockposition), 2); + worldserver.setTypeAndData(blockposition, this.plant.a((IBlockAccess) worldserver, blockposition), 2); } else { - this.a((World) worldserver, blockposition); + // CraftBukkit - add event diff --git a/nms-patches/net/minecraft/world/level/block/BlockCocoa.patch b/nms-patches/net/minecraft/world/level/block/BlockCocoa.patch index eeeebbf89..fc9fcce7d 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCocoa.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCocoa.patch @@ -8,8 +8,8 @@ + public class BlockCocoa extends BlockFacingHorizontal implements IBlockFragilePlantElement { - public static final BlockStateInteger AGE = BlockProperties.af; -@@ -45,7 +47,7 @@ + public static final int MAX_AGE = 2; +@@ -55,7 +57,7 @@ int i = (Integer) iblockdata.get(BlockCocoa.AGE); if (i < 2) { @@ -18,7 +18,7 @@ } } -@@ -115,7 +117,7 @@ +@@ -125,7 +127,7 @@ @Override public void a(WorldServer worldserver, Random random, BlockPosition blockposition, IBlockData iblockdata) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockCommand.patch b/nms-patches/net/minecraft/world/level/block/BlockCommand.patch index c3ce8f364..827f874f9 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCommand.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCommand.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/BlockCommand.java +++ b/net/minecraft/world/level/block/BlockCommand.java -@@ -27,6 +27,8 @@ +@@ -26,6 +26,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit + - public class BlockCommand extends BlockTileEntity { + public class BlockCommand extends BlockTileEntity implements GameMasterBlock { private static final Logger LOGGER = LogManager.getLogger(); -@@ -55,6 +57,15 @@ +@@ -56,6 +58,15 @@ TileEntityCommand tileentitycommand = (TileEntityCommand) tileentity; boolean flag1 = world.isBlockIndirectlyPowered(blockposition); boolean flag2 = tileentitycommand.f(); @@ -24,4 +24,4 @@ + // CraftBukkit end tileentitycommand.a(flag1); - if (!flag2 && !tileentitycommand.g() && tileentitycommand.m() != TileEntityCommand.Type.SEQUENCE) { + if (!flag2 && !tileentitycommand.g() && tileentitycommand.t() != TileEntityCommand.Type.SEQUENCE) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockComposter.patch b/nms-patches/net/minecraft/world/level/block/BlockComposter.patch index f9f6c311f..7c4733fdf 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockComposter.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockComposter.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockComposter.java +++ b/net/minecraft/world/level/block/BlockComposter.java -@@ -36,12 +36,18 @@ +@@ -38,6 +38,12 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -12,15 +12,17 @@ + public class BlockComposter extends Block implements IInventoryHolder { - public static final BlockStateInteger a = BlockProperties.as; - public static final Object2FloatMap b = new Object2FloatOpenHashMap(); - private static final VoxelShape c = VoxelShapes.b(); -- private static final VoxelShape[] d = (VoxelShape[]) SystemUtils.a((Object) (new VoxelShape[9]), (avoxelshape) -> { -+ private static final VoxelShape[] d = (VoxelShape[]) SystemUtils.a((new VoxelShape[9]), (avoxelshape) -> { // CraftBukkit - decompile error + public static final int READY = 8; +@@ -47,7 +53,7 @@ + public static final Object2FloatMap 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.c, Block.a(2.0D, (double) Math.max(2, 1 + i * 2), 2.0D, 14.0D, 16.0D, 14.0D), OperatorBoolean.ONLY_FIRST); + 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); } -@@ -187,18 +193,25 @@ +@@ -225,18 +231,25 @@ return EnumInteractionResult.a(world.isClientSide); } else if (i == 8) { @@ -34,22 +36,22 @@ - 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.a); + int i = (Integer) iblockdata.get(BlockComposter.LEVEL); - if (i < 7 && BlockComposter.b.containsKey(itemstack.getItem())) { -- IBlockData iblockdata1 = b(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack); + if (i < 7 && BlockComposter.COMPOSTABLES.containsKey(itemstack.getItem())) { +- IBlockData iblockdata1 = a(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack); + // CraftBukkit start + double rand = worldserver.getRandom().nextDouble(); -+ IBlockData iblockdata1 = b(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack, rand); ++ IBlockData iblockdata1 = a(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack, rand); + if (iblockdata == iblockdata1 || org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) { + return iblockdata; + } -+ iblockdata1 = b(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack, rand); ++ iblockdata1 = a(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack, rand); + // CraftBukkit end itemstack.subtract(1); return iblockdata1; -@@ -207,7 +220,15 @@ +@@ -245,7 +258,15 @@ } } @@ -57,7 +59,7 @@ + // CraftBukkit start + public static IBlockData d(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + if (entity != null) { -+ IBlockData iblockdata1 = d(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition); ++ IBlockData iblockdata1 = c(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition); + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) { + return iblockdata; + } @@ -66,69 +68,71 @@ if (!world.isClientSide) { float f = 0.7F; double d0 = (double) (world.random.nextFloat() * 0.7F) + 0.15000000596046448D; -@@ -233,10 +254,16 @@ +@@ -271,10 +292,16 @@ } - private static IBlockData b(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) { + static IBlockData a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) { + // CraftBukkit start -+ return b(iblockdata, generatoraccess, blockposition, itemstack, generatoraccess.getRandom().nextDouble()); ++ return a(iblockdata, generatoraccess, blockposition, itemstack, generatoraccess.getRandom().nextDouble()); + } + -+ private static IBlockData b(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack, double rand) { ++ static IBlockData a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack, double rand) { + // CraftBukkit end - int i = (Integer) iblockdata.get(BlockComposter.a); - float f = BlockComposter.b.getFloat(itemstack.getItem()); + int i = (Integer) iblockdata.get(BlockComposter.LEVEL); + float f = BlockComposter.COMPOSTABLES.getFloat(itemstack.getItem()); - if ((i != 0 || f <= 0.0F) && generatoraccess.getRandom().nextDouble() >= (double) f) { + if ((i != 0 || f <= 0.0F) && rand >= (double) f) { return iblockdata; } else { int j = i + 1; -@@ -284,7 +311,8 @@ +@@ -322,7 +349,8 @@ public IWorldInventory a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { - int i = (Integer) iblockdata.get(BlockComposter.a); + int i = (Integer) iblockdata.get(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 + return (IWorldInventory) (i == 8 ? new BlockComposter.ContainerOutput(iblockdata, generatoraccess, blockposition, new ItemStack(Items.BONE_MEAL)) : (i < 7 ? new BlockComposter.ContainerInput(iblockdata, generatoraccess, blockposition) : new BlockComposter.ContainerEmpty(generatoraccess, blockposition))); } - static class ContainerInput extends InventorySubcontainer implements IWorldInventory { -@@ -296,6 +324,7 @@ - - public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { - super(1); -+ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit - this.a = iblockdata; - this.b = generatoraccess; - this.c = blockposition; -@@ -348,6 +377,7 @@ - this.blockData = iblockdata; - this.generatorAccess = generatoraccess; - this.blockPosition = blockposition; + private static class ContainerOutput extends InventorySubcontainer implements IWorldInventory { +@@ -337,6 +365,7 @@ + this.state = iblockdata; + this.level = generatoraccess; + this.pos = blockposition; + this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit } @Override -@@ -372,15 +402,23 @@ +@@ -361,8 +390,15 @@ @Override public void update() { -- BlockComposter.d(this.blockData, this.generatorAccess, this.blockPosition); -- this.emptied = true; +- BlockComposter.c(this.state, this.level, this.pos); +- this.changed = true; + // CraftBukkit start - allow putting items back (eg cancelled InventoryMoveItemEvent) + if (this.isEmpty()) { -+ BlockComposter.d(this.blockData, this.generatorAccess, this.blockPosition); -+ this.emptied = true; ++ BlockComposter.c(this.state, this.level, this.pos); ++ this.changed = true; + } else { -+ this.generatorAccess.setTypeAndData(this.blockPosition, this.blockData, 3); -+ this.emptied = false; ++ this.level.setTypeAndData(this.pos, this.state, 3); ++ this.changed = false; + } + // CraftBukkit end } } - static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory { +@@ -375,6 +411,7 @@ + + public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { + super(1); ++ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit + this.state = iblockdata; + this.level = generatoraccess; + this.pos = blockposition; +@@ -417,8 +454,9 @@ + + private static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory { - public ContainerEmpty() { + public ContainerEmpty(GeneratorAccess generatoraccess, BlockPosition blockposition) { // CraftBukkit diff --git a/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch b/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch index 1da36e4f4..d7485b2bc 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch @@ -11,13 +11,13 @@ + public class BlockConcretePowder extends BlockFalling { - private final IBlockData a; + private final IBlockData concrete; @@ -25,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.a, 3); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.a, 3); // CraftBukkit +- world.setTypeAndData(blockposition, this.concrete, 3); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.concrete, 3); // CraftBukkit } } @@ -25,7 +25,7 @@ BlockPosition blockposition = blockactioncontext.getClickPosition(); IBlockData iblockdata = world.getType(blockposition); -- return canHarden(world, blockposition, iblockdata) ? this.a : super.getPlacedState(blockactioncontext); +- return canHarden(world, blockposition, iblockdata) ? this.concrete : super.getPlacedState(blockactioncontext); + // CraftBukkit start + if (!canHarden(world, blockposition, iblockdata)) { + return super.getPlacedState(blockactioncontext); @@ -33,7 +33,7 @@ + + // TODO: An event factory call for methods like this + CraftBlockState blockState = CraftBlockState.getBlockState(world, blockposition); -+ blockState.setData(this.a); ++ blockState.setData(this.concrete); + + BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState); + world.getMinecraftServer().server.getPluginManager().callEvent(event); @@ -47,19 +47,19 @@ } private static boolean canHarden(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) { -@@ -72,6 +94,24 @@ +@@ -72,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.a : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); +- return a((IBlockAccess) generatoraccess, blockposition) ? this.concrete : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); + // CraftBukkit start + if (a((IBlockAccess) generatoraccess, blockposition)) { + // Suppress during worldgen + if (!(generatoraccess instanceof World)) { -+ return this.a; ++ return this.concrete; + } + CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition); -+ blockState.setData(this.a); ++ blockState.setData(this.concrete); + + BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState); + ((World) generatoraccess).getServer().getPluginManager().callEvent(event); @@ -72,4 +72,5 @@ + return super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); + // CraftBukkit end } - } + + @Override diff --git a/nms-patches/net/minecraft/world/level/block/BlockCoral.patch b/nms-patches/net/minecraft/world/level/block/BlockCoral.patch index 6a1a5843f..cfce2e65e 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCoral.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCoral.patch @@ -5,10 +5,10 @@ public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { if (!this.a((IBlockAccess) worldserver, blockposition)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.a.getBlockData()).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.deadBlock.getBlockData()).isCancelled()) { + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, this.a.getBlockData(), 2); + worldserver.setTypeAndData(blockposition, this.deadBlock.getBlockData(), 2); } diff --git a/nms-patches/net/minecraft/world/level/block/BlockCoralFan.patch b/nms-patches/net/minecraft/world/level/block/BlockCoralFan.patch index 61a602827..d2e4c6f94 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCoralFan.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCoralFan.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/BlockCoralFan.java +++ b/net/minecraft/world/level/block/BlockCoralFan.java -@@ -29,6 +29,11 @@ +@@ -28,6 +28,11 @@ @Override public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - if (!c(iblockdata, (IBlockAccess) worldserver, blockposition)) { + if (!e(iblockdata, worldserver, blockposition)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.a.getBlockData().set(BlockCoralFan.b, false)).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.deadBlock.getBlockData().set(BlockCoralFan.WATERLOGGED, false)).isCancelled()) { + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) this.a.getBlockData().set(BlockCoralFan.b, false), 2); + worldserver.setTypeAndData(blockposition, (IBlockData) this.deadBlock.getBlockData().set(BlockCoralFan.WATERLOGGED, false), 2); } diff --git a/nms-patches/net/minecraft/world/level/block/BlockCoralFanWall.patch b/nms-patches/net/minecraft/world/level/block/BlockCoralFanWall.patch index fe8f568e4..da6718f88 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCoralFanWall.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCoralFanWall.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/BlockCoralFanWall.java +++ b/net/minecraft/world/level/block/BlockCoralFanWall.java -@@ -29,6 +29,11 @@ +@@ -28,6 +28,11 @@ @Override public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - if (!c(iblockdata, (IBlockAccess) worldserver, blockposition)) { + if (!e(iblockdata, worldserver, blockposition)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.c.getBlockData().set(BlockCoralFanWall.b, false).set(BlockCoralFanWall.a, iblockdata.get(BlockCoralFanWall.a))).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.deadBlock.getBlockData().set(BlockCoralFanWall.WATERLOGGED, false).set(BlockCoralFanWall.FACING, iblockdata.get(BlockCoralFanWall.FACING))).isCancelled()) { + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) ((IBlockData) this.c.getBlockData().set(BlockCoralFanWall.b, false)).set(BlockCoralFanWall.a, iblockdata.get(BlockCoralFanWall.a)), 2); + worldserver.setTypeAndData(blockposition, (IBlockData) ((IBlockData) this.deadBlock.getBlockData().set(BlockCoralFanWall.WATERLOGGED, false)).set(BlockCoralFanWall.FACING, (EnumDirection) iblockdata.get(BlockCoralFanWall.FACING)), 2); } diff --git a/nms-patches/net/minecraft/world/level/block/BlockCoralPlant.patch b/nms-patches/net/minecraft/world/level/block/BlockCoralPlant.patch index f5c84b508..47b84ee9b 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCoralPlant.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCoralPlant.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/BlockCoralPlant.java +++ b/net/minecraft/world/level/block/BlockCoralPlant.java -@@ -32,6 +32,11 @@ +@@ -33,6 +33,11 @@ @Override public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - if (!c(iblockdata, (IBlockAccess) worldserver, blockposition)) { + if (!e(iblockdata, worldserver, blockposition)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.c.getBlockData().set(BlockCoralPlant.b, false)).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.deadBlock.getBlockData().set(BlockCoralPlant.WATERLOGGED, false)).isCancelled()) { + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) this.c.getBlockData().set(BlockCoralPlant.b, false), 2); + worldserver.setTypeAndData(blockposition, (IBlockData) this.deadBlock.getBlockData().set(BlockCoralPlant.WATERLOGGED, false), 2); } diff --git a/nms-patches/net/minecraft/world/level/block/BlockCrops.patch b/nms-patches/net/minecraft/world/level/block/BlockCrops.patch index 1cc918121..7ae016a7d 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCrops.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCrops.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCrops.java +++ b/net/minecraft/world/level/block/BlockCrops.java -@@ -18,6 +18,8 @@ +@@ -21,6 +21,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -8,8 +8,8 @@ + public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement { - public static final BlockStateInteger AGE = BlockProperties.ai; -@@ -72,7 +74,7 @@ + public static final int MAX_AGE = 7; +@@ -76,7 +78,7 @@ float f = a((Block) this, (IBlockAccess) worldserver, blockposition); if (random.nextInt((int) (25.0F / f) + 1) == 0) { @@ -18,7 +18,7 @@ } } } -@@ -87,7 +89,7 @@ +@@ -91,7 +93,7 @@ i = j; } @@ -27,12 +27,12 @@ } protected int a(World world) { -@@ -145,7 +147,7 @@ +@@ -149,7 +151,7 @@ @Override public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { -- if (entity instanceof EntityRavager && world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) { -+ if (entity instanceof EntityRavager && !CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.getBlockData(), !world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)).isCancelled()) { // CraftBukkit +- 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); } diff --git a/nms-patches/net/minecraft/world/level/block/BlockDaylightDetector.patch b/nms-patches/net/minecraft/world/level/block/BlockDaylightDetector.patch index 32e5a8226..a25715e10 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockDaylightDetector.patch +++ b/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 -@@ -65,6 +65,7 @@ +@@ -67,6 +67,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, 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); + } diff --git a/nms-patches/net/minecraft/world/level/block/BlockDiodeAbstract.patch b/nms-patches/net/minecraft/world/level/block/BlockDiodeAbstract.patch index 5296f6030..43f602864 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockDiodeAbstract.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockDiodeAbstract.patch @@ -8,7 +8,7 @@ + public abstract class BlockDiodeAbstract extends BlockFacingHorizontal { - protected static final VoxelShape b = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D); + 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); @@ -18,13 +18,13 @@ + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.c, false), 2); + worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(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.c, true), 2); + worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.POWERED, true), 2); if (!flag1) { worldserver.getBlockTickList().a(blockposition, this, this.g(iblockdata), TickListPriority.VERY_HIGH); diff --git a/nms-patches/net/minecraft/world/level/block/BlockDirtSnowSpreadable.patch b/nms-patches/net/minecraft/world/level/block/BlockDirtSnowSpreadable.patch index 1d6fc7b17..621967b80 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockDirtSnowSpreadable.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockDirtSnowSpreadable.patch @@ -13,11 +13,11 @@ } else { if (worldserver.getLightLevel(blockposition.up()) >= 9) { @@ -51,7 +56,7 @@ - BlockPosition blockposition1 = blockposition.b(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1); + BlockPosition blockposition1 = blockposition.c(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.a, worldserver.getType(blockposition1.up()).a(Blocks.SNOW))); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, (IBlockData) iblockdata1.set(BlockDirtSnowSpreadable.a, worldserver.getType(blockposition1.up()).a(Blocks.SNOW))); // CraftBukkit +- 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 } } } diff --git a/nms-patches/net/minecraft/world/level/block/BlockDispenser.patch b/nms-patches/net/minecraft/world/level/block/BlockDispenser.patch index db9105998..0036c4b9c 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockDispenser.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockDispenser.patch @@ -1,21 +1,22 @@ --- a/net/minecraft/world/level/block/BlockDispenser.java +++ b/net/minecraft/world/level/block/BlockDispenser.java -@@ -41,9 +41,10 @@ +@@ -41,10 +41,11 @@ public static final BlockStateDirection FACING = BlockDirectional.FACING; - public static final BlockStateBoolean TRIGGERED = BlockProperties.A; -- public static final Map REGISTRY = (Map) SystemUtils.a((Object) (new Object2ObjectOpenHashMap()), (object2objectopenhashmap) -> { -+ public static final Map REGISTRY = (Map) SystemUtils.a((new Object2ObjectOpenHashMap()), (object2objectopenhashmap) -> { // CraftBukkit - decompile error + public static final BlockStateBoolean TRIGGERED = BlockProperties.TRIGGERED; +- public static final Map DISPENSER_REGISTRY = (Map) SystemUtils.a((Object) (new Object2ObjectOpenHashMap()), (object2objectopenhashmap) -> { ++ public static final Map DISPENSER_REGISTRY = (Map) SystemUtils.a((new Object2ObjectOpenHashMap()), (object2objectopenhashmap) -> { // CraftBukkit - decompile error 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.REGISTRY.put(imaterial.getItem(), idispensebehavior); -@@ -86,6 +87,7 @@ + BlockDispenser.DISPENSER_REGISTRY.put(imaterial.getItem(), idispensebehavior); +@@ -88,6 +89,7 @@ IDispenseBehavior idispensebehavior = this.a(itemstack); - if (idispensebehavior != IDispenseBehavior.NONE) { + if (idispensebehavior != IDispenseBehavior.NOOP) { + eventFired = false; // CraftBukkit - reset event status tileentitydispenser.setItem(i, idispensebehavior.dispense(sourceblock, itemstack)); } diff --git a/nms-patches/net/minecraft/world/level/block/BlockDoor.patch b/nms-patches/net/minecraft/world/level/block/BlockDoor.patch index 183d8b275..1457f6dbc 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockDoor.patch +++ b/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 -@@ -31,6 +31,8 @@ +@@ -34,6 +34,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -9,7 +9,7 @@ public class BlockDoor extends Block { public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING; -@@ -186,9 +188,24 @@ +@@ -192,9 +194,24 @@ @Override public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) { @@ -30,9 +30,9 @@ + BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power); + world.getServer().getPluginManager().callEvent(eventRedstone); -- if (block != this && flag1 != (Boolean) iblockdata.get(BlockDoor.POWERED)) { +- if (!this.getBlockData().a(block) && flag1 != (Boolean) iblockdata.get(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); diff --git a/nms-patches/net/minecraft/world/level/block/BlockDragonEgg.patch b/nms-patches/net/minecraft/world/level/block/BlockDragonEgg.patch index ed2fb2ce0..9023ea854 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockDragonEgg.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockDragonEgg.patch @@ -8,9 +8,9 @@ + public class BlockDragonEgg extends BlockFalling { - protected static final VoxelShape a = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D); + 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.b(world.random.nextInt(16) - world.random.nextInt(16), world.random.nextInt(8) - world.random.nextInt(8), world.random.nextInt(16) - world.random.nextInt(16)); + 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)); if (world.getType(blockposition1).isAir()) { + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/level/block/BlockDropper.patch b/nms-patches/net/minecraft/world/level/block/BlockDropper.patch index d0bb1f438..84a00f1f5 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockDropper.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockDropper.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/BlockDropper.java +++ b/net/minecraft/world/level/block/BlockDropper.java @@ -16,6 +16,12 @@ - import net.minecraft.world.level.block.entity.TileEntityHopper; import net.minecraft.world.level.block.state.BlockBase; + import net.minecraft.world.level.block.state.IBlockData; +// CraftBukkit start +import net.minecraft.world.InventoryLargeChest; @@ -12,10 +12,10 @@ + public class BlockDropper extends BlockDispenser { - private static final IDispenseBehavior c = new DispenseBehaviorItem(); + private static final IDispenseBehavior DISPENSE_BEHAVIOUR = new DispenseBehaviorItem(); @@ -53,8 +59,25 @@ if (iinventory == null) { - itemstack1 = BlockDropper.c.dispense(sourceblock, itemstack); + itemstack1 = BlockDropper.DISPENSE_BEHAVIOUR.dispense(sourceblock, itemstack); } else { - itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, itemstack.cloneItemStack().cloneAndSubtract(1), enumdirection.opposite()); - if (itemstack1.isEmpty()) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch b/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch index 8856533be..fdd6ec43b 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockEnderPortal.java +++ b/net/minecraft/world/level/block/BlockEnderPortal.java -@@ -16,6 +16,13 @@ +@@ -19,6 +19,13 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -13,13 +13,13 @@ + public class BlockEnderPortal extends BlockTileEntity { - protected static final VoxelShape a = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 12.0D, 16.0D); -@@ -37,13 +44,22 @@ + protected static final VoxelShape SHAPE = Block.a(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 resourcekey = world.getDimensionKey() == World.THE_END ? World.OVERWORLD : World.THE_END; -+ ResourceKey resourcekey = world.getTypeKey() == DimensionManager.THE_END ? World.OVERWORLD : World.THE_END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends +- ResourceKey resourcekey = world.getDimensionKey() == World.END ? World.OVERWORLD : World.END; ++ ResourceKey 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); if (worldserver == null) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch b/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch index 1f6dccae6..db7231ade 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockFenceGate.java +++ b/net/minecraft/world/level/block/BlockFenceGate.java -@@ -125,6 +125,17 @@ +@@ -130,6 +130,17 @@ public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) { if (!world.isClientSide) { boolean flag1 = world.isBlockIndirectlyPowered(blockposition); diff --git a/nms-patches/net/minecraft/world/level/block/BlockFire.patch b/nms-patches/net/minecraft/world/level/block/BlockFire.patch index cd886028c..fd0297adc 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockFire.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockFire.patch @@ -13,8 +13,8 @@ + public class BlockFire extends BlockFireAbstract { - public static final BlockStateInteger AGE = BlockProperties.aj; -@@ -84,7 +91,24 @@ + public static final int MAX_AGE = 15; +@@ -93,7 +100,24 @@ @Override public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { @@ -40,16 +40,16 @@ } @Override -@@ -133,7 +157,7 @@ +@@ -142,7 +166,7 @@ worldserver.getBlockTickList().a(blockposition, this, a(worldserver.random)); - if (worldserver.getGameRules().getBoolean(GameRules.DO_FIRE_TICK)) { + if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { if (!iblockdata.canPlace(worldserver, blockposition)) { - worldserver.a(blockposition, false); + fireExtinguished(worldserver, blockposition); // CraftBukkit - invalid place location } IBlockData iblockdata1 = worldserver.getType(blockposition.down()); -@@ -141,7 +165,7 @@ +@@ -150,7 +174,7 @@ int i = (Integer) iblockdata.get(BlockFire.AGE); if (!flag && worldserver.isRaining() && this.a((World) worldserver, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) { @@ -58,7 +58,7 @@ } else { int j = Math.min(15, i + random.nextInt(3) / 2); -@@ -155,14 +179,14 @@ +@@ -164,14 +188,14 @@ BlockPosition blockposition1 = blockposition.down(); if (!worldserver.getType(blockposition1).d(worldserver, blockposition1, EnumDirection.UP) || i > 3) { @@ -69,13 +69,13 @@ return; } - if (i == 15 && random.nextInt(4) == 0 && !this.e(worldserver.getType(blockposition.down()))) { + if (i == 15 && random.nextInt(4) == 0 && !this.f(worldserver.getType(blockposition.down()))) { - worldserver.a(blockposition, false); + fireExtinguished(worldserver, blockposition); // CraftBukkit return; } } -@@ -170,12 +194,14 @@ +@@ -179,12 +203,14 @@ boolean flag1 = worldserver.u(blockposition); int k = flag1 ? -50 : 0; @@ -96,7 +96,7 @@ BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition(); for (int l = -1; l <= 1; ++l) { -@@ -201,7 +227,15 @@ +@@ -210,7 +236,15 @@ if (i2 > 0 && random.nextInt(k1) <= i2 && (!worldserver.isRaining() || !this.a((World) worldserver, (BlockPosition) blockposition_mutableblockposition))) { int j2 = Math.min(15, i + random.nextInt(5) / 4); @@ -113,8 +113,8 @@ } } } -@@ -225,12 +259,24 @@ - return iblockdata.b(BlockProperties.C) && (Boolean) iblockdata.get(BlockProperties.C) ? 0 : this.flameChances.getInt(iblockdata.getBlock()); +@@ -234,12 +268,24 @@ + return iblockdata.b(BlockProperties.WATERLOGGED) && (Boolean) iblockdata.get(BlockProperties.WATERLOGGED) ? 0 : this.flameOdds.getInt(iblockdata.getBlock()); } - private void trySpread(World world, BlockPosition blockposition, int i, Random random, int j) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch b/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch index e532aee98..4152a9f98 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockFireAbstract.java +++ b/net/minecraft/world/level/block/BlockFireAbstract.java -@@ -50,7 +50,14 @@ +@@ -125,7 +125,14 @@ if (!entity.isFireProof()) { entity.setFireTicks(entity.getFireTicks() + 1); if (entity.getFireTicks() == 0) { @@ -15,8 +15,8 @@ + // CraftBukkit end } - entity.damageEntity(DamageSource.FIRE, this.b); -@@ -72,14 +79,14 @@ + entity.damageEntity(DamageSource.IN_FIRE, this.fireDamage); +@@ -147,14 +154,14 @@ } if (!iblockdata.canPlace(world, blockposition)) { @@ -28,12 +28,12 @@ } private static boolean a(World world) { -- return world.getDimensionKey() == World.OVERWORLD || world.getDimensionKey() == World.THE_NETHER; -+ return world.getTypeKey() == net.minecraft.world.level.dimension.DimensionManager.OVERWORLD || world.getTypeKey() == net.minecraft.world.level.dimension.DimensionManager.THE_NETHER; // CraftBukkit - getTypeKey() +- return world.getDimensionKey() == World.OVERWORLD || world.getDimensionKey() == 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 -@@ -123,4 +130,12 @@ +@@ -202,4 +209,12 @@ } } } diff --git a/nms-patches/net/minecraft/world/level/block/BlockFluids.patch b/nms-patches/net/minecraft/world/level/block/BlockFluids.patch index c6a739a81..566334348 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockFluids.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockFluids.patch @@ -1,27 +1,27 @@ --- a/net/minecraft/world/level/block/BlockFluids.java +++ b/net/minecraft/world/level/block/BlockFluids.java -@@ -137,14 +137,20 @@ - if (world.getFluid(blockposition1).a((Tag) TagsFluid.WATER)) { - Block block = world.getFluid(blockposition).isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE; +@@ -143,14 +143,20 @@ + if (world.getFluid(blockposition1).a((Tag) TagsFluid.WATER)) { + Block block = world.getFluid(blockposition).isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE; -- world.setTypeUpdate(blockposition, block.getBlockData()); -- this.fizz(world, blockposition); -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, block.getBlockData())) { -+ this.fizz(world, blockposition); -+ } -+ // CraftBukkit end - return false; - } - - if (flag && world.getType(blockposition1).a(Blocks.BLUE_ICE)) { -- world.setTypeUpdate(blockposition, Blocks.BASALT.getBlockData()); -- this.fizz(world, blockposition); -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.BASALT.getBlockData())) { -+ this.fizz(world, blockposition); -+ } -+ // CraftBukkit end - return false; - } +- world.setTypeUpdate(blockposition, block.getBlockData()); +- this.fizz(world, blockposition); ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, block.getBlockData())) { ++ this.fizz(world, blockposition); ++ } ++ // CraftBukkit end + return false; } + + if (flag && world.getType(blockposition1).a(Blocks.BLUE_ICE)) { +- world.setTypeUpdate(blockposition, Blocks.BASALT.getBlockData()); +- this.fizz(world, blockposition); ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.BASALT.getBlockData())) { ++ this.fizz(world, blockposition); ++ } ++ // CraftBukkit end + return false; + } + } diff --git a/nms-patches/net/minecraft/world/level/block/BlockFungi.patch b/nms-patches/net/minecraft/world/level/block/BlockFungi.patch index fdfbb6d4a..8ca017419 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockFungi.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockFungi.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockFungi.java +++ b/net/minecraft/world/level/block/BlockFungi.java -@@ -50,6 +50,13 @@ +@@ -51,6 +51,13 @@ @Override public void a(WorldServer worldserver, Random random, BlockPosition blockposition, IBlockData iblockdata) { @@ -11,6 +11,6 @@ + BlockSapling.treeType = org.bukkit.TreeType.CRIMSON_FUNGUS; + } + // CraftBukkit end - ((WorldGenFeatureConfigured) this.b.get()).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), random, blockposition); + ((WorldGenFeatureConfigured) this.feature.get()).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), random, blockposition); } } diff --git a/nms-patches/net/minecraft/world/level/block/BlockGrass.patch b/nms-patches/net/minecraft/world/level/block/BlockGrass.patch index fb9bc0117..df4cdce88 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockGrass.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockGrass.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockGrass.java +++ b/net/minecraft/world/level/block/BlockGrass.java -@@ -72,7 +72,7 @@ +@@ -70,7 +70,7 @@ } if (iblockdata3.canPlace(worldserver, blockposition2)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockGrowingTop.patch b/nms-patches/net/minecraft/world/level/block/BlockGrowingTop.patch index 75e697a55..75f188c15 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockGrowingTop.patch +++ b/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 -@@ -44,7 +44,7 @@ - BlockPosition blockposition1 = blockposition.shift(this.a); +@@ -45,7 +45,7 @@ + BlockPosition blockposition1 = blockposition.shift(this.growthDirection); - if (this.h(worldserver.getType(blockposition1))) { -- worldserver.setTypeUpdate(blockposition1, (IBlockData) iblockdata.a((IBlockState) BlockGrowingTop.d)); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, (IBlockData) iblockdata.a((IBlockState) BlockGrowingTop.d)); // CraftBukkit + 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 } } diff --git a/nms-patches/net/minecraft/world/level/block/BlockJukeBox.patch b/nms-patches/net/minecraft/world/level/block/BlockJukeBox.patch index 9f7002ce6..7880c2266 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockJukeBox.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockJukeBox.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockJukeBox.java +++ b/net/minecraft/world/level/block/BlockJukeBox.java -@@ -63,7 +63,13 @@ +@@ -62,7 +62,13 @@ TileEntity tileentity = generatoraccess.getTileEntity(blockposition); if (tileentity instanceof TileEntityJukeBox) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch b/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch index 2d51051cf..bf6879a93 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch +++ b/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 -@@ -19,6 +19,8 @@ +@@ -21,6 +21,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -8,8 +8,8 @@ + public class BlockLeaves extends Block { - public static final BlockStateInteger DISTANCE = BlockProperties.an; -@@ -42,6 +44,14 @@ + public static final int DECAY_DISTANCE = 7; +@@ -46,6 +48,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) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockLectern.patch b/nms-patches/net/minecraft/world/level/block/BlockLectern.patch index 182db2ec5..1a5b5ad8f 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockLectern.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockLectern.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockLectern.java +++ b/net/minecraft/world/level/block/BlockLectern.java -@@ -196,12 +196,13 @@ +@@ -199,12 +199,13 @@ } private void d(IBlockData iblockdata, World world, BlockPosition blockposition) { @@ -9,7 +9,7 @@ if (tileentity instanceof TileEntityLectern) { TileEntityLectern tileentitylectern = (TileEntityLectern) tileentity; - EnumDirection enumdirection = (EnumDirection) iblockdata.get(BlockLectern.a); + EnumDirection enumdirection = (EnumDirection) iblockdata.get(BlockLectern.FACING); ItemStack itemstack = tileentitylectern.getBook().cloneItemStack(); + if (itemstack.isEmpty()) return; // CraftBukkit - SPIGOT-5500 float f = 0.25F * (float) enumdirection.getAdjacentX(); diff --git a/nms-patches/net/minecraft/world/level/block/BlockLever.patch b/nms-patches/net/minecraft/world/level/block/BlockLever.patch index 96472a754..7b828bc89 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockLever.patch +++ b/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 -@@ -22,6 +22,8 @@ +@@ -25,6 +25,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -8,8 +8,8 @@ + public class BlockLever extends BlockAttachable { - public static final BlockStateBoolean POWERED = BlockProperties.w; -@@ -86,6 +88,20 @@ + public static final BlockStateBoolean POWERED = BlockProperties.POWERED; +@@ -92,6 +94,20 @@ return EnumInteractionResult.SUCCESS; } else { diff --git a/nms-patches/net/minecraft/world/level/block/BlockMagma.patch b/nms-patches/net/minecraft/world/level/block/BlockMagma.patch index 57ee64aaf..cda1c85d7 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockMagma.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockMagma.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/block/BlockMagma.java +++ b/net/minecraft/world/level/block/BlockMagma.java -@@ -28,7 +28,9 @@ +@@ -30,7 +30,9 @@ @Override - public void stepOn(World world, BlockPosition blockposition, Entity entity) { + public void stepOn(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { if (!entity.isFireProof() && entity instanceof EntityLiving && !EnchantmentManager.i((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); + org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = null; // CraftBukkit } - super.stepOn(world, blockposition, entity); + super.stepOn(world, blockposition, iblockdata, entity); diff --git a/nms-patches/net/minecraft/world/level/block/BlockMinecartDetector.patch b/nms-patches/net/minecraft/world/level/block/BlockMinecartDetector.patch index ae590673b..46d2f1bfb 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockMinecartDetector.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockMinecartDetector.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockMinecartDetector.java +++ b/net/minecraft/world/level/block/BlockMinecartDetector.java -@@ -26,6 +26,8 @@ +@@ -25,6 +25,8 @@ import net.minecraft.world.level.block.state.properties.IBlockState; import net.minecraft.world.phys.AxisAlignedBB; @@ -8,8 +8,8 @@ + public class BlockMinecartDetector extends BlockMinecartTrackAbstract { - public static final BlockStateEnum SHAPE = BlockProperties.ad; -@@ -78,6 +80,16 @@ + public static final BlockStateEnum SHAPE = BlockProperties.RAIL_SHAPE_STRAIGHT; +@@ -80,6 +82,16 @@ } IBlockData iblockdata1; diff --git a/nms-patches/net/minecraft/world/level/block/BlockMobSpawner.patch b/nms-patches/net/minecraft/world/level/block/BlockMobSpawner.patch index 7f4ede58d..985d0ac8b 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockMobSpawner.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockMobSpawner.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockMobSpawner.java +++ b/net/minecraft/world/level/block/BlockMobSpawner.java -@@ -23,9 +23,19 @@ +@@ -33,9 +33,19 @@ @Override public void dropNaturally(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { super.dropNaturally(iblockdata, worldserver, blockposition, itemstack); diff --git a/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch b/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch index 9ec317fc8..5ea5b2762 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/BlockMonsterEggs.java +++ b/net/minecraft/world/level/block/BlockMonsterEggs.java -@@ -15,6 +15,8 @@ - import net.minecraft.world.level.block.state.BlockBase; +@@ -18,6 +18,8 @@ import net.minecraft.world.level.block.state.IBlockData; + import net.minecraft.world.level.block.state.properties.IBlockState; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; // CraftBukkit + public class BlockMonsterEggs extends Block { - private final Block a; -@@ -38,7 +40,7 @@ + private final Block hostBlock; +@@ -43,7 +45,7 @@ EntitySilverfish entitysilverfish = (EntitySilverfish) EntityTypes.SILVERFISH.a((World) worldserver); entitysilverfish.setPositionRotation((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F); diff --git a/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch b/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch index a50bea1fc..15a306cff 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch @@ -10,8 +10,8 @@ + public class BlockMushroom extends BlockPlant implements IBlockFragilePlantElement { - protected static final VoxelShape a = Block.a(5.0D, 0.0D, 5.0D, 11.0D, 6.0D, 11.0D); -@@ -58,7 +62,7 @@ + protected static final float AABB_OFFSET = 3.0F; +@@ -61,7 +65,7 @@ } if (worldserver.isEmpty(blockposition2) && iblockdata.canPlace(worldserver, blockposition2)) { @@ -21,18 +21,10 @@ } @@ -82,6 +86,7 @@ - WorldGenFeatureConfigured worldgenfeatureconfigured; - if (this == Blocks.BROWN_MUSHROOM) { -+ BlockSapling.treeType = TreeType.BROWN_MUSHROOM; // CraftBukkit - worldgenfeatureconfigured = BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM; + public boolean a(WorldServer worldserver, BlockPosition blockposition, IBlockData iblockdata, Random random) { + worldserver.a(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)) { + return true; } else { - if (this != Blocks.RED_MUSHROOM) { -@@ -89,6 +94,7 @@ - return false; - } - -+ BlockSapling.treeType = TreeType.RED_MUSHROOM; // CraftBukkit - worldgenfeatureconfigured = BiomeDecoratorGroups.HUGE_RED_MUSHROOM; - } - diff --git a/nms-patches/net/minecraft/world/level/block/BlockNetherWart.patch b/nms-patches/net/minecraft/world/level/block/BlockNetherWart.patch index be21279b5..2cf667a46 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockNetherWart.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockNetherWart.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockNetherWart.java +++ b/net/minecraft/world/level/block/BlockNetherWart.java -@@ -43,7 +43,7 @@ +@@ -46,7 +46,7 @@ if (i < 3 && random.nextInt(10) == 0) { iblockdata = (IBlockData) iblockdata.set(BlockNetherWart.AGE, i + 1); diff --git a/nms-patches/net/minecraft/world/level/block/BlockObserver.patch b/nms-patches/net/minecraft/world/level/block/BlockObserver.patch index ab8938468..bbaabcfdf 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockObserver.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockObserver.patch @@ -8,23 +8,23 @@ + public class BlockObserver extends BlockDirectional { - public static final BlockStateBoolean b = BlockProperties.w; + 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.b)) { + if ((Boolean) iblockdata.get(BlockObserver.POWERED)) { + // CraftBukkit start + if (CraftEventFactory.callRedstoneChange(worldserver, blockposition, 15, 0).getNewCurrent() != 0) { + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockObserver.b, false), 2); + worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(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.b, true), 2); + worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockObserver.POWERED, true), 2); worldserver.getBlockTickList().a(blockposition, this, 2); } diff --git a/nms-patches/net/minecraft/world/level/block/BlockOre.patch b/nms-patches/net/minecraft/world/level/block/BlockOre.patch index 48a495484..c0109dc12 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockOre.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockOre.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/BlockOre.java +++ b/net/minecraft/world/level/block/BlockOre.java -@@ -23,6 +23,7 @@ +@@ -25,6 +25,7 @@ @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.a(worldserver.random); + int i = this.xpRange.a(worldserver.random); -@@ -30,6 +31,21 @@ +@@ -32,6 +33,21 @@ this.dropExperience(worldserver, blockposition, i); } } @@ -19,7 +19,7 @@ + @Override + public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { + if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { -+ int i = this.a(worldserver.random); ++ int i = this.xpRange.a(worldserver.random); + + if (i > 0) { + return i; diff --git a/nms-patches/net/minecraft/world/level/block/BlockPlant.patch b/nms-patches/net/minecraft/world/level/block/BlockPlant.patch index 1a21f2e0f..1c0d46a34 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockPlant.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockPlant.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockPlant.java +++ b/net/minecraft/world/level/block/BlockPlant.java -@@ -21,7 +21,14 @@ +@@ -23,7 +23,14 @@ @Override public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockPortal.patch b/nms-patches/net/minecraft/world/level/block/BlockPortal.patch index c3e8cdd1f..0715794c3 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockPortal.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockPortal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockPortal.java +++ b/net/minecraft/world/level/block/BlockPortal.java -@@ -23,6 +23,10 @@ +@@ -27,6 +27,10 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -10,8 +10,8 @@ + public class BlockPortal extends Block { - public static final BlockStateEnum AXIS = BlockProperties.E; -@@ -53,7 +57,8 @@ + public static final BlockStateEnum AXIS = BlockProperties.HORIZONTAL_AXIS; +@@ -58,7 +62,8 @@ } if (worldserver.getType(blockposition).a((IBlockAccess) worldserver, blockposition, EntityTypes.ZOMBIFIED_PIGLIN)) { @@ -21,7 +21,7 @@ if (entity != null) { entity.resetPortalCooldown(); -@@ -75,6 +80,10 @@ +@@ -80,6 +85,10 @@ @Override public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { if (!entity.isPassenger() && !entity.isVehicle() && entity.canPortal()) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockPoweredRail.patch b/nms-patches/net/minecraft/world/level/block/BlockPoweredRail.patch index 36fb21512..0759c8244 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockPoweredRail.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockPoweredRail.patch @@ -8,7 +8,7 @@ + public class BlockPoweredRail extends BlockMinecartTrackAbstract { - public static final BlockStateEnum SHAPE = BlockProperties.ad; + public static final BlockStateEnum 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); @@ -22,4 +22,4 @@ + // CraftBukkit end world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockPoweredRail.POWERED, flag1), 3); world.applyPhysics(blockposition.down(), this); - if (((BlockPropertyTrackPosition) iblockdata.get(BlockPoweredRail.SHAPE)).c()) { + if (((BlockPropertyTrackPosition) iblockdata.get(BlockPoweredRail.SHAPE)).b()) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockPressurePlateAbstract.patch b/nms-patches/net/minecraft/world/level/block/BlockPressurePlateAbstract.patch index 72fc98ef5..fc3081142 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockPressurePlateAbstract.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockPressurePlateAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockPressurePlateAbstract.java +++ b/net/minecraft/world/level/block/BlockPressurePlateAbstract.java -@@ -16,6 +16,8 @@ +@@ -18,6 +18,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -8,8 +8,8 @@ + public abstract class BlockPressurePlateAbstract extends Block { - protected static final VoxelShape a = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 0.5D, 15.0D); -@@ -79,6 +81,19 @@ + protected static final VoxelShape PRESSED_AABB = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 0.5D, 15.0D); +@@ -81,6 +83,19 @@ boolean flag = i > 0; boolean flag1 = j > 0; diff --git a/nms-patches/net/minecraft/world/level/block/BlockPressurePlateBinary.patch b/nms-patches/net/minecraft/world/level/block/BlockPressurePlateBinary.patch index 2e99fd6c1..2161e591b 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockPressurePlateBinary.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockPressurePlateBinary.patch @@ -8,7 +8,7 @@ + public class BlockPressurePlateBinary extends BlockPressurePlateAbstract { - public static final BlockStateBoolean POWERED = BlockProperties.w; + public static final BlockStateBoolean POWERED = BlockProperties.POWERED; @@ -81,6 +83,26 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); diff --git a/nms-patches/net/minecraft/world/level/block/BlockPressurePlateWeighted.patch b/nms-patches/net/minecraft/world/level/block/BlockPressurePlateWeighted.patch index 3a36239cd..fd9fa7545 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockPressurePlateWeighted.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockPressurePlateWeighted.patch @@ -8,16 +8,16 @@ + public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract { - public static final BlockStateInteger POWER = BlockProperties.az; + public static final BlockStateInteger POWER = BlockProperties.POWER; @@ -27,7 +29,31 @@ @Override protected int b(World world, BlockPosition blockposition) { -- int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight); +- int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.TOUCH_AABB.a(blockposition)).size(), this.maxWeight); + // CraftBukkit start + // int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight); + int i = 0; -+ java.util.Iterator iterator = world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).iterator(); ++ java.util.Iterator iterator = world.a(Entity.class, BlockPressurePlateWeighted.TOUCH_AABB.a(blockposition)).iterator(); + + while (iterator.hasNext()) { + Entity entity = (Entity) iterator.next(); @@ -37,8 +37,8 @@ + } + } + -+ i = Math.min(i, this.weight); ++ i = Math.min(i, this.maxWeight); + // CraftBukkit end if (i > 0) { - float f = (float) Math.min(this.weight, i) / (float) this.weight; + float f = (float) Math.min(this.maxWeight, i) / (float) this.maxWeight; diff --git a/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch b/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch index ca3b643f0..3c6f90556 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch @@ -11,7 +11,7 @@ + public class BlockPumpkinCarved extends BlockFacingHorizontal implements ItemWearable { - public static final BlockStateDirection a = BlockFacingHorizontal.FACING; + public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING; @@ -64,19 +69,28 @@ EntityPlayer entityplayer; int j; diff --git a/nms-patches/net/minecraft/world/level/block/BlockRedstoneComparator.patch b/nms-patches/net/minecraft/world/level/block/BlockRedstoneComparator.patch index 72bd60127..feb76c041 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockRedstoneComparator.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockRedstoneComparator.patch @@ -8,8 +8,8 @@ + public class BlockRedstoneComparator extends BlockDiodeAbstract implements ITileEntity { - public static final BlockStateEnum MODE = BlockProperties.aG; -@@ -91,7 +93,8 @@ + public static final BlockStateEnum MODE = BlockProperties.MODE_COMPARATOR; +@@ -99,7 +101,8 @@ @Nullable private EntityItemFrame a(World world, EnumDirection enumdirection, BlockPosition blockposition) { @@ -19,8 +19,8 @@ return entityitemframe != null && entityitemframe.getDirection() == enumdirection; }); -@@ -146,8 +149,18 @@ - boolean flag1 = (Boolean) iblockdata.get(BlockRedstoneComparator.c); +@@ -154,8 +157,18 @@ + boolean flag1 = (Boolean) iblockdata.get(BlockRedstoneComparator.POWERED); if (flag1 && !flag) { + // CraftBukkit start @@ -28,13 +28,13 @@ + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneComparator.c, false), 2); + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(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.c, true), 2); + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneComparator.POWERED, true), 2); } diff --git a/nms-patches/net/minecraft/world/level/block/BlockRedstoneLamp.patch b/nms-patches/net/minecraft/world/level/block/BlockRedstoneLamp.patch index 778838990..9af94ef44 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockRedstoneLamp.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockRedstoneLamp.patch @@ -8,7 +8,7 @@ + public class BlockRedstoneLamp extends Block { - public static final BlockStateBoolean a = BlockRedstoneTorch.LIT; + public static final BlockStateBoolean LIT = BlockRedstoneTorch.LIT; @@ -36,6 +38,11 @@ if (flag1) { world.getBlockTickList().a(blockposition, this, 4); @@ -18,18 +18,18 @@ + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.a), 2); + world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.LIT), 2); } } @@ -46,6 +53,11 @@ @Override public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - if ((Boolean) iblockdata.get(BlockRedstoneLamp.a) && !worldserver.isBlockIndirectlyPowered(blockposition)) { + if ((Boolean) iblockdata.get(BlockRedstoneLamp.LIT) && !worldserver.isBlockIndirectlyPowered(blockposition)) { + // CraftBukkit start + if (CraftEventFactory.callRedstoneChange(worldserver, blockposition, 15, 0).getNewCurrent() != 0) { + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.a), 2); + worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.LIT), 2); } diff --git a/nms-patches/net/minecraft/world/level/block/BlockRedstoneOre.patch b/nms-patches/net/minecraft/world/level/block/BlockRedstoneOre.patch index 628ebf4c1..b90f562a7 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockRedstoneOre.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockRedstoneOre.patch @@ -11,7 +11,7 @@ + public class BlockRedstoneOre extends Block { - public static final BlockStateBoolean a = BlockRedstoneTorch.LIT; + public static final BlockStateBoolean LIT = BlockRedstoneTorch.LIT; @@ -32,14 +37,30 @@ @Override @@ -22,24 +22,24 @@ } @Override - public void stepOn(World world, BlockPosition blockposition, Entity entity) { -- interact(world.getType(blockposition), world, blockposition); -- super.stepOn(world, blockposition, entity); + public void stepOn(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { +- interact(iblockdata, world, blockposition); +- super.stepOn(world, blockposition, iblockdata, entity); + // CraftBukkit start -+ // interact(world.getType(blockposition), world, blockposition); -+ // super.stepOn(world, blockposition, entity); ++ // interact(iblockdata, world, blockposition); ++ // super.stepOn(world, blockposition, iblockdata, entity); + 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 -+ super.stepOn(world, blockposition, entity); ++ super.stepOn(world, blockposition, iblockdata, entity); + } + } else { + EntityInteractEvent event = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ())); + world.getServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { + interact(world.getType(blockposition), world, blockposition, entity); // add entity -+ super.stepOn(world, blockposition, entity); ++ super.stepOn(world, blockposition, iblockdata, entity); + } + } + // CraftBukkit end @@ -62,25 +62,25 @@ - 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.a)) { + if (!(Boolean) iblockdata.get(BlockRedstoneOre.LIT)) { + // CraftBukkit start -+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.set(BlockRedstoneOre.a, true)).isCancelled()) { ++ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.set(BlockRedstoneOre.LIT, true)).isCancelled()) { + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, true), 3); + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(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.a)) { + if ((Boolean) iblockdata.get(BlockRedstoneOre.LIT)) { + // CraftBukkit start -+ if (CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, iblockdata.set(BlockRedstoneOre.a, false)).isCancelled()) { ++ if (CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, iblockdata.set(BlockRedstoneOre.LIT, false)).isCancelled()) { + return; + } + // CraftBukkit end - worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, false), 3); + worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.LIT, false), 3); } @@ -79,12 +110,25 @@ @@ -108,4 +108,4 @@ + // CraftBukkit end } - private static void playEffect(World world, BlockPosition blockposition) { + @Override diff --git a/nms-patches/net/minecraft/world/level/block/BlockRedstoneTorch.patch b/nms-patches/net/minecraft/world/level/block/BlockRedstoneTorch.patch index 94cf28cf0..0fbc2319c 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockRedstoneTorch.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockRedstoneTorch.patch @@ -8,8 +8,8 @@ + public class BlockRedstoneTorch extends BlockTorch { - public static final BlockStateBoolean LIT = BlockProperties.r; -@@ -73,8 +75,24 @@ + public static final BlockStateBoolean LIT = BlockProperties.LIT; +@@ -77,8 +79,24 @@ list.remove(0); } @@ -34,7 +34,7 @@ worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, false), 3); if (a(worldserver, blockposition, true)) { worldserver.triggerEffect(1502, blockposition, 0); -@@ -82,6 +100,15 @@ +@@ -86,6 +104,15 @@ } } } else if (!flag && !a(worldserver, blockposition, false)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockRedstoneWire.patch b/nms-patches/net/minecraft/world/level/block/BlockRedstoneWire.patch index 5a8753f80..27efcc694 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockRedstoneWire.patch +++ b/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 -@@ -34,6 +34,8 @@ +@@ -38,6 +38,8 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -8,8 +8,17 @@ + public class BlockRedstoneWire extends Block { - public static final BlockStateEnum NORTH = BlockProperties.X; -@@ -238,7 +240,16 @@ + public static final BlockStateEnum NORTH = BlockProperties.NORTH_REDSTONE; +@@ -55,7 +57,7 @@ + private static final Map 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 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 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); diff --git a/nms-patches/net/minecraft/world/level/block/BlockReed.patch b/nms-patches/net/minecraft/world/level/block/BlockReed.patch index a0b56761d..dc5abbd77 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockReed.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockReed.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockReed.java +++ b/net/minecraft/world/level/block/BlockReed.java -@@ -55,7 +55,7 @@ +@@ -57,7 +57,7 @@ int j = (Integer) iblockdata.get(BlockReed.AGE); if (j == 15) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockSapling.patch b/nms-patches/net/minecraft/world/level/block/BlockSapling.patch index 65afc5237..4a4538033 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockSapling.patch +++ b/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,11 +15,19 @@ +@@ -15,12 +15,20 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -13,14 +13,15 @@ + public class BlockSapling extends BlockPlant implements IBlockFragilePlantElement { - public static final BlockStateInteger STAGE = BlockProperties.aA; - protected static final VoxelShape b = Block.a(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D); - private final WorldGenTreeProvider c; + 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); + private final WorldGenTreeProvider treeGrower; + public static TreeType treeType; // CraftBukkit protected BlockSapling(WorldGenTreeProvider worldgentreeprovider, BlockBase.Info blockbase_info) { super(blockbase_info); -@@ -35,7 +43,30 @@ +@@ -36,7 +44,30 @@ @Override public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { if (worldserver.getLightLevel(blockposition.up()) >= 9 && random.nextInt(7) == 0) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockScaffolding.patch b/nms-patches/net/minecraft/world/level/block/BlockScaffolding.patch index e3019e7a1..dd9fe1c7c 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockScaffolding.patch +++ b/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 -@@ -94,7 +94,7 @@ +@@ -96,7 +96,7 @@ int i = a((IBlockAccess) worldserver, blockposition); - IBlockData iblockdata1 = (IBlockData) ((IBlockData) iblockdata.set(BlockScaffolding.a, i)).set(BlockScaffolding.c, this.a(worldserver, blockposition, i)); + IBlockData iblockdata1 = (IBlockData) ((IBlockData) iblockdata.set(BlockScaffolding.DISTANCE, i)).set(BlockScaffolding.BOTTOM, this.a(worldserver, blockposition, i)); -- if ((Integer) iblockdata1.get(BlockScaffolding.a) == 7) { -+ if ((Integer) iblockdata1.get(BlockScaffolding.a) == 7 && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { // CraftBukkit - BlockFadeEvent - if ((Integer) iblockdata.get(BlockScaffolding.a) == 7) { - worldserver.addEntity(new EntityFallingBlock(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (IBlockData) iblockdata1.set(BlockScaffolding.b, false))); +- 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))); } else { diff --git a/nms-patches/net/minecraft/world/level/block/BlockSnow.patch b/nms-patches/net/minecraft/world/level/block/BlockSnow.patch index 7fb414a67..73190bf36 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockSnow.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockSnow.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockSnow.java +++ b/net/minecraft/world/level/block/BlockSnow.java -@@ -85,6 +85,11 @@ +@@ -87,6 +87,11 @@ @Override public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { if (worldserver.getBrightness(EnumSkyBlock.BLOCK, blockposition) > 11) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockSoil.patch b/nms-patches/net/minecraft/world/level/block/BlockSoil.patch index 893fcc629..47b004388 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockSoil.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockSoil.patch @@ -11,8 +11,8 @@ + public class BlockSoil extends Block { - public static final BlockStateInteger MOISTURE = BlockProperties.aw; -@@ -81,26 +86,49 @@ + public static final BlockStateInteger MOISTURE = BlockProperties.MOISTURE; +@@ -82,26 +87,49 @@ if (!a((IWorldReader) worldserver, blockposition) && !worldserver.isRainingAt(blockposition.up())) { if (i > 0) { @@ -29,9 +29,9 @@ } @Override - public void fallOn(World world, BlockPosition blockposition, Entity entity, float f) { -+ super.fallOn(world, 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.MOB_GRIEFING)) && entity.getWidth() * entity.getWidth() * entity.getHeight() > 0.512F) { + 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) { + // CraftBukkit start - Interact soil + org.bukkit.event.Cancellable cancellable; + if (entity instanceof EntityHuman) { @@ -49,11 +49,11 @@ + return; + } + // CraftBukkit end - fade(world.getType(blockposition), world, blockposition); + fade(iblockdata, world, blockposition); } -- super.fallOn(world, blockposition, entity, f); -+ // super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved up +- 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) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockSponge.patch b/nms-patches/net/minecraft/world/level/block/BlockSponge.patch index 9ae2263c5..253979c14 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockSponge.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockSponge.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/BlockSponge.java +++ b/net/minecraft/world/level/block/BlockSponge.java -@@ -16,6 +16,13 @@ - import net.minecraft.world.level.material.FluidTypes; +@@ -15,6 +15,13 @@ + import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Material; +// CraftBukkit start @@ -13,8 +13,8 @@ + public class BlockSponge extends Block { - protected BlockSponge(BlockBase.Info blockbase_info) { -@@ -48,6 +55,7 @@ + public static final int MAX_DEPTH = 6; +@@ -50,6 +57,7 @@ queue.add(new Tuple<>(blockposition, 0)); int i = 0; @@ -22,7 +22,7 @@ while (!queue.isEmpty()) { Tuple tuple = (Tuple) queue.poll(); -@@ -59,27 +67,31 @@ +@@ -61,27 +69,31 @@ for (int l = 0; l < k; ++l) { EnumDirection enumdirection = aenumdirection[l]; BlockPosition blockposition2 = blockposition1.shift(enumdirection); @@ -35,8 +35,8 @@ Material material = iblockdata.getMaterial(); if (fluid.a((Tag) TagsFluid.WATER)) { -- if (iblockdata.getBlock() instanceof IFluidSource && ((IFluidSource) iblockdata.getBlock()).removeFluid(world, blockposition2, iblockdata) != FluidTypes.EMPTY) { -+ if (iblockdata.getBlock() instanceof IFluidSource && ((IFluidSource) iblockdata.getBlock()).removeFluid(blockList, blockposition2, iblockdata) != FluidTypes.EMPTY) { // CraftBukkit +- 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 ++i; if (j < 6) { queue.add(new Tuple<>(blockposition2, j + 1)); @@ -49,9 +49,9 @@ queue.add(new Tuple<>(blockposition2, j + 1)); } } else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) { -- TileEntity tileentity = iblockdata.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null; +- TileEntity tileentity = iblockdata.isTileEntity() ? world.getTileEntity(blockposition2) : null; + // CraftBukkit start -+ // TileEntity tileentity = iblockdata.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null; ++ // TileEntity tileentity = iblockdata.isTileEntity() ? world.getTileEntity(blockposition2) : null; - a(iblockdata, (GeneratorAccess) world, blockposition2, tileentity); - world.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3); @@ -61,7 +61,7 @@ ++i; if (j < 6) { queue.add(new Tuple<>(blockposition2, j + 1)); -@@ -92,6 +104,39 @@ +@@ -94,6 +106,39 @@ break; } } @@ -84,12 +84,12 @@ + Material material = iblockdata.getMaterial(); + + if (fluid.a(TagsFluid.WATER)) { -+ if (iblockdata.getBlock() instanceof IFluidSource && ((IFluidSource) iblockdata.getBlock()).removeFluid(blockList, blockposition2, iblockdata) != FluidTypes.EMPTY) { ++ if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).removeFluid(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.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null; ++ TileEntity tileentity = iblockdata.isTileEntity() ? world.getTileEntity(blockposition2) : null; + + a(iblockdata, world, blockposition2, tileentity); + } diff --git a/nms-patches/net/minecraft/world/level/block/BlockStem.patch b/nms-patches/net/minecraft/world/level/block/BlockStem.patch index 091761f81..08787546b 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockStem.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockStem.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockStem.java +++ b/net/minecraft/world/level/block/BlockStem.java -@@ -15,6 +15,8 @@ +@@ -21,6 +21,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -8,8 +8,8 @@ + public class BlockStem extends BlockPlant implements IBlockFragilePlantElement { - public static final BlockStateInteger AGE = BlockProperties.ai; -@@ -47,14 +49,18 @@ + public static final int MAX_AGE = 7; +@@ -57,14 +59,18 @@ if (i < 7) { iblockdata = (IBlockData) iblockdata.set(BlockStem.AGE, i + 1); @@ -20,17 +20,17 @@ BlockPosition blockposition1 = blockposition.shift(enumdirection); IBlockData iblockdata1 = worldserver.getType(blockposition1.down()); - if (worldserver.getType(blockposition1).isAir() && (iblockdata1.a(Blocks.FARMLAND) || iblockdata1.a(Blocks.DIRT) || iblockdata1.a(Blocks.COARSE_DIRT) || iblockdata1.a(Blocks.PODZOL) || iblockdata1.a(Blocks.GRASS_BLOCK))) { -- worldserver.setTypeUpdate(blockposition1, this.blockFruit.getBlockData()); + if (worldserver.getType(blockposition1).isAir() && (iblockdata1.a(Blocks.FARMLAND) || iblockdata1.a((Tag) TagsBlock.DIRT))) { +- worldserver.setTypeUpdate(blockposition1, this.fruit.getBlockData()); + // CraftBukkit start -+ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, this.blockFruit.getBlockData())) { ++ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, this.fruit.getBlockData())) { + return; + } + // CraftBukkit end - worldserver.setTypeUpdate(blockposition, (IBlockData) this.blockFruit.d().getBlockData().set(BlockFacingHorizontal.FACING, enumdirection)); + worldserver.setTypeUpdate(blockposition, (IBlockData) this.fruit.d().getBlockData().set(BlockFacingHorizontal.FACING, enumdirection)); } } -@@ -78,7 +84,7 @@ +@@ -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); diff --git a/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch b/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch index d974f401b..5d6ee0d51 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch @@ -14,18 +14,18 @@ + public class BlockSweetBerryBush extends BlockPlant implements IBlockFragilePlantElement { - public static final BlockStateInteger a = BlockProperties.ag; -@@ -52,7 +60,7 @@ - int i = (Integer) iblockdata.get(BlockSweetBerryBush.a); + private static final float HURT_SPEED_THRESHOLD = 0.003F; +@@ -59,7 +67,7 @@ + int i = (Integer) iblockdata.get(BlockSweetBerryBush.AGE); if (i < 3 && random.nextInt(5) == 0 && worldserver.getLightLevel(blockposition.up(), 0) >= 9) { -- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.a, i + 1), 2); -+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.a, i + 1), 2); // CraftBukkit +- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.AGE, i + 1), 2); ++ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.AGE, i + 1), 2); // CraftBukkit } } -@@ -66,7 +74,9 @@ - double d1 = Math.abs(entity.locZ() - entity.F); +@@ -73,7 +81,9 @@ + double d1 = Math.abs(entity.locZ() - entity.zOld); if (d0 >= 0.003000000026077032D || d1 >= 0.003000000026077032D) { + CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); // CraftBukkit @@ -34,7 +34,7 @@ } } -@@ -83,7 +93,15 @@ +@@ -90,7 +100,15 @@ } else if (i > 1) { int j = 1 + world.random.nextInt(2); @@ -48,6 +48,6 @@ + a(world, blockposition, CraftItemStack.asNMSCopy(itemStack)); + } + // CraftBukkit end - world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_SWEET_BERRIES_PICK_FROM_BUSH, SoundCategory.BLOCKS, 1.0F, 0.8F + world.random.nextFloat() * 0.4F); - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.a, 1), 2); + 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); diff --git a/nms-patches/net/minecraft/world/level/block/BlockTNT.patch b/nms-patches/net/minecraft/world/level/block/BlockTNT.patch index cbbf826de..436da0669 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTNT.patch +++ b/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 -@@ -115,6 +115,11 @@ +@@ -121,6 +121,11 @@ + Entity entity = iprojectile.getShooter(); - if (iprojectile.isBurning()) { - BlockPosition blockposition = movingobjectpositionblock.getBlockPosition(); + if (iprojectile.isBurning() && iprojectile.a(world, blockposition)) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { + return; + } + // CraftBukkit end - a(world, blockposition, entity instanceof EntityLiving ? (EntityLiving) entity : null); world.a(blockposition, false); + } diff --git a/nms-patches/net/minecraft/world/level/block/BlockTallPlant.patch b/nms-patches/net/minecraft/world/level/block/BlockTallPlant.patch index 2e45f966a..f0eaee368 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTallPlant.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockTallPlant.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockTallPlant.java +++ b/net/minecraft/world/level/block/BlockTallPlant.java -@@ -82,6 +82,11 @@ +@@ -84,6 +84,11 @@ } protected static void b(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch b/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch index d8014b649..0fa4ffc68 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch +++ b/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 -@@ -27,6 +27,8 @@ +@@ -29,6 +29,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -8,11 +8,11 @@ + public class BlockTrapdoor extends BlockFacingHorizontal implements IBlockWaterlogged { - public static final BlockStateBoolean OPEN = BlockProperties.u; -@@ -113,6 +115,19 @@ + public static final BlockStateBoolean OPEN = BlockProperties.OPEN; +@@ -117,6 +119,19 @@ boolean flag1 = world.isBlockIndirectlyPowered(blockposition); - if (flag1 != (Boolean) iblockdata.get(BlockTrapdoor.c)) { + if (flag1 != (Boolean) iblockdata.get(BlockTrapdoor.POWERED)) { + // CraftBukkit start + org.bukkit.World bworld = world.getWorld(); + org.bukkit.block.Block bblock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); diff --git a/nms-patches/net/minecraft/world/level/block/BlockTripwire.patch b/nms-patches/net/minecraft/world/level/block/BlockTripwire.patch index 53ff86300..724fe5e41 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTripwire.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockTripwire.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockTripwire.java +++ b/net/minecraft/world/level/block/BlockTripwire.java -@@ -23,6 +23,8 @@ +@@ -24,6 +24,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -8,8 +8,8 @@ + public class BlockTripwire extends Block { - public static final BlockStateBoolean POWERED = BlockProperties.w; -@@ -150,6 +152,40 @@ + public static final BlockStateBoolean POWERED = BlockProperties.POWERED; +@@ -153,6 +155,40 @@ } } diff --git a/nms-patches/net/minecraft/world/level/block/BlockTripwireHook.patch b/nms-patches/net/minecraft/world/level/block/BlockTripwireHook.patch index 255d64077..136c5b875 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTripwireHook.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockTripwireHook.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockTripwireHook.java +++ b/net/minecraft/world/level/block/BlockTripwireHook.java -@@ -25,6 +25,8 @@ +@@ -26,6 +26,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -9,7 +9,7 @@ public class BlockTripwireHook extends Block { public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING; -@@ -155,6 +157,17 @@ +@@ -160,6 +162,17 @@ this.a(world, blockposition1, flag4, flag5, flag2, flag3); } diff --git a/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch b/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch index 1413c1598..b298e8a93 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch @@ -12,38 +12,38 @@ + public class BlockTurtleEgg extends Block { - private static final VoxelShape c = Block.a(3.0D, 0.0D, 3.0D, 12.0D, 7.0D, 12.0D); + public static final int MAX_HATCH_LEVEL = 2; @@ -62,6 +68,19 @@ - IBlockData iblockdata = world.getType(blockposition); - - if (iblockdata.a(Blocks.TURTLE_EGG)) { -+ // CraftBukkit start - Step on eggs -+ org.bukkit.event.Cancellable cancellable; -+ if (entity instanceof EntityHuman) { -+ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null); -+ } else { -+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), CraftBlock.at(world, blockposition)); -+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable); -+ } + 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)) { ++ // CraftBukkit start - Step on eggs ++ org.bukkit.event.Cancellable cancellable; ++ if (entity instanceof EntityHuman) { ++ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null); ++ } else { ++ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), CraftBlock.at(world, blockposition)); ++ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable); ++ } + -+ if (cancellable.isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - this.a(world, blockposition, iblockdata); - } - } -@@ -88,9 +107,19 @@ - int i = (Integer) iblockdata.get(BlockTurtleEgg.a); - - if (i < 2) { -+ // CraftBukkit start - Call BlockGrowEvent -+ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata.set(BlockTurtleEgg.a, i + 1), 2)) { ++ if (cancellable.isCancelled()) { + return; + } + // CraftBukkit end - worldserver.playSound((EntityHuman) null, blockposition, SoundEffects.ENTITY_TURTLE_EGG_CRACK, SoundCategory.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F); -- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockTurtleEgg.a, i + 1), 2); + this.a(world, blockposition, iblockdata); + } + +@@ -87,9 +106,19 @@ + int i = (Integer) iblockdata.get(BlockTurtleEgg.HATCH); + + if (i < 2) { ++ // CraftBukkit start - Call BlockGrowEvent ++ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata.set(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 } else { + // CraftBukkit start - Call BlockFadeEvent @@ -51,10 +51,10 @@ + return; + } + // CraftBukkit end - worldserver.playSound((EntityHuman) null, blockposition, SoundEffects.ENTITY_TURTLE_EGG_HATCH, SoundCategory.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F); + worldserver.playSound((EntityHuman) null, blockposition, SoundEffects.TURTLE_EGG_HATCH, SoundCategory.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F); worldserver.a(blockposition, false); -@@ -101,7 +130,7 @@ +@@ -100,7 +129,7 @@ entityturtle.setAgeRaw(-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); diff --git a/nms-patches/net/minecraft/world/level/block/BlockVine.patch b/nms-patches/net/minecraft/world/level/block/BlockVine.patch index 61690537d..64a3121d9 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockVine.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockVine.patch @@ -8,8 +8,8 @@ + public class BlockVine extends Block { - public static final BlockStateBoolean UP = BlockSprawling.e; -@@ -190,20 +192,24 @@ + public static final BlockStateBoolean UP = BlockSprawling.UP; +@@ -196,20 +198,24 @@ BlockPosition blockposition3 = blockposition2.shift(enumdirection1); BlockPosition blockposition4 = blockposition2.shift(enumdirection2); @@ -31,7 +31,7 @@ } 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) worldserver.random.nextFloat() < 0.05D && a((IBlockAccess) worldserver, blockposition2.up(), EnumDirection.UP)) { + } 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); } @@ -39,7 +39,7 @@ } } else if (a((IBlockAccess) worldserver, blockposition2, enumdirection)) { worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(getDirection(enumdirection), true), 2); -@@ -233,7 +239,7 @@ +@@ -239,7 +245,7 @@ } if (this.canSpread(iblockdata2)) { @@ -48,7 +48,7 @@ } return; -@@ -248,7 +254,7 @@ +@@ -254,7 +260,7 @@ IBlockData iblockdata4 = this.a(iblockdata, iblockdata3, random); if (iblockdata3 != iblockdata4 && this.canSpread(iblockdata4)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch b/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch index f3ac4af49..b09c1cf82 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockWitherRose.java +++ b/net/minecraft/world/level/block/BlockWitherRose.java -@@ -31,7 +31,7 @@ +@@ -51,7 +51,7 @@ EntityLiving entityliving = (EntityLiving) entity; if (!entityliving.isInvulnerable(DamageSource.WITHER)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch b/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch index 19c83f006..da107d124 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch @@ -39,7 +39,7 @@ @@ -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.aA = shapedetector_shapedetectorcollection.getFacing().n() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F; + entitywither.yBodyRot = shapedetector_shapedetectorcollection.getFacing().n() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F; entitywither.beginSpawnSequence(); + // CraftBukkit start + if (!world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) { @@ -54,7 +54,7 @@ while (iterator.hasNext()) { @@ -82,7 +99,7 @@ - CriterionTriggers.n.a(entityplayer, (Entity) entitywither); + CriterionTriggers.SUMMONED_ENTITY.a(entityplayer, (Entity) entitywither); } - world.addEntity(entitywither); diff --git a/nms-patches/net/minecraft/world/level/block/BuddingAmethystBlock.patch b/nms-patches/net/minecraft/world/level/block/BuddingAmethystBlock.patch new file mode 100644 index 000000000..aa753f7fe --- /dev/null +++ b/nms-patches/net/minecraft/world/level/block/BuddingAmethystBlock.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/BuddingAmethystBlock.java ++++ 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); + +- worldserver.setTypeUpdate(blockposition1, iblockdata2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, iblockdata2); // CraftBukkit + } + + } diff --git a/nms-patches/net/minecraft/world/level/block/CaveVines.patch b/nms-patches/net/minecraft/world/level/block/CaveVines.patch new file mode 100644 index 000000000..2babaa141 --- /dev/null +++ b/nms-patches/net/minecraft/world/level/block/CaveVines.patch @@ -0,0 +1,48 @@ +--- a/net/minecraft/world/level/block/CaveVines.java ++++ b/net/minecraft/world/level/block/CaveVines.java +@@ -15,17 +15,43 @@ + import net.minecraft.world.level.block.state.properties.BlockStateBoolean; + import net.minecraft.world.phys.shapes.VoxelShape; + ++// CraftBukkit start ++import java.util.Collections; ++import net.minecraft.world.entity.Entity; ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.event.player.PlayerHarvestBlockEvent; ++// CraftBukkit end ++ + public interface CaveVines { + + VoxelShape SHAPE = Block.a(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)); ++ // CraftBukkit start ++ if (entity instanceof EntityHuman) { ++ PlayerHarvestBlockEvent event = CraftEventFactory.callPlayerHarvestBlockEvent(world, blockposition, (EntityHuman) entity, Collections.singletonList(new ItemStack(Items.GLOW_BERRIES, 1))); ++ 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()) { ++ Block.a(world, blockposition, CraftItemStack.asNMSCopy(itemStack)); ++ } ++ } else { ++ Block.a(world, blockposition, new ItemStack(Items.GLOW_BERRIES, 1)); ++ } ++ // CraftBukkit end ++ + float f = MathHelper.b(world.random, 0.8F, 1.2F); + + world.playSound((EntityHuman) null, blockposition, SoundEffects.CAVE_VINES_PICK_BERRIES, SoundCategory.BLOCKS, 1.0F, f); ++ // CraftBukkit start - call EntityChangeBlockEvent ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, (IBlockData) iblockdata.set(CaveVines.BERRIES, false)).isCancelled()) { ++ return EnumInteractionResult.SUCCESS; ++ } ++ // CraftBukkit end + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(CaveVines.BERRIES, false), 2); + return EnumInteractionResult.a(world.isClientSide); + } else { diff --git a/nms-patches/net/minecraft/world/level/block/CaveVinesBlock.patch b/nms-patches/net/minecraft/world/level/block/CaveVinesBlock.patch new file mode 100644 index 000000000..b938347ae --- /dev/null +++ b/nms-patches/net/minecraft/world/level/block/CaveVinesBlock.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/CaveVinesBlock.java ++++ b/net/minecraft/world/level/block/CaveVinesBlock.java +@@ -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 + } + + @Override diff --git a/nms-patches/net/minecraft/world/level/block/CaveVinesPlantBlock.patch b/nms-patches/net/minecraft/world/level/block/CaveVinesPlantBlock.patch new file mode 100644 index 000000000..f9836c2ac --- /dev/null +++ b/nms-patches/net/minecraft/world/level/block/CaveVinesPlantBlock.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/CaveVinesPlantBlock.java ++++ b/net/minecraft/world/level/block/CaveVinesPlantBlock.java +@@ -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 + } + + @Override diff --git a/nms-patches/net/minecraft/world/level/block/ChangeOverTimeBlock.patch b/nms-patches/net/minecraft/world/level/block/ChangeOverTimeBlock.patch new file mode 100644 index 000000000..a4f2d3d1e --- /dev/null +++ b/nms-patches/net/minecraft/world/level/block/ChangeOverTimeBlock.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/ChangeOverTimeBlock.java ++++ b/net/minecraft/world/level/block/ChangeOverTimeBlock.java +@@ -69,7 +69,7 @@ + + if (random.nextFloat() < f1) { + this.a(iblockdata).ifPresent((iblockdata2) -> { +- worldserver.setTypeUpdate(blockposition, iblockdata2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(worldserver, blockposition, iblockdata2); // CraftBukkit + }); + } + diff --git a/nms-patches/net/minecraft/world/level/block/LayeredCauldronBlock.patch b/nms-patches/net/minecraft/world/level/block/LayeredCauldronBlock.patch new file mode 100644 index 000000000..88125eeba --- /dev/null +++ b/nms-patches/net/minecraft/world/level/block/LayeredCauldronBlock.patch @@ -0,0 +1,85 @@ +--- a/net/minecraft/world/level/block/LayeredCauldronBlock.java ++++ b/net/minecraft/world/level/block/LayeredCauldronBlock.java +@@ -17,6 +17,11 @@ + import net.minecraft.world.level.material.FluidType; + import net.minecraft.world.level.material.FluidTypes; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.block.CraftBlockState; ++import org.bukkit.event.block.CauldronLevelChangeEvent; ++// CraftBukkit end ++ + public class LayeredCauldronBlock extends AbstractCauldronBlock { + + public static final int MIN_FILL_LEVEL = 1; +@@ -56,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(); ++ // CraftBukkit start + if (entity.a(world, blockposition)) { +- this.d(iblockdata, world, blockposition); ++ if (!decreaseLevel(iblockdata, world, blockposition, entity, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH)) { ++ return; ++ } + } ++ entity.extinguish(); ++ // CraftBukkit end + } + + } +@@ -69,15 +78,38 @@ + } + + public static void e(IBlockData iblockdata, World world, BlockPosition blockposition) { ++ // CraftBukkit start ++ decreaseLevel(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; + +- 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); + } + ++ // CraftBukkit start ++ public static boolean changeLevel(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData newBlock, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) { ++ CraftBlockState newState = CraftBlockState.getBlockState(world, blockposition); ++ newState.setData(newBlock); ++ ++ CauldronLevelChangeEvent event = new CauldronLevelChangeEvent( ++ world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), ++ (entity == null) ? null : entity.getBukkitEntity(), reason, newState ++ ); ++ world.getServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ return false; ++ } ++ newState.update(true); ++ return true; ++ } ++ // CraftBukkit end ++ + @Override + public void a(IBlockData iblockdata, World world, BlockPosition blockposition, BiomeBase.Precipitation biomebase_precipitation) { + if (BlockCauldron.a(world) && (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 + } + } + +@@ -94,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)); ++ // CraftBukkit start ++ if (!changeLevel(iblockdata, world, blockposition, (IBlockData) iblockdata.set(LayeredCauldronBlock.LEVEL, (Integer) iblockdata.get(LayeredCauldronBlock.LEVEL) + 1), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) { ++ return; ++ } ++ // CraftBukkit end + world.triggerEffect(1047, blockposition, 0); + } + } diff --git a/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch b/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch new file mode 100644 index 000000000..cc2e2b1ec --- /dev/null +++ b/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch @@ -0,0 +1,42 @@ +--- a/net/minecraft/world/level/block/LightningRodBlock.java ++++ b/net/minecraft/world/level/block/LightningRodBlock.java +@@ -33,6 +33,11 @@ + import net.minecraft.world.phys.MovingObjectPositionBlock; + import net.minecraft.world.phys.Vec3D; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.block.CraftBlock; ++import org.bukkit.event.block.BlockRedstoneEvent; ++// CraftBukkit end ++ + public class LightningRodBlock extends RodBlock implements IBlockWaterlogged { + + public static final BlockStateBoolean WATERLOGGED = BlockProperties.WATERLOGGED; +@@ -79,6 +84,18 @@ + } + + public void d(IBlockData iblockdata, World world, BlockPosition blockposition) { ++ // CraftBukkit start ++ boolean powered = iblockdata.get(LightningRodBlock.POWERED); ++ int old = (powered) ? 15 : 0; ++ int current = (!powered) ? 15 : 0; ++ ++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(CraftBlock.at(world, blockposition), old, current); ++ world.getServer().getPluginManager().callEvent(eventRedstone); ++ ++ if (eventRedstone.getNewCurrent() <= 0) { ++ 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(); + + entitylightning.b(entity instanceof EntityPlayer ? (EntityPlayer) entity : null); +- world.addEntity(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/nms-patches/net/minecraft/world/level/block/MultifaceBlock.patch b/nms-patches/net/minecraft/world/level/block/MultifaceBlock.patch new file mode 100644 index 000000000..3d45662d0 --- /dev/null +++ b/nms-patches/net/minecraft/world/level/block/MultifaceBlock.patch @@ -0,0 +1,47 @@ +--- 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 PROPERTY_BY_DIRECTION = BlockSprawling.PROPERTY_BY_DIRECTION; +- private static final Map SHAPE_BY_DIRECTION = (Map) SystemUtils.a((Object) Maps.newEnumMap(EnumDirection.class), (enummap) -> { ++ private static final Map 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 @@ + + return (IBlockData) Arrays.stream(blockactioncontext.f()).map((enumdirection) -> { + return this.c(iblockdata, (IBlockAccess) world, blockposition, enumdirection); +- }).filter(Objects::nonNull).findFirst().orElse((Object) null); ++ }).filter(Objects::nonNull).findFirst().orElse(null); // CraftBukkit - decompile error + } + + @Nullable +@@ -226,7 +226,7 @@ + if (optional.isPresent()) { + Pair 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 + } else { + return false; + } +@@ -271,7 +271,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); + +@@ -280,7 +280,7 @@ + generatoraccess.A(blockposition).e(blockposition); + } + +- return generatoraccess.setTypeAndData(blockposition, iblockdata1, 2); ++ return org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(generatoraccess, source, blockposition, iblockdata1, 2); // CraftBukkit + } else { + return false; + } diff --git a/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch b/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch new file mode 100644 index 000000000..b96c5326b --- /dev/null +++ b/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch @@ -0,0 +1,90 @@ +--- a/net/minecraft/world/level/block/PointedDripstoneBlock.java ++++ b/net/minecraft/world/level/block/PointedDripstoneBlock.java +@@ -43,6 +43,11 @@ + import net.minecraft.world.phys.shapes.VoxelShapeCollision; + import net.minecraft.world.phys.shapes.VoxelShapes; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.block.CraftBlock; ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++// CraftBukkit end ++ + 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(); + + if (!world.isClientSide && iprojectile.a(world, blockposition) && iprojectile instanceof EntityThrownTrident && iprojectile.getMot().f() > 0.6D) { ++ // CraftBukkit start ++ if (CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + world.b(blockposition, true); + } + +@@ -133,7 +143,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) { ++ CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); // CraftBukkit + entity.a(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 + } + + } + +- 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); + +- generatoraccess.setTypeAndData(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(); + } + +- 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 + } + + public static void a(World world, BlockPosition blockposition, IBlockData iblockdata) { +@@ -454,7 +466,7 @@ + + return (BlockPosition) a(generatoraccess, blockposition, enumdirection.e(), predicate, (iblockdata1) -> { + return a(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); + }; + +- 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 + } + + @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 FluidType b(World world, BlockPosition blockposition) { diff --git a/nms-patches/net/minecraft/world/level/block/PowderSnowBlock.patch b/nms-patches/net/minecraft/world/level/block/PowderSnowBlock.patch new file mode 100644 index 000000000..18bb84f5c --- /dev/null +++ b/nms-patches/net/minecraft/world/level/block/PowderSnowBlock.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/world/level/block/PowderSnowBlock.java ++++ b/net/minecraft/world/level/block/PowderSnowBlock.java +@@ -68,7 +68,12 @@ + + entity.o(true); + if (!world.isClientSide) { +- if (entity.isBurning() && (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity instanceof EntityHuman) && entity.a(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()) { ++ return; ++ } ++ // CraftBukkit end + world.b(blockposition, false); + } + diff --git a/nms-patches/net/minecraft/world/level/block/RootedDirtBlock.patch b/nms-patches/net/minecraft/world/level/block/RootedDirtBlock.patch new file mode 100644 index 000000000..58a482662 --- /dev/null +++ b/nms-patches/net/minecraft/world/level/block/RootedDirtBlock.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/level/block/RootedDirtBlock.java ++++ b/net/minecraft/world/level/block/RootedDirtBlock.java +@@ -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 + } + } diff --git a/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch b/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch new file mode 100644 index 000000000..30ab4dbc8 --- /dev/null +++ b/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch @@ -0,0 +1,52 @@ +--- a/net/minecraft/world/level/block/SculkSensorBlock.java ++++ b/net/minecraft/world/level/block/SculkSensorBlock.java +@@ -38,11 +38,16 @@ + import net.minecraft.world.phys.shapes.VoxelShape; + import net.minecraft.world.phys.shapes.VoxelShapeCollision; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.block.CraftBlock; ++import org.bukkit.event.block.BlockRedstoneEvent; ++// CraftBukkit end ++ + 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 VIBRATION_STRENGTH_FOR_EVENT = Object2IntMaps.unmodifiable((Object2IntMap) SystemUtils.a((Object) (new Object2IntOpenHashMap()), (object2intopenhashmap) -> { ++ public static final Object2IntMap 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) { ++ // CraftBukkit start ++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(CraftBlock.at(world, blockposition), iblockdata.get(SculkSensorBlock.POWER), 0); ++ world.getServer().getPluginManager().callEvent(eventRedstone); ++ ++ if (eventRedstone.getNewCurrent() > 0) { ++ world.setTypeAndData(blockposition, iblockdata.set(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)) { +@@ -226,6 +240,15 @@ + } + + public static void a(World world, BlockPosition blockposition, IBlockData iblockdata, int i) { ++ // CraftBukkit start ++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(CraftBlock.at(world, blockposition), iblockdata.get(SculkSensorBlock.POWER), i); ++ world.getServer().getPluginManager().callEvent(eventRedstone); ++ ++ if (eventRedstone.getNewCurrent() <= 0) { ++ return; ++ } ++ 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); diff --git a/nms-patches/net/minecraft/world/level/block/entity/ContainerOpenersCounter.patch b/nms-patches/net/minecraft/world/level/block/entity/ContainerOpenersCounter.patch new file mode 100644 index 000000000..fa292ecbd --- /dev/null +++ b/nms-patches/net/minecraft/world/level/block/entity/ContainerOpenersCounter.patch @@ -0,0 +1,58 @@ +--- a/net/minecraft/world/level/block/entity/ContainerOpenersCounter.java ++++ b/net/minecraft/world/level/block/entity/ContainerOpenersCounter.java +@@ -13,6 +13,7 @@ + + private static final int CHECK_TICK_DELAY = 5; + private int openCount; ++ public boolean opened; // CraftBukkit + + public ContainerOpenersCounter() {} + +@@ -25,8 +26,19 @@ + protected abstract boolean a(EntityHuman entityhuman); + + public void a(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)) { ++ int newPower = Math.max(0, Math.min(15, this.openCount)); ++ ++ if (oldPower != newPower) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, blockposition, oldPower, newPower); ++ } ++ } ++ // CraftBukkit end ++ + if (i == 0) { + this.a(world, blockposition, iblockdata); + world.a((Entity) entityhuman, GameEvent.CONTAINER_OPEN, blockposition); +@@ -37,8 +49,19 @@ + } + + public void b(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)) { ++ int newPower = Math.max(0, Math.min(15, this.openCount)); ++ ++ if (oldPower != newPower) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, blockposition, oldPower, newPower); ++ } ++ } ++ // CraftBukkit end ++ + if (this.openCount == 0) { + this.b(world, blockposition, iblockdata); + world.a((Entity) entityhuman, GameEvent.CONTAINER_CLOSE, blockposition); +@@ -59,6 +82,7 @@ + + public void c(World world, BlockPosition blockposition, IBlockData iblockdata) { + int i = this.a(world, blockposition); ++ if (opened) i++; // CraftBukkit - add dummy count from API + int j = this.openCount; + + if (j != i) { diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch index ad16478e8..343c0b89e 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/entity/TileEntity.java +++ b/net/minecraft/world/level/block/entity/TileEntity.java -@@ -15,8 +15,18 @@ +@@ -12,8 +12,18 @@ + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.apache.logging.log4j.util.Supplier; +// CraftBukkit start +import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer; @@ -17,27 +17,30 @@ + public CraftPersistentDataContainer persistentDataContainer; + // CraftBukkit end private static final Logger LOGGER = LogManager.getLogger(); - private final TileEntityTypes tileType; + private final TileEntityTypes type; @Nullable -@@ -48,6 +58,14 @@ +@@ -41,7 +51,16 @@ + return this.level != null; + } - public void load(IBlockData iblockdata, NBTTagCompound nbttagcompound) { - this.position = new BlockPosition(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z")); -+ // CraftBukkit start - read container +- public void load(NBTTagCompound nbttagcompound) {} ++ // CraftBukkit start - read container ++ public void load(NBTTagCompound nbttagcompound) { + this.persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY); + + net.minecraft.nbt.NBTBase persistentDataTag = nbttagcompound.get("PublicBukkitValues"); + if (persistentDataTag instanceof NBTTagCompound) { + this.persistentDataContainer.putAll((NBTTagCompound) persistentDataTag); + } -+ // CraftBukkit end - } ++ } ++ // CraftBukkit end public NBTTagCompound save(NBTTagCompound nbttagcompound) { -@@ -64,6 +82,11 @@ - nbttagcompound.setInt("x", this.position.getX()); - nbttagcompound.setInt("y", this.position.getY()); - nbttagcompound.setInt("z", this.position.getZ()); + 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()); @@ -46,15 +49,15 @@ return nbttagcompound; } } -@@ -179,4 +202,13 @@ - }, this::getPosition}); - } +@@ -164,4 +188,13 @@ + public void b(IBlockData iblockdata) { + this.blockState = iblockdata; } + + // CraftBukkit start - add method + public InventoryHolder getOwner() { -+ if (world == null) return null; -+ org.bukkit.block.BlockState state = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()).getState(); ++ if (level == null) return null; ++ org.bukkit.block.BlockState state = level.getWorld().getBlockAt(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()).getState(); + if (state instanceof InventoryHolder) return (InventoryHolder) state; + return null; + } diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBanner.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBanner.patch index c868fd0a5..17a109a7e 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBanner.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBanner.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/entity/TileEntityBanner.java +++ b/net/minecraft/world/level/block/entity/TileEntityBanner.java -@@ -80,6 +80,11 @@ +@@ -99,6 +99,11 @@ } - this.patterns = nbttagcompound.getList("Patterns", 10); + this.itemPatterns = nbttagcompound.getList("Patterns", 10); + // CraftBukkit start -+ while (this.patterns.size() > 20) { -+ this.patterns.remove(20); ++ while (this.itemPatterns.size() > 20) { ++ this.itemPatterns.remove(20); + } + // CraftBukkit end - this.h = null; - this.g = true; + this.patterns = null; + this.receivedData = true; } diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBarrel.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBarrel.patch index 68f3dbc44..eca5f2c5d 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBarrel.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBarrel.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/entity/TileEntityBarrel.java +++ b/net/minecraft/world/level/block/entity/TileEntityBarrel.java -@@ -19,8 +19,50 @@ - import net.minecraft.world.level.block.Blocks; +@@ -21,8 +21,49 @@ + import net.minecraft.world.level.block.BlockBarrel; import net.minecraft.world.level.block.state.IBlockData; +// CraftBukkit start @@ -16,7 +16,6 @@ + // CraftBukkit start - add fields and methods + public List transaction = new ArrayList<>(); + private int maxStack = MAX_STACK; -+ public boolean opened; + + @Override + public List getContents() { @@ -49,14 +48,5 @@ + } + // CraftBukkit end private NonNullList items; - private int b; + public ContainerOpenersCounter openersCounter; -@@ -119,7 +161,7 @@ - return; - } - -- boolean flag = (Boolean) iblockdata.get(BlockBarrel.OPEN); -+ boolean flag = (Boolean) iblockdata.get(BlockBarrel.OPEN) && !opened; // CraftBukkit - only set flag if Barrel isn't set open by API. - - if (flag) { - this.playOpenSound(iblockdata, SoundEffects.BLOCK_BARREL_CLOSE); diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch index 1a7f81d98..1ad514957 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityBeacon.java +++ b/net/minecraft/world/level/block/entity/TileEntityBeacon.java -@@ -38,6 +38,11 @@ +@@ -40,6 +40,11 @@ import net.minecraft.world.level.levelgen.HeightMap; import net.minecraft.world.phys.AxisAlignedBB; @@ -9,38 +9,38 @@ +import org.bukkit.potion.PotionEffect; +// CraftBukkit end + - public class TileEntityBeacon extends TileEntity implements ITileInventory, ITickable { + public class TileEntityBeacon extends TileEntity implements ITileInventory { - public static final MobEffectList[][] a = new MobEffectList[][]{{MobEffects.FASTER_MOVEMENT, MobEffects.FASTER_DIG}, {MobEffects.RESISTANCE, MobEffects.JUMP}, {MobEffects.INCREASE_DAMAGE}, {MobEffects.REGENERATION}}; -@@ -54,6 +59,15 @@ - public IChatBaseComponent customName; - public ChestLock chestLock; - private final IContainerProperties containerProperties; + private static final int MAX_LEVELS = 4; +@@ -62,6 +67,15 @@ + public IChatBaseComponent name; + public ChestLock lockKey; + private final IContainerProperties dataAccess; + // CraftBukkit start - add fields and methods + public PotionEffect getPrimaryEffect() { -+ return (this.primaryEffect != null) ? CraftPotionUtil.toBukkit(new MobEffect(this.primaryEffect, getLevel(), getAmplification(), true, true)) : null; ++ return (this.primaryPower != null) ? CraftPotionUtil.toBukkit(new MobEffect(this.primaryPower, getLevel(this.levels), getAmplification(levels, primaryPower, secondaryPower), true, true)) : null; + } + + public PotionEffect getSecondaryEffect() { -+ return (hasSecondaryEffect()) ? CraftPotionUtil.toBukkit(new MobEffect(this.secondaryEffect, getLevel(), getAmplification(), true, true)) : null; ++ return (hasSecondaryEffect(levels, primaryPower, secondaryPower)) ? CraftPotionUtil.toBukkit(new MobEffect(this.secondaryPower, getLevel(this.levels), getAmplification(levels, primaryPower, secondaryPower), true, true)) : null; + } + // CraftBukkit end - public TileEntityBeacon() { - super(TileEntityTypes.BEACON); -@@ -222,39 +236,78 @@ - super.al_(); + public TileEntityBeacon(BlockPosition blockposition, IBlockData iblockdata) { + super(TileEntityTypes.BEACON, blockposition, iblockdata); +@@ -230,39 +244,78 @@ + super.aa_(); } -- private void applyEffects() { -- if (!this.world.isClientSide && this.primaryEffect != null) { -- double d0 = (double) (this.levels * 10 + 10); +- private static void applyEffects(World world, BlockPosition blockposition, int i, @Nullable MobEffectList mobeffectlist, @Nullable MobEffectList mobeffectlist1) { +- if (!world.isClientSide && mobeffectlist != null) { +- double d0 = (double) (i * 10 + 10); + // CraftBukkit start - split into components -+ private byte getAmplification() { ++ private static byte getAmplification(int i, @Nullable MobEffectList mobeffectlist, @Nullable MobEffectList mobeffectlist1) { + { byte b0 = 0; - if (this.levels >= 4 && this.primaryEffect == this.secondaryEffect) { + if (i >= 4 && mobeffectlist == mobeffectlist1) { b0 = 1; } @@ -48,25 +48,25 @@ + } + } + -+ private int getLevel() { ++ private static int getLevel(int i) { + { - int i = (9 + this.levels * 2) * 20; -+ return i; + int j = (9 + i * 2) * 20; ++ return j; + } + } + -+ public List getHumansInRange() { ++ public static List getHumansInRange(World world, BlockPosition blockposition, int i) { + { -+ double d0 = (double) (this.levels * 10 + 10); ++ double d0 = (double) (i * 10 + 10); + - AxisAlignedBB axisalignedbb = (new AxisAlignedBB(this.position)).g(d0).b(0.0D, (double) this.world.getBuildHeight(), 0.0D); - List list = this.world.a(EntityHuman.class, axisalignedbb); + AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition)).g(d0).b(0.0D, (double) world.getHeight(), 0.0D); + List list = world.a(EntityHuman.class, axisalignedbb); + + return list; + } + } + -+ private void applyEffect(List list, MobEffectList effects, int i, int b0) { ++ private static void applyEffect(List list, MobEffectList mobeffectlist, int j, int b0) { + { Iterator iterator = list.iterator(); @@ -74,20 +74,20 @@ while (iterator.hasNext()) { entityhuman = (EntityHuman) iterator.next(); -- entityhuman.addEffect(new MobEffect(this.primaryEffect, i, b0, true, true)); -+ entityhuman.addEffect(new MobEffect(effects, i, b0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON); +- entityhuman.addEffect(new MobEffect(mobeffectlist, j, b0, true, true)); ++ entityhuman.addEffect(new MobEffect(mobeffectlist, j, b0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON); } + } + } -+ private boolean hasSecondaryEffect() { ++ private static boolean hasSecondaryEffect(int i, @Nullable MobEffectList mobeffectlist, @Nullable MobEffectList mobeffectlist1) { + { - if (this.levels >= 4 && this.primaryEffect != this.secondaryEffect && this.secondaryEffect != null) { + if (i >= 4 && mobeffectlist != mobeffectlist1 && mobeffectlist1 != null) { - iterator = list.iterator(); - - while (iterator.hasNext()) { - entityhuman = (EntityHuman) iterator.next(); -- entityhuman.addEffect(new MobEffect(this.secondaryEffect, i, 0, true, true)); +- entityhuman.addEffect(new MobEffect(mobeffectlist1, j, 0, true, true)); - } + return true; } @@ -96,38 +96,38 @@ } } -+ private void applyEffects() { -+ if (!this.world.isClientSide && this.primaryEffect != null) { -+ double d0 = (double) (this.levels * 10 + 10); -+ byte b0 = getAmplification(); ++ private static void applyEffects(World world, BlockPosition blockposition, int i, @Nullable MobEffectList mobeffectlist, @Nullable MobEffectList mobeffectlist1) { ++ if (!world.isClientSide && mobeffectlist != null) { ++ double d0 = (double) (i * 10 + 10); ++ byte b0 = getAmplification(i, mobeffectlist, mobeffectlist1); + -+ int i = getLevel(); -+ List list = getHumansInRange(); ++ int j = getLevel(i); ++ List list = getHumansInRange(world, blockposition, i); + -+ applyEffect(list, this.primaryEffect, i, b0); ++ applyEffect(list, mobeffectlist, j, b0); + -+ if (hasSecondaryEffect()) { -+ applyEffect(list, this.secondaryEffect, i, 0); ++ if (hasSecondaryEffect(i, mobeffectlist, mobeffectlist1)) { ++ applyEffect(list, mobeffectlist1, j, 0); + } + } + + } + // CraftBukkit end + - public void a(SoundEffect soundeffect) { - this.world.playSound((EntityHuman) null, this.position, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); + public static void a(World world, BlockPosition blockposition, SoundEffect soundeffect) { + world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); } -@@ -284,8 +337,11 @@ +@@ -292,8 +345,11 @@ @Override - public void load(IBlockData iblockdata, NBTTagCompound nbttagcompound) { - super.load(iblockdata, nbttagcompound); -- this.primaryEffect = b(nbttagcompound.getInt("Primary")); -- this.secondaryEffect = b(nbttagcompound.getInt("Secondary")); + public void load(NBTTagCompound nbttagcompound) { + super.load(nbttagcompound); +- this.primaryPower = a(nbttagcompound.getInt("Primary")); +- this.secondaryPower = a(nbttagcompound.getInt("Secondary")); + // CraftBukkit start - persist manually set non-default beacon effects (SPIGOT-3598) -+ this.primaryEffect = MobEffectList.fromId(nbttagcompound.getInt("Primary")); -+ this.secondaryEffect = MobEffectList.fromId(nbttagcompound.getInt("Secondary")); ++ this.primaryPower = MobEffectList.fromId(nbttagcompound.getInt("Primary")); ++ this.secondaryPower = MobEffectList.fromId(nbttagcompound.getInt("Secondary")); + this.levels = nbttagcompound.getInt("Levels"); // SPIGOT-5053, use where available + // CraftBukkit end if (nbttagcompound.hasKeyOfType("CustomName", 8)) { - this.customName = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName")); + this.name = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName")); } diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch index f54259dec..103c21bd4 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/world/level/block/entity/TileEntityBeehive.java +++ b/net/minecraft/world/level/block/entity/TileEntityBeehive.java -@@ -29,6 +29,7 @@ - private final List bees = Lists.newArrayList(); +@@ -43,6 +43,7 @@ + private final List stored = Lists.newArrayList(); @Nullable - public BlockPosition flowerPos = null; + public BlockPosition savedFlowerPos; + public int maxBees = 3; // CraftBukkit - allow setting max amount of bees a hive can hold - public TileEntityBeehive() { - super(TileEntityTypes.BEEHIVE); -@@ -68,7 +69,7 @@ + public TileEntityBeehive(BlockPosition blockposition, IBlockData iblockdata) { + super(TileEntityTypes.BEEHIVE, blockposition, iblockdata); +@@ -82,7 +83,7 @@ } public boolean isFull() { -- return this.bees.size() == 3; -+ return this.bees.size() == this.maxBees; // CraftBukkit +- return this.stored.size() == 3; ++ return this.stored.size() == this.maxBees; // CraftBukkit } public void a(@Nullable EntityHuman entityhuman, IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { -@@ -85,7 +86,7 @@ +@@ -99,7 +100,7 @@ if (entityhuman.getPositionVector().distanceSquared(entity.getPositionVector()) <= 16.0D) { if (!this.isSedated()) { @@ -26,7 +26,7 @@ } else { entitybee.setCannotEnterHiveTicks(400); } -@@ -97,10 +98,16 @@ +@@ -111,10 +112,16 @@ } private List releaseBees(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { @@ -37,22 +37,22 @@ + public List releaseBees(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, boolean force) { List list = Lists.newArrayList(); - this.bees.removeIf((tileentitybeehive_hivebee) -> { -- return this.releaseBee(iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus); -+ return this.releaseBee(iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, force); + this.stored.removeIf((tileentitybeehive_hivebee) -> { +- return releaseBee(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 }); return list; } -@@ -126,7 +133,19 @@ +@@ -138,7 +145,19 @@ } public void a(Entity entity, boolean flag, int i) { -- if (this.bees.size() < 3) { -+ if (this.bees.size() < this.maxBees) { // CraftBukkit +- if (this.stored.size() < 3) { ++ if (this.stored.size() < this.maxBees) { // CraftBukkit + // CraftBukkit start -+ if (this.world != null) { -+ org.bukkit.event.entity.EntityEnterBlockEvent event = new org.bukkit.event.entity.EntityEnterBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, getPosition())); ++ 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.Bukkit.getPluginManager().callEvent(event); + if (event.isCancelled()) { + if (entity instanceof EntityBee) { @@ -65,22 +65,22 @@ entity.stopRiding(); entity.ejectPassengers(); NBTTagCompound nbttagcompound = new NBTTagCompound(); -@@ -152,7 +171,13 @@ +@@ -168,7 +187,13 @@ } - private boolean releaseBee(IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { -- if ((this.world.isNight() || this.world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) { + private static boolean releaseBee(World world, BlockPosition blockposition, IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List 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(iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, false); ++ return releaseBee(world, blockposition, iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, blockposition1, false); + } + -+ private boolean releaseBee(IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, boolean force) { -+ if (!force && (this.world.isNight() || this.world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) { ++ private static boolean releaseBee(World world, BlockPosition blockposition, IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, @Nullable BlockPosition blockposition1, boolean force) { ++ if (!force && (world.isNight() || world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) { + // CraftBukkit end return false; } else { - BlockPosition blockposition = this.getPosition(); -@@ -176,6 +201,18 @@ + NBTTagCompound nbttagcompound = tileentitybeehive_hivebee.entityData; +@@ -191,6 +216,18 @@ if (!entity.getEntityType().a((Tag) TagsEntity.BEEHIVE_INHABITORS)) { return false; } else { @@ -92,14 +92,14 @@ + double d2 = (double) blockposition.getY() + 0.5D - (double) (entity.getHeight() / 2.0F); + double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getAdjacentZ(); + -+ entity.setPositionRotation(d1, d2, d3, entity.yaw, entity.pitch); ++ entity.setPositionRotation(d1, d2, d3, entity.getYRot(), entity.getXRot()); + } -+ if (!this.world.addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BEEHIVE)) return false; // CraftBukkit - SpawnReason, moved from below ++ if (!world.addEntity(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; -@@ -205,6 +242,7 @@ +@@ -220,6 +257,7 @@ list.add(entitybee); } @@ -107,22 +107,22 @@ float f = entity.getWidth(); double d0 = flag ? 0.0D : 0.55D + (double) (f / 2.0F); double d1 = (double) blockposition.getX() + 0.5D + d0 * (double) enumdirection.getAdjacentX(); -@@ -212,10 +250,11 @@ +@@ -227,10 +265,11 @@ double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getAdjacentZ(); - entity.setPositionRotation(d1, d2, d3, entity.yaw, entity.pitch); + entity.setPositionRotation(d1, d2, d3, entity.getYRot(), entity.getXRot()); + */ // CraftBukkit end } - this.world.playSound((EntityHuman) null, blockposition, SoundEffects.BLOCK_BEEHIVE_EXIT, SoundCategory.BLOCKS, 1.0F, 1.0F); -- return this.world.addEntity(entity); + 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 } } else { return false; -@@ -253,6 +292,10 @@ +@@ -276,6 +315,10 @@ - if (this.releaseBee(iblockdata, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus)) { + if (releaseBee(world, blockposition, iblockdata, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus, blockposition1)) { iterator.remove(); + // CraftBukkit start + } else { @@ -131,8 +131,8 @@ } } } -@@ -295,6 +338,11 @@ - this.flowerPos = GameProfileSerializer.b(nbttagcompound.getCompound("FlowerPos")); +@@ -313,6 +356,11 @@ + this.savedFlowerPos = GameProfileSerializer.b(nbttagcompound.getCompound("FlowerPos")); } + // CraftBukkit start @@ -143,9 +143,9 @@ } @Override -@@ -304,6 +352,7 @@ - if (this.x()) { - nbttagcompound.set("FlowerPos", GameProfileSerializer.a(this.flowerPos)); +@@ -322,6 +370,7 @@ + if (this.s()) { + nbttagcompound.set("FlowerPos", GameProfileSerializer.a(this.savedFlowerPos)); } + nbttagcompound.setInt("Bukkit.MaxEntities", this.maxBees); // CraftBukkit diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch index 9538973c3..575c662fb 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch @@ -1,12 +1,13 @@ --- a/net/minecraft/world/level/block/entity/TileEntityBrewingStand.java +++ b/net/minecraft/world/level/block/entity/TileEntityBrewingStand.java -@@ -24,6 +24,17 @@ +@@ -25,6 +25,18 @@ import net.minecraft.world.level.block.BlockBrewingStand; import net.minecraft.world.level.block.state.IBlockData; +// CraftBukkit start +import java.util.List; +import net.minecraft.server.MinecraftServer; ++import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.entity.HumanEntity; @@ -15,13 +16,13 @@ +import org.bukkit.inventory.InventoryHolder; +// CraftBukkit end + - public class TileEntityBrewingStand extends TileEntityContainer implements IWorldInventory, ITickable { + public class TileEntityBrewingStand extends TileEntityContainer implements IWorldInventory { - private static final int[] b = new int[]{3}; -@@ -35,6 +46,36 @@ - private Item k; - public int fuelLevel; - protected final IContainerProperties a; + private static final int INGREDIENT_SLOT = 3; +@@ -42,6 +54,36 @@ + private Item ingredient; + public int fuel; + protected final IContainerProperties dataAccess; + // CraftBukkit start - add fields and methods + private int lastTick = MinecraftServer.currentTick; + public List transaction = new java.util.ArrayList(); @@ -53,55 +54,62 @@ + } + // CraftBukkit end - public TileEntityBrewingStand() { - super(TileEntityTypes.BREWING_STAND); -@@ -103,8 +144,19 @@ - ItemStack itemstack = (ItemStack) this.items.get(4); + public TileEntityBrewingStand(BlockPosition blockposition, IBlockData iblockdata) { + super(TileEntityTypes.BREWING_STAND, blockposition, iblockdata); +@@ -109,8 +151,19 @@ + ItemStack itemstack = (ItemStack) tileentitybrewingstand.items.get(4); - if (this.fuelLevel <= 0 && itemstack.getItem() == Items.BLAZE_POWDER) { -- this.fuelLevel = 20; + if (tileentitybrewingstand.fuel <= 0 && itemstack.a(Items.BLAZE_POWDER)) { +- tileentitybrewingstand.fuel = 20; - itemstack.subtract(1); + // CraftBukkit start -+ BrewingStandFuelEvent event = new BrewingStandFuelEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), CraftItemStack.asCraftMirror(itemstack), 20); -+ this.world.getServer().getPluginManager().callEvent(event); ++ BrewingStandFuelEvent event = new BrewingStandFuelEvent(CraftBlock.at(world, blockposition), CraftItemStack.asCraftMirror(itemstack), 20); ++ world.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; + } + -+ this.fuelLevel = event.getFuelPower(); -+ if (this.fuelLevel > 0 && event.isConsuming()) { ++ tileentitybrewingstand.fuel = event.getFuelPower(); ++ if (tileentitybrewingstand.fuel > 0 && event.isConsuming()) { + itemstack.subtract(1); + } + // CraftBukkit end - this.update(); + a(world, blockposition, iblockdata); } -@@ -112,9 +164,14 @@ - boolean flag1 = this.brewTime > 0; - ItemStack itemstack1 = (ItemStack) this.items.get(3); +@@ -118,12 +171,17 @@ + boolean flag1 = tileentitybrewingstand.brewTime > 0; + ItemStack itemstack1 = (ItemStack) tileentitybrewingstand.items.get(3); + // CraftBukkit start - Use wall time instead of ticks for brewing -+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick; -+ this.lastTick = MinecraftServer.currentTick; ++ int elapsedTicks = MinecraftServer.currentTick - tileentitybrewingstand.lastTick; ++ tileentitybrewingstand.lastTick = MinecraftServer.currentTick; + if (flag1) { -- --this.brewTime; -- boolean flag2 = this.brewTime == 0; -+ this.brewTime -= elapsedTicks; -+ boolean flag2 = this.brewTime <= 0; // == -> <= +- --tileentitybrewingstand.brewTime; +- boolean flag2 = tileentitybrewingstand.brewTime == 0; ++ tileentitybrewingstand.brewTime -= elapsedTicks; ++ boolean flag2 = tileentitybrewingstand.brewTime <= 0; // == -> <= + // CraftBukkit end if (flag2 && flag) { - this.j(); -@@ -188,6 +245,16 @@ +- a(world, blockposition, tileentitybrewingstand.items); ++ a(world, blockposition, tileentitybrewingstand.items, tileentitybrewingstand); // CraftBukkit + a(world, blockposition, iblockdata); + } else if (!flag || !itemstack1.a(tileentitybrewingstand.ingredient)) { + tileentitybrewingstand.brewTime = 0; +@@ -187,8 +245,18 @@ + } + } - private void j() { - ItemStack itemstack = (ItemStack) this.items.get(3); -+ // CraftBukkit start -+ InventoryHolder owner = this.getOwner(); +- private static void a(World world, BlockPosition blockposition, NonNullList nonnulllist) { ++ // CraftBukkit start ++ private static void a(World world, BlockPosition blockposition, NonNullList nonnulllist, TileEntityBrewingStand tileentitybrewingstand) { + ItemStack itemstack = (ItemStack) nonnulllist.get(3); ++ InventoryHolder owner = tileentitybrewingstand.getOwner(); + if (owner != null) { -+ BrewEvent event = new BrewEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), (org.bukkit.inventory.BrewerInventory) owner.getInventory(), this.fuelLevel); ++ BrewEvent event = new BrewEvent(CraftBlock.at(world, blockposition), (org.bukkit.inventory.BrewerInventory) owner.getInventory(), tileentitybrewingstand.fuel); + org.bukkit.Bukkit.getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; @@ -110,4 +118,4 @@ + // CraftBukkit end for (int i = 0; i < 3; ++i) { - this.items.set(i, PotionBrewer.d(itemstack, (ItemStack) this.items.get(i))); + nonnulllist.set(i, PotionBrewer.d(itemstack, (ItemStack) nonnulllist.get(i))); diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch index 8f82afe03..ba68eb823 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch @@ -10,19 +10,19 @@ +import org.bukkit.event.block.BlockCookEvent; +// CraftBukkit end + - public class TileEntityCampfire extends TileEntity implements Clearable, ITickable { + public class TileEntityCampfire extends TileEntity implements Clearable { - private final NonNullList items; -@@ -72,6 +78,20 @@ + private static final int BURN_COOL_SPEED = 2; +@@ -52,6 +58,20 @@ + return recipecampfire.a(inventorysubcontainer); }).orElse(itemstack); - BlockPosition blockposition = this.getPosition(); + // CraftBukkit start - fire BlockCookEvent + CraftItemStack source = CraftItemStack.asCraftMirror(itemstack); + org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1); + -+ BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(this.world, this.position), source, result); -+ this.world.getServer().getPluginManager().callEvent(blockCookEvent); ++ BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(world, blockposition), source, result); ++ world.getServer().getPluginManager().callEvent(blockCookEvent); + + if (blockCookEvent.isCancelled()) { + return; @@ -31,6 +31,6 @@ + result = blockCookEvent.getResult(); + itemstack1 = CraftItemStack.asNMSCopy(result); + // CraftBukkit end - InventoryUtils.dropItem(this.world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1); - this.items.set(i, ItemStack.b); - this.k(); + InventoryUtils.dropItem(world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1); + tileentitycampfire.items.set(i, ItemStack.EMPTY); + world.notify(blockposition, iblockdata, iblockdata, 3); diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityChest.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityChest.patch index ff36b5dd6..41bc9995b 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityChest.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityChest.patch @@ -1,26 +1,25 @@ --- a/net/minecraft/world/level/block/entity/TileEntityChest.java +++ b/net/minecraft/world/level/block/entity/TileEntityChest.java -@@ -27,6 +27,12 @@ +@@ -24,6 +24,12 @@ + import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.block.state.properties.BlockPropertyChestType; - import net.minecraft.world.phys.AxisAlignedBB; +// CraftBukkit start -+import net.minecraft.world.level.block.Blocks; ++import java.util.List; +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.entity.HumanEntity; +// CraftBukkit end + - public class TileEntityChest extends TileEntityLootable implements ITickable { + public class TileEntityChest extends TileEntityLootable implements LidBlockEntity { - private NonNullList items; -@@ -35,6 +41,37 @@ - public int viewingCount; - private int j; + private static final int EVENT_SET_OPEN_COUNT = 1; +@@ -31,6 +37,36 @@ + public final ContainerOpenersCounter openersCounter; + private final ChestLidController chestLidController; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; -+ public boolean opened; + + public List getContents() { + return this.items; @@ -48,75 +47,12 @@ + } + // CraftBukkit end + - protected TileEntityChest(TileEntityTypes tileentitytypes) { - super(tileentitytypes); - this.items = NonNullList.a(27, ItemStack.b); -@@ -85,6 +122,13 @@ - this.b = this.a; - float f = 0.1F; + protected TileEntityChest(TileEntityTypes tileentitytypes, BlockPosition blockposition, IBlockData iblockdata) { + super(tileentitytypes, blockposition, iblockdata); + this.items = NonNullList.a(27, ItemStack.EMPTY); +@@ -200,4 +236,11 @@ -+ // CraftBukkit start - If chest is forced open by API, remove a viewer due to playBlockAction() call and don't tick to prevent sound effects. -+ if (opened) { -+ this.viewingCount--; -+ return; -+ } -+ // CraftBukkit end -+ - if (this.viewingCount > 0 && this.a == 0.0F) { - this.playOpenSound(SoundEffects.BLOCK_CHEST_OPEN); - } -@@ -179,8 +223,20 @@ - if (this.viewingCount < 0) { - this.viewingCount = 0; - } -+ int oldPower = Math.max(0, Math.min(15, this.viewingCount)); // CraftBukkit - Get power before new viewer is added - - ++this.viewingCount; -+ if (this.world == null) return; // CraftBukkit -+ -+ // CraftBukkit start - Call redstone event -+ if (this.getBlock().getBlock() == Blocks.TRAPPED_CHEST) { -+ int newPower = Math.max(0, Math.min(15, this.viewingCount)); -+ -+ if (oldPower != newPower) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position, oldPower, newPower); -+ } -+ } -+ // CraftBukkit end - this.onOpen(); - } - -@@ -189,7 +245,18 @@ - @Override - public void closeContainer(EntityHuman entityhuman) { - if (!entityhuman.isSpectator()) { -+ int oldPower = Math.max(0, Math.min(15, this.viewingCount)); // CraftBukkit - Get power before new viewer is added - --this.viewingCount; -+ -+ // CraftBukkit start - Call redstone event -+ if (this.getBlock().getBlock() == Blocks.TRAPPED_CHEST) { -+ int newPower = Math.max(0, Math.min(15, this.viewingCount)); -+ -+ if (oldPower != newPower) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position, oldPower, newPower); -+ } -+ } -+ // CraftBukkit end - this.onOpen(); - } - -@@ -199,7 +266,7 @@ - Block block = this.getBlock().getBlock(); - - if (block instanceof BlockChest) { -- this.world.playBlockAction(this.position, block, 1, this.viewingCount); -+ if (!opened) this.world.playBlockAction(this.position, block, 1, this.viewingCount); // CraftBukkit - this.world.applyPhysics(this.position, block); - } - -@@ -240,4 +307,11 @@ - protected Container createContainer(int i, PlayerInventory playerinventory) { - return ContainerChest.a(i, playerinventory, this); + world.playBlockAction(blockposition, block, 1, j); } + + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityCommand.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityCommand.patch index be8d2691d..136de0297 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityCommand.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityCommand.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/entity/TileEntityCommand.java +++ b/net/minecraft/world/level/block/entity/TileEntityCommand.java @@ -24,6 +24,13 @@ - private boolean c; - private boolean g; - private final CommandBlockListenerAbstract h = new CommandBlockListenerAbstract() { + private boolean conditionMet; + private boolean sendToClient; + private final CommandBlockListenerAbstract commandBlock = new CommandBlockListenerAbstract() { + // CraftBukkit start + @Override + public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) { diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch index ea6e09941..465df97f2 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityConduit.java +++ b/net/minecraft/world/level/block/entity/TileEntityConduit.java -@@ -27,6 +27,11 @@ +@@ -29,6 +29,11 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -9,49 +9,31 @@ +import org.bukkit.craftbukkit.event.CraftEventFactory; +// CraftBukkit end + - public class TileEntityConduit extends TileEntity implements ITickable { + public class TileEntityConduit extends TileEntity { - private static final Block[] b = new Block[]{Blocks.PRISMARINE, Blocks.PRISMARINE_BRICKS, Blocks.SEA_LANTERN, Blocks.DARK_PRISMARINE}; -@@ -178,7 +183,7 @@ + private static final int BLOCK_REFRESH_RATE = 2; +@@ -205,7 +210,7 @@ EntityHuman entityhuman = (EntityHuman) iterator.next(); - if (this.position.a((BaseBlockPosition) entityhuman.getChunkCoordinates(), (double) j) && entityhuman.isInWaterOrRain()) { + if (blockposition.a((BaseBlockPosition) entityhuman.getChunkCoordinates(), (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 } } -@@ -195,7 +200,7 @@ - this.target = this.x(); - this.k = null; - } else if (this.target == null) { -- List list = this.world.a(EntityLiving.class, this.m(), (entityliving1) -> { -+ List list = this.world.a(EntityLiving.class, this.m(), (java.util.function.Predicate) (entityliving1) -> { // CraftBukkit - decompile error - return entityliving1 instanceof IMonster && entityliving1.isInWaterOrRain(); - }); - -@@ -207,8 +212,13 @@ +@@ -234,8 +239,13 @@ } - if (this.target != null) { -- this.world.playSound((EntityHuman) null, this.target.locX(), this.target.locY(), this.target.locZ(), SoundEffects.BLOCK_CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F); -- this.target.damageEntity(DamageSource.MAGIC, 4.0F); + 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); + // CraftBukkit start -+ CraftEventFactory.blockDamage = CraftBlock.at(this.world, this.position); -+ if (this.target.damageEntity(DamageSource.MAGIC, 4.0F)) { -+ this.world.playSound((EntityHuman) null, this.target.locX(), this.target.locY(), this.target.locZ(), SoundEffects.BLOCK_CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F); ++ 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); + } + CraftEventFactory.blockDamage = null; + // CraftBukkit end } - if (entityliving != this.target) { -@@ -241,7 +251,7 @@ - - @Nullable - private EntityLiving x() { -- List list = this.world.a(EntityLiving.class, this.m(), (entityliving) -> { -+ List list = this.world.a(EntityLiving.class, this.m(), (java.util.function.Predicate) (entityliving) -> { // CraftBukkit - decompile error - return entityliving.getUniqueID().equals(this.k); - }); - + if (entityliving != tileentityconduit.destroyTarget) { diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityContainer.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityContainer.patch index be760114c..531902186 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityContainer.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityContainer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityContainer.java +++ b/net/minecraft/world/level/block/entity/TileEntityContainer.java -@@ -89,4 +89,12 @@ +@@ -90,4 +90,12 @@ } protected abstract Container createContainer(int i, PlayerInventory playerinventory); @@ -8,8 +8,8 @@ + // CraftBukkit start + @Override + public org.bukkit.Location getLocation() { -+ if (world == null) return null; -+ return new org.bukkit.Location(world.getWorld(), position.getX(), position.getY(), position.getZ()); ++ if (level == null) return null; ++ return new org.bukkit.Location(level.getWorld(), worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()); + } + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityDispenser.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityDispenser.patch index 816d1d7fa..3776af10f 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityDispenser.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityDispenser.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityDispenser.java +++ b/net/minecraft/world/level/block/entity/TileEntityDispenser.java -@@ -13,11 +13,48 @@ +@@ -14,12 +14,49 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.IBlockData; @@ -13,7 +13,8 @@ + public class TileEntityDispenser extends TileEntityLootable { - private static final Random a = new Random(); + private static final Random RANDOM = new Random(); + public static final int CONTAINER_SIZE = 9; private NonNullList items; + // CraftBukkit start - add fields and methods @@ -46,6 +47,6 @@ + } + // CraftBukkit end + - protected TileEntityDispenser(TileEntityTypes tileentitytypes) { - super(tileentitytypes); - this.items = NonNullList.a(9, ItemStack.b); + protected TileEntityDispenser(TileEntityTypes tileentitytypes, BlockPosition blockposition, IBlockData iblockdata) { + super(tileentitytypes, blockposition, iblockdata); + this.items = NonNullList.a(9, ItemStack.EMPTY); diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch index 0c6644746..65872db9a 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityEndGateway.java +++ b/net/minecraft/world/level/block/entity/TileEntityEndGateway.java -@@ -30,6 +30,14 @@ +@@ -32,6 +32,14 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -12,19 +12,19 @@ +import org.bukkit.event.player.PlayerTeleportEvent; +// CraftBukkit end + - public class TileEntityEndGateway extends TileEntityEnderPortal implements ITickable { + public class TileEntityEndGateway extends TileEntityEnderPortal { private static final Logger LOGGER = LogManager.getLogger(); -@@ -140,7 +148,7 @@ - public void b(Entity entity) { - if (this.world instanceof WorldServer && !this.f()) { - this.c = 100; -- if (this.exitPortal == null && this.world.getDimensionKey() == World.THE_END) { -+ if (this.exitPortal == null && this.world.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit - work in alternate worlds - this.a((WorldServer) this.world); - } +@@ -170,7 +178,7 @@ + tileentityendgateway.teleportCooldown = 100; + BlockPosition blockposition1; -@@ -165,6 +173,27 @@ +- if (tileentityendgateway.exitPortal == null && world.getDimensionKey() == World.END) { ++ if (tileentityendgateway.exitPortal == null && world.getTypeKey() == DimensionManager.END_LOCATION) { // CraftBukkit - work in alternate worlds + blockposition1 = a(worldserver, blockposition); + blockposition1 = blockposition1.up(10); + TileEntityEndGateway.LOGGER.debug("Creating portal at {}", blockposition1); +@@ -199,6 +207,27 @@ entity1 = entity.getRootVehicle(); } @@ -42,22 +42,22 @@ + } + + entity1.resetPortalCooldown(); -+ ((EntityPlayer) entity1).playerConnection.teleport(teleEvent.getTo()); -+ this.h(); // CraftBukkit - call at end of method ++ ((EntityPlayer) entity1).connection.teleport(teleEvent.getTo()); ++ c(world, blockposition, iblockdata, tileentityendgateway); // CraftBukkit - call at end of method + return; + + } + // CraftBukkit end + entity1.resetPortalCooldown(); - entity1.enderTeleportAndLoad((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D); + entity1.enderTeleportAndLoad((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D); } -@@ -269,7 +298,7 @@ +@@ -310,7 +339,7 @@ } - private void a(WorldServer worldserver, BlockPosition blockposition) { -- WorldGenerator.END_GATEWAY.b((WorldGenFeatureConfiguration) WorldGenEndGatewayConfiguration.a(this.getPosition(), false)).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition); -+ WorldGenerator.END_GATEWAY.b(WorldGenEndGatewayConfiguration.a(this.getPosition(), false)).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition); // CraftBukkit - decompile error + 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 } - public void a(BlockPosition blockposition, boolean flag) { + @Override diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch index 09d4e7073..455a5bd4c 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityFurnace.java +++ b/net/minecraft/world/level/block/entity/TileEntityFurnace.java -@@ -39,6 +39,17 @@ +@@ -43,6 +43,17 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.Vec3D; @@ -15,10 +15,10 @@ +import org.bukkit.event.inventory.FurnaceSmeltEvent; +// CraftBukkit end + - public abstract class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeHolder, AutoRecipeOutput, ITickable { + public abstract class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeHolder, AutoRecipeOutput { - private static final int[] g = new int[]{0}; -@@ -166,6 +177,36 @@ + protected static final int SLOT_INPUT = 0; +@@ -182,6 +193,36 @@ return map; } @@ -55,46 +55,63 @@ private static boolean b(Item item) { return TagsItem.NON_FLAMMABLE_WOOD.isTagged(item); } -@@ -252,12 +293,23 @@ - this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.cookTimeTotal); - } - } else { -- IRecipe irecipe = (IRecipe) this.world.getCraftingManager().craft(this.c, this, this.world).orElse((Object) null); -+ IRecipe irecipe = this.world.getCraftingManager().craft((Recipes) this.c, this, this.world).orElse(null); // Eclipse fail +@@ -266,13 +307,24 @@ + tileentityfurnace.cookingProgress = MathHelper.clamp(tileentityfurnace.cookingProgress - 2, 0, tileentityfurnace.cookingTotalTime); + } + } else { +- IRecipe irecipe = (IRecipe) world.getCraftingManager().craft(tileentityfurnace.recipeType, tileentityfurnace, world).orElse((Object) null); ++ IRecipe irecipe = (IRecipe) world.getCraftingManager().craft((Recipes) tileentityfurnace.recipeType, tileentityfurnace, world).orElse(null); // CraftBukkit - decompile error // Eclipse fail + int i = tileentityfurnace.getMaxStackSize(); - if (!this.isBurning() && this.canBurn(irecipe)) { -- this.burnTime = this.fuelTime(itemstack); -+ // CraftBukkit start -+ CraftItemStack fuel = CraftItemStack.asCraftMirror(itemstack); + if (!tileentityfurnace.isBurning() && canBurn(irecipe, tileentityfurnace.items, i)) { +- tileentityfurnace.litTime = tileentityfurnace.fuelTime(itemstack); ++ // CraftBukkit start ++ CraftItemStack fuel = CraftItemStack.asCraftMirror(itemstack); + -+ FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(CraftBlock.at(this.world, this.position), fuel, fuelTime(itemstack)); -+ this.world.getServer().getPluginManager().callEvent(furnaceBurnEvent); ++ FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(CraftBlock.at(world, blockposition), fuel, tileentityfurnace.fuelTime(itemstack)); ++ world.getServer().getPluginManager().callEvent(furnaceBurnEvent); + -+ if (furnaceBurnEvent.isCancelled()) { -+ return; -+ } ++ if (furnaceBurnEvent.isCancelled()) { ++ return; ++ } + -+ this.burnTime = furnaceBurnEvent.getBurnTime(); - this.ticksForCurrentFuel = this.burnTime; -- if (this.isBurning()) { -+ if (this.isBurning() && furnaceBurnEvent.isBurning()) { -+ // CraftBukkit end - flag1 = true; - if (!itemstack.isEmpty()) { - Item item = itemstack.getItem(); -@@ -319,11 +371,38 @@ ++ tileentityfurnace.litTime = furnaceBurnEvent.getBurnTime(); + tileentityfurnace.litDuration = tileentityfurnace.litTime; +- if (tileentityfurnace.isBurning()) { ++ if (tileentityfurnace.isBurning() && furnaceBurnEvent.isBurning()) { ++ // CraftBukkit end + flag1 = true; + if (!itemstack.isEmpty()) { + Item item = itemstack.getItem(); +@@ -292,7 +344,7 @@ + if (tileentityfurnace.cookingProgress == tileentityfurnace.cookingTotalTime) { + tileentityfurnace.cookingProgress = 0; + tileentityfurnace.cookingTotalTime = getRecipeCookingTime(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 +383,44 @@ + } + } + +- private static boolean burn(@Nullable IRecipe irecipe, NonNullList nonnulllist, int i) { ++ private static boolean burn(World world, BlockPosition blockposition, @Nullable IRecipe irecipe, NonNullList nonnulllist, int i) { // CraftBukkit + if (irecipe != null && canBurn(irecipe, nonnulllist, i)) { + ItemStack itemstack = (ItemStack) nonnulllist.get(0); ItemStack itemstack1 = irecipe.getResult(); - ItemStack itemstack2 = (ItemStack) this.items.get(2); + ItemStack itemstack2 = (ItemStack) nonnulllist.get(2); + // CraftBukkit start - fire FurnaceSmeltEvent + CraftItemStack source = CraftItemStack.asCraftMirror(itemstack); + org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1); + -+ FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), source, result); -+ this.world.getServer().getPluginManager().callEvent(furnaceSmeltEvent); ++ FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(CraftBlock.at(world, blockposition), source, result); ++ world.getServer().getPluginManager().callEvent(furnaceSmeltEvent); + + if (furnaceSmeltEvent.isCancelled()) { -+ return; ++ return false; + } + + result = furnaceSmeltEvent.getResult(); @@ -102,86 +119,86 @@ + + if (!itemstack1.isEmpty()) { + if (itemstack2.isEmpty()) { -+ this.items.set(2, itemstack1.cloneItemStack()); ++ nonnulllist.set(2, itemstack1.cloneItemStack()); + } else if (CraftItemStack.asCraftMirror(itemstack2).isSimilar(result)) { + itemstack2.add(itemstack1.getCount()); + } else { -+ return; ++ return false; + } + } + + /* if (itemstack2.isEmpty()) { - this.items.set(2, itemstack1.cloneItemStack()); - } else if (itemstack2.getItem() == itemstack1.getItem()) { + nonnulllist.set(2, itemstack1.cloneItemStack()); + } else if (itemstack2.a(itemstack1.getItem())) { itemstack2.add(1); } + */ + // CraftBukkit end - if (!this.world.isClientSide) { - this.a(irecipe); -@@ -348,7 +427,7 @@ + if (itemstack.a(Blocks.WET_SPONGE.getItem()) && !((ItemStack) nonnulllist.get(1)).isEmpty() && ((ItemStack) nonnulllist.get(1)).a(Items.BUCKET)) { + nonnulllist.set(1, new ItemStack(Items.WATER_BUCKET)); +@@ -365,7 +444,7 @@ } - protected int getRecipeCookingTime() { -- return (Integer) this.world.getCraftingManager().craft(this.c, this, this.world).map(RecipeCooking::getCookingTime).orElse(200); -+ return (this.hasWorld()) ? (Integer) this.world.getCraftingManager().craft((Recipes) this.c, this, this.world).map(RecipeCooking::getCookingTime).orElse(200) : 200; // CraftBukkit - SPIGOT-4302 // Eclipse fail + private static int getRecipeCookingTime(World world, Recipes recipes, IInventory iinventory) { +- return (Integer) world.getCraftingManager().craft(recipes, iinventory, world).map(RecipeCooking::getCookingTime).orElse(200); ++ return (world != null) ? (Integer) world.getCraftingManager().craft((Recipes) recipes, iinventory, world).map(RecipeCooking::getCookingTime).orElse(200) : 200; // CraftBukkit - SPIGOT-4302 // Eclipse fail } public static boolean isFuel(ItemStack itemstack) { -@@ -475,14 +554,20 @@ +@@ -484,14 +563,20 @@ @Override - public void b(EntityHuman entityhuman) {} + public void awardUsedRecipes(EntityHuman entityhuman) {} -- public void d(EntityHuman entityhuman) { -- List> list = this.a(entityhuman.world, entityhuman.getPositionVector()); -+ public void d(EntityHuman entityhuman, ItemStack itemstack, int amount) { // CraftBukkit -+ List> list = this.a(entityhuman.world, entityhuman.getPositionVector(), entityhuman, itemstack, amount); // CraftBukkit +- public void a(EntityPlayer entityplayer) { +- List> list = this.a(entityplayer.getWorldServer(), entityplayer.getPositionVector()); ++ public void a(EntityPlayer entityplayer, ItemStack itemstack, int amount) { // CraftBukkit ++ List> list = this.a(entityplayer.getWorldServer(), entityplayer.getPositionVector(), this.worldPosition, entityplayer, itemstack, amount); // CraftBukkit - entityhuman.discoverRecipes(list); - this.n.clear(); + entityplayer.discoverRecipes(list); + this.recipesUsed.clear(); } - public List> a(World world, Vec3D vec3d) { + public List> a(WorldServer worldserver, Vec3D vec3d) { + // CraftBukkit start -+ return this.a(world, vec3d, null, null, 0); ++ return this.a(worldserver, vec3d, this.worldPosition, null, null, 0); + } + -+ public List> a(World world, Vec3D vec3d, EntityHuman entityhuman, ItemStack itemstack, int amount) { ++ public List> a(WorldServer worldserver, Vec3D vec3d, BlockPosition blockposition, EntityPlayer entityplayer, ItemStack itemstack, int amount) { + // CraftBukkit end List> list = Lists.newArrayList(); - ObjectIterator objectiterator = this.n.object2IntEntrySet().iterator(); + ObjectIterator objectiterator = this.recipesUsed.object2IntEntrySet().iterator(); -@@ -491,14 +576,14 @@ +@@ -500,14 +585,14 @@ - world.getCraftingManager().getRecipe((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> { + worldserver.getCraftingManager().getRecipe((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> { list.add(irecipe); -- a(world, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience()); -+ a(world, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience(), entityhuman, itemstack, amount); // CraftBukkit +- a(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience()); ++ a(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit }); } return list; } -- private static void a(World world, Vec3D vec3d, int i, float f) { -+ private void a(World world, Vec3D vec3d, int i, float f, EntityHuman entityhuman, ItemStack itemstack, int amount) { // CraftBukkit +- 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); -@@ -506,6 +591,14 @@ +@@ -515,6 +600,14 @@ ++j; } + // CraftBukkit start - fire FurnaceExtractEvent + if (amount != 0) { -+ FurnaceExtractEvent event = new FurnaceExtractEvent((Player) entityhuman.getBukkitEntity(), CraftBlock.at(world, position), org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(itemstack.getItem()), amount, j); -+ world.getServer().getPluginManager().callEvent(event); ++ FurnaceExtractEvent event = new FurnaceExtractEvent((Player) entityhuman.getBukkitEntity(), CraftBlock.at(worldserver, blockposition), org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(itemstack.getItem()), amount, j); ++ worldserver.getServer().getPluginManager().callEvent(event); + j = event.getExpToDrop(); + } + // CraftBukkit end + - while (j > 0) { - int k = EntityExperienceOrb.getOrbValue(j); + EntityExperienceOrb.a(worldserver, vec3d, j); + } diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityHopper.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityHopper.patch index 9b5878b37..d48bd62b3 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityHopper.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityHopper.patch @@ -1,12 +1,13 @@ --- a/net/minecraft/world/level/block/entity/TileEntityHopper.java +++ b/net/minecraft/world/level/block/entity/TileEntityHopper.java -@@ -33,12 +33,53 @@ +@@ -33,6 +33,18 @@ import net.minecraft.world.phys.shapes.OperatorBoolean; import net.minecraft.world.phys.shapes.VoxelShapes; +// CraftBukkit start +import net.minecraft.world.InventoryLargeChest; +import net.minecraft.world.entity.vehicle.EntityMinecartHopper; ++import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.entity.HumanEntity; @@ -15,11 +16,12 @@ +import org.bukkit.inventory.Inventory; +// CraftBukkit end + - public class TileEntityHopper extends TileEntityLootable implements IHopper, ITickable { + public class TileEntityHopper extends TileEntityLootable implements IHopper { - private NonNullList items; - private int j; - private long k; + public static final int MOVE_ITEM_SPEED = 8; +@@ -41,6 +53,36 @@ + private int cooldownTime; + private long tickedGameTime; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); @@ -51,40 +53,58 @@ + } + // CraftBukkit end + - public TileEntityHopper() { - super(TileEntityTypes.HOPPER); - this.items = NonNullList.a(5, ItemStack.b); -@@ -164,7 +205,28 @@ - for (int i = 0; i < this.getSize(); ++i) { - if (!this.getItem(i).isEmpty()) { - ItemStack itemstack = this.getItem(i).cloneItemStack(); -- ItemStack itemstack1 = addItem(this, iinventory, this.splitStack(i, 1), enumdirection); -+ // ItemStack itemstack1 = addItem(this, iinventory, this.splitStack(i, 1), enumdirection); + public TileEntityHopper(BlockPosition blockposition, IBlockData iblockdata) { + super(TileEntityTypes.HOPPER, blockposition, iblockdata); + this.items = NonNullList.a(5, ItemStack.EMPTY); +@@ -115,7 +157,7 @@ + boolean flag = false; + + if (!tileentityhopper.isEmpty()) { +- flag = a(world, blockposition, iblockdata, (IInventory) tileentityhopper); ++ flag = a(world, blockposition, iblockdata, (IInventory) tileentityhopper, tileentityhopper); // CraftBukkit + } + + if (!tileentityhopper.i()) { +@@ -149,7 +191,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); + + if (iinventory1 == null) { +@@ -163,7 +205,28 @@ + for (int i = 0; i < iinventory.getSize(); ++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); + + // CraftBukkit start - Call event when pushing items into other inventories -+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(i, 1)); ++ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, 1)); + + Inventory destinationInventory; + // Have to special case large chests as they work oddly -+ if (iinventory instanceof InventoryLargeChest) { -+ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory); ++ if (iinventory1 instanceof InventoryLargeChest) { ++ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory1); + } else { -+ destinationInventory = iinventory.getOwner().getInventory(); ++ destinationInventory = iinventory1.getOwner().getInventory(); + } + -+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(this.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true); -+ this.getWorld().getServer().getPluginManager().callEvent(event); ++ InventoryMoveItemEvent event = new InventoryMoveItemEvent(iinventory.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true); ++ world.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { -+ this.setItem(i, itemstack); -+ this.setCooldown(8); // Delay hopper checks ++ hopper.setItem(i, itemstack); ++ hopper.setCooldown(8); // Delay hopper checks + return false; + } -+ ItemStack itemstack1 = addItem(this, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection); ++ ItemStack itemstack1 = addItem(iinventory, iinventory1, CraftItemStack.asNMSCopy(event.getItem()), enumdirection); + // CraftBukkit end if (itemstack1.isEmpty()) { - iinventory.update(); -@@ -229,7 +291,34 @@ + iinventory1.update(); +@@ -228,7 +291,34 @@ if (!itemstack.isEmpty() && b(iinventory, itemstack, i, enumdirection)) { ItemStack itemstack1 = itemstack.cloneItemStack(); @@ -103,7 +123,7 @@ + + InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false); + -+ ihopper.getWorld().getServer().getPluginManager().callEvent(event); ++ Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + iinventory.setItem(i, itemstack1); + @@ -120,13 +140,13 @@ if (itemstack2.isEmpty()) { iinventory.update(); -@@ -244,6 +333,13 @@ +@@ -243,6 +333,13 @@ public static boolean a(IInventory iinventory, EntityItem entityitem) { boolean flag = false; + // CraftBukkit start + InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory.getOwner().getInventory(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); -+ entityitem.world.getServer().getPluginManager().callEvent(event); ++ entityitem.level.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return false; + } diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch index 71abcc23a..546c65c42 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityLectern.java +++ b/net/minecraft/world/level/block/entity/TileEntityLectern.java -@@ -27,9 +27,67 @@ +@@ -27,13 +27,71 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; @@ -18,9 +18,14 @@ +// CraftBukkit end + +public class TileEntityLectern extends TileEntity implements Clearable, ITileInventory, ICommandListener { // CraftBukkit - ICommandListener -+ + + public static final int DATA_PAGE = 0; + public static final int NUM_DATA = 1; + public static final int SLOT_BOOK = 0; + public static final int NUM_SLOTS = 1; +- public final IInventory bookAccess = new IInventory() { + // CraftBukkit start - add fields and methods -+ public final IInventory inventory = new LecternInventory(); ++ public final IInventory bookAccess = new LecternInventory(); + public class LecternInventory implements IInventory { + + public List transaction = new ArrayList<>(); @@ -53,7 +58,7 @@ + + @Override + public Location getLocation() { -+ return new Location(world.getWorld(), position.getX(), position.getY(), position.getZ()); ++ return new Location(level.getWorld(), worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()); + } + + @Override @@ -65,12 +70,11 @@ + return TileEntityLectern.this; + } + // CraftBukkit end - -- public final IInventory inventory = new IInventory() { ++ @Override public int getSize() { return 1; -@@ -74,11 +132,20 @@ +@@ -78,11 +136,20 @@ } @Override @@ -93,16 +97,16 @@ } @Override -@@ -160,7 +227,7 @@ +@@ -162,7 +229,7 @@ if (j != this.page) { this.page = j; this.update(); - BlockLectern.a(this.getWorld(), this.getPosition(), this.getBlock()); -+ if (this.world != null) BlockLectern.a(this.getWorld(), this.getPosition(), this.getBlock()); // CraftBukkit ++ if (this.level != null) BlockLectern.a(this.getWorld(), this.getPosition(), this.getBlock()); // CraftBukkit } } -@@ -183,6 +250,32 @@ +@@ -185,6 +252,32 @@ return itemstack; } @@ -135,22 +139,22 @@ private CommandListenerWrapper a(@Nullable EntityHuman entityhuman) { String s; Object object; -@@ -197,7 +290,8 @@ +@@ -199,7 +292,8 @@ - Vec3D vec3d = Vec3D.a((BaseBlockPosition) this.position); + Vec3D vec3d = Vec3D.a((BaseBlockPosition) this.worldPosition); -- return new CommandListenerWrapper(ICommandListener.DUMMY, vec3d, Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityhuman); +- return new CommandListenerWrapper(ICommandListener.NULL, vec3d, Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getMinecraftServer(), entityhuman); + // CraftBukkit - this -+ return new CommandListenerWrapper(this, vec3d, Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityhuman); ++ return new CommandListenerWrapper(this, vec3d, Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getMinecraftServer(), entityhuman); } @Override -@@ -236,7 +330,7 @@ +@@ -238,7 +332,7 @@ @Override public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) { -- return new ContainerLectern(i, this.inventory, this.containerProperties); -+ return new ContainerLectern(i, this.inventory, this.containerProperties, playerinventory); // CraftBukkit +- return new ContainerLectern(i, this.bookAccess, this.dataAccess); ++ return new ContainerLectern(i, this.bookAccess, this.dataAccess, playerinventory); // CraftBukkit } @Override diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch index 119673267..7694f833c 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/level/block/entity/TileEntityShulkerBox.java +++ b/net/minecraft/world/level/block/entity/TileEntityShulkerBox.java -@@ -29,6 +29,11 @@ +@@ -32,6 +32,11 @@ + import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; - import net.minecraft.world.phys.shapes.VoxelShapes; +// CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.entity.HumanEntity; +// CraftBukkit end + - public class TileEntityShulkerBox extends TileEntityLootable implements IWorldInventory, ITickable { + public class TileEntityShulkerBox extends TileEntityLootable implements IWorldInventory { - private static final int[] a = IntStream.range(0, 27).toArray(); -@@ -41,6 +46,37 @@ - private EnumColor l; - private boolean m; + public static final int COLUMNS = 9; +@@ -51,6 +56,37 @@ + @Nullable + private final EnumColor color; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); @@ -22,7 +22,7 @@ + public boolean opened; + + public List getContents() { -+ return this.contents; ++ return this.itemStacks; + } + + public void onOpen(CraftHumanEntity who) { @@ -47,22 +47,22 @@ + } + // CraftBukkit end + - public TileEntityShulkerBox(@Nullable EnumColor enumcolor) { - super(TileEntityTypes.SHULKER_BOX); - this.contents = NonNullList.a(27, ItemStack.b); -@@ -203,6 +239,7 @@ + public TileEntityShulkerBox(@Nullable EnumColor enumcolor, BlockPosition blockposition, IBlockData iblockdata) { + super(TileEntityTypes.SHULKER_BOX, blockposition, iblockdata); + this.itemStacks = NonNullList.a(27, ItemStack.EMPTY); +@@ -163,6 +199,7 @@ } - ++this.viewingCount; + ++this.openCount; + if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call. - this.world.playBlockAction(this.position, this.getBlock().getBlock(), 1, this.viewingCount); - if (this.viewingCount == 1) { - this.world.playSound((EntityHuman) null, this.position, SoundEffects.BLOCK_SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F); -@@ -215,6 +252,7 @@ + this.level.playBlockAction(this.worldPosition, this.getBlock().getBlock(), 1, this.openCount); + if (this.openCount == 1) { + this.level.a((Entity) entityhuman, GameEvent.CONTAINER_OPEN, this.worldPosition); +@@ -176,6 +213,7 @@ public void closeContainer(EntityHuman entityhuman) { if (!entityhuman.isSpectator()) { - --this.viewingCount; + --this.openCount; + if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call. - this.world.playBlockAction(this.position, this.getBlock().getBlock(), 1, this.viewingCount); - if (this.viewingCount <= 0) { - this.world.playSound((EntityHuman) null, this.position, SoundEffects.BLOCK_SHULKER_BOX_CLOSE, SoundCategory.BLOCKS, 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F); + this.level.playBlockAction(this.worldPosition, this.getBlock().getBlock(), 1, this.openCount); + if (this.openCount <= 0) { + this.level.a((Entity) entityhuman, GameEvent.CONTAINER_CLOSE, this.worldPosition); diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch index 41279c969..bda80c85e 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/level/block/entity/TileEntitySign.java +++ b/net/minecraft/world/level/block/entity/TileEntitySign.java -@@ -23,7 +23,7 @@ +@@ -25,7 +25,7 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; -public class TileEntitySign extends TileEntity { +public class TileEntitySign extends TileEntity implements ICommandListener { // CraftBukkit - implements - public final IChatBaseComponent[] lines; - public boolean isEditable; -@@ -49,6 +49,12 @@ - nbttagcompound.setString("Text" + (i + 1), s); + public static final int LINES = 4; + private static final String[] RAW_TEXT_FIELD_NAMES = new String[]{"Text1", "Text2", "Text3", "Text4"}; +@@ -65,6 +65,12 @@ + } } + // CraftBukkit start @@ -19,56 +19,46 @@ + } + // CraftBukkit end + - nbttagcompound.setString("Color", this.color.c()); + nbttagcompound.setString("Color", this.color.b()); + nbttagcompound.setBoolean("GlowingText", this.hasGlowingText); return nbttagcompound; - } -@@ -59,18 +65,38 @@ - super.load(iblockdata, nbttagcompound); +@@ -76,8 +82,24 @@ + super.load(nbttagcompound); this.color = EnumColor.a(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 + // we have no way to tell whether a sign is from 1.7.10 or 1.8 -+ + boolean oldSign = Boolean.getBoolean("convertLegacySigns") && !nbttagcompound.getBoolean("Bukkit.isConverted"); ++ // CraftBukkit end + for (int i = 0; i < 4; ++i) { - String s = nbttagcompound.getString("Text" + (i + 1)); -- IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.ChatSerializer.a(s.isEmpty() ? "\"\"" : s); + String s = nbttagcompound.getString(TileEntitySign.RAW_TEXT_FIELD_NAMES[i]); ++ // CraftBukkit start + if (s != null && s.length() > 2048) { + s = "\"\""; + } + -+ try { -+ IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.ChatSerializer.a(s.isEmpty() ? "\"\"" : s); ++ if (oldSign) { ++ messages[i] = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(s)[0]; ++ continue; ++ } ++ // CraftBukkit end + IChatBaseComponent ichatbasecomponent = this.a(s); -- if (this.world instanceof WorldServer) { -- try { -- this.lines[i] = ChatComponentUtils.filterForDisplay(this.a((EntityPlayer) null), ichatmutablecomponent, (Entity) null, 0); -- } catch (CommandSyntaxException commandsyntaxexception) { -+ if (oldSign) { -+ lines[i] = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(s)[0]; -+ continue; -+ } -+ // CraftBukkit end -+ -+ if (this.world instanceof WorldServer) { -+ try { -+ this.lines[i] = ChatComponentUtils.filterForDisplay(this.a((EntityPlayer) null), ichatmutablecomponent, (Entity) null, 0); -+ } catch (CommandSyntaxException commandsyntaxexception) { -+ this.lines[i] = ichatmutablecomponent; -+ } -+ } else { - this.lines[i] = ichatmutablecomponent; - } -- } else { -- this.lines[i] = ichatmutablecomponent; -+ } catch (com.google.gson.JsonParseException jsonparseexception) { -+ this.lines[i] = new ChatComponentText(s); + this.messages[i] = ichatbasecomponent; +@@ -115,6 +137,10 @@ + if (ichatmutablecomponent != null) { + return ichatmutablecomponent; } - - this.g[i] = null; -@@ -131,11 +157,37 @@ ++ // CraftBukkit start ++ } catch (com.google.gson.JsonParseException jsonparseexception) { ++ return new ChatComponentText(s); ++ // CraftBukkit end + } catch (Exception exception) { + ; + } +@@ -207,11 +233,37 @@ return true; } @@ -97,22 +87,21 @@ + } + // CraftBukkit end + - public CommandListenerWrapper a(@Nullable EntityPlayer entityplayer) { + public CommandListenerWrapper b(@Nullable EntityPlayer entityplayer) { String s = entityplayer == null ? "Sign" : entityplayer.getDisplayName().getString(); Object object = entityplayer == null ? new ChatComponentText("Sign") : entityplayer.getScoreboardDisplayName(); -- return new CommandListenerWrapper(ICommandListener.DUMMY, Vec3D.a((BaseBlockPosition) this.position), Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityplayer); +- return new CommandListenerWrapper(ICommandListener.NULL, Vec3D.a((BaseBlockPosition) this.worldPosition), Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getMinecraftServer(), entityplayer); + // CraftBukkit - this -+ return new CommandListenerWrapper(this, Vec3D.a((BaseBlockPosition) this.position), Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityplayer); ++ return new CommandListenerWrapper(this, Vec3D.a((BaseBlockPosition) this.worldPosition), Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getMinecraftServer(), entityplayer); } public EnumColor getColor() { -@@ -146,7 +198,7 @@ - if (enumcolor != this.getColor()) { - this.color = enumcolor; - this.update(); -- this.world.notify(this.getPosition(), this.getBlock(), this.getBlock(), 3); -+ if (this.world != null) this.world.notify(this.getPosition(), this.getBlock(), this.getBlock(), 3); // CraftBukkit - skip notify if world is null (SPIGOT-5122) - return true; - } else { - return false; +@@ -244,6 +296,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) + } + } diff --git a/nms-patches/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.patch b/nms-patches/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.patch index e5a11ce1c..020dc1dac 100644 --- a/nms-patches/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.patch +++ b/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 -@@ -39,6 +39,7 @@ +@@ -38,6 +38,7 @@ + if (worldgenfeatureconfigured == null) { return false; } else { - ((WorldGenFeatureTreeConfiguration) worldgenfeatureconfigured.f).b(); + setTreeType(worldgenfeatureconfigured); // CraftBukkit IBlockData iblockdata1 = Blocks.AIR.getBlockData(); - worldserver.setTypeAndData(blockposition.b(i, 0, j), iblockdata1, 4); + worldserver.setTypeAndData(blockposition.c(i, 0, j), iblockdata1, 4); diff --git a/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch b/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch index e7e3cdb13..d8c128b32 100644 --- a/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch +++ b/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch @@ -19,9 +19,9 @@ } else { + setTreeType(worldgenfeatureconfigured); // CraftBukkit worldserver.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 4); - ((WorldGenFeatureTreeConfiguration) worldgenfeatureconfigured.f).b(); if (worldgenfeatureconfigured.a(worldserver, chunkgenerator, random, blockposition)) { -@@ -53,4 +60,46 @@ + return true; +@@ -52,4 +59,48 @@ return true; } @@ -48,7 +48,7 @@ + BlockSapling.treeType = TreeType.BIRCH; + } else if (worldgentreeabstract == BiomeDecoratorGroups.SUPER_BIRCH_BEES_0002) { + BlockSapling.treeType = TreeType.TALL_BIRCH; -+ } else if (worldgentreeabstract == BiomeDecoratorGroups.SWAMP_TREE) { ++ } else if (worldgentreeabstract == BiomeDecoratorGroups.SWAMP_OAK) { + BlockSapling.treeType = TreeType.SWAMP; + } else if (worldgentreeabstract == BiomeDecoratorGroups.FANCY_OAK || worldgentreeabstract == BiomeDecoratorGroups.FANCY_OAK_BEES_005) { + BlockSapling.treeType = TreeType.BIG_TREE; @@ -62,6 +62,8 @@ + BlockSapling.treeType = TreeType.MEGA_REDWOOD; + } else if (worldgentreeabstract == BiomeDecoratorGroups.MEGA_JUNGLE_TREE) { + BlockSapling.treeType = TreeType.JUNGLE; ++ } else if (worldgentreeabstract == BiomeDecoratorGroups.AZALEA_TREE) { ++ BlockSapling.treeType = TreeType.AZALEA; + } else { + throw new IllegalArgumentException("Unknown tree generator " + worldgentreeabstract); + } diff --git a/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch b/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch index 4d88e6a44..abecbe083 100644 --- a/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch +++ b/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/piston/BlockPiston.java +++ b/net/minecraft/world/level/block/piston/BlockPiston.java -@@ -36,6 +36,14 @@ +@@ -39,6 +39,14 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -14,13 +14,13 @@ + public class BlockPiston extends BlockDirectional { - public static final BlockStateBoolean EXTENDED = BlockProperties.g; -@@ -132,6 +140,18 @@ + public static final BlockStateBoolean EXTENDED = BlockProperties.EXTENDED; +@@ -139,6 +147,18 @@ } } + // CraftBukkit start -+ if (!this.sticky) { ++ if (!this.isSticky) { + org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, ImmutableList.of(), CraftBlock.notchToBlockFace(enumdirection)); + world.getServer().getPluginManager().callEvent(event); @@ -31,10 +31,10 @@ + } + // PAIL: checkME - what happened to setTypeAndData? + // CraftBukkit end - world.playBlockAction(blockposition, this, b0, enumdirection.c()); + world.playBlockAction(blockposition, this, b0, enumdirection.b()); } -@@ -308,6 +328,48 @@ +@@ -317,6 +337,48 @@ IBlockData[] aiblockdata = new IBlockData[list.size() + list2.size()]; EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite(); int j = 0; diff --git a/nms-patches/net/minecraft/world/level/block/state/properties/BlockStateInteger.patch b/nms-patches/net/minecraft/world/level/block/state/properties/BlockStateInteger.patch index 27e534f75..202d0bf45 100644 --- a/nms-patches/net/minecraft/world/level/block/state/properties/BlockStateInteger.patch +++ b/nms-patches/net/minecraft/world/level/block/state/properties/BlockStateInteger.patch @@ -3,7 +3,7 @@ @@ -9,9 +9,15 @@ public class BlockStateInteger extends IBlockState { - private final ImmutableSet a; + private final ImmutableSet values; + // CraftBukkit start + public final int min; + public final int max; diff --git a/nms-patches/net/minecraft/world/level/border/WorldBorder.patch b/nms-patches/net/minecraft/world/level/border/WorldBorder.patch index bcd2b2d6c..e82ac5583 100644 --- a/nms-patches/net/minecraft/world/level/border/WorldBorder.patch +++ b/nms-patches/net/minecraft/world/level/border/WorldBorder.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/level/border/WorldBorder.java +++ b/net/minecraft/world/level/border/WorldBorder.java -@@ -27,6 +27,7 @@ - private int i = 29999984; - private WorldBorder.a j = new WorldBorder.d(6.0E7D); - public static final WorldBorder.c c = new WorldBorder.c(0.0D, 0.0D, 0.2D, 5.0D, 5, 15, 6.0E7D, 0L, 0.0D); +@@ -28,6 +28,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); + public net.minecraft.server.level.WorldServer world; // CraftBukkit public WorldBorder() {} -@@ -140,6 +141,7 @@ +@@ -149,6 +150,7 @@ } public void a(IWorldBorderListener iworldborderlistener) { -+ if (a.contains(iworldborderlistener)) return; // CraftBukkit - this.a.add(iworldborderlistener); ++ if (listeners.contains(iworldborderlistener)) return; // CraftBukkit + this.listeners.add(iworldborderlistener); } diff --git a/nms-patches/net/minecraft/world/level/chunk/BiomeStorage.patch b/nms-patches/net/minecraft/world/level/chunk/BiomeStorage.patch index ba06164c4..df6cec907 100644 --- a/nms-patches/net/minecraft/world/level/chunk/BiomeStorage.patch +++ b/nms-patches/net/minecraft/world/level/chunk/BiomeStorage.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/level/chunk/BiomeStorage.java +++ b/net/minecraft/world/level/chunk/BiomeStorage.java -@@ -93,4 +93,14 @@ +@@ -109,4 +109,14 @@ - return this.h[i1 << BiomeStorage.e + BiomeStorage.e | j1 << BiomeStorage.e | l]; + 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.b; -+ int i1 = MathHelper.clamp(j, 0, BiomeStorage.c); -+ int j1 = k & BiomeStorage.b; ++ int l = i & BiomeStorage.HORIZONTAL_MASK; ++ int i1 = MathHelper.clamp(j - this.quartMinY, 0, this.quartHeight); ++ int j1 = k & BiomeStorage.HORIZONTAL_MASK; + -+ this.h[i1 << BiomeStorage.e + BiomeStorage.e | j1 << BiomeStorage.e | l] = biome; ++ this.biomes[i1 << BiomeStorage.WIDTH_BITS + BiomeStorage.WIDTH_BITS | j1 << BiomeStorage.WIDTH_BITS | l] = biome; + } + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/level/chunk/Chunk.patch b/nms-patches/net/minecraft/world/level/chunk/Chunk.patch index 66e0aaef6..2ef62924d 100644 --- a/nms-patches/net/minecraft/world/level/chunk/Chunk.patch +++ b/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 -@@ -65,7 +65,7 @@ - private BiomeStorage d; - private final Map e; +@@ -92,7 +92,7 @@ + private final Map pendingBlockEntities; + private final Map tickersInLevel; public boolean loaded; -- public final World world; -+ public final WorldServer world; // CraftBukkit - type - public final Map heightMap; - private final ChunkConverter i; - public final Map tileEntities; -@@ -99,7 +99,7 @@ - this.m = Maps.newHashMap(); - this.n = new ShortList[16]; - this.entitySlices = (EntitySlice[]) (new EntitySlice[16]); -- this.world = world; -+ this.world = (WorldServer) world; // CraftBukkit - type - this.loc = chunkcoordintpair; - this.i = chunkconverter; - HeightMap.Type[] aheightmap_type = HeightMap.Type.values(); -@@ -130,8 +130,22 @@ - } +- public final World level; ++ public final WorldServer level; // CraftBukkit - type + public final Map heightmaps; + private final ChunkConverter upgradeData; + public final Map blockEntities; +@@ -122,7 +122,7 @@ + this.blockEntities = Maps.newHashMap(); + this.structureStarts = Maps.newHashMap(); + this.structuresRefences = Maps.newHashMap(); +- 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()]; + // CraftBukkit start + this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this); } @@ -38,18 +38,18 @@ + public final org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer(DATA_TYPE_REGISTRY); + // CraftBukkit end + - public Chunk(World world, ProtoChunk protochunk) { - this(world, protochunk.getPos(), protochunk.getBiomeIndex(), protochunk.p(), protochunk.n(), protochunk.o(), protochunk.getInhabitedTime(), protochunk.getSections(), (Consumer) null); - Iterator iterator = protochunk.y().iterator(); -@@ -173,6 +187,7 @@ + public Chunk(WorldServer worldserver, ProtoChunk protochunk, @Nullable Consumer 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 @@ - this.b(protochunk.r()); - this.s = true; + this.b(protochunk.s()); + this.unsaved = true; + this.needsDecoration = true; // CraftBukkit } @Override -@@ -263,9 +278,16 @@ +@@ -285,9 +300,16 @@ } } @@ -63,54 +63,54 @@ + @Nullable + public IBlockData setType(BlockPosition blockposition, IBlockData iblockdata, boolean flag, boolean doPlace) { + // CraftBukkit end - int i = blockposition.getX() & 15; - int j = blockposition.getY(); - int k = blockposition.getZ() & 15; -@@ -317,7 +339,8 @@ - } - } - -- if (!this.world.isClientSide) { + 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.world.isClientSide && doPlace && (!this.world.captureBlockStates || block instanceof net.minecraft.world.level.block.BlockTileEntity)) { - iblockdata.onPlace(this.world, blockposition, iblockdata1, flag); ++ if (!this.level.isClientSide && doPlace && (!this.level.captureBlockStates || block instanceof net.minecraft.world.level.block.BlockTileEntity)) { + iblockdata.onPlace(this.level, blockposition, iblockdata1, flag); } -@@ -412,7 +435,12 @@ +@@ -401,7 +424,12 @@ @Nullable public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) { -- TileEntity tileentity = (TileEntity) this.tileEntities.get(blockposition); +- TileEntity tileentity = (TileEntity) this.blockEntities.get(blockposition); + // CraftBukkit start -+ TileEntity tileentity = world.capturedTileEntities.get(blockposition); ++ TileEntity tileentity = level.capturedTileEntities.get(blockposition); + if (tileentity == null) { -+ tileentity = (TileEntity) this.tileEntities.get(blockposition); ++ tileentity = (TileEntity) this.blockEntities.get(blockposition); + } + // CraftBukkit end if (tileentity == null) { - NBTTagCompound nbttagcompound = (NBTTagCompound) this.e.remove(blockposition); -@@ -458,6 +486,13 @@ - tileentity1.al_(); + NBTTagCompound nbttagcompound = (NBTTagCompound) this.pendingBlockEntities.remove(blockposition); +@@ -460,6 +488,13 @@ + tileentity1.aa_(); } + // 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("Chunk coordinates: " + (this.loc.x * 16) + "," + (this.loc.z * 16)); ++ System.out.println("Chunk coordinates: " + (this.chunkPos.x * 16) + "," + (this.chunkPos.z * 16)); + new Exception().printStackTrace(); + // CraftBukkit end } } -@@ -507,6 +542,50 @@ +@@ -541,6 +576,50 @@ } + // CraftBukkit start + public void loadCallback() { -+ org.bukkit.Server server = this.world.getServer(); ++ org.bukkit.Server server = this.level.getServer(); + if (server != null) { + /* + * If it's a new world, the first few chunks are generated inside @@ -122,20 +122,20 @@ + if (this.needsDecoration) { + this.needsDecoration = false; + java.util.Random random = new java.util.Random(); -+ random.setSeed(world.getSeed()); ++ random.setSeed(level.getSeed()); + long xRand = random.nextLong() / 2L * 2L + 1L; + long zRand = random.nextLong() / 2L * 2L + 1L; -+ random.setSeed((long) this.loc.x * xRand + (long) this.loc.z * zRand ^ world.getSeed()); ++ random.setSeed((long) this.chunkPos.x * xRand + (long) this.chunkPos.z * zRand ^ level.getSeed()); + -+ org.bukkit.World world = this.world.getWorld(); ++ org.bukkit.World world = this.level.getWorld(); + if (world != null) { -+ this.world.populating = true; ++ this.level.populating = true; + try { + for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) { + populator.populate(world, random, bukkitChunk); + } + } finally { -+ this.world.populating = false; ++ this.level.populating = false; + } + } + server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk)); @@ -144,7 +144,7 @@ + } + + public void unloadCallback() { -+ org.bukkit.Server server = this.world.getServer(); ++ org.bukkit.Server server = this.level.getServer(); + org.bukkit.event.world.ChunkUnloadEvent unloadEvent = new org.bukkit.event.world.ChunkUnloadEvent(this.bukkitChunk, this.isNeedsSaving()); + server.getPluginManager().callEvent(unloadEvent); + // note: saving can be prevented, but not forced if no saving is actually required @@ -153,65 +153,76 @@ + // CraftBukkit end + public void markDirty() { - this.s = true; + this.unsaved = true; } -@@ -560,7 +639,7 @@ - Iterator iterator = this.entitySlices[k].a(Entity.class).iterator(); - - while (iterator.hasNext()) { -- Entity entity = (Entity) iterator.next(); -+ T entity = (T) iterator.next(); // CraftBukkit - decompile error - - if ((entitytypes == null || entity.getEntityType() == entitytypes) && entity.getBoundingBox().c(axisalignedbb) && predicate.test(entity)) { - list.add(entity); -@@ -581,7 +660,7 @@ - Iterator iterator = this.entitySlices[k].a(oclass).iterator(); - - while (iterator.hasNext()) { -- T t0 = (Entity) iterator.next(); -+ T t0 = (T) iterator.next(); // CraftBukkit - decompile error - - if (t0.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.test(t0))) { - list.add(t0); -@@ -655,7 +734,7 @@ +@@ -664,7 +743,7 @@ @Override public boolean isNeedsSaving() { -- return this.s || this.q && this.world.getTime() != this.lastSaved; -+ return (this.s || this.q && this.world.getTime() != this.lastSaved) && !this.mustNotSave; // CraftBukkit +- return this.unsaved; ++ return this.unsaved && !this.mustNotSave; // CraftBukkit } - public void d(boolean flag) { -@@ -797,7 +876,7 @@ + @Nullable +@@ -795,7 +874,7 @@ public void B() { - if (this.o instanceof ProtoChunkTickList) { -- ((ProtoChunkTickList) this.o).a(this.world.getBlockTickList(), (blockposition) -> { -+ ((ProtoChunkTickList) this.o).a(this.world.getBlockTickList(), (blockposition) -> { // CraftBukkit - decompile error + if (this.blockTicks instanceof ProtoChunkTickList) { +- ((ProtoChunkTickList) this.blockTicks).a(this.level.getBlockTickList(), (blockposition) -> { ++ ((ProtoChunkTickList) this.blockTicks).a(this.level.getBlockTickList(), (blockposition) -> { // CraftBukkit - decompile error return this.getType(blockposition).getBlock(); }); - this.o = TickListEmpty.b(); -@@ -807,7 +886,7 @@ + this.blockTicks = TickListEmpty.b(); +@@ -805,7 +884,7 @@ } - if (this.p instanceof ProtoChunkTickList) { -- ((ProtoChunkTickList) this.p).a(this.world.getFluidTickList(), (blockposition) -> { -+ ((ProtoChunkTickList) this.p).a(this.world.getFluidTickList(), (blockposition) -> { // CraftBukkit - decompile error + if (this.liquidTicks instanceof ProtoChunkTickList) { +- ((ProtoChunkTickList) this.liquidTicks).a(this.level.getFluidTickList(), (blockposition) -> { ++ ((ProtoChunkTickList) this.liquidTicks).a(this.level.getFluidTickList(), (blockposition) -> { // CraftBukkit - decompile error return this.getFluid(blockposition).getType(); }); - this.p = TickListEmpty.b(); -@@ -819,12 +898,12 @@ - } - + this.liquidTicks = TickListEmpty.b(); +@@ -819,14 +898,14 @@ public void a(WorldServer worldserver) { -- if (this.o == TickListEmpty.b()) { -+ if (this.o == TickListEmpty.b()) { // CraftBukkit - decompile error - this.o = new TickListChunk<>(IRegistry.BLOCK::getKey, worldserver.getBlockTickList().a(this.loc, true, false), worldserver.getTime()); + RegistryBlocks registryblocks; + +- if (this.blockTicks == TickListEmpty.b()) { ++ if (this.blockTicks == TickListEmpty.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.p == TickListEmpty.b()) { -+ if (this.p == TickListEmpty.b()) { // CraftBukkit - decompile error - this.p = new TickListChunk<>(IRegistry.FLUID::getKey, worldserver.getFluidTickList().a(this.loc, true, false), worldserver.getTime()); - this.setNeedsSaving(true); +- if (this.liquidTicks == TickListEmpty.b()) { ++ if (this.liquidTicks == TickListEmpty.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 +978,7 @@ + + private void f(T t0) { + IBlockData iblockdata = t0.getBlock(); +- BlockEntityTicker blockentityticker = iblockdata.a(this.level, t0.getTileType()); ++ BlockEntityTicker blockentityticker = iblockdata.a(this.level, (TileEntityTypes) t0.getTileType()); // CraftBukkit - decompile error + + if (blockentityticker == null) { + this.l(t0.getPosition()); +@@ -978,7 +1057,7 @@ + private boolean loggedInvalidBlockState; + + a(TileEntity tileentity, BlockEntityTicker blockentityticker) { +- this.blockEntity = tileentity; ++ this.blockEntity = (T) tileentity; // CraftBukkit - decompile error + this.ticker = blockentityticker; } + +@@ -1001,7 +1080,7 @@ + this.loggedInvalidBlockState = true; + Chunk.LOGGER.warn("Block entity {} @ {} state {} invalid for ticking:", new org.apache.logging.log4j.util.Supplier[]{this::d, this::c, () -> { + return iblockdata; +- }}); ++ }}); // CraftBukkit - squelch checkstyle + } + + gameprofilerfiller.exit(); diff --git a/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch b/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch index 87855a895..ca7d4eebc 100644 --- a/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch +++ b/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch @@ -1,35 +1,35 @@ --- a/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/net/minecraft/world/level/chunk/ChunkGenerator.java -@@ -246,7 +246,16 @@ +@@ -269,7 +269,16 @@ while (iterator.hasNext()) { Supplier> supplier = (Supplier) iterator.next(); -- this.a((StructureFeature) supplier.get(), iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase); +- this.a((StructureFeature) supplier.get(), iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, biomebase); + // CraftBukkit start + StructureFeature structurefeature = (StructureFeature) supplier.get(); -+ if (structurefeature.c == StructureGenerator.STRONGHOLD) { ++ if (structurefeature.LIST_CODEC == StructureGenerator.STRONGHOLD) { + synchronized (structurefeature) { -+ this.a(structurefeature, iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase); ++ this.a((StructureFeature) supplier.get(), iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, biomebase); + } + } else { -+ this.a(structurefeature, iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase); ++ this.a((StructureFeature) supplier.get(), iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, biomebase); + } + // CraftBukkit end } } -@@ -330,9 +339,11 @@ +@@ -364,9 +373,11 @@ } static { -- IRegistry.a(IRegistry.CHUNK_GENERATOR, "noise", (Object) ChunkGeneratorAbstract.d); -- IRegistry.a(IRegistry.CHUNK_GENERATOR, "flat", (Object) ChunkProviderFlat.d); -- IRegistry.a(IRegistry.CHUNK_GENERATOR, "debug", (Object) ChunkProviderDebug.d); +- 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.d); -+ IRegistry.a(IRegistry.CHUNK_GENERATOR, "flat", ChunkProviderFlat.d); -+ IRegistry.a(IRegistry.CHUNK_GENERATOR, "debug", ChunkProviderDebug.d); ++ 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 - a = IRegistry.CHUNK_GENERATOR.dispatchStable(ChunkGenerator::a, Function.identity()); + CODEC = IRegistry.CHUNK_GENERATOR.dispatchStable(ChunkGenerator::a, Function.identity()); } } diff --git a/nms-patches/net/minecraft/world/level/chunk/ChunkStatus.patch b/nms-patches/net/minecraft/world/level/chunk/ChunkStatus.patch index f4ff21014..fd89fa9e4 100644 --- a/nms-patches/net/minecraft/world/level/chunk/ChunkStatus.patch +++ b/nms-patches/net/minecraft/world/level/chunk/ChunkStatus.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/level/chunk/ChunkStatus.java +++ b/net/minecraft/world/level/chunk/ChunkStatus.java -@@ -38,7 +38,7 @@ +@@ -39,7 +39,7 @@ }); - public static final ChunkStatus STRUCTURE_STARTS = a("structure_starts", ChunkStatus.EMPTY, 0, ChunkStatus.n, ChunkStatus.Type.PROTOCHUNK, (chunkstatus, worldserver, chunkgenerator, definedstructuremanager, lightenginethreaded, function, list, ichunkaccess) -> { + 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.worldDataServer.getGeneratorSettings().shouldGenerateMapFeatures()) { // CraftBukkit - chunkgenerator.createStructures(worldserver.r(), worldserver.getStructureManager(), ichunkaccess, definedstructuremanager, worldserver.getSeed()); ++ if (worldserver.serverLevelData.getGeneratorSettings().shouldGenerateMapFeatures()) { // CraftBukkit + chunkgenerator.createStructures(worldserver.t(), worldserver.getStructureManager(), ichunkaccess, definedstructuremanager, worldserver.getSeed()); } -@@ -101,7 +101,7 @@ +@@ -112,7 +112,7 @@ return (CompletableFuture) function.apply(ichunkaccess); }); - private static final List q = 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 r = (IntList) SystemUtils.a((Object) (new IntArrayList(a().size())), (intarraylist) -> { -+ private static final IntList r = (IntList) SystemUtils.a((new IntArrayList(a().size())), (java.util.function.Consumer) (intarraylist) -> { // CraftBukkit - decompile error + private static final List 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) -> { // CraftBukkit - decompile error int i = 0; for (int j = a().size() - 1; j >= 0; --j) { diff --git a/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch b/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch index e7c43d03e..08fff92d8 100644 --- a/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch +++ b/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch @@ -1,27 +1,9 @@ --- a/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java +++ b/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java -@@ -133,7 +133,7 @@ +@@ -163,6 +163,12 @@ - if (nbttagcompound1.hasKeyOfType("TileTicks", 9)) { - nbttaglist1 = nbttagcompound1.getList("TileTicks", 10); -- function = IRegistry.BLOCK::getKey; -+ function = (block) -> IRegistry.BLOCK.getKey((Block) block); // CraftBukkit - decompile error - registryblocks = IRegistry.BLOCK; - registryblocks.getClass(); - object1 = TickListChunk.a(nbttaglist1, function, registryblocks::get); -@@ -145,7 +145,7 @@ - - if (nbttagcompound1.hasKeyOfType("LiquidTicks", 9)) { - nbttaglist1 = nbttagcompound1.getList("LiquidTicks", 10); -- function = IRegistry.FLUID::getKey; -+ function = (fluid) -> IRegistry.FLUID.getKey((FluidType) fluid); // CraftBukkit - decompile error - registryblocks = IRegistry.FLUID; - registryblocks.getClass(); - object2 = TickListChunk.a(nbttaglist1, function, registryblocks::get); -@@ -155,6 +155,12 @@ - - object = new Chunk(worldserver.getMinecraftWorld(), chunkcoordintpair, biomestorage, chunkconverter, (TickList) object1, (TickList) object2, j, achunksection, (chunk) -> { - loadEntities(nbttagcompound1, chunk); + 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) { @@ -30,28 +12,27 @@ + // CraftBukkit end }); } else { - ProtoChunk protochunk = new ProtoChunk(chunkcoordintpair, chunkconverter, achunksection, protochunkticklist, protochunkticklist1); -@@ -288,8 +294,9 @@ - NBTTagCompound nbttagcompound2; + ProtoChunk protochunk = new ProtoChunk(chunkcoordintpair, chunkconverter, achunksection, protochunkticklist, protochunkticklist1, worldserver); +@@ -294,8 +300,9 @@ + boolean flag = ichunkaccess.s(); - for (int i = -1; i < 17; ++i) { + 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 && chunksection1.getYPosition() >> 4 == i; -+ return chunksection1 != null && chunksection1.getYPosition() >> 4 == finalI; // CraftBukkit - decompile errors - }).findFirst().orElse(Chunk.a); +- 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)); -@@ -344,6 +351,12 @@ - if (ichunkaccess.getChunkStatus().getType() == ChunkStatus.Type.LEVELCHUNK) { - Chunk chunk = (Chunk) ichunkaccess; +@@ -403,6 +410,11 @@ -+ // CraftBukkit start - store chunk persistent data in nbt -+ if (!chunk.persistentDataContainer.isEmpty()) { -+ nbttagcompound1.set("ChunkBukkitValues", chunk.persistentDataContainer.toTagCompound()); -+ } -+ // CraftBukkit end -+ - chunk.d(false); + nbttagcompound1.set("Heightmaps", nbttagcompound3); + nbttagcompound1.set("Structures", a(worldserver, chunkcoordintpair, ichunkaccess.g(), ichunkaccess.w())); ++ // CraftBukkit start - store chunk persistent data in nbt ++ if (ichunkaccess instanceof Chunk && !((Chunk) ichunkaccess).persistentDataContainer.isEmpty()) { ++ nbttagcompound1.set("ChunkBukkitValues", ((Chunk) ichunkaccess).persistentDataContainer.toTagCompound()); ++ } ++ // CraftBukkit end + return nbttagcompound; + } - for (int j = 0; j < chunk.getEntitySlices().length; ++j) { diff --git a/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch b/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch index f4162d365..e6dce93bd 100644 --- a/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch +++ b/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch @@ -14,9 +14,9 @@ + public class IChunkLoader implements AutoCloseable { - private final IOWorker a; + private final IOWorker worker; @@ -27,10 +35,49 @@ - this.a = new IOWorker(file, flag, "chunk"); + this.worker = new IOWorker(file, flag, "chunk"); } - public NBTTagCompound getChunkData(ResourceKey resourcekey, Supplier supplier, NBTTagCompound nbttagcompound) { @@ -64,5 +64,5 @@ + // CraftBukkit end + if (i < 1493) { - nbttagcompound = GameProfileSerializer.a(this.b, DataFixTypes.CHUNK, nbttagcompound, i, 1493); + nbttagcompound = GameProfileSerializer.a(this.fixerUpper, DataFixTypes.CHUNK, nbttagcompound, i, 1493); if (nbttagcompound.getCompound("Level").getBoolean("hasLegacyStructureData")) { diff --git a/nms-patches/net/minecraft/world/level/chunk/storage/RegionFile.patch b/nms-patches/net/minecraft/world/level/chunk/storage/RegionFile.patch index 025901b8e..8bff3c79e 100644 --- a/nms-patches/net/minecraft/world/level/chunk/storage/RegionFile.patch +++ b/nms-patches/net/minecraft/world/level/chunk/storage/RegionFile.patch @@ -5,77 +5,77 @@ package net.minecraft.world.level.chunk.storage; import com.google.common.annotations.VisibleForTesting; -@@ -51,8 +52,8 @@ +@@ -60,8 +61,8 @@ } else { - this.e = path1; - this.h = this.g.asIntBuffer(); -- this.h.limit(1024); -- this.g.position(4096); -+ ((java.nio.Buffer) this.h).limit(1024); // CraftBukkit - decompile error -+ ((java.nio.Buffer) this.g).position(4096); // CraftBukkit - decompile error - this.i = this.g.asIntBuffer(); + this.externalFileDir = path1; + this.offsets = this.header.asIntBuffer(); +- this.offsets.limit(1024); +- this.header.position(4096); ++ ((java.nio.Buffer) this.offsets).limit(1024); // CraftBukkit - decompile error ++ ((java.nio.Buffer) this.header).position(4096); // CraftBukkit - decompile error + this.timestamps = this.header.asIntBuffer(); if (flag) { - this.dataFile = FileChannel.open(path, StandardOpenOption.CREATE, StandardOpenOption.READ, StandardOpenOption.WRITE, StandardOpenOption.DSYNC); -@@ -61,7 +62,7 @@ + this.file = FileChannel.open(path, StandardOpenOption.CREATE, StandardOpenOption.READ, StandardOpenOption.WRITE, StandardOpenOption.DSYNC); +@@ -70,7 +71,7 @@ } - this.freeSectors.a(0, 2); -- this.g.position(0); -+ ((java.nio.Buffer) this.g).position(0); // CraftBukkit - decompile error - int i = this.dataFile.read(this.g, 0L); + this.usedSectors.a(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) { -@@ -116,7 +117,7 @@ +@@ -125,7 +126,7 @@ ByteBuffer bytebuffer = ByteBuffer.allocate(l); - this.dataFile.read(bytebuffer, (long) (j * 4096)); + this.file.read(bytebuffer, (long) (j * 4096)); - bytebuffer.flip(); + ((java.nio.Buffer) bytebuffer).flip(); // CraftBukkit - decompile error if (bytebuffer.remaining() < 5) { RegionFile.LOGGER.error("Chunk {} header is truncated: expected {} but read {}", chunkcoordintpair, l, bytebuffer.remaining()); return null; -@@ -214,7 +215,7 @@ +@@ -227,7 +228,7 @@ try { - this.dataFile.read(bytebuffer, (long) (j * 4096)); + this.file.read(bytebuffer, (long) (j * 4096)); - bytebuffer.flip(); + ((java.nio.Buffer) bytebuffer).flip(); // CraftBukkit - decompile error if (bytebuffer.remaining() != 5) { return false; } else { -@@ -306,7 +307,7 @@ +@@ -330,7 +331,7 @@ bytebuffer.putInt(1); - bytebuffer.put((byte) (this.f.a() | 128)); + bytebuffer.put((byte) (this.version.a() | 128)); - bytebuffer.flip(); + ((java.nio.Buffer) bytebuffer).flip(); // CraftBukkit - decompile error return bytebuffer; } -@@ -316,7 +317,7 @@ - Throwable throwable = null; +@@ -339,7 +340,7 @@ + FileChannel filechannel = FileChannel.open(path1, StandardOpenOption.CREATE, StandardOpenOption.WRITE); try { - bytebuffer.position(5); + ((java.nio.Buffer) bytebuffer).position(5); // CraftBukkit - decompile error filechannel.write(bytebuffer); - } catch (Throwable throwable1) { - throwable = throwable1; -@@ -342,7 +343,7 @@ + } catch (Throwable throwable) { + if (filechannel != null) { +@@ -363,7 +364,7 @@ } - private void c() throws IOException { -- this.g.position(0); -+ ((java.nio.Buffer) this.g).position(0); // CraftBukkit - decompile error - this.dataFile.write(this.g, 0L); + private void d() throws IOException { +- this.header.position(0); ++ ((java.nio.Buffer) this.header).position(0); // CraftBukkit - decompile error + this.file.write(this.header, 0L); } -@@ -378,7 +379,7 @@ +@@ -399,7 +400,7 @@ if (i != j) { - ByteBuffer bytebuffer = RegionFile.c.duplicate(); + ByteBuffer bytebuffer = RegionFile.PADDING_BUFFER.duplicate(); - bytebuffer.position(0); + ((java.nio.Buffer) bytebuffer).position(0); // CraftBukkit - decompile error - this.dataFile.write(bytebuffer, (long) (j - 1)); + this.file.write(bytebuffer, (long) (j - 1)); } diff --git a/nms-patches/net/minecraft/world/level/chunk/storage/RegionFileCache.patch b/nms-patches/net/minecraft/world/level/chunk/storage/RegionFileCache.patch index 4d73d3c09..24b94b5d5 100644 --- a/nms-patches/net/minecraft/world/level/chunk/storage/RegionFileCache.patch +++ b/nms-patches/net/minecraft/world/level/chunk/storage/RegionFileCache.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/world/level/chunk/storage/RegionFileCache.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileCache.java -@@ -25,7 +25,7 @@ - this.c = flag; +@@ -27,7 +27,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()); - RegionFile regionfile = (RegionFile) this.cache.getAndMoveToFirst(i); + RegionFile regionfile = (RegionFile) this.regionCache.getAndMoveToFirst(i); -@@ -41,6 +41,7 @@ - } +@@ -45,6 +45,7 @@ + File file = 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); - File file = new File(this.b, "r." + chunkcoordintpair.getRegionX() + "." + chunkcoordintpair.getRegionZ() + ".mca"); -+ if (existingOnly && !file.exists()) return null; // CraftBukkit - RegionFile regionfile1 = new RegionFile(file, this.b, this.c); - - this.cache.putAndMoveToFirst(i, regionfile1); -@@ -50,7 +51,12 @@ + this.regionCache.putAndMoveToFirst(i, regionfile1); +@@ -54,7 +55,12 @@ @Nullable public NBTTagCompound read(ChunkCoordIntPair chunkcoordintpair) throws IOException { @@ -29,14 +29,14 @@ + } + // CraftBukkit end DataInputStream datainputstream = regionfile.a(chunkcoordintpair); - Throwable throwable = null; -@@ -85,7 +91,7 @@ + NBTTagCompound nbttagcompound; +@@ -94,7 +100,7 @@ } - protected void write(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException { + protected void write(ChunkCoordIntPair chunkcoordintpair, @Nullable NBTTagCompound nbttagcompound) throws IOException { - RegionFile regionfile = this.getFile(chunkcoordintpair); + RegionFile regionfile = this.getFile(chunkcoordintpair, false); // CraftBukkit - DataOutputStream dataoutputstream = regionfile.c(chunkcoordintpair); - Throwable throwable = null; + if (nbttagcompound == null) { + regionfile.d(chunkcoordintpair); diff --git a/nms-patches/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.patch b/nms-patches/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.patch deleted file mode 100644 index e588d593e..000000000 --- a/nms-patches/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- a/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.java -+++ b/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.java -@@ -58,7 +58,7 @@ - return chunkgeneratorabstract.h; - })).apply(instance, instance.stable(ChunkGeneratorAbstract::new)); - }); -- private static final float[] i = (float[]) SystemUtils.a((Object) (new float[13824]), (afloat) -> { -+ private static final float[] i = (float[]) SystemUtils.a((new float[13824]), (afloat) -> { // CraftBukkit - decompile error - for (int i = 0; i < 24; ++i) { - for (int j = 0; j < 24; ++j) { - for (int k = 0; k < 24; ++k) { -@@ -68,7 +68,7 @@ - } - - }); -- private static final float[] j = (float[]) SystemUtils.a((Object) (new float[25]), (afloat) -> { -+ private static final float[] j = (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); -@@ -227,6 +227,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 * ChunkGeneratorAbstract.j[l + 2 + (i1 + 2) * 5] / (f6 + 2.0F); diff --git a/nms-patches/net/minecraft/world/level/levelgen/GeneratorSettings.patch b/nms-patches/net/minecraft/world/level/levelgen/GeneratorSettings.patch index 72b8da69c..0ec7ab64f 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/GeneratorSettings.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/GeneratorSettings.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/GeneratorSettings.java +++ b/net/minecraft/world/level/levelgen/GeneratorSettings.java -@@ -34,9 +34,14 @@ +@@ -35,9 +35,14 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -11,26 +11,44 @@ + public class GeneratorSettings { -- public static final Codec a = RecordCodecBuilder.create((instance) -> { -+ public static final Codec a = RecordCodecBuilder.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.M, Lifecycle.stable(), WorldDimension.a).xmap(WorldDimension::a, Function.identity()).fieldOf("dimensions").forGetter(GeneratorSettings::d), Codec.STRING.optionalFieldOf("legacy_custom_options").stable().forGetter((generatorsettings) -> { - return generatorsettings.g; +- public static final Codec CODEC = RecordCodecBuilder.create((instance) -> { ++ public static final Codec CODEC = RecordCodecBuilder.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 generatorsettings.legacyCustomOptions; })).apply(instance, instance.stable(GeneratorSettings::new)); -@@ -120,7 +125,7 @@ +@@ -121,7 +126,7 @@ public static RegistryMaterials a(RegistryMaterials registrymaterials, Supplier supplier, ChunkGenerator chunkgenerator) { - RegistryMaterials registrymaterials1 = new RegistryMaterials<>(IRegistry.M, Lifecycle.experimental()); + RegistryMaterials 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(); while (iterator.hasNext()) { -@@ -229,7 +234,7 @@ +@@ -129,7 +134,7 @@ + ResourceKey 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 + } + } + +@@ -242,7 +247,7 @@ switch (b0) { case 0: JsonObject jsonobject = !s.isEmpty() ? ChatDeserializer.a(s) : new JsonObject(); - Dynamic dynamic = new Dynamic(JsonOps.INSTANCE, jsonobject); + Dynamic dynamic = new Dynamic(RegistryReadOps.a(JsonOps.INSTANCE, IResourceManager.Empty.INSTANCE, (IRegistryCustom.Dimension) iregistrycustom), jsonobject); // CraftBukkit - SPIGOT-6237 - DataResult dataresult = GeneratorSettingsFlat.a.parse(dynamic); + DataResult dataresult = GeneratorSettingsFlat.CODEC.parse(dynamic); Logger logger = GeneratorSettings.LOGGER; +@@ -278,7 +283,7 @@ + Entry, WorldDimension> entry = (Entry) iterator.next(); + ResourceKey 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/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch b/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch index 4657200b9..6469db56a 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/MobSpawnerPatrol.java +++ b/net/minecraft/world/level/levelgen/MobSpawnerPatrol.java -@@ -118,7 +118,7 @@ +@@ -119,7 +119,7 @@ entitymonsterpatrolling.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); entitymonsterpatrolling.prepare(worldserver, worldserver.getDamageScaler(blockposition), EnumMobSpawn.PATROL, (GroupDataEntity) null, (NBTTagCompound) null); diff --git a/nms-patches/net/minecraft/world/level/levelgen/NoiseSampler.patch b/nms-patches/net/minecraft/world/level/levelgen/NoiseSampler.patch new file mode 100644 index 000000000..9c9d15814 --- /dev/null +++ b/nms-patches/net/minecraft/world/level/levelgen/NoiseSampler.patch @@ -0,0 +1,23 @@ +--- 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/nms-patches/net/minecraft/world/level/levelgen/StructureSettings.patch b/nms-patches/net/minecraft/world/level/levelgen/StructureSettings.patch index faf4e3642..7a339b2bc 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/StructureSettings.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/StructureSettings.patch @@ -6,21 +6,21 @@ import com.google.common.collect.ImmutableMap; @@ -22,14 +23,15 @@ - return structuresettings.d; + return structuresettings.structureConfig; })).apply(instance, StructureSettings::new); }); -- public static final ImmutableMap, StructureSettingsFeature> b = 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_PYRAMID, 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.MONUMENT, new StructureSettingsFeature(32, 5, 10387313)).put(StructureGenerator.ENDCITY, new StructureSettingsFeature(20, 11, 10387313)).put(StructureGenerator.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.FORTRESS, new StructureSettingsFeature(27, 4, 30084232)).put(StructureGenerator.NETHER_FOSSIL, new StructureSettingsFeature(2, 1, 14357921)).build(); +- public static final ImmutableMap, 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(); + // CraftBukkit - decompile error -+ public static final ImmutableMap, StructureSettingsFeature> b = ImmutableMap., 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_PYRAMID, 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.MONUMENT, new StructureSettingsFeature(32, 5, 10387313)).put(StructureGenerator.ENDCITY, new StructureSettingsFeature(20, 11, 10387313)).put(StructureGenerator.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.FORTRESS, new StructureSettingsFeature(27, 4, 30084232)).put(StructureGenerator.NETHER_FOSSIL, new StructureSettingsFeature(2, 1, 14357921)).build(); - public static final StructureSettingsStronghold c; - private final Map, StructureSettingsFeature> d; ++ public static final ImmutableMap, StructureSettingsFeature> DEFAULTS = ImmutableMap., 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 StructureSettingsStronghold DEFAULT_STRONGHOLD; + private final Map, StructureSettingsFeature> structureConfig; @Nullable - private final StructureSettingsStronghold e; + private final StructureSettingsStronghold stronghold; public StructureSettings(Optional optional, Map, StructureSettingsFeature> map) { -- this.e = (StructureSettingsStronghold) optional.orElse((Object) null); -+ this.e = (StructureSettingsStronghold) optional.orElse(null); // CraftBukkit - decompile error - this.d = map; +- this.stronghold = (StructureSettingsStronghold) optional.orElse((Object) null); ++ this.stronghold = (StructureSettingsStronghold) optional.orElse(null); // CraftBukkit - decompile error + this.structureConfig = map; } @@ -53,6 +55,15 @@ @@ -28,10 +28,10 @@ static { + // CraftBukkit - decompile error start -+ c = new StructureSettingsStronghold(32, 3, 128); ++ DEFAULT_STRONGHOLD = new StructureSettingsStronghold(32, 3, 128); + + for (StructureGenerator structuregenerator : IRegistry.STRUCTURE_FEATURE) { -+ if (!StructureSettings.b.containsKey(structuregenerator)) { ++ if (!StructureSettings.DEFAULTS.containsKey(structuregenerator)) { + throw new IllegalStateException("Structure feature without default settings: " + IRegistry.STRUCTURE_FEATURE.getKey(structuregenerator)); + } + } @@ -40,7 +40,7 @@ StructureGenerator structuregenerator; @@ -67,5 +78,7 @@ - } while (StructureSettings.b.containsKey(structuregenerator)); + } while (StructureSettings.DEFAULTS.containsKey(structuregenerator)); throw new IllegalStateException("Structure feature without default settings: " + IRegistry.STRUCTURE_FEATURE.getKey(structuregenerator)); + */ diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch index 1e1da9454..4077b0e69 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch @@ -10,8 +10,8 @@ + public class PersistentStructureLegacy { -- private static final Map a = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { -+ private static final Map a = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error +- private static final Map CURRENT_TO_LEGACY_MAP = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { ++ private static final Map 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"); @@ -19,29 +19,29 @@ hashmap.put("Fortress", "Fortress"); hashmap.put("EndCity", "EndCity"); }); -- private static final Map b = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { -+ private static final Map b = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error +- private static final Map LEGACY_TO_CURRENT_MAP = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { ++ private static final Map 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"); -@@ -236,16 +240,16 @@ +@@ -234,16 +238,16 @@ } } - public static PersistentStructureLegacy a(ResourceKey resourcekey, @Nullable WorldPersistentData worldpersistentdata) { - if (resourcekey == World.OVERWORLD) { + public static PersistentStructureLegacy a(ResourceKey resourcekey, @Nullable WorldPersistentData worldpersistentdata) { // CraftBukkit -+ if (resourcekey == DimensionManager.OVERWORLD) { // 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 { ImmutableList immutablelist; -- if (resourcekey == World.THE_NETHER) { -+ if (resourcekey == DimensionManager.THE_NETHER) { // CraftBukkit +- if (resourcekey == World.NETHER) { ++ if (resourcekey == DimensionManager.NETHER_LOCATION) { // CraftBukkit immutablelist = ImmutableList.of("Fortress"); return new PersistentStructureLegacy(worldpersistentdata, immutablelist, immutablelist); -- } else if (resourcekey == World.THE_END) { -+ } else if (resourcekey == DimensionManager.THE_END) { // CraftBukkit +- } else if (resourcekey == World.END) { ++ } else if (resourcekey == DimensionManager.END_LOCATION) { // CraftBukkit immutablelist = ImmutableList.of("EndCity"); return new PersistentStructureLegacy(worldpersistentdata, immutablelist, immutablelist); } else { diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/WorldGenWitchHut.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/WorldGenWitchHut.patch index 273e8ed4e..85f8a3aea 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/WorldGenWitchHut.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/WorldGenWitchHut.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/level/levelgen/structure/WorldGenWitchHut.java +++ b/net/minecraft/world/level/levelgen/structure/WorldGenWitchHut.java -@@ -106,7 +106,7 @@ +@@ -101,7 +101,7 @@ entitywitch.setPersistent(); - entitywitch.setPositionRotation((double) j + 0.5D, (double) i, (double) k + 0.5D, 0.0F, 0.0F); - entitywitch.prepare(generatoraccessseed, generatoraccessseed.getDamageScaler(new BlockPosition(j, i, k)), EnumMobSpawn.STRUCTURE, (GroupDataEntity) null, (NBTTagCompound) null); + 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 } } -@@ -128,7 +128,7 @@ +@@ -121,7 +121,7 @@ entitycat.setPersistent(); - entitycat.setPositionRotation((double) i + 0.5D, (double) j, (double) k + 0.5D, 0.0F, 0.0F); - entitycat.prepare(worldaccess, worldaccess.getDamageScaler(new BlockPosition(i, j, k)), EnumMobSpawn.STRUCTURE, (GroupDataEntity) null, (NBTTagCompound) null); + 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 } diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch index af20c1943..1a380a21a 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java -@@ -134,7 +134,7 @@ +@@ -147,7 +147,7 @@ } private static List a(List list, List list1, List list2) { - Comparator comparator = Comparator.comparingInt((definedstructure_blockinfo) -> { + Comparator comparator = Comparator.comparingInt((definedstructure_blockinfo) -> { // CraftBukkit - decompile error - return definedstructure_blockinfo.a.getY(); + return definedstructure_blockinfo.pos.getY(); }).thenComparingInt((definedstructure_blockinfo) -> { - return definedstructure_blockinfo.a.getX(); -@@ -154,7 +154,7 @@ + return definedstructure_blockinfo.pos.getX(); +@@ -167,7 +167,7 @@ } private void a(World world, BlockPosition blockposition, BlockPosition blockposition1) { @@ -18,14 +18,14 @@ return !(entity instanceof EntityHuman); }); -@@ -466,11 +466,13 @@ +@@ -471,11 +471,13 @@ } private static Optional a(WorldAccess worldaccess, NBTTagCompound nbttagcompound) { - try { + // CraftBukkit start + // try { - return EntityTypes.a(nbttagcompound, (World) worldaccess.getMinecraftWorld()); + return EntityTypes.a(nbttagcompound, (World) worldaccess.getLevel()); - } catch (Exception exception) { - return Optional.empty(); - } @@ -35,13 +35,13 @@ + // CraftBukkit end } - public BlockPosition a(EnumBlockRotation enumblockrotation) { -@@ -905,7 +907,7 @@ + public BaseBlockPosition a(EnumBlockRotation enumblockrotation) { +@@ -868,7 +870,7 @@ public IBlockData a(int i) { - IBlockData iblockdata = (IBlockData) this.b.fromId(i); + IBlockData iblockdata = (IBlockData) this.ids.fromId(i); -- return iblockdata == null ? DefinedStructure.b.a : iblockdata; -+ return iblockdata == null ? a : iblockdata; // CraftBukkit - decompile error +- return iblockdata == null ? DefinedStructure.b.DEFAULT_BLOCK_STATE : iblockdata; ++ return iblockdata == null ? DEFAULT_BLOCK_STATE : iblockdata; // CraftBukkit - decompile error } public Iterator iterator() { diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureManager.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureManager.patch deleted file mode 100644 index 1c785a261..000000000 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureManager.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureManager.java -+++ b/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureManager.java -@@ -31,7 +31,7 @@ - public class DefinedStructureManager { - - private static final Logger LOGGER = LogManager.getLogger(); -- private final Map b = Maps.newHashMap(); -+ private final Map b = Maps.newConcurrentMap(); // SPIGOT-5287 - private final DataFixer c; - private IResourceManager d; - private final Path e; diff --git a/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch b/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch index 6bb80f3bb..6104a4a95 100644 --- a/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch +++ b/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch @@ -15,8 +15,8 @@ + public abstract class FluidTypeFlowing extends FluidType { - public static final BlockStateBoolean FALLING = BlockProperties.i; -@@ -131,6 +140,15 @@ + public static final BlockStateBoolean FALLING = BlockProperties.FALLING; +@@ -132,6 +141,15 @@ Fluid fluid1 = this.a((IWorldReader) generatoraccess, blockposition1, iblockdata1); if (this.a(generatoraccess, blockposition, iblockdata, EnumDirection.DOWN, blockposition1, iblockdata1, generatoraccess.getFluid(blockposition1), fluid1.getType())) { @@ -32,7 +32,7 @@ this.a(generatoraccess, blockposition1, iblockdata1, EnumDirection.DOWN, fluid1); if (this.a((IWorldReader) generatoraccess, blockposition) >= 3) { this.a(generatoraccess, blockposition, fluid, iblockdata); -@@ -161,6 +179,15 @@ +@@ -162,6 +180,15 @@ IBlockData iblockdata1 = generatoraccess.getType(blockposition1); if (this.a(generatoraccess, blockposition, iblockdata, enumdirection, blockposition1, iblockdata1, generatoraccess.getFluid(blockposition1), fluid1.getType())) { @@ -48,7 +48,7 @@ this.a(generatoraccess, blockposition1, iblockdata1, enumdirection, fluid1); } } -@@ -439,12 +466,23 @@ +@@ -440,12 +467,23 @@ if (fluid1.isEmpty()) { fluid = fluid1; diff --git a/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch b/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch index 368720b54..3137b7f21 100644 --- a/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch +++ b/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/material/FluidTypeLava.java +++ b/net/minecraft/world/level/material/FluidTypeLava.java -@@ -55,6 +55,13 @@ +@@ -85,6 +85,13 @@ if (iblockdata.isAir()) { if (this.a((IWorldReader) world, blockposition1)) { @@ -14,7 +14,7 @@ world.setTypeUpdate(blockposition1, BlockFireAbstract.a((IBlockAccess) world, blockposition1)); return; } -@@ -71,6 +78,14 @@ +@@ -101,6 +108,14 @@ } if (world.isEmpty(blockposition2.up()) && this.b(world, blockposition2)) { @@ -29,7 +29,7 @@ world.setTypeUpdate(blockposition2.up(), BlockFireAbstract.a((IBlockAccess) world, blockposition2)); } } -@@ -160,7 +175,11 @@ +@@ -196,7 +211,11 @@ if (this.a((Tag) TagsFluid.LAVA) && fluid1.a((Tag) TagsFluid.WATER)) { if (iblockdata.getBlock() instanceof BlockFluids) { diff --git a/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch b/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch index 24df2c6c3..caa611ce4 100644 --- a/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch +++ b/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch @@ -11,98 +11,98 @@ + public class BlockPortalShape { - private static final BlockBase.e a = (iblockdata, iblockaccess, blockposition) -> { -@@ -32,6 +37,7 @@ - private BlockPosition position; + private static final int MIN_WIDTH = 2; +@@ -36,6 +41,7 @@ + private BlockPosition bottomLeft; private int height; - private int width; + private final int width; + org.bukkit.craftbukkit.util.BlockStateListPopulator blocks; // CraftBukkit - add field public static Optional a(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { return a(generatoraccess, blockposition, (blockportalshape) -> { -@@ -52,6 +58,7 @@ +@@ -56,6 +62,7 @@ } public BlockPortalShape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { + blocks = new org.bukkit.craftbukkit.util.BlockStateListPopulator(generatoraccess.getMinecraftWorld()); // CraftBukkit - this.b = generatoraccess; - this.c = enumdirection_enumaxis; - this.d = enumdirection_enumaxis == EnumDirection.EnumAxis.X ? EnumDirection.WEST : EnumDirection.SOUTH; -@@ -96,6 +103,7 @@ + this.level = generatoraccess; + this.axis = enumdirection_enumaxis; + this.rightDir = enumdirection_enumaxis == EnumDirection.EnumAxis.X ? EnumDirection.WEST : EnumDirection.SOUTH; +@@ -100,6 +107,7 @@ if (!a(iblockdata)) { - if (BlockPortalShape.a.test(iblockdata, this.b, blockposition_mutableblockposition)) { + if (BlockPortalShape.FRAME.test(iblockdata, this.level, blockposition_mutableblockposition)) { + blocks.setTypeAndData(blockposition_mutableblockposition, iblockdata, 18); // CraftBukkit - lower left / right return i; } break; -@@ -106,6 +114,7 @@ - if (!BlockPortalShape.a.test(iblockdata1, this.b, blockposition_mutableblockposition)) { +@@ -110,6 +118,7 @@ + if (!BlockPortalShape.FRAME.test(iblockdata1, this.level, blockposition_mutableblockposition)) { break; } + blocks.setTypeAndData(blockposition_mutableblockposition, iblockdata1, 18); // CraftBukkit - bottom row } return 0; -@@ -125,6 +134,7 @@ - if (!BlockPortalShape.a.test(this.b.getType(blockposition_mutableblockposition1), this.b, blockposition_mutableblockposition1)) { +@@ -129,6 +138,7 @@ + if (!BlockPortalShape.FRAME.test(this.level.getType(blockposition_mutableblockposition1), this.level, blockposition_mutableblockposition1)) { return false; } -+ blocks.setTypeAndData(blockposition_mutableblockposition1, this.b.getType(blockposition_mutableblockposition1), 18); // CraftBukkit - upper row ++ blocks.setTypeAndData(blockposition_mutableblockposition1, this.level.getType(blockposition_mutableblockposition1), 18); // CraftBukkit - upper row } return true; -@@ -154,6 +164,10 @@ - ++this.e; +@@ -158,6 +168,10 @@ + ++this.numPortalBlocks; } } + // CraftBukkit start - left and right -+ blocks.setTypeAndData(blockposition_mutableblockposition.g(this.position).c(EnumDirection.UP, i).c(this.d, -1), this.b.getType(blockposition_mutableblockposition), 18); -+ blocks.setTypeAndData(blockposition_mutableblockposition.g(this.position).c(EnumDirection.UP, i).c(this.d, this.width), this.b.getType(blockposition_mutableblockposition), 18); ++ 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); + // CraftBukkit end } return 21; -@@ -167,12 +181,28 @@ - return this.position != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; +@@ -171,12 +185,28 @@ + return this.bottomLeft != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; } - public void createPortal() { + // CraftBukkit start - return boolean + public boolean createPortal() { -+ org.bukkit.World bworld = this.b.getMinecraftWorld().getWorld(); ++ org.bukkit.World bworld = this.level.getMinecraftWorld().getWorld(); + + // Copy below for loop - IBlockData iblockdata = (IBlockData) Blocks.NETHER_PORTAL.getBlockData().set(BlockPortal.AXIS, this.c); + IBlockData iblockdata = (IBlockData) Blocks.NETHER_PORTAL.getBlockData().set(BlockPortal.AXIS, this.axis); - BlockPosition.a(this.position, this.position.shift(EnumDirection.UP, this.height - 1).shift(this.d, this.width - 1)).forEach((blockposition) -> { + 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); + }); + + PortalCreateEvent event = new PortalCreateEvent((java.util.List) (java.util.List) blocks.getList(), bworld, null, PortalCreateEvent.CreateReason.FIRE); -+ this.b.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event); ++ this.level.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return false; + } + // CraftBukkit end -+ BlockPosition.a(this.position, this.position.shift(EnumDirection.UP, this.height - 1).shift(this.d, this.width - 1)).forEach((blockposition) -> { - this.b.setTypeAndData(blockposition, iblockdata, 18); ++ 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); }); + return true; // CraftBukkit } public boolean c() { -@@ -209,7 +239,7 @@ +@@ -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 - BlockPosition blockposition = blockutil_rectangle.origin; + BlockPosition blockposition = blockutil_rectangle.minCorner; IBlockData iblockdata = worldserver.getType(blockposition); - EnumDirection.EnumAxis enumdirection_enumaxis1 = (EnumDirection.EnumAxis) iblockdata.get(BlockProperties.E); -@@ -223,6 +253,6 @@ + EnumDirection.EnumAxis enumdirection_enumaxis1 = (EnumDirection.EnumAxis) iblockdata.d(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/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch b/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch index 0132c7f33..fc25c59b9 100644 --- a/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch +++ b/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/portal/PortalTravelAgent.java +++ b/net/minecraft/world/level/portal/PortalTravelAgent.java -@@ -30,13 +30,19 @@ +@@ -43,13 +43,19 @@ } public Optional findPortal(BlockPosition blockposition, boolean flag) { @@ -9,20 +9,20 @@ + } + + public Optional findPortal(BlockPosition blockposition, int i) { - VillagePlace villageplace = this.world.y(); + VillagePlace villageplace = this.level.A(); - int i = flag ? 16 : 128; + // int i = flag ? 16 : 128; + // CraftBukkit end - villageplace.a(this.world, blockposition, i); + villageplace.a(this.level, blockposition, i); Optional optional = villageplace.b((villageplacetype) -> { - return villageplacetype == VillagePlaceType.v; + 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); }).thenComparingInt((villageplacerecord) -> { return villageplacerecord.f().getY(); -@@ -57,6 +63,12 @@ +@@ -70,6 +76,12 @@ } public Optional createPortal(BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { @@ -35,55 +35,55 @@ EnumDirection enumdirection = EnumDirection.a(EnumDirection.EnumAxisDirection.POSITIVE, enumdirection_enumaxis); double d0 = -1.0D; BlockPosition blockposition1 = null; -@@ -65,7 +77,7 @@ - WorldBorder worldborder = this.world.getWorldBorder(); - int i = this.world.getHeight() - 1; +@@ -78,7 +90,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 int j; - -@@ -119,6 +131,7 @@ - + int k; +@@ -133,6 +145,7 @@ int j1; + int k1; -+ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(this.world); // CraftBukkit - Use BlockStateListPopulator ++ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(this.level); // CraftBukkit - Use BlockStateListPopulator if (d0 == -1.0D) { - blockposition1 = (new BlockPosition(blockposition.getX(), MathHelper.clamp(blockposition.getY(), 70, this.world.getHeight() - 10), blockposition.getZ())).immutableCopy(); - EnumDirection enumdirection1 = enumdirection.g(); -@@ -133,7 +146,7 @@ - IBlockData iblockdata = k1 < 0 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData(); + 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(); - blockposition_mutableblockposition.a((BaseBlockPosition) blockposition1, j * enumdirection.getAdjacentX() + j1 * enumdirection1.getAdjacentX(), k1, j * enumdirection.getAdjacentZ() + j1 * enumdirection1.getAdjacentZ()); -- this.world.setTypeUpdate(blockposition_mutableblockposition, iblockdata); + 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 } } } -@@ -143,7 +156,7 @@ - for (j1 = -1; j1 < 4; ++j1) { - if (l1 == -1 || l1 == 2 || j1 == -1 || j1 == 3) { - blockposition_mutableblockposition.a((BaseBlockPosition) blockposition1, l1 * enumdirection.getAdjacentX(), j1, l1 * enumdirection.getAdjacentZ()); -- this.world.setTypeAndData(blockposition_mutableblockposition, Blocks.OBSIDIAN.getBlockData(), 3); +@@ -163,7 +176,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 } } } -@@ -153,10 +166,20 @@ - for (j1 = 0; j1 < 2; ++j1) { +@@ -173,10 +186,20 @@ + for (k1 = 0; k1 < 2; ++k1) { for (j = 0; j < 3; ++j) { - blockposition_mutableblockposition.a((BaseBlockPosition) blockposition1, j1 * enumdirection.getAdjacentX(), j, j1 * enumdirection.getAdjacentZ()); -- this.world.setTypeAndData(blockposition_mutableblockposition, iblockdata1, 18); + 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 } } + // CraftBukkit start -+ org.bukkit.World bworld = this.world.getWorld(); ++ org.bukkit.World bworld = this.level.getWorld(); + org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent((java.util.List) (java.util.List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.NETHER_PAIR); + -+ this.world.getServer().getPluginManager().callEvent(event); ++ this.level.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return Optional.empty(); + } diff --git a/nms-patches/net/minecraft/world/level/portal/ShapeDetectorShape.patch b/nms-patches/net/minecraft/world/level/portal/ShapeDetectorShape.patch index 421f2fdcc..55ca34278 100644 --- a/nms-patches/net/minecraft/world/level/portal/ShapeDetectorShape.patch +++ b/nms-patches/net/minecraft/world/level/portal/ShapeDetectorShape.patch @@ -11,10 +11,10 @@ + public class ShapeDetectorShape { - public final Vec3D position; - public final Vec3D velocity; - public final float yaw; - public final float pitch; + public final Vec3D pos; + public final Vec3D speed; + public final float yRot; + public final float xRot; + // CraftBukkit start + public final WorldServer world; + public final CraftPortalEvent portalEventInfo; @@ -24,6 +24,6 @@ + this.world = world; + this.portalEventInfo = portalEventInfo; + // CraftBukkit end - this.position = vec3d; - this.velocity = vec3d1; - this.yaw = f; + this.pos = vec3d; + this.speed = vec3d1; + this.yRot = f; diff --git a/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch b/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch index 103492458..1d7afff60 100644 --- a/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch +++ b/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch @@ -1,12 +1,13 @@ --- a/net/minecraft/world/level/saveddata/maps/WorldMap.java +++ b/net/minecraft/world/level/saveddata/maps/WorldMap.java -@@ -31,6 +31,15 @@ +@@ -32,6 +32,16 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start +import java.util.UUID; + ++import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.map.CraftMapView; @@ -16,45 +17,46 @@ public class WorldMap extends PersistentBase { private static final Logger LOGGER = LogManager.getLogger(); -@@ -48,8 +57,18 @@ - public final Map decorations = Maps.newLinkedHashMap(); - private final Map n = Maps.newHashMap(); +@@ -54,6 +64,13 @@ + private final Map frameMarkers = Maps.newHashMap(); + private int trackedDecorationCount; + // CraftBukkit start + public final CraftMapView mapView; + private CraftServer server; + private UUID uniqueId = null; ++ public String id; + // CraftBukkit end + - public WorldMap(String s) { - super(s); + private WorldMap(int i, int j, byte b0, boolean flag, boolean flag1, boolean flag2, ResourceKey resourcekey) { + this.scale = b0; + this.x = i; +@@ -63,6 +80,10 @@ + this.unlimitedTracking = flag1; + this.locked = flag2; + this.b(); + // CraftBukkit start + mapView = new CraftMapView(this); + server = (CraftServer) org.bukkit.Bukkit.getServer(); + // CraftBukkit end } - public void a(int i, int j, int k, boolean flag, boolean flag1, ResourceKey resourcekey) { -@@ -72,12 +91,30 @@ - - @Override - public void a(NBTTagCompound nbttagcompound) { -- DataResult dataresult = DimensionManager.a(new Dynamic(DynamicOpsNBT.a, nbttagcompound.get("dimension"))); -+ DataResult> dataresult = DimensionManager.a(new Dynamic(DynamicOpsNBT.a, nbttagcompound.get("dimension"))); // CraftBukkit - decompile error + public static WorldMap a(double d0, double d1, byte b0, boolean flag, boolean flag1, ResourceKey resourcekey) { +@@ -84,8 +105,26 @@ Logger logger = WorldMap.LOGGER; - logger.getClass(); -- this.map = (ResourceKey) dataresult.resultOrPartial(logger::error).orElseThrow(() -> { + Objects.requireNonNull(logger); +- ResourceKey resourcekey = (ResourceKey) dataresult.resultOrPartial(logger::error).orElseThrow(() -> { - return new IllegalArgumentException("Invalid map dimension: " + nbttagcompound.get("dimension")); + // CraftBukkit start -+ this.map = (ResourceKey) dataresult.resultOrPartial(logger::error).orElseGet(() -> { ++ ResourceKey resourcekey = (ResourceKey) dataresult.resultOrPartial(logger::error).orElseGet(() -> { + long least = nbttagcompound.getLong("UUIDLeast"); + long most = nbttagcompound.getLong("UUIDMost"); + + if (least != 0L && most != 0L) { -+ this.uniqueId = new UUID(most, least); ++ UUID uniqueId = new UUID(most, least); + -+ CraftWorld world = (CraftWorld) server.getWorld(this.uniqueId); ++ CraftWorld world = (CraftWorld) Bukkit.getWorld(uniqueId); + // Check if the stored world details are correct. + if (world == null) { + /* All Maps which do not have their valid world loaded are set to a dimension which hopefully won't be reached. @@ -67,17 +69,17 @@ + throw new IllegalArgumentException("Invalid map dimension: " + nbttagcompound.get("dimension")); + // CraftBukkit end }); - this.centerX = nbttagcompound.getInt("xCenter"); - this.centerZ = nbttagcompound.getInt("zCenter"); -@@ -112,13 +149,32 @@ + int i = nbttagcompound.getInt("xCenter"); + int j = nbttagcompound.getInt("zCenter"); +@@ -123,13 +162,32 @@ @Override - public NBTTagCompound b(NBTTagCompound nbttagcompound) { -- DataResult dataresult = MinecraftKey.a.encodeStart(DynamicOpsNBT.a, this.map.a()); -+ DataResult dataresult = MinecraftKey.a.encodeStart(DynamicOpsNBT.a, this.map.a()); // CraftBukkit - decompile error + public NBTTagCompound a(NBTTagCompound nbttagcompound) { +- DataResult dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.dimension.a()); ++ DataResult dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.dimension.a()); // CraftBukkit - decompile error Logger logger = WorldMap.LOGGER; - logger.getClass(); + Objects.requireNonNull(logger); dataresult.resultOrPartial(logger::error).ifPresent((nbtbase) -> { nbttagcompound.set("dimension", nbtbase); }); @@ -86,7 +88,7 @@ + if (this.uniqueId == null) { + for (org.bukkit.World world : server.getWorlds()) { + CraftWorld cWorld = (CraftWorld) world; -+ if (cWorld.getHandle().getDimensionKey() == this.map) { ++ if (cWorld.getHandle().getDimensionKey() == this.dimension) { + this.uniqueId = cWorld.getUID(); + break; + } @@ -100,34 +102,57 @@ + } + } + // CraftBukkit end - nbttagcompound.setInt("xCenter", this.centerX); - nbttagcompound.setInt("zCenter", this.centerZ); + nbttagcompound.setInt("xCenter", this.x); + nbttagcompound.setInt("zCenter", this.z); nbttagcompound.setByte("scale", this.scale); -@@ -409,12 +465,25 @@ - - @Nullable - public Packet a(ItemStack itemstack) { -+ // CraftBukkit start -+ org.bukkit.craftbukkit.map.RenderData render = WorldMap.this.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) this.trackee.getBukkitEntity()); // CraftBukkit -+ -+ java.util.Collection icons = new java.util.ArrayList(); -+ -+ 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()))); -+ } -+ } -+ - if (this.d) { - this.d = false; -- return new PacketPlayOutMap(ItemWorldMap.d(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.locked, WorldMap.this.decorations.values(), WorldMap.this.colors, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f); -+ return new PacketPlayOutMap(ItemWorldMap.d(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.locked, icons, render.buffer, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f); - } else { -- return this.i++ % 5 == 0 ? new PacketPlayOutMap(ItemWorldMap.d(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.locked, WorldMap.this.decorations.values(), WorldMap.this.colors, 0, 0, 0, 0) : null; -+ return this.i++ % 5 == 0 ? new PacketPlayOutMap(ItemWorldMap.d(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.locked, icons, render.buffer, 0, 0, 0, 0) : null; - } -+ // CraftBukkit end +@@ -504,7 +562,7 @@ + this.player = entityhuman; } - public void a(int i, int j) { +- private WorldMap.b a() { ++ private WorldMap.b a(byte[] buffer) { // CraftBukkit + int i = this.minDirtyX; + int j = this.minDirtyY; + int k = this.maxDirtyX + 1 - this.minDirtyX; +@@ -513,7 +571,7 @@ + + for (int i1 = 0; i1 < k; ++i1) { + for (int j1 = 0; j1 < l; ++j1) { +- abyte[i1 + j1 * k] = WorldMap.this.colors[i + i1 + (j + j1) * 128]; ++ abyte[i1 + j1 * k] = buffer[i + i1 + (j + j1) * 128]; // CraftBukkit + } + } + +@@ -523,19 +581,29 @@ + @Nullable + Packet a(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 + } else { + worldmap_b = null; + } + + Collection collection; + +- if (this.dirtyDecorations && this.tick++ % 5 == 0) { ++ if ((true || this.dirtyDecorations) && this.tick++ % 5 == 0) { // CraftBukkit - custom maps don't update this yet + this.dirtyDecorations = false; +- collection = WorldMap.this.decorations.values(); ++ // CraftBukkit start ++ java.util.Collection icons = new java.util.ArrayList(); ++ ++ 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()))); ++ } ++ } ++ collection = icons; ++ // CraftBukkit end + } else { + collection = null; + } diff --git a/nms-patches/net/minecraft/world/level/storage/Convertable.patch b/nms-patches/net/minecraft/world/level/storage/Convertable.patch index dd47e5519..48a2d3fa1 100644 --- a/nms-patches/net/minecraft/world/level/storage/Convertable.patch +++ b/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 -@@ -47,6 +47,10 @@ +@@ -60,6 +60,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -10,34 +10,40 @@ + public class Convertable { - private static final Logger LOGGER = LogManager.getLogger(); -@@ -96,21 +100,21 @@ + static final Logger LOGGER = LogManager.getLogger(); +@@ -105,26 +109,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) logger::error)).orElseGet(() -> { // CraftBukkit - decompile error + DataResult dataresult1 = RegistryLookupCodec.a(IRegistry.DIMENSION_TYPE_REGISTRY).codec().parse(dynamic2); Logger logger1 = Convertable.LOGGER; - logger1.getClass(); + Objects.requireNonNull(logger1); - IRegistry iregistry = (IRegistry) dataresult1.resultOrPartial(SystemUtils.a("Dimension type registry: ", logger1::error)).orElseThrow(() -> { -+ IRegistry iregistry = (IRegistry) ((DataResult>) dataresult1).resultOrPartial(SystemUtils.a("Dimension type registry: ", logger1::error)).orElseThrow(() -> { // CraftBukkit - decompile error ++ IRegistry iregistry = (IRegistry) ((DataResult>) dataresult1).resultOrPartial(SystemUtils.a("Dimension type registry: ", (java.util.function.Consumer) logger1::error)).orElseThrow(() -> { // CraftBukkit - decompile error return new IllegalStateException("Failed to get dimension registry"); }); - dataresult1 = RegistryLookupCodec.a(IRegistry.ay).codec().parse(dynamic2); + dataresult1 = RegistryLookupCodec.a(IRegistry.BIOME_REGISTRY).codec().parse(dynamic2); logger1 = Convertable.LOGGER; - logger1.getClass(); + Objects.requireNonNull(logger1); - IRegistry iregistry1 = (IRegistry) dataresult1.resultOrPartial(SystemUtils.a("Biome registry: ", logger1::error)).orElseThrow(() -> { -+ IRegistry iregistry1 = (IRegistry) ((DataResult>) dataresult1).resultOrPartial(SystemUtils.a("Biome registry: ", logger1::error)).orElseThrow(() -> { // CraftBukkit - decompile error ++ IRegistry iregistry1 = (IRegistry) ((DataResult>) dataresult1).resultOrPartial(SystemUtils.a("Biome registry: ", (java.util.function.Consumer) logger1::error)).orElseThrow(() -> { // CraftBukkit - decompile error return new IllegalStateException("Failed to get biome registry"); }); - dataresult1 = RegistryLookupCodec.a(IRegistry.ar).codec().parse(dynamic2); + dataresult1 = RegistryLookupCodec.a(IRegistry.NOISE_GENERATOR_SETTINGS_REGISTRY).codec().parse(dynamic2); logger1 = Convertable.LOGGER; - logger1.getClass(); + Objects.requireNonNull(logger1); - IRegistry iregistry2 = (IRegistry) dataresult1.resultOrPartial(SystemUtils.a("Noise settings registry: ", logger1::error)).orElseThrow(() -> { -+ IRegistry iregistry2 = (IRegistry) ((DataResult>) dataresult1).resultOrPartial(SystemUtils.a("Noise settings registry: ", logger1::error)).orElseThrow(() -> { // CraftBukkit - decompile error ++ IRegistry iregistry2 = (IRegistry) ((DataResult>) dataresult1).resultOrPartial(SystemUtils.a("Noise settings registry: ", (java.util.function.Consumer) logger1::error)).orElseThrow(() -> { // CraftBukkit - decompile error return new IllegalStateException("Failed to get noise settings registry"); }); -@@ -218,9 +222,23 @@ - }; +@@ -294,9 +298,23 @@ + return this.backupDir; } - public Convertable.ConversionSession c(String s) throws IOException { @@ -50,9 +56,9 @@ + public static File getFolder(File file, ResourceKey dimensionType) { + if (dimensionType == WorldDimension.OVERWORLD) { + return file; -+ } else if (dimensionType == WorldDimension.THE_NETHER) { ++ } else if (dimensionType == WorldDimension.NETHER) { + return new File(file, "DIM-1"); -+ } else if (dimensionType == WorldDimension.THE_END) { ++ } else if (dimensionType == WorldDimension.END) { + return new File(file, "DIM1"); + } else { + return new File(file, "dimensions/" + dimensionType.a().getNamespace() + "/" + dimensionType.a().getKey()); @@ -62,10 +68,10 @@ public class ConversionSession implements AutoCloseable { -@@ -228,8 +246,12 @@ - public final Path folder; - private final String levelName; - private final Map e = Maps.newHashMap(); +@@ -304,8 +322,12 @@ + public final Path levelPath; + private final String levelId; + private final Map resources = Maps.newHashMap(); + // CraftBukkit start + private final ResourceKey dimensionType; @@ -73,15 +79,15 @@ + public ConversionSession(String s, ResourceKey dimensionType) throws IOException { + this.dimensionType = dimensionType; + // CraftBukkit end - this.levelName = s; - this.folder = Convertable.this.universe.resolve(s); - this.lock = SessionLock.a(this.folder); -@@ -246,7 +268,7 @@ + this.levelId = s; + this.levelPath = Convertable.this.baseDir.resolve(s); + this.lock = SessionLock.a(this.levelPath); +@@ -322,7 +344,7 @@ } public File a(ResourceKey resourcekey) { -- return DimensionManager.a(resourcekey, this.folder.toFile()); -+ return getFolder(this.folder.toFile(), this.dimensionType); // CraftBukkit +- return DimensionManager.a(resourcekey, this.levelPath.toFile()); ++ return getFolder(this.levelPath.toFile(), this.dimensionType); // CraftBukkit } private void checkSession() { diff --git a/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch b/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch index b371b3ff5..683169734 100644 --- a/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch +++ b/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/WorldDataServer.java +++ b/net/minecraft/world/level/storage/WorldDataServer.java -@@ -38,10 +38,19 @@ +@@ -40,6 +40,15 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -16,47 +16,56 @@ public class WorldDataServer implements IWorldDataServer, SaveData { private static final Logger LOGGER = LogManager.getLogger(); -- private WorldSettings b; -+ public WorldSettings b; - private final GeneratorSettings c; - private final Lifecycle d; - private int e; -@@ -75,6 +84,7 @@ - private final Set C; - private boolean D; - private final CustomFunctionCallbackTimerQueue E; +@@ -78,6 +87,7 @@ + private final Set knownServerBrands; + private boolean wasModded; + private final CustomFunctionCallbackTimerQueue scheduledEvents; + public WorldServer world; // CraftBukkit - private WorldDataServer(@Nullable DataFixer datafixer, int i, @Nullable NBTTagCompound nbttagcompound, boolean flag, int j, int k, int l, float f, long i1, long j1, int k1, int l1, int i2, boolean flag1, int j2, boolean flag2, boolean flag3, boolean flag4, WorldBorder.c worldborder_c, int k2, int l2, @Nullable UUID uuid, LinkedHashSet linkedhashset, CustomFunctionCallbackTimerQueue customfunctioncallbacktimerqueue, @Nullable NBTTagCompound nbttagcompound1, NBTTagCompound nbttagcompound2, WorldSettings worldsettings, GeneratorSettings generatorsettings, Lifecycle lifecycle) { - this.k = datafixer; -@@ -118,7 +128,8 @@ + private WorldDataServer(@Nullable DataFixer datafixer, int i, @Nullable NBTTagCompound nbttagcompound, boolean flag, int j, int k, int l, float f, long i1, long j1, int k1, int l1, int i2, boolean flag1, int j2, boolean flag2, boolean flag3, boolean flag4, WorldBorder.c worldborder_c, int k2, int l2, @Nullable UUID uuid, Set set, CustomFunctionCallbackTimerQueue customfunctioncallbacktimerqueue, @Nullable NBTTagCompound nbttagcompound1, NBTTagCompound nbttagcompound2, WorldSettings worldsettings, GeneratorSettings generatorsettings, Lifecycle lifecycle) { + this.fixerUpper = datafixer; +@@ -121,7 +131,8 @@ 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.c), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(MinecraftSerializableUUID.a).result().orElse((Object) null), (LinkedHashSet) 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.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) -> { + // 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.c), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(MinecraftSerializableUUID.a).result().orElse(null), (LinkedHashSet) 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.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()); - }).collect(Collectors.toCollection(Sets::newLinkedHashSet)), new CustomFunctionCallbackTimerQueue<>(CustomFunctionCallbackTimers.a, dynamic.get("ScheduledEvents").asStream()), (NBTTagCompound) dynamic.get("CustomBossEvents").orElseEmptyMap().getValue(), nbttagcompound1, worldsettings, generatorsettings, lifecycle); + }).collect(Collectors.toCollection(Sets::newLinkedHashSet)), new CustomFunctionCallbackTimerQueue<>(CustomFunctionCallbackTimers.SERVER_CALLBACKS, dynamic.get("ScheduledEvents").asStream()), (NBTTagCompound) dynamic.get("CustomBossEvents").orElseEmptyMap().getValue(), nbttagcompound1, worldsettings, generatorsettings, lifecycle); } -@@ -150,7 +161,7 @@ +@@ -141,7 +152,7 @@ + + private void a(IRegistryCustom iregistrycustom, NBTTagCompound nbttagcompound, @Nullable NBTTagCompound nbttagcompound1) { + NBTTagList nbttaglist = new NBTTagList(); +- Stream stream = this.knownServerBrands.stream().map(NBTTagString::a); ++ Stream stream = this.knownServerBrands.stream().map(NBTTagString::a); // 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 registrywriteops = RegistryWriteOps.a(DynamicOpsNBT.a, iregistrycustom); -- DataResult dataresult = GeneratorSettings.a.encodeStart(registrywriteops, this.c); -+ DataResult dataresult = GeneratorSettings.a.encodeStart(registrywriteops, this.c); // CraftBukkit - decompile error + RegistryWriteOps registrywriteops = RegistryWriteOps.a(DynamicOpsNBT.INSTANCE, iregistrycustom); +- DataResult dataresult = GeneratorSettings.CODEC.encodeStart(registrywriteops, this.worldGenSettings); ++ DataResult dataresult = GeneratorSettings.CODEC.encodeStart(registrywriteops, this.worldGenSettings); // CraftBukkit - decompile error Logger logger = WorldDataServer.LOGGER; - logger.getClass(); -@@ -198,6 +209,7 @@ - nbttagcompound.a("WanderingTraderId", this.B); + Objects.requireNonNull(logger); +- dataresult.resultOrPartial(SystemUtils.a("WorldGenSettings: ", logger::error)).ifPresent((nbtbase) -> { ++ dataresult.resultOrPartial(SystemUtils.a("WorldGenSettings: ", (java.util.function.Consumer) 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); } + nbttagcompound.setString("Bukkit.Version", Bukkit.getName() + "/" + Bukkit.getVersion() + "/" + Bukkit.getBukkitVersion()); // CraftBukkit } @Override -@@ -315,6 +327,20 @@ +@@ -320,6 +332,20 @@ @Override public void setThundering(boolean flag) { @@ -77,7 +86,7 @@ this.thundering = flag; } -@@ -335,6 +361,20 @@ +@@ -340,6 +366,20 @@ @Override public void setStorm(boolean flag) { @@ -98,28 +107,28 @@ this.raining = flag; } -@@ -401,6 +441,12 @@ +@@ -406,6 +446,12 @@ @Override public void setDifficulty(EnumDifficulty enumdifficulty) { - this.b = this.b.a(enumdifficulty); + this.settings = this.settings.a(enumdifficulty); + // CraftBukkit start + PacketPlayOutServerDifficulty packet = new PacketPlayOutServerDifficulty(this.getDifficulty(), this.isDifficultyLocked()); + for (EntityPlayer player : (java.util.List) (java.util.List) world.getPlayers()) { -+ player.playerConnection.sendPacket(packet); ++ player.connection.sendPacket(packet); + } + // CraftBukkit end } @Override -@@ -505,4 +551,12 @@ - public IWorldDataServer H() { - return this; +@@ -526,4 +572,12 @@ + public WorldSettings I() { + return this.settings.h(); } + + // CraftBukkit start - Check if the name stored in NBT is the correct one + public void checkName(String name) { -+ if (!this.b.levelName.equals(name)) { -+ this.b.levelName = name; ++ if (!this.settings.levelName.equals(name)) { ++ this.settings.levelName = name; + } + } + // CraftBukkit end diff --git a/nms-patches/net/minecraft/world/level/storage/WorldNBTStorage.patch b/nms-patches/net/minecraft/world/level/storage/WorldNBTStorage.patch index a25c07502..500b7b512 100644 --- a/nms-patches/net/minecraft/world/level/storage/WorldNBTStorage.patch +++ b/nms-patches/net/minecraft/world/level/storage/WorldNBTStorage.patch @@ -30,7 +30,7 @@ + // CraftBukkit end int i = nbttagcompound.hasKeyOfType("DataVersion", 3) ? nbttagcompound.getInt("DataVersion") : -1; - entityhuman.load(GameProfileSerializer.a(this.a, DataFixTypes.PLAYER, nbttagcompound, i)); + entityhuman.load(GameProfileSerializer.a(this.fixerUpper, DataFixTypes.PLAYER, nbttagcompound, i)); @@ -63,6 +80,22 @@ return nbttagcompound; } diff --git a/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch b/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch index 7cce3f727..ba3dfe6ae 100644 --- a/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch +++ b/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/loot/LootTable.java +++ b/net/minecraft/world/level/storage/loot/LootTable.java -@@ -29,6 +29,13 @@ +@@ -30,6 +30,13 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -13,8 +13,8 @@ + public class LootTable { - private static final Logger LOGGER = LogManager.getLogger(); -@@ -113,8 +120,21 @@ + static final Logger LOGGER = LogManager.getLogger(); +@@ -115,8 +122,21 @@ } public void fillInventory(IInventory iinventory, LootTableInfo loottableinfo) { diff --git a/nms-patches/net/minecraft/world/level/storage/loot/LootTableRegistry.patch b/nms-patches/net/minecraft/world/level/storage/loot/LootTableRegistry.patch index 91c6954ef..b362ab0e8 100644 --- a/nms-patches/net/minecraft/world/level/storage/loot/LootTableRegistry.patch +++ b/nms-patches/net/minecraft/world/level/storage/loot/LootTableRegistry.patch @@ -1,29 +1,29 @@ --- a/net/minecraft/world/level/storage/loot/LootTableRegistry.java +++ b/net/minecraft/world/level/storage/loot/LootTableRegistry.java -@@ -21,6 +21,7 @@ +@@ -22,6 +22,7 @@ private static final Logger LOGGER = LogManager.getLogger(); - private static final Gson b = LootSerialization.c().create(); - private Map keyToLootTable = ImmutableMap.of(); + private static final Gson GSON = LootSerialization.c().create(); + private Map tables = ImmutableMap.of(); + public Map lootTableToKey = ImmutableMap.of(); // CraftBukkit - private final LootPredicateManager d; + private final LootPredicateManager predicateManager; public LootTableRegistry(LootPredicateManager lootpredicatemanager) { -@@ -56,7 +57,7 @@ - LootPredicateManager lootpredicatemanager = this.d; +@@ -57,7 +58,7 @@ + LootPredicateManager lootpredicatemanager = this.predicateManager; - this.d.getClass(); + Objects.requireNonNull(this.predicateManager); - Function function = lootpredicatemanager::a; + Function function = lootpredicatemanager::a; // CraftBukkit - decompile error - immutablemap.getClass(); + Objects.requireNonNull(immutablemap); LootCollector lootcollector = new LootCollector(lootcontextparameterset, function, immutablemap::get); -@@ -68,6 +69,11 @@ - LootTableRegistry.LOGGER.warn("Found validation problem in " + s + ": " + s1); +@@ -69,6 +70,11 @@ + LootTableRegistry.LOGGER.warn("Found validation problem in {}: {}", s, s1); }); - this.keyToLootTable = immutablemap; + this.tables = immutablemap; + // CraftBukkit start - build a reversed registry map + ImmutableMap.Builder lootTableToKeyBuilder = ImmutableMap.builder(); -+ this.keyToLootTable.forEach((lootTable, key) -> lootTableToKeyBuilder.put(key, lootTable)); ++ this.tables.forEach((lootTable, key) -> lootTableToKeyBuilder.put(key, lootTable)); + this.lootTableToKey = lootTableToKeyBuilder.build(); + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/level/storage/loot/entries/LootEntryAbstract.patch b/nms-patches/net/minecraft/world/level/storage/loot/entries/LootEntryAbstract.patch deleted file mode 100644 index 1504e2f12..000000000 --- a/nms-patches/net/minecraft/world/level/storage/loot/entries/LootEntryAbstract.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/world/level/storage/loot/entries/LootEntryAbstract.java -+++ b/net/minecraft/world/level/storage/loot/entries/LootEntryAbstract.java -@@ -41,7 +41,16 @@ - - public Serializer() {} - -- public final void serializeType(JsonObject jsonobject, T t0, JsonSerializationContext jsonserializationcontext) {} -+ // CraftBukkit start -+ @Override -+ public final void a(JsonObject jsonobject, T t0, JsonSerializationContext jsonserializationcontext) { -+ if (!org.apache.commons.lang3.ArrayUtils.isEmpty(t0.d)) { -+ jsonobject.add("conditions", jsonserializationcontext.serialize(t0.d)); -+ } -+ -+ this.serializeType(jsonobject, t0, jsonserializationcontext); -+ } -+ // CraftBukkit end - - @Override - public final T a(JsonObject jsonobject, JsonDeserializationContext jsondeserializationcontext) { diff --git a/nms-patches/net/minecraft/world/level/storage/loot/functions/LootEnchantFunction.patch b/nms-patches/net/minecraft/world/level/storage/loot/functions/LootEnchantFunction.patch index fcd3d70ac..fc43056ef 100644 --- a/nms-patches/net/minecraft/world/level/storage/loot/functions/LootEnchantFunction.patch +++ b/nms-patches/net/minecraft/world/level/storage/loot/functions/LootEnchantFunction.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/loot/functions/LootEnchantFunction.java +++ b/net/minecraft/world/level/storage/loot/functions/LootEnchantFunction.java -@@ -47,8 +47,13 @@ +@@ -49,8 +49,13 @@ if (entity instanceof EntityLiving) { int i = EnchantmentManager.g((EntityLiving) entity); @@ -15,12 +15,12 @@ return itemstack; } -@@ -72,7 +77,7 @@ +@@ -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 - jsonobject.add("count", jsonserializationcontext.serialize(lootenchantfunction.a)); + jsonobject.add("count", jsonserializationcontext.serialize(lootenchantfunction.value)); if (lootenchantfunction.c()) { - jsonobject.add("limit", jsonserializationcontext.serialize(lootenchantfunction.b)); + jsonobject.add("limit", jsonserializationcontext.serialize(lootenchantfunction.limit)); diff --git a/nms-patches/net/minecraft/world/level/storage/loot/parameters/LootContextParameters.patch b/nms-patches/net/minecraft/world/level/storage/loot/parameters/LootContextParameters.patch index 0213d1e80..7bc1ed20a 100644 --- a/nms-patches/net/minecraft/world/level/storage/loot/parameters/LootContextParameters.patch +++ b/nms-patches/net/minecraft/world/level/storage/loot/parameters/LootContextParameters.patch @@ -6,5 +6,5 @@ public static final LootContextParameter EXPLOSION_RADIUS = a("explosion_radius"); + public static final LootContextParameter LOOTING_MOD = new LootContextParameter<>(new MinecraftKey("bukkit:looting_mod")); // CraftBukkit - private static LootContextParameter a(String s) { - return new LootContextParameter<>(new MinecraftKey(s)); + public LootContextParameters() {} + diff --git a/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.patch b/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.patch index 272906283..958b64d0c 100644 --- a/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.patch +++ b/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.patch @@ -10,5 +10,5 @@ + } + // CraftBukkit end - return loottableinfo.a().nextFloat() < this.a + (float) i * this.b; + return loottableinfo.a().nextFloat() < this.percent + (float) i * this.lootingMultiplier; } diff --git a/pom.xml b/pom.xml index 414afe09f..dd10ea68f 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.bukkit craftbukkit jar - 1.16.5-R0.1-SNAPSHOT + 1.17-R0.1-SNAPSHOT CraftBukkit https://www.spigotmc.org/ @@ -13,8 +13,7 @@ UTF-8 unknown git - 1.16.5 - 1_16_R3 + 1_17_R1 1.8 1.8 @@ -29,7 +28,7 @@ org.spigotmc minecraft-server - ${minecraft.version}-SNAPSHOT + ${project.version} compile @@ -41,7 +40,7 @@ org.apache.logging.log4j log4j-iostreams - 2.8.1 + 2.14.1 compile @@ -86,28 +85,15 @@ org.apache.maven.resolver maven-resolver-connector-basic - 1.6.2 + 1.7.0 runtime org.apache.maven.resolver maven-resolver-transport-http - 1.6.2 + 1.7.0 runtime - - org.apache.logging.log4j - log4j-slf4j-impl - 2.8.1 - runtime - - - - org.apache.logging.log4j - log4j-api - - - junit @@ -142,6 +128,19 @@ + + org.apache.maven.plugins + maven-clean-plugin + 3.1.0 + + + initialize + + clean + + + + org.apache.maven.plugins maven-jar-plugin @@ -159,6 +158,7 @@ Bukkit ${api.version} Bukkit Team + true @@ -186,7 +186,19 @@ org.apache.maven.plugins maven-shade-plugin - 3.2.3 + 3.2.4 + + + org.ow2.asm + asm + 9.1 + + + org.ow2.asm + asm-commons + 9.1 + + package @@ -270,16 +282,6 @@ org.bukkit.craftbukkit.Main* - - com/mojang/math/(.+/)*(.*) - net/minecraft/server/v${minecraft_version}/$2 - true - - - net/minecraft/(.+/)*(.*) - net/minecraft/server/v${minecraft_version}/$2 - true - @@ -290,6 +292,24 @@ + + net.md-5 + specialsource-maven-plugin + 1.2.2 + + + package + + remap + + remap-fields + + org.spigotmc:minecraft-server:${project.version}:csrg:maps-spigot-fields + true + + + + org.apache.maven.plugins maven-compiler-plugin @@ -367,7 +387,7 @@ org.codehaus.mojo animal-sniffer-maven-plugin - 1.19 + 1.20 process-classes @@ -387,5 +407,44 @@ + + remapped + + + + net.md-5 + specialsource-maven-plugin + + + package + + remap + + remap-obf + + org.spigotmc:minecraft-server:${project.version}:csrg:maps-spigot + true + true + remapped-obf + + + + package + + remap + + remap-mojang + + ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar + org.spigotmc:minecraft-server:${project.version}:txt:maps-mojang + true + remapped-mojang + + + + + + + diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index 7c3148490..19a8d2ef9 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -19,13 +19,16 @@ 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.levelgen.HeightMap; import net.minecraft.world.level.levelgen.SeededRandom; import net.minecraft.world.level.lighting.LightEngine; import org.bukkit.Chunk; import org.bukkit.ChunkSnapshot; +import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockState; @@ -48,7 +51,7 @@ public class CraftChunk implements Chunk { public CraftChunk(net.minecraft.world.level.chunk.Chunk chunk) { this.weakChunk = new WeakReference(chunk); - worldServer = (WorldServer) getHandle().world; + worldServer = (WorldServer) getHandle().level; x = getHandle().getPos().x; z = getHandle().getPos().z; } @@ -95,7 +98,7 @@ public class CraftChunk implements Chunk { @Override public Block getBlock(int x, int y, int z) { - validateChunkCoordinates(x, y, z); + validateChunkCoordinates(getHandle().getMinBuildHeight(), getHandle().getMaxBuildHeight(), x, y, z); return new CraftBlock(worldServer, new BlockPosition((this.x << 4) | x, y, (this.z << 4) | z)); } @@ -105,27 +108,12 @@ public class CraftChunk implements Chunk { if (!isLoaded()) { getWorld().getChunkAt(x, z); // Transient load for this tick } - int count = 0, index = 0; - net.minecraft.world.level.chunk.Chunk chunk = getHandle(); - for (int i = 0; i < 16; i++) { - count += chunk.entitySlices[i].size(); - } - - Entity[] entities = new Entity[count]; - - for (int i = 0; i < 16; i++) { - - for (Object obj : chunk.entitySlices[i].toArray()) { - if (!(obj instanceof net.minecraft.world.entity.Entity)) { - continue; - } - - entities[index++] = ((net.minecraft.world.entity.Entity) obj).getBukkitEntity(); - } - } - - return entities; + Location location = new Location(null, 0, 0, 0); + return getWorld().getEntities().stream().filter((entity) -> { + entity.getLocation(location); + return location.getBlockX() >> 4 == this.x && location.getBlockZ() >> 4 == this.z; + }).toArray(Entity[]::new); } @Override @@ -136,9 +124,9 @@ public class CraftChunk implements Chunk { int index = 0; net.minecraft.world.level.chunk.Chunk chunk = getHandle(); - BlockState[] entities = new BlockState[chunk.tileEntities.size()]; + BlockState[] entities = new BlockState[chunk.blockEntities.size()]; - for (Object obj : chunk.tileEntities.keySet().toArray()) { + for (Object obj : chunk.blockEntities.keySet().toArray()) { if (!(obj instanceof BlockPosition)) { continue; } @@ -257,12 +245,12 @@ public class CraftChunk implements Chunk { NBTTagCompound data = new NBTTagCompound(); cs[i].getBlocks().a(data, "Palette", "BlockStates"); - DataPaletteBlock blockids = new DataPaletteBlock<>(ChunkSection.GLOBAL_PALETTE, net.minecraft.world.level.block.Block.REGISTRY_ID, GameProfileSerializer::c, GameProfileSerializer::a, Blocks.AIR.getBlockData()); // TODO: snapshot whole ChunkSection + 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.world.getChunkProvider().getLightEngine(); + LightEngine lightengine = chunk.level.getChunkProvider().getLightEngine(); NibbleArray skyLightArray = lightengine.a(EnumSkyBlock.SKY).a(SectionPosition.a(x, i, z)); if (skyLightArray == null) { sectionSkyLights[i] = emptyLight; @@ -283,8 +271,8 @@ public class CraftChunk implements Chunk { HeightMap hmap = null; if (includeMaxBlockY) { - hmap = new HeightMap(null, HeightMap.Type.MOTION_BLOCKING); - hmap.a(chunk.heightMap.get(HeightMap.Type.MOTION_BLOCKING).a()); + 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; @@ -294,7 +282,7 @@ public class CraftChunk implements Chunk { } World world = getWorld(); - return new CraftChunkSnapshot(getX(), getZ(), world.getName(), world.getFullTime(), sectionBlockIDs, sectionSkyLights, sectionEmitLights, sectionEmpty, hmap, biome); + return new CraftChunkSnapshot(getX(), getZ(), chunk.getMinBuildHeight(), chunk.getMaxBuildHeight(), world.getName(), world.getFullTime(), sectionBlockIDs, sectionSkyLights, sectionEmitLights, sectionEmpty, hmap, biome); } @Override @@ -307,11 +295,12 @@ public class CraftChunk implements Chunk { if (includeBiome || includeBiomeTempRain) { WorldChunkManager wcm = world.getHandle().getChunkProvider().getChunkGenerator().getWorldChunkManager(); - biome = new BiomeStorage(world.getHandle().r().b(IRegistry.ay), new ChunkCoordIntPair(x, z), wcm); + 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); /* Fill with empty data */ - int hSection = world.getMaxHeight() >> 4; + int hSection = actual.getSectionsCount(); DataPaletteBlock[] blockIDs = new DataPaletteBlock[hSection]; byte[][] skyLight = new byte[hSection][]; byte[][] emitLight = new byte[hSection][]; @@ -324,12 +313,12 @@ public class CraftChunk implements Chunk { empty[i] = true; } - return new CraftChunkSnapshot(x, z, world.getName(), world.getFullTime(), blockIDs, skyLight, emitLight, empty, new HeightMap(null, HeightMap.Type.MOTION_BLOCKING), biome); + 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); } - static void validateChunkCoordinates(int x, int y, int z) { + static void validateChunkCoordinates(int minY, int maxY, int x, int y, int z) { Preconditions.checkArgument(0 <= x && x <= 15, "x out of range (expected 0-15, got %s)", x); - Preconditions.checkArgument(0 <= y && y <= 255, "y out of range (expected 0-255, got %s)", y); + Preconditions.checkArgument(minY <= y && y <= maxY, "y out of range (expected %s-%s, got %s)", minY, maxY, y); Preconditions.checkArgument(0 <= z && z <= 15, "z out of range (expected 0-15, got %s)", z); } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java b/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java index aa20cecc9..d90a3ec09 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java @@ -24,6 +24,7 @@ import org.bukkit.craftbukkit.util.CraftMagicNumbers; */ public class CraftChunkSnapshot implements ChunkSnapshot { private final int x, z; + private final int minHeight, maxHeight; private final String worldname; private final DataPaletteBlock[] blockids; private final byte[][] skylight; @@ -33,9 +34,11 @@ public class CraftChunkSnapshot implements ChunkSnapshot { private final long captureFulltime; private final BiomeStorage biome; - CraftChunkSnapshot(int x, int z, String wname, long wtime, DataPaletteBlock[] 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[] sectionBlockIDs, byte[][] sectionSkyLights, byte[][] sectionEmitLights, boolean[] sectionEmpty, HeightMap hmap, BiomeStorage biome) { this.x = x; this.z = z; + this.minHeight = minHeight; + this.maxHeight = maxHeight; this.worldname = wname; this.captureFulltime = wtime; this.blockids = sectionBlockIDs; @@ -77,45 +80,45 @@ public class CraftChunkSnapshot implements ChunkSnapshot { @Override public Material getBlockType(int x, int y, int z) { - CraftChunk.validateChunkCoordinates(x, y, z); + validateChunkCoordinates(x, y, z); - return CraftMagicNumbers.getMaterial(blockids[y >> 4].a(x, y & 0xF, z).getBlock()); + return CraftMagicNumbers.getMaterial(blockids[getSectionIndex(y)].a(x, y & 0xF, z).getBlock()); } @Override public final BlockData getBlockData(int x, int y, int z) { - CraftChunk.validateChunkCoordinates(x, y, z); + validateChunkCoordinates(x, y, z); - return CraftBlockData.fromData(blockids[y >> 4].a(x, y & 0xF, z)); + return CraftBlockData.fromData(blockids[getSectionIndex(y)].a(x, y & 0xF, z)); } @Override public final int getData(int x, int y, int z) { - CraftChunk.validateChunkCoordinates(x, y, z); + validateChunkCoordinates(x, y, z); - return CraftMagicNumbers.toLegacyData(blockids[y >> 4].a(x, y & 0xF, z)); + return CraftMagicNumbers.toLegacyData(blockids[getSectionIndex(y)].a(x, y & 0xF, z)); } @Override public final int getBlockSkyLight(int x, int y, int z) { - CraftChunk.validateChunkCoordinates(x, y, z); + validateChunkCoordinates(x, y, z); int off = ((y & 0xF) << 7) | (z << 3) | (x >> 1); - return (skylight[y >> 4][off] >> ((x & 1) << 2)) & 0xF; + return (skylight[getSectionIndex(y)][off] >> ((x & 1) << 2)) & 0xF; } @Override public final int getBlockEmittedLight(int x, int y, int z) { - CraftChunk.validateChunkCoordinates(x, y, z); + validateChunkCoordinates(x, y, z); int off = ((y & 0xF) << 7) | (z << 3) | (x >> 1); - return (emitlight[y >> 4][off] >> ((x & 1) << 2)) & 0xF; + return (emitlight[getSectionIndex(y)][off] >> ((x & 1) << 2)) & 0xF; } @Override public final int getHighestBlockYAt(int x, int z) { Preconditions.checkState(hmap != null, "ChunkSnapshot created without height map. Please call getSnapshot with includeMaxblocky=true"); - CraftChunk.validateChunkCoordinates(x, 0, z); + validateChunkCoordinates(x, 0, z); return hmap.a(x, z); } @@ -128,9 +131,9 @@ public class CraftChunkSnapshot implements ChunkSnapshot { @Override public final Biome getBiome(int x, int y, int z) { Preconditions.checkState(biome != null, "ChunkSnapshot created without biome. Please call getSnapshot with includeBiome=true"); - CraftChunk.validateChunkCoordinates(x, y, z); + validateChunkCoordinates(x, y, z); - return CraftBlock.biomeBaseToBiome((IRegistry) biome.registry, biome.getBiome(x >> 2, y >> 2, z >> 2)); + return CraftBlock.biomeBaseToBiome((IRegistry) biome.biomeRegistry, biome.getBiome(x >> 2, y >> 2, z >> 2)); } @Override @@ -141,7 +144,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot { @Override public final double getRawBiomeTemperature(int x, int y, int z) { Preconditions.checkState(biome != null, "ChunkSnapshot created without biome. Please call getSnapshot with includeBiome=true"); - CraftChunk.validateChunkCoordinates(x, y, z); + 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)); } @@ -155,4 +158,12 @@ public class CraftChunkSnapshot implements ChunkSnapshot { public final boolean isSectionEmpty(int sy) { return empty[sy]; } + + private int getSectionIndex(int y) { + return (y - minHeight) >> 4; + } + + private void validateChunkCoordinates(int x, int y, int z) { + CraftChunk.validateChunkCoordinates(minHeight, maxHeight, x, y, z); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java b/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java index e50731723..9e4508183 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java @@ -5,7 +5,7 @@ import java.io.StringWriter; import java.util.Arrays; import java.util.Collection; import java.util.Map; -import net.minecraft.CrashReportCallable; +import java.util.function.Supplier; import net.minecraft.server.MinecraftServer; import org.bukkit.Bukkit; import org.bukkit.Chunk; @@ -14,10 +14,10 @@ import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; -public class CraftCrashReport implements CrashReportCallable { +public class CraftCrashReport implements Supplier { @Override - public Object call() throws Exception { + 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())); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java index 9b8d7b176..9d046f7d9 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java @@ -33,7 +33,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa protected CraftOfflinePlayer(CraftServer server, GameProfile profile) { this.server = server; this.profile = profile; - this.storage = server.console.worldNBTStorage; + this.storage = server.console.playerDataStorage; } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftParticle.java b/src/main/java/org/bukkit/craftbukkit/CraftParticle.java index daa23a57a..9fcbcc42a 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftParticle.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftParticle.java @@ -3,17 +3,27 @@ package org.bukkit.craftbukkit; import com.google.common.base.Preconditions; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; +import com.mojang.math.Vector3fa; import java.util.HashMap; import java.util.Map; +import net.minecraft.core.BlockPosition; import net.minecraft.core.IRegistry; +import net.minecraft.core.particles.DustColorTransitionOptions; import net.minecraft.core.particles.ParticleParam; import net.minecraft.core.particles.ParticleParamBlock; import net.minecraft.core.particles.ParticleParamItem; import net.minecraft.core.particles.ParticleParamRedstone; import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.particles.VibrationParticleOption; import net.minecraft.resources.MinecraftKey; +import net.minecraft.world.level.gameevent.BlockPositionSource; +import net.minecraft.world.level.gameevent.EntityPositionSource; +import net.minecraft.world.level.gameevent.PositionSource; +import net.minecraft.world.level.gameevent.vibrations.VibrationPath; import org.bukkit.Color; +import org.bukkit.Location; import org.bukkit.Particle; +import org.bukkit.Vibration; import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -98,6 +108,23 @@ 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"), + SPORE_BLOSSOM_AIR("spore_blossom_air"), + SMALL_FLAME("small_flame"), + SNOWFLAKE("snowflake"), + DRIPPING_DRIPSTONE_LAVA("dripping_dripstone_lava"), + FALLING_DRIPSTONE_LAVA("falling_dripstone_lava"), + DRIPPING_DRIPSTONE_WATER("dripping_dripstone_water"), + FALLING_DRIPSTONE_WATER("falling_dripstone_water"), + GLOW_SQUID_INK("glow_squid_ink"), + GLOW("glow"), + WAX_ON("wax_on"), + WAX_OFF("wax_off"), + ELECTRIC_SPARK("electric_spark"), + SCRAPE("scrape"), // ----- Legacy Separator ----- LEGACY_BLOCK_CRACK("block"), LEGACY_BLOCK_DUST("block"), @@ -159,7 +186,30 @@ public enum CraftParticle { if (particle.getDataType() == Particle.DustOptions.class) { Particle.DustOptions data = (Particle.DustOptions) obj; Color color = data.getColor(); - return new ParticleParamRedstone(color.getRed() / 255.0f, color.getGreen() / 255.0f, color.getBlue() / 255.0f, data.getSize()); + return new ParticleParamRedstone(new Vector3fa(color.getRed() / 255.0f, color.getGreen() / 255.0f, color.getBlue() / 255.0f), data.getSize()); + } + if (particle.getDataType() == Particle.DustTransition.class) { + Particle.DustTransition data = (Particle.DustTransition) obj; + Color from = data.getColor(); + Color to = data.getToColor(); + return new DustColorTransitionOptions(new Vector3fa(from.getRed() / 255.0f, from.getGreen() / 255.0f, from.getBlue() / 255.0f), new Vector3fa(to.getRed() / 255.0f, to.getGreen() / 255.0f, to.getBlue() / 255.0f), data.getSize()); + } + if (particle.getDataType() == Vibration.class) { + Vibration vibration = (Vibration) obj; + Location origin = vibration.getOrigin(); + + PositionSource source; + if (vibration.getDestination() instanceof Vibration.Destination.BlockDestination) { + Location destination = ((Vibration.Destination.BlockDestination) vibration.getDestination()).getLocation(); + source = new BlockPositionSource(new BlockPosition(destination.getBlockX(), destination.getBlockY(), destination.getBlockZ())); + } else if (vibration.getDestination() instanceof Vibration.Destination.EntityDestination) { + source = new EntityPositionSource(((Vibration.Destination.EntityDestination) vibration.getDestination()).getEntity().getEntityId()); + } else { + throw new IllegalArgumentException("Unknown vibration destination " + vibration.getDestination()); + } + + VibrationPath path = new VibrationPath(new BlockPosition(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ()), source, vibration.getArrivalTime()); + return new VibrationParticleOption(path); } throw new IllegalArgumentException(particle.getDataType().toString()); } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRaid.java b/src/main/java/org/bukkit/craftbukkit/CraftRaid.java index aa405523d..3b8ab1a72 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftRaid.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftRaid.java @@ -87,7 +87,7 @@ public final class CraftRaid implements Raid { @Override public Set getHeroes() { - return Collections.unmodifiableSet(handle.heroes); + return Collections.unmodifiableSet(handle.heroesOfTheVillage); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 6cd929b53..c90476311 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -73,6 +73,9 @@ import net.minecraft.server.level.WorldServer; import net.minecraft.server.players.JsonListEntry; import net.minecraft.server.players.PlayerList; import net.minecraft.tags.Tags; +import net.minecraft.tags.TagsBlock; +import net.minecraft.tags.TagsFluid; +import net.minecraft.tags.TagsItem; import net.minecraft.util.datafix.DataConverterRegistry; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.effect.MobEffects; @@ -279,7 +282,7 @@ public final class CraftServer implements Server { Bukkit.setServer(this); // Register all the Enchantments and PotionTypes now so we can stop new registration immediately after - Enchantments.DAMAGE_ALL.getClass(); + Enchantments.SHARPNESS.getClass(); org.bukkit.enchantments.Enchantment.stopAcceptingRegistrations(); Potion.setPotionBrewer(new CraftPotionBrewer()); @@ -337,7 +340,7 @@ public final class CraftServer implements Server { ambientSpawn = configuration.getInt("spawn-limits.ambient"); console.autosavePeriod = configuration.getInt("ticks-per.autosave"); warningState = WarningState.value(configuration.getString("settings.deprecated-verbose")); - TicketType.PLUGIN.loadPeriod = configuration.getInt("chunk-gc.period-in-ticks"); + TicketType.PLUGIN.timeout = configuration.getInt("chunk-gc.period-in-ticks"); minimumAPI = configuration.getString("settings.minimum-api"); loadIcon(); } @@ -432,7 +435,7 @@ public final class CraftServer implements Server { public void syncCommands() { // Clear existing commands - CommandDispatcher dispatcher = console.dataPackResources.commandDispatcher = new CommandDispatcher(); + CommandDispatcher dispatcher = console.resources.commands = new CommandDispatcher(); // Register all commands, vanilla ones will be using the old dispatcher references for (Map.Entry entry : commandMap.getKnownCommands().entrySet()) { @@ -610,7 +613,7 @@ public final class CraftServer implements Server { @Override public boolean getGenerateStructures() { - return this.getProperties().generatorSettings.shouldGenerateMapFeatures(); + return this.getProperties().worldGenSettings.shouldGenerateMapFeatures(); } @Override @@ -717,15 +720,15 @@ public final class CraftServer implements Server { Conversable conversable = (Conversable) sender; if (conversable.isConversing()) { - conversable.acceptConversationInput(serverCommand.command); + conversable.acceptConversationInput(serverCommand.msg); return true; } } try { this.playerCommandState = true; - return dispatchCommand(sender, serverCommand.command); + return dispatchCommand(sender, serverCommand.msg); } catch (Exception ex) { - getLogger().log(Level.WARNING, "Unexpected exception while parsing console command \"" + serverCommand.command + '"', ex); + getLogger().log(Level.WARNING, "Unexpected exception while parsing console command \"" + serverCommand.msg + '"', ex); return false; } finally { this.playerCommandState = false; @@ -756,8 +759,8 @@ public final class CraftServer implements Server { configuration = YamlConfiguration.loadConfiguration(getConfigFile()); commandsConfiguration = YamlConfiguration.loadConfiguration(getCommandsConfigFile()); - console.propertyManager = new DedicatedServerSettings(console.getCustomRegistry(), console.options); - DedicatedServerProperties config = console.propertyManager.getProperties(); + console.settings = new DedicatedServerSettings(console.options); + DedicatedServerProperties config = console.settings.getProperties(); console.setPVP(config.pvp); console.setAllowFlight(config.allowFlight); @@ -768,7 +771,7 @@ public final class CraftServer implements Server { waterAmbientSpawn = configuration.getInt("spawn-limits.water-ambient"); ambientSpawn = configuration.getInt("spawn-limits.ambient"); warningState = WarningState.value(configuration.getString("settings.deprecated-verbose")); - TicketType.PLUGIN.loadPeriod = configuration.getInt("chunk-gc.period-in-ticks"); + TicketType.PLUGIN.timeout = configuration.getInt("chunk-gc.period-in-ticks"); minimumAPI = configuration.getString("settings.minimum-api"); printSaveWarning = false; console.autosavePeriod = configuration.getInt("ticks-per.autosave"); @@ -786,7 +789,7 @@ public final class CraftServer implements Server { } for (WorldServer world : console.getWorlds()) { - world.worldDataServer.setDifficulty(config.difficulty); + world.serverLevelData.setDifficulty(config.difficulty); world.setSpawnFlags(config.spawnMonsters, config.spawnAnimals); if (this.getTicksPerAnimalSpawns() < 0) { world.ticksPerAnimalSpawns = 400; @@ -943,7 +946,7 @@ public final class CraftServer implements Server { @Override public World createWorld(WorldCreator creator) { - Preconditions.checkState(!console.worldServer.isEmpty(), "Cannot create additional worlds on STARTUP"); + Preconditions.checkState(!console.levels.isEmpty(), "Cannot create additional worlds on STARTUP"); Validate.notNull(creator, "Creator may not be null"); String name = creator.name(); @@ -969,10 +972,10 @@ public final class CraftServer implements Server { actualDimension = WorldDimension.OVERWORLD; break; case NETHER: - actualDimension = WorldDimension.THE_NETHER; + actualDimension = WorldDimension.NETHER; break; case THE_END: - actualDimension = WorldDimension.THE_END; + actualDimension = WorldDimension.END; break; default: throw new IllegalArgumentException("Illegal dimension"); @@ -988,7 +991,7 @@ public final class CraftServer implements Server { boolean hardcore = creator.hardcore(); - RegistryReadOps registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, console.dataPackResources.h(), console.customRegistry); + RegistryReadOps registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.INSTANCE, console.resources.i(), console.registryHolder); WorldDataServer worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, console.datapackconfiguration); WorldSettings worldSettings; @@ -1011,7 +1014,7 @@ public final class CraftServer implements Server { net.minecraft.server.Main.convertWorld(worldSession, DataConverterRegistry.a(), console.options.has("eraseCache"), () -> { return true; }, worlddata.getGeneratorSettings().d().d().stream().map((entry) -> { - return ResourceKey.a(IRegistry.K, ((ResourceKey) entry.getKey()).a()); + return ResourceKey.a(IRegistry.DIMENSION_TYPE_REGISTRY, ((ResourceKey) entry.getKey()).a()); }).collect(ImmutableSet.toImmutableSet())); } @@ -1023,8 +1026,8 @@ public final class CraftServer implements Server { net.minecraft.world.level.chunk.ChunkGenerator chunkgenerator; if (worlddimension == null) { - dimensionmanager = (DimensionManager) console.customRegistry.a().d(DimensionManager.OVERWORLD); - chunkgenerator = GeneratorSettings.a(console.customRegistry.b(IRegistry.ay), console.customRegistry.b(IRegistry.ar), (new Random()).nextLong()); + 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()); } else { dimensionmanager = worlddimension.b(); chunkgenerator = worlddimension.c(); @@ -1033,14 +1036,14 @@ public final class CraftServer implements Server { ResourceKey worldKey; String levelName = this.getServer().getDedicatedServerProperties().levelName; if (name.equals(levelName + "_nether")) { - worldKey = net.minecraft.world.level.World.THE_NETHER; + worldKey = net.minecraft.world.level.World.NETHER; } else if (name.equals(levelName + "_the_end")) { - worldKey = net.minecraft.world.level.World.THE_END; + worldKey = net.minecraft.world.level.World.END; } else { - worldKey = ResourceKey.a(IRegistry.L, new MinecraftKey(name.toLowerCase(java.util.Locale.ENGLISH))); + worldKey = ResourceKey.a(IRegistry.DIMENSION_REGISTRY, new MinecraftKey(name.toLowerCase(java.util.Locale.ENGLISH))); } - WorldServer internal = (WorldServer) new WorldServer(console, console.executorService, worldSession, worlddata, worldKey, dimensionmanager, getServer().worldLoadListenerFactory.create(11), + 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); if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) { @@ -1050,9 +1053,9 @@ public final class CraftServer implements Server { console.initWorld(internal, worlddata, worlddata, worlddata.getGeneratorSettings()); internal.setSpawnFlags(true, true); - console.worldServer.put(internal.getDimensionKey(), internal); + console.levels.put(internal.getDimensionKey(), internal); - getServer().loadSpawn(internal.getChunkProvider().playerChunkMap.worldLoadListener, internal); + getServer().loadSpawn(internal.getChunkProvider().chunkMap.progressListener, internal); pluginManager.callEvent(new WorldLoadEvent(internal.getWorld())); return internal.getWorld(); @@ -1071,7 +1074,7 @@ public final class CraftServer implements Server { WorldServer handle = ((CraftWorld) world).getHandle(); - if (!(console.worldServer.containsKey(handle.getDimensionKey()))) { + if (!(console.levels.containsKey(handle.getDimensionKey()))) { return false; } @@ -1102,7 +1105,7 @@ public final class CraftServer implements Server { } worlds.remove(world.getName().toLowerCase(java.util.Locale.ENGLISH)); - console.worldServer.remove(handle.getDimensionKey()); + console.levels.remove(handle.getDimensionKey()); return true; } @@ -1547,7 +1550,7 @@ public final class CraftServer implements Server { @Override public GameMode getDefaultGameMode() { - return GameMode.getByValue(console.getWorldServer(net.minecraft.world.level.World.OVERWORLD).worldDataServer.getGameType().getId()); + return GameMode.getByValue(console.getWorldServer(net.minecraft.world.level.World.OVERWORLD).serverLevelData.getGameType().getId()); } @Override @@ -1555,7 +1558,7 @@ public final class CraftServer implements Server { Validate.notNull(mode, "Mode cannot be null"); for (World world : getWorlds()) { - ((CraftWorld) world).getHandle().worldDataServer.setGameType(EnumGamemode.getById(mode.getValue())); + ((CraftWorld) world).getHandle().serverLevelData.setGameType(EnumGamemode.getById(mode.getValue())); } } @@ -1578,12 +1581,12 @@ public final class CraftServer implements Server { @Override public File getWorldContainer() { - return this.getServer().convertable.a(net.minecraft.world.level.World.OVERWORLD).getParentFile(); + return this.getServer().storageSource.a(net.minecraft.world.level.World.OVERWORLD).getParentFile(); } @Override public OfflinePlayer[] getOfflinePlayers() { - WorldNBTStorage storage = console.worldNBTStorage; + WorldNBTStorage storage = console.playerDataStorage; String[] files = storage.getPlayerDir().list(new DatFileFilter()); Set players = new HashSet(); @@ -1959,15 +1962,15 @@ 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) new CraftBlockTag(console.getTagRegistry().getBlockTags(), key); + return (org.bukkit.Tag) new CraftBlockTag(TagsBlock.a(), key); case org.bukkit.Tag.REGISTRY_ITEMS: Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Item namespace must have material type"); - return (org.bukkit.Tag) new CraftItemTag(console.getTagRegistry().getItemTags(), key); + return (org.bukkit.Tag) new CraftItemTag(TagsItem.a(), key); case org.bukkit.Tag.REGISTRY_FLUIDS: Preconditions.checkArgument(clazz == org.bukkit.Fluid.class, "Fluid namespace must have fluid type"); - return (org.bukkit.Tag) new CraftFluidTag(console.getTagRegistry().getFluidTags(), key); + return (org.bukkit.Tag) new CraftFluidTag(TagsFluid.a(), key); default: throw new IllegalArgumentException(); } @@ -1980,17 +1983,17 @@ 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 blockTags = console.getTagRegistry().getBlockTags(); + Tags blockTags = TagsBlock.a(); return blockTags.a().keySet().stream().map(key -> (org.bukkit.Tag) 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 itemTags = console.getTagRegistry().getItemTags(); + Tags itemTags = TagsItem.a(); return itemTags.a().keySet().stream().map(key -> (org.bukkit.Tag) 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 fluidTags = console.getTagRegistry().getFluidTags(); + Tags fluidTags = TagsFluid.a(); return fluidTags.a().keySet().stream().map(key -> (org.bukkit.Tag) new CraftFluidTag(fluidTags, key)).collect(ImmutableList.toImmutableList()); default: throw new IllegalArgumentException(); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java b/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java index 43420fc6b..1307e30f9 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java @@ -30,11 +30,12 @@ public enum CraftStatistic { DROP_COUNT(StatisticList.DROP), DROP(new MinecraftKey("dropped")), PICKUP(new MinecraftKey("picked_up")), - PLAY_ONE_MINUTE(StatisticList.PLAY_ONE_MINUTE), + PLAY_ONE_MINUTE(StatisticList.PLAY_TIME), + TOTAL_WORLD_TIME(StatisticList.TOTAL_WORLD_TIME), WALK_ONE_CM(StatisticList.WALK_ONE_CM), WALK_ON_WATER_ONE_CM(StatisticList.WALK_ON_WATER_ONE_CM), FALL_ONE_CM(StatisticList.FALL_ONE_CM), - SNEAK_TIME(StatisticList.SNEAK_TIME), + SNEAK_TIME(StatisticList.CROUCH_TIME), CLIMB_ONE_CM(StatisticList.CLIMB_ONE_CM), FLY_ONE_CM(StatisticList.FLY_ONE_CM), WALK_UNDER_WATER_ONE_CM(StatisticList.WALK_UNDER_WATER_ONE_CM), @@ -122,7 +123,7 @@ public enum CraftStatistic { public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.stats.Statistic statistic) { IRegistry statRegistry = statistic.getWrapper().getRegistry(); - MinecraftKey nmsKey = IRegistry.STATS.getKey(statistic.getWrapper()); + MinecraftKey nmsKey = IRegistry.STAT_TYPE.getKey(statistic.getWrapper()); if (statRegistry == IRegistry.CUSTOM_STAT) { nmsKey = (MinecraftKey) statistic.b(); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index ded480aca..0f79445f6 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -85,6 +85,7 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.IChunkAccess; import net.minecraft.world.level.chunk.ProtoChunkExtension; +import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; import net.minecraft.world.level.levelgen.feature.StructureGenerator; import net.minecraft.world.level.storage.SavedFile; import net.minecraft.world.phys.AxisAlignedBB; @@ -132,6 +133,7 @@ import org.bukkit.entity.Ambient; import org.bukkit.entity.AreaEffectCloud; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Arrow; +import org.bukkit.entity.Axolotl; import org.bukkit.entity.Bat; import org.bukkit.entity.Bee; import org.bukkit.entity.Blaze; @@ -168,6 +170,9 @@ import org.bukkit.entity.Fish; import org.bukkit.entity.Fox; import org.bukkit.entity.Ghast; import org.bukkit.entity.Giant; +import org.bukkit.entity.GlowItemFrame; +import org.bukkit.entity.GlowSquid; +import org.bukkit.entity.Goat; import org.bukkit.entity.Golem; import org.bukkit.entity.Guardian; import org.bukkit.entity.Hanging; @@ -185,6 +190,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Llama; import org.bukkit.entity.LlamaSpit; import org.bukkit.entity.MagmaCube; +import org.bukkit.entity.Marker; import org.bukkit.entity.Minecart; import org.bukkit.entity.Mule; import org.bukkit.entity.MushroomCow; @@ -318,7 +324,7 @@ public class CraftWorld implements World { public boolean setSpawnLocation(int x, int y, int z, float angle) { try { Location previousLocation = getSpawnLocation(); - world.worldData.setSpawn(new BlockPosition(x, y, z), angle); + world.levelData.setSpawn(new BlockPosition(x, y, z), angle); // Notify anyone who's listening. SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation); @@ -355,7 +361,7 @@ public class CraftWorld implements World { @Override public boolean isChunkGenerated(int x, int z) { try { - return isChunkLoaded(x, z) || world.getChunkProvider().playerChunkMap.read(new ChunkCoordIntPair(x, z)) != null; + return isChunkLoaded(x, z) || world.getChunkProvider().chunkMap.read(new ChunkCoordIntPair(x, z)) != null; } catch (IOException ex) { throw new RuntimeException(ex); } @@ -363,7 +369,7 @@ public class CraftWorld implements World { @Override public Chunk[] getLoadedChunks() { - Long2ObjectLinkedOpenHashMap chunks = world.getChunkProvider().playerChunkMap.visibleChunks; + Long2ObjectLinkedOpenHashMap chunks = world.getChunkProvider().chunkMap.visibleChunkMap; return chunks.values().stream().map(PlayerChunk::getFullChunk).filter(Objects::nonNull).map(net.minecraft.world.level.chunk.Chunk::getBukkitChunk).toArray(Chunk[]::new); } @@ -498,7 +504,7 @@ public class CraftWorld implements World { Preconditions.checkArgument(plugin != null, "null plugin"); Preconditions.checkArgument(plugin.isEnabled(), "plugin is not enabled"); - ChunkMapDistance chunkDistanceManager = this.world.getChunkProvider().playerChunkMap.chunkDistanceManager; + ChunkMapDistance chunkDistanceManager = this.world.getChunkProvider().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 @@ -512,7 +518,7 @@ public class CraftWorld implements World { public boolean removePluginChunkTicket(int x, int z, Plugin plugin) { Preconditions.checkNotNull(plugin, "null plugin"); - ChunkMapDistance chunkDistanceManager = this.world.getChunkProvider().playerChunkMap.chunkDistanceManager; + ChunkMapDistance chunkDistanceManager = this.world.getChunkProvider().chunkMap.distanceManager; return chunkDistanceManager.removeTicketAtLevel(TicketType.PLUGIN_TICKET, new ChunkCoordIntPair(x, z), 31, plugin); // keep in-line with force loading, remove at level 31 } @@ -520,13 +526,13 @@ public class CraftWorld implements World { public void removePluginChunkTickets(Plugin plugin) { Preconditions.checkNotNull(plugin, "null plugin"); - ChunkMapDistance chunkDistanceManager = this.world.getChunkProvider().playerChunkMap.chunkDistanceManager; + ChunkMapDistance chunkDistanceManager = this.world.getChunkProvider().chunkMap.distanceManager; chunkDistanceManager.removeAllTicketsFor(TicketType.PLUGIN_TICKET, 31, plugin); // keep in-line with force loading, remove at level 31 } @Override public Collection getPluginChunkTickets(int x, int z) { - ChunkMapDistance chunkDistanceManager = this.world.getChunkProvider().playerChunkMap.chunkDistanceManager; + ChunkMapDistance chunkDistanceManager = this.world.getChunkProvider().chunkMap.distanceManager; ArraySetSorted> tickets = chunkDistanceManager.tickets.get(ChunkCoordIntPair.pair(x, z)); if (tickets == null) { @@ -536,7 +542,7 @@ public class CraftWorld implements World { ImmutableList.Builder ret = ImmutableList.builder(); for (Ticket ticket : tickets) { if (ticket.getTicketType() == TicketType.PLUGIN_TICKET) { - ret.add((Plugin) ticket.identifier); + ret.add((Plugin) ticket.key); } } @@ -546,7 +552,7 @@ public class CraftWorld implements World { @Override public Map> getPluginChunkTickets() { Map> ret = new HashMap<>(); - ChunkMapDistance chunkDistanceManager = this.world.getChunkProvider().playerChunkMap.chunkDistanceManager; + ChunkMapDistance chunkDistanceManager = this.world.getChunkProvider().chunkMap.distanceManager; for (Long2ObjectMap.Entry>> chunkTickets : chunkDistanceManager.tickets.long2ObjectEntrySet()) { long chunkKey = chunkTickets.getLongKey(); @@ -562,7 +568,7 @@ public class CraftWorld implements World { chunk = this.getChunkAt(ChunkCoordIntPair.getX(chunkKey), ChunkCoordIntPair.getZ(chunkKey)); } - ret.computeIfAbsent((Plugin) ticket.identifier, (key) -> ImmutableList.builder()).add(chunk); + ret.computeIfAbsent((Plugin) ticket.key, (key) -> ImmutableList.builder()).add(chunk); } } @@ -716,7 +722,7 @@ public class CraftWorld implements World { gen = BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM; break; case SWAMP: - gen = BiomeDecoratorGroups.SWAMP_TREE; + gen = BiomeDecoratorGroups.SWAMP_OAK; break; case ACACIA: gen = BiomeDecoratorGroups.ACACIA; @@ -739,13 +745,16 @@ public class CraftWorld implements World { case WARPED_FUNGUS: gen = BiomeDecoratorGroups.WARPED_FUNGI_PLANTED; break; + case AZALEA: + gen = BiomeDecoratorGroups.AZALEA_TREE; + break; case TREE: default: gen = BiomeDecoratorGroups.OAK; break; } - return gen.e.generate(world, world.getChunkProvider().getChunkGenerator(), rand, pos, gen.f); + return gen.feature.generate(new FeaturePlaceContext(world, world.getChunkProvider().getChunkGenerator(), rand, pos, gen.config)); } @Override @@ -767,7 +776,7 @@ public class CraftWorld implements World { @Override public String getName() { - return world.worldDataServer.getName(); + return world.serverLevelData.getName(); } @Override @@ -813,15 +822,15 @@ public class CraftWorld implements World { // Forces the client to update to the new time immediately for (Player p : getPlayers()) { CraftPlayer cp = (CraftPlayer) p; - if (cp.getHandle().playerConnection == null) continue; + if (cp.getHandle().connection == null) continue; - cp.getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateTime(cp.getHandle().world.getTime(), cp.getHandle().getPlayerTime(), cp.getHandle().world.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))); + cp.getHandle().connection.sendPacket(new PacketPlayOutUpdateTime(cp.getHandle().level.getTime(), cp.getHandle().getPlayerTime(), cp.getHandle().level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); } } @Override public long getGameTime() { - return world.worldData.getTime(); + return world.levelData.getTime(); } @Override @@ -935,7 +944,7 @@ public class CraftWorld implements World { @Override public Biome getBiome(int x, int y, int z) { - return CraftBlock.biomeBaseToBiome(getHandle().r().b(IRegistry.ay), this.world.getBiome(x >> 2, y >> 2, z >> 2)); + return CraftBlock.biomeBaseToBiome(getHandle().t().d(IRegistry.BIOME_REGISTRY), this.world.getBiome(x >> 2, y >> 2, z >> 2)); } @Override @@ -948,7 +957,7 @@ public class CraftWorld implements World { @Override public void setBiome(int x, int y, int z, Biome bio) { Preconditions.checkArgument(bio != Biome.CUSTOM, "Cannot set the biome to %s", bio); - BiomeBase bb = CraftBlock.biomeToBiomeBase(getHandle().r().b(IRegistry.ay), bio); + BiomeBase bb = CraftBlock.biomeToBiomeBase(getHandle().t().d(IRegistry.BIOME_REGISTRY), bio); BlockPosition pos = new BlockPosition(x, 0, z); if (this.world.isLoaded(pos)) { net.minecraft.world.level.chunk.Chunk chunk = this.world.getChunkAtWorldCoords(pos); @@ -986,17 +995,14 @@ public class CraftWorld implements World { public List getEntities() { List list = new ArrayList(); - for (Object o : world.entitiesById.values()) { - if (o instanceof net.minecraft.world.entity.Entity) { - net.minecraft.world.entity.Entity mcEnt = (net.minecraft.world.entity.Entity) o; - Entity bukkitEntity = mcEnt.getBukkitEntity(); + world.getEntities().a().forEach((mcEnt) -> { + Entity bukkitEntity = mcEnt.getBukkitEntity(); - // Assuming that bukkitEntity isn't null - if (bukkitEntity != null && bukkitEntity.isValid()) { - list.add(bukkitEntity); - } + // Assuming that bukkitEntity isn't null + if (bukkitEntity != null && bukkitEntity.isValid()) { + list.add(bukkitEntity); } - } + }); return list; } @@ -1005,17 +1011,14 @@ public class CraftWorld implements World { public List getLivingEntities() { List list = new ArrayList(); - for (Object o : world.entitiesById.values()) { - if (o instanceof net.minecraft.world.entity.Entity) { - net.minecraft.world.entity.Entity mcEnt = (net.minecraft.world.entity.Entity) o; - Entity bukkitEntity = mcEnt.getBukkitEntity(); + world.getEntities().a().forEach((mcEnt) -> { + Entity bukkitEntity = mcEnt.getBukkitEntity(); - // Assuming that bukkitEntity isn't null - if (bukkitEntity != null && bukkitEntity instanceof LivingEntity && bukkitEntity.isValid()) { - list.add((LivingEntity) bukkitEntity); - } + // Assuming that bukkitEntity isn't null + if (bukkitEntity != null && bukkitEntity instanceof LivingEntity && bukkitEntity.isValid()) { + list.add((LivingEntity) bukkitEntity); } - } + }); return list; } @@ -1032,21 +1035,19 @@ public class CraftWorld implements World { public Collection getEntitiesByClass(Class clazz) { Collection list = new ArrayList(); - for (Object entity: world.entitiesById.values()) { - if (entity instanceof net.minecraft.world.entity.Entity) { - Entity bukkitEntity = ((net.minecraft.world.entity.Entity) entity).getBukkitEntity(); + world.getEntities().a().forEach((entity) -> { + Entity bukkitEntity = ((net.minecraft.world.entity.Entity) entity).getBukkitEntity(); - if (bukkitEntity == null) { - continue; - } - - Class bukkitClass = bukkitEntity.getClass(); - - if (clazz.isAssignableFrom(bukkitClass) && bukkitEntity.isValid()) { - list.add((T) bukkitEntity); - } + if (bukkitEntity == null) { + return; } - } + + Class bukkitClass = bukkitEntity.getClass(); + + if (clazz.isAssignableFrom(bukkitClass) && bukkitEntity.isValid()) { + list.add((T) bukkitEntity); + } + }); return list; } @@ -1055,26 +1056,24 @@ public class CraftWorld implements World { public Collection getEntitiesByClasses(Class... classes) { Collection list = new ArrayList(); - for (Object entity: world.entitiesById.values()) { - if (entity instanceof net.minecraft.world.entity.Entity) { - Entity bukkitEntity = ((net.minecraft.world.entity.Entity) entity).getBukkitEntity(); + world.getEntities().a().forEach((entity) -> { + Entity bukkitEntity = ((net.minecraft.world.entity.Entity) entity).getBukkitEntity(); - if (bukkitEntity == null) { - continue; - } + if (bukkitEntity == null) { + return; + } - Class bukkitClass = bukkitEntity.getClass(); + Class bukkitClass = bukkitEntity.getClass(); - for (Class clazz : classes) { - if (clazz.isAssignableFrom(bukkitClass)) { - if (bukkitEntity.isValid()) { - list.add(bukkitEntity); - } - break; + for (Class clazz : classes) { + if (clazz.isAssignableFrom(bukkitClass)) { + if (bukkitEntity.isValid()) { + list.add(bukkitEntity); } + break; } } - } + }); return list; } @@ -1255,27 +1254,27 @@ public class CraftWorld implements World { @Override public void save() { this.server.checkSaveState(); - boolean oldSave = world.savingDisabled; + boolean oldSave = world.noSave; - world.savingDisabled = false; + world.noSave = false; world.save(null, false, false); - world.savingDisabled = oldSave; + world.noSave = oldSave; } @Override public boolean isAutoSave() { - return !world.savingDisabled; + return !world.noSave; } @Override public void setAutoSave(boolean value) { - world.savingDisabled = !value; + world.noSave = !value; } @Override public void setDifficulty(Difficulty difficulty) { - this.getHandle().worldDataServer.setDifficulty(EnumDifficulty.getById(difficulty.getValue())); + this.getHandle().serverLevelData.setDifficulty(EnumDifficulty.getById(difficulty.getValue())); } @Override @@ -1289,46 +1288,46 @@ public class CraftWorld implements World { @Override public boolean hasStorm() { - return world.worldData.hasStorm(); + return world.levelData.hasStorm(); } @Override public void setStorm(boolean hasStorm) { - world.worldData.setStorm(hasStorm); + world.levelData.setStorm(hasStorm); setWeatherDuration(0); // Reset weather duration (legacy behaviour) setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands) } @Override public int getWeatherDuration() { - return world.worldDataServer.getWeatherDuration(); + return world.serverLevelData.getWeatherDuration(); } @Override public void setWeatherDuration(int duration) { - world.worldDataServer.setWeatherDuration(duration); + world.serverLevelData.setWeatherDuration(duration); } @Override public boolean isThundering() { - return world.worldData.isThundering(); + return world.levelData.isThundering(); } @Override public void setThundering(boolean thundering) { - world.worldDataServer.setThundering(thundering); + world.serverLevelData.setThundering(thundering); setThunderDuration(0); // Reset weather duration (legacy behaviour) setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands) } @Override public int getThunderDuration() { - return world.worldDataServer.getThunderDuration(); + return world.serverLevelData.getThunderDuration(); } @Override public void setThunderDuration(int duration) { - world.worldDataServer.setThunderDuration(duration); + world.serverLevelData.setThunderDuration(duration); } @Override @@ -1338,12 +1337,12 @@ public class CraftWorld implements World { @Override public void setClearWeatherDuration(int duration) { - world.worldDataServer.setClearWeatherTime(duration); + world.serverLevelData.setClearWeatherTime(duration); } @Override public int getClearWeatherDuration() { - return world.worldDataServer.getClearWeatherTime(); + return world.serverLevelData.getClearWeatherTime(); } @Override @@ -1398,12 +1397,12 @@ public class CraftWorld implements World { radius *= radius; for (Player player : getPlayers()) { - if (((CraftPlayer) player).getHandle().playerConnection == null) continue; + if (((CraftPlayer) player).getHandle().connection == null) continue; if (!location.getWorld().equals(player.getWorld())) continue; distance = (int) player.getLocation().distanceSquared(location); if (distance <= radius) { - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + ((CraftPlayer) player).getHandle().connection.sendPacket(packet); } } } @@ -1431,7 +1430,7 @@ public class CraftWorld implements World { Validate.isTrue(material.isBlock(), "Material must be a block"); EntityFallingBlock entity = new EntityFallingBlock(world, location.getX(), location.getY(), location.getZ(), CraftMagicNumbers.getBlock(material).getBlockData()); - entity.ticksLived = 1; + entity.time = 1; world.addEntity(entity, SpawnReason.CUSTOM); return (FallingBlock) entity.getBukkitEntity(); @@ -1443,7 +1442,7 @@ public class CraftWorld implements World { Validate.notNull(data, "Material cannot be null"); EntityFallingBlock entity = new EntityFallingBlock(world, location.getX(), location.getY(), location.getZ(), ((CraftBlockData) data).getState()); - entity.ticksLived = 1; + entity.time = 1; world.addEntity(entity, SpawnReason.CUSTOM); return (FallingBlock) entity.getBukkitEntity(); @@ -1520,7 +1519,7 @@ public class CraftWorld implements World { entity = EntityTypes.LLAMA_SPIT.a(world); entity.setPositionRotation(x, y, z, yaw, pitch); } else if (Firework.class.isAssignableFrom(clazz)) { - entity = new EntityFireworks(world, x, y, z, net.minecraft.world.item.ItemStack.b); + entity = new EntityFireworks(world, x, y, z, net.minecraft.world.item.ItemStack.EMPTY); } } else if (Minecart.class.isAssignableFrom(clazz)) { if (PoweredMinecart.class.isAssignableFrom(clazz)) { @@ -1611,7 +1610,11 @@ public class CraftWorld implements World { entity = EntityTypes.SPIDER.a(world); } } else if (Squid.class.isAssignableFrom(clazz)) { - entity = EntityTypes.SQUID.a(world); + if (GlowSquid.class.isAssignableFrom(clazz)) { + entity = EntityTypes.GLOW_SQUID.a(world); + } else { + entity = EntityTypes.SQUID.a(world); + } } else if (Tameable.class.isAssignableFrom(clazz)) { if (Wolf.class.isAssignableFrom(clazz)) { entity = EntityTypes.WOLF.a(world); @@ -1722,6 +1725,10 @@ public class CraftWorld implements World { entity = EntityTypes.STRIDER.a(world); } else if (Zoglin.class.isAssignableFrom(clazz)) { entity = EntityTypes.ZOGLIN.a(world); + } else if (Axolotl.class.isAssignableFrom(clazz)) { + entity = EntityTypes.AXOLOTL.a(world); + } else if (Goat.class.isAssignableFrom(clazz)) { + entity = EntityTypes.GOAT.a(world); } if (entity != null) { @@ -1768,7 +1775,6 @@ public class CraftWorld implements World { if (LeashHitch.class.isAssignableFrom(clazz)) { entity = new EntityLeash(world, new BlockPosition(x, y, z)); - entity.attachedToPlayer = true; } else { // No valid face found Preconditions.checkArgument(face != BlockFace.SELF, "Cannot spawn hanging entity for %s at %s (no free face)", clazz.getName(), location); @@ -1777,7 +1783,11 @@ public class CraftWorld implements World { if (Painting.class.isAssignableFrom(clazz)) { entity = new EntityPainting(world, new BlockPosition(x, y, z), dir); } else if (ItemFrame.class.isAssignableFrom(clazz)) { - entity = new EntityItemFrame(world, new BlockPosition(x, y, z), dir); + if (GlowItemFrame.class.isAssignableFrom(clazz)) { + entity = new net.minecraft.world.entity.decoration.GlowItemFrame(world, new BlockPosition(x, y, z), dir); + } else { + entity = new EntityItemFrame(world, new BlockPosition(x, y, z), dir); + } } } @@ -1794,6 +1804,8 @@ public class CraftWorld implements World { 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); } if (entity != null) { @@ -1842,22 +1854,22 @@ public class CraftWorld implements World { @Override public boolean getAllowAnimals() { - return world.getChunkProvider().allowAnimals; + return world.getChunkProvider().spawnFriendlies; } @Override public boolean getAllowMonsters() { - return world.getChunkProvider().allowMonsters; + return world.getChunkProvider().spawnEnemies; } @Override public int getMinHeight() { - return 0; + return world.getMinBuildHeight(); } @Override public int getMaxHeight() { - return world.getBuildHeight(); + return world.getMaxBuildHeight(); } @Override @@ -1934,7 +1946,7 @@ public class CraftWorld implements World { @Override public boolean canGenerateStructures() { - return world.worldDataServer.getGeneratorSettings().shouldGenerateMapFeatures(); + return world.serverLevelData.getGeneratorSettings().shouldGenerateMapFeatures(); } @Override @@ -1944,7 +1956,7 @@ public class CraftWorld implements World { @Override public void setHardcore(boolean hardcore) { - world.worldDataServer.b.hardcore = hardcore; + world.serverLevelData.settings.hardcore = hardcore; } @Override @@ -2322,7 +2334,7 @@ public class CraftWorld 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.a.get(structureType.getName()), originPos, radius, findUnexplored); + BlockPosition nearest = getHandle().getChunkProvider().getChunkGenerator().findNearestMapFeature(getHandle(), StructureGenerator.STRUCTURES_REGISTRY.get(structureType.getName()), originPos, radius, findUnexplored); return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ()); } @@ -2339,7 +2351,7 @@ public class CraftWorld implements World { @Override public List getRaids() { PersistentRaid persistentRaid = world.getPersistentRaid(); - return persistentRaid.raids.values().stream().map(CraftRaid::new).collect(Collectors.toList()); + return persistentRaid.raidMap.values().stream().map(CraftRaid::new).collect(Collectors.toList()); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java index dcc3c5793..7bdefcaa0 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -149,6 +149,10 @@ 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'."); + return; + } if (javaVersion > 60.0) { System.err.println("Unsupported Java detected (" + javaVersion + "). Only up to Java 16 is supported."); return; @@ -177,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, -3); if (buildDate.before(deadline.getTime())) { System.err.println("*** Error, this build is outdated ***"); System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***"); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java index 870ae6e7a..520309eb8 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java @@ -35,9 +35,9 @@ public class CraftBanner extends CraftBlockEntityState impleme base = DyeColor.getByWoolData((byte) ((BlockBannerAbstract) this.data.getBlock()).getColor().getColorIndex()); patterns = new ArrayList(); - if (banner.patterns != null) { - for (int i = 0; i < banner.patterns.size(); i++) { - NBTTagCompound p = (NBTTagCompound) banner.patterns.get(i); + if (banner.itemPatterns != null) { + for (int i = 0; i < banner.itemPatterns.size(); i++) { + NBTTagCompound p = (NBTTagCompound) banner.itemPatterns.get(i); patterns.add(new Pattern(DyeColor.getByWoolData((byte) p.getInt("Color")), PatternType.getByIdentifier(p.getString("Pattern")))); } } @@ -93,7 +93,7 @@ public class CraftBanner extends CraftBlockEntityState impleme public void applyTo(TileEntityBanner banner) { super.applyTo(banner); - banner.color = EnumColor.fromColorIndex(base.getWoolData()); + banner.baseColor = EnumColor.fromColorIndex(base.getWoolData()); NBTTagList newPatterns = new NBTTagList(); @@ -103,6 +103,6 @@ public class CraftBanner extends CraftBlockEntityState impleme compound.setString("Pattern", p.getPattern().getIdentifier()); newPatterns.add(compound); } - banner.patterns = newPatterns; + banner.itemPatterns = newPatterns; } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java index e27f5d689..54ba3aca2 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java @@ -37,26 +37,26 @@ public class CraftBarrel extends CraftLootable implements Barr @Override public void open() { requirePlaced(); - if (!getTileEntity().opened) { + if (!getTileEntity().openersCounter.opened) { IBlockData blockData = getTileEntity().getBlock(); boolean open = blockData.get(BlockBarrel.OPEN); if (!open) { getTileEntity().setOpenFlag(blockData, true); - getTileEntity().playOpenSound(blockData, SoundEffects.BLOCK_BARREL_OPEN); + getTileEntity().playOpenSound(blockData, SoundEffects.BARREL_OPEN); } } - getTileEntity().opened = true; + getTileEntity().openersCounter.opened = true; } @Override public void close() { requirePlaced(); - if (getTileEntity().opened) { + if (getTileEntity().openersCounter.opened) { IBlockData blockData = getTileEntity().getBlock(); getTileEntity().setOpenFlag(blockData, false); - getTileEntity().playOpenSound(blockData, SoundEffects.BLOCK_BARREL_CLOSE); + getTileEntity().playOpenSound(blockData, SoundEffects.BARREL_CLOSE); } - getTileEntity().opened = false; + getTileEntity().openersCounter.opened = false; } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java index ae735836a..5dc372e7b 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java @@ -31,7 +31,7 @@ public class CraftBeacon extends CraftBlockEntityState impleme if (tileEntity instanceof TileEntityBeacon) { TileEntityBeacon beacon = (TileEntityBeacon) tileEntity; - Collection nms = beacon.getHumansInRange(); + Collection nms = TileEntityBeacon.getHumansInRange(beacon.getWorld(), beacon.getPosition(), beacon.levels); Collection bukkit = new ArrayList(nms.size()); for (EntityHuman human : nms) { @@ -57,7 +57,7 @@ public class CraftBeacon extends CraftBlockEntityState impleme @Override public void setPrimaryEffect(PotionEffectType effect) { - this.getSnapshot().primaryEffect = (effect != null) ? MobEffectList.fromId(effect.getId()) : null; + this.getSnapshot().primaryPower = (effect != null) ? MobEffectList.fromId(effect.getId()) : null; } @Override @@ -67,13 +67,13 @@ public class CraftBeacon extends CraftBlockEntityState impleme @Override public void setSecondaryEffect(PotionEffectType effect) { - this.getSnapshot().secondaryEffect = (effect != null) ? MobEffectList.fromId(effect.getId()) : null; + this.getSnapshot().secondaryPower = (effect != null) ? MobEffectList.fromId(effect.getId()) : null; } @Override public String getCustomName() { TileEntityBeacon beacon = this.getSnapshot(); - return beacon.customName != null ? CraftChatMessage.fromComponent(beacon.customName) : null; + return beacon.name != null ? CraftChatMessage.fromComponent(beacon.name) : null; } @Override @@ -83,16 +83,16 @@ public class CraftBeacon extends CraftBlockEntityState impleme @Override public boolean isLocked() { - return !this.getSnapshot().chestLock.key.isEmpty(); + return !this.getSnapshot().lockKey.key.isEmpty(); } @Override public String getLock() { - return this.getSnapshot().chestLock.key; + return this.getSnapshot().lockKey.key; } @Override public void setLock(String key) { - this.getSnapshot().chestLock = (key == null) ? ChestLock.a : new ChestLock(key); + this.getSnapshot().lockKey = (key == null) ? ChestLock.NO_LOCK : new ChestLock(key); } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java index af691b28b..ed334ebad 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java @@ -26,14 +26,14 @@ public class CraftBeehive extends CraftBlockEntityState imple @Override public Location getFlower() { - BlockPosition flower = getSnapshot().flowerPos; + BlockPosition flower = getSnapshot().savedFlowerPos; 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"); - getSnapshot().flowerPos = (location == null) ? null : new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()); + getSnapshot().savedFlowerPos = (location == null) ? null : new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 255aac080..a5a6e03cd 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -472,6 +472,8 @@ public class CraftBlock implements Block { case BEEHIVE: case BEE_NEST: return new CraftBeehive(this); + case SCULK_SENSOR: + return new CraftSculkSensor(this); default: TileEntity tileEntity = world.getTileEntity(position); if (tileEntity != null) { @@ -583,7 +585,7 @@ public class CraftBlock implements Block { } private static int getPower(int i, IBlockData iblockdata) { - if (!iblockdata.getBlock().a(Blocks.REDSTONE_WIRE)) { + if (!iblockdata.a(Blocks.REDSTONE_WIRE)) { return i; } else { int j = iblockdata.get(BlockRedstoneWire.POWER); @@ -637,7 +639,7 @@ public class CraftBlock implements Block { @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.ORIGIN, direction, getPosition(), false)); + ItemActionContext context = new ItemActionContext(getCraftWorld().getHandle(), null, EnumHand.MAIN_HAND, Items.BONE_MEAL.createItemStack(), new MovingObjectPositionBlock(Vec3D.ZERO, direction, getPosition(), false)); return ItemBoneMeal.applyBonemeal(context) == EnumInteractionResult.SUCCESS; } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java index 524f27830..3cbcc7211 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java @@ -48,7 +48,7 @@ public class CraftBlockEntityState extends CraftBlockState } NBTTagCompound nbtTagCompound = tileEntity.save(new NBTTagCompound()); - T snapshot = (T) TileEntity.create(getHandle(), nbtTagCompound); + T snapshot = (T) TileEntity.create(getPosition(), getHandle(), nbtTagCompound); return snapshot; } @@ -57,10 +57,7 @@ public class CraftBlockEntityState extends CraftBlockState private void copyData(T from, T to) { BlockPosition pos = to.getPosition(); NBTTagCompound nbtTagCompound = from.save(new NBTTagCompound()); - to.load(getHandle(), nbtTagCompound); - - // reset the original position: - to.setPosition(pos); + to.load(nbtTagCompound); } // gets the wrapped TileEntity diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java index b7ce67757..d62b23a6f 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -48,8 +48,8 @@ public class CraftBlockState implements BlockState { return new CraftBlockState(CraftBlock.at(world, pos)); } - public static CraftBlockState getBlockState(net.minecraft.world.level.World world, net.minecraft.core.BlockPosition pos, int flag) { - return new CraftBlockState(world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()), flag); + public static CraftBlockState getBlockState(GeneratorAccess world, net.minecraft.core.BlockPosition pos, int flag) { + return new CraftBlockState(CraftBlock.at(world, pos), flag); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java index f963cdde4..580f187e5 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java @@ -43,11 +43,11 @@ public class CraftBrewingStand extends CraftContainer im @Override public int getFuelLevel() { - return this.getSnapshot().fuelLevel; + return this.getSnapshot().fuel; } @Override public void setFuelLevel(int level) { - this.getSnapshot().fuelLevel = level; + this.getSnapshot().fuel = level; } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCampfire.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCampfire.java index 326729103..4b924b7ad 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftCampfire.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCampfire.java @@ -35,21 +35,21 @@ public class CraftCampfire extends CraftBlockEntityState imp @Override public int getCookTime(int index) { - return getSnapshot().cookingTimes[index]; + return getSnapshot().cookingProgress[index]; } @Override public void setCookTime(int index, int cookTime) { - getSnapshot().cookingTimes[index] = cookTime; + getSnapshot().cookingProgress[index] = cookTime; } @Override public int getCookTimeTotal(int index) { - return getSnapshot().cookingTotalTimes[index]; + return getSnapshot().cookingTime[index]; } @Override public void setCookTimeTotal(int index, int cookTimeTotal) { - getSnapshot().cookingTotalTimes[index] = cookTimeTotal; + getSnapshot().cookingTime[index] = cookTimeTotal; } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java index 486fa8937..4409edb26 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java @@ -5,6 +5,7 @@ import net.minecraft.world.ITileInventory; import net.minecraft.world.level.block.BlockChest; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.TileEntityChest; +import net.minecraft.world.level.block.state.IBlockData; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Chest; @@ -59,22 +60,22 @@ public class CraftChest extends CraftLootable implements Chest @Override public void open() { requirePlaced(); - if (!getTileEntity().opened) { - net.minecraft.world.level.block.Block block = getTileEntity().getBlock().getBlock(); - getTileEntity().getWorld().playBlockAction(getTileEntity().getPosition(), block, 1, getTileEntity().viewingCount + 1); - getTileEntity().playOpenSound(SoundEffects.BLOCK_CHEST_OPEN); + if (!getTileEntity().openersCounter.opened) { + IBlockData block = getTileEntity().getBlock(); + getTileEntity().getWorld().playBlockAction(getPosition(), block.getBlock(), 1, getTileEntity().openersCounter.getOpenerCount() + 1); + TileEntityChest.playOpenSound(getTileEntity().getWorld(), getPosition(), block, SoundEffects.CHEST_OPEN); } - getTileEntity().opened = true; + getTileEntity().openersCounter.opened = true; } @Override public void close() { requirePlaced(); - if (getTileEntity().opened) { - net.minecraft.world.level.block.Block block = getTileEntity().getBlock().getBlock(); - getTileEntity().getWorld().playBlockAction(getTileEntity().getPosition(), block, 1, 0); - getTileEntity().playOpenSound(SoundEffects.BLOCK_CHEST_CLOSE); + if (getTileEntity().openersCounter.opened) { + IBlockData block = getTileEntity().getBlock(); + getTileEntity().getWorld().playBlockAction(getPosition(), block.getBlock(), 1, 0); + TileEntityChest.playOpenSound(getTileEntity().getWorld(), getPosition(), block, SoundEffects.CHEST_OPEN); } - getTileEntity().opened = false; + getTileEntity().openersCounter.opened = false; } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java index e8ce890c5..2a680527b 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java @@ -19,23 +19,23 @@ public abstract class CraftContainer extends Craf @Override public boolean isLocked() { - return !this.getSnapshot().chestLock.key.isEmpty(); + return !this.getSnapshot().lockKey.key.isEmpty(); } @Override public String getLock() { - return this.getSnapshot().chestLock.key; + return this.getSnapshot().lockKey.key; } @Override public void setLock(String key) { - this.getSnapshot().chestLock = (key == null) ? ChestLock.a : new ChestLock(key); + this.getSnapshot().lockKey = (key == null) ? ChestLock.NO_LOCK : new ChestLock(key); } @Override public String getCustomName() { T container = this.getSnapshot(); - return container.customName != null ? CraftChatMessage.fromComponent(container.getCustomName()) : null; + return container.name != null ? CraftChatMessage.fromComponent(container.getCustomName()) : null; } @Override @@ -47,7 +47,7 @@ public abstract class CraftContainer extends Craf public void applyTo(T container) { super.applyTo(container); - if (this.getSnapshot().customName == null) { + if (this.getSnapshot().name == null) { container.setCustomName(null); } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java index 28295ebd3..319cac3e6 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.block; import com.google.common.base.Preconditions; +import net.minecraft.core.BlockPosition; import net.minecraft.resources.MinecraftKey; import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.level.block.entity.TileEntityMobSpawner; @@ -21,7 +22,7 @@ public class CraftCreatureSpawner extends CraftBlockEntityState extends CraftCon @Override public short getBurnTime() { - return (short) this.getSnapshot().burnTime; + return (short) this.getSnapshot().litTime; } @Override public void setBurnTime(short burnTime) { - this.getSnapshot().burnTime = burnTime; + this.getSnapshot().litTime = burnTime; // SPIGOT-844: Allow lighting and relighting using this API this.data = this.data.set(BlockFurnace.LIT, burnTime > 0); } @Override public short getCookTime() { - return (short) this.getSnapshot().cookTime; + return (short) this.getSnapshot().cookingProgress; } @Override public void setCookTime(short cookTime) { - this.getSnapshot().cookTime = cookTime; + this.getSnapshot().cookingProgress = cookTime; } @Override public int getCookTimeTotal() { - return this.getSnapshot().cookTimeTotal; + return this.getSnapshot().cookingTotalTime; } @Override public void setCookTimeTotal(int cookTimeTotal) { - this.getSnapshot().cookTimeTotal = cookTimeTotal; + this.getSnapshot().cookingTotalTime = cookTimeTotal; } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftLectern.java b/src/main/java/org/bukkit/craftbukkit/block/CraftLectern.java index f56ec524c..a80e13e6a 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftLectern.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftLectern.java @@ -30,7 +30,7 @@ public class CraftLectern extends CraftBlockEntityState imple @Override public Inventory getSnapshotInventory() { - return new CraftInventoryLectern(this.getSnapshot().inventory); + return new CraftInventoryLectern(this.getSnapshot().bookAccess); } @Override @@ -39,7 +39,7 @@ public class CraftLectern extends CraftBlockEntityState imple return this.getSnapshotInventory(); } - return new CraftInventoryLectern(this.getTileEntity().inventory); + return new CraftInventoryLectern(this.getTileEntity().bookAccess); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSculkSensor.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSculkSensor.java new file mode 100644 index 000000000..04ad11f87 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSculkSensor.java @@ -0,0 +1,29 @@ +package org.bukkit.craftbukkit.block; + +import com.google.common.base.Preconditions; +import net.minecraft.world.level.block.entity.SculkSensorBlockEntity; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.SculkSensor; + +public class CraftSculkSensor extends CraftBlockEntityState implements SculkSensor { + + public CraftSculkSensor(final Block block) { + super(block, SculkSensorBlockEntity.class); + } + + public CraftSculkSensor(final Material material, final SculkSensorBlockEntity te) { + super(material, te); + } + + @Override + public int getLastVibrationFrequency() { + return getTileEntity().getLastVibrationFrequency(); + } + + @Override + public void setLastVibrationFrequency(int lastVibrationFrequency) { + Preconditions.checkArgument(0 <= lastVibrationFrequency && lastVibrationFrequency <= 15, "Vibration frequency must be between 0-15"); + getTileEntity().lastVibrationFrequency = lastVibrationFrequency; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java b/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java index fcf2a1810..86fd466f7 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java @@ -51,7 +51,7 @@ public class CraftShulkerBox extends CraftLootable impleme if (!getTileEntity().opened) { World world = getTileEntity().getWorld(); world.playBlockAction(getPosition(), getTileEntity().getBlock().getBlock(), 1, 1); - world.playSound(null, getPosition(), SoundEffects.BLOCK_SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F); + world.playSound(null, getPosition(), SoundEffects.SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F); } getTileEntity().opened = true; } @@ -62,7 +62,7 @@ public class CraftShulkerBox extends CraftLootable impleme if (getTileEntity().opened) { World world = getTileEntity().getWorld(); world.playBlockAction(getPosition(), getTileEntity().getBlock().getBlock(), 1, 0); - world.playSound(null, getPosition(), SoundEffects.BLOCK_SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F); + 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/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java index 50d3f9ea1..b4bedba81 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java @@ -29,8 +29,8 @@ public class CraftSign extends CraftBlockEntityState implements if (lines == null) { // Lazy initialization: TileEntitySign sign = this.getSnapshot(); - lines = new String[sign.lines.length]; - System.arraycopy(revertComponents(sign.lines), 0, lines, 0, lines.length); + lines = new String[sign.messages.length]; + System.arraycopy(revertComponents(sign.messages), 0, lines, 0, lines.length); originalLines = new String[lines.length]; System.arraycopy(lines, 0, originalLines, 0, originalLines.length); } @@ -57,6 +57,16 @@ public class CraftSign extends CraftBlockEntityState implements getSnapshot().isEditable = editable; } + @Override + public boolean isGlowingText() { + return getSnapshot().hasGlowingText(); + } + + @Override + public void setGlowingText(boolean glowing) { + getSnapshot().setHasGlowingText(glowing); + } + @Override public DyeColor getColor() { return DyeColor.getByWoolData((byte) getSnapshot().getColor().getColorIndex()); @@ -77,7 +87,7 @@ public class CraftSign extends CraftBlockEntityState implements if (line.equals(originalLines[i])) { continue; // The line contents are still the same, skip. } - sign.lines[i] = CraftChatMessage.fromString(line)[0]; + sign.a(i, CraftChatMessage.fromString(line)[0]); } } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java index 80ee7ab69..22aa6479c 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java @@ -33,7 +33,7 @@ public class CraftSkull extends CraftBlockEntityState implement public void load(TileEntitySkull skull) { super.load(skull); - profile = skull.gameProfile; + profile = skull.owner; } static int getSkullType(SkullType type) { diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java index 037d8abf4..02482904d 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java @@ -59,7 +59,7 @@ public class CraftStructureBlock extends CraftBlockEntityState + register(net.minecraft.world.level.block.AmethystClusterBlock.class, org.bukkit.craftbukkit.block.impl.CraftAmethystCluster::new); + register(net.minecraft.world.level.block.BigDripleafBlock.class, org.bukkit.craftbukkit.block.impl.CraftBigDripleaf::new); + register(net.minecraft.world.level.block.BigDripleafStemBlock.class, org.bukkit.craftbukkit.block.impl.CraftBigDripleafStem::new); register(net.minecraft.world.level.block.BlockAnvil.class, org.bukkit.craftbukkit.block.impl.CraftAnvil::new); register(net.minecraft.world.level.block.BlockBamboo.class, org.bukkit.craftbukkit.block.impl.CraftBamboo::new); register(net.minecraft.world.level.block.BlockBanner.class, org.bukkit.craftbukkit.block.impl.CraftBanner::new); @@ -358,7 +361,6 @@ public class CraftBlockData implements BlockData { register(net.minecraft.world.level.block.BlockCake.class, org.bukkit.craftbukkit.block.impl.CraftCake::new); register(net.minecraft.world.level.block.BlockCampfire.class, org.bukkit.craftbukkit.block.impl.CraftCampfire::new); register(net.minecraft.world.level.block.BlockCarrots.class, org.bukkit.craftbukkit.block.impl.CraftCarrots::new); - register(net.minecraft.world.level.block.BlockCauldron.class, org.bukkit.craftbukkit.block.impl.CraftCauldron::new); register(net.minecraft.world.level.block.BlockChain.class, org.bukkit.craftbukkit.block.impl.CraftChain::new); register(net.minecraft.world.level.block.BlockChest.class, org.bukkit.craftbukkit.block.impl.CraftChest::new); register(net.minecraft.world.level.block.BlockChestTrapped.class, org.bukkit.craftbukkit.block.impl.CraftChestTrapped::new); @@ -413,9 +415,6 @@ public class CraftBlockData implements BlockData { register(net.minecraft.world.level.block.BlockNetherWart.class, org.bukkit.craftbukkit.block.impl.CraftNetherWart::new); register(net.minecraft.world.level.block.BlockNote.class, org.bukkit.craftbukkit.block.impl.CraftNote::new); register(net.minecraft.world.level.block.BlockObserver.class, org.bukkit.craftbukkit.block.impl.CraftObserver::new); - register(net.minecraft.world.level.block.piston.BlockPiston.class, org.bukkit.craftbukkit.block.impl.CraftPiston::new); - register(net.minecraft.world.level.block.piston.BlockPistonExtension.class, org.bukkit.craftbukkit.block.impl.CraftPistonExtension::new); - register(net.minecraft.world.level.block.piston.BlockPistonMoving.class, org.bukkit.craftbukkit.block.impl.CraftPistonMoving::new); register(net.minecraft.world.level.block.BlockPortal.class, org.bukkit.craftbukkit.block.impl.CraftPortal::new); register(net.minecraft.world.level.block.BlockPotatoes.class, org.bukkit.craftbukkit.block.impl.CraftPotatoes::new); register(net.minecraft.world.level.block.BlockPoweredRail.class, org.bukkit.craftbukkit.block.impl.CraftPoweredRail::new); @@ -455,7 +454,6 @@ public class CraftBlockData implements BlockData { register(net.minecraft.world.level.block.BlockTNT.class, org.bukkit.craftbukkit.block.impl.CraftTNT::new); register(net.minecraft.world.level.block.BlockTallPlant.class, org.bukkit.craftbukkit.block.impl.CraftTallPlant::new); register(net.minecraft.world.level.block.BlockTallPlantFlower.class, org.bukkit.craftbukkit.block.impl.CraftTallPlantFlower::new); - register(net.minecraft.world.level.block.BlockTallSeaGrass.class, org.bukkit.craftbukkit.block.impl.CraftTallSeaGrass::new); register(net.minecraft.world.level.block.BlockTarget.class, org.bukkit.craftbukkit.block.impl.CraftTarget::new); register(net.minecraft.world.level.block.BlockTorchWall.class, org.bukkit.craftbukkit.block.impl.CraftTorchWall::new); register(net.minecraft.world.level.block.BlockTrapdoor.class, org.bukkit.craftbukkit.block.impl.CraftTrapdoor::new); @@ -469,6 +467,26 @@ public class CraftBlockData implements BlockData { register(net.minecraft.world.level.block.BlockWitherSkull.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkull::new); register(net.minecraft.world.level.block.BlockWitherSkullWall.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkullWall::new); register(net.minecraft.world.level.block.BlockWoodButton.class, org.bukkit.craftbukkit.block.impl.CraftWoodButton::new); + register(net.minecraft.world.level.block.CandleBlock.class, org.bukkit.craftbukkit.block.impl.CraftCandle::new); + register(net.minecraft.world.level.block.CandleCakeBlock.class, org.bukkit.craftbukkit.block.impl.CraftCandleCake::new); + register(net.minecraft.world.level.block.CaveVinesBlock.class, org.bukkit.craftbukkit.block.impl.CraftCaveVines::new); + register(net.minecraft.world.level.block.CaveVinesPlantBlock.class, org.bukkit.craftbukkit.block.impl.CraftCaveVinesPlant::new); + register(net.minecraft.world.level.block.GlowLichenBlock.class, org.bukkit.craftbukkit.block.impl.CraftGlowLichen::new); + register(net.minecraft.world.level.block.HangingRootsBlock.class, org.bukkit.craftbukkit.block.impl.CraftHangingRoots::new); + register(net.minecraft.world.level.block.InfestedRotatedPillarBlock.class, org.bukkit.craftbukkit.block.impl.CraftInfestedRotatedPillar::new); + register(net.minecraft.world.level.block.LayeredCauldronBlock.class, org.bukkit.craftbukkit.block.impl.CraftLayeredCauldron::new); + register(net.minecraft.world.level.block.LightBlock.class, org.bukkit.craftbukkit.block.impl.CraftLight::new); + register(net.minecraft.world.level.block.LightningRodBlock.class, org.bukkit.craftbukkit.block.impl.CraftLightningRod::new); + register(net.minecraft.world.level.block.PointedDripstoneBlock.class, org.bukkit.craftbukkit.block.impl.CraftPointedDripstone::new); + register(net.minecraft.world.level.block.PowderSnowCauldronBlock.class, org.bukkit.craftbukkit.block.impl.CraftPowderSnowCauldron::new); + register(net.minecraft.world.level.block.SculkSensorBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkSensor::new); + register(net.minecraft.world.level.block.SmallDripleafBlock.class, org.bukkit.craftbukkit.block.impl.CraftSmallDripleaf::new); + register(net.minecraft.world.level.block.TallSeagrassBlock.class, org.bukkit.craftbukkit.block.impl.CraftTallSeagrass::new); + register(net.minecraft.world.level.block.WeatheringCopperSlabBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperSlab::new); + register(net.minecraft.world.level.block.WeatheringCopperStairBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperStair::new); + register(net.minecraft.world.level.block.piston.BlockPiston.class, org.bukkit.craftbukkit.block.impl.CraftPiston::new); + register(net.minecraft.world.level.block.piston.BlockPistonExtension.class, org.bukkit.craftbukkit.block.impl.CraftPistonExtension::new); + register(net.minecraft.world.level.block.piston.BlockPistonMoving.class, org.bukkit.craftbukkit.block.impl.CraftPistonMoving::new); // } diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBigDripleaf.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBigDripleaf.java new file mode 100644 index 000000000..bd509f2f1 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBigDripleaf.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.BigDripleaf; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftBigDripleaf extends CraftBlockData implements BigDripleaf { + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum TILT = getEnum("tilt"); + + @Override + public Tilt getTilt() { + return get(TILT, org.bukkit.block.data.type.BigDripleaf.Tilt.class); + } + + @Override + public void setTilt(org.bukkit.block.data.type.BigDripleaf.Tilt tilt) { + set(TILT, tilt); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCandle.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCandle.java new file mode 100644 index 000000000..214779784 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCandle.java @@ -0,0 +1,24 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Candle; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftCandle extends CraftBlockData implements Candle { + + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger CANDLES = getInteger("candles"); + + @Override + public int getCandles() { + return get(CANDLES); + } + + @Override + public void setCandles(int candles) { + set(CANDLES, candles); + } + + @Override + public int getMaximumCandles() { + return getMax(CANDLES); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCaveVinesPlant.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCaveVinesPlant.java new file mode 100644 index 000000000..5cd6f7ef4 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCaveVinesPlant.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.CaveVinesPlant; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftCaveVinesPlant extends CraftBlockData implements CaveVinesPlant { + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean BERRIES = getBoolean("berries"); + + @Override + public boolean isBerries() { + return get(BERRIES); + } + + @Override + public void setBerries(boolean berries) { + set(BERRIES, berries); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPointedDripstone.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPointedDripstone.java new file mode 100644 index 000000000..f677c007a --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPointedDripstone.java @@ -0,0 +1,35 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.PointedDripstone; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftPointedDripstone extends CraftBlockData implements PointedDripstone { + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum VERTICAL_DIRECTION = getEnum("vertical_direction"); + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum THICKNESS = getEnum("thickness"); + + @Override + public org.bukkit.block.BlockFace getVerticalDirection() { + return get(VERTICAL_DIRECTION, org.bukkit.block.BlockFace.class); + } + + @Override + public void setVerticalDirection(org.bukkit.block.BlockFace direction) { + set(VERTICAL_DIRECTION, direction); + } + + @Override + public java.util.Set getVerticalDirections() { + return getValues(VERTICAL_DIRECTION, org.bukkit.block.BlockFace.class); + } + + @Override + public org.bukkit.block.data.type.PointedDripstone.Thickness getThickness() { + return get(THICKNESS, org.bukkit.block.data.type.PointedDripstone.Thickness.class); + } + + @Override + public void setThickness(org.bukkit.block.data.type.PointedDripstone.Thickness thickness) { + set(THICKNESS, thickness); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSculkSensor.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSculkSensor.java new file mode 100644 index 000000000..c1a764879 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSculkSensor.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.SculkSensor; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftSculkSensor extends CraftBlockData implements SculkSensor { + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum PHASE = getEnum("sculk_sensor_phase"); + + @Override + public org.bukkit.block.data.type.SculkSensor.Phase getPhase() { + return get(PHASE, org.bukkit.block.data.type.SculkSensor.Phase.class); + } + + @Override + public void setPhase(org.bukkit.block.data.type.SculkSensor.Phase phase) { + set(PHASE, phase); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftAmethystCluster.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftAmethystCluster.java new file mode 100644 index 000000000..311ce20cf --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftAmethystCluster.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftAmethystCluster extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.AmethystCluster, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged { + + public CraftAmethystCluster() { + super(); + } + + public CraftAmethystCluster(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACING = getEnum(net.minecraft.world.level.block.AmethystClusterBlock.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.AmethystClusterBlock.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleaf.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleaf.java new file mode 100644 index 000000000..435386dbf --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleaf.java @@ -0,0 +1,62 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +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() { + super(); + } + + public CraftBigDripleaf(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftBigDripleaf + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum TILT = getEnum(net.minecraft.world.level.block.BigDripleafBlock.class, "tilt"); + + @Override + public Tilt getTilt() { + return get(TILT, org.bukkit.block.data.type.BigDripleaf.Tilt.class); + } + + @Override + public void setTilt(org.bukkit.block.data.type.BigDripleaf.Tilt tilt) { + set(TILT, tilt); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACING = getEnum(net.minecraft.world.level.block.BigDripleafBlock.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.BigDripleafBlock.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleafStem.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleafStem.java new file mode 100644 index 000000000..1c054426f --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleafStem.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftBigDripleafStem extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Dripleaf, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged { + + public CraftBigDripleafStem() { + super(); + } + + public CraftBigDripleafStem(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACING = getEnum(net.minecraft.world.level.block.BigDripleafStemBlock.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.BigDripleafStemBlock.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCandle.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCandle.java new file mode 100644 index 000000000..d33acb15d --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCandle.java @@ -0,0 +1,62 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftCandle extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Candle, org.bukkit.block.data.Lightable, org.bukkit.block.data.Waterlogged { + + public CraftCandle() { + super(); + } + + public CraftCandle(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftCandle + + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger CANDLES = getInteger(net.minecraft.world.level.block.CandleBlock.class, "candles"); + + @Override + public int getCandles() { + return get(CANDLES); + } + + @Override + public void setCandles(int candles) { + set(CANDLES, candles); + } + + @Override + public int getMaximumCandles() { + return getMax(CANDLES); + } + + // org.bukkit.craftbukkit.block.data.CraftLightable + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean LIT = getBoolean(net.minecraft.world.level.block.CandleBlock.class, "lit"); + + @Override + public boolean isLit() { + return get(LIT); + } + + @Override + public void setLit(boolean lit) { + set(LIT, lit); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.CandleBlock.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCandleCake.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCandleCake.java new file mode 100644 index 000000000..bbcc97552 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCandleCake.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftCandleCake extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Lightable { + + public CraftCandleCake() { + super(); + } + + public CraftCandleCake(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftLightable + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean LIT = getBoolean(net.minecraft.world.level.block.CandleCakeBlock.class, "lit"); + + @Override + public boolean isLit() { + return get(LIT); + } + + @Override + public void setLit(boolean lit) { + set(LIT, lit); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCaveVines.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCaveVines.java new file mode 100644 index 000000000..92e5a4c7e --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCaveVines.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftCaveVines extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.CaveVines, org.bukkit.block.data.Ageable, org.bukkit.block.data.type.CaveVinesPlant { + + public CraftCaveVines() { + super(); + } + + public CraftCaveVines(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftAgeable + + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger AGE = getInteger(net.minecraft.world.level.block.CaveVinesBlock.class, "age"); + + @Override + public int getAge() { + return get(AGE); + } + + @Override + public void setAge(int age) { + set(AGE, age); + } + + @Override + public int getMaximumAge() { + return getMax(AGE); + } + + // org.bukkit.craftbukkit.block.data.type.CraftCaveVinesPlant + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean BERRIES = getBoolean(net.minecraft.world.level.block.CaveVinesBlock.class, "berries"); + + @Override + public boolean isBerries() { + return get(BERRIES); + } + + @Override + public void setBerries(boolean berries) { + set(BERRIES, berries); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCaveVinesPlant.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCaveVinesPlant.java new file mode 100644 index 000000000..03721a561 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCaveVinesPlant.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftCaveVinesPlant extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.CaveVinesPlant { + + public CraftCaveVinesPlant() { + super(); + } + + public CraftCaveVinesPlant(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftCaveVinesPlant + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean BERRIES = getBoolean(net.minecraft.world.level.block.CaveVinesPlantBlock.class, "berries"); + + @Override + public boolean isBerries() { + return get(BERRIES); + } + + @Override + public void setBerries(boolean berries) { + set(BERRIES, berries); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGlowLichen.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGlowLichen.java new file mode 100644 index 000000000..1c82832e3 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGlowLichen.java @@ -0,0 +1,79 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftGlowLichen extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.GlowLichen, org.bukkit.block.data.MultipleFacing, org.bukkit.block.data.Waterlogged { + + public CraftGlowLichen() { + super(); + } + + public CraftGlowLichen(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftMultipleFacing + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean[] FACES = new net.minecraft.world.level.block.state.properties.BlockStateBoolean[]{ + getBoolean(net.minecraft.world.level.block.GlowLichenBlock.class, "north", true), getBoolean(net.minecraft.world.level.block.GlowLichenBlock.class, "east", true), getBoolean(net.minecraft.world.level.block.GlowLichenBlock.class, "south", true), getBoolean(net.minecraft.world.level.block.GlowLichenBlock.class, "west", true), getBoolean(net.minecraft.world.level.block.GlowLichenBlock.class, "up", true), getBoolean(net.minecraft.world.level.block.GlowLichenBlock.class, "down", true) + }; + + @Override + public boolean hasFace(org.bukkit.block.BlockFace face) { + net.minecraft.world.level.block.state.properties.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + return get(state); + } + + @Override + public void setFace(org.bukkit.block.BlockFace face, boolean has) { + net.minecraft.world.level.block.state.properties.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + set(state, has); + } + + @Override + public java.util.Set getFaces() { + com.google.common.collect.ImmutableSet.Builder faces = com.google.common.collect.ImmutableSet.builder(); + + for (int i = 0; i < FACES.length; i++) { + if (FACES[i] != null && get(FACES[i])) { + faces.add(org.bukkit.block.BlockFace.values()[i]); + } + } + + return faces.build(); + } + + @Override + public java.util.Set getAllowedFaces() { + com.google.common.collect.ImmutableSet.Builder faces = com.google.common.collect.ImmutableSet.builder(); + + for (int i = 0; i < FACES.length; i++) { + if (FACES[i] != null) { + faces.add(org.bukkit.block.BlockFace.values()[i]); + } + } + + return faces.build(); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.GlowLichenBlock.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHangingRoots.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHangingRoots.java new file mode 100644 index 000000000..01418e892 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHangingRoots.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftHangingRoots extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Waterlogged { + + public CraftHangingRoots() { + super(); + } + + public CraftHangingRoots(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.HangingRootsBlock.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftInfestedRotatedPillar.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftInfestedRotatedPillar.java new file mode 100644 index 000000000..e7a67d4d4 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftInfestedRotatedPillar.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftInfestedRotatedPillar extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Orientable { + + public CraftInfestedRotatedPillar() { + super(); + } + + public CraftInfestedRotatedPillar(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftOrientable + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum AXIS = getEnum(net.minecraft.world.level.block.InfestedRotatedPillarBlock.class, "axis"); + + @Override + public org.bukkit.Axis getAxis() { + return get(AXIS, org.bukkit.Axis.class); + } + + @Override + public void setAxis(org.bukkit.Axis axis) { + set(AXIS, axis); + } + + @Override + public java.util.Set getAxes() { + return getValues(AXIS, org.bukkit.Axis.class); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLayeredCauldron.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLayeredCauldron.java new file mode 100644 index 000000000..d041159f2 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLayeredCauldron.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftLayeredCauldron extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Levelled { + + public CraftLayeredCauldron() { + super(); + } + + public CraftLayeredCauldron(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftLevelled + + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger LEVEL = getInteger(net.minecraft.world.level.block.LayeredCauldronBlock.class, "level"); + + @Override + public int getLevel() { + return get(LEVEL); + } + + @Override + public void setLevel(int level) { + set(LEVEL, level); + } + + @Override + public int getMaximumLevel() { + return getMax(LEVEL); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLight.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLight.java new file mode 100644 index 000000000..b09f55f63 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLight.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftLight extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Light, org.bukkit.block.data.Levelled, org.bukkit.block.data.Waterlogged { + + public CraftLight() { + super(); + } + + public CraftLight(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftLevelled + + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger LEVEL = getInteger(net.minecraft.world.level.block.LightBlock.class, "level"); + + @Override + public int getLevel() { + return get(LEVEL); + } + + @Override + public void setLevel(int level) { + set(LEVEL, level); + } + + @Override + public int getMaximumLevel() { + return getMax(LEVEL); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.LightBlock.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLightningRod.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLightningRod.java new file mode 100644 index 000000000..5d3446ea6 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLightningRod.java @@ -0,0 +1,62 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftLightningRod extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.LightningRod, org.bukkit.block.data.Directional, org.bukkit.block.data.Powerable, org.bukkit.block.data.Waterlogged { + + public CraftLightningRod() { + super(); + } + + public CraftLightningRod(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACING = getEnum(net.minecraft.world.level.block.LightningRodBlock.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } + + // org.bukkit.craftbukkit.block.data.CraftPowerable + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean POWERED = getBoolean(net.minecraft.world.level.block.LightningRodBlock.class, "powered"); + + @Override + public boolean isPowered() { + return get(POWERED); + } + + @Override + public void setPowered(boolean powered) { + set(POWERED, powered); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.LightningRodBlock.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMinecartDetector.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMinecartDetector.java index 61e29dd31..bd02bb1b2 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMinecartDetector.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMinecartDetector.java @@ -3,7 +3,7 @@ */ package org.bukkit.craftbukkit.block.impl; -public final class CraftMinecartDetector extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.RedstoneRail, org.bukkit.block.data.Powerable, org.bukkit.block.data.Rail { +public final class CraftMinecartDetector extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.RedstoneRail, org.bukkit.block.data.Powerable, org.bukkit.block.data.Rail, org.bukkit.block.data.Waterlogged { public CraftMinecartDetector() { super(); @@ -45,4 +45,18 @@ public final class CraftMinecartDetector extends org.bukkit.craftbukkit.block.da public java.util.Set getShapes() { return getValues(SHAPE, org.bukkit.block.data.Rail.Shape.class); } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.BlockMinecartDetector.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMinecartTrack.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMinecartTrack.java index ac02a1bea..9ab6b8839 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMinecartTrack.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMinecartTrack.java @@ -3,7 +3,7 @@ */ package org.bukkit.craftbukkit.block.impl; -public final class CraftMinecartTrack extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Rail { +public final class CraftMinecartTrack extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Rail, org.bukkit.block.data.Waterlogged { public CraftMinecartTrack() { super(); @@ -31,4 +31,18 @@ public final class CraftMinecartTrack extends org.bukkit.craftbukkit.block.data. public java.util.Set getShapes() { return getValues(SHAPE, org.bukkit.block.data.Rail.Shape.class); } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.BlockMinecartTrack.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPointedDripstone.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPointedDripstone.java new file mode 100644 index 000000000..a1b320d77 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPointedDripstone.java @@ -0,0 +1,59 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftPointedDripstone extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.PointedDripstone, org.bukkit.block.data.Waterlogged { + + public CraftPointedDripstone() { + super(); + } + + public CraftPointedDripstone(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftPointedDripstone + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum VERTICAL_DIRECTION = getEnum(net.minecraft.world.level.block.PointedDripstoneBlock.class, "vertical_direction"); + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum THICKNESS = getEnum(net.minecraft.world.level.block.PointedDripstoneBlock.class, "thickness"); + + @Override + public org.bukkit.block.BlockFace getVerticalDirection() { + return get(VERTICAL_DIRECTION, org.bukkit.block.BlockFace.class); + } + + @Override + public void setVerticalDirection(org.bukkit.block.BlockFace direction) { + set(VERTICAL_DIRECTION, direction); + } + + @Override + public java.util.Set getVerticalDirections() { + return getValues(VERTICAL_DIRECTION, org.bukkit.block.BlockFace.class); + } + + @Override + public org.bukkit.block.data.type.PointedDripstone.Thickness getThickness() { + return get(THICKNESS, org.bukkit.block.data.type.PointedDripstone.Thickness.class); + } + + @Override + public void setThickness(org.bukkit.block.data.type.PointedDripstone.Thickness thickness) { + set(THICKNESS, thickness); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.PointedDripstoneBlock.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPowderSnowCauldron.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPowderSnowCauldron.java new file mode 100644 index 000000000..ec98fc27f --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPowderSnowCauldron.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftPowderSnowCauldron extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Levelled { + + public CraftPowderSnowCauldron() { + super(); + } + + public CraftPowderSnowCauldron(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftLevelled + + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger LEVEL = getInteger(net.minecraft.world.level.block.PowderSnowCauldronBlock.class, "level"); + + @Override + public int getLevel() { + return get(LEVEL); + } + + @Override + public void setLevel(int level) { + set(LEVEL, level); + } + + @Override + public int getMaximumLevel() { + return getMax(LEVEL); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPoweredRail.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPoweredRail.java index c8dc7e331..dd7303234 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPoweredRail.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPoweredRail.java @@ -3,7 +3,7 @@ */ package org.bukkit.craftbukkit.block.impl; -public final class CraftPoweredRail extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.RedstoneRail, org.bukkit.block.data.Powerable, org.bukkit.block.data.Rail { +public final class CraftPoweredRail extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.RedstoneRail, org.bukkit.block.data.Powerable, org.bukkit.block.data.Rail, org.bukkit.block.data.Waterlogged { public CraftPoweredRail() { super(); @@ -45,4 +45,18 @@ public final class CraftPoweredRail extends org.bukkit.craftbukkit.block.data.Cr public java.util.Set getShapes() { return getValues(SHAPE, org.bukkit.block.data.Rail.Shape.class); } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.BlockPoweredRail.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSculkSensor.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSculkSensor.java new file mode 100644 index 000000000..8ba6b02b7 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSculkSensor.java @@ -0,0 +1,62 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftSculkSensor extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.SculkSensor, org.bukkit.block.data.AnaloguePowerable, org.bukkit.block.data.Waterlogged { + + public CraftSculkSensor() { + super(); + } + + public CraftSculkSensor(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftSculkSensor + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum PHASE = getEnum(net.minecraft.world.level.block.SculkSensorBlock.class, "sculk_sensor_phase"); + + @Override + public org.bukkit.block.data.type.SculkSensor.Phase getPhase() { + return get(PHASE, org.bukkit.block.data.type.SculkSensor.Phase.class); + } + + @Override + public void setPhase(org.bukkit.block.data.type.SculkSensor.Phase phase) { + set(PHASE, phase); + } + + // org.bukkit.craftbukkit.block.data.CraftAnaloguePowerable + + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger POWER = getInteger(net.minecraft.world.level.block.SculkSensorBlock.class, "power"); + + @Override + public int getPower() { + return get(POWER); + } + + @Override + public void setPower(int power) { + set(POWER, power); + } + + @Override + public int getMaximumPower() { + return getMax(POWER); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.SculkSensorBlock.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSmallDripleaf.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSmallDripleaf.java new file mode 100644 index 000000000..3c41d44bb --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSmallDripleaf.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftSmallDripleaf extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Dripleaf, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged { + + public CraftSmallDripleaf() { + super(); + } + + public CraftSmallDripleaf(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACING = getEnum(net.minecraft.world.level.block.SmallDripleafBlock.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.SmallDripleafBlock.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallSeaGrass.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallSeagrass.java similarity index 77% rename from src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallSeaGrass.java rename to src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallSeagrass.java index af8178b35..2cd6f5526 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallSeaGrass.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallSeagrass.java @@ -3,19 +3,19 @@ */ package org.bukkit.craftbukkit.block.impl; -public final class CraftTallSeaGrass extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Bisected { +public final class CraftTallSeagrass extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Bisected { - public CraftTallSeaGrass() { + public CraftTallSeagrass() { super(); } - public CraftTallSeaGrass(net.minecraft.world.level.block.state.IBlockData state) { + public CraftTallSeagrass(net.minecraft.world.level.block.state.IBlockData state) { super(state); } // org.bukkit.craftbukkit.block.data.CraftBisected - private static final net.minecraft.world.level.block.state.properties.BlockStateEnum HALF = getEnum(net.minecraft.world.level.block.BlockTallSeaGrass.class, "half"); + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum HALF = getEnum(net.minecraft.world.level.block.TallSeagrassBlock.class, "half"); @Override public org.bukkit.block.data.Bisected.Half getHalf() { diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperSlab.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperSlab.java new file mode 100644 index 000000000..4b62dc648 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperSlab.java @@ -0,0 +1,43 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftWeatheringCopperSlab extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Slab, org.bukkit.block.data.Waterlogged { + + public CraftWeatheringCopperSlab() { + super(); + } + + public CraftWeatheringCopperSlab(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftSlab + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum TYPE = getEnum(net.minecraft.world.level.block.WeatheringCopperSlabBlock.class, "type"); + + @Override + public org.bukkit.block.data.type.Slab.Type getType() { + return get(TYPE, org.bukkit.block.data.type.Slab.Type.class); + } + + @Override + public void setType(org.bukkit.block.data.type.Slab.Type type) { + set(TYPE, type); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.WeatheringCopperSlabBlock.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperStair.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperStair.java new file mode 100644 index 000000000..41f34f984 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperStair.java @@ -0,0 +1,76 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftWeatheringCopperStair extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Stairs, org.bukkit.block.data.Bisected, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged { + + public CraftWeatheringCopperStair() { + super(); + } + + public CraftWeatheringCopperStair(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftStairs + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum SHAPE = getEnum(net.minecraft.world.level.block.WeatheringCopperStairBlock.class, "shape"); + + @Override + public org.bukkit.block.data.type.Stairs.Shape getShape() { + return get(SHAPE, org.bukkit.block.data.type.Stairs.Shape.class); + } + + @Override + public void setShape(org.bukkit.block.data.type.Stairs.Shape shape) { + set(SHAPE, shape); + } + + // org.bukkit.craftbukkit.block.data.CraftBisected + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum HALF = getEnum(net.minecraft.world.level.block.WeatheringCopperStairBlock.class, "half"); + + @Override + public org.bukkit.block.data.Bisected.Half getHalf() { + return get(HALF, org.bukkit.block.data.Bisected.Half.class); + } + + @Override + public void setHalf(org.bukkit.block.data.Bisected.Half half) { + set(HALF, half); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACING = getEnum(net.minecraft.world.level.block.WeatheringCopperStairBlock.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.WeatheringCopperStairBlock.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java b/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java index 14bd54755..cd6b16661 100644 --- a/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java +++ b/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java @@ -97,13 +97,13 @@ public class CraftBossBar implements BossBar { @Override public String getTitle() { - return CraftChatMessage.fromComponent(handle.title); + return CraftChatMessage.fromComponent(handle.name); } @Override public void setTitle(String title) { - handle.title = CraftChatMessage.fromString(title, true)[0]; - handle.sendUpdate(PacketPlayOutBoss.Action.UPDATE_NAME); + handle.name = CraftChatMessage.fromString(title, true)[0]; + handle.sendUpdate(PacketPlayOutBoss::createUpdateNamePacket); } @Override @@ -114,18 +114,18 @@ public class CraftBossBar implements BossBar { @Override public void setColor(BarColor color) { handle.color = convertColor(color); - handle.sendUpdate(PacketPlayOutBoss.Action.UPDATE_STYLE); + handle.sendUpdate(PacketPlayOutBoss::createUpdatePropertiesPacket); } @Override public BarStyle getStyle() { - return convertStyle(handle.style); + return convertStyle(handle.overlay); } @Override public void setStyle(BarStyle style) { - handle.style = convertStyle(style); - handle.sendUpdate(PacketPlayOutBoss.Action.UPDATE_STYLE); + handle.overlay = convertStyle(style); + handle.sendUpdate(PacketPlayOutBoss::createUpdatePropertiesPacket); } @Override @@ -167,7 +167,7 @@ public class CraftBossBar implements BossBar { @Override public void addPlayer(Player player) { Preconditions.checkArgument(player != null, "player == null"); - Preconditions.checkArgument(((CraftPlayer) player).getHandle().playerConnection != null, "player is not fully connected (wait for PlayerJoinEvent)"); + Preconditions.checkArgument(((CraftPlayer) player).getHandle().connection != null, "player is not fully connected (wait for PlayerJoinEvent)"); handle.addPlayer(((CraftPlayer) player).getHandle()); } diff --git a/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java b/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java index d2c583516..a954f4703 100644 --- a/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java +++ b/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java @@ -20,27 +20,27 @@ public class CraftDragonBattle implements DragonBattle { @Override public EnderDragon getEnderDragon() { - Entity entity = handle.world.getEntity(handle.dragonUUID); + Entity entity = handle.level.getEntity(handle.dragonUUID); return (entity != null) ? (EnderDragon) entity.getBukkitEntity() : null; } @Override public BossBar getBossBar() { - return new CraftBossBar(handle.bossBattle); + return new CraftBossBar(handle.dragonEvent); } @Override public Location getEndPortalLocation() { - if (handle.exitPortalLocation == null) { + if (handle.portalLocation == null) { return null; } - return new Location(handle.world.getWorld(), handle.exitPortalLocation.getX(), handle.exitPortalLocation.getY(), handle.exitPortalLocation.getZ()); + return new Location(handle.level.getWorld(), handle.portalLocation.getX(), handle.portalLocation.getY(), handle.portalLocation.getZ()); } @Override public boolean generateEndPortal(boolean withPortals) { - if (handle.exitPortalLocation != null || handle.getExitPortalShape() != null) { + if (handle.portalLocation != null || handle.getExitPortalShape() != null) { return false; } @@ -60,14 +60,14 @@ public class CraftDragonBattle implements DragonBattle { @Override public RespawnPhase getRespawnPhase() { - return toBukkitRespawnPhase(handle.respawnPhase); + return toBukkitRespawnPhase(handle.respawnStage); } @Override public boolean setRespawnPhase(RespawnPhase phase) { Preconditions.checkArgument(phase != null && phase != RespawnPhase.NONE, "Invalid respawn phase provided: %s", phase); - if (handle.respawnPhase == null) { + if (handle.respawnStage == null) { return false; } diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java index 599fe901f..03b35104d 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java @@ -30,7 +30,7 @@ public class CraftBlockCommandSender extends ServerCommandSender implements Bloc @Override public void sendMessage(String message) { for (IChatBaseComponent component : CraftChatMessage.fromString(message)) { - block.base.sendMessage(component, SystemUtils.b); + block.source.sendMessage(component, SystemUtils.NIL_UUID); } } diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java index 24662d58c..c77e0a3ff 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java @@ -15,7 +15,7 @@ public class CraftRemoteConsoleCommandSender extends ServerCommandSender impleme @Override public void sendMessage(String message) { - listener.sendMessage(new ChatComponentText(message + "\n"), SystemUtils.b); // Send a newline after each message, to preserve formatting. + listener.sendMessage(new ChatComponentText(message + "\n"), SystemUtils.NIL_UUID); // Send a newline after each message, to preserve formatting. } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java index 56a066512..a3fc0c059 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java +++ b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java @@ -74,7 +74,7 @@ public final class VanillaCommandWrapper extends BukkitCommand { return ((EntityMinecartCommandBlock) ((CraftMinecartCommand) sender).getHandle()).getCommandBlock().getWrapper(); } if (sender instanceof RemoteConsoleCommandSender) { - return ((DedicatedServer) MinecraftServer.getServer()).remoteControlCommandListener.getWrapper(); + return ((DedicatedServer) MinecraftServer.getServer()).rconConsoleSource.getWrapper(); } if (sender instanceof ConsoleCommandSender) { return ((CraftServer) sender.getServer()).getServer().getServerCommandListener(); diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java index 8f694de2f..0f038a258 100644 --- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java @@ -30,7 +30,7 @@ public class CraftEnchantment extends Enchantment { @Override public EnchantmentTarget getItemTarget() { - switch (target.itemTarget) { + switch (target.category) { case ARMOR: return EnchantmentTarget.ARMOR; case ARMOR_FEET: @@ -82,7 +82,7 @@ public class CraftEnchantment extends Enchantment { @Override public String getName() { // PAIL: migration paths - switch (IRegistry.ENCHANTMENT.a(target)) { + switch (IRegistry.ENCHANTMENT.getId(target)) { case 0: return "PROTECTION_ENVIRONMENTAL"; case 1: @@ -160,7 +160,7 @@ public class CraftEnchantment extends Enchantment { case 37: return "VANISHING_CURSE"; default: - return "UNKNOWN_ENCHANT_" + IRegistry.ENCHANTMENT.a(target); + return "UNKNOWN_ENCHANT_" + IRegistry.ENCHANTMENT.getId(target); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java index 00b97d9ee..21da1f9f9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java @@ -99,6 +99,6 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac @Override public AbstractHorseInventory getInventory() { - return new CraftInventoryAbstractHorse(getHandle().inventoryChest); + return new CraftInventoryAbstractHorse(getHandle().inventory); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java index 6dc57b708..4667744a8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java @@ -24,12 +24,12 @@ public class CraftAnimals extends CraftAgeable implements Animals { @Override public UUID getBreedCause() { - return getHandle().breedCause; + return getHandle().loveCause; } @Override public void setBreedCause(UUID uuid) { - getHandle().breedCause = uuid; + getHandle().loveCause = uuid; } @Override @@ -45,6 +45,6 @@ public class CraftAnimals extends CraftAgeable implements Animals { @Override public int getLoveModeTicks() { - return getHandle().loveTicks; + return getHandle().inLove; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java index 86c8662b3..da1a5a04e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java @@ -156,7 +156,7 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand { public void setGravity(boolean gravity) { super.setGravity(gravity); // Armor stands are special - getHandle().noclip = !gravity; + getHandle().noPhysics = !gravity; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java index ea33a36df..bdfbab745 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java @@ -26,7 +26,7 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow { @Override public int getKnockbackStrength() { - return getHandle().knockbackStrength; + return getHandle().knockback; } @Override @@ -94,13 +94,13 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow { @Override public PickupStatus getPickupStatus() { - return PickupStatus.values()[getHandle().fromPlayer.ordinal()]; + return PickupStatus.values()[getHandle().pickup.ordinal()]; } @Override public void setPickupStatus(PickupStatus status) { Preconditions.checkNotNull(status, "status"); - getHandle().fromPlayer = EntityArrow.PickupStatus.a(status.ordinal()); + getHandle().pickup = EntityArrow.PickupStatus.a(status.ordinal()); } @Override @@ -108,7 +108,7 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow { super.setTicksLived(value); // Second field for EntityArrow - getHandle().despawnCounter = value; + getHandle().life = value; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java new file mode 100644 index 000000000..85847d344 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java @@ -0,0 +1,50 @@ +package org.bukkit.craftbukkit.entity; + +import com.google.common.base.Preconditions; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Axolotl; +import org.bukkit.entity.EntityType; + +public class CraftAxolotl extends CraftAnimals implements Axolotl { + + public CraftAxolotl(CraftServer server, net.minecraft.world.entity.animal.axolotl.Axolotl entity) { + super(server, entity); + } + + @Override + public net.minecraft.world.entity.animal.axolotl.Axolotl getHandle() { + return (net.minecraft.world.entity.animal.axolotl.Axolotl) super.getHandle(); + } + + @Override + public EntityType getType() { + return EntityType.AXOLOTL; + } + + @Override + public String toString() { + return "CraftAxolotl"; + } + + @Override + public boolean isPlayingDead() { + return getHandle().isPlayingDead(); + } + + @Override + public void setPlayingDead(boolean playingDead) { + getHandle().setPlayingDead(playingDead); + } + + @Override + public Variant getVariant() { + return Variant.values()[getHandle().getVariant().ordinal()]; + } + + @Override + public void setVariant(Variant variant) { + Preconditions.checkArgument(variant != null, "variant"); + + getHandle().setVariant(net.minecraft.world.entity.animal.axolotl.Axolotl.Variant.BY_ID[variant.ordinal()]); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java index e7904216c..3b5063c89 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java @@ -85,7 +85,7 @@ public class CraftBee extends CraftAnimals implements Bee { @Override public int getCannotEnterHiveTicks() { - return getHandle().cannotEnterHiveTicks; + return getHandle().stayOutOfHiveCountdown; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java index eb7155609..b3d62532c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java @@ -15,7 +15,7 @@ public class CraftComplexPart extends CraftEntity implements ComplexEntityPart { @Override public ComplexLivingEntity getParent() { - return (ComplexLivingEntity) ((EntityEnderDragon) getHandle().owner).getBukkitEntity(); + return (ComplexLivingEntity) ((EntityEnderDragon) getHandle().parentMob).getBukkitEntity(); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java index 167b8f0c7..8da12cd56 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java @@ -44,12 +44,12 @@ public class CraftCreeper extends CraftMonster implements Creeper { public void setMaxFuseTicks(int ticks) { Preconditions.checkArgument(ticks >= 0, "ticks < 0"); - getHandle().maxFuseTicks = ticks; + getHandle().maxSwell = ticks; } @Override public int getMaxFuseTicks() { - return getHandle().maxFuseTicks; + return getHandle().maxSwell; } @Override @@ -57,12 +57,12 @@ public class CraftCreeper extends CraftMonster implements Creeper { Preconditions.checkArgument(ticks >= 0, "ticks < 0"); Preconditions.checkArgument(ticks <= getMaxFuseTicks(), "ticks > maxFuseTicks"); - getHandle().fuseTicks = ticks; + getHandle().swell = ticks; } @Override public int getFuseTicks() { - return getHandle().fuseTicks; + return getHandle().swell; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java index df5530806..c9c23c65f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java @@ -25,7 +25,7 @@ public class CraftEnderDragon extends CraftComplexLivingEntity implements EnderD public Set getParts() { Builder builder = ImmutableSet.builder(); - for (EntityComplexPart part : getHandle().children) { + for (EntityComplexPart part : getHandle().subEntities) { builder.add((ComplexEntityPart) part.getBukkitEntity()); } @@ -49,7 +49,7 @@ public class CraftEnderDragon extends CraftComplexLivingEntity implements EnderD @Override public Phase getPhase() { - return Phase.values()[getHandle().getDataWatcher().get(EntityEnderDragon.PHASE)]; + return Phase.values()[getHandle().getDataWatcher().get(EntityEnderDragon.DATA_PHASE)]; } @Override @@ -77,6 +77,6 @@ public class CraftEnderDragon extends CraftComplexLivingEntity implements EnderD @Override public int getDeathAnimationTicks() { - return getHandle().deathAnimationTicks; + return getHandle().dragonDeathTime; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java index d8beee82c..1d9b9f548 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java @@ -33,7 +33,7 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal { @Override public Location getTargetLocation() { - return new Location(getWorld(), getHandle().targetX, getHandle().targetY, getHandle().targetZ, getHandle().yaw, getHandle().pitch); + return new Location(getWorld(), getHandle().tx, getHandle().ty, getHandle().tz, getHandle().getYRot(), getHandle().getXRot()); } @Override @@ -44,17 +44,17 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal { @Override public boolean getDropItem() { - return getHandle().shouldDropItem; + return getHandle().surviveAfterDeath; } @Override public void setDropItem(boolean shouldDropItem) { - getHandle().shouldDropItem = shouldDropItem; + getHandle().surviveAfterDeath = shouldDropItem; } @Override public ItemStack getItem() { - return CraftItemStack.asBukkitCopy(getHandle().getItem()); + return CraftItemStack.asBukkitCopy(getHandle().getSuppliedItem()); } @Override @@ -64,11 +64,11 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal { @Override public int getDespawnTimer() { - return getHandle().despawnTimer; + return getHandle().life; } @Override public void setDespawnTimer(int time) { - getHandle().despawnTimer = time; + getHandle().life = time; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java index 30b16c057..5d743f8b6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java @@ -28,11 +28,11 @@ public class CraftEndermite extends CraftMonster implements Endermite { @Override public boolean isPlayerSpawned() { - return getHandle().isPlayerSpawned(); + return false; } @Override public void setPlayerSpawned(boolean playerSpawned) { - getHandle().setPlayerSpawned(playerSpawned); + // Nop } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 7c217fcfc..1e755ac0a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -20,6 +20,8 @@ import net.minecraft.world.entity.EntityFlying; import net.minecraft.world.entity.EntityLightning; import net.minecraft.world.entity.EntityLiving; import net.minecraft.world.entity.EntityTameableAnimal; +import net.minecraft.world.entity.GlowSquid; +import net.minecraft.world.entity.Marker; import net.minecraft.world.entity.ambient.EntityAmbient; import net.minecraft.world.entity.ambient.EntityBat; import net.minecraft.world.entity.animal.EntityAnimal; @@ -49,6 +51,8 @@ import net.minecraft.world.entity.animal.EntityTropicalFish; import net.minecraft.world.entity.animal.EntityTurtle; import net.minecraft.world.entity.animal.EntityWaterAnimal; import net.minecraft.world.entity.animal.EntityWolf; +import net.minecraft.world.entity.animal.axolotl.Axolotl; +import net.minecraft.world.entity.animal.goat.Goat; import net.minecraft.world.entity.animal.horse.EntityHorse; import net.minecraft.world.entity.animal.horse.EntityHorseAbstract; import net.minecraft.world.entity.animal.horse.EntityHorseChestedAbstract; @@ -67,6 +71,7 @@ import net.minecraft.world.entity.decoration.EntityHanging; import net.minecraft.world.entity.decoration.EntityItemFrame; import net.minecraft.world.entity.decoration.EntityLeash; import net.minecraft.world.entity.decoration.EntityPainting; +import net.minecraft.world.entity.decoration.GlowItemFrame; import net.minecraft.world.entity.item.EntityFallingBlock; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.item.EntityTNTPrimed; @@ -198,7 +203,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } // Water Animals else if (entity instanceof EntityWaterAnimal) { - if (entity instanceof EntitySquid) { return new CraftSquid(server, (EntitySquid) entity); } + if (entity instanceof EntitySquid) { + if (entity instanceof GlowSquid) { return new CraftGlowSquid(server, (GlowSquid) entity); } + else { return new CraftSquid(server, (EntitySquid) entity); } + } else if (entity instanceof EntityFish) { if (entity instanceof EntityCod) { return new CraftCod(server, (EntityCod) entity); } else if (entity instanceof EntityPufferFish) { return new CraftPufferFish(server, (EntityPufferFish) entity); } @@ -243,6 +251,8 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (entity instanceof EntityBee) { return new CraftBee(server, (EntityBee) entity); } else if (entity instanceof EntityHoglin) { return new CraftHoglin(server, (EntityHoglin) entity); } else if (entity instanceof EntityStrider) { return new CraftStrider(server, (EntityStrider) entity); } + else if (entity instanceof Axolotl) { return new CraftAxolotl(server, (Axolotl) entity); } + else if (entity instanceof Goat) { return new CraftGoat(server, (Goat) entity); } else { return new CraftAnimals(server, (EntityAnimal) entity); } } // Monsters @@ -332,7 +342,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } else if (entity instanceof EntityComplexPart) { EntityComplexPart part = (EntityComplexPart) entity; - if (part.owner instanceof EntityEnderDragon) { return new CraftEnderDragonPart(server, (EntityComplexPart) entity); } + if (part.parentMob instanceof EntityEnderDragon) { return new CraftEnderDragonPart(server, (EntityComplexPart) entity); } else { return new CraftComplexPart(server, (EntityComplexPart) entity); } } else if (entity instanceof EntityExperienceOrb) { return new CraftExperienceOrb(server, (EntityExperienceOrb) entity); } @@ -373,7 +383,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (entity instanceof EntityMinecartCommandBlock) { return new CraftMinecartCommand(server, (EntityMinecartCommandBlock) entity); } } else if (entity instanceof EntityHanging) { if (entity instanceof EntityPainting) { return new CraftPainting(server, (EntityPainting) entity); } - else if (entity instanceof EntityItemFrame) { return new CraftItemFrame(server, (EntityItemFrame) entity); } + else if (entity instanceof EntityItemFrame) { + if (entity instanceof GlowItemFrame) { return new CraftGlowItemFrame(server, (GlowItemFrame) entity); } + else { return new CraftItemFrame(server, (EntityItemFrame) entity); } + } else if (entity instanceof EntityLeash) { return new CraftLeash(server, (EntityLeash) entity); } else { return new CraftHanging(server, (EntityHanging) entity); } } @@ -383,6 +396,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (entity instanceof EntityAreaEffectCloud) { return new CraftAreaEffectCloud(server, (EntityAreaEffectCloud) entity); } else if (entity instanceof EntityEvokerFangs) { return new CraftEvokerFangs(server, (EntityEvokerFangs) entity); } else if (entity instanceof EntityLlamaSpit) { return new CraftLlamaSpit(server, (EntityLlamaSpit) entity); } + else if (entity instanceof Marker) { return new CraftMarker(server, (Marker) entity); } // CHECKSTYLE:ON throw new AssertionError("Unknown entity " + (entity == null ? null : entity.getClass())); @@ -390,7 +404,7 @@ 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.pitch); + return new Location(getWorld(), entity.locX(), entity.locY(), entity.locZ(), entity.getBukkitYaw(), entity.getXRot()); } @Override @@ -401,7 +415,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { loc.setY(entity.locY()); loc.setZ(entity.locZ()); loc.setYaw(entity.getBukkitYaw()); - loc.setPitch(entity.pitch); + loc.setPitch(entity.getXRot()); } return loc; @@ -417,7 +431,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { Preconditions.checkArgument(velocity != null, "velocity"); velocity.checkFinite(); entity.setMot(CraftVector.toNMS(velocity)); - entity.velocityChanged = true; + entity.hurtMarked = true; } @Override @@ -451,7 +465,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public World getWorld() { - return entity.world.getWorld(); + return entity.level.getWorld(); } @Override @@ -462,10 +476,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { yaw = Location.normalizeYaw(yaw); pitch = Location.normalizePitch(pitch); - entity.yaw = yaw; - entity.pitch = pitch; - entity.lastYaw = yaw; - entity.lastPitch = pitch; + entity.setYRot(yaw); + entity.setXRot(pitch); + entity.yRotO = yaw; + entity.xRotO = pitch; entity.setHeadRotation(yaw); } @@ -479,7 +493,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { Preconditions.checkArgument(location != null, "location"); location.checkFinite(); - if (entity.isVehicle() || entity.dead) { + if (entity.isVehicle() || entity.isRemoved()) { return false; } @@ -512,7 +526,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public List getNearbyEntities(double x, double y, double z) { - List notchEntityList = entity.world.getEntities(entity, entity.getBoundingBox().grow(x, y, z), null); + List notchEntityList = entity.level.getEntities(entity, entity.getBoundingBox().grow(x, y, z), null); List bukkitEntityList = new java.util.ArrayList(notchEntityList.size()); for (Entity e : notchEntityList) { @@ -528,7 +542,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public int getFireTicks() { - return entity.fireTicks; + return entity.remainingFireTicks; } @Override @@ -538,7 +552,39 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public void setFireTicks(int ticks) { - entity.fireTicks = ticks; + entity.remainingFireTicks = ticks; + } + + @Override + public void setVisualFire(boolean fire) { + getHandle().hasVisualFire = fire; + } + + @Override + public boolean isVisualFire() { + return getHandle().hasVisualFire; + } + + @Override + public int getFreezeTicks() { + return getHandle().getTicksFrozen(); + } + + @Override + public int getMaxFreezeTicks() { + return getHandle().getTicksRequiredToFreeze(); + } + + @Override + public void setFreezeTicks(int ticks) { + Preconditions.checkArgument(0 <= ticks && ticks <= getMaxFreezeTicks(), "Ticks cannot be less than 0 or greater than getMaxFreezeTicks"); + + getHandle().setTicksFrozen(ticks); + } + + @Override + public boolean isFrozen() { + return getHandle().isFullyFrozen(); } @Override @@ -662,7 +708,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public int getTicksLived() { - return getHandle().ticksLived; + return getHandle().tickCount; } @Override @@ -670,7 +716,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { if (value <= 0) { throw new IllegalArgumentException("Age must be at least 1 tick"); } - getHandle().ticksLived = value; + getHandle().tickCount = value; } public Entity getHandle() { @@ -682,7 +728,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { Preconditions.checkArgument(type != null, "type"); if (type.getApplicable().isInstance(this)) { - this.getHandle().world.broadcastEntityEffect(getHandle(), type.getData()); + this.getHandle().level.broadcastEntityEffect(getHandle(), type.getData()); } } @@ -881,16 +927,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public void setGlowing(boolean flag) { - getHandle().glowing = flag; - Entity e = getHandle(); - if (e.getFlag(6) != flag) { - e.setFlag(6, flag); - } + getHandle().setGlowingTag(true); } @Override public boolean isGlowing() { - return getHandle().glowing; + return getHandle().isCurrentlyGlowing(); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java index c98d0c684..ed1a64976 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java @@ -64,6 +64,6 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock { super.setTicksLived(value); // Second field for EntityFallingBlock - getHandle().ticksLived = value; + getHandle().time = value; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java index 528c76ae9..53514e513 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java @@ -50,7 +50,7 @@ public class CraftFireball extends AbstractProjectile implements Fireball { @Override public Vector getDirection() { - return new Vector(getHandle().dirX, getHandle().dirY, getHandle().dirZ); + return new Vector(getHandle().xPower, getHandle().yPower, getHandle().zPower); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java index 33162fd41..2759de2c6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java +++ b/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.FIREWORK_ITEM); + ItemStack item = getHandle().getDataWatcher().get(EntityFireworks.DATA_ID_FIREWORKS_ITEM); if (item.isEmpty()) { item = new ItemStack(Items.FIREWORK_ROCKET); - getHandle().getDataWatcher().set(EntityFireworks.FIREWORK_ITEM, item); + getHandle().getDataWatcher().set(EntityFireworks.DATA_ID_FIREWORKS_ITEM, item); } this.item = CraftItemStack.asCraftMirror(item); @@ -59,14 +59,14 @@ public class CraftFirework extends CraftProjectile implements Firework { item.setItemMeta(meta); // Copied from EntityFireworks constructor, update firework lifetime/power - getHandle().expectedLifespan = 10 * (1 + meta.getPower()) + random.nextInt(6) + random.nextInt(7); + getHandle().lifetime = 10 * (1 + meta.getPower()) + random.nextInt(6) + random.nextInt(7); - getHandle().getDataWatcher().markDirty(EntityFireworks.FIREWORK_ITEM); + getHandle().getDataWatcher().markDirty(EntityFireworks.DATA_ID_FIREWORKS_ITEM); } @Override public void detonate() { - getHandle().expectedLifespan = 0; + getHandle().lifetime = 0; } @Override @@ -76,6 +76,6 @@ public class CraftFirework extends CraftProjectile implements Firework { @Override public void setShotAtAngle(boolean shotAtAngle) { - getHandle().getDataWatcher().set(EntityFireworks.SHOT_AT_ANGLE, shotAtAngle); + getHandle().getDataWatcher().set(EntityFireworks.DATA_SHOT_AT_ANGLE, shotAtAngle); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java index 4dd3deaab..5a02fab2e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java +++ b/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.world.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.locX()), MathHelper.floor(hook.locY()) + 1, MathHelper.floor(hook.locZ())))) { return 1 / 300.0; } return 1 / 500.0; @@ -92,7 +92,7 @@ public class CraftFishHook extends CraftProjectile implements FishHook { @Override public Entity getHookedEntity() { - net.minecraft.world.entity.Entity hooked = getHandle().hooked; + net.minecraft.world.entity.Entity hooked = getHandle().hookedIn; return (hooked != null) ? hooked.getBukkitEntity() : null; } @@ -100,23 +100,23 @@ public class CraftFishHook extends CraftProjectile implements FishHook { public void setHookedEntity(Entity entity) { EntityFishingHook hook = getHandle(); - hook.hooked = (entity != null) ? ((CraftEntity) entity).getHandle() : null; - hook.getDataWatcher().set(EntityFishingHook.HOOKED_ENTITY, hook.hooked != null ? hook.hooked.getId() + 1 : 0); + hook.hookedIn = (entity != null) ? ((CraftEntity) entity).getHandle() : null; + hook.getDataWatcher().set(EntityFishingHook.DATA_HOOKED_ENTITY, hook.hookedIn != null ? hook.hookedIn.getId() + 1 : 0); } @Override public boolean pullHookedEntity() { EntityFishingHook hook = getHandle(); - if (hook.hooked == null) { + if (hook.hookedIn == null) { return false; } - hook.reel(); + hook.reel(hook.hookedIn); return true; } @Override public HookState getState() { - return HookState.values()[getHandle().hookState.ordinal()]; + return HookState.values()[getHandle().currentState.ordinal()]; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java index 362ac8e43..d8646392d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java @@ -70,7 +70,7 @@ public class CraftFox extends CraftAnimals implements Fox { @Override public AnimalTamer getFirstTrustedPlayer() { - UUID uuid = getHandle().getDataWatcher().get(EntityFox.FIRST_TRUSTED_PLAYER).orElse(null); + UUID uuid = getHandle().getDataWatcher().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.SECOND_TRUSTED_PLAYER).isPresent()) { + if (player == null && getHandle().getDataWatcher().get(EntityFox.DATA_TRUSTED_ID_1).isPresent()) { throw new IllegalStateException("Must remove second trusted player first"); } - getHandle().getDataWatcher().set(EntityFox.FIRST_TRUSTED_PLAYER, player == null ? Optional.empty() : Optional.of(player.getUniqueId())); + getHandle().getDataWatcher().set(EntityFox.DATA_TRUSTED_ID_0, player == null ? Optional.empty() : Optional.of(player.getUniqueId())); } @Override public AnimalTamer getSecondTrustedPlayer() { - UUID uuid = getHandle().getDataWatcher().get(EntityFox.SECOND_TRUSTED_PLAYER).orElse(null); + UUID uuid = getHandle().getDataWatcher().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.FIRST_TRUSTED_PLAYER).isPresent()) { + if (player != null && !getHandle().getDataWatcher().get(EntityFox.DATA_TRUSTED_ID_0).isPresent()) { throw new IllegalStateException("Must add first trusted player first"); } - getHandle().getDataWatcher().set(EntityFox.SECOND_TRUSTED_PLAYER, player == null ? Optional.empty() : Optional.of(player.getUniqueId())); + getHandle().getDataWatcher().set(EntityFox.DATA_TRUSTED_ID_1, player == null ? Optional.empty() : Optional.of(player.getUniqueId())); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowItemFrame.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowItemFrame.java new file mode 100644 index 000000000..c704784df --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowItemFrame.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.entity; + +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.GlowItemFrame; + +public class CraftGlowItemFrame extends CraftItemFrame implements GlowItemFrame { + + public CraftGlowItemFrame(CraftServer server, net.minecraft.world.entity.decoration.GlowItemFrame entity) { + super(server, entity); + } + + @Override + public net.minecraft.world.entity.decoration.GlowItemFrame getHandle() { + return (net.minecraft.world.entity.decoration.GlowItemFrame) super.getHandle(); + } + + @Override + public EntityType getType() { + return EntityType.GLOW_ITEM_FRAME; + } + + @Override + public String toString() { + return "CraftGlowItemFrame"; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowSquid.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowSquid.java new file mode 100644 index 000000000..bcc1464bc --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowSquid.java @@ -0,0 +1,39 @@ +package org.bukkit.craftbukkit.entity; + +import com.google.common.base.Preconditions; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.GlowSquid; + +public class CraftGlowSquid extends CraftSquid implements GlowSquid { + + public CraftGlowSquid(CraftServer server, net.minecraft.world.entity.GlowSquid entity) { + super(server, entity); + } + + @Override + public net.minecraft.world.entity.GlowSquid getHandle() { + return (net.minecraft.world.entity.GlowSquid) super.getHandle(); + } + + @Override + public EntityType getType() { + return EntityType.GLOW_SQUID; + } + + @Override + public String toString() { + return "CraftGlowSquid"; + } + + @Override + public int getDarkTicksRemaining() { + return getHandle().getDarkTicksRemaining(); + } + + @Override + public void setDarkTicksRemaining(int darkTicksRemaining) { + Preconditions.checkArgument(darkTicksRemaining >= 0, "darkTicksRemaining must be >= 0"); + getHandle().setDarkTicksRemaining(darkTicksRemaining); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGoat.java new file mode 100644 index 000000000..59e02596e --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGoat.java @@ -0,0 +1,37 @@ +package org.bukkit.craftbukkit.entity; + +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Goat; + +public class CraftGoat extends CraftAnimals implements Goat { + + public CraftGoat(CraftServer server, net.minecraft.world.entity.animal.goat.Goat entity) { + super(server, entity); + } + + @Override + public net.minecraft.world.entity.animal.goat.Goat getHandle() { + return (net.minecraft.world.entity.animal.goat.Goat) super.getHandle(); + } + + @Override + public EntityType getType() { + return EntityType.GOAT; + } + + @Override + public String toString() { + return "CraftGoat"; + } + + @Override + public boolean isScreaming() { + return getHandle().isScreamingGoat(); + } + + @Override + public void setScreaming(boolean screaming) { + getHandle().setScreamingGoat(screaming); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java index 34d22e34a..f90f8855e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java @@ -81,12 +81,12 @@ public class CraftHanging extends CraftEntity implements Hanging { } WorldServer world = ((CraftWorld) getWorld()).getHandle(); - PlayerChunkMap.EntityTracker entityTracker = world.getChunkProvider().playerChunkMap.trackedEntities.get(getEntityId()); + PlayerChunkMap.EntityTracker entityTracker = world.getChunkProvider().chunkMap.entityMap.get(getEntityId()); if (entityTracker == null) { return; } - entityTracker.broadcast(getHandle().P()); + entityTracker.broadcast(getHandle().getPacket()); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java index 54d92bb52..e5284f6e7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java @@ -35,16 +35,16 @@ public class CraftHoglin extends CraftAnimals implements Hoglin { @Override public int getConversionTime() { Preconditions.checkState(isConverting(), "Entity not converting"); - return getHandle().conversionTicks; + return getHandle().timeInOverworld; } @Override public void setConversionTime(int time) { if (time < 0) { - getHandle().conversionTicks = -1; + getHandle().timeInOverworld = -1; getHandle().setImmuneToZombification(false); } else { - getHandle().conversionTicks = time; + getHandle().timeInOverworld = time; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java index de9e5e786..1c7ef05e4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java @@ -63,7 +63,7 @@ public class CraftHorse extends CraftAbstractHorse implements Horse { @Override public HorseInventory getInventory() { - return new CraftInventoryHorse(getHandle().inventoryChest); + return new CraftInventoryHorse(getHandle().inventory); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 816f2cbeb..888e5a6c8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -73,7 +73,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { public CraftHumanEntity(final CraftServer server, final EntityHuman entity) { super(server, entity); mode = server.getDefaultGameMode(); - this.inventory = new CraftInventoryPlayer(entity.inventory); + this.inventory = new CraftInventoryPlayer(entity.getInventory()); enderChest = new CraftInventory(entity.getEnderChest()); } @@ -109,21 +109,21 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @Override public ItemStack getItemOnCursor() { - return CraftItemStack.asCraftMirror(getHandle().inventory.getCarried()); + return CraftItemStack.asCraftMirror(getHandle().inventoryMenu.getCarried()); } @Override public void setItemOnCursor(ItemStack item) { net.minecraft.world.item.ItemStack stack = CraftItemStack.asNMSCopy(item); - getHandle().inventory.setCarried(stack); + getHandle().inventoryMenu.setCarried(stack); if (this instanceof CraftPlayer) { - ((EntityPlayer) getHandle()).broadcastCarriedItem(); // Send set slot for cursor + getHandle().inventoryMenu.broadcastCarriedItem(); // Send set slot for cursor } } @Override public int getSleepTicks() { - return getHandle().sleepTicks; + return getHandle().sleepCounter; } @Override @@ -133,7 +133,7 @@ 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().world.getType(blockposition); + IBlockData iblockdata = getHandle().level.getType(blockposition); if (!(iblockdata.getBlock() instanceof BlockBed)) { return false; } @@ -144,7 +144,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { // From BlockBed iblockdata = (IBlockData) iblockdata.set(BlockBed.OCCUPIED, true); - getHandle().world.setTypeAndData(blockposition, iblockdata, 4); + getHandle().level.setTypeAndData(blockposition, iblockdata, 4); return true; } @@ -256,7 +256,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { public void setHandle(final EntityHuman entity) { super.setHandle(entity); - this.inventory = new CraftInventoryPlayer(entity.inventory); + this.inventory = new CraftInventoryPlayer(entity.getInventory()); } @Override @@ -266,14 +266,14 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @Override public InventoryView getOpenInventory() { - return getHandle().activeContainer.getBukkitView(); + return getHandle().containerMenu.getBukkitView(); } @Override public InventoryView openInventory(Inventory inventory) { if (!(getHandle() instanceof EntityPlayer)) return null; EntityPlayer player = (EntityPlayer) getHandle(); - Container formerContainer = getHandle().activeContainer; + Container formerContainer = getHandle().containerMenu; ITileInventory iinventory = null; if (inventory instanceof CraftInventoryDoubleChest) { @@ -291,7 +291,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { if (iinventory instanceof TileEntity) { TileEntity te = (TileEntity) iinventory; if (!te.hasWorld()) { - te.setLocation(getHandle().world, getHandle().getChunkCoordinates()); + te.setWorld(getHandle().level); } } } @@ -303,26 +303,26 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { openCustomInventory(inventory, player, container); } - if (getHandle().activeContainer == formerContainer) { + if (getHandle().containerMenu == formerContainer) { return null; } - getHandle().activeContainer.checkReachable = false; - return getHandle().activeContainer.getBukkitView(); + getHandle().containerMenu.checkReachable = false; + return getHandle().containerMenu.getBukkitView(); } - private void openCustomInventory(Inventory inventory, EntityPlayer player, Containers windowType) { - if (player.playerConnection == null) return; + private static void openCustomInventory(Inventory inventory, EntityPlayer player, Containers windowType) { + if (player.connection == null) return; Preconditions.checkArgument(windowType != null, "Unknown windowType"); - Container container = new CraftContainer(inventory, this.getHandle(), player.nextContainerCounter()); + Container container = new CraftContainer(inventory, player, player.nextContainerCounter()); container = CraftEventFactory.callInventoryOpenEvent(player, container); if (container == null) return; String title = container.getBukkitView().getTitle(); - player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); - getHandle().activeContainer = container; - getHandle().activeContainer.addSlotListener(player); + player.connection.sendPacket(new PacketPlayOutOpenWindow(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); + player.containerMenu = container; + player.initMenu(container); } @Override @@ -336,11 +336,11 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { return null; } } - getHandle().openContainer(((BlockWorkbench) Blocks.CRAFTING_TABLE).getInventory(null, getHandle().world, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()))); + getHandle().openContainer(((BlockWorkbench) Blocks.CRAFTING_TABLE).getInventory(null, getHandle().level, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()))); if (force) { - getHandle().activeContainer.checkReachable = false; + getHandle().containerMenu.checkReachable = false; } - return getHandle().activeContainer.getBukkitView(); + return getHandle().containerMenu.getBukkitView(); } @Override @@ -357,21 +357,21 @@ 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().world, pos)); + getHandle().openContainer(((BlockEnchantmentTable) Blocks.ENCHANTING_TABLE).getInventory(null, getHandle().level, pos)); if (force) { - getHandle().activeContainer.checkReachable = false; + getHandle().containerMenu.checkReachable = false; } - return getHandle().activeContainer.getBukkitView(); + return getHandle().containerMenu.getBukkitView(); } @Override public void openInventory(InventoryView inventory) { if (!(getHandle() instanceof EntityPlayer)) return; // TODO: NPC support? - if (((EntityPlayer) getHandle()).playerConnection == null) return; - if (getHandle().activeContainer != getHandle().defaultContainer) { + if (((EntityPlayer) getHandle()).connection == null) return; + if (getHandle().containerMenu != getHandle().inventoryMenu) { // fire INVENTORY_CLOSE if one already open - ((EntityPlayer) getHandle()).playerConnection.a(new PacketPlayInCloseWindow(getHandle().activeContainer.windowId)); + ((EntityPlayer) getHandle()).connection.a(new PacketPlayInCloseWindow(getHandle().containerMenu.containerId)); } EntityPlayer player = (EntityPlayer) getHandle(); Container container; @@ -390,9 +390,9 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { // Now open the window Containers windowType = CraftContainer.getNotchInventoryType(inventory.getTopInventory()); String title = inventory.getTitle(); - player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); - player.activeContainer = container; - player.activeContainer.addSlotListener(player); + player.connection.sendPacket(new PacketPlayOutOpenWindow(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); + player.containerMenu = container; + player.initMenu(container); } @Override @@ -432,7 +432,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { mcMerchant.setTradingPlayer(this.getHandle()); mcMerchant.openTrade(this.getHandle(), name, level); - return this.getHandle().activeContainer.getBukkitView(); + return this.getHandle().containerMenu.getBukkitView(); } @Override @@ -477,7 +477,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { Preconditions.checkArgument(material != null, "material"); ItemCooldown.Info cooldown = getHandle().getCooldownTracker().cooldowns.get(CraftMagicNumbers.getItem(material)); - return (cooldown == null) ? 0 : Math.max(0, cooldown.endTick - getHandle().getCooldownTracker().currentTick); + return (cooldown == null) ? 0 : Math.max(0, cooldown.endTime - getHandle().getCooldownTracker().tickCount); } @Override @@ -520,7 +520,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { private Collection> bukkitKeysToMinecraftRecipes(Collection recipeKeys) { Collection> recipes = new ArrayList<>(); - CraftingManager manager = getHandle().world.getMinecraftServer().getCraftingManager(); + CraftingManager manager = getHandle().level.getMinecraftServer().getCraftingManager(); for (NamespacedKey recipeKey : recipeKeys) { Optional> recipe = manager.getRecipe(CraftNamespacedKey.toMinecraft(recipeKey)); @@ -537,7 +537,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @Override public org.bukkit.entity.Entity getShoulderEntityLeft() { if (!getHandle().getShoulderEntityLeft().isEmpty()) { - Optional shoulder = EntityTypes.a(getHandle().getShoulderEntityLeft(), getHandle().world); + Optional shoulder = EntityTypes.a(getHandle().getShoulderEntityLeft(), getHandle().level); return (!shoulder.isPresent()) ? null : shoulder.get().getBukkitEntity(); } @@ -556,7 +556,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @Override public org.bukkit.entity.Entity getShoulderEntityRight() { if (!getHandle().getShoulderEntityRight().isEmpty()) { - Optional shoulder = EntityTypes.a(getHandle().getShoulderEntityRight(), getHandle().world); + Optional shoulder = EntityTypes.a(getHandle().getShoulderEntityRight(), getHandle().level); return (!shoulder.isPresent()) ? null : shoulder.get().getBukkitEntity(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java index 4238641eb..ec0fa8482 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java @@ -42,12 +42,12 @@ 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().c()) { + for (DataWatcher.Item dataItem : getHandle().getDataWatcher().getAll()) { getHandle().getDataWatcher().markDirty(dataItem.a()); } // update redstone - getHandle().getWorld().updateAdjacentComparators(getHandle().blockPosition, Blocks.AIR); + getHandle().getWorld().updateAdjacentComparators(getHandle().pos, Blocks.AIR); } @Override @@ -67,13 +67,13 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame { @Override public float getItemDropChance() { - return getHandle().itemDropChance; + return getHandle().dropChance; } @Override public void setItemDropChance(float chance) { Preconditions.checkArgument(0.0 <= chance && chance <= 1.0, "Chance outside range [0, 1]"); - getHandle().itemDropChance = chance; + getHandle().dropChance = chance; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java index 389cb9e17..75b092527 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java @@ -13,7 +13,7 @@ public class CraftLargeFireball extends CraftSizedFireball implements LargeFireb @Override public void setYield(float yield) { super.setYield(yield); - getHandle().yield = (int) yield; + getHandle().explosionPower = (int) yield; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java index 2f881b054..9ab9f0a31 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java @@ -12,7 +12,7 @@ public class CraftLightningStrike extends CraftEntity implements LightningStrike @Override public boolean isEffect() { - return getHandle().isEffect; + return getHandle().visualOnly; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index da0a7a60c..350925252 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -248,12 +248,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public int getArrowCooldown() { - return getHandle().arrowCooldown; + return getHandle().removeArrowTime; } @Override public void setArrowCooldown(int ticks) { - getHandle().arrowCooldown = ticks; + getHandle().removeArrowTime = ticks; } @Override @@ -264,7 +264,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.ARROWS_IN_BODY, count); + getHandle().getDataWatcher().set(EntityLiving.DATA_ARROW_COUNT_ID, count); } @Override @@ -294,32 +294,32 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public int getMaximumNoDamageTicks() { - return getHandle().maxNoDamageTicks; + return getHandle().invulnerableDuration; } @Override public void setMaximumNoDamageTicks(int ticks) { - getHandle().maxNoDamageTicks = ticks; + getHandle().invulnerableDuration = ticks; } @Override public double getLastDamage() { - return getHandle().lastDamage; + return getHandle().lastHurt; } @Override public void setLastDamage(double damage) { - getHandle().lastDamage = (float) damage; + getHandle().lastHurt = (float) damage; } @Override public int getNoDamageTicks() { - return getHandle().noDamageTicks; + return getHandle().invulnerableTime; } @Override public void setNoDamageTicks(int ticks) { - getHandle().noDamageTicks = ticks; + getHandle().invulnerableTime = ticks; } @Override @@ -338,7 +338,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public Player getKiller() { - return getHandle().killer == null ? null : (Player) getHandle().killer.getBukkitEntity(); + return getHandle().lastHurtByPlayer == null ? null : (Player) getHandle().lastHurtByPlayer.getBukkitEntity(); } @Override @@ -380,7 +380,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public Collection getActivePotionEffects() { List effects = new ArrayList(); - for (MobEffect handle : getHandle().effects.values()) { + for (MobEffect handle : getHandle().activeEffects.values()) { effects.add(new PotionEffect(PotionEffectType.getById(MobEffectList.getId(handle.getMobEffect())), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isShowParticles())); } return effects; @@ -399,13 +399,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { if (Snowball.class.isAssignableFrom(projectile)) { launch = new EntitySnowball(world, getHandle()); - ((EntityProjectile) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, 0.0F, 1.5F, 1.0F); // ItemSnowball + ((EntityProjectile) launch).a(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().pitch, getHandle().yaw, 0.0F, 1.5F, 1.0F); // ItemEgg + ((EntityProjectile) launch).a(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().pitch, getHandle().yaw, 0.0F, 1.5F, 1.0F); // ItemEnderPearl + ((EntityProjectile) launch).a(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()); @@ -417,7 +417,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } else { launch = new EntityTippedArrow(world, getHandle()); } - ((EntityArrow) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, 0.0F, 3.0F, 1.0F); // ItemBow + ((EntityArrow) launch).a(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()); @@ -426,10 +426,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().pitch, getHandle().yaw, -20.0F, 0.5F, 1.0F); // ItemSplashPotion + ((EntityProjectile) launch).a(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().pitch, getHandle().yaw, -20.0F, 0.7F, 1.0F); // ItemExpBottle + ((EntityProjectile) launch).a(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)) { @@ -443,7 +443,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } else if (DragonFireball.class.isAssignableFrom(projectile)) { launch = new EntityDragonFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ()); } else { - launch = new EntityLargeFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ()); + launch = new EntityLargeFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ(), 1); } ((EntityFireball) launch).projectileSource = this; @@ -465,7 +465,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } else if (Firework.class.isAssignableFrom(projectile)) { Location location = getEyeLocation(); - launch = new EntityFireworks(world, net.minecraft.world.item.ItemStack.b, getHandle()); + launch = new EntityFireworks(world, net.minecraft.world.item.ItemStack.EMPTY, getHandle()); launch.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); } @@ -491,13 +491,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public boolean getRemoveWhenFarAway() { - return getHandle() instanceof EntityInsentient && !((EntityInsentient) getHandle()).persistent; + return getHandle() instanceof EntityInsentient && !((EntityInsentient) getHandle()).persistenceRequired; } @Override public void setRemoveWhenFarAway(boolean remove) { if (getHandle() instanceof EntityInsentient) { - ((EntityInsentient) getHandle()).persistent = !remove; + ((EntityInsentient) getHandle()).persistenceRequired = !remove; } } @@ -508,12 +508,20 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public void setCanPickupItems(boolean pickup) { - getHandle().canPickUpLoot = pickup; + if (getHandle() instanceof EntityInsentient) { + ((EntityInsentient) getHandle()).setCanPickupLoot(pickup); + } else { + getHandle().bukkitPickUpLoot = pickup; + } } @Override public boolean getCanPickupItems() { - return getHandle().canPickUpLoot; + if (getHandle() instanceof EntityInsentient) { + return ((EntityInsentient) getHandle()).canPickupLoot(); + } else { + return getHandle().bukkitPickUpLoot; + } } @Override @@ -669,7 +677,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { return EntityCategory.ARTHROPOD; } else if (type == EnumMonsterType.ILLAGER) { return EntityCategory.ILLAGER; - } else if (type == EnumMonsterType.WATER_MOB) { + } else if (type == EnumMonsterType.WATER) { return EntityCategory.WATER; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java index 6dcf196fd..59fddf218 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java @@ -35,7 +35,7 @@ public class CraftLlama extends CraftChestedHorse implements Llama { @Override public LlamaInventory getInventory() { - return new CraftInventoryLlama(getHandle().inventoryChest); + return new CraftInventoryLlama(getHandle().inventory); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMarker.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMarker.java new file mode 100644 index 000000000..1e794ec9f --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMarker.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.entity; + +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Marker; + +public class CraftMarker extends CraftEntity implements Marker { + + public CraftMarker(CraftServer server, net.minecraft.world.entity.Marker entity) { + super(server, entity); + } + + @Override + public net.minecraft.world.entity.Marker getHandle() { + return (net.minecraft.world.entity.Marker) super.getHandle(); + } + + @Override + public EntityType getType() { + return EntityType.MARKER; + } + + @Override + public String toString() { + return "CraftMarker"; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java index 0590675b9..c2e7b31b7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java +++ b/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.COMMAND, getHandle().getCommandBlock().getCommand()); + getHandle().getDataWatcher().set(EntityMinecartCommandBlock.DATA_ID_COMMAND_NAME, getHandle().getCommandBlock().getCommand()); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java index eb275ac45..a3c80bc71 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java @@ -53,16 +53,16 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { @Override public void setLootTable(LootTable table) { - getHandle().lootTableKey = (table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey()); + getHandle().lootTable = (table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey()); } @Override public LootTable getLootTable() { - if (getHandle().lootTableKey == null) { - getHandle().lootTableKey = getHandle().getLootTable(); + if (getHandle().lootTable == null) { + getHandle().lootTable = getHandle().getDefaultLootTable(); } - NamespacedKey key = CraftNamespacedKey.fromMinecraft(getHandle().lootTableKey); + NamespacedKey key = CraftNamespacedKey.fromMinecraft(getHandle().lootTable); return Bukkit.getLootTable(key); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java index 72f38fe6b..4ef1b6173 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java @@ -17,7 +17,7 @@ public class CraftPainting extends CraftHanging implements Painting { @Override public Art getArt() { - Paintings art = getHandle().art; + Paintings art = getHandle().motive; return CraftArt.NotchToBukkit(art); } @@ -29,12 +29,12 @@ public class CraftPainting extends CraftHanging implements Painting { @Override public boolean setArt(Art art, boolean force) { EntityPainting painting = this.getHandle(); - Paintings oldArt = painting.art; - painting.art = CraftArt.BukkitToNotch(art); + Paintings oldArt = painting.motive; + painting.motive = CraftArt.BukkitToNotch(art); painting.setDirection(painting.getDirection()); if (!force && !painting.survives()) { // Revert painting since it doesn't fit - painting.art = oldArt; + painting.motive = oldArt; painting.setDirection(painting.getDirection()); return false; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java index 80a2f05b1..363a2a4db 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java @@ -20,36 +20,36 @@ public class CraftPig extends CraftAnimals implements Pig { @Override public void setSaddle(boolean saddled) { - getHandle().saddleStorage.setSaddle(saddled); + getHandle().steering.setSaddle(saddled); } @Override public int getBoostTicks() { - return getHandle().saddleStorage.boosting ? getHandle().saddleStorage.boostTicks : 0; + return getHandle().steering.boosting ? getHandle().steering.boostTimeTotal : 0; } @Override public void setBoostTicks(int ticks) { Preconditions.checkArgument(ticks >= 0, "ticks must be >= 0"); - getHandle().saddleStorage.setBoostTicks(ticks); + getHandle().steering.setBoostTicks(ticks); } @Override public int getCurrentBoostTicks() { - return getHandle().saddleStorage.boosting ? getHandle().saddleStorage.currentBoostTicks : 0; + return getHandle().steering.boosting ? getHandle().steering.boostTime : 0; } @Override public void setCurrentBoostTicks(int ticks) { - if (!getHandle().saddleStorage.boosting) { + if (!getHandle().steering.boosting) { return; } - int max = getHandle().saddleStorage.boostTicks; + int max = getHandle().steering.boostTimeTotal; Preconditions.checkArgument(ticks >= 0 && ticks <= max, "boost ticks must not exceed 0 or %d (inclusive)", max); - this.getHandle().saddleStorage.currentBoostTicks = ticks; + this.getHandle().steering.boostTime = ticks; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java index 0327f3d9e..814da5c4e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java @@ -74,7 +74,7 @@ public class CraftPiglin extends CraftPiglinAbstract implements Piglin { @Override public Inventory getInventory() { - return new CraftInventory(getHandle().bu); + return new CraftInventory(getHandle().inventory); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java index 5087e922c..ca64b9f42 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java @@ -24,16 +24,16 @@ public class CraftPiglinAbstract extends CraftMonster implements PiglinAbstract @Override public int getConversionTime() { Preconditions.checkState(isConverting(), "Entity not converting"); - return getHandle().conversionTicks; + return getHandle().timeInOverworld; } @Override public void setConversionTime(int time) { if (time < 0) { - getHandle().conversionTicks = -1; + getHandle().timeInOverworld = -1; getHandle().setImmuneToZombification(false); } else { - getHandle().conversionTicks = time; + getHandle().timeInOverworld = time; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index eee059d4b..7e07b9240 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -32,6 +32,10 @@ import net.minecraft.network.PacketDataSerializer; import net.minecraft.network.chat.ChatComponentText; import net.minecraft.network.chat.ChatMessageType; import net.minecraft.network.chat.IChatBaseComponent; +import net.minecraft.network.protocol.game.ClientboundClearTitlesPacket; +import net.minecraft.network.protocol.game.ClientboundSetSubtitleTextPacket; +import net.minecraft.network.protocol.game.ClientboundSetTitleTextPacket; +import net.minecraft.network.protocol.game.ClientboundSetTitlesAnimationPacket; import net.minecraft.network.protocol.game.PacketPlayOutBlockBreakAnimation; import net.minecraft.network.protocol.game.PacketPlayOutBlockChange; import net.minecraft.network.protocol.game.PacketPlayOutChat; @@ -44,7 +48,6 @@ import net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo; import net.minecraft.network.protocol.game.PacketPlayOutPlayerListHeaderFooter; import net.minecraft.network.protocol.game.PacketPlayOutSpawnPosition; import net.minecraft.network.protocol.game.PacketPlayOutStopSound; -import net.minecraft.network.protocol.game.PacketPlayOutTitle; import net.minecraft.network.protocol.game.PacketPlayOutUpdateAttributes; import net.minecraft.network.protocol.game.PacketPlayOutUpdateHealth; import net.minecraft.network.protocol.game.PacketPlayOutWorldEvent; @@ -65,8 +68,10 @@ import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.inventory.Container; import net.minecraft.world.item.EnumColor; import net.minecraft.world.level.EnumGamemode; +import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.TileEntitySign; import net.minecraft.world.level.saveddata.maps.MapIcon; +import net.minecraft.world.level.saveddata.maps.WorldMap; import net.minecraft.world.phys.Vec3D; import org.apache.commons.lang.NotImplementedException; import org.apache.commons.lang.Validate; @@ -171,9 +176,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public InetSocketAddress getAddress() { - if (getHandle().playerConnection == null) return null; + if (getHandle().connection == null) return null; - SocketAddress addr = getHandle().playerConnection.networkManager.getSocketAddress(); + SocketAddress addr = getHandle().connection.connection.getSocketAddress(); if (addr instanceof InetSocketAddress) { return (InetSocketAddress) addr; } else { @@ -192,19 +197,19 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void sendRawMessage(String message) { - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; for (IChatBaseComponent component : CraftChatMessage.fromString(message)) { - getHandle().playerConnection.sendPacket(new PacketPlayOutChat(component, ChatMessageType.SYSTEM, SystemUtils.b)); + getHandle().connection.sendPacket(new PacketPlayOutChat(component, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID)); } } @Override public void sendRawMessage(UUID sender, String message) { - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; for (IChatBaseComponent component : CraftChatMessage.fromString(message)) { - getHandle().playerConnection.sendPacket(new PacketPlayOutChat(component, ChatMessageType.CHAT, (sender == null) ? SystemUtils.b : sender)); + getHandle().connection.sendPacket(new PacketPlayOutChat(component, ChatMessageType.CHAT, (sender == null) ? SystemUtils.NIL_UUID : sender)); } } @@ -259,7 +264,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { getHandle().listName = name.equals(getName()) ? null : CraftChatMessage.fromStringOrNull(name); for (EntityPlayer player : (List) server.getHandle().players) { if (player.getBukkitEntity().canSee(this)) { - player.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, getHandle())); + player.connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, getHandle())); } } } @@ -297,12 +302,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } private void updatePlayerListHeaderFooter() { - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; - PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter(); - packet.header = (this.playerListHeader == null) ? new ChatComponentText("") : this.playerListHeader; - packet.footer = (this.playerListFooter == null) ? new ChatComponentText("") : this.playerListFooter; - getHandle().playerConnection.sendPacket(packet); + PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter((this.playerListHeader == null) ? new ChatComponentText("") : this.playerListHeader, (this.playerListFooter == null) ? new ChatComponentText("") : this.playerListFooter); + getHandle().connection.sendPacket(packet); } @Override @@ -327,17 +330,17 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void kickPlayer(String message) { - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; - getHandle().playerConnection.disconnect(message == null ? "" : message); + getHandle().connection.disconnect(message == null ? "" : message); } @Override public void setCompassTarget(Location loc) { - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; // Do not directly assign here, from the packethandler we'll assign it. - getHandle().playerConnection.sendPacket(new PacketPlayOutSpawnPosition(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), loc.getYaw())); + getHandle().connection.sendPacket(new PacketPlayOutSpawnPosition(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), loc.getYaw())); } @Override @@ -347,9 +350,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void chat(String msg) { - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; - getHandle().playerConnection.chat(msg, false); + getHandle().connection.chat(msg, false); } @Override @@ -359,7 +362,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void playNote(Location loc, byte instrument, byte note) { - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; String instrumentName = null; switch (instrument) { @@ -396,12 +399,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } float f = (float) Math.pow(2.0D, (note - 12.0D) / 12.0D); - getHandle().playerConnection.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.sendPacket(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f)); } @Override public void playNote(Location loc, Instrument instrument, Note note) { - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; String instrumentName = null; switch (instrument.ordinal()) { @@ -458,7 +461,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { break; } float f = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D); - getHandle().playerConnection.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.sendPacket(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f)); } @Override @@ -473,18 +476,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void playSound(Location loc, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) { - if (loc == null || sound == null || category == null || getHandle().playerConnection == null) return; + 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().playerConnection.sendPacket(packet); + getHandle().connection.sendPacket(packet); } @Override public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch) { - if (loc == null || sound == null || category == null || getHandle().playerConnection == null) return; + 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().playerConnection.sendPacket(packet); + getHandle().connection.sendPacket(packet); } @Override @@ -504,18 +507,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void stopSound(String sound, org.bukkit.SoundCategory category) { - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; - getHandle().playerConnection.sendPacket(new PacketPlayOutStopSound(new MinecraftKey(sound), category == null ? net.minecraft.sounds.SoundCategory.MASTER : net.minecraft.sounds.SoundCategory.valueOf(category.name()))); + getHandle().connection.sendPacket(new PacketPlayOutStopSound(new MinecraftKey(sound), category == null ? net.minecraft.sounds.SoundCategory.MASTER : net.minecraft.sounds.SoundCategory.valueOf(category.name()))); } @Override public void playEffect(Location loc, Effect effect, int data) { - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; int packetData = effect.getId(); PacketPlayOutWorldEvent packet = new PacketPlayOutWorldEvent(packetData, new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), data, false); - getHandle().playerConnection.sendPacket(packet); + getHandle().connection.sendPacket(packet); } @Override @@ -532,18 +535,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void sendBlockChange(Location loc, Material material, byte data) { - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), CraftMagicNumbers.getBlock(material, data)); - getHandle().playerConnection.sendPacket(packet); + getHandle().connection.sendPacket(packet); } @Override public void sendBlockChange(Location loc, BlockData block) { - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), ((CraftBlockData) block).getState()); - getHandle().playerConnection.sendPacket(packet); + getHandle().connection.sendPacket(packet); } @Override @@ -551,11 +554,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player { Preconditions.checkArgument(loc != null, "loc must not be null"); Preconditions.checkArgument(progress >= 0.0 && progress <= 1.0, "progress must be between 0.0 and 1.0 (inclusive)"); - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; 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().playerConnection.sendPacket(packet); + getHandle().connection.sendPacket(packet); } @Override @@ -565,7 +568,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void sendSignChange(Location loc, String[] lines, DyeColor dyeColor) { - if (getHandle().playerConnection == null) { + if (getHandle().connection == null) { return; } @@ -580,17 +583,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } IChatBaseComponent[] components = CraftSign.sanitizeLines(lines); - TileEntitySign sign = new TileEntitySign(); - sign.setPosition(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); + TileEntitySign sign = new TileEntitySign(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), Blocks.OAK_SIGN.getBlockData()); sign.setColor(EnumColor.fromColorIndex(dyeColor.getWoolData())); - System.arraycopy(components, 0, sign.lines, 0, sign.lines.length); + for (int i = 0; i < components.length; i++) { + sign.a(i, components[i]); + } - getHandle().playerConnection.sendPacket(sign.getUpdatePacket()); + getHandle().connection.sendPacket(sign.getUpdatePacket()); } @Override public boolean sendChunkChange(Location loc, int sx, int sy, int sz, byte[] data) { - if (getHandle().playerConnection == null) return false; + if (getHandle().connection == null) return false; /* int x = loc.getBlockX(); @@ -624,7 +628,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void sendMap(MapView map) { - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; RenderData data = ((CraftMapView) map).render(this); Collection icons = new ArrayList(); @@ -634,8 +638,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } } - PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), map.getScale().getValue(), true, map.isLocked(), icons, data.buffer, 0, 0, 128, 128); - getHandle().playerConnection.sendPacket(packet); + 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); } @Override @@ -651,11 +655,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player { EntityPlayer entity = getHandle(); - if (getHealth() == 0 || entity.dead) { + if (getHealth() == 0 || entity.isRemoved()) { return false; } - if (entity.playerConnection == null) { + if (entity.connection == null) { return false; } @@ -693,13 +697,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player { WorldServer toWorld = ((CraftWorld) to.getWorld()).getHandle(); // Close any foreign inventory - if (getHandle().activeContainer != getHandle().defaultContainer) { + if (getHandle().containerMenu != getHandle().inventoryMenu) { getHandle().closeInventory(); } // Check if the fromWorld and toWorld are the same. if (fromWorld == toWorld) { - entity.playerConnection.teleport(to); + entity.connection.teleport(to); } else { server.getHandle().moveToWorld(entity, toWorld, true, to, true); } @@ -728,18 +732,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void loadData() { - server.getHandle().playerFileData.load(getHandle()); + server.getHandle().playerIo.load(getHandle()); } @Override public void saveData() { - server.getHandle().playerFileData.save(getHandle()); + server.getHandle().playerIo.save(getHandle()); } @Deprecated @Override public void updateInventory() { - getHandle().updateInventory(getHandle().activeContainer); + getHandle().containerMenu.updateInventory(); } @Override @@ -799,7 +803,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public Set getDiscoveredRecipes() { ImmutableSet.Builder bukkitRecipeKeys = ImmutableSet.builder(); - getHandle().getRecipeBook().recipes.forEach(key -> bukkitRecipeKeys.add(CraftNamespacedKey.fromMinecraft(key))); + getHandle().getRecipeBook().known.forEach(key -> bukkitRecipeKeys.add(CraftNamespacedKey.fromMinecraft(key))); return bukkitRecipeKeys.build(); } @@ -955,7 +959,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void setGameMode(GameMode mode) { - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; if (mode == null) { throw new IllegalArgumentException("Mode cannot be null"); @@ -966,7 +970,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public GameMode getGameMode() { - return GameMode.getByValue(getHandle().playerInteractManager.getGameMode().getId()); + return GameMode.getByValue(getHandle().gameMode.getGameMode().getId()); } @Override @@ -981,37 +985,37 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public float getExp() { - return getHandle().exp; + return getHandle().experienceProgress; } @Override public void setExp(float exp) { Preconditions.checkArgument(exp >= 0.0 && exp <= 1.0, "Experience progress must be between 0.0 and 1.0 (%s)", exp); - getHandle().exp = exp; + getHandle().experienceProgress = exp; getHandle().lastSentExp = -1; } @Override public int getLevel() { - return getHandle().expLevel; + return getHandle().experienceLevel; } @Override public void setLevel(int level) { Preconditions.checkArgument(level >= 0, "Experience level must not be negative (%s)", level); - getHandle().expLevel = level; + getHandle().experienceLevel = level; getHandle().lastSentExp = -1; } @Override public int getTotalExperience() { - return getHandle().expTotal; + return getHandle().totalExperience; } @Override public void setTotalExperience(int exp) { Preconditions.checkArgument(exp >= 0, "Total experience points must not be negative (%s)", exp); - getHandle().expTotal = exp; + getHandle().totalExperience = exp; } @Override @@ -1024,12 +1028,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { Preconditions.checkArgument(progress >= 0.0 && progress <= 1.0, "Experience progress must be between 0.0 and 1.0 (%s)", progress); Preconditions.checkArgument(level >= 0, "Experience level must not be negative (%s)", level); - if (getHandle().playerConnection == null) { + if (getHandle().connection == null) { return; } PacketPlayOutExperience packet = new PacketPlayOutExperience(progress, getTotalExperience(), level); - getHandle().playerConnection.sendPacket(packet); + getHandle().connection.sendPacket(packet); } @Nullable @@ -1053,7 +1057,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { private void hidePlayer0(@Nullable Plugin plugin, Player player) { Validate.notNull(player, "hidden player cannot be null"); - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; if (equals(player)) return; Set> hidingPlugins = hiddenPlayers.get(player.getUniqueId()); @@ -1068,16 +1072,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.world).getChunkProvider().playerChunkMap; + PlayerChunkMap tracker = ((WorldServer) entity.level).getChunkProvider().chunkMap; EntityPlayer other = ((CraftPlayer) player).getHandle(); - PlayerChunkMap.EntityTracker entry = tracker.trackedEntities.get(other.getId()); + PlayerChunkMap.EntityTracker entry = tracker.entityMap.get(other.getId()); if (entry != null) { entry.clear(getHandle()); } // Remove the hidden player from this player user list, if they're on it if (other.sentListPacket) { - getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, other)); + getHandle().connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, other)); } } @@ -1097,7 +1101,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { private void showPlayer0(@Nullable Plugin plugin, Player player) { Validate.notNull(player, "shown player cannot be null"); - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; if (equals(player)) return; Set> hidingPlugins = hiddenPlayers.get(player.getUniqueId()); @@ -1110,13 +1114,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } hiddenPlayers.remove(player.getUniqueId()); - PlayerChunkMap tracker = ((WorldServer) entity.world).getChunkProvider().playerChunkMap; + PlayerChunkMap tracker = ((WorldServer) entity.level).getChunkProvider().chunkMap; EntityPlayer other = ((CraftPlayer) player).getHandle(); - getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, other)); + getHandle().connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, other)); - PlayerChunkMap.EntityTracker entry = tracker.trackedEntities.get(other.getId()); - if (entry != null && !entry.trackedPlayers.contains(getHandle())) { + PlayerChunkMap.EntityTracker entry = tracker.entityMap.get(other.getId()); + if (entry != null && !entry.seenBy.contains(getHandle())) { entry.updatePlayer(getHandle()); } } @@ -1251,12 +1255,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void sendPluginMessage(Plugin source, String channel, byte[] message) { StandardMessenger.validatePluginMessage(server.getMessenger(), source, channel, message); - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; if (channels.contains(channel)) { channel = StandardMessenger.validateAndCorrectChannel(channel); PacketPlayOutCustomPayload packet = new PacketPlayOutCustomPayload(new MinecraftKey(channel), new PacketDataSerializer(Unpooled.wrappedBuffer(message))); - getHandle().playerConnection.sendPacket(packet); + getHandle().connection.sendPacket(packet); } } @@ -1269,7 +1273,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"); + getHandle().setResourcePack(url, "null", false, null); } @Override @@ -1278,7 +1282,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)); + getHandle().setResourcePack(url, BaseEncoding.base16().lowerCase().encode(hash), false, null); } public void addChannel(String channel) { @@ -1302,7 +1306,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } public void sendSupportedChannels() { - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; Set listening = server.getMessenger().getIncomingChannels(); if (!listening.isEmpty()) { @@ -1317,7 +1321,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } } - getHandle().playerConnection.sendPacket(new PacketPlayOutCustomPayload(new MinecraftKey("register"), new PacketDataSerializer(Unpooled.wrappedBuffer(stream.toByteArray())))); + getHandle().connection.sendPacket(new PacketPlayOutCustomPayload(new MinecraftKey("register"), new PacketDataSerializer(Unpooled.wrappedBuffer(stream.toByteArray())))); } } @@ -1348,11 +1352,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public boolean setWindowProperty(Property prop, int value) { - Container container = getHandle().activeContainer; + Container container = getHandle().containerMenu; if (container.getBukkitView().getType() != prop.getType()) { return false; } - getHandle().setContainerData(container, prop.getId(), value); + container.setContainerData(prop.getId(), value); return true; } @@ -1363,7 +1367,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public boolean isFlying() { - return getHandle().abilities.isFlying; + return getHandle().getAbilities().flying; } @Override @@ -1372,45 +1376,45 @@ public class CraftPlayer extends CraftHumanEntity implements Player { throw new IllegalArgumentException("Cannot make player fly if getAllowFlight() is false"); } - getHandle().abilities.isFlying = value; + getHandle().getAbilities().flying = value; getHandle().updateAbilities(); } @Override public boolean getAllowFlight() { - return getHandle().abilities.canFly; + return getHandle().getAbilities().mayfly; } @Override public void setAllowFlight(boolean value) { if (isFlying() && !value) { - getHandle().abilities.isFlying = false; + getHandle().getAbilities().flying = false; } - getHandle().abilities.canFly = value; + getHandle().getAbilities().mayfly = value; getHandle().updateAbilities(); } @Override public int getNoDamageTicks() { - if (getHandle().invulnerableTicks > 0) { - return Math.max(getHandle().invulnerableTicks, getHandle().noDamageTicks); + if (getHandle().spawnInvulnerableTime > 0) { + return Math.max(getHandle().spawnInvulnerableTime, getHandle().invulnerableTime); } else { - return getHandle().noDamageTicks; + return getHandle().invulnerableTime; } } @Override public void setNoDamageTicks(int ticks) { super.setNoDamageTicks(ticks); - getHandle().invulnerableTicks = ticks; // SPIGOT-5921: Update both for players, like the getter above + getHandle().spawnInvulnerableTime = ticks; // SPIGOT-5921: Update both for players, like the getter above } @Override public void setFlySpeed(float value) { validateSpeed(value); EntityPlayer player = getHandle(); - player.abilities.flySpeed = value / 2f; + player.getAbilities().flyingSpeed = value / 2f; player.updateAbilities(); } @@ -1419,19 +1423,19 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void setWalkSpeed(float value) { validateSpeed(value); EntityPlayer player = getHandle(); - player.abilities.walkSpeed = value / 2f; + player.getAbilities().walkingSpeed = value / 2f; player.updateAbilities(); - getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(player.abilities.walkSpeed); // SPIGOT-5833: combination of the two in 1.16+ + getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(player.getAbilities().walkingSpeed); // SPIGOT-5833: combination of the two in 1.16+ } @Override public float getFlySpeed() { - return (float) getHandle().abilities.flySpeed * 2f; + return (float) getHandle().getAbilities().flyingSpeed * 2f; } @Override public float getWalkSpeed() { - return getHandle().abilities.walkSpeed * 2f; + return getHandle().getAbilities().walkingSpeed * 2f; } private void validateSpeed(float value) { @@ -1467,7 +1471,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void setScoreboard(Scoreboard scoreboard) { Validate.notNull(scoreboard, "Scoreboard cannot be null"); - PlayerConnection playerConnection = getHandle().playerConnection; + PlayerConnection playerConnection = getHandle().connection; if (playerConnection == null) { throw new IllegalStateException("Cannot set scoreboard yet"); } @@ -1527,19 +1531,19 @@ public class CraftPlayer extends CraftHumanEntity implements Player { injectScaledMaxHealth(set, true); // SPIGOT-3813: Attributes before health - if (getHandle().playerConnection != null) { - getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateAttributes(getHandle().getId(), set)); + if (getHandle().connection != null) { + getHandle().connection.sendPacket(new PacketPlayOutUpdateAttributes(getHandle().getId(), set)); if (sendHealth) { sendHealthUpdate(); } } - getHandle().getDataWatcher().set(EntityLiving.HEALTH, (float) getScaledHealth()); + getHandle().getDataWatcher().set(EntityLiving.DATA_HEALTH_ID, (float) getScaledHealth()); getHandle().maxHealthCache = getMaxHealth(); } public void sendHealthUpdate() { - getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateHealth(getScaledHealth(), getHandle().getFoodData().getFoodLevel(), getHandle().getFoodData().getSaturationLevel())); + getHandle().connection.sendPacket(new PacketPlayOutUpdateHealth(getScaledHealth(), getHandle().getFoodData().getFoodLevel(), getHandle().getFoodData().getSaturationLevel())); } public void injectScaledMaxHealth(Collection collection, boolean force) { @@ -1576,24 +1580,24 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut) { - PacketPlayOutTitle times = new PacketPlayOutTitle(fadeIn, stay, fadeOut); - getHandle().playerConnection.sendPacket(times); + ClientboundSetTitlesAnimationPacket times = new ClientboundSetTitlesAnimationPacket(fadeIn, stay, fadeOut); + getHandle().connection.sendPacket(times); if (title != null) { - PacketPlayOutTitle packetTitle = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TITLE, CraftChatMessage.fromStringOrNull(title)); - getHandle().playerConnection.sendPacket(packetTitle); + ClientboundSetTitleTextPacket packetTitle = new ClientboundSetTitleTextPacket(CraftChatMessage.fromStringOrNull(title)); + getHandle().connection.sendPacket(packetTitle); } if (subtitle != null) { - PacketPlayOutTitle packetSubtitle = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.SUBTITLE, CraftChatMessage.fromStringOrNull(subtitle)); - getHandle().playerConnection.sendPacket(packetSubtitle); + ClientboundSetSubtitleTextPacket packetSubtitle = new ClientboundSetSubtitleTextPacket(CraftChatMessage.fromStringOrNull(subtitle)); + getHandle().connection.sendPacket(packetSubtitle); } } @Override public void resetTitle() { - PacketPlayOutTitle packetReset = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.RESET, null); - getHandle().playerConnection.sendPacket(packetReset); + ClientboundClearTitlesPacket packetReset = new ClientboundClearTitlesPacket(true); + getHandle().connection.sendPacket(packetReset); } @Override @@ -1657,7 +1661,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().playerConnection.sendPacket(packetplayoutworldparticles); + getHandle().connection.sendPacket(packetplayoutworldparticles); } @@ -1679,7 +1683,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public int getPing() { - return getHandle().ping; + return getHandle().latency; } @Override @@ -1689,7 +1693,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void updateCommands() { - if (getHandle().playerConnection == null) return; + if (getHandle().connection == null) return; getHandle().server.getCommandDispatcher().a(getHandle()); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java index 834451ea6..fe220c0d8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java @@ -26,7 +26,7 @@ public abstract class CraftRaider extends CraftMonster implements Raider { @Override public Block getPatrolTarget() { - return getHandle().getPatrolTarget() == null ? null : CraftBlock.at(getHandle().world, getHandle().getPatrolTarget()); + return getHandle().getPatrolTarget() == null ? null : CraftBlock.at(getHandle().level, getHandle().getPatrolTarget()); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java index 0ebd0f407..7bed85e1e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java @@ -32,34 +32,34 @@ public class CraftShulker extends CraftGolem implements Shulker { @Override public DyeColor getColor() { - return DyeColor.getByWoolData(getHandle().getDataWatcher().get(EntityShulker.COLOR)); + return DyeColor.getByWoolData(getHandle().getDataWatcher().get(EntityShulker.DATA_COLOR_ID)); } @Override public void setColor(DyeColor color) { - getHandle().getDataWatcher().set(EntityShulker.COLOR, (color == null) ? 16 : color.getWoolData()); + getHandle().getDataWatcher().set(EntityShulker.DATA_COLOR_ID, (color == null) ? 16 : color.getWoolData()); } @Override public float getPeek() { - return (float) getHandle().eN() / 100; // PAIL rename getPeek + return (float) getHandle().getPeek() / 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().a((int) (value * 100)); // PAIL rename setPeek + getHandle().setPeek((int) (value * 100)); } @Override public BlockFace getAttachedFace() { - return CraftBlock.notchToBlockFace(getHandle().eL()); // PAIL rename getAttachedFace + return CraftBlock.notchToBlockFace(getHandle().getAttachFace()); } @Override public void setAttachedFace(BlockFace face) { Preconditions.checkNotNull(face, "face cannot be null"); Preconditions.checkArgument(face.isCartesian(), "%s is not a valid block face to attach a shulker to, a cartesian block face is expected", face); - getHandle().getDataWatcher().set(EntityShulker.b, CraftBlock.blockFaceToNotch(face)); + getHandle().setAttachFace(CraftBlock.blockFaceToNotch(face)); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java index 3e9be0182..a75dbd018 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java @@ -30,36 +30,36 @@ public class CraftStrider extends CraftAnimals implements Strider { @Override public void setSaddle(boolean saddled) { - getHandle().saddleStorage.setSaddle(saddled); + getHandle().steering.setSaddle(saddled); } @Override public int getBoostTicks() { - return getHandle().saddleStorage.boosting ? getHandle().saddleStorage.boostTicks : 0; + return getHandle().steering.boosting ? getHandle().steering.boostTimeTotal : 0; } @Override public void setBoostTicks(int ticks) { Preconditions.checkArgument(ticks >= 0, "ticks must be >= 0"); - getHandle().saddleStorage.setBoostTicks(ticks); + getHandle().steering.setBoostTicks(ticks); } @Override public int getCurrentBoostTicks() { - return getHandle().saddleStorage.boosting ? getHandle().saddleStorage.currentBoostTicks : 0; + return getHandle().steering.boosting ? getHandle().steering.boostTime : 0; } @Override public void setCurrentBoostTicks(int ticks) { - if (!getHandle().saddleStorage.boosting) { + if (!getHandle().steering.boosting) { return; } - int max = getHandle().saddleStorage.boostTicks; + int max = getHandle().steering.boostTimeTotal; Preconditions.checkArgument(ticks >= 0 && ticks <= max, "boost ticks must not exceed 0 or %d (inclusive)", max); - this.getHandle().saddleStorage.currentBoostTicks = ticks; + this.getHandle().steering.boostTime = ticks; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java index 67a9585c8..4e4ca0169 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java @@ -69,9 +69,9 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed { @Override public void setSource(Entity source) { if (source instanceof LivingEntity) { - getHandle().source = ((CraftLivingEntity) source).getHandle(); + getHandle().owner = ((CraftLivingEntity) source).getHandle(); } else { - getHandle().source = null; + getHandle().owner = null; } } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java index 3a91823b5..af7dbaa68 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java @@ -20,12 +20,12 @@ public class CraftTrident extends CraftArrow implements Trident { @Override public ItemStack getItem() { - return CraftItemStack.asBukkitCopy(getHandle().trident); + return CraftItemStack.asBukkitCopy(getHandle().tridentItem); } @Override public void setItem(ItemStack itemStack) { - getHandle().trident = CraftItemStack.asNMSCopy(itemStack); + getHandle().tridentItem = CraftItemStack.asNMSCopy(itemStack); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java index b020bc9e7..8f92d79b1 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -91,7 +91,7 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { Preconditions.checkArgument(location.getWorld().equals(getWorld()), "Cannot sleep across worlds"); BlockPosition position = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - IBlockData iblockdata = getHandle().world.getType(position); + IBlockData iblockdata = getHandle().level.getType(position); if (!(iblockdata.getBlock() instanceof BlockBed)) { return false; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java index 7734d7ee2..ce4d95b72 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java @@ -68,17 +68,17 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager { public int getConversionTime() { Preconditions.checkState(isConverting(), "Entity not converting"); - return getHandle().conversionTime; + return getHandle().villagerConversionTime; } @Override public void setConversionTime(int time) { if (time < 0) { - getHandle().conversionTime = -1; - getHandle().getDataWatcher().set(EntityZombieVillager.CONVERTING, false); - getHandle().persistent = false; // CraftBukkit - SPIGOT-4684 update persistence - getHandle().conversionPlayer = null; - getHandle().removeEffect(MobEffects.INCREASE_DAMAGE, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); + getHandle().villagerConversionTime = -1; + getHandle().getDataWatcher().set(EntityZombieVillager.DATA_CONVERTING_ID, false); + getHandle().persistenceRequired = 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); } @@ -86,12 +86,12 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager { @Override public OfflinePlayer getConversionPlayer() { - return (getHandle().conversionPlayer == null) ? null : Bukkit.getOfflinePlayer(getHandle().conversionPlayer); + return (getHandle().conversionStarter == null) ? null : Bukkit.getOfflinePlayer(getHandle().conversionStarter); } @Override public void setConversionPlayer(OfflinePlayer conversionPlayer) { if (!this.isConverting()) return; - getHandle().conversionPlayer = (conversionPlayer == null) ? null : conversionPlayer.getUniqueId(); + getHandle().conversionStarter = (conversionPlayer == null) ? null : conversionPlayer.getUniqueId(); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java index 7150702d8..9330e76e8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java @@ -14,8 +14,8 @@ public class CraftWither extends CraftMonster implements Wither { public CraftWither(CraftServer server, EntityWither entity) { super(server, entity); - if (entity.bossBattle != null) { - this.bossBar = new CraftBossBar(entity.bossBattle); + if (entity.bossEvent != null) { + this.bossBar = new CraftBossBar(entity.bossEvent); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java index 8ba92b7ed..b37b160eb 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java @@ -68,14 +68,14 @@ public class CraftZombie extends CraftMonster implements Zombie { public int getConversionTime() { Preconditions.checkState(isConverting(), "Entity not converting"); - return getHandle().drownedConversionTime; + return getHandle().conversionTime; } @Override public void setConversionTime(int time) { if (time < 0) { - getHandle().drownedConversionTime = -1; - getHandle().getDataWatcher().set(EntityZombie.DROWN_CONVERTING, false); + getHandle().conversionTime = -1; + getHandle().getDataWatcher().set(EntityZombie.DATA_DROWNED_CONVERSION_ID, false); } else { getHandle().startDrownedConversion(time); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryMapper.java b/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryMapper.java index eae0f82bb..ed442c198 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryMapper.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryMapper.java @@ -21,6 +21,8 @@ public final class CraftMemoryMapper { return (UUID) object; } else if (object instanceof Boolean) { return (Boolean) object; + } else if (object instanceof Integer) { + return (Integer) object; } throw new UnsupportedOperationException("Do not know how to map " + object); @@ -37,6 +39,8 @@ public final class CraftMemoryMapper { return (UUID) object; } else if (object instanceof Boolean) { return (Boolean) object; + } else if (object instanceof Integer) { + return (Integer) object; } throw new UnsupportedOperationException("Do not know how to map " + object); diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index d6bbee0df..4e54c05d8 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -197,6 +197,7 @@ import org.bukkit.event.inventory.TradeSelectEvent; import org.bukkit.event.player.PlayerBedEnterEvent; import org.bukkit.event.player.PlayerBedEnterEvent.BedEnterResult; import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerBucketEntityEvent; import org.bukkit.event.player.PlayerBucketFillEvent; import org.bukkit.event.player.PlayerBucketFishEvent; import org.bukkit.event.player.PlayerEditBookEvent; @@ -225,7 +226,7 @@ import org.bukkit.inventory.meta.BookMeta; import org.bukkit.potion.PotionEffect; public class CraftEventFactory { - public static final DamageSource MELTING = CraftDamageSource.copyOf(DamageSource.BURN); + public static final DamageSource MELTING = CraftDamageSource.copyOf(DamageSource.ON_FIRE); public static final DamageSource POISON = CraftDamageSource.copyOf(DamageSource.MAGIC); public static org.bukkit.block.Block blockDamage; // For use in EntityDamageByBlockEvent public static Entity entityDamage; // For use in EntityDamageByEntityEvent @@ -272,7 +273,7 @@ public class CraftEventFactory { } }, t -> BedEnterResult.OK).map(java.util.function.Function.identity(), java.util.function.Function.identity()); - PlayerBedEnterEvent event = new PlayerBedEnterEvent((Player) player.getBukkitEntity(), CraftBlock.at(player.world, bed), bedEnterResult); + PlayerBedEnterEvent event = new PlayerBedEnterEvent((Player) player.getBukkitEntity(), CraftBlock.at(player.level, bed), bedEnterResult); Bukkit.getServer().getPluginManager().callEvent(event); Result result = event.useBed(); @@ -308,12 +309,16 @@ public class CraftEventFactory { /** * Player Fish Bucket Event */ - public static PlayerBucketFishEvent callPlayerFishBucketEvent(EntityFish fish, EntityHuman entityHuman, ItemStack waterBucket, ItemStack fishBucket) { - Fish bukkitFish = (Fish) fish.getBukkitEntity(); + public static PlayerBucketEntityEvent callPlayerFishBucketEvent(EntityLiving fish, EntityHuman entityHuman, ItemStack originalBucket, ItemStack entityBucket) { Player player = (Player) entityHuman.getBukkitEntity(); - PlayerBucketFishEvent playerBucketFishEvent = new PlayerBucketFishEvent(player, bukkitFish, CraftItemStack.asBukkitCopy(waterBucket), CraftItemStack.asBukkitCopy(fishBucket)); - Bukkit.getPluginManager().callEvent(playerBucketFishEvent); - return playerBucketFishEvent; + PlayerBucketEntityEvent event; + if (fish instanceof EntityFish) { + event = new PlayerBucketFishEvent(player, (Fish) fish.getBukkitEntity(), CraftItemStack.asBukkitCopy(originalBucket), CraftItemStack.asBukkitCopy(entityBucket)); + } else { + event = new PlayerBucketEntityEvent(player, fish.getBukkitEntity(), CraftItemStack.asBukkitCopy(originalBucket), CraftItemStack.asBukkitCopy(entityBucket)); + } + Bukkit.getPluginManager().callEvent(event); + return event; } /** @@ -389,7 +394,7 @@ public class CraftEventFactory { if (!event.isCancelled()) { for (EntityItem item : items) { - item.world.addEntity(item); + item.level.addEntity(item); } } } @@ -404,7 +409,7 @@ public class CraftEventFactory { org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(clickedFace); EntityPlaceEvent event = new EntityPlaceEvent(entity.getBukkitEntity(), who, blockClicked, blockFace); - entity.world.getServer().getPluginManager().callEvent(event); + entity.level.getServer().getPluginManager().callEvent(event); return event; } @@ -575,7 +580,7 @@ public class CraftEventFactory { if (spawnReason != SpawnReason.CUSTOM) { if (isAnimal && !world.getWorld().getAllowAnimals() || isMonster && !world.getWorld().getAllowMonsters() || isNpc && !world.getServer().getServer().getSpawnNPCs()) { - entity.dead = true; + entity.die(); return false; } } @@ -595,15 +600,15 @@ public class CraftEventFactory { event = CraftEventFactory.callEntitySpawnEvent(entity); } - if (event != null && (event.isCancelled() || entity.dead)) { + if (event != null && (event.isCancelled() || entity.isRemoved())) { Entity vehicle = entity.getVehicle(); if (vehicle != null) { - vehicle.dead = true; + vehicle.die(); } for (Entity passenger : entity.getAllPassengers()) { - passenger.dead = true; + passenger.die(); } - entity.dead = true; + entity.die(); return false; } @@ -641,7 +646,7 @@ public class CraftEventFactory { org.bukkit.entity.AnimalTamer bukkitTamer = (tamer != null ? tamer.getBukkitEntity() : null); CraftServer craftServer = (CraftServer) bukkitEntity.getServer(); - entity.persistent = true; + entity.persistenceRequired = true; EntityTameEvent event = new EntityTameEvent((LivingEntity) bukkitEntity, bukkitTamer); craftServer.getPluginManager().callEvent(event); @@ -735,11 +740,17 @@ public class CraftEventFactory { return handleBlockSpreadEvent(world, source, target, block, 2); } - public static boolean handleBlockSpreadEvent(World world, BlockPosition source, BlockPosition target, IBlockData block, int flag) { + 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); + return true; + } + CraftBlockState state = CraftBlockState.getBlockState(world, target, flag); state.setData(block); - BlockSpreadEvent event = new BlockSpreadEvent(world.getWorld().getBlockAt(target.getX(), target.getY(), target.getZ()), world.getWorld().getBlockAt(source.getX(), source.getY(), source.getZ()), state); + BlockSpreadEvent event = new BlockSpreadEvent(state.getBlock(), CraftBlock.at(world, source), state); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { @@ -841,7 +852,7 @@ public class CraftEventFactory { } else if (damager.getBukkitEntity() instanceof Projectile) { cause = DamageCause.PROJECTILE; } - } else if ("thorns".equals(source.translationIndex)) { + } else if ("thorns".equals(source.msgId)) { cause = DamageCause.THORNS; } @@ -866,14 +877,14 @@ public class CraftEventFactory { DamageCause cause = null; Block damager = blockDamage; blockDamage = null; - if (source == DamageSource.CACTUS || source == DamageSource.SWEET_BERRY_BUSH) { + if (source == DamageSource.CACTUS || source == DamageSource.SWEET_BERRY_BUSH || source == DamageSource.STALAGMITE) { cause = DamageCause.CONTACT; } else if (source == DamageSource.HOT_FLOOR) { cause = DamageCause.HOT_FLOOR; } else if (source == DamageSource.MAGIC) { cause = DamageCause.MAGIC; } else { - throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager, source.translationIndex)); + throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager, source.msgId)); } EntityDamageEvent event = new EntityDamageByBlockEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions); event.setCancelled(cancelled); @@ -886,7 +897,7 @@ public class CraftEventFactory { DamageCause cause = null; CraftEntity damager = entityDamage.getBukkitEntity(); entityDamage = null; - if (source == DamageSource.ANVIL || source == DamageSource.FALLING_BLOCK) { + if (source == DamageSource.ANVIL || source == DamageSource.FALLING_BLOCK || source == DamageSource.FALLING_STALACTITE) { cause = DamageCause.FALLING_BLOCK; } else if (damager instanceof LightningStrike) { cause = DamageCause.LIGHTNING; @@ -897,7 +908,7 @@ public class CraftEventFactory { } else if (source == DamageSource.MAGIC) { cause = DamageCause.MAGIC; } else { - throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager.getHandle(), source.translationIndex)); + throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager.getHandle(), source.msgId)); } EntityDamageEvent event = new EntityDamageByEntityEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions); event.setCancelled(cancelled); @@ -909,17 +920,17 @@ public class CraftEventFactory { } DamageCause cause = null; - if (source == DamageSource.FIRE) { + if (source == DamageSource.IN_FIRE) { cause = DamageCause.FIRE; } else if (source == DamageSource.STARVE) { cause = DamageCause.STARVATION; } else if (source == DamageSource.WITHER) { cause = DamageCause.WITHER; - } else if (source == DamageSource.STUCK) { + } else if (source == DamageSource.IN_WALL) { cause = DamageCause.SUFFOCATION; } else if (source == DamageSource.DROWN) { cause = DamageCause.DROWNING; - } else if (source == DamageSource.BURN) { + } else if (source == DamageSource.ON_FIRE) { cause = DamageCause.FIRE_TICK; } else if (source == MELTING) { cause = DamageCause.MELTING; @@ -933,8 +944,10 @@ public class CraftEventFactory { cause = DamageCause.FLY_INTO_WALL; } else if (source == DamageSource.CRAMMING) { cause = DamageCause.CRAMMING; - } else if (source == DamageSource.DRYOUT) { + } else if (source == DamageSource.DRY_OUT) { cause = DamageCause.DRYOUT; + } else if (source == DamageSource.FREEZE) { + cause = DamageCause.FREEZE; } else if (source == DamageSource.GENERIC) { cause = DamageCause.CUSTOM; } @@ -943,7 +956,7 @@ public class CraftEventFactory { return callEntityDamageEvent(null, entity, cause, modifiers, modifierFunctions, cancelled); } - throw new IllegalStateException(String.format("Unhandled damage of %s from %s", entity, source.translationIndex)); + throw new IllegalStateException(String.format("Unhandled damage of %s from %s", entity, source.msgId)); } private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map modifiers, Map> modifierFunctions) { @@ -1090,7 +1103,7 @@ public class CraftEventFactory { } public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, BlockPosition position, IBlockData newBlock, boolean cancelled) { - Block block = entity.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()); + Block block = entity.level.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()); EntityChangeBlockEvent event = new EntityChangeBlockEvent(entity.getBukkitEntity(), block, CraftBlockData.fromData(newBlock)); event.setCancelled(cancelled); @@ -1118,7 +1131,7 @@ public class CraftEventFactory { public static EntityBreakDoorEvent callEntityBreakDoorEvent(Entity entity, BlockPosition pos) { org.bukkit.entity.Entity entity1 = entity.getBukkitEntity(); - Block block = CraftBlock.at(entity.world, pos); + Block block = CraftBlock.at(entity.level, pos); EntityBreakDoorEvent event = new EntityBreakDoorEvent((LivingEntity) entity1, block); entity1.getServer().getPluginManager().callEvent(event); @@ -1131,20 +1144,20 @@ public class CraftEventFactory { } public static Container callInventoryOpenEvent(EntityPlayer player, Container container, boolean cancelled) { - if (player.activeContainer != player.defaultContainer) { // fire INVENTORY_CLOSE if one already open - player.playerConnection.a(new PacketPlayInCloseWindow(player.activeContainer.windowId)); + if (player.containerMenu != player.inventoryMenu) { // fire INVENTORY_CLOSE if one already open + player.connection.a(new PacketPlayInCloseWindow(player.containerMenu.containerId)); } - CraftServer server = player.world.getServer(); + CraftServer server = player.level.getServer(); CraftPlayer craftPlayer = player.getBukkitEntity(); - player.activeContainer.transferTo(container, craftPlayer); + player.containerMenu.transferTo(container, craftPlayer); InventoryOpenEvent event = new InventoryOpenEvent(container.getBukkitView()); event.setCancelled(cancelled); server.getPluginManager().callEvent(event); if (event.isCancelled()) { - container.transferTo(player.activeContainer, craftPlayer); + container.transferTo(player.containerMenu, craftPlayer); return null; } @@ -1179,7 +1192,7 @@ public class CraftEventFactory { BlockFace hitFace = null; if (position.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) { MovingObjectPositionBlock positionBlock = (MovingObjectPositionBlock) position; - hitBlock = CraftBlock.at(entity.world, positionBlock.getBlockPosition()); + hitBlock = CraftBlock.at(entity.level, positionBlock.getBlockPosition()); hitFace = CraftBlock.notchToBlockFace(positionBlock.getDirection()); } @@ -1189,7 +1202,7 @@ public class CraftEventFactory { } ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity(), hitEntity, hitBlock, hitFace); - entity.world.getServer().getPluginManager().callEvent(event); + entity.level.getServer().getPluginManager().callEvent(event); return event; } @@ -1289,14 +1302,14 @@ public class CraftEventFactory { } public static void handleInventoryCloseEvent(EntityHuman human) { - InventoryCloseEvent event = new InventoryCloseEvent(human.activeContainer.getBukkitView()); - human.world.getServer().getPluginManager().callEvent(event); - human.activeContainer.transferTo(human.defaultContainer, human.getBukkitEntity()); + InventoryCloseEvent event = new InventoryCloseEvent(human.containerMenu.getBukkitView()); + human.level.getServer().getPluginManager().callEvent(event); + human.containerMenu.transferTo(human.inventoryMenu, human.getBukkitEntity()); } public static ItemStack handleEditBookEvent(EntityPlayer player, int itemInHandIndex, ItemStack itemInHand, ItemStack newBookItem) { PlayerEditBookEvent editBookEvent = new PlayerEditBookEvent(player.getBukkitEntity(), (itemInHandIndex >= 0 && itemInHandIndex <= 8) ? itemInHandIndex : -1, (BookMeta) CraftItemStack.getItemMeta(itemInHand), (BookMeta) CraftItemStack.getItemMeta(newBookItem), newBookItem.getItem() == Items.WRITTEN_BOOK); - player.world.getServer().getPluginManager().callEvent(editBookEvent); + player.level.getServer().getPluginManager().callEvent(editBookEvent); // If they've got the same item in their hand, it'll need to be updated. if (itemInHand != null && itemInHand.getItem() == Items.WRITABLE_BOOK) { @@ -1314,13 +1327,13 @@ public class CraftEventFactory { public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(EntityInsentient entity, EntityHuman player) { PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity()); - entity.world.getServer().getPluginManager().callEvent(event); + entity.level.getServer().getPluginManager().callEvent(event); return event; } public static PlayerLeashEntityEvent callPlayerLeashEntityEvent(EntityInsentient entity, Entity leashHolder, EntityHuman player) { PlayerLeashEntityEvent event = new PlayerLeashEntityEvent(entity.getBukkitEntity(), leashHolder.getBukkitEntity(), (Player) player.getBukkitEntity()); - entity.world.getServer().getPluginManager().callEvent(event); + entity.level.getServer().getPluginManager().callEvent(event); return event; } @@ -1380,13 +1393,13 @@ public class CraftEventFactory { event = new PlayerStatisticIncrementEvent(player, stat, current, newValue, material); } } - entityHuman.world.getServer().getPluginManager().callEvent(event); + entityHuman.level.getServer().getPluginManager().callEvent(event); return (Cancellable) event; } public static FireworkExplodeEvent callFireworkExplodeEvent(EntityFireworks firework) { FireworkExplodeEvent event = new FireworkExplodeEvent((Firework) firework.getBukkitEntity()); - firework.world.getServer().getPluginManager().callEvent(event); + firework.level.getServer().getPluginManager().callEvent(event); return event; } @@ -1406,19 +1419,19 @@ public class CraftEventFactory { public static EntityToggleGlideEvent callToggleGlideEvent(EntityLiving entity, boolean gliding) { EntityToggleGlideEvent event = new EntityToggleGlideEvent((LivingEntity) entity.getBukkitEntity(), gliding); - entity.world.getServer().getPluginManager().callEvent(event); + entity.level.getServer().getPluginManager().callEvent(event); return event; } public static EntityToggleSwimEvent callToggleSwimEvent(EntityLiving entity, boolean swimming) { EntityToggleSwimEvent event = new EntityToggleSwimEvent((LivingEntity) entity.getBukkitEntity(), swimming); - entity.world.getServer().getPluginManager().callEvent(event); + entity.level.getServer().getPluginManager().callEvent(event); return event; } public static AreaEffectCloudApplyEvent callAreaEffectCloudApplyEvent(EntityAreaEffectCloud cloud, List entities) { AreaEffectCloudApplyEvent event = new AreaEffectCloudApplyEvent((AreaEffectCloud) cloud.getBukkitEntity(), entities); - cloud.world.getServer().getPluginManager().callEvent(event); + cloud.level.getServer().getPluginManager().callEvent(event); return event; } @@ -1434,7 +1447,7 @@ public class CraftEventFactory { CraftItemStack bredWithStack = bredWith == null ? null : CraftItemStack.asCraftMirror(bredWith).clone(); EntityBreedEvent event = new EntityBreedEvent((LivingEntity) child.getBukkitEntity(), (LivingEntity) mother.getBukkitEntity(), (LivingEntity) father.getBukkitEntity(), breederEntity, bredWithStack, experience); - child.world.getServer().getPluginManager().callEvent(event); + child.level.getServer().getPluginManager().callEvent(event); return event; } diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java index 3d1591527..a95a50958 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java @@ -18,20 +18,24 @@ import org.bukkit.material.MaterialData; * Data to be used for the block types and data in a newly generated chunk. */ public final class CraftChunkData implements ChunkGenerator.ChunkData { + private final int minHeight; private final int maxHeight; private final ChunkSection[] sections; private Set tiles; public CraftChunkData(World world) { - this(world.getMaxHeight()); + this(world.getMinHeight(), world.getMaxHeight()); } - /* pp for tests */ CraftChunkData(int maxHeight) { - if (maxHeight > 256) { - throw new IllegalArgumentException("World height exceeded max chunk height"); - } + /* pp for tests */ CraftChunkData(int minHeight, int maxHeight) { + this.minHeight = minHeight; this.maxHeight = maxHeight; - sections = new ChunkSection[maxHeight >> 4]; + sections = new ChunkSection[(maxHeight - minHeight) >> 4]; + } + + @Override + public int getMinHeight() { + return minHeight; } @Override @@ -92,8 +96,8 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData { if (xMin < 0) { xMin = 0; } - if (yMin < 0) { - yMin = 0; + if (yMin < minHeight) { + yMin = minHeight; } if (zMin < 0) { zMin = 0; @@ -122,7 +126,7 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData { } public IBlockData getTypeId(int x, int y, int z) { - if (x != (x & 0xf) || y < 0 || y >= maxHeight || z != (z & 0xf)) { + if (x != (x & 0xf) || y < minHeight || y >= maxHeight || z != (z & 0xf)) { return Blocks.AIR.getBlockData(); } ChunkSection section = getChunkSection(y, false); @@ -139,13 +143,13 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData { } private void setBlock(int x, int y, int z, IBlockData type) { - if (x != (x & 0xf) || y < 0 || y >= maxHeight || z != (z & 0xf)) { + if (x != (x & 0xf) || y < minHeight || y >= maxHeight || z != (z & 0xf)) { return; } ChunkSection section = getChunkSection(y, true); section.setType(x, y & 0xf, z, type); - if (type.getBlock().isTileEntity()) { + if (type.isTileEntity()) { if (tiles == null) { tiles = new HashSet<>(); } @@ -155,9 +159,10 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData { } private ChunkSection getChunkSection(int y, boolean create) { - ChunkSection section = sections[y >> 4]; + int offset = (y - minHeight) >> 4; + ChunkSection section = sections[offset]; if (create && section == null) { - sections[y >> 4] = section = new ChunkSection(y >> 4 << 4); + sections[offset] = section = new ChunkSection(offset << 4); } return section; } diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java index 7ce7e1303..aa5d61f8b 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java @@ -3,21 +3,25 @@ package org.bukkit.craftbukkit.generator; import com.google.common.base.Preconditions; import com.mojang.serialization.Codec; import java.util.Random; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; import net.minecraft.core.BlockPosition; import net.minecraft.core.IRegistry; import net.minecraft.core.IRegistryCustom; import net.minecraft.server.level.RegionLimitedWorldAccess; import net.minecraft.server.level.WorldServer; +import net.minecraft.world.level.BlockColumn; import net.minecraft.world.level.GeneratorAccess; import net.minecraft.world.level.GeneratorAccessSeed; import net.minecraft.world.level.IBlockAccess; +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.WorldChunkManager; -import net.minecraft.world.level.block.Block; 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; @@ -60,13 +64,13 @@ public class CustomChunkGenerator extends InternalChunkGenerator { @Override public Biome getBiome(int x, int y, int z) { - return CraftBlock.biomeBaseToBiome((IRegistry) biome.registry, biome.getBiome(x >> 2, y >> 2, z >> 2)); + return CraftBlock.biomeBaseToBiome((IRegistry) biome.biomeRegistry, biome.getBiome(x >> 2, y >> 2, z >> 2)); } @Override public void setBiome(int x, int y, int z, Biome bio) { Preconditions.checkArgument(bio != Biome.CUSTOM, "Cannot set the biome to %s", bio); - biome.setBiome(x >> 2, y >> 2, z >> 2, CraftBlock.biomeToBiomeBase((IRegistry) biome.registry, bio)); + biome.setBiome(x >> 2, y >> 2, z >> 2, CraftBlock.biomeToBiomeBase((IRegistry) biome.biomeRegistry, bio)); } } @@ -78,6 +82,11 @@ public class CustomChunkGenerator extends InternalChunkGenerator { this.generator = generator; } + @Override + public net.minecraft.world.level.chunk.ChunkGenerator withSeed(long i) { + return new CustomChunkGenerator(this.world, delegate.withSeed(i), this.generator); + } + @Override public void createBiomes(IRegistry iregistry, IChunkAccess ichunkaccess) { // Don't allow the server to override any custom biomes that have been set @@ -106,7 +115,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator { random.setSeed((long) x * 341873128712L + (long) z * 132897987541L); // Get default biome data for chunk - CustomBiomeGrid biomegrid = new CustomBiomeGrid(new BiomeStorage(world.r().b(IRegistry.ay), ichunkaccess.getPos(), this.getWorldChunkManager())); + CustomBiomeGrid biomegrid = new CustomBiomeGrid(new BiomeStorage(world.t().d(IRegistry.BIOME_REGISTRY), regionlimitedworldaccess, ichunkaccess.getPos(), this.getWorldChunkManager())); ChunkData data; if (generator.isParallelCapable()) { @@ -142,11 +151,11 @@ public class CustomChunkGenerator extends InternalChunkGenerator { int tx = pos.getX(); int ty = pos.getY(); int tz = pos.getZ(); - Block block = craftData.getTypeId(tx, ty, tz).getBlock(); + IBlockData block = craftData.getTypeId(tx, ty, tz); if (block.isTileEntity()) { - TileEntity tile = ((ITileEntity) block).createTile(world); - ichunkaccess.setTileEntity(new BlockPosition((x << 4) + tx, ty, (z << 4) + tz), tile); + TileEntity tile = ((ITileEntity) block).createTile(new BlockPosition((x << 4) + tx, ty, (z << 4) + tz), block); + ichunkaccess.setTileEntity(tile); } } } @@ -170,13 +179,14 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } @Override - public void buildNoise(GeneratorAccess generatoraccess, StructureManager structuremanager, IChunkAccess ichunkaccess) { + public CompletableFuture buildNoise(Executor executor, StructureManager structuremanager, IChunkAccess ichunkaccess) { // Disable vanilla generation + return CompletableFuture.completedFuture(ichunkaccess); } @Override - public int getBaseHeight(int i, int j, HeightMap.Type heightmap_type) { - return delegate.getBaseHeight(i, j, heightmap_type); + public int getBaseHeight(int i, int j, HeightMap.Type heightmap_type, LevelHeightAccessor levelheightaccessor) { + return delegate.getBaseHeight(i, j, heightmap_type, levelheightaccessor); } @Override @@ -194,8 +204,8 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } @Override - public int getSpawnHeight() { - return delegate.getSpawnHeight(); + public int getSpawnHeight(LevelHeightAccessor levelheightaccessor) { + return delegate.getSpawnHeight(levelheightaccessor); } @Override @@ -204,8 +214,8 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } @Override - public IBlockAccess a(int i, int j) { - return delegate.a(i, j); + public BlockColumn getBaseColumn(int i, int j, LevelHeightAccessor levelheightaccessor) { + return delegate.getBaseColumn(i, j, levelheightaccessor); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java index 384520dd7..59d927c45 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java @@ -1,7 +1,5 @@ package org.bukkit.craftbukkit.inventory; -import net.minecraft.network.chat.ChatComponentText; -import net.minecraft.network.protocol.game.PacketPlayOutOpenWindow; import net.minecraft.world.IInventory; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.entity.player.PlayerInventory; @@ -29,7 +27,6 @@ import net.minecraft.world.inventory.ContainerWorkbench; import net.minecraft.world.inventory.Containers; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; -import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.entity.HumanEntity; import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; @@ -39,9 +36,7 @@ public class CraftContainer extends Container { private final InventoryView view; private InventoryType cachedType; - private String cachedTitle; private Container delegate; - private final int cachedSize; public CraftContainer(InventoryView view, EntityHuman player, int id) { super(getNotchInventoryType(view.getTopInventory()), id); @@ -50,8 +45,6 @@ public class CraftContainer extends Container { IInventory top = ((CraftInventory) view.getTopInventory()).getInventory(); PlayerInventory bottom = (PlayerInventory) ((CraftInventory) view.getBottomInventory()).getInventory(); cachedType = view.getType(); - cachedTitle = view.getTitle(); - cachedSize = getSize(); setupSlots(top, bottom, player); } @@ -89,38 +82,6 @@ public class CraftContainer extends Container { return view; } - private int getSize() { - return view.getTopInventory().getSize(); - } - - @Override - public boolean c(EntityHuman entityhuman) { - if (cachedType == view.getType() && cachedSize == getSize() && cachedTitle.equals(view.getTitle())) { - return true; - } - // If the window type has changed for some reason, update the player - // This method will be called every tick or something, so it's - // as good a place as any to put something like this. - boolean typeChanged = (cachedType != view.getType()); - cachedType = view.getType(); - cachedTitle = view.getTitle(); - if (view.getPlayer() instanceof CraftPlayer) { - CraftPlayer player = (CraftPlayer) view.getPlayer(); - Containers type = getNotchInventoryType(view.getTopInventory()); - IInventory top = ((CraftInventory) view.getTopInventory()).getInventory(); - PlayerInventory bottom = (PlayerInventory) ((CraftInventory) view.getBottomInventory()).getInventory(); - this.items.clear(); - this.slots.clear(); - if (typeChanged) { - setupSlots(top, bottom, player.getHandle()); - } - int size = getSize(); - player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, new ChatComponentText(cachedTitle))); - player.updateInventory(); - } - return true; - } - public static Containers getNotchInventoryType(Inventory inventory) { switch (inventory.getType()) { case PLAYER: @@ -129,18 +90,18 @@ public class CraftContainer extends Container { case BARREL: switch (inventory.getSize()) { case 9: - return Containers.GENERIC_9X1; + return Containers.GENERIC_9x1; case 18: - return Containers.GENERIC_9X2; + return Containers.GENERIC_9x2; case 27: - return Containers.GENERIC_9X3; + return Containers.GENERIC_9x3; case 36: case 41: // PLAYER - return Containers.GENERIC_9X4; + return Containers.GENERIC_9x4; case 45: - return Containers.GENERIC_9X5; + return Containers.GENERIC_9x5; case 54: - return Containers.GENERIC_9X6; + return Containers.GENERIC_9x6; default: throw new IllegalArgumentException("Unsupported custom inventory size " + inventory.getSize()); } @@ -149,7 +110,7 @@ public class CraftContainer extends Container { case FURNACE: return Containers.FURNACE; case DISPENSER: - return Containers.GENERIC_3X3; + return Containers.GENERIC_3x3; case ENCHANTING: return Containers.ENCHANTMENT; case BREWING: @@ -163,7 +124,7 @@ public class CraftContainer extends Container { case HOPPER: return Containers.HOPPER; case DROPPER: - return Containers.GENERIC_3X3; + return Containers.GENERIC_3x3; case SHULKER_BOX: return Containers.SHULKER_BOX; case BLAST_FURNACE: @@ -186,7 +147,7 @@ public class CraftContainer extends Container { throw new IllegalArgumentException("Can't open a " + inventory.getType() + " inventory!"); default: // TODO: If it reaches the default case, should we throw an error? - return Containers.GENERIC_9X3; + return Containers.GENERIC_9x3; } } @@ -199,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.getSize() / 9); break; case DISPENSER: case DROPPER: @@ -260,7 +221,7 @@ public class CraftContainer extends Container { } if (delegate != null) { - this.items = delegate.items; + this.lastSlots = delegate.lastSlots; this.slots = delegate.slots; } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java index 27e0e2767..879ef718b 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java @@ -248,17 +248,17 @@ public class CraftEntityEquipment implements EntityEquipment { private void setDropChance(EnumItemSlot slot, float chance) { if (slot == EnumItemSlot.MAINHAND || slot == EnumItemSlot.OFFHAND) { - ((EntityInsentient) entity.getHandle()).dropChanceHand[slot.b()] = chance; + ((EntityInsentient) entity.getHandle()).handDropChances[slot.b()] = chance; } else { - ((EntityInsentient) entity.getHandle()).dropChanceArmor[slot.b()] = chance; + ((EntityInsentient) entity.getHandle()).armorDropChances[slot.b()] = chance; } } private float getDropChance(EnumItemSlot slot) { if (slot == EnumItemSlot.MAINHAND || slot == EnumItemSlot.OFFHAND) { - return ((EntityInsentient) entity.getHandle()).dropChanceHand[slot.b()]; + return ((EntityInsentient) entity.getHandle()).handDropChances[slot.b()]; } else { - return ((EntityInsentient) entity.getHandle()).dropChanceArmor[slot.b()]; + return ((EntityInsentient) entity.getHandle()).armorDropChances[slot.b()]; } } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java index fd59f77d7..2386eb2a0 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java @@ -24,17 +24,17 @@ public class CraftInventoryAnvil extends CraftResultInventory implements AnvilIn @Override public String getRenameText() { - return container.renameText; + return container.itemName; } @Override public int getRepairCost() { - return container.levelCost.get(); + return container.cost.get(); } @Override public void setRepairCost(int i) { - container.levelCost.set(i); + container.cost.set(i); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java index 323eb1926..d075c191e 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java @@ -105,7 +105,7 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn if (i < contents.length) { getMatrixInventory().setItem(i, CraftItemStack.asNMSCopy(contents[i])); } else { - getMatrixInventory().setItem(i, net.minecraft.world.item.ItemStack.b); + getMatrixInventory().setItem(i, net.minecraft.world.item.ItemStack.EMPTY); } } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java index a537cc4ac..370af0da0 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java +++ b/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.b); + this.items = NonNullList.a(size, ItemStack.EMPTY); this.title = title; this.viewers = new ArrayList(); this.owner = owner; @@ -76,9 +76,9 @@ public class CraftInventoryCustom extends CraftInventory { public ItemStack splitStack(int i, int j) { ItemStack stack = this.getItem(i); ItemStack result; - if (stack == ItemStack.b) return stack; + if (stack == ItemStack.EMPTY) return stack; if (stack.getCount() <= j) { - this.setItem(i, ItemStack.b); + this.setItem(i, ItemStack.EMPTY); result = stack; } else { result = CraftItemStack.copyNMSStack(stack, j); @@ -92,7 +92,7 @@ public class CraftInventoryCustom extends CraftInventory { public ItemStack splitWithoutUpdate(int i) { ItemStack stack = this.getItem(i); ItemStack result; - if (stack == ItemStack.b) return stack; + if (stack == ItemStack.EMPTY) return stack; if (stack.getCount() <= 1) { this.setItem(i, null); result = stack; @@ -106,7 +106,7 @@ public class CraftInventoryCustom extends CraftInventory { @Override public void setItem(int i, ItemStack itemstack) { items.set(i, itemstack); - if (itemstack != ItemStack.b && this.getMaxStackSize() > 0 && itemstack.getCount() > this.getMaxStackSize()) { + if (itemstack != ItemStack.EMPTY && this.getMaxStackSize() > 0 && itemstack.getCount() > this.getMaxStackSize()) { itemstack.setCount(this.getMaxStackSize()); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java index 47029af76..30141a95c 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java @@ -17,21 +17,21 @@ public class CraftInventoryDoubleChest extends CraftInventory implements DoubleC public CraftInventoryDoubleChest(BlockChest.DoubleInventory block) { super(block.inventorylargechest); this.tile = block; - this.left = new CraftInventory(block.inventorylargechest.left); - this.right = new CraftInventory(block.inventorylargechest.right); + this.left = new CraftInventory(block.inventorylargechest.container1); + this.right = new CraftInventory(block.inventorylargechest.container2); } public CraftInventoryDoubleChest(InventoryLargeChest largeChest) { super(largeChest); - if (largeChest.left instanceof InventoryLargeChest) { - left = new CraftInventoryDoubleChest((InventoryLargeChest) largeChest.left); + if (largeChest.container1 instanceof InventoryLargeChest) { + left = new CraftInventoryDoubleChest((InventoryLargeChest) largeChest.container1); } else { - left = new CraftInventory(largeChest.left); + left = new CraftInventory(largeChest.container1); } - if (largeChest.right instanceof InventoryLargeChest) { - right = new CraftInventoryDoubleChest((InventoryLargeChest) largeChest.right); + if (largeChest.container2 instanceof InventoryLargeChest) { + right = new CraftInventoryDoubleChest((InventoryLargeChest) largeChest.container2); } else { - right = new CraftInventory(largeChest.right); + right = new CraftInventory(largeChest.container2); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryMerchant.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryMerchant.java index 6863e220d..2dcb6e90d 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryMerchant.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryMerchant.java @@ -17,7 +17,7 @@ public class CraftInventoryMerchant extends CraftInventory implements MerchantIn @Override public int getSelectedRecipeIndex() { - return getInventory().selectedIndex; + return getInventory().selectionHint; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java index b812e1af4..17b867212 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java @@ -44,7 +44,7 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i @Override public ItemStack getItemInOffHand() { - return CraftItemStack.asCraftMirror(getInventory().extraSlots.get(0)); + return CraftItemStack.asCraftMirror(getInventory().offhand.get(0)); } @Override @@ -74,7 +74,7 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i super.setItem(index, item); if (this.getHolder() == null) return; EntityPlayer player = ((CraftPlayer) this.getHolder()).getHandle(); - if (player.playerConnection == null) return; + if (player.connection == null) return; // PacketPlayOutSetSlot places the items differently than setItem() // // Between, and including, index 9 (the first index outside of the hotbar) and index 35 (the last index before @@ -110,7 +110,7 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i } else if (index > 35) { index = 8 - (index - 36); } - player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.defaultContainer.windowId, index, CraftItemStack.asNMSCopy(item))); + player.connection.sendPacket(new PacketPlayOutSetSlot(player.inventoryMenu.containerId, index, CraftItemStack.asNMSCopy(item))); } @Override @@ -170,14 +170,14 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i @Override public int getHeldItemSlot() { - return getInventory().itemInHandIndex; + return getInventory().selected; } @Override public void setHeldItemSlot(int slot) { Validate.isTrue(slot >= 0 && slot < PlayerInventory.getHotbarSize(), "Slot is not between 0 and 8 inclusive"); - this.getInventory().itemInHandIndex = slot; - ((CraftPlayer) this.getHolder()).getHandle().playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(slot)); + this.getInventory().selected = slot; + ((CraftPlayer) this.getHolder()).getHandle().connection.sendPacket(new PacketPlayOutHeldItemSlot(slot)); } @Override @@ -272,12 +272,12 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i @Override public ItemStack[] getExtraContents() { - return asCraftMirror(getInventory().extraSlots); + return asCraftMirror(getInventory().offhand); } @Override public void setExtraContents(ItemStack[] items) { - setSlots(items, getInventory().items.size() + getInventory().armor.size(), getInventory().extraSlots.size()); + setSlots(items, getInventory().items.size() + getInventory().armor.size(), getInventory().offhand.size()); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySmithing.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySmithing.java index 7004bd83c..ac36437b3 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySmithing.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySmithing.java @@ -39,7 +39,7 @@ public class CraftInventorySmithing extends CraftResultInventory implements Smit @Override public Recipe getRecipe() { - IRecipe recipe = getResultInventory().ak_(); + IRecipe recipe = getResultInventory().getRecipeUsed(); return (recipe == null) ? null : recipe.toBukkitRecipe(); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java index 89a361706..7bcf8a3bd 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -252,6 +252,7 @@ public final class CraftItemFactory implements ItemFactory { case SMOKER: case BEEHIVE: case BEE_NEST: + case SCULK_SENSOR: return new CraftMetaBlockState(meta, material); case TROPICAL_FISH_BUCKET: return meta instanceof CraftMetaTropicalFishBucket ? meta : new CraftMetaTropicalFishBucket(meta); @@ -267,6 +268,8 @@ public final class CraftItemFactory implements ItemFactory { return meta instanceof CraftMetaEntityTag ? meta : new CraftMetaEntityTag(meta); case COMPASS: return meta instanceof CraftMetaCompass ? meta : new CraftMetaCompass(meta); + case BUNDLE: + return meta instanceof CraftMetaBundle ? meta : new CraftMetaBundle(meta); default: return new CraftMetaItem(meta); } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index 52fa8a385..b9b08fb9c 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -25,16 +25,16 @@ 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.b : stack.handle.cloneItemStack(); + return stack.handle == null ? net.minecraft.world.item.ItemStack.EMPTY : stack.handle.cloneItemStack(); } if (original == null || original.getType() == Material.AIR) { - return net.minecraft.world.item.ItemStack.b; + return net.minecraft.world.item.ItemStack.EMPTY; } Item item = CraftMagicNumbers.getItem(original.getType(), original.getDurability()); if (item == null) { - return net.minecraft.world.item.ItemStack.b; + return net.minecraft.world.item.ItemStack.EMPTY; } net.minecraft.world.item.ItemStack stack = new net.minecraft.world.item.ItemStack(item, original.getAmount()); @@ -521,6 +521,7 @@ public final class CraftItemStack extends ItemStack { case SMOKER: case BEEHIVE: case BEE_NEST: + case SCULK_SENSOR: return new CraftMetaBlockState(item.getTag(), CraftMagicNumbers.getMaterial(item.getItem())); case TROPICAL_FISH_BUCKET: return new CraftMetaTropicalFishBucket(item.getTag()); @@ -536,6 +537,8 @@ public final class CraftItemStack extends ItemStack { return new CraftMetaEntityTag(item.getTag()); case COMPASS: return new CraftMetaCompass(item.getTag()); + case BUNDLE: + return new CraftMetaBundle(item.getTag()); default: return new CraftMetaItem(item.getTag()); } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java index ef10c7ab1..9da2b9c32 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java @@ -51,7 +51,7 @@ public class CraftMerchantCustom extends CraftMerchant { public void setTradingPlayer(EntityHuman entityhuman) { this.tradingPlayer = entityhuman; if (entityhuman != null) { - this.tradingWorld = entityhuman.world; + this.tradingWorld = entityhuman.level; } } @@ -72,7 +72,7 @@ public class CraftMerchantCustom extends CraftMerchant { } @Override - public void k(ItemStack itemstack) { + public void m(ItemStack itemstack) { } public IChatBaseComponent getScoreboardDisplayName() { @@ -100,7 +100,11 @@ public class CraftMerchantCustom extends CraftMerchant { @Override public SoundEffect getTradeSound() { - return SoundEffects.ENTITY_VILLAGER_YES; + return SoundEffects.VILLAGER_YES; + } + + @Override + public void a(MerchantRecipeList merchantrecipelist) { } } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java index e3b9a0ebe..79e286ebe 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java @@ -10,17 +10,17 @@ public class CraftMerchantRecipe extends MerchantRecipe { private final net.minecraft.world.item.trading.MerchantRecipe handle; public CraftMerchantRecipe(net.minecraft.world.item.trading.MerchantRecipe merchantRecipe) { - super(CraftItemStack.asBukkitCopy(merchantRecipe.sellingItem), 0); + super(CraftItemStack.asBukkitCopy(merchantRecipe.result), 0); this.handle = merchantRecipe; - addIngredient(CraftItemStack.asBukkitCopy(merchantRecipe.buyingItem1)); - addIngredient(CraftItemStack.asBukkitCopy(merchantRecipe.buyingItem2)); + addIngredient(CraftItemStack.asBukkitCopy(merchantRecipe.baseCostA)); + addIngredient(CraftItemStack.asBukkitCopy(merchantRecipe.costB)); } public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier) { super(result, uses, maxUses, experienceReward, experience, priceMultiplier); this.handle = new net.minecraft.world.item.trading.MerchantRecipe( - net.minecraft.world.item.ItemStack.b, - net.minecraft.world.item.ItemStack.b, + net.minecraft.world.item.ItemStack.EMPTY, + net.minecraft.world.item.ItemStack.EMPTY, CraftItemStack.asNMSCopy(result), uses, maxUses, @@ -84,9 +84,9 @@ public class CraftMerchantRecipe extends MerchantRecipe { public net.minecraft.world.item.trading.MerchantRecipe toMinecraft() { List ingredients = getIngredients(); Preconditions.checkState(!ingredients.isEmpty(), "No offered ingredients"); - handle.buyingItem1 = CraftItemStack.asNMSCopy(ingredients.get(0)); + handle.baseCostA = CraftItemStack.asNMSCopy(ingredients.get(0)); if (ingredients.size() > 1) { - handle.buyingItem2 = CraftItemStack.asNMSCopy(ingredients.get(1)); + handle.costB = CraftItemStack.asNMSCopy(ingredients.get(1)); } return handle; } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java index d003a2e5d..f2ffeb22f 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java @@ -3,9 +3,11 @@ package org.bukkit.craftbukkit.inventory; import com.google.common.base.Objects; import com.google.common.collect.ImmutableMap; import java.util.Map; +import net.minecraft.core.BlockPosition; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.item.EnumColor; +import net.minecraft.world.level.block.entity.SculkSensorBlockEntity; import net.minecraft.world.level.block.entity.TileEntity; import net.minecraft.world.level.block.entity.TileEntityBanner; import net.minecraft.world.level.block.entity.TileEntityBarrel; @@ -35,6 +37,7 @@ import net.minecraft.world.level.block.entity.TileEntitySign; import net.minecraft.world.level.block.entity.TileEntitySkull; import net.minecraft.world.level.block.entity.TileEntitySmoker; import net.minecraft.world.level.block.entity.TileEntityStructure; +import net.minecraft.world.level.block.state.IBlockData; import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.block.BlockState; @@ -63,6 +66,7 @@ import org.bukkit.craftbukkit.block.CraftHopper; import org.bukkit.craftbukkit.block.CraftJigsaw; import org.bukkit.craftbukkit.block.CraftJukebox; import org.bukkit.craftbukkit.block.CraftLectern; +import org.bukkit.craftbukkit.block.CraftSculkSensor; import org.bukkit.craftbukkit.block.CraftShulkerBox; import org.bukkit.craftbukkit.block.CraftSign; import org.bukkit.craftbukkit.block.CraftSkull; @@ -248,6 +252,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case SMOKER: case BEEHIVE: case BEE_NEST: + case SCULK_SENSOR: return true; } return false; @@ -301,7 +306,9 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta break; } } - TileEntity te = (blockEntityTag == null) ? null : TileEntity.create(CraftMagicNumbers.getBlock(stateMaterial).getBlockData(), blockEntityTag); + BlockPosition blockposition = BlockPosition.ZERO; + IBlockData iblockdata = CraftMagicNumbers.getBlock(stateMaterial).getBlockData(); + TileEntity te = (blockEntityTag == null) ? null : TileEntity.create(blockposition, iblockdata, blockEntityTag); switch (material) { case ACACIA_SIGN: @@ -321,53 +328,53 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case WARPED_SIGN: case WARPED_WALL_SIGN: if (te == null) { - te = new TileEntitySign(); + te = new TileEntitySign(blockposition, iblockdata); } return new CraftSign(material, (TileEntitySign) te); case CHEST: case TRAPPED_CHEST: if (te == null) { - te = new TileEntityChest(); + te = new TileEntityChest(blockposition, iblockdata); } return new CraftChest(material, (TileEntityChest) te); case FURNACE: if (te == null) { - te = new TileEntityFurnaceFurnace(); + te = new TileEntityFurnaceFurnace(blockposition, iblockdata); } return new CraftFurnaceFurnace(material, (TileEntityFurnaceFurnace) te); case DISPENSER: if (te == null) { - te = new TileEntityDispenser(); + te = new TileEntityDispenser(blockposition, iblockdata); } return new CraftDispenser(material, (TileEntityDispenser) te); case DROPPER: if (te == null) { - te = new TileEntityDropper(); + te = new TileEntityDropper(blockposition, iblockdata); } return new CraftDropper(material, (TileEntityDropper) te); case END_GATEWAY: if (te == null) { - te = new TileEntityEndGateway(); + te = new TileEntityEndGateway(blockposition, iblockdata); } return new CraftEndGateway(material, (TileEntityEndGateway) te); case HOPPER: if (te == null) { - te = new TileEntityHopper(); + te = new TileEntityHopper(blockposition, iblockdata); } return new CraftHopper(material, (TileEntityHopper) te); case SPAWNER: if (te == null) { - te = new TileEntityMobSpawner(); + te = new TileEntityMobSpawner(blockposition, iblockdata); } return new CraftCreatureSpawner(material, (TileEntityMobSpawner) te); case JUKEBOX: if (te == null) { - te = new TileEntityJukeBox(); + te = new TileEntityJukeBox(blockposition, iblockdata); } return new CraftJukebox(material, (TileEntityJukeBox) te); case BREWING_STAND: if (te == null) { - te = new TileEntityBrewingStand(); + te = new TileEntityBrewingStand(blockposition, iblockdata); } return new CraftBrewingStand(material, (TileEntityBrewingStand) te); case CREEPER_HEAD: @@ -383,26 +390,26 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case ZOMBIE_HEAD: case ZOMBIE_WALL_HEAD: if (te == null) { - te = new TileEntitySkull(); + te = new TileEntitySkull(blockposition, iblockdata); } return new CraftSkull(material, (TileEntitySkull) te); case COMMAND_BLOCK: case REPEATING_COMMAND_BLOCK: case CHAIN_COMMAND_BLOCK: if (te == null) { - te = new TileEntityCommand(); + te = new TileEntityCommand(blockposition, iblockdata); } return new CraftCommandBlock(material, (TileEntityCommand) te); case BEACON: if (te == null) { - te = new TileEntityBeacon(); + te = new TileEntityBeacon(blockposition, iblockdata); } return new CraftBeacon(material, (TileEntityBeacon) te); case SHIELD: if (te == null) { - te = new TileEntityBanner(); + te = new TileEntityBanner(blockposition, iblockdata); } - ((TileEntityBanner) te).color = (blockEntityTag == null) ? EnumColor.WHITE : EnumColor.fromColorIndex(blockEntityTag.getInt(CraftMetaBanner.BASE.NBT)); + ((TileEntityBanner) te).baseColor = (blockEntityTag == null) ? EnumColor.WHITE : EnumColor.fromColorIndex(blockEntityTag.getInt(CraftMetaBanner.BASE.NBT)); case BLACK_BANNER: case BLACK_WALL_BANNER: case BLUE_BANNER: @@ -436,12 +443,12 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case YELLOW_BANNER: case YELLOW_WALL_BANNER: if (te == null) { - te = new TileEntityBanner(); + te = new TileEntityBanner(blockposition, iblockdata); } return new CraftBanner(material == Material.SHIELD ? shieldToBannerHack(blockEntityTag) : material, (TileEntityBanner) te); case STRUCTURE_BLOCK: if (te == null) { - te = new TileEntityStructure(); + te = new TileEntityStructure(blockposition, iblockdata); } return new CraftStructureBlock(material, (TileEntityStructure) te); case SHULKER_BOX: @@ -462,71 +469,76 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case RED_SHULKER_BOX: case BLACK_SHULKER_BOX: if (te == null) { - te = new TileEntityShulkerBox(); + te = new TileEntityShulkerBox(blockposition, iblockdata); } return new CraftShulkerBox(material, (TileEntityShulkerBox) te); case ENCHANTING_TABLE: if (te == null) { - te = new TileEntityEnchantTable(); + te = new TileEntityEnchantTable(blockposition, iblockdata); } return new CraftEnchantingTable(material, (TileEntityEnchantTable) te); case ENDER_CHEST: if (te == null) { - te = new TileEntityEnderChest(); + te = new TileEntityEnderChest(blockposition, iblockdata); } return new CraftEnderChest(material, (TileEntityEnderChest) te); case DAYLIGHT_DETECTOR: if (te == null) { - te = new TileEntityLightDetector(); + te = new TileEntityLightDetector(blockposition, iblockdata); } return new CraftDaylightDetector(material, (TileEntityLightDetector) te); case COMPARATOR: if (te == null) { - te = new TileEntityComparator(); + te = new TileEntityComparator(blockposition, iblockdata); } return new CraftComparator(material, (TileEntityComparator) te); case BARREL: if (te == null) { - te = new TileEntityBarrel(); + te = new TileEntityBarrel(blockposition, iblockdata); } return new CraftBarrel(material, (TileEntityBarrel) te); case BELL: if (te == null) { - te = new TileEntityBell(); + te = new TileEntityBell(blockposition, iblockdata); } return new CraftBell(material, (TileEntityBell) te); case BLAST_FURNACE: if (te == null) { - te = new TileEntityBlastFurnace(); + te = new TileEntityBlastFurnace(blockposition, iblockdata); } return new CraftBlastFurnace(material, (TileEntityBlastFurnace) te); case CAMPFIRE: case SOUL_CAMPFIRE: if (te == null) { - te = new TileEntityCampfire(); + te = new TileEntityCampfire(blockposition, iblockdata); } return new CraftCampfire(material, (TileEntityCampfire) te); case JIGSAW: if (te == null) { - te = new TileEntityJigsaw(); + te = new TileEntityJigsaw(blockposition, iblockdata); } return new CraftJigsaw(material, (TileEntityJigsaw) te); case LECTERN: if (te == null) { - te = new TileEntityLectern(); + te = new TileEntityLectern(blockposition, iblockdata); } return new CraftLectern(material, (TileEntityLectern) te); case SMOKER: if (te == null) { - te = new TileEntitySmoker(); + te = new TileEntitySmoker(blockposition, iblockdata); } return new CraftSmoker(material, (TileEntitySmoker) te); case BEE_NEST: case BEEHIVE: if (te == null) { - te = new TileEntityBeehive(); + te = new TileEntityBeehive(blockposition, iblockdata); } return new CraftBeehive(material, (TileEntityBeehive) te); + case SCULK_SENSOR: + if (te == null) { + te = new SculkSensorBlockEntity(blockposition, iblockdata); + } + return new CraftSculkSensor(material, (SculkSensorBlockEntity) te); default: throw new IllegalStateException("Missing blockState for " + material); } @@ -701,6 +713,9 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case BEE_NEST: valid = blockState instanceof CraftBeehive; break; + case SCULK_SENSOR: + valid = blockState instanceof CraftSculkSensor; + break; default: valid = false; break; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java new file mode 100644 index 000000000..4b6d3faad --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java @@ -0,0 +1,186 @@ +package org.bukkit.craftbukkit.inventory; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import org.bukkit.Material; +import org.bukkit.configuration.serialization.DelegateDeserialization; +import org.bukkit.craftbukkit.inventory.CraftMetaItem.ItemMetaKey; +import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BundleMeta; + +@DelegateDeserialization(CraftMetaItem.SerializableMeta.class) +public class CraftMetaBundle extends CraftMetaItem implements BundleMeta { + + static final ItemMetaKey ITEMS = new ItemMetaKey("Items", "items"); + // + private List items; + + CraftMetaBundle(CraftMetaItem meta) { + super(meta); + + if (!(meta instanceof CraftMetaBundle)) { + return; + } + + CraftMetaBundle bundle = (CraftMetaBundle) meta; + + if (bundle.hasItems()) { + this.items = new ArrayList<>(bundle.items); + } + } + + CraftMetaBundle(NBTTagCompound tag) { + super(tag); + + if (tag.hasKeyOfType(ITEMS.NBT, CraftMagicNumbers.NBT.TAG_LIST)) { + NBTTagList list = tag.getList(ITEMS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND); + + if (list != null && !list.isEmpty()) { + items = new ArrayList<>(); + + for (int i = 0; i < list.size(); i++) { + NBTTagCompound nbttagcompound1 = list.getCompound(i); + + addItem(CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.a(nbttagcompound1))); + } + } + } + } + + CraftMetaBundle(Map map) { + super(map); + + Iterable items = SerializableMeta.getObject(Iterable.class, map, ITEMS.BUKKIT, true); + if (items != null) { + for (Object stack : items) { + if (stack instanceof ItemStack) { + this.items.add((ItemStack) stack); + } + } + } + } + + @Override + void applyToItem(NBTTagCompound tag) { + super.applyToItem(tag); + + if (hasItems()) { + NBTTagList list = new NBTTagList(); + + for (ItemStack item : items) { + NBTTagCompound saved = new NBTTagCompound(); + CraftItemStack.asNMSCopy(item).save(saved); + list.add(saved); + } + + tag.set(ITEMS.NBT, list); + } + } + + @Override + boolean applicableTo(Material type) { + switch (type) { + case BUNDLE: + return true; + default: + return false; + } + } + + @Override + boolean isEmpty() { + return super.isEmpty() && isBundleEmpty(); + } + + boolean isBundleEmpty() { + return !(hasItems()); + } + + @Override + public boolean hasItems() { + return items != null && !items.isEmpty(); + } + + @Override + public List getItems() { + return (items == null) ? ImmutableList.of() : ImmutableList.copyOf(items); + } + + @Override + public void setItems(List items) { + items = null; + + if (items == null) { + return; + } + + for (ItemStack i : items) { + addItem(i); + } + } + + @Override + public void addItem(ItemStack item) { + Preconditions.checkArgument(item != null && !item.getType().isAir(), "item is null or air"); + + if (items == null) { + items = new ArrayList<>(); + } + + items.add(item); + } + + @Override + boolean equalsCommon(CraftMetaItem meta) { + if (!super.equalsCommon(meta)) { + return false; + } + if (meta instanceof CraftMetaBundle) { + CraftMetaBundle that = (CraftMetaBundle) meta; + + return (hasItems() ? that.hasItems() && this.items.equals(that.items) : !that.hasItems()); + } + return true; + } + + @Override + boolean notUncommon(CraftMetaItem meta) { + return super.notUncommon(meta) && (meta instanceof CraftMetaBundle || isBundleEmpty()); + } + + @Override + int applyHash() { + final int original; + int hash = original = super.applyHash(); + + if (hasItems()) { + hash = 61 * hash + items.hashCode(); + } + + return original != hash ? CraftMetaBundle.class.hashCode() ^ hash : hash; + } + + @Override + public CraftMetaBundle clone() { + return (CraftMetaBundle) super.clone(); + } + + @Override + ImmutableMap.Builder serialize(ImmutableMap.Builder builder) { + super.serialize(builder); + + if (hasItems()) { + builder.put(ITEMS.BUKKIT, items); + } + + return builder; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCompass.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCompass.java index 10ef4c6f0..a547ca7de 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCompass.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCompass.java @@ -131,7 +131,7 @@ public class CraftMetaCompass extends CraftMetaItem implements CompassMeta { if (lodestoneWorld == null) { return null; } - Optional> key = net.minecraft.world.level.World.f.parse(DynamicOpsNBT.a, lodestoneWorld).result(); + Optional> key = net.minecraft.world.level.World.RESOURCE_KEY_CODEC.parse(DynamicOpsNBT.INSTANCE, lodestoneWorld).result(); WorldServer worldServer = key.isPresent() ? MinecraftServer.getServer().getWorldServer(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 @@ -144,7 +144,7 @@ public class CraftMetaCompass extends CraftMetaItem implements CompassMeta { this.lodestoneWorld = null; } else { ResourceKey key = ((CraftWorld) lodestone.getWorld()).getHandle().getDimensionKey(); - DataResult dataresult = net.minecraft.world.level.World.f.encodeStart(DynamicOpsNBT.a, key); + DataResult dataresult = net.minecraft.world.level.World.RESOURCE_KEY_CODEC.encodeStart(DynamicOpsNBT.INSTANCE, key); this.lodestoneWorld = (NBTTagString) dataresult.get().orThrow(); this.lodestoneX = lodestone.getBlockX(); this.lodestoneY = lodestone.getBlockY(); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index 2a1deb8d9..f5172e113 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -156,6 +156,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { .put(CraftMetaSuspiciousStew.class, "SUSPICIOUS_STEW") .put(CraftMetaEntityTag.class, "ENTITY_TAG") .put(CraftMetaCompass.class, "COMPASS") + .put(CraftMetaBundle.class, "BUNDLE") .put(CraftMetaItem.class, "UNSPECIFIC") .build(); @@ -1406,7 +1407,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { CraftMetaSuspiciousStew.EFFECTS.NBT, CraftMetaCompass.LODESTONE_DIMENSION.NBT, CraftMetaCompass.LODESTONE_POS.NBT, - CraftMetaCompass.LODESTONE_TRACKED.NBT + CraftMetaCompass.LODESTONE_TRACKED.NBT, + CraftMetaBundle.ITEMS.NBT )); } return HANDLED_TAGS; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java index d171b8fc3..a3467994d 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java @@ -90,9 +90,10 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { if (profile != null) { // Fill in textures - setProfile(TileEntitySkull.b(profile)); - - tag.set(SKULL_OWNER.NBT, serializedProfile); + TileEntitySkull.a(profile, (filledProfile) -> { + setProfile(filledProfile); + tag.set(SKULL_OWNER.NBT, serializedProfile); + }); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java index b7e8c3798..9b7acad5a 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java @@ -16,7 +16,7 @@ public interface CraftRecipe extends Recipe { RecipeItemStack stack; if (bukkit == null) { - stack = RecipeItemStack.a; + stack = RecipeItemStack.EMPTY; } else if (bukkit instanceof RecipeChoice.MaterialChoice) { stack = new RecipeItemStack(((RecipeChoice.MaterialChoice) bukkit).getChoices().stream().map((mat) -> new net.minecraft.world.item.crafting.RecipeItemStack.StackProvider(CraftItemStack.asNMSCopy(new ItemStack(mat))))); } else if (bukkit instanceof RecipeChoice.ExactChoice) { @@ -27,7 +27,7 @@ public interface CraftRecipe extends Recipe { } stack.buildChoices(); - if (requireNotEmpty && stack.choices.length == 0) { + if (requireNotEmpty && stack.itemStacks.length == 0) { throw new IllegalArgumentException("Recipe requires at least one non-air choice!"); } @@ -37,21 +37,21 @@ public interface CraftRecipe extends Recipe { public static RecipeChoice toBukkit(RecipeItemStack list) { list.buildChoices(); - if (list.choices.length == 0) { + if (list.itemStacks.length == 0) { return null; } if (list.exact) { - List choices = new ArrayList<>(list.choices.length); - for (net.minecraft.world.item.ItemStack i : list.choices) { + List choices = new ArrayList<>(list.itemStacks.length); + for (net.minecraft.world.item.ItemStack i : list.itemStacks) { choices.add(CraftItemStack.asBukkitCopy(i)); } return new RecipeChoice.ExactChoice(choices); } else { - List choices = new ArrayList<>(list.choices.length); - for (net.minecraft.world.item.ItemStack i : list.choices) { + List choices = new ArrayList<>(list.itemStacks.length); + for (net.minecraft.world.item.ItemStack i : list.itemStacks) { choices.add(CraftMagicNumbers.getMaterial(i.getItem())); } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java index b69097f9c..5c4b0c07d 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java @@ -47,7 +47,7 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe { String[] shape = this.getShape(); Map ingred = this.getChoiceMap(); int width = shape[0].length(); - NonNullList data = NonNullList.a(shape.length * width, RecipeItemStack.a); + NonNullList data = NonNullList.a(shape.length * width, RecipeItemStack.EMPTY); for (int i = 0; i < shape.length; i++) { String row = shape[i]; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java index de9c5ed6b..82fd9c493 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java @@ -39,7 +39,7 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe @Override public void addToCraftingManager() { List ingred = this.getChoiceList(); - NonNullList data = NonNullList.a(ingred.size(), RecipeItemStack.a); + NonNullList data = NonNullList.a(ingred.size(), RecipeItemStack.EMPTY); for (int i = 0; i < ingred.size(); i++) { data.set(i, toNMS(ingred.get(i), true)); } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java index f35e66dab..d69dc9cbd 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java @@ -4,6 +4,7 @@ import net.minecraft.core.BlockPosition; import net.minecraft.server.MinecraftServer; import net.minecraft.world.IInventory; import net.minecraft.world.level.World; +import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.TileEntityBlastFurnace; import net.minecraft.world.level.block.entity.TileEntityBrewingStand; import net.minecraft.world.level.block.entity.TileEntityDispenser; @@ -49,8 +50,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public IInventory getTileEntity() { - TileEntityFurnace furnace = new TileEntityFurnaceFurnace(); - furnace.setLocation(MinecraftServer.getServer().getWorldServer(World.OVERWORLD), BlockPosition.ZERO); // TODO: customize this if required + TileEntityFurnace furnace = new TileEntityFurnaceFurnace(BlockPosition.ZERO, Blocks.FURNACE.getBlockData()); // TODO: customize this if required return furnace; } @@ -71,7 +71,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public IInventory getTileEntity() { - return new TileEntityBrewingStand(); + return new TileEntityBrewingStand(BlockPosition.ZERO, Blocks.BREWING_STAND.getBlockData()); } @Override @@ -94,7 +94,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public IInventory getTileEntity() { - return new TileEntityDispenser(); + return new TileEntityDispenser(BlockPosition.ZERO, Blocks.DISPENSER.getBlockData()); } } @@ -102,7 +102,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public IInventory getTileEntity() { - return new TileEntityDropper(); + return new TileEntityDropper(BlockPosition.ZERO, Blocks.DROPPER.getBlockData()); } } @@ -110,7 +110,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public IInventory getTileEntity() { - return new TileEntityHopper(); + return new TileEntityHopper(BlockPosition.ZERO, Blocks.HOPPER.getBlockData()); } } @@ -118,7 +118,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public IInventory getTileEntity() { - return new TileEntityBlastFurnace(); + return new TileEntityBlastFurnace(BlockPosition.ZERO, Blocks.BLAST_FURNACE.getBlockData()); } } @@ -126,7 +126,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public IInventory getTileEntity() { - return new TileEntityLectern().inventory; + return new TileEntityLectern(BlockPosition.ZERO, Blocks.LECTERN.getBlockData()).bookAccess; } } @@ -134,7 +134,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public IInventory getTileEntity() { - return new TileEntitySmoker(); + return new TileEntitySmoker(BlockPosition.ZERO, Blocks.SMOKER.getBlockData()); } } } diff --git a/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java b/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java index b86604cbf..ab58b0cac 100644 --- a/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java +++ b/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java @@ -8,6 +8,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Optional; import java.util.Set; +import net.minecraft.SharedConstants; import net.minecraft.core.IRegistry; import net.minecraft.nbt.DynamicOpsNBT; import net.minecraft.nbt.NBTBase; @@ -312,6 +313,7 @@ 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(); for (Material material : Material.values()) { @@ -400,7 +402,7 @@ public final class CraftLegacy { stack.setInt("id", material.getId()); stack.setShort("Damage", data); - Dynamic converted = DataConverterRegistry.a().update(DataConverterTypes.ITEM_STACK, new Dynamic(DynamicOpsNBT.a, stack), -1, CraftMagicNumbers.INSTANCE.getDataVersion()); + Dynamic converted = DataConverterRegistry.a().update(DataConverterTypes.ITEM_STACK, new Dynamic(DynamicOpsNBT.INSTANCE, stack), -1, CraftMagicNumbers.INSTANCE.getDataVersion()); String newId = converted.get("id").asString(""); // Recover spawn eggs with invalid data diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java index 1f0b117fc..a33babdf1 100644 --- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java +++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java @@ -34,14 +34,14 @@ public class CraftMapRenderer extends MapRenderer { cursors.removeCursor(cursors.getCursor(0)); } - for (Object key : worldMap.decorations.keySet()) { + for (String key : worldMap.decorations.keySet()) { // If this cursor is for a player check visibility with vanish system Player other = Bukkit.getPlayerExact((String) key); if (other != null && !player.canSee(other)) { continue; } - MapIcon decoration = (MapIcon) worldMap.decorations.get(key); + MapIcon decoration = worldMap.decorations.get(key); cursors.addCursor(decoration.getX(), decoration.getY(), (byte) (decoration.getRotation() & 15), decoration.getType().a(), true, CraftChatMessage.fromComponent(decoration.getName())); } } diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java index 30631e831..0b760dbf9 100644 --- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java +++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java @@ -32,7 +32,7 @@ public final class CraftMapView implements MapView { @Override public int getId() { - String text = worldMap.getId(); + String text = worldMap.id; if (text.startsWith("map_")) { try { return Integer.parseInt(text.substring("map_".length())); @@ -61,7 +61,7 @@ public final class CraftMapView implements MapView { @Override public World getWorld() { - ResourceKey dimension = worldMap.map; + ResourceKey dimension = worldMap.dimension; WorldServer world = MinecraftServer.getServer().getWorldServer(dimension); return (world == null) ? null : world.getWorld(); @@ -69,27 +69,27 @@ public final class CraftMapView implements MapView { @Override public void setWorld(World world) { - worldMap.map = ((CraftWorld) world).getHandle().getDimensionKey(); + worldMap.dimension = ((CraftWorld) world).getHandle().getDimensionKey(); } @Override public int getCenterX() { - return worldMap.centerX; + return worldMap.x; } @Override public int getCenterZ() { - return worldMap.centerZ; + return worldMap.z; } @Override public void setCenterX(int x) { - worldMap.centerX = x; + worldMap.x = x; } @Override public void setCenterZ(int z) { - worldMap.centerZ = z; + worldMap.z = z; } @Override @@ -178,12 +178,12 @@ public final class CraftMapView implements MapView { @Override public boolean isTrackingPosition() { - return worldMap.track; + return worldMap.trackingPosition; } @Override public void setTrackingPosition(boolean trackingPosition) { - worldMap.track = trackingPosition; + worldMap.trackingPosition = trackingPosition; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java b/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java index 39844f401..da8effafd 100644 --- a/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java +++ b/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java @@ -99,7 +99,7 @@ public class CraftBlockProjectileSource implements BlockProjectileSource { } else { launch = new EntityTippedArrow(world, iposition.getX(), iposition.getY(), iposition.getZ()); } - ((EntityArrow) launch).fromPlayer = EntityArrow.PickupStatus.ALLOWED; + ((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); @@ -115,19 +115,19 @@ public class CraftBlockProjectileSource implements BlockProjectileSource { } else if (WitherSkull.class.isAssignableFrom(projectile)) { launch = EntityTypes.WITHER_SKULL.a(world); launch.setPosition(d0, d1, d2); - double d6 = (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5); + double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5); - ((EntityFireball) launch).dirX = d3 / d6 * 0.1D; - ((EntityFireball) launch).dirY = d4 / d6 * 0.1D; - ((EntityFireball) launch).dirZ = d5 / d6 * 0.1D; + ((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); - double d6 = (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5); + double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5); - ((EntityFireball) launch).dirX = d3 / d6 * 0.1D; - ((EntityFireball) launch).dirY = d4 / d6 * 0.1D; - ((EntityFireball) launch).dirZ = d5 / d6 * 0.1D; + ((EntityFireball) launch).xPower = d3 / d6 * 0.1D; + ((EntityFireball) launch).yPower = d4 / d6 * 0.1D; + ((EntityFireball) launch).zPower = d5 / d6 * 0.1D; } ((EntityFireball) launch).projectileSource = this; diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftCriteria.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftCriteria.java index 1a5d9f1b0..4e0d1b92a 100644 --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftCriteria.java +++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftCriteria.java @@ -12,9 +12,9 @@ final class CraftCriteria { static { ImmutableMap.Builder defaults = ImmutableMap.builder(); - for (Map.Entry entry : ((Map) IScoreboardCriteria.criteria).entrySet()) { - String name = entry.getKey().toString(); - IScoreboardCriteria criteria = (IScoreboardCriteria) entry.getValue(); + for (Map.Entry entry : IScoreboardCriteria.CRITERIA_CACHE.entrySet()) { + String name = entry.getKey(); + IScoreboardCriteria criteria = entry.getValue(); defaults.put(name, new CraftCriteria(criteria)); } diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java index efcd5aa02..51942cbde 100644 --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java +++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java @@ -76,7 +76,7 @@ public final class CraftScoreboardManager implements ScoreboardManager { for (int i = 0; i < 3; ++i) { ScoreboardObjective scoreboardobjective = oldboard.getObjectiveForSlot(i); if (scoreboardobjective != null && !removed.contains(scoreboardobjective)) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutScoreboardObjective(scoreboardobjective, 1)); + entityplayer.connection.sendPacket(new PacketPlayOutScoreboardObjective(scoreboardobjective, 1)); removed.add(scoreboardobjective); } } @@ -85,7 +85,7 @@ public final class CraftScoreboardManager implements ScoreboardManager { Iterator iterator = oldboard.getTeams().iterator(); while (iterator.hasNext()) { ScoreboardTeam scoreboardteam = (ScoreboardTeam) iterator.next(); - entityplayer.playerConnection.sendPacket(new PacketPlayOutScoreboardTeam(scoreboardteam, 1)); + entityplayer.connection.sendPacket(PacketPlayOutScoreboardTeam.a(scoreboardteam)); } // The above is the reverse of the below method. diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java index 45cbdcfc1..8617e3b95 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java @@ -193,6 +193,9 @@ public class Commodore case "ZOMBIE_PIGMAN_SPAWN_EGG": name = "ZOMBIFIED_PIGLIN_SPAWN_EGG"; break; + case "GRASS_PATH": + name = "DIRT_PATH"; + break; } } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java index 6a0b4cd36..424a3e7e7 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java @@ -38,7 +38,7 @@ public final class CraftChatMessage { } public static ChatColor getColor(EnumChatFormat format) { - return ChatColor.getByChar(format.character); + return ChatColor.getByChar(format.code); } private static final class StringMessage { @@ -46,11 +46,11 @@ 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.a.setBold(false).setItalic(false).setUnderline(false).setStrikethrough(false).setRandom(false); + private static final ChatModifier RESET = ChatModifier.EMPTY.setBold(false).setItalic(false).setUnderline(false).setStrikethrough(false).setRandom(false); private final List list = new ArrayList(); private IChatMutableComponent currentChatComponent = new ChatComponentText(""); - private ChatModifier modifier = ChatModifier.a; + private ChatModifier modifier = ChatModifier.EMPTY; private final IChatBaseComponent[] output; private int currentIndex; private StringBuilder hex; diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftDamageSource.java b/src/main/java/org/bukkit/craftbukkit/util/CraftDamageSource.java index cf0124cd7..4d88de6dc 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftDamageSource.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftDamageSource.java @@ -5,7 +5,7 @@ import net.minecraft.world.damagesource.DamageSource; // Util class to create custom DamageSources. public final class CraftDamageSource extends DamageSource { public static DamageSource copyOf(final DamageSource original) { - CraftDamageSource newSource = new CraftDamageSource(original.translationIndex); + CraftDamageSource newSource = new CraftDamageSource(original.msgId); // Check ignoresArmor if (original.ignoresArmor()) { diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftDimensionUtil.java b/src/main/java/org/bukkit/craftbukkit/util/CraftDimensionUtil.java index 174b743c8..f8a2bf635 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftDimensionUtil.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftDimensionUtil.java @@ -11,12 +11,12 @@ public class CraftDimensionUtil { public static ResourceKey getMainDimensionKey(World world) { ResourceKey typeKey = world.getTypeKey(); - if (typeKey == DimensionManager.OVERWORLD) { + if (typeKey == DimensionManager.OVERWORLD_LOCATION) { return World.OVERWORLD; - } else if (typeKey == DimensionManager.THE_NETHER) { - return World.THE_NETHER; - } else if (typeKey == DimensionManager.THE_END) { - return World.THE_END; + } else if (typeKey == DimensionManager.NETHER_LOCATION) { + return World.NETHER; + } else if (typeKey == DimensionManager.END_LOCATION) { + return World.END; } return world.getDimensionKey(); diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 972840fd3..defaec786 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -198,7 +198,7 @@ public final class CraftMagicNumbers implements UnsafeValues { return Material.getMaterial(material); } - Dynamic name = new Dynamic<>(DynamicOpsNBT.a, NBTTagString.a("minecraft:" + material.toLowerCase(Locale.ROOT))); + Dynamic name = new Dynamic<>(DynamicOpsNBT.INSTANCE, NBTTagString.a("minecraft:" + material.toLowerCase(Locale.ROOT))); Dynamic converted = DataConverterRegistry.a().update(DataConverterTypes.ITEM_NAME, name, version, this.getDataVersion()); if (name.equals(converted)) { @@ -224,7 +224,7 @@ public final class CraftMagicNumbers implements UnsafeValues { * @return string */ public String getMappingsVersion() { - return "d4b392244df170796f8779ef0fc1f2e9"; + return "acd6e6c27e5a0a9440afba70a96c27c9"; } @Override @@ -248,7 +248,7 @@ public final class CraftMagicNumbers implements UnsafeValues { } private static File getBukkitDataPackFolder() { - return new File(MinecraftServer.getServer().a(SavedFile.DATAPACKS).toFile(), "bukkit"); + return new File(MinecraftServer.getServer().a(SavedFile.DATAPACK_DIR).toFile(), "bukkit"); } @Override @@ -258,11 +258,11 @@ public final class CraftMagicNumbers implements UnsafeValues { } MinecraftKey minecraftkey = CraftNamespacedKey.toMinecraft(key); - JsonElement jsonelement = AdvancementDataWorld.DESERIALIZER.fromJson(advancement, JsonElement.class); + 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())); if (nms != null) { - MinecraftServer.getServer().getAdvancementData().REGISTRY.a(Maps.newHashMap(Collections.singletonMap(minecraftkey, nms))); + MinecraftServer.getServer().getAdvancementData().advancements.a(Maps.newHashMap(Collections.singletonMap(minecraftkey, nms))); Advancement bukkit = Bukkit.getAdvancement(key); if (bukkit != null) { @@ -290,7 +290,7 @@ public final class CraftMagicNumbers implements UnsafeValues { return file.delete(); } - private static final List SUPPORTED_API = Arrays.asList("1.13", "1.14", "1.15", "1.16"); + private static final List SUPPORTED_API = Arrays.asList("1.13", "1.14", "1.15", "1.16", "1.17"); @Override public void checkSupported(PluginDescriptionFile pdf) throws InvalidPluginException { diff --git a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java index f4ea5809f..edc9a7c96 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java +++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java @@ -4,8 +4,10 @@ import java.util.List; import java.util.Random; import java.util.function.Predicate; import net.minecraft.core.BlockPosition; +import net.minecraft.core.EnumDirection; import net.minecraft.core.IRegistryCustom; import net.minecraft.core.particles.ParticleParam; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.WorldServer; import net.minecraft.sounds.SoundCategory; import net.minecraft.sounds.SoundEffect; @@ -25,6 +27,8 @@ import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.IChunkAccess; import net.minecraft.world.level.chunk.IChunkProvider; import net.minecraft.world.level.dimension.DimensionManager; +import net.minecraft.world.level.entity.EntityTypeTest; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.levelgen.HeightMap; import net.minecraft.world.level.lighting.LightEngine; import net.minecraft.world.level.material.Fluid; @@ -59,6 +63,11 @@ public class DummyGeneratorAccess implements GeneratorAccess { throw new UnsupportedOperationException("Not supported yet."); } + @Override + public MinecraftServer getMinecraftServer() { + throw new UnsupportedOperationException("Not supported yet."); + } + @Override public IChunkProvider getChunkProvider() { throw new UnsupportedOperationException("Not supported yet."); @@ -81,6 +90,11 @@ public class DummyGeneratorAccess implements GeneratorAccess { @Override public void a(EntityHuman entityhuman, int i, BlockPosition blockposition, int j) { + // Used by PowderSnowBlock.removeFluid + } + + @Override + public void a(Entity entity, GameEvent gameevent, BlockPosition blockposition) { throw new UnsupportedOperationException("Not supported yet."); } @@ -90,7 +104,7 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public IRegistryCustom r() { + public IRegistryCustom t() { throw new UnsupportedOperationException("Not supported yet."); } @@ -100,7 +114,7 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public List a(Class type, AxisAlignedBB aabb, Predicate prdct) { + public List a(EntityTypeTest ett, AxisAlignedBB aabb, Predicate prdct) { throw new UnsupportedOperationException("Not supported yet."); } @@ -120,12 +134,12 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public int c() { + public int n_() { throw new UnsupportedOperationException("Not supported yet."); } @Override - public BiomeManager d() { + public BiomeManager r_() { throw new UnsupportedOperationException("Not supported yet."); } @@ -135,8 +149,8 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public boolean s_() { - throw new UnsupportedOperationException("Not supported yet."); + public boolean isClientSide() { + return false; } @Override @@ -150,7 +164,12 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public LightEngine e() { + public float a(EnumDirection ed, boolean bln) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public LightEngine k_() { throw new UnsupportedOperationException("Not supported yet."); } @@ -179,6 +198,11 @@ public class DummyGeneratorAccess implements GeneratorAccess { throw new UnsupportedOperationException("Not supported yet."); } + @Override + public boolean b(BlockPosition bp, Predicate prdct) { + throw new UnsupportedOperationException("Not supported yet."); + } + @Override public boolean a(BlockPosition blockposition, IBlockData iblockdata, int i, int j) { return false; diff --git a/src/test/java/org/bukkit/BiomeTest.java b/src/test/java/org/bukkit/BiomeTest.java index 3f478abc0..c95b80286 100644 --- a/src/test/java/org/bukkit/BiomeTest.java +++ b/src/test/java/org/bukkit/BiomeTest.java @@ -17,14 +17,14 @@ public class BiomeTest extends AbstractTestingBase { continue; } - Assert.assertNotNull("No NMS mapping for " + biome, CraftBlock.biomeToBiomeBase(RegistryGeneration.WORLDGEN_BIOME, biome)); + Assert.assertNotNull("No NMS mapping for " + biome, CraftBlock.biomeToBiomeBase(RegistryGeneration.BIOME, biome)); } } @Test public void testMinecraftToBukkit() { - for (BiomeBase biomeBase : RegistryGeneration.WORLDGEN_BIOME) { - Biome biome = CraftBlock.biomeBaseToBiome(RegistryGeneration.WORLDGEN_BIOME, biomeBase); + for (BiomeBase biomeBase : RegistryGeneration.BIOME) { + Biome biome = CraftBlock.biomeBaseToBiome(RegistryGeneration.BIOME, biomeBase); Assert.assertTrue("No Bukkit mapping for " + biomeBase, biome != null && biome != Biome.CUSTOM); } } diff --git a/src/test/java/org/bukkit/GameEventTest.java b/src/test/java/org/bukkit/GameEventTest.java new file mode 100644 index 000000000..e133dff23 --- /dev/null +++ b/src/test/java/org/bukkit/GameEventTest.java @@ -0,0 +1,19 @@ +package org.bukkit; + +import net.minecraft.core.IRegistry; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.support.AbstractTestingBase; +import org.junit.Assert; +import org.junit.Test; + +public class GameEventTest extends AbstractTestingBase { + + @Test + public void toBukkit() { + for (net.minecraft.world.level.gameevent.GameEvent nms : IRegistry.GAME_EVENT) { + GameEvent bukkit = GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.GAME_EVENT.getKey(nms))); + + Assert.assertNotNull("Bukkit should not be null " + nms, bukkit); + } + } +} diff --git a/src/test/java/org/bukkit/ParticleTest.java b/src/test/java/org/bukkit/ParticleTest.java index 49282d691..bd4e44202 100644 --- a/src/test/java/org/bukkit/ParticleTest.java +++ b/src/test/java/org/bukkit/ParticleTest.java @@ -22,6 +22,10 @@ public class ParticleTest extends AbstractTestingBase { data = new MaterialData(Material.LEGACY_STONE); } else if (bukkit.getDataType() == Particle.DustOptions.class) { data = new Particle.DustOptions(Color.BLACK, 0); + } else if (bukkit.getDataType() == Particle.DustTransition.class) { + data = new Particle.DustTransition(Color.BLACK, Color.WHITE, 0); + } else if (bukkit.getDataType() == Vibration.class) { + data = new Vibration(new Location(null, 0, 0, 0), new Vibration.Destination.BlockDestination(new Location(null, 0, 0, 0)), 0); } else if (bukkit.getDataType() == BlockData.class) { data = CraftBlockData.newData(Material.STONE, ""); } diff --git a/src/test/java/org/bukkit/PerMaterialTest.java b/src/test/java/org/bukkit/PerMaterialTest.java index a777d0d8f..ab00359f9 100644 --- a/src/test/java/org/bukkit/PerMaterialTest.java +++ b/src/test/java/org/bukkit/PerMaterialTest.java @@ -27,7 +27,6 @@ import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.support.AbstractTestingBase; -import org.bukkit.support.Util; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -41,7 +40,7 @@ public class PerMaterialTest extends AbstractTestingBase { @BeforeClass public static void getFireValues() { - fireValues = Util.getInternalState(BlockFire.class, Blocks.FIRE, "flameChances"); + fireValues = ((BlockFire) Blocks.FIRE).flameOdds; } @Parameters(name = "{index}: {0}") @@ -232,7 +231,7 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void testBlockHardness() { if (material.isBlock()) { - assertThat(material.getHardness(), is(CraftMagicNumbers.getBlock(material).getBlockData().strength)); + assertThat(material.getHardness(), is(CraftMagicNumbers.getBlock(material).getBlockData().destroySpeed)); } } @@ -263,7 +262,7 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void testEquipmentSlot() { if (material.isItem()) { - EquipmentSlot expected = CraftEquipmentSlot.getSlot(EntityInsentient.j(CraftItemStack.asNMSCopy(new ItemStack(material)))); // PAIL rename getEquipmentSlotForItem + EquipmentSlot expected = CraftEquipmentSlot.getSlot(EntityInsentient.getEquipmentSlotForItem(CraftItemStack.asNMSCopy(new ItemStack(material)))); assertThat(material.getEquipmentSlot(), is(expected)); } } diff --git a/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java b/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java index d9c70d395..d256ab477 100644 --- a/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java +++ b/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java @@ -31,7 +31,7 @@ public class StatisticsAndAchievementsTest extends AbstractTestingBase { @SuppressWarnings("unchecked") public void verifyStatisticMapping() throws Throwable { HashMultiset statistics = HashMultiset.create(); - for (StatisticWrapper wrapper : IRegistry.STATS) { + for (StatisticWrapper wrapper : IRegistry.STAT_TYPE) { for (Object child : wrapper.getRegistry()) { net.minecraft.stats.Statistic statistic = wrapper.b(child); String message = String.format("org.bukkit.Statistic is missing: '%s'", statistic); diff --git a/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java b/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java index b59b28aa9..40c324612 100644 --- a/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java +++ b/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java @@ -32,16 +32,23 @@ public class ChunkDataTest extends AbstractTestingBase { } } + @Test + public void testMinHeight() { + CraftChunkData data = new CraftChunkData(-128, 128); + 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() { - CraftChunkData data = new CraftChunkData(128); + CraftChunkData data = new CraftChunkData(0, 128); 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() { - CraftChunkData data = new CraftChunkData(256); + CraftChunkData data = new CraftChunkData(0, 256); 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)); @@ -54,7 +61,7 @@ public class ChunkDataTest extends AbstractTestingBase { @Test public void testSetRegion() { - CraftChunkData data = new CraftChunkData(256); + CraftChunkData data = new CraftChunkData(0, 256); 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/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java index 9a351c137..b813d2d7c 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java @@ -36,6 +36,7 @@ import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.BlockDataMeta; import org.bukkit.inventory.meta.BlockStateMeta; import org.bukkit.inventory.meta.BookMeta; +import org.bukkit.inventory.meta.BundleMeta; import org.bukkit.inventory.meta.CrossbowMeta; import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.FireworkEffectMeta; @@ -341,6 +342,14 @@ public class ItemMetaTest extends AbstractTestingBase { cleanStack.setItemMeta(meta); return cleanStack; } + }, + new StackProvider(Material.BUNDLE) { + @Override ItemStack operate(ItemStack cleanStack) { + final BundleMeta meta = (BundleMeta) cleanStack.getItemMeta(); + meta.addItem(new ItemStack(Material.STONE)); + cleanStack.setItemMeta(meta); + return cleanStack; + } } ); diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java index 8718e4570..b9abed464 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java +++ b/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.DAMAGE_ALL, 1); + nmsItemStack.addEnchantment(Enchantments.SHARPNESS, 1); ItemStack itemStack = CraftItemStack.asCraftMirror(nmsItemStack); ItemStack clone = itemStack.clone(); assertThat(clone.getType(), is(itemStack.getType())); diff --git a/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java b/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java index 5ce268bb2..02eae5a40 100644 --- a/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java +++ b/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java @@ -64,6 +64,25 @@ public class LegacyTest extends AbstractTestingBase { Material.SOUL_CAMPFIRE, Material.STRIDER_SPAWN_EGG, Material.WARPED_FUNGUS_ON_A_STICK, Material.ZOGLIN_SPAWN_EGG, Material.CHAIN, Material.MUSIC_DISC_PIGSTEP, // 1.16.2 Material.PIGLIN_BRUTE_SPAWN_EGG, + // 1.17 + Material.AMETHYST_BLOCK, Material.AMETHYST_CLUSTER, Material.AMETHYST_SHARD, Material.AXOLOTL_BUCKET, Material.AXOLOTL_SPAWN_EGG, Material.AZALEA, Material.AZALEA_LEAVES, Material.FLOWERING_AZALEA_LEAVES, Material.BIG_DRIPLEAF, + Material.BIG_DRIPLEAF_STEM, Material.BLACK_CANDLE, Material.BLACK_CANDLE_CAKE, Material.BLUE_CANDLE, Material.BLUE_CANDLE_CAKE, Material.BROWN_CANDLE, Material.BROWN_CANDLE_CAKE, Material.BUDDING_AMETHYST, Material.BUNDLE, Material.CALCITE, + Material.CANDLE, Material.CANDLE_CAKE, Material.CAVE_VINES, Material.CAVE_VINES_PLANT, Material.CHISELED_DEEPSLATE, Material.COBBLED_DEEPSLATE, Material.COBBLED_DEEPSLATE_SLAB, Material.COBBLED_DEEPSLATE_STAIRS, Material.COBBLED_DEEPSLATE_WALL, + Material.COPPER_BLOCK, Material.COPPER_INGOT, Material.COPPER_ORE, Material.CRACKED_DEEPSLATE_BRICKS, Material.CRACKED_DEEPSLATE_TILES, Material.CUT_COPPER, Material.CUT_COPPER_SLAB, Material.CUT_COPPER_STAIRS, Material.CYAN_CANDLE, + Material.CYAN_CANDLE_CAKE, Material.DEEPSLATE, Material.DEEPSLATE_BRICKS, Material.DEEPSLATE_BRICK_SLAB, Material.DEEPSLATE_BRICK_STAIRS, Material.DEEPSLATE_BRICK_WALL, Material.DEEPSLATE_COAL_ORE, Material.DEEPSLATE_COPPER_ORE, + Material.DEEPSLATE_DIAMOND_ORE, Material.DEEPSLATE_EMERALD_ORE, Material.DEEPSLATE_GOLD_ORE, Material.DEEPSLATE_IRON_ORE, Material.DEEPSLATE_LAPIS_ORE, Material.DEEPSLATE_REDSTONE_ORE, Material.DEEPSLATE_TILES, Material.DEEPSLATE_TILE_SLAB, + Material.DEEPSLATE_TILE_STAIRS, Material.DEEPSLATE_TILE_WALL, Material.DRIPSTONE_BLOCK, Material.EXPOSED_COPPER, Material.EXPOSED_CUT_COPPER, Material.EXPOSED_CUT_COPPER_SLAB, Material.EXPOSED_CUT_COPPER_STAIRS, Material.FLOWERING_AZALEA, + Material.GLOW_BERRIES, Material.GLOW_INK_SAC, Material.GLOW_ITEM_FRAME, Material.GLOW_LICHEN, Material.GLOW_SQUID_SPAWN_EGG, Material.GOAT_SPAWN_EGG, Material.GRAY_CANDLE, Material.GRAY_CANDLE_CAKE, Material.GREEN_CANDLE, + Material.GREEN_CANDLE_CAKE, Material.HANGING_ROOTS, Material.INFESTED_DEEPSLATE, Material.LARGE_AMETHYST_BUD, Material.LAVA_CAULDRON, Material.LIGHT, Material.LIGHTNING_ROD, Material.LIGHT_BLUE_CANDLE, Material.LIGHT_BLUE_CANDLE_CAKE, + Material.LIGHT_GRAY_CANDLE, Material.LIGHT_GRAY_CANDLE_CAKE, Material.LIME_CANDLE, Material.LIME_CANDLE_CAKE, Material.MAGENTA_CANDLE, Material.MAGENTA_CANDLE_CAKE, Material.MEDIUM_AMETHYST_BUD, Material.MOSS_BLOCK, Material.MOSS_CARPET, + Material.ORANGE_CANDLE, Material.ORANGE_CANDLE_CAKE, Material.OXIDIZED_COPPER, Material.OXIDIZED_CUT_COPPER, Material.OXIDIZED_CUT_COPPER_SLAB, Material.OXIDIZED_CUT_COPPER_STAIRS, Material.PINK_CANDLE, Material.PINK_CANDLE_CAKE, + Material.POINTED_DRIPSTONE, Material.POLISHED_DEEPSLATE, Material.POLISHED_DEEPSLATE_SLAB, Material.POLISHED_DEEPSLATE_STAIRS, Material.POLISHED_DEEPSLATE_WALL, Material.POWDER_SNOW, Material.POWDER_SNOW_BUCKET, Material.POWDER_SNOW_CAULDRON, + Material.PURPLE_CANDLE, Material.PURPLE_CANDLE_CAKE, Material.RAW_COPPER, Material.RAW_COPPER_BLOCK, Material.RAW_GOLD, Material.RAW_GOLD_BLOCK, Material.RAW_IRON, Material.RAW_IRON_BLOCK, Material.RED_CANDLE, Material.RED_CANDLE_CAKE, + Material.ROOTED_DIRT, Material.SCULK_SENSOR, Material.SMALL_AMETHYST_BUD, Material.SMALL_DRIPLEAF, Material.SMOOTH_BASALT, Material.SPORE_BLOSSOM, Material.SPYGLASS, Material.TINTED_GLASS, Material.TUFF, Material.WATER_CAULDRON, + Material.WAXED_COPPER_BLOCK, Material.WAXED_CUT_COPPER, Material.WAXED_CUT_COPPER_SLAB, Material.WAXED_CUT_COPPER_STAIRS, Material.WAXED_EXPOSED_COPPER, Material.WAXED_EXPOSED_CUT_COPPER, Material.WAXED_EXPOSED_CUT_COPPER_SLAB, + 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, // Material.LEGACY_AIR, Material.LEGACY_DEAD_BUSH, Material.LEGACY_BURNING_FURNACE, Material.LEGACY_WALL_SIGN, Material.LEGACY_REDSTONE_TORCH_OFF, Material.LEGACY_SKULL, Material.LEGACY_REDSTONE_COMPARATOR_ON, Material.LEGACY_WALL_BANNER, Material.LEGACY_MONSTER_EGG)); diff --git a/src/test/java/org/bukkit/entity/EnderDragonPhaseTest.java b/src/test/java/org/bukkit/entity/EnderDragonPhaseTest.java index d51a0c15b..200f96a33 100644 --- a/src/test/java/org/bukkit/entity/EnderDragonPhaseTest.java +++ b/src/test/java/org/bukkit/entity/EnderDragonPhaseTest.java @@ -28,7 +28,7 @@ public class EnderDragonPhaseTest { Assert.assertEquals("ROAR_BEFORE_ATTACK", CraftEnderDragon.getMinecraftPhase(EnderDragon.Phase.ROAR_BEFORE_ATTACK), DragonControllerPhase.SITTING_ATTACKING); Assert.assertEquals("CHARGE_PLAYER", CraftEnderDragon.getMinecraftPhase(EnderDragon.Phase.CHARGE_PLAYER), DragonControllerPhase.CHARGING_PLAYER); Assert.assertEquals("DYING", CraftEnderDragon.getMinecraftPhase(EnderDragon.Phase.DYING), DragonControllerPhase.DYING); - Assert.assertEquals("HOVER", CraftEnderDragon.getMinecraftPhase(EnderDragon.Phase.HOVER), DragonControllerPhase.HOVER); + Assert.assertEquals("HOVER", CraftEnderDragon.getMinecraftPhase(EnderDragon.Phase.HOVER), DragonControllerPhase.HOVERING); } @Test @@ -43,6 +43,6 @@ public class EnderDragonPhaseTest { Assert.assertEquals("ROAR_BEFORE_ATTACK", CraftEnderDragon.getBukkitPhase(DragonControllerPhase.SITTING_ATTACKING), EnderDragon.Phase.ROAR_BEFORE_ATTACK); Assert.assertEquals("CHARGE_PLAYER", CraftEnderDragon.getBukkitPhase(DragonControllerPhase.CHARGING_PLAYER), EnderDragon.Phase.CHARGE_PLAYER); Assert.assertEquals("DYING", CraftEnderDragon.getBukkitPhase(DragonControllerPhase.DYING), EnderDragon.Phase.DYING); - Assert.assertEquals("HOVER", CraftEnderDragon.getBukkitPhase(DragonControllerPhase.HOVER), EnderDragon.Phase.HOVER); + Assert.assertEquals("HOVER", CraftEnderDragon.getBukkitPhase(DragonControllerPhase.HOVERING), EnderDragon.Phase.HOVER); } } diff --git a/src/test/java/org/bukkit/entity/memory/CraftMemoryKeyTest.java b/src/test/java/org/bukkit/entity/memory/CraftMemoryKeyTest.java index afbbaa60d..7de087a8f 100644 --- a/src/test/java/org/bukkit/entity/memory/CraftMemoryKeyTest.java +++ b/src/test/java/org/bukkit/entity/memory/CraftMemoryKeyTest.java @@ -49,7 +49,7 @@ public class CraftMemoryKeyTest extends AbstractTestingBase { @Test public void shouldReturnNullWhenBukkitRepresentationOfKeyisNotAvailable() { - MemoryKey bukkitNoKey = CraftMemoryKey.toMemoryKey(MemoryModuleType.MOBS); + MemoryKey bukkitNoKey = CraftMemoryKey.toMemoryKey(MemoryModuleType.NEAREST_LIVING_ENTITIES); Assert.assertNull("MemoryModuleType should be null", bukkitNoKey); } diff --git a/src/test/java/org/bukkit/map/MapTest.java b/src/test/java/org/bukkit/map/MapTest.java index 37cae0859..5a8e3ebfb 100644 --- a/src/test/java/org/bukkit/map/MapTest.java +++ b/src/test/java/org/bukkit/map/MapTest.java @@ -15,7 +15,7 @@ public class MapTest { @Test public void testColors() { - MaterialMapColor[] nmsColors = MaterialMapColor.a; + MaterialMapColor[] nmsColors = MaterialMapColor.MATERIAL_COLORS; Color[] bukkitColors = MapPalette.colors; boolean fail = false; @@ -23,7 +23,7 @@ public class MapTest { if (nmsColors[i] == null) { break; } - int rgb = nmsColors[i].rgb; + int rgb = nmsColors[i].col; int r = (rgb >> 16) & 0xFF; int g = (rgb >> 8) & 0xFF; diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java index 5831d6d38..ebf0ed156 100644 --- a/src/test/java/org/bukkit/support/AbstractTestingBase.java +++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java @@ -5,9 +5,12 @@ import com.google.common.util.concurrent.MoreExecutors; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; +import net.minecraft.SharedConstants; +import net.minecraft.core.IRegistryCustom; import net.minecraft.server.DispenserRegistry; import net.minecraft.server.packs.EnumResourcePackType; import net.minecraft.server.packs.ResourcePackVanilla; +import net.minecraft.server.packs.repository.ResourcePackSourceVanilla; import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.tags.TagRegistry; import net.minecraft.util.Unit; @@ -33,14 +36,15 @@ public abstract class AbstractTestingBase { public static final TagRegistry TAG_REGISTRY; static { + SharedConstants.a(); DispenserRegistry.init(); // 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()); + resourceManager.a(TAG_REGISTRY = new TagRegistry(IRegistryCustom.a())); resourceManager.a(LOOT_TABLE_REGISTRY = new LootTableRegistry(new LootPredicateManager())); // Register vanilla pack - resourceManager.a(MoreExecutors.directExecutor(), MoreExecutors.directExecutor(), Collections.singletonList(new ResourcePackVanilla("minecraft")), CompletableFuture.completedFuture(Unit.INSTANCE)).join(); + resourceManager.a(MoreExecutors.directExecutor(), MoreExecutors.directExecutor(), Collections.singletonList(new ResourcePackVanilla(ResourcePackSourceVanilla.BUILT_IN_METADATA, "minecraft")), CompletableFuture.completedFuture(Unit.INSTANCE)).join(); // Bind tags TAG_REGISTRY.a().bind(); @@ -54,6 +58,6 @@ public abstract class AbstractTestingBase { } } INVALIDATED_MATERIALS = builder.build(); - Assert.assertEquals("Expected 564 invalidated materials (got " + INVALIDATED_MATERIALS.size() + ")", 564, INVALIDATED_MATERIALS.size()); + Assert.assertEquals("Expected 590 invalidated materials (got " + INVALIDATED_MATERIALS.size() + ")", 590, INVALIDATED_MATERIALS.size()); } } diff --git a/src/test/java/org/bukkit/support/DummyEnchantments.java b/src/test/java/org/bukkit/support/DummyEnchantments.java index 7a6b74e19..d0027f476 100644 --- a/src/test/java/org/bukkit/support/DummyEnchantments.java +++ b/src/test/java/org/bukkit/support/DummyEnchantments.java @@ -4,7 +4,7 @@ import net.minecraft.world.item.enchantment.Enchantments; public class DummyEnchantments { static { - Enchantments.DAMAGE_ALL.getClass(); + Enchantments.SHARPNESS.getClass(); org.bukkit.enchantments.Enchantment.stopAcceptingRegistrations(); } diff --git a/src/test/java/org/bukkit/support/Util.java b/src/test/java/org/bukkit/support/Util.java deleted file mode 100644 index 2f24d9a40..000000000 --- a/src/test/java/org/bukkit/support/Util.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.bukkit.support; - -import java.lang.reflect.Field; - -public class Util { - /* - public static T getInternalState(Object object, String fieldName) { - return getInternalState(object.getClass(), object, fieldName); - } - */ - - @SuppressWarnings("unchecked") - public static T getInternalState(Class clazz, Object object, String fieldName) { - Field field; - try { - field = clazz.getDeclaredField(fieldName); - } catch (SecurityException e) { - throw new RuntimeException("Not allowed to access " + clazz, e); - } catch (NoSuchFieldException e) { - throw new RuntimeException("Unable to find field " + fieldName, e); - } - - field.setAccessible(true); - try { - return (T) field.get(object); - } catch (IllegalArgumentException e) { - } catch (IllegalAccessException e) { - } - throw new RuntimeException("Unable to get internal value"); - } -}