From 40076782ed710d3606ec8f9704f3b7d172a8cfd3 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Wed, 15 Mar 2023 03:30:00 +1100 Subject: [PATCH] Update to Minecraft 1.19.4 By: md_5 --- .../commands/CommandDispatcher.patch | 16 +- .../core/dispenser/IDispenseBehavior.patch | 51 ++--- .../minecraft/network/NetworkManager.patch | 6 +- .../network/PacketDataSerializer.patch | 24 +-- .../minecraft/network/chat/ChatHexColor.patch | 6 +- .../protocol/PlayerConnectionUtils.patch | 2 +- .../network/syncher/DataWatcher.patch | 8 +- .../server/AdvancementDataPlayer.patch | 10 +- .../net/minecraft/server/Main.patch | 47 +++-- .../minecraft/server/MinecraftServer.patch | 79 ++++---- .../server/commands/CommandEffect.patch | 6 +- .../server/commands/CommandLoot.patch | 4 +- .../commands/CommandSpreadPlayers.patch | 2 +- .../server/commands/CommandSummon.patch | 2 +- .../server/commands/CommandTeleport.patch | 41 ++-- .../minecraft/server/level/EntityPlayer.patch | 135 +++++++------ .../server/level/EntityTrackerEntry.patch | 39 ++-- .../server/level/PlayerChunkMap.patch | 26 +-- .../minecraft/server/level/WorldServer.patch | 77 ++++---- .../server/network/HandshakeListener.patch | 6 +- .../server/network/LoginListener.patch | 4 +- .../server/network/PacketStatusListener.patch | 34 ++-- .../server/network/PlayerConnection.patch | 177 ++++++++---------- .../server/network/ServerConnection.patch | 14 +- .../minecraft/server/players/PlayerList.patch | 87 ++++----- .../stats/ServerStatisticManager.patch | 2 +- .../util/datafix/DataConverterRegistry.patch | 60 +++--- .../net/minecraft/world/IInventory.patch | 12 +- .../world/damagesource/DamageSource.patch | 32 +++- .../world/damagesource/DamageSources.patch | 18 ++ .../EntityDamageSourceIndirect.patch | 13 -- .../world/effect/MobEffectList.patch | 14 +- .../world/effect/MobEffectUtil.patch | 4 +- .../net/minecraft/world/entity/Entity.patch | 94 +++++----- .../world/entity/EntityAgeable.patch | 8 +- .../world/entity/EntityAreaEffectCloud.patch | 8 +- .../world/entity/EntityInsentient.patch | 47 ++--- .../minecraft/world/entity/EntityLiving.patch | 132 ++++++------- .../minecraft/world/entity/EntityTypes.patch | 20 +- .../world/entity/SaddleStorage.patch | 7 +- .../ai/behavior/BehaviorWorkComposter.patch | 20 -- .../ai/goal/PathfinderGoalFollowOwner.patch | 2 +- .../ai/goal/PathfinderGoalRemoveBlock.patch | 2 +- .../world/entity/ambient/EntityBat.patch | 2 +- .../world/entity/animal/EntityBee.patch | 8 +- .../world/entity/animal/EntityCat.patch | 8 +- .../world/entity/animal/EntityFox.patch | 18 +- .../world/entity/animal/EntityOcelot.patch | 4 +- .../world/entity/animal/EntityParrot.patch | 6 +- .../entity/animal/EntityPufferFish.patch | 2 +- .../world/entity/animal/EntitySheep.patch | 2 +- .../world/entity/animal/EntitySnowman.patch | 28 +-- .../world/entity/animal/EntityTurtle.patch | 14 +- .../world/entity/animal/allay/Allay.patch | 16 +- .../world/entity/animal/axolotl/Axolotl.patch | 12 +- .../animal/horse/EntityHorseAbstract.patch | 26 +-- .../boss/enderdragon/EntityEnderCrystal.patch | 10 +- .../boss/enderdragon/EntityEnderDragon.patch | 38 ++-- .../entity/boss/wither/EntityWither.patch | 10 +- .../entity/decoration/EntityArmorStand.patch | 46 ++--- .../entity/decoration/EntityHanging.patch | 8 +- .../entity/decoration/EntityItemFrame.patch | 14 +- .../world/entity/decoration/EntityLeash.patch | 27 +-- .../entity/item/EntityFallingBlock.patch | 10 +- .../world/entity/item/EntityItem.patch | 24 +-- .../world/entity/item/EntityTNTPrimed.patch | 10 +- .../world/entity/monster/EntityCreeper.patch | 6 +- .../world/entity/monster/EntityDrowned.patch | 2 +- .../world/entity/monster/EntityEnderman.patch | 4 +- .../world/entity/monster/EntityPhantom.patch | 2 +- .../world/entity/monster/EntityRavager.patch | 2 +- .../world/entity/monster/EntityShulker.patch | 8 +- .../monster/EntitySkeletonAbstract.patch | 2 +- .../world/entity/monster/EntitySpider.patch | 8 +- .../world/entity/monster/EntityStrider.patch | 15 +- .../world/entity/monster/EntityVex.patch | 2 +- .../world/entity/monster/EntityWitch.patch | 2 +- .../world/entity/npc/EntityVillager.patch | 14 +- .../entity/npc/EntityVillagerTrader.patch | 8 +- .../world/entity/player/EntityHuman.patch | 81 ++++---- .../world/entity/player/PlayerInventory.patch | 6 +- .../world/entity/projectile/EntityEgg.patch | 4 +- .../entity/projectile/EntityEnderPearl.patch | 14 +- .../entity/projectile/EntityEvokerFangs.patch | 4 +- .../entity/projectile/EntityFireworks.patch | 18 +- .../projectile/EntityLargeFireball.patch | 6 +- .../entity/projectile/EntityLlamaSpit.patch | 2 +- .../entity/projectile/EntityPotion.patch | 32 ++-- .../projectile/EntityShulkerBullet.patch | 16 +- .../projectile/EntitySmallFireball.patch | 2 +- .../entity/projectile/EntityTippedArrow.patch | 12 +- .../entity/projectile/EntityWitherSkull.patch | 8 +- .../world/entity/projectile/IProjectile.patch | 12 +- .../world/entity/vehicle/ChestBoat.patch | 6 +- .../world/entity/vehicle/EntityBoat.patch | 10 +- .../entity/vehicle/EntityMinecartTNT.patch | 4 +- .../minecraft/world/food/FoodMetaData.patch | 10 +- .../minecraft/world/inventory/Container.patch | 4 +- .../world/inventory/ContainerAnvil.patch | 28 +-- .../inventory/ContainerAnvilAbstract.patch | 2 +- .../world/inventory/ContainerPlayer.patch | 6 +- .../world/inventory/ContainerSmithing.patch | 31 +-- .../world/inventory/Containers.patch | 10 +- .../world/inventory/LegacySmithingMenu.patch | 60 ++++++ .../net/minecraft/world/item/ItemArmor.patch | 6 +- .../minecraft/world/item/ItemArmorStand.patch | 4 +- .../minecraft/world/item/ItemCrossbow.patch | 4 +- .../minecraft/world/item/ItemHanging.patch | 6 +- .../net/minecraft/world/item/ItemLeash.patch | 8 +- .../net/minecraft/world/item/ItemRecord.patch | 8 +- .../net/minecraft/world/item/ItemStack.patch | 41 ++-- .../world/item/crafting/IRecipe.patch | 2 +- .../world/item/crafting/IRecipeComplex.patch | 2 +- ...ithing.patch => LegacyUpgradeRecipe.patch} | 16 +- .../world/item/crafting/ShapedRecipes.patch | 6 +- .../item/crafting/ShapelessRecipes.patch | 4 +- .../crafting/SmithingTransformRecipe.patch | 35 ++++ .../item/crafting/SmithingTrimRecipe.patch | 30 +++ .../net/minecraft/world/level/Explosion.patch | 10 +- .../net/minecraft/world/level/GameRules.patch | 14 +- .../world/level/StructureManager.patch | 11 -- .../net/minecraft/world/level/World.patch | 34 ++-- .../world/level/block/BlockBed.patch | 8 +- .../level/block/BlockButtonAbstract.patch | 6 +- .../world/level/block/BlockCactus.patch | 8 +- .../world/level/block/BlockCampfire.patch | 8 +- .../world/level/block/BlockComposter.patch | 61 +++--- .../level/block/BlockDaylightDetector.patch | 2 +- .../world/level/block/BlockDoor.patch | 2 +- .../world/level/block/BlockEnderPortal.patch | 2 +- .../world/level/block/BlockFenceGate.patch | 2 +- .../world/level/block/BlockFire.patch | 18 +- .../world/level/block/BlockFireAbstract.patch | 6 +- .../world/level/block/BlockGrassPath.patch | 4 +- .../world/level/block/BlockJukeBox.patch | 17 -- .../world/level/block/BlockLeaves.patch | 4 +- .../world/level/block/BlockLectern.patch | 2 +- .../world/level/block/BlockMagma.patch | 4 +- .../world/level/block/BlockNote.patch | 4 +- .../world/level/block/BlockPortal.patch | 2 +- .../block/BlockPressurePlateAbstract.patch | 4 +- .../block/BlockPressurePlateBinary.patch | 9 +- .../block/BlockPressurePlateWeighted.patch | 11 +- .../level/block/BlockPumpkinCarved.patch | 6 +- .../world/level/block/BlockSoil.patch | 14 +- .../level/block/BlockSweetBerryBush.patch | 10 +- .../world/level/block/BlockTrapdoor.patch | 2 +- .../world/level/block/BlockVine.patch | 80 ++++---- .../world/level/block/BlockWitherRose.patch | 4 +- .../world/level/block/CaveVines.patch | 9 +- .../world/level/block/CaveVinesBlock.patch | 11 -- .../level/block/CaveVinesPlantBlock.patch | 11 -- .../level/block/PointedDripstoneBlock.patch | 2 +- .../block/entity/TileEntityBrewingStand.patch | 12 +- .../block/entity/TileEntityConduit.patch | 10 +- .../block/entity/TileEntityFurnace.patch | 38 ++-- .../level/block/entity/TileEntityHopper.patch | 12 +- .../block/entity/TileEntityLectern.patch | 14 +- .../level/block/entity/TileEntitySkull.patch | 26 --- .../block/grower/WorldGenTreeProvider.patch | 4 +- .../minecraft/world/level/chunk/Chunk.patch | 4 +- .../world/level/chunk/ChunkSection.patch | 2 +- .../chunk/storage/ChunkRegionLoader.patch | 8 +- .../level/chunk/storage/IChunkLoader.patch | 2 +- .../level/gameevent/GameEventDispatcher.patch | 2 +- .../vibrations/VibrationListener.patch | 17 +- .../templatesystem/DefinedStructure.patch | 22 +-- .../world/level/storage/Convertable.patch | 14 +- .../world/level/storage/WorldDataServer.patch | 6 +- .../world/level/storage/WorldNBTStorage.patch | 4 +- paper-server/pom.xml | 48 +---- .../bukkit/craftbukkit/CraftLootTable.java | 4 +- .../org/bukkit/craftbukkit/CraftParticle.java | 3 + .../craftbukkit/CraftRegionAccessor.java | 38 +++- .../org/bukkit/craftbukkit/CraftServer.java | 31 ++- .../org/bukkit/craftbukkit/CraftWorld.java | 8 +- .../bukkit/craftbukkit/CraftWorldBorder.java | 2 +- .../java/org/bukkit/craftbukkit/Main.java | 14 +- .../craftbukkit/block/CraftBlockStates.java | 8 + .../craftbukkit/block/CraftDecoratedPot.java | 38 ++++ .../craftbukkit/block/CraftJukebox.java | 9 +- .../block/CraftSuspiciousSand.java | 67 +++++++ .../block/data/CraftBlockData.java | 5 + .../block/data/type/CraftPinkPetals.java | 24 +++ .../block/data/type/CraftSuspiciousSand.java | 24 +++ .../block/impl/CraftCherryLeaves.java | 54 ++++++ .../block/impl/CraftDecoratedPot.java | 48 +++++ .../block/impl/CraftPinkPetals.java | 53 ++++++ .../block/impl/CraftSuspiciousSand.java | 34 ++++ .../block/impl/CraftTorchflowerCrop.java | 34 ++++ .../bukkit/craftbukkit/entity/CraftAllay.java | 2 +- .../craftbukkit/entity/CraftBlockDisplay.java | 42 +++++ .../bukkit/craftbukkit/entity/CraftBoat.java | 2 + .../bukkit/craftbukkit/entity/CraftCamel.java | 3 +- .../craftbukkit/entity/CraftDisplay.java | 158 ++++++++++++++++ .../craftbukkit/entity/CraftEnderSignal.java | 2 +- .../craftbukkit/entity/CraftEntity.java | 16 +- .../craftbukkit/entity/CraftInteraction.java | 95 ++++++++++ .../bukkit/craftbukkit/entity/CraftItem.java | 6 +- .../craftbukkit/entity/CraftItemDisplay.java | 53 ++++++ .../craftbukkit/entity/CraftLivingEntity.java | 10 +- .../bukkit/craftbukkit/entity/CraftPig.java | 4 +- .../craftbukkit/entity/CraftPlayer.java | 10 +- .../craftbukkit/entity/CraftSniffer.java | 27 +++ .../craftbukkit/entity/CraftStrider.java | 4 +- .../craftbukkit/entity/CraftTextDisplay.java | 151 +++++++++++++++ .../craftbukkit/entity/CraftWarden.java | 2 +- .../entity/memory/CraftMemoryMapper.java | 2 +- .../craftbukkit/event/CraftEventFactory.java | 82 ++++---- .../generator/CustomWorldChunkManager.java | 8 +- .../inventory/CraftComplexRecipe.java | 3 +- .../craftbukkit/inventory/CraftContainer.java | 29 ++- .../craftbukkit/inventory/CraftInventory.java | 2 + .../inventory/CraftInventorySmithingNew.java | 45 +++++ .../inventory/CraftItemFactory.java | 7 + .../craftbukkit/inventory/CraftItemStack.java | 7 + .../inventory/CraftMetaBlockState.java | 8 +- .../inventory/CraftMetaSpawnEgg.java | 1 + .../inventory/CraftSmithingRecipe.java | 2 +- .../CraftSmithingTransformRecipe.java | 29 +++ .../inventory/CraftSmithingTrimRecipe.java | 27 +++ .../inventory/util/CraftInventoryCreator.java | 1 + .../craftbukkit/util/CraftDamageSource.java | 31 --- .../craftbukkit/util/CraftIconCache.java | 4 +- .../craftbukkit/util/CraftMagicNumbers.java | 4 +- .../bukkit/craftbukkit/legacy/LegacyTest.java | 7 + .../bukkit/support/AbstractTestingBase.java | 2 +- 227 files changed, 2788 insertions(+), 1621 deletions(-) create mode 100644 paper-server/nms-patches/net/minecraft/world/damagesource/DamageSources.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/damagesource/EntityDamageSourceIndirect.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/inventory/LegacySmithingMenu.patch rename paper-server/nms-patches/net/minecraft/world/item/crafting/{RecipeSmithing.patch => LegacyUpgradeRecipe.patch} (68%) create mode 100644 paper-server/nms-patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/level/StructureManager.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/level/block/BlockJukeBox.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/level/block/CaveVinesBlock.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/level/block/CaveVinesPlantBlock.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntitySkull.patch create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDecoratedPot.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSuspiciousSand.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPinkPetals.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSuspiciousSand.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCherryLeaves.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDecoratedPot.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPinkPetals.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSuspiciousSand.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTorchflowerCrop.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftInteraction.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemDisplay.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTextDisplay.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySmithingNew.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftDamageSource.java diff --git a/paper-server/nms-patches/net/minecraft/commands/CommandDispatcher.patch b/paper-server/nms-patches/net/minecraft/commands/CommandDispatcher.patch index a68679da9c..8085fe8a75 100644 --- a/paper-server/nms-patches/net/minecraft/commands/CommandDispatcher.patch +++ b/paper-server/nms-patches/net/minecraft/commands/CommandDispatcher.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/CommandDispatcher.java +++ b/net/minecraft/commands/CommandDispatcher.java -@@ -116,6 +116,14 @@ +@@ -119,6 +119,14 @@ import net.minecraft.util.profiling.jfr.JvmProfiler; import org.slf4j.Logger; @@ -15,7 +15,7 @@ public class CommandDispatcher { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -127,6 +135,7 @@ +@@ -130,6 +138,7 @@ private final com.mojang.brigadier.CommandDispatcher dispatcher = new com.mojang.brigadier.CommandDispatcher(); public CommandDispatcher(CommandDispatcher.ServerType commanddispatcher_servertype, CommandBuildContext commandbuildcontext) { @@ -23,7 +23,7 @@ CommandAdvancement.register(this.dispatcher); CommandAttribute.register(this.dispatcher, commandbuildcontext); CommandExecute.register(this.dispatcher, commandbuildcontext); -@@ -212,6 +221,11 @@ +@@ -218,6 +227,11 @@ CommandPublish.register(this.dispatcher); } @@ -35,7 +35,7 @@ this.dispatcher.setConsumer((commandcontext, flag, i) -> { ((CommandListenerWrapper) commandcontext.getSource()).onCommandComplete(commandcontext, flag, i); }); -@@ -224,12 +238,59 @@ +@@ -230,12 +244,59 @@ return new ParseResults(commandcontextbuilder1, parseresults.getReader(), parseresults.getExceptions()); } @@ -96,7 +96,7 @@ CommandListenerWrapper commandlistenerwrapper = (CommandListenerWrapper) parseresults.getContext().getSource(); commandlistenerwrapper.getServer().getProfiler().push(() -> { -@@ -254,7 +315,7 @@ +@@ -260,7 +321,7 @@ if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) { int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor()); IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.empty().withStyle(EnumChatFormat.GRAY).withStyle((chatmodifier) -> { @@ -105,7 +105,7 @@ }); if (j > 10) { -@@ -304,11 +365,36 @@ +@@ -310,11 +371,36 @@ } public void sendCommands(EntityPlayer entityplayer) { @@ -143,7 +143,7 @@ entityplayer.connection.send(new PacketPlayOutCommands(rootcommandnode)); } -@@ -319,7 +405,7 @@ +@@ -325,7 +411,7 @@ CommandNode commandnode2 = (CommandNode) iterator.next(); if (commandnode2.canUse(commandlistenerwrapper)) { @@ -152,7 +152,7 @@ argumentbuilder.requires((icompletionprovider) -> { return true; -@@ -342,7 +428,7 @@ +@@ -348,7 +434,7 @@ argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect())); } diff --git a/paper-server/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch b/paper-server/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch index 9b34ddac01..6d2c3def84 100644 --- a/paper-server/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch +++ b/paper-server/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/IDispenseBehavior.java +++ b/net/minecraft/core/dispenser/IDispenseBehavior.java -@@ -77,6 +77,21 @@ +@@ -78,6 +78,21 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import org.slf4j.Logger; @@ -22,7 +22,7 @@ public interface IDispenseBehavior { Logger LOGGER = LogUtils.getLogger(); -@@ -201,14 +216,42 @@ +@@ -202,14 +217,42 @@ EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING); EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(itemstack.getTag()); @@ -67,7 +67,7 @@ isourceblock.getLevel().gameEvent((Entity) null, GameEvent.ENTITY_PLACE, isourceblock.getPos()); return itemstack; } -@@ -227,12 +270,40 @@ +@@ -228,13 +271,41 @@ EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING); BlockPosition blockposition = isourceblock.getPos().relative(enumdirection); WorldServer worldserver = isourceblock.getLevel(); @@ -99,17 +99,18 @@ + } + // CraftBukkit end + - EntityArmorStand entityarmorstand = new EntityArmorStand(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D); + Consumer consumer = EntityTypes.appendDefaultStackConfig((entityarmorstand) -> { + entityarmorstand.setYRot(enumdirection.toYRot()); + }, worldserver, itemstack, (EntityHuman) null); + EntityArmorStand entityarmorstand = (EntityArmorStand) EntityTypes.ARMOR_STAND.spawn(worldserver, itemstack.getTag(), consumer, blockposition, EnumMobSpawn.DISPENSER, false, false); + + if (entityarmorstand != null) { +- itemstack.shrink(1); ++ // itemstack.shrink(1); // CraftBukkit - Handled during event processing + } - EntityTypes.updateCustomEntityTag(worldserver, (EntityHuman) null, entityarmorstand, itemstack.getTag()); - entityarmorstand.setYRot(enumdirection.toYRot()); - worldserver.addFreshEntity(entityarmorstand); -- itemstack.shrink(1); -+ // itemstack.shrink(1); // CraftBukkit - Handled during event processing return itemstack; - } - }); -@@ -251,8 +322,35 @@ +@@ -255,8 +326,35 @@ }); if (!list.isEmpty()) { @@ -146,7 +147,7 @@ this.setSuccess(true); return itemstack; } else { -@@ -279,7 +377,35 @@ +@@ -283,7 +381,35 @@ entityhorseabstract = (EntityHorseAbstract) iterator1.next(); } while (!entityhorseabstract.isArmor(itemstack) || entityhorseabstract.isWearingArmor() || !entityhorseabstract.isTamed()); @@ -183,7 +184,7 @@ this.setSuccess(true); return itemstack; } -@@ -322,9 +448,35 @@ +@@ -326,9 +452,35 @@ } entityhorsechestedabstract = (EntityHorseChestedAbstract) iterator1.next(); @@ -221,7 +222,7 @@ this.setSuccess(true); return itemstack; } -@@ -333,12 +485,41 @@ +@@ -337,12 +489,41 @@ @Override public ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) { EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING); @@ -264,7 +265,7 @@ return itemstack; } -@@ -360,12 +541,40 @@ +@@ -364,12 +545,40 @@ double d3 = randomsource.triangle((double) enumdirection.getStepX(), 0.11485000000000001D); double d4 = randomsource.triangle((double) enumdirection.getStepY(), 0.11485000000000001D); double d5 = randomsource.triangle((double) enumdirection.getStepZ(), 0.11485000000000001D); @@ -310,7 +311,7 @@ return itemstack; } -@@ -399,9 +608,52 @@ +@@ -405,9 +614,52 @@ BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING)); WorldServer worldserver = isourceblock.getLevel(); @@ -364,7 +365,7 @@ } else { return this.defaultDispenseItemBehavior.dispense(isourceblock, itemstack); } -@@ -428,7 +680,7 @@ +@@ -434,7 +686,7 @@ Block block = iblockdata.getBlock(); if (block instanceof IFluidSource) { @@ -373,7 +374,7 @@ if (itemstack1.isEmpty()) { return super.execute(isourceblock, itemstack); -@@ -436,6 +688,32 @@ +@@ -442,6 +694,32 @@ worldserver.gameEvent((Entity) null, GameEvent.FLUID_PICKUP, blockposition); Item item = itemstack1.getItem(); @@ -406,7 +407,7 @@ itemstack.shrink(1); if (itemstack.isEmpty()) { return new ItemStack(item); -@@ -457,14 +735,42 @@ +@@ -463,14 +741,42 @@ protected ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) { WorldServer worldserver = isourceblock.getLevel(); @@ -451,7 +452,7 @@ } else if (!BlockCampfire.canLight(iblockdata) && !CandleBlock.canLight(iblockdata) && !CandleCakeBlock.canLight(iblockdata)) { if (iblockdata.getBlock() instanceof BlockTNT) { BlockTNT.explode(worldserver, blockposition); -@@ -490,12 +796,62 @@ +@@ -496,12 +802,62 @@ this.setSuccess(true); WorldServer worldserver = isourceblock.getLevel(); BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING)); @@ -514,7 +515,7 @@ return itemstack; } -@@ -505,12 +861,41 @@ +@@ -511,12 +867,41 @@ protected ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) { WorldServer worldserver = isourceblock.getLevel(); BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING)); @@ -558,7 +559,7 @@ return itemstack; } }); -@@ -535,6 +920,30 @@ +@@ -541,6 +926,30 @@ EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING); BlockPosition blockposition = isourceblock.getPos().relative(enumdirection); @@ -589,7 +590,7 @@ if (worldserver.isEmptyBlock(blockposition) && BlockWitherSkull.canSpawnMob(worldserver, blockposition, itemstack)) { worldserver.setBlock(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.defaultBlockState().setValue(BlockSkull.ROTATION, RotationSegment.convertToSegment(enumdirection)), 3); worldserver.gameEvent((Entity) null, GameEvent.BLOCK_PLACE, blockposition); -@@ -560,6 +969,30 @@ +@@ -566,6 +975,30 @@ BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING)); BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN; @@ -620,7 +621,7 @@ if (worldserver.isEmptyBlock(blockposition) && blockpumpkincarved.canSpawnGolem(worldserver, blockposition)) { if (!worldserver.isClientSide) { worldserver.setBlock(blockposition, blockpumpkincarved.defaultBlockState(), 3); -@@ -609,6 +1042,30 @@ +@@ -615,6 +1048,30 @@ BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING)); IBlockData iblockdata = worldserver.getBlockState(blockposition); diff --git a/paper-server/nms-patches/net/minecraft/network/NetworkManager.patch b/paper-server/nms-patches/net/minecraft/network/NetworkManager.patch index b017f56bfb..1d77a80627 100644 --- a/paper-server/nms-patches/net/minecraft/network/NetworkManager.patch +++ b/paper-server/nms-patches/net/minecraft/network/NetworkManager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/NetworkManager.java +++ b/net/minecraft/network/NetworkManager.java -@@ -84,6 +84,7 @@ +@@ -86,6 +86,7 @@ private float averageSentPackets; private int tickCount; private boolean handlingFault; @@ -8,7 +8,7 @@ public NetworkManager(EnumProtocolDirection enumprotocoldirection) { this.receiving = enumprotocoldirection; -@@ -164,7 +165,7 @@ +@@ -167,7 +168,7 @@ } private static void genericsFtw(Packet packet, PacketListener packetlistener) { @@ -17,7 +17,7 @@ } public void setListener(PacketListener packetlistener) { -@@ -289,7 +290,7 @@ +@@ -296,7 +297,7 @@ public void disconnect(IChatBaseComponent ichatbasecomponent) { if (this.channel.isOpen()) { diff --git a/paper-server/nms-patches/net/minecraft/network/PacketDataSerializer.patch b/paper-server/nms-patches/net/minecraft/network/PacketDataSerializer.patch index c3ea1e9b32..4e2539ed18 100644 --- a/paper-server/nms-patches/net/minecraft/network/PacketDataSerializer.patch +++ b/paper-server/nms-patches/net/minecraft/network/PacketDataSerializer.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/network/PacketDataSerializer.java +++ b/net/minecraft/network/PacketDataSerializer.java -@@ -74,6 +74,8 @@ - import net.minecraft.world.phys.MovingObjectPositionBlock; - import net.minecraft.world.phys.Vec3D; +@@ -81,6 +81,8 @@ + import org.joml.Quaternionf; + import org.joml.Vector3f; +import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit + public class PacketDataSerializer extends ByteBuf { private static final int MAX_VARINT_SIZE = 5; -@@ -195,7 +197,7 @@ +@@ -220,7 +222,7 @@ public > C readCollection(IntFunction intfunction, PacketDataSerializer.a packetdataserializer_a) { int i = this.readVarInt(); @@ -18,7 +18,7 @@ for (int j = 0; j < i; ++j) { c0.add(packetdataserializer_a.apply(this)); -@@ -206,7 +208,7 @@ +@@ -231,7 +233,7 @@ public void writeCollection(Collection collection, PacketDataSerializer.b packetdataserializer_b) { this.writeVarInt(collection.size()); @@ -27,7 +27,7 @@ while (iterator.hasNext()) { T t0 = iterator.next(); -@@ -233,12 +235,12 @@ +@@ -258,12 +260,12 @@ public void writeIntIdList(IntList intlist) { this.writeVarInt(intlist.size()); @@ -42,7 +42,7 @@ for (int j = 0; j < i; ++j) { K k0 = packetdataserializer_a.apply(this); -@@ -272,7 +274,7 @@ +@@ -297,7 +299,7 @@ } public > void writeEnumSet(EnumSet enumset, Class oclass) { @@ -51,7 +51,7 @@ BitSet bitset = new BitSet(ae.length); for (int i = 0; i < ae.length; ++i) { -@@ -283,7 +285,7 @@ +@@ -308,7 +310,7 @@ } public > EnumSet readEnumSet(Class oclass) { @@ -60,7 +60,7 @@ BitSet bitset = this.readFixedBitSet(ae.length); EnumSet enumset = EnumSet.noneOf(oclass); -@@ -499,7 +501,7 @@ +@@ -545,7 +547,7 @@ } public > T readEnum(Class oclass) { @@ -69,7 +69,7 @@ } public PacketDataSerializer writeEnum(Enum oenum) { -@@ -576,7 +578,7 @@ +@@ -622,7 +624,7 @@ } else { try { NBTCompressedStreamTools.write(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this))); @@ -78,7 +78,7 @@ throw new EncoderException(ioexception); } } -@@ -613,7 +615,7 @@ +@@ -659,7 +661,7 @@ } public PacketDataSerializer writeItem(ItemStack itemstack) { @@ -87,7 +87,7 @@ this.writeBoolean(false); } else { this.writeBoolean(true); -@@ -642,6 +644,11 @@ +@@ -688,6 +690,11 @@ ItemStack itemstack = new ItemStack(item, b0); itemstack.setTag(this.readNbt()); diff --git a/paper-server/nms-patches/net/minecraft/network/chat/ChatHexColor.patch b/paper-server/nms-patches/net/minecraft/network/chat/ChatHexColor.patch index 26fb857152..0cb321cf9b 100644 --- a/paper-server/nms-patches/net/minecraft/network/chat/ChatHexColor.patch +++ b/paper-server/nms-patches/net/minecraft/network/chat/ChatHexColor.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/network/chat/ChatHexColor.java +++ b/net/minecraft/network/chat/ChatHexColor.java -@@ -20,7 +20,7 @@ - return chathexcolor != null ? DataResult.success(chathexcolor) : DataResult.error("String is not a valid color name or hex color code"); +@@ -22,7 +22,7 @@ + }); }, ChatHexColor::serialize); private static final Map LEGACY_FORMAT_TO_COLOR = (Map) Stream.of(EnumChatFormat.values()).filter(EnumChatFormat::isColor).collect(ImmutableMap.toImmutableMap(Function.identity(), (enumchatformat) -> { - return new ChatHexColor(enumchatformat.getColor(), enumchatformat.getName()); @@ -9,7 +9,7 @@ })); private static final Map NAMED_COLORS = (Map) ChatHexColor.LEGACY_FORMAT_TO_COLOR.values().stream().collect(ImmutableMap.toImmutableMap((chathexcolor) -> { return chathexcolor.name; -@@ -28,16 +28,22 @@ +@@ -30,16 +30,22 @@ private final int value; @Nullable public final String name; diff --git a/paper-server/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch b/paper-server/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch index bc591c26f5..57d31871c3 100644 --- a/paper-server/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch +++ b/paper-server/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch @@ -17,7 +17,7 @@ if (!iasynctaskhandler.isSameThread()) { iasynctaskhandler.executeIfPossible(() -> { + if (MinecraftServer.getServer().hasStopped() || (t0 instanceof PlayerConnection && ((PlayerConnection) t0).processedDisconnect)) return; // CraftBukkit, MC-142590 - if (t0.getConnection().isConnected()) { + if (t0.isAcceptingMessages()) { try { packet.handle(t0); @@ -36,6 +42,10 @@ diff --git a/paper-server/nms-patches/net/minecraft/network/syncher/DataWatcher.patch b/paper-server/nms-patches/net/minecraft/network/syncher/DataWatcher.patch index 31b97b17ea..e92b802732 100644 --- a/paper-server/nms-patches/net/minecraft/network/syncher/DataWatcher.patch +++ b/paper-server/nms-patches/net/minecraft/network/syncher/DataWatcher.patch @@ -12,7 +12,7 @@ public class DataWatcher { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -138,6 +143,13 @@ +@@ -142,6 +147,13 @@ } @@ -26,7 +26,7 @@ public boolean isDirty() { return this.isDirty; } -@@ -218,7 +230,7 @@ +@@ -223,7 +235,7 @@ if (!Objects.equals(datawatcher_b.serializer(), datawatcher_item.accessor.getSerializer())) { throw new IllegalStateException(String.format(Locale.ROOT, "Invalid entity data item type for field %d on entity %s: old=%s(%s), new=%s(%s)", datawatcher_item.accessor.getId(), this.entity, datawatcher_item.value, datawatcher_item.value.getClass(), datawatcher_b.value, datawatcher_b.value.getClass())); } else { @@ -35,7 +35,7 @@ } } -@@ -226,6 +238,18 @@ +@@ -231,6 +243,18 @@ return this.itemsById.isEmpty(); } @@ -54,7 +54,7 @@ public static class Item { final DataWatcherObject accessor; -@@ -268,7 +292,7 @@ +@@ -273,7 +297,7 @@ } } diff --git a/paper-server/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch b/paper-server/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch index 7b0f44738b..2c10c4effe 100644 --- a/paper-server/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch +++ b/paper-server/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/server/AdvancementDataPlayer.java +++ b/net/minecraft/server/AdvancementDataPlayer.java -@@ -179,7 +179,11 @@ +@@ -144,7 +144,11 @@ Advancement advancement = advancementdataworld.getAdvancement((MinecraftKey) entry.getKey()); if (advancement == null) { -- AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.file); +- AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.playerSavePath); + // CraftBukkit start + if (entry.getKey().getNamespace().equals("minecraft")) { -+ AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.file); ++ AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.playerSavePath); + } + // CraftBukkit end } else { this.startProgress(advancement, (AdvancementProgress) entry.getValue()); - } -@@ -274,6 +278,7 @@ + this.progressChanged.add(advancement); +@@ -227,6 +231,7 @@ this.progressChanged.add(advancement); flag = true; if (!flag1 && advancementprogress.isDone()) { diff --git a/paper-server/nms-patches/net/minecraft/server/Main.patch b/paper-server/nms-patches/net/minecraft/server/Main.patch index 3494b2d398..b4c2f112a7 100644 --- a/paper-server/nms-patches/net/minecraft/server/Main.patch +++ b/paper-server/nms-patches/net/minecraft/server/Main.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -59,6 +59,16 @@ +@@ -64,6 +64,16 @@ import net.minecraft.world.level.storage.WorldInfo; import org.slf4j.Logger; +// CraftBukkit start +import com.google.common.base.Charsets; -+import com.mojang.bridge.game.PackType; +import java.io.InputStreamReader; +import java.util.concurrent.atomic.AtomicReference; +import net.minecraft.SharedConstants; ++import net.minecraft.server.packs.EnumResourcePackType; +import net.minecraft.world.level.dimension.WorldDimension; +import org.bukkit.configuration.file.YamlConfiguration; +// CraftBukkit end @@ -17,7 +17,7 @@ public class Main { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -66,8 +76,9 @@ +@@ -71,8 +81,9 @@ public Main() {} @DontObfuscate @@ -28,7 +28,7 @@ OptionParser optionparser = new OptionParser(); OptionSpec optionspec = optionparser.accepts("nogui"); OptionSpec optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); -@@ -92,9 +103,12 @@ +@@ -98,15 +109,18 @@ optionparser.printHelpOn(System.err); return; } @@ -36,22 +36,29 @@ + + try { +- Path path = (Path) optionset.valueOf(optionspec14); ++ Path path = (Path) optionset.valueOf("pidFile"); // CraftBukkit + + if (path != null) { + writePidFile(path); + } + CrashReport.preload(); - if (optionset.has(optionspec13)) { + if (optionset.has("jfrProfile")) { // CraftBukkit JvmProfiler.INSTANCE.start(Environment.SERVER); } -@@ -102,13 +116,26 @@ +@@ -114,13 +128,26 @@ DispenserRegistry.validate(); SystemUtils.startTimerHackThread(); - Path path = Paths.get("server.properties"); -- DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(path); + Path path1 = Paths.get("server.properties"); +- DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(path1); + DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(optionset); // CraftBukkit - CLI argument support dedicatedserversettings.forceSave(); - Path path1 = Paths.get("eula.txt"); - EULA eula = new EULA(path1); + Path path2 = Paths.get("eula.txt"); + EULA eula = new EULA(path2); - if (optionset.has(optionspec1)) { + if (optionset.has("initSettings")) { // CraftBukkit @@ -68,10 +75,10 @@ + commandsConfiguration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(Main.class.getClassLoader().getResourceAsStream("configurations/commands.yml"), Charsets.UTF_8))); + commandsConfiguration.save(commandFile); + // CraftBukkit end - Main.LOGGER.info("Initialized '{}' and '{}'", path.toAbsolutePath(), path1.toAbsolutePath()); + Main.LOGGER.info("Initialized '{}' and '{}'", path1.toAbsolutePath(), path2.toAbsolutePath()); return; } -@@ -118,11 +145,12 @@ +@@ -130,11 +157,12 @@ return; } @@ -87,7 +94,7 @@ WorldInfo worldinfo = convertable_conversionsession.getSummary(); if (worldinfo != null) { -@@ -137,13 +165,31 @@ +@@ -149,13 +177,31 @@ } } @@ -109,7 +116,7 @@ + com.google.common.io.Files.write("{\n" + + " \"pack\": {\n" + + " \"description\": \"Data pack for resources provided by Bukkit plugins\",\n" -+ + " \"pack_format\": " + SharedConstants.getCurrentVersion().getPackVersion(PackType.DATA) + "\n" ++ + " \"pack_format\": " + SharedConstants.getCurrentVersion().getPackVersion(EnumResourcePackType.SERVER_DATA) + "\n" + + " }\n" + + "}\n", mcMeta, com.google.common.base.Charsets.UTF_8); + } catch (java.io.IOException ex) { @@ -120,7 +127,7 @@ WorldStem worldstem; -@@ -152,6 +198,7 @@ +@@ -164,6 +210,7 @@ worldstem = (WorldStem) SystemUtils.blockUntilDone((executor) -> { return WorldLoader.load(worldloader_c, (worldloader_a) -> { @@ -128,7 +135,7 @@ IRegistry iregistry = worldloader_a.datapackDimensions().registryOrThrow(Registries.LEVEL_STEM); DynamicOps dynamicops = RegistryOps.create(DynamicOpsNBT.INSTANCE, (HolderLookup.b) worldloader_a.datapackWorldgen()); Pair pair = convertable_conversionsession.getDataTag(dynamicops, worldloader_a.dataConfiguration(), iregistry, worldloader_a.datapackWorldgen().allRegistriesLifecycle()); -@@ -163,7 +210,7 @@ +@@ -175,7 +222,7 @@ WorldOptions worldoptions; WorldDimensions worlddimensions; @@ -137,7 +144,7 @@ worldsettings = MinecraftServer.DEMO_SETTINGS; worldoptions = WorldOptions.DEMO_OPTIONS; worlddimensions = WorldPresets.createNormalWorldDimensions(worldloader_a.datapackWorldgen()); -@@ -171,7 +218,7 @@ +@@ -183,7 +230,7 @@ DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.getProperties(); worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), worldloader_a.dataConfiguration()); @@ -146,7 +153,7 @@ worlddimensions = dedicatedserverproperties.createDimensions(worldloader_a.datapackWorldgen()); } -@@ -187,6 +234,7 @@ +@@ -199,6 +246,7 @@ return; } @@ -154,7 +161,7 @@ IRegistryCustom.Dimension iregistrycustom_dimension = worldstem.registries().compositeAccess(); if (optionset.has(optionspec4)) { -@@ -198,21 +246,32 @@ +@@ -210,21 +258,32 @@ SaveData savedata = worldstem.worldData(); convertable_conversionsession.saveDataTag(iregistrycustom_dimension, savedata); @@ -189,7 +196,7 @@ Thread thread = new Thread("Server Shutdown Thread") { public void run() { dedicatedserver.halt(true); -@@ -221,6 +280,7 @@ +@@ -233,6 +292,7 @@ thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER)); Runtime.getRuntime().addShutdownHook(thread); @@ -197,7 +204,7 @@ } catch (Exception exception1) { Main.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", exception1); } -@@ -246,7 +306,7 @@ +@@ -268,7 +328,7 @@ } public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, IRegistry iregistry) { diff --git a/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch b/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch index d4578ed508..6452dbc7a3 100644 --- a/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch +++ b/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -165,6 +165,32 @@ - import org.apache.commons.lang3.Validate; + import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; +// CraftBukkit start @@ -33,7 +33,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant implements ICommandListener, AutoCloseable { public static final Logger LOGGER = LogUtils.getLogger(); -@@ -247,6 +273,20 @@ +@@ -250,6 +276,20 @@ protected SaveData worldData; private volatile boolean isSaving; @@ -54,7 +54,7 @@ public static S spin(Function function) { AtomicReference atomicreference = new AtomicReference(); Thread thread = new Thread(() -> { -@@ -260,14 +300,14 @@ +@@ -263,14 +303,14 @@ thread.setPriority(8); } @@ -71,7 +71,7 @@ super("Server"); this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; this.profiler = this.metricsRecorder.getProfiler(); -@@ -288,7 +328,7 @@ +@@ -290,7 +330,7 @@ this.frameTimer = new CircularTimer(); this.registries = worldstem.registries(); this.worldData = worldstem.worldData(); @@ -80,7 +80,7 @@ throw new IllegalStateException("Missing Overworld dimension data"); } else { this.proxy = proxy; -@@ -311,13 +351,40 @@ +@@ -313,13 +353,40 @@ this.serverThread = thread; this.executor = SystemUtils.backgroundExecutor(); } @@ -122,7 +122,7 @@ ScoreboardServer scoreboardserver1 = this.getScoreboard(); Objects.requireNonNull(scoreboardserver1); -@@ -326,7 +393,7 @@ +@@ -328,7 +395,7 @@ protected abstract boolean initServer() throws IOException; @@ -131,7 +131,7 @@ if (!JvmProfiler.INSTANCE.isRunning()) { ; } -@@ -334,12 +401,8 @@ +@@ -336,12 +403,8 @@ boolean flag = false; ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted(); @@ -145,7 +145,7 @@ if (profiledduration != null) { profiledduration.finish(); } -@@ -354,25 +417,183 @@ +@@ -356,25 +419,183 @@ } @@ -223,9 +223,7 @@ + MinecraftServer.LOGGER.info("---- Migration of old " + worldType + " folder failed ----"); + } + } - -- this.levels.put(World.OVERWORLD, worldserver); -- WorldPersistentData worldpersistentdata = worldserver.getDataStorage(); ++ + try { + worldSession = Convertable.createDefault(server.getWorldContainer().toPath()).createAccess(name, dimensionKey); + } catch (IOException ex) { @@ -235,9 +233,7 @@ + + org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name); + org.bukkit.generator.BiomeProvider biomeProvider = this.server.getBiomeProvider(name); - -- this.readScoreboard(worldpersistentdata); -- this.commandStorage = new PersistentCommandStorage(worldpersistentdata); ++ + WorldDataServer worlddata; + WorldLoader.a worldloader_a = this.worldLoader; + IRegistry iregistry = worldloader_a.datapackDimensions().registryOrThrow(Registries.LEVEL_STEM); @@ -293,9 +289,13 @@ + if (dimensionKey == WorldDimension.OVERWORLD) { + this.worldData = worlddata; + this.worldData.setGameType(((DedicatedServer) this).getProperties().gamemode); // From DedicatedServer.init -+ + +- this.levels.put(World.OVERWORLD, worldserver); +- WorldPersistentData worldpersistentdata = worldserver.getDataStorage(); + WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11); -+ + +- this.readScoreboard(worldpersistentdata); +- this.commandStorage = new PersistentCommandStorage(worldpersistentdata); + world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, worlddimension, worldloadlistener, flag, j, list, true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider); + WorldPersistentData worldpersistentdata = world.getDataStorage(); + this.readScoreboard(worldpersistentdata); @@ -344,7 +344,7 @@ if (!iworlddataserver.isInitialized()) { try { -@@ -396,29 +617,8 @@ +@@ -398,29 +619,8 @@ iworlddataserver.setInitialized(true); } @@ -375,7 +375,7 @@ private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) { if (flag1) { -@@ -426,6 +626,21 @@ +@@ -428,6 +628,21 @@ } else { ChunkProviderServer chunkproviderserver = worldserver.getChunkSource(); ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition()); @@ -397,7 +397,7 @@ int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver); if (i < worldserver.getMinBuildHeight()) { -@@ -485,8 +700,11 @@ +@@ -487,8 +702,11 @@ iworlddataserver.setGameType(EnumGamemode.SPECTATOR); } @@ -411,7 +411,7 @@ MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location()); BlockPosition blockposition = worldserver.getSharedSpawnPos(); -@@ -496,19 +714,23 @@ +@@ -498,19 +716,23 @@ chunkproviderserver.getLightEngine().setTaskPerBatch(500); this.nextTickTime = SystemUtils.getMillis(); @@ -444,7 +444,7 @@ ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk::load, "chunks"); if (forcedchunk != null) { -@@ -523,11 +745,18 @@ +@@ -525,11 +747,18 @@ } } @@ -466,7 +466,7 @@ } public EnumGamemode getDefaultGameType() { -@@ -557,12 +786,16 @@ +@@ -559,12 +788,16 @@ worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2); } @@ -483,7 +483,7 @@ if (flag1) { Iterator iterator1 = this.getAllLevels().iterator(); -@@ -597,12 +830,33 @@ +@@ -599,12 +832,33 @@ this.stopServer(); } @@ -517,7 +517,7 @@ if (this.getConnection() != null) { this.getConnection().stop(); } -@@ -612,6 +866,7 @@ +@@ -614,6 +868,7 @@ MinecraftServer.LOGGER.info("Saving players"); this.playerList.saveAll(); this.playerList.removeAll(); @@ -525,7 +525,14 @@ } MinecraftServer.LOGGER.info("Saving worlds"); -@@ -707,9 +962,10 @@ +@@ -701,15 +956,16 @@ + } + + this.nextTickTime = SystemUtils.getMillis(); +- this.statusIcon = (ServerPing.a) this.loadStatusIcon().orElse((Object) null); ++ this.statusIcon = (ServerPing.a) this.loadStatusIcon().orElse(null); // CraftBukkit - decompile error + this.status = this.buildServerStatus(); + while (this.running) { long i = SystemUtils.getMillis() - this.nextTickTime; @@ -585,8 +592,8 @@ this.getProfiler().incrementCounter("runTask"); super.doRunTask(ticktask); } -@@ -909,7 +1179,7 @@ - } +@@ -891,7 +1161,7 @@ + this.status = this.buildServerStatus(); } - if (this.tickCount % 6000 == 0) { @@ -594,7 +601,7 @@ MinecraftServer.LOGGER.debug("Autosave started"); this.profiler.push("save"); this.saveEverything(true, false, false); -@@ -928,22 +1198,39 @@ +@@ -938,22 +1208,39 @@ } public void tickChildren(BooleanSupplier booleansupplier) { @@ -627,14 +634,14 @@ + /* Drop global time updates if (this.tickCount % 20 == 0) { this.profiler.push("timeSync"); - this.playerList.broadcastAll(new PacketPlayOutUpdateTime(worldserver.getGameTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)), worldserver.dimension()); + this.synchronizeTime(worldserver); this.profiler.pop(); } + // CraftBukkit end */ this.profiler.push("tick"); -@@ -1006,6 +1293,22 @@ +@@ -1033,6 +1320,22 @@ return (WorldServer) this.levels.get(resourcekey); } @@ -657,7 +664,7 @@ public Set> levelKeys() { return this.levels.keySet(); } -@@ -1032,7 +1335,7 @@ +@@ -1059,7 +1362,7 @@ @DontObfuscate public String getServerModName() { @@ -666,7 +673,7 @@ } public SystemReport fillSystemReport(SystemReport systemreport) { -@@ -1370,11 +1673,11 @@ +@@ -1398,11 +1701,11 @@ public CompletableFuture reloadResources(Collection collection) { IRegistryCustom.Dimension iregistrycustom_dimension = this.registries.getAccessForLoading(RegistryLayer.RELOADABLE); CompletableFuture completablefuture = CompletableFuture.supplyAsync(() -> { @@ -680,7 +687,7 @@ }, this).thenCompose((immutablelist) -> { ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist); -@@ -1389,6 +1692,7 @@ +@@ -1417,6 +1720,7 @@ }).thenAcceptAsync((minecraftserver_reloadableresources) -> { this.resources.close(); this.resources = minecraftserver_reloadableresources; @@ -688,7 +695,7 @@ this.packRepository.setSelected(collection); WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(getSelectedPacks(this.packRepository), this.worldData.enabledFeatures()); -@@ -1757,7 +2061,7 @@ +@@ -1785,7 +2089,7 @@ try { label51: { @@ -697,7 +704,7 @@ try { arraylist = Lists.newArrayList(NativeModuleLister.listModules()); -@@ -1807,6 +2111,22 @@ +@@ -1835,6 +2139,22 @@ } @@ -720,7 +727,7 @@ private void startMetricsRecordingTick() { if (this.willStartRecordingMetrics) { this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> { -@@ -1933,8 +2253,30 @@ +@@ -1961,8 +2281,30 @@ } diff --git a/paper-server/nms-patches/net/minecraft/server/commands/CommandEffect.patch b/paper-server/nms-patches/net/minecraft/server/commands/CommandEffect.patch index fe749fc3b2..9df39d9511 100644 --- a/paper-server/nms-patches/net/minecraft/server/commands/CommandEffect.patch +++ b/paper-server/nms-patches/net/minecraft/server/commands/CommandEffect.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/CommandEffect.java +++ b/net/minecraft/server/commands/CommandEffect.java -@@ -76,7 +76,7 @@ +@@ -84,7 +84,7 @@ if (entity instanceof EntityLiving) { MobEffect mobeffect = new MobEffect(mobeffectlist, k, i, false, flag); @@ -9,7 +9,7 @@ ++j; } } -@@ -102,7 +102,7 @@ +@@ -110,7 +110,7 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); @@ -18,7 +18,7 @@ ++i; } } -@@ -128,7 +128,7 @@ +@@ -136,7 +136,7 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); diff --git a/paper-server/nms-patches/net/minecraft/server/commands/CommandLoot.patch b/paper-server/nms-patches/net/minecraft/server/commands/CommandLoot.patch index b0712200b5..5004695bcc 100644 --- a/paper-server/nms-patches/net/minecraft/server/commands/CommandLoot.patch +++ b/paper-server/nms-patches/net/minecraft/server/commands/CommandLoot.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/CommandLoot.java +++ b/net/minecraft/server/commands/CommandLoot.java -@@ -91,7 +91,7 @@ +@@ -90,7 +90,7 @@ } private static > T addTargets(T t0, CommandLoot.c commandloot_c) { @@ -9,7 +9,7 @@ return entityReplace(ArgumentEntity.getEntities(commandcontext, "entities"), ArgumentInventorySlot.getSlot(commandcontext, "slot"), list.size(), list, commandloot_a); }).then(commandloot_c.construct(net.minecraft.commands.CommandDispatcher.argument("count", IntegerArgumentType.integer(0)), (commandcontext, list, commandloot_a) -> { return entityReplace(ArgumentEntity.getEntities(commandcontext, "entities"), ArgumentInventorySlot.getSlot(commandcontext, "slot"), IntegerArgumentType.getInteger(commandcontext, "count"), list, commandloot_a); -@@ -248,6 +248,7 @@ +@@ -247,6 +247,7 @@ private static int dropInWorld(CommandListenerWrapper commandlistenerwrapper, Vec3D vec3d, List list, CommandLoot.a commandloot_a) throws CommandSyntaxException { WorldServer worldserver = commandlistenerwrapper.getLevel(); diff --git a/paper-server/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch b/paper-server/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch index ec8c21b242..e21ef716cf 100644 --- a/paper-server/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch +++ b/paper-server/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch @@ -21,7 +21,7 @@ @@ -312,7 +312,7 @@ public boolean isSafe(IBlockAccess iblockaccess, int i) { - BlockPosition blockposition = new BlockPosition(this.x, (double) (this.getSpawnY(iblockaccess, i) - 1), this.z); + BlockPosition blockposition = BlockPosition.containing(this.x, (double) (this.getSpawnY(iblockaccess, i) - 1), this.z); - IBlockData iblockdata = iblockaccess.getBlockState(blockposition); + IBlockData iblockdata = getBlockState(iblockaccess, blockposition); // CraftBukkit Material material = iblockdata.getMaterial(); diff --git a/paper-server/nms-patches/net/minecraft/server/commands/CommandSummon.patch b/paper-server/nms-patches/net/minecraft/server/commands/CommandSummon.patch index e2a71691d6..7ab0f2a793 100644 --- a/paper-server/nms-patches/net/minecraft/server/commands/CommandSummon.patch +++ b/paper-server/nms-patches/net/minecraft/server/commands/CommandSummon.patch @@ -8,4 +8,4 @@ + if (!worldserver.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND)) { // CraftBukkit - pass a spawn reason of "COMMAND" throw CommandSummon.ERROR_DUPLICATE_UUID.create(); } else { - commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.summon.success", entity.getDisplayName()), true); + return entity; diff --git a/paper-server/nms-patches/net/minecraft/server/commands/CommandTeleport.patch b/paper-server/nms-patches/net/minecraft/server/commands/CommandTeleport.patch index 2bef358836..7699b8562d 100644 --- a/paper-server/nms-patches/net/minecraft/server/commands/CommandTeleport.patch +++ b/paper-server/nms-patches/net/minecraft/server/commands/CommandTeleport.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/CommandTeleport.java +++ b/net/minecraft/server/commands/CommandTeleport.java -@@ -35,6 +35,12 @@ +@@ -33,6 +33,13 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; @@ -8,27 +8,23 @@ +import org.bukkit.Location; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.event.entity.EntityTeleportEvent; ++import org.bukkit.event.player.PlayerTeleportEvent; +// CraftBukkit end + public class CommandTeleport { private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(IChatBaseComponent.translatable("commands.teleport.invalidPosition")); -@@ -159,14 +165,29 @@ - } +@@ -147,7 +154,30 @@ + float f2 = MathHelper.wrapDegrees(f); + float f3 = MathHelper.wrapDegrees(f1); - if (worldserver == entity.level) { -- ((EntityPlayer) entity).connection.teleport(d0, d1, d2, f2, f3, set); -+ ((EntityPlayer) entity).connection.teleport(d0, d1, d2, f2, f3, set, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit - } else { -- ((EntityPlayer) entity).teleportTo(worldserver, d0, d1, d2, f2, f3); -+ ((EntityPlayer) entity).teleportTo(worldserver, d0, d1, d2, f2, f3, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit - } - - entity.setYHeadRot(f2); - } else { - float f4 = MathHelper.clamp(f3, -90.0F, 90.0F); -+ // CraftBukkit start - Teleport event -+ Location to = new Location(worldserver.getWorld(), d0, d1, d2, f2, f4); +- if (entity.teleportTo(worldserver, d0, d1, d2, set, f2, f3)) { ++ // CraftBukkit start - Teleport event ++ boolean result; ++ if (entity instanceof EntityPlayer player) { ++ result = player.teleportTo(worldserver, d0, d1, d2, set, f2, f3, PlayerTeleportEvent.TeleportCause.COMMAND); ++ } else { ++ Location to = new Location(worldserver.getWorld(), d0, d1, d2, f2, f3); + EntityTeleportEvent event = new EntityTeleportEvent(entity.getBukkitEntity(), entity.getBukkitEntity().getLocation(), to); + worldserver.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { @@ -39,9 +35,14 @@ + d1 = to.getY(); + d2 = to.getZ(); + f2 = to.getYaw(); -+ f4 = to.getPitch(); ++ f3 = to.getPitch(); + worldserver = ((CraftWorld) to.getWorld()).getHandle(); ++ ++ result = entity.teleportTo(worldserver, d0, d1, d2, set, f2, f3); ++ } ++ ++ if (result) { + // CraftBukkit end - - if (worldserver == entity.level) { - entity.moveTo(d0, d1, d2, f2, f4); + if (commandteleport_a != null) { + commandteleport_a.perform(commandlistenerwrapper, entity); + } diff --git a/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch b/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch index 1fab621e9e..f26c735000 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/EntityPlayer.java +++ b/net/minecraft/server/level/EntityPlayer.java -@@ -150,6 +150,35 @@ +@@ -155,6 +155,35 @@ import net.minecraft.world.scores.criteria.IScoreboardCriteria; import org.slf4j.Logger; @@ -36,7 +36,7 @@ public class EntityPlayer extends EntityHuman { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -207,6 +236,21 @@ +@@ -212,6 +241,21 @@ public int latency; public boolean wonGame; @@ -58,9 +58,9 @@ public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile) { super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile); this.chatVisibility = EnumChatVisibility.FULL; -@@ -270,12 +314,56 @@ +@@ -275,12 +319,56 @@ this.advancements = minecraftserver.getPlayerList().getPlayerAdvancements(this); - this.maxUpStep = 1.0F; + this.setMaxUpStep(1.0F); this.fudgeSpawnLocation(worldserver); + + // CraftBukkit start @@ -116,7 +116,7 @@ int i = Math.max(0, this.server.getSpawnRadius(worldserver)); int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ())); -@@ -324,7 +412,7 @@ +@@ -329,7 +417,7 @@ public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { super.readAdditionalSaveData(nbttagcompound); if (nbttagcompound.contains("warden_spawn_tracker", 10)) { @@ -125,7 +125,7 @@ Logger logger = EntityPlayer.LOGGER; Objects.requireNonNull(logger); -@@ -343,17 +431,26 @@ +@@ -348,17 +436,26 @@ if (nbttagcompound.contains("recipeBook", 10)) { this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager()); } @@ -153,7 +153,7 @@ Logger logger1 = EntityPlayer.LOGGER; Objects.requireNonNull(logger1); -@@ -366,7 +463,7 @@ +@@ -371,7 +468,7 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(nbttagcompound); @@ -162,7 +162,7 @@ Logger logger = EntityPlayer.LOGGER; Objects.requireNonNull(logger); -@@ -387,7 +484,20 @@ +@@ -392,7 +489,20 @@ Entity entity = this.getRootVehicle(); Entity entity1 = this.getVehicle(); @@ -184,7 +184,7 @@ NBTTagCompound nbttagcompound2 = new NBTTagCompound(); NBTTagCompound nbttagcompound3 = new NBTTagCompound(); -@@ -412,9 +522,33 @@ +@@ -417,9 +527,33 @@ nbttagcompound.put("SpawnDimension", nbtbase); }); } @@ -218,7 +218,7 @@ public void setExperiencePoints(int i) { float f = (float) this.getXpNeededForNextLevel(); float f1 = (f - 1.0F) / f; -@@ -473,6 +607,11 @@ +@@ -478,6 +612,11 @@ @Override public void tick() { @@ -230,7 +230,7 @@ this.gameMode.tick(); this.wardenSpawnTracker.tick(); --this.spawnInvulnerableTime; -@@ -529,7 +668,7 @@ +@@ -534,7 +673,7 @@ } if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -239,7 +239,7 @@ this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -560,6 +699,12 @@ +@@ -565,6 +704,12 @@ this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience)); } @@ -252,7 +252,7 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel)); -@@ -574,6 +719,20 @@ +@@ -579,6 +724,20 @@ CriterionTriggers.LOCATION.trigger(this); } @@ -273,7 +273,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked"); -@@ -616,7 +775,8 @@ +@@ -621,7 +780,8 @@ } private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) { @@ -283,7 +283,7 @@ scoreboardscore.setScore(i); }); } -@@ -625,9 +785,47 @@ +@@ -630,9 +790,47 @@ public void die(DamageSource damagesource) { this.gameEvent(GameEvent.ENTITY_DIE); boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); @@ -333,7 +333,7 @@ this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> { boolean flag1 = true; -@@ -658,12 +856,18 @@ +@@ -663,12 +861,18 @@ if (this.level.getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) { this.tellNeutralMobsThatIDied(); } @@ -356,7 +356,7 @@ EntityLiving entityliving = this.getKillCredit(); if (entityliving != null) { -@@ -701,10 +905,12 @@ +@@ -706,10 +910,12 @@ String s = this.getScoreboardName(); String s1 = entity.getScoreboardName(); @@ -371,7 +371,7 @@ } else { this.awardStat(StatisticList.MOB_KILLS); } -@@ -722,7 +928,8 @@ +@@ -727,7 +933,8 @@ int i = scoreboardteam.getColor().getId(); if (i >= 0 && i < aiscoreboardcriteria.length) { @@ -381,7 +381,7 @@ } } -@@ -766,18 +973,20 @@ +@@ -777,18 +984,20 @@ } private boolean isPvpAllowed() { @@ -405,7 +405,7 @@ } else { return shapedetectorshape; } -@@ -786,11 +995,20 @@ +@@ -797,11 +1006,20 @@ @Nullable @Override public Entity changeDimension(WorldServer worldserver) { @@ -429,7 +429,7 @@ this.unRide(); this.getLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); if (!this.wonGame) { -@@ -801,6 +1019,8 @@ +@@ -812,6 +1030,8 @@ return this; } else { @@ -438,7 +438,7 @@ WorldData worlddata = worldserver.getLevelData(); this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), (byte) 3, this.getLastDeathLocation())); -@@ -810,20 +1030,50 @@ +@@ -821,20 +1041,50 @@ playerlist.sendPlayerPermissionLevel(this); worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); this.unsetRemoved(); @@ -455,7 +455,7 @@ this.enteredNetherPosition = this.position(); - } else if (worldserver.dimension() == World.END) { + } else if (worldserver.getTypeKey() == WorldDimension.END && shapedetectorshape.portalEventInfo != null && shapedetectorshape.portalEventInfo.getCanCreatePortal()) { // CraftBukkit - this.createEndPlatform(worldserver, new BlockPosition(shapedetectorshape.pos)); + this.createEndPlatform(worldserver, BlockPosition.containing(shapedetectorshape.pos)); } + // CraftBukkit start + } else { @@ -494,7 +494,7 @@ this.connection.resetPosition(); worldserver.addDuringPortalTeleport(this); worldserver1.getProfiler().pop(); -@@ -843,39 +1093,66 @@ +@@ -854,39 +1104,66 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -567,7 +567,7 @@ } return optional1; -@@ -885,13 +1162,21 @@ +@@ -896,13 +1173,21 @@ public void triggerDimensionChangeTriggers(WorldServer worldserver) { ResourceKey resourcekey = worldserver.dimension(); ResourceKey resourcekey1 = this.level.dimension(); @@ -592,7 +592,7 @@ this.enteredNetherPosition = null; } -@@ -908,12 +1193,10 @@ +@@ -919,12 +1204,10 @@ this.containerMenu.broadcastChanges(); } @@ -608,7 +608,7 @@ return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE); } else if (!this.bedInRange(blockposition, enumdirection)) { return Either.left(EntityHuman.EnumBedResult.TOO_FAR_AWAY); -@@ -937,7 +1220,36 @@ +@@ -948,7 +1231,36 @@ } } @@ -646,7 +646,7 @@ this.awardStat(StatisticList.SLEEP_IN_BED); CriterionTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -950,9 +1262,8 @@ +@@ -961,9 +1273,8 @@ return either; } } @@ -657,7 +657,7 @@ } @Override -@@ -979,6 +1290,24 @@ +@@ -990,6 +1301,24 @@ @Override public void stopSleepInBed(boolean flag, boolean flag1) { @@ -682,7 +682,7 @@ if (this.isSleeping()) { this.getLevel().getChunkSource().broadcastAndSend(this, new PacketPlayOutAnimation(this, 2)); } -@@ -1060,8 +1389,9 @@ +@@ -1038,8 +1367,9 @@ this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos())); } @@ -693,7 +693,7 @@ } @Override -@@ -1069,13 +1399,35 @@ +@@ -1047,13 +1377,35 @@ if (itileinventory == null) { return OptionalInt.empty(); } else { @@ -729,7 +729,7 @@ if (container == null) { if (this.isSpectator()) { this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true); -@@ -1083,9 +1435,11 @@ +@@ -1061,9 +1413,11 @@ return OptionalInt.empty(); } else { @@ -743,7 +743,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1098,13 +1452,24 @@ +@@ -1076,13 +1430,24 @@ @Override public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { @@ -770,7 +770,7 @@ this.initMenu(this.containerMenu); } -@@ -1127,6 +1492,7 @@ +@@ -1105,6 +1470,7 @@ @Override public void closeContainer() { @@ -778,7 +778,7 @@ this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId)); this.doCloseContainer(); } -@@ -1157,7 +1523,7 @@ +@@ -1135,7 +1501,7 @@ @Override public void awardStat(Statistic statistic, int i) { this.stats.increment(this, statistic, i); @@ -787,7 +787,7 @@ scoreboardscore.add(i); }); } -@@ -1165,7 +1531,7 @@ +@@ -1143,7 +1509,7 @@ @Override public void resetStat(Statistic statistic) { this.stats.setValue(this, statistic, 0); @@ -796,7 +796,7 @@ } @Override -@@ -1181,7 +1547,7 @@ +@@ -1159,7 +1525,7 @@ for (int j = 0; j < i; ++j) { MinecraftKey minecraftkey = aminecraftkey1[j]; @@ -805,7 +805,7 @@ Objects.requireNonNull(list); optional.ifPresent(list::add); -@@ -1216,6 +1582,7 @@ +@@ -1194,6 +1560,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -813,7 +813,7 @@ } @Override -@@ -1274,7 +1641,7 @@ +@@ -1252,7 +1619,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -822,8 +822,33 @@ this.seenCredits = entityplayer.seenCredits; this.enteredNetherPosition = entityplayer.enteredNetherPosition; this.setShoulderEntityLeft(entityplayer.getShoulderEntityLeft()); -@@ -1415,7 +1782,20 @@ - return s; +@@ -1302,6 +1669,12 @@ + + @Override + public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1) { ++ // CraftBukkit start ++ return teleportTo(worldserver, 0, 0, 0, set, 0, 0, TeleportCause.UNKNOWN); ++ } ++ ++ public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1, TeleportCause cause) { ++ // CraftBukkit end + ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(BlockPosition.containing(d0, d1, d2)); + + worldserver.getChunkSource().addRegionTicket(TicketType.POST_TELEPORT, chunkcoordintpair, 1, this.getId()); +@@ -1311,9 +1684,9 @@ + } + + if (worldserver == this.level) { +- this.connection.teleport(d0, d1, d2, f, f1, set); ++ this.connection.teleport(d0, d1, d2, f, f1, set, cause); // CraftBukkit + } else { +- this.teleportTo(worldserver, d0, d1, d2, f, f1); ++ this.teleportTo(worldserver, d0, d1, d2, f, f1, cause); // CraftBukkit + } + + this.setYHeadRot(f); +@@ -1417,7 +1790,20 @@ + } } + public String locale = "en_us"; // CraftBukkit - add, lowercase @@ -843,16 +868,16 @@ this.chatVisibility = packetplayinsettings.chatVisibility(); this.canChatColor = packetplayinsettings.chatColors(); this.textFilteringEnabled = packetplayinsettings.textFilteringEnabled(); -@@ -1486,7 +1866,7 @@ - this.camera = (Entity) (entity == null ? this : entity); - if (entity1 != this.camera) { - this.connection.send(new PacketPlayOutCamera(this.camera)); -- this.connection.teleport(this.camera.getX(), this.camera.getY(), this.camera.getZ(), this.getYRot(), this.getXRot()); -+ this.connection.teleport(this.camera.getX(), this.camera.getY(), this.camera.getZ(), this.getYRot(), this.getXRot(), TeleportCause.SPECTATE); // CraftBukkit - this.connection.resetPosition(); - } +@@ -1492,7 +1878,7 @@ + if (world instanceof WorldServer) { + WorldServer worldserver = (WorldServer) world; -@@ -1516,7 +1896,7 @@ +- this.teleportTo(worldserver, this.camera.getX(), this.camera.getY(), this.camera.getZ(), Set.of(), this.getYRot(), this.getXRot()); ++ this.teleportTo(worldserver, this.camera.getX(), this.camera.getY(), this.camera.getZ(), Set.of(), this.getYRot(), this.getXRot(), TeleportCause.SPECTATE); // CraftBukkit + } + + if (entity != null) { +@@ -1529,7 +1915,7 @@ @Nullable public IChatBaseComponent getTabListDisplayName() { @@ -861,7 +886,7 @@ } @Override -@@ -1537,9 +1917,16 @@ +@@ -1550,9 +1936,16 @@ return this.advancements; } @@ -878,7 +903,7 @@ if (worldserver == this.level) { this.connection.teleport(d0, d1, d2, f, f1); } else { -@@ -1559,6 +1946,9 @@ +@@ -1572,6 +1965,9 @@ this.server.getPlayerList().sendLevelInfo(this, worldserver); this.server.getPlayerList().sendAllPlayerInfo(this); } @@ -888,9 +913,9 @@ } -@@ -1743,4 +2133,146 @@ - public RemoteChatSession getChatSession() { - return this.chatSession; +@@ -1762,4 +2158,146 @@ + this.hurtDir = (float) (MathHelper.atan2(d1, d0) * 57.2957763671875D - (double) this.getYRot()); + this.connection.send(new ClientboundHurtAnimationPacket(this)); } + + // CraftBukkit start - Add per-player time and weather. diff --git a/paper-server/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch b/paper-server/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch index 14e8321bea..28cc0f3df7 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/EntityTrackerEntry.java +++ b/net/minecraft/server/level/EntityTrackerEntry.java -@@ -42,6 +42,12 @@ +@@ -44,6 +44,12 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -13,7 +13,7 @@ public class EntityTrackerEntry { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -63,8 +69,12 @@ +@@ -65,8 +71,12 @@ private boolean wasOnGround; @Nullable private List> trackedDataValues; @@ -27,16 +27,16 @@ this.ap = Vec3D.ZERO; this.lastPassengers = Collections.emptyList(); this.level = worldserver; -@@ -85,7 +95,7 @@ +@@ -86,7 +96,7 @@ + List list = this.entity.getPassengers(); if (!list.equals(this.lastPassengers)) { - this.lastPassengers = list; - this.broadcast.accept(new PacketPlayOutMount(this.entity)); + this.broadcastAndSend(new PacketPlayOutMount(this.entity)); // CraftBukkit - } - - Entity entity = this.entity; -@@ -93,18 +103,18 @@ + this.changedPassengers(list, this.lastPassengers).forEach((entity) -> { + if (entity instanceof EntityPlayer) { + EntityPlayer entityplayer = (EntityPlayer) entity; +@@ -105,18 +115,18 @@ if (entity instanceof EntityItemFrame) { EntityItemFrame entityitemframe = (EntityItemFrame) entity; @@ -59,7 +59,7 @@ worldmap.tickCarriedBy(entityplayer, itemstack); Packet packet = worldmap.getUpdatePacket(integer, entityplayer); -@@ -209,7 +219,27 @@ +@@ -229,7 +239,27 @@ ++this.tickCount; if (this.entity.hurtMarked) { @@ -88,17 +88,18 @@ this.entity.hurtMarked = false; } -@@ -224,13 +254,16 @@ - PlayerConnection playerconnection = entityplayer.connection; +@@ -252,14 +282,17 @@ + List> list = new ArrayList(); - Objects.requireNonNull(entityplayer.connection); -- this.sendPairingData(playerconnection::send); -+ this.sendPairingData(playerconnection::send, entityplayer); // CraftBukkit - add player + Objects.requireNonNull(list); +- this.sendPairingData(list::add); ++ this.sendPairingData(list::add, entityplayer); // CraftBukkit - add player + entityplayer.connection.send(new ClientboundBundlePacket(list)); this.entity.startSeenByPlayer(entityplayer); } -- public void sendPairingData(Consumer> consumer) { -+ public void sendPairingData(Consumer> consumer, EntityPlayer entityplayer) { // CraftBukkit - add player +- public void sendPairingData(Consumer> consumer) { ++ public void sendPairingData(Consumer> consumer, EntityPlayer entityplayer) { // CraftBukkit - add player if (this.entity.isRemoved()) { - EntityTrackerEntry.LOGGER.warn("Fetching packet for removed entity {}", this.entity); + // CraftBukkit start - Remove useless error spam, just return @@ -108,7 +109,7 @@ } Packet packet = this.entity.getAddEntityPacket(); -@@ -246,6 +279,12 @@ +@@ -275,6 +308,12 @@ if (this.entity instanceof EntityLiving) { Collection collection = ((EntityLiving) this.entity).getAttributes().getSyncableAttributes(); @@ -121,7 +122,7 @@ if (!collection.isEmpty()) { consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection)); } -@@ -277,8 +316,14 @@ +@@ -306,8 +345,14 @@ if (!list.isEmpty()) { consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list)); } @@ -136,7 +137,7 @@ if (this.entity instanceof EntityLiving) { EntityLiving entityliving = (EntityLiving) this.entity; Iterator iterator = entityliving.getActiveEffects().iterator(); -@@ -321,6 +366,11 @@ +@@ -350,6 +395,11 @@ Set set = ((EntityLiving) this.entity).getAttributes().getDirtyAttributes(); if (!set.isEmpty()) { diff --git a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch index 0f7b584a1b..5848f7e474 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/PlayerChunkMap.java +++ b/net/minecraft/server/level/PlayerChunkMap.java -@@ -106,6 +106,12 @@ +@@ -109,6 +109,12 @@ import org.apache.commons.lang3.mutable.MutableObject; import org.slf4j.Logger; @@ -13,7 +13,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.e { private static final byte CHUNK_TYPE_REPLACEABLE = -1; -@@ -149,6 +155,27 @@ +@@ -152,6 +158,27 @@ private final Queue unloadQueue; int viewDistance; @@ -41,7 +41,7 @@ public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, StructureTemplateManager structuretemplatemanager, Executor executor, IAsyncTaskHandler iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier supplier, int i, boolean flag) { super(convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag); this.visibleChunkMap = this.updatingChunkMap.clone(); -@@ -167,6 +194,11 @@ +@@ -170,6 +197,11 @@ this.storageName = path.getFileName().toString(); this.level = worldserver; this.generator = chunkgenerator; @@ -53,7 +53,7 @@ IRegistryCustom iregistrycustom = worldserver.registryAccess(); long j = worldserver.getSeed(); -@@ -326,9 +358,12 @@ +@@ -329,9 +361,12 @@ CompletableFuture>> completablefuture1 = SystemUtils.sequence(list); CompletableFuture, PlayerChunk.Failure>> completablefuture2 = completablefuture1.thenApply((list2) -> { List list3 = Lists.newArrayList(); @@ -68,7 +68,7 @@ final Either either = (Either) iterator.next(); if (either == null) { -@@ -533,7 +568,7 @@ +@@ -536,7 +571,7 @@ private void scheduleUnload(long i, PlayerChunk playerchunk) { CompletableFuture completablefuture = playerchunk.getChunkToSave(); @@ -77,7 +77,7 @@ CompletableFuture completablefuture1 = playerchunk.getChunkToSave(); if (completablefuture1 != completablefuture) { -@@ -622,9 +657,9 @@ +@@ -625,9 +660,9 @@ ProtoChunk protochunk = ChunkRegionLoader.read(this.level, this.poiManager, chunkcoordintpair, (NBTTagCompound) optional.get()); this.markPosition(chunkcoordintpair, protochunk.getStatus().getChunkType()); @@ -89,7 +89,7 @@ } }, this.mainThreadExecutor).exceptionallyAsync((throwable) -> { return this.handleChunkLoadFailure(throwable, chunkcoordintpair); -@@ -730,7 +765,21 @@ +@@ -733,7 +768,21 @@ private static void postLoadProtoChunk(WorldServer worldserver, List list) { if (!list.isEmpty()) { @@ -112,7 +112,7 @@ } } -@@ -829,7 +878,7 @@ +@@ -832,7 +881,7 @@ if (!playerchunk.wasAccessibleSinceLastSave()) { return false; } else { @@ -121,7 +121,7 @@ if (!(ichunkaccess instanceof ProtoChunkExtension) && !(ichunkaccess instanceof Chunk)) { return false; -@@ -991,7 +1040,8 @@ +@@ -994,7 +1043,8 @@ return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty(); }); @@ -131,7 +131,7 @@ return chunk.getBlockEntities().size(); }).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> { return chunk.getBlockTicks().count(); -@@ -1004,7 +1054,7 @@ +@@ -1007,7 +1057,7 @@ private static String printFuture(CompletableFuture> completablefuture) { try { @@ -140,7 +140,7 @@ return either != null ? (String) either.map((chunk) -> { return "done"; -@@ -1020,12 +1070,14 @@ +@@ -1023,12 +1073,14 @@ private CompletableFuture> readChunk(ChunkCoordIntPair chunkcoordintpair) { return this.read(chunkcoordintpair).thenApplyAsync((optional) -> { @@ -158,7 +158,7 @@ } boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) { -@@ -1471,7 +1523,7 @@ +@@ -1482,7 +1534,7 @@ public final Set seenBy = Sets.newIdentityHashSet(); public EntityTracker(Entity entity, int i, int j, boolean flag) { @@ -167,7 +167,7 @@ this.entity = entity; this.range = i; this.lastSectionPos = SectionPosition.of((EntityAccess) entity); -@@ -1530,6 +1582,11 @@ +@@ -1541,6 +1593,11 @@ double d2 = d0 * d0; boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer); diff --git a/paper-server/nms-patches/net/minecraft/server/level/WorldServer.patch b/paper-server/nms-patches/net/minecraft/server/level/WorldServer.patch index 9da4e176a1..889389b2b7 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/WorldServer.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/WorldServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/WorldServer.java +++ b/net/minecraft/server/level/WorldServer.java -@@ -156,6 +156,26 @@ +@@ -159,6 +159,26 @@ import net.minecraft.world.ticks.TickListServer; import org.slf4j.Logger; @@ -27,7 +27,7 @@ public class WorldServer extends World implements GeneratorAccessSeed { public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0); -@@ -173,7 +193,7 @@ +@@ -172,7 +192,7 @@ final List players; private final ChunkProviderServer chunkSource; private final MinecraftServer server; @@ -36,11 +36,12 @@ final EntityTickList entityTickList; public final PersistentEntitySectionManager entityManager; private final GameEventDispatcher gameEventDispatcher; -@@ -197,11 +217,28 @@ +@@ -196,12 +216,30 @@ private final StructureCheck structureCheck; private final boolean tickTime; - public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey resourcekey, WorldDimension worlddimension, WorldLoadListener worldloadlistener, boolean flag, long i, List list, boolean flag1) { +- IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess(); - Holder holder = worlddimension.type(); + // CraftBukkit start + public final Convertable.ConversionSession convertable; @@ -56,12 +57,14 @@ + } - Objects.requireNonNull(minecraftserver); -- super(iworlddataserver, resourcekey, holder, minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates()); +- super(iworlddataserver, resourcekey, iregistrycustom_dimension, holder, minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates()); + // Add env and gen to constructor, IWorldDataServer -> WorldDataServer + public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, WorldDataServer iworlddataserver, ResourceKey resourcekey, WorldDimension worlddimension, WorldLoadListener worldloadlistener, boolean flag, long i, List list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { ++ // IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess(); // CraftBukkit - decompile error + // Holder holder = worlddimension.type(); // CraftBukkit - decompile error ++ + // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error -+ super(iworlddataserver, resourcekey, worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env); ++ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env); + this.pvpMode = minecraftserver.isPvpAllowed(); + convertable = convertable_conversionsession; + uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile()); @@ -69,7 +72,7 @@ this.players = Lists.newArrayList(); this.entityTickList = new EntityTickList(); this.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier()); -@@ -215,6 +252,22 @@ +@@ -215,6 +253,22 @@ this.customSpawners = list; this.serverLevelData = iworlddataserver; ChunkGenerator chunkgenerator = worlddimension.generator(); @@ -92,7 +95,7 @@ boolean flag2 = minecraftserver.forceSynchronousWrites(); DataFixer datafixer = minecraftserver.getFixerUpper(); EntityPersistentStorage entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver); -@@ -246,15 +299,16 @@ +@@ -246,15 +300,16 @@ long l = minecraftserver.getWorldData().worldGenOptions().seed(); this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer); @@ -112,7 +115,7 @@ } public void setWeatherParameters(int i, int j, boolean flag, boolean flag1) { -@@ -286,12 +340,20 @@ +@@ -286,12 +341,20 @@ long j; if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { @@ -136,7 +139,7 @@ if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) { this.resetWeatherCycle(); } -@@ -317,7 +379,7 @@ +@@ -317,7 +380,7 @@ this.runBlockEvents(); this.handlingTick = false; gameprofilerfiller.pop(); @@ -145,7 +148,7 @@ if (flag) { this.resetEmptyTime(); -@@ -333,7 +395,7 @@ +@@ -333,7 +396,7 @@ this.entityTickList.forEach((entity) -> { if (!entity.isRemoved()) { @@ -154,7 +157,7 @@ entity.discard(); } else { gameprofilerfiller.push("checkDespawn"); -@@ -405,7 +467,7 @@ +@@ -405,7 +468,7 @@ private void wakeUpAllPlayers() { this.sleepStatus.removeAllSleepers(); @@ -163,7 +166,7 @@ entityplayer.stopSleepInBed(false, false); }); } -@@ -433,7 +495,7 @@ +@@ -433,7 +496,7 @@ entityhorseskeleton.setTrap(true); entityhorseskeleton.setAge(0); entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); @@ -172,7 +175,7 @@ } } -@@ -442,7 +504,7 @@ +@@ -442,7 +505,7 @@ if (entitylightning != null) { entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition)); entitylightning.setVisualOnly(flag1); @@ -181,7 +184,7 @@ } } } -@@ -456,7 +518,7 @@ +@@ -456,7 +519,7 @@ BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition).value(); if (biomebase.shouldFreeze(this, blockposition1)) { @@ -190,7 +193,7 @@ } if (flag) { -@@ -471,10 +533,10 @@ +@@ -471,10 +534,10 @@ IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, l + 1); Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition); @@ -203,7 +206,7 @@ } } -@@ -671,6 +733,7 @@ +@@ -670,6 +733,7 @@ this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F); } @@ -211,7 +214,7 @@ if (this.oRainLevel != this.rainLevel) { this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension()); } -@@ -689,14 +752,47 @@ +@@ -688,14 +752,47 @@ this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } @@ -261,7 +264,7 @@ } public void resetEmptyTime() { -@@ -731,6 +827,7 @@ +@@ -730,6 +827,7 @@ }); gameprofilerfiller.incrementCounter("tickNonPassenger"); entity.tick(); @@ -269,7 +272,7 @@ this.getProfiler().pop(); Iterator iterator = entity.getPassengers().iterator(); -@@ -754,6 +851,7 @@ +@@ -753,6 +851,7 @@ }); gameprofilerfiller.incrementCounter("tickPassenger"); entity1.rideTick(); @@ -277,7 +280,7 @@ gameprofilerfiller.pop(); Iterator iterator = entity1.getPassengers().iterator(); -@@ -778,6 +876,7 @@ +@@ -777,6 +876,7 @@ ChunkProviderServer chunkproviderserver = this.getChunkSource(); if (!flag1) { @@ -285,7 +288,7 @@ if (iprogressupdate != null) { iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel")); } -@@ -795,11 +894,19 @@ +@@ -794,11 +894,19 @@ } } @@ -306,7 +309,7 @@ } this.getChunkSource().getDataStorage().save(); -@@ -864,15 +971,37 @@ +@@ -863,15 +971,37 @@ @Override public boolean addFreshEntity(Entity entity) { @@ -347,7 +350,7 @@ } public void addDuringCommandTeleport(EntityPlayer entityplayer) { -@@ -903,24 +1032,37 @@ +@@ -902,24 +1032,37 @@ this.entityManager.addNewEntity(entityplayer); } @@ -389,7 +392,7 @@ return true; } } -@@ -934,10 +1076,32 @@ +@@ -933,10 +1076,32 @@ entityplayer.remove(entity_removalreason); } @@ -422,7 +425,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -946,6 +1110,12 @@ +@@ -945,6 +1110,12 @@ double d1 = (double) blockposition.getY() - entityplayer.getY(); double d2 = (double) blockposition.getZ() - entityplayer.getZ(); @@ -435,7 +438,7 @@ if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); } -@@ -1005,7 +1175,18 @@ +@@ -1004,7 +1175,18 @@ Iterator iterator = this.navigatingMobs.iterator(); while (iterator.hasNext()) { @@ -455,7 +458,7 @@ NavigationAbstract navigationabstract = entityinsentient.getNavigation(); if (navigationabstract.shouldRecomputePath(blockposition)) { -@@ -1062,6 +1243,11 @@ +@@ -1066,6 +1248,11 @@ @Override public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, World.a world_a) { Explosion explosion = this.explode(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, world_a, false); @@ -467,7 +470,7 @@ if (!explosion.interactsWithBlocks()) { explosion.clearToBlow(); -@@ -1134,13 +1320,20 @@ +@@ -1138,13 +1325,20 @@ } public int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { @@ -490,7 +493,7 @@ ++j; } } -@@ -1191,7 +1384,7 @@ +@@ -1195,7 +1389,7 @@ @Nullable public BlockPosition findNearestMapStructure(TagKey tagkey, BlockPosition blockposition, int i, boolean flag) { @@ -499,7 +502,7 @@ return null; } else { Optional> optional = this.registryAccess().registryOrThrow(Registries.STRUCTURE).getTag(tagkey); -@@ -1233,11 +1426,21 @@ +@@ -1232,11 +1426,21 @@ @Nullable @Override public WorldMap getMapData(String s) { @@ -522,7 +525,7 @@ this.getServer().overworld().getDataStorage().set(s, worldmap); } -@@ -1535,6 +1738,11 @@ +@@ -1534,6 +1738,11 @@ @Override public void blockUpdated(BlockPosition blockposition, Block block) { if (!this.isDebug()) { @@ -534,7 +537,7 @@ this.updateNeighborsAt(blockposition, block); } -@@ -1554,12 +1762,12 @@ +@@ -1553,12 +1762,12 @@ } public boolean isFlat() { @@ -549,7 +552,7 @@ } @Nullable -@@ -1582,7 +1790,7 @@ +@@ -1581,7 +1790,7 @@ private static String getTypeCount(Iterable iterable, Function function) { try { Object2IntOpenHashMap object2intopenhashmap = new Object2IntOpenHashMap(); @@ -558,7 +561,7 @@ while (iterator.hasNext()) { T t0 = iterator.next(); -@@ -1591,7 +1799,7 @@ +@@ -1590,7 +1799,7 @@ object2intopenhashmap.addTo(s, 1); } @@ -567,7 +570,7 @@ String s1 = (String) entry.getKey(); return s1 + ":" + entry.getIntValue(); -@@ -1602,17 +1810,33 @@ +@@ -1601,17 +1810,33 @@ } public static void makeObsidianPlatform(WorldServer worldserver) { @@ -603,7 +606,7 @@ } @Override -@@ -1728,6 +1952,7 @@ +@@ -1727,6 +1952,7 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -611,7 +614,7 @@ } public void onTrackingEnd(Entity entity) { -@@ -1764,6 +1989,14 @@ +@@ -1763,6 +1989,14 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); diff --git a/paper-server/nms-patches/net/minecraft/server/network/HandshakeListener.patch b/paper-server/nms-patches/net/minecraft/server/network/HandshakeListener.patch index 60422bf368..937d7f4809 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/HandshakeListener.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/HandshakeListener.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/network/HandshakeListener.java +++ b/net/minecraft/server/network/HandshakeListener.java -@@ -10,8 +10,17 @@ - import net.minecraft.network.protocol.login.PacketLoginOutDisconnect; +@@ -11,8 +11,17 @@ + import net.minecraft.network.protocol.status.ServerPing; import net.minecraft.server.MinecraftServer; +// CraftBukkit start @@ -18,7 +18,7 @@ private static final IChatBaseComponent IGNORE_STATUS_REASON = IChatBaseComponent.literal("Ignoring status request"); private final MinecraftServer server; private final NetworkManager connection; -@@ -23,9 +32,44 @@ +@@ -24,9 +33,44 @@ @Override public void handleIntention(PacketHandshakingInSetProtocol packethandshakinginsetprotocol) { diff --git a/paper-server/nms-patches/net/minecraft/server/network/LoginListener.patch b/paper-server/nms-patches/net/minecraft/server/network/LoginListener.patch index b58f09f2bd..ee6abfc0cf 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/LoginListener.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/LoginListener.patch @@ -25,8 +25,8 @@ + // CraftBukkit end + @Override - public NetworkManager getConnection() { - return this.connection; + public boolean isAcceptingMessages() { + return this.connection.isConnected(); @@ -104,10 +117,12 @@ this.gameProfile = this.createFakeProfile(this.gameProfile); } diff --git a/paper-server/nms-patches/net/minecraft/server/network/PacketStatusListener.patch b/paper-server/nms-patches/net/minecraft/server/network/PacketStatusListener.patch index ca725c566b..49073b4376 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/PacketStatusListener.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/PacketStatusListener.patch @@ -1,15 +1,18 @@ --- a/net/minecraft/server/network/PacketStatusListener.java +++ b/net/minecraft/server/network/PacketStatusListener.java -@@ -9,6 +9,18 @@ +@@ -9,6 +9,21 @@ import net.minecraft.network.protocol.status.PacketStatusOutServerInfo; - import net.minecraft.server.MinecraftServer; + import net.minecraft.network.protocol.status.ServerPing; +// CraftBukkit start +import com.mojang.authlib.GameProfile; +import java.net.InetSocketAddress; ++import java.util.Collections; +import java.util.Iterator; ++import java.util.Optional; +import net.minecraft.SharedConstants; +import net.minecraft.network.protocol.status.ServerPing; ++import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.EntityPlayer; +import org.bukkit.craftbukkit.util.CraftChatMessage; +import org.bukkit.craftbukkit.util.CraftIconCache; @@ -19,13 +22,14 @@ public class PacketStatusListener implements PacketStatusInListener { private static final IChatBaseComponent DISCONNECT_REASON = IChatBaseComponent.translatable("multiplayer.status.request_handled"); -@@ -35,7 +47,102 @@ +@@ -35,7 +50,101 @@ this.connection.disconnect(PacketStatusListener.DISCONNECT_REASON); } else { this.hasRequestedStatus = true; -- this.connection.send(new PacketStatusOutServerInfo(this.server.getStatus())); +- this.connection.send(new PacketStatusOutServerInfo(this.status)); + // CraftBukkit start -+ // this.connection.send(new PacketStatusOutServerInfo(this.server.getStatus())); ++ // this.connection.send(new PacketStatusOutServerInfo(this.status)); ++ MinecraftServer server = MinecraftServer.getServer(); + final Object[] players = server.getPlayerList().players.toArray(); + class ServerListPingEvent extends org.bukkit.event.server.ServerListPingEvent { + @@ -92,7 +96,7 @@ + } + + ServerListPingEvent event = new ServerListPingEvent(); -+ this.server.server.getPluginManager().callEvent(event); ++ server.server.getPluginManager().callEvent(event); + + java.util.List profiles = new java.util.ArrayList(players.length); + for (Object player : players) { @@ -106,17 +110,15 @@ + } + } + -+ ServerPing.ServerPingPlayerSample playerSample = new ServerPing.ServerPingPlayerSample(event.getMaxPlayers(), profiles.size()); -+ if (!this.server.hidesOnlinePlayers()) { -+ playerSample.setSample(profiles.toArray(new GameProfile[profiles.size()])); -+ } ++ ServerPing.ServerPingPlayerSample playerSample = new ServerPing.ServerPingPlayerSample(event.getMaxPlayers(), profiles.size(), (server.hidesOnlinePlayers()) ? Collections.emptyList() : profiles); + -+ ServerPing ping = new ServerPing(); -+ ping.setFavicon(event.icon.value); -+ ping.setDescription(CraftChatMessage.fromString(event.getMotd(), true)[0]); -+ ping.setPlayers(playerSample); -+ int version = SharedConstants.getCurrentVersion().getProtocolVersion(); -+ ping.setVersion(new ServerPing.ServerData(server.getServerModName() + " " + server.getServerVersion(), version)); ++ ServerPing ping = new ServerPing( ++ CraftChatMessage.fromString(event.getMotd(), true)[0], ++ Optional.of(playerSample), ++ Optional.of(new ServerPing.ServerData(server.getServerModName() + " " + server.getServerVersion(), SharedConstants.getCurrentVersion().getProtocolVersion())), ++ (event.icon.value != null) ? Optional.of(new ServerPing.a(event.icon.value)) : Optional.empty(), ++ server.enforceSecureProfile() ++ ); + + this.connection.send(new PacketStatusOutServerInfo(ping)); + // CraftBukkit end diff --git a/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch b/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch index 0f0e5bd95d..57379210d9 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/PlayerConnection.java +++ b/net/minecraft/server/network/PlayerConnection.java -@@ -182,6 +182,67 @@ +@@ -184,6 +184,67 @@ import net.minecraft.world.phys.shapes.VoxelShapes; import org.slf4j.Logger; @@ -68,7 +68,7 @@ public class PlayerConnection implements ServerPlayerConnection, TickablePacketListener, PacketListenerPlayIn { static final Logger LOGGER = LogUtils.getLogger(); -@@ -198,7 +259,9 @@ +@@ -200,7 +261,9 @@ private long keepAliveTime; private boolean keepAlivePending; private long keepAliveChallenge; @@ -79,7 +79,7 @@ private int dropSpamTickCount; private double firstGoodX; private double firstGoodY; -@@ -244,8 +307,31 @@ +@@ -246,8 +309,31 @@ this.keepAliveTime = SystemUtils.getMillis(); entityplayer.getTextFilter().join(); this.signedMessageDecoder = minecraftserver.enforceSecureProfile() ? SignedMessageChain.b.REJECT_ALL : SignedMessageChain.b.unsigned(entityplayer.getUUID()); @@ -112,7 +112,7 @@ @Override public void tick() { -@@ -300,7 +386,7 @@ +@@ -302,7 +388,7 @@ this.server.getProfiler().push("keepAlive"); long i = SystemUtils.getMillis(); @@ -121,7 +121,7 @@ if (this.keepAlivePending) { this.disconnect(IChatBaseComponent.translatable("disconnect.timeout")); } else { -@@ -312,15 +398,21 @@ +@@ -314,15 +400,21 @@ } this.server.getProfiler().pop(); @@ -143,7 +143,7 @@ this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.idling")); } -@@ -344,16 +436,67 @@ +@@ -346,16 +438,67 @@ return this.server.isSingleplayerOwner(this.player.getGameProfile()); } @@ -212,7 +212,7 @@ } private CompletableFuture filterTextPacket(T t0, BiFunction> bifunction) { -@@ -417,7 +560,34 @@ +@@ -419,7 +562,34 @@ double d9 = entity.getDeltaMovement().lengthSqr(); double d10 = d6 * d6 + d7 * d7 + d8 * d8; @@ -248,7 +248,7 @@ PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8}); this.connection.send(new PacketPlayOutVehicleMove(entity)); return; -@@ -449,14 +619,72 @@ +@@ -451,14 +621,72 @@ } entity.absMoveTo(d3, d4, d5, f, f1); @@ -321,7 +321,7 @@ this.player.getLevel().getChunkSource().move(this.player); this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2); this.clientVehicleIsFloating = d11 >= -0.03125D && !flag1 && !this.server.isFlightAllowed() && !entity.isNoGravity() && this.noBlocksAround(entity); -@@ -490,6 +718,7 @@ +@@ -492,6 +720,7 @@ } this.awaitingPositionFromClient = null; @@ -329,7 +329,7 @@ } } -@@ -497,7 +726,7 @@ +@@ -499,7 +728,7 @@ @Override public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.getLevel()); @@ -338,7 +338,7 @@ RecipeBookServer recipebookserver = this.player.getRecipeBook(); Objects.requireNonNull(recipebookserver); -@@ -527,6 +756,12 @@ +@@ -529,6 +758,12 @@ @Override public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.getLevel()); @@ -351,7 +351,7 @@ StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand()); if (stringreader.canRead() && stringreader.peek() == '/') { -@@ -536,6 +771,7 @@ +@@ -538,6 +773,7 @@ ParseResults parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { @@ -359,7 +359,7 @@ this.connection.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions)); }); } -@@ -785,6 +1021,13 @@ +@@ -787,6 +1023,13 @@ if (container instanceof ContainerMerchant) { ContainerMerchant containermerchant = (ContainerMerchant) container; @@ -373,7 +373,7 @@ if (!containermerchant.stillValid(this.player)) { PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant); -@@ -799,6 +1042,13 @@ +@@ -801,6 +1044,13 @@ @Override public void handleEditBook(PacketPlayInBEdit packetplayinbedit) { @@ -387,7 +387,7 @@ int i = packetplayinbedit.getSlot(); if (PlayerInventory.isHotbarSlot(i) || i == 40) { -@@ -807,7 +1057,7 @@ +@@ -809,7 +1059,7 @@ Objects.requireNonNull(list); optional.ifPresent(list::add); @@ -396,7 +396,7 @@ Objects.requireNonNull(list); stream.forEach(list::add); -@@ -825,7 +1075,7 @@ +@@ -827,7 +1077,7 @@ ItemStack itemstack = this.player.getInventory().getItem(i); if (itemstack.is(Items.WRITABLE_BOOK)) { @@ -405,7 +405,7 @@ } } -@@ -850,16 +1100,16 @@ +@@ -852,16 +1102,16 @@ this.updateBookPages(list, (s) -> { return IChatBaseComponent.ChatSerializer.toJson(IChatBaseComponent.literal(s)); @@ -426,7 +426,7 @@ return NBTTagString.valueOf((String) unaryoperator.apply(filteredtext.filteredOrEmpty())); }); -@@ -885,6 +1135,7 @@ +@@ -887,6 +1137,7 @@ } itemstack.addTagElement("pages", nbttaglist); @@ -434,7 +434,7 @@ } @Override -@@ -921,7 +1172,7 @@ +@@ -923,7 +1174,7 @@ } else { WorldServer worldserver = this.player.getLevel(); @@ -443,7 +443,7 @@ if (this.tickCount == 0) { this.resetPosition(); } -@@ -931,7 +1182,7 @@ +@@ -933,7 +1184,7 @@ this.awaitingTeleportTime = this.tickCount; this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); } @@ -452,7 +452,7 @@ } else { this.awaitingTeleportTime = this.tickCount; double d0 = clampHorizontal(packetplayinflying.getX(this.player.getX())); -@@ -943,7 +1194,15 @@ +@@ -945,7 +1196,15 @@ if (this.player.isPassenger()) { this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); this.player.getLevel().getChunkSource().move(this.player); @@ -468,7 +468,7 @@ double d3 = this.player.getX(); double d4 = this.player.getY(); double d5 = this.player.getZ(); -@@ -963,15 +1222,33 @@ +@@ -965,15 +1224,33 @@ ++this.receivedMovePacketCount; int i = this.receivedMovePacketCount - this.knownMovePacketCount; @@ -504,7 +504,7 @@ PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d7, d8, d9}); this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot()); return; -@@ -992,6 +1269,7 @@ +@@ -994,6 +1271,7 @@ boolean flag1 = this.player.verticalCollisionBelow; this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9)); @@ -512,12 +512,12 @@ double d12 = d8; d7 = d0 - this.player.getX(); -@@ -1011,9 +1289,72 @@ +@@ -1013,9 +1291,72 @@ this.player.absMoveTo(d0, d1, d2, f, f1); if (!this.player.noPhysics && !this.player.isSleeping() && (flag2 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb))) { - this.teleport(d3, d4, d5, f, f1); -+ this.internalTeleport(d3, d4, d5, f, f1, Collections.emptySet(), false); // CraftBukkit - SPIGOT-1807: Don't call teleport event, when the client thinks the player is falling, because the chunks are not loaded on the client yet. ++ this.internalTeleport(d3, d4, d5, f, f1, Collections.emptySet()); // CraftBukkit - SPIGOT-1807: Don't call teleport event, when the client thinks the player is falling, because the chunks are not loaded on the client yet. this.player.doCheckFallDamage(this.player.getY() - d6, packetplayinflying.isOnGround()); } else { + // CraftBukkit start - fire PlayerMoveEvent @@ -586,40 +586,25 @@ this.clientIsFloating = d12 >= -0.03125D && !flag1 && this.player.gameMode.getGameModeForPlayer() != EnumGamemode.SPECTATOR && !this.server.isFlightAllowed() && !this.player.getAbilities().mayfly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isFallFlying() && !this.player.isAutoSpinAttack() && this.noBlocksAround(this.player); this.player.getLevel().getChunkSource().move(this.player); this.player.doCheckFallDamage(this.player.getY() - d6, packetplayinflying.isOnGround()); -@@ -1052,19 +1393,80 @@ +@@ -1054,11 +1395,68 @@ return true; } + // CraftBukkit start - Delegate to teleport(Location) - public void dismount(double d0, double d1, double d2, float f, float f1) { -- this.teleport(d0, d1, d2, f, f1, Collections.emptySet(), true); -+ this.dismount(d0, d1, d2, f, f1, PlayerTeleportEvent.TeleportCause.DISMOUNT); -+ } -+ -+ public void dismount(double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) { -+ this.teleport(d0, d1, d2, f, f1, Collections.emptySet(), true, cause); - } - public void teleport(double d0, double d1, double d2, float f, float f1) { -- this.teleport(d0, d1, d2, f, f1, Collections.emptySet(), false); +- this.teleport(d0, d1, d2, f, f1, Collections.emptySet()); + this.teleport(d0, d1, d2, f, f1, PlayerTeleportEvent.TeleportCause.UNKNOWN); + } + + public void teleport(double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) { -+ this.teleport(d0, d1, d2, f, f1, Collections.emptySet(), false, cause); ++ this.teleport(d0, d1, d2, f, f1, Collections.emptySet(), cause); } - public void teleport(double d0, double d1, double d2, float f, float f1, Set set) { -- this.teleport(d0, d1, d2, f, f1, set, false); + public void teleport(double d0, double d1, double d2, float f, float f1, Set set) { + this.teleport(d0, d1, d2, f, f1, set, PlayerTeleportEvent.TeleportCause.UNKNOWN); + } + -+ public void teleport(double d0, double d1, double d2, float f, float f1, Set set, PlayerTeleportEvent.TeleportCause cause) { -+ this.teleport(d0, d1, d2, f, f1, set, false, cause); - } - -- public void teleport(double d0, double d1, double d2, float f, float f1, Set set, boolean flag) { -+ public boolean teleport(double d0, double d1, double d2, float f, float f1, Set set, boolean flag, PlayerTeleportEvent.TeleportCause cause) { // CraftBukkit - Return event status ++ public boolean teleport(double d0, double d1, double d2, float f, float f1, Set set, PlayerTeleportEvent.TeleportCause cause) { // CraftBukkit - Return event status + Player player = this.getCraftPlayer(); + Location from = player.getLocation(); + @@ -632,7 +617,7 @@ + Location to = new Location(this.getCraftPlayer().getWorld(), x, y, z, yaw, pitch); + // SPIGOT-5171: Triggered on join + if (from.equals(to)) { -+ this.internalTeleport(d0, d1, d2, f, f1, set, flag); ++ this.internalTeleport(d0, d1, d2, f, f1, set); + return false; // CraftBukkit - Return event status + } + @@ -649,15 +634,15 @@ + f1 = to.getPitch(); + } + -+ this.internalTeleport(d0, d1, d2, f, f1, set, flag); ++ this.internalTeleport(d0, d1, d2, f, f1, set); + 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(), true); ++ internalTeleport(dest.getX(), dest.getY(), dest.getZ(), dest.getYaw(), dest.getPitch(), Collections.emptySet()); + } + -+ private void internalTeleport(double d0, double d1, double d2, float f, float f1, Set set, boolean flag) { ++ private void internalTeleport(double d0, double d1, double d2, float f, float f1, Set set) { + // CraftBukkit start + if (Float.isNaN(f)) { + f = 0; @@ -668,10 +653,10 @@ + + this.justTeleported = true; + // CraftBukkit end - double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.getX() : 0.0D; - double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.getY() : 0.0D; - double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.getZ() : 0.0D; -@@ -1076,6 +1478,14 @@ + double d3 = set.contains(RelativeMovement.X) ? this.player.getX() : 0.0D; + double d4 = set.contains(RelativeMovement.Y) ? this.player.getY() : 0.0D; + double d5 = set.contains(RelativeMovement.Z) ? this.player.getZ() : 0.0D; +@@ -1070,6 +1468,14 @@ this.awaitingTeleport = 0; } @@ -685,8 +670,8 @@ + this.awaitingTeleportTime = this.tickCount; this.player.absMoveTo(d0, d1, d2, f, f1); - this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag)); -@@ -1084,6 +1494,7 @@ + this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport)); +@@ -1078,6 +1484,7 @@ @Override public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.getLevel()); @@ -694,7 +679,7 @@ BlockPosition blockposition = packetplayinblockdig.getPos(); this.player.resetLastActionTime(); -@@ -1094,14 +1505,46 @@ +@@ -1088,14 +1495,46 @@ if (!this.player.isSpectator()) { ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND); @@ -743,7 +728,7 @@ this.player.drop(false); } -@@ -1139,6 +1582,7 @@ +@@ -1133,6 +1572,7 @@ @Override public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.getLevel()); @@ -751,7 +736,7 @@ this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence()); WorldServer worldserver = this.player.getLevel(); EnumHand enumhand = packetplayinuseitem.getHand(); -@@ -1162,6 +1606,7 @@ +@@ -1156,6 +1596,7 @@ if (blockposition.getY() < i) { if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) { @@ -759,7 +744,7 @@ EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); if (enumdirection == EnumDirection.UP && !enuminteractionresult.consumesAction() && blockposition.getY() >= i - 1 && wasBlockPlacementAttempt(this.player, itemstack)) { -@@ -1190,6 +1635,7 @@ +@@ -1184,6 +1625,7 @@ @Override public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.getLevel()); @@ -767,7 +752,7 @@ this.ackBlockChangesUpTo(packetplayinblockplace.getSequence()); WorldServer worldserver = this.player.getLevel(); EnumHand enumhand = packetplayinblockplace.getHand(); -@@ -1197,6 +1643,49 @@ +@@ -1191,6 +1633,49 @@ this.player.resetLastActionTime(); if (!itemstack.isEmpty() && itemstack.isItemEnabled(worldserver.enabledFeatures())) { @@ -817,7 +802,7 @@ EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand); if (enuminteractionresult.shouldSwing()) { -@@ -1217,7 +1706,7 @@ +@@ -1211,7 +1696,7 @@ Entity entity = packetplayinspectate.getEntity(worldserver); if (entity != null) { @@ -826,7 +811,7 @@ return; } } -@@ -1232,6 +1721,7 @@ +@@ -1226,6 +1711,7 @@ PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName()); this.disconnect(IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect")); } @@ -834,7 +819,7 @@ } -@@ -1251,12 +1741,27 @@ +@@ -1247,12 +1733,27 @@ @Override public void onDisconnect(IChatBaseComponent ichatbasecomponent) { @@ -863,7 +848,7 @@ this.player.getTextFilter().leave(); if (this.isSingleplayerOwner()) { PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out"); -@@ -1279,6 +1784,15 @@ +@@ -1275,6 +1776,15 @@ } public void send(Packet packet, @Nullable PacketSendListener packetsendlistener) { @@ -879,7 +864,7 @@ try { this.connection.send(packet, packetsendlistener); } catch (Throwable throwable) { -@@ -1295,7 +1809,16 @@ +@@ -1291,7 +1801,16 @@ @Override public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.getLevel()); @@ -896,7 +881,7 @@ if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) { this.player.stopUsingItem(); } -@@ -1304,18 +1827,25 @@ +@@ -1300,18 +1819,25 @@ this.player.resetLastActionTime(); } else { PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString()); @@ -923,7 +908,7 @@ PlayerChatMessage playerchatmessage; try { -@@ -1333,9 +1863,9 @@ +@@ -1329,9 +1855,9 @@ PlayerChatMessage playerchatmessage1 = playerchatmessage.withUnsignedContent((IChatBaseComponent) completablefuture1.join()).filter(((FilteredText) completablefuture.join()).mask()); this.broadcastChatMessage(playerchatmessage1); @@ -935,7 +920,7 @@ } } -@@ -1359,12 +1889,25 @@ +@@ -1355,12 +1881,25 @@ } private void performChatCommand(ServerboundChatCommandPacket serverboundchatcommandpacket, LastSeenMessages lastseenmessages) { @@ -963,7 +948,7 @@ } catch (SignedMessageChain.a signedmessagechain_a) { this.handleMessageDecodeFailure(signedmessagechain_a); return; -@@ -1372,10 +1915,10 @@ +@@ -1368,10 +1907,10 @@ CommandSigningContext.a commandsigningcontext_a = new CommandSigningContext.a(map); @@ -976,16 +961,16 @@ } private void handleMessageDecodeFailure(SignedMessageChain.a signedmessagechain_a) { -@@ -1413,7 +1956,7 @@ - PlayerConnection.LOGGER.warn("{} sent out-of-order chat: '{}'", this.player.getName().getString(), s); - this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.out_of_order_chat")); - return Optional.empty(); -- } else if (this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { -+ } else if (this.player.isRemoved() || this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales - this.send(new ClientboundSystemChatPacket(IChatBaseComponent.translatable("chat.disabled.options").withStyle(EnumChatFormat.RED), false)); - return Optional.empty(); +@@ -1412,7 +1951,7 @@ } else { -@@ -1462,6 +2005,122 @@ + Optional optional = this.unpackAndApplyLastSeen(lastseenmessages_b); + +- if (this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { ++ if (this.player.isRemoved() || this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales + this.send(new ClientboundSystemChatPacket(IChatBaseComponent.translatable("chat.disabled.options").withStyle(EnumChatFormat.RED), false)); + return Optional.empty(); + } else { +@@ -1460,6 +1999,122 @@ return false; } @@ -1108,7 +1093,7 @@ private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a { SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages); -@@ -1469,13 +2128,33 @@ +@@ -1467,13 +2122,33 @@ } private void broadcastChatMessage(PlayerChatMessage playerchatmessage) { @@ -1145,7 +1130,7 @@ this.disconnect(IChatBaseComponent.translatable("disconnect.spam")); } -@@ -1497,13 +2176,59 @@ +@@ -1495,13 +2170,59 @@ @Override public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.getLevel()); @@ -1203,9 +1188,9 @@ + } + // CraftBukkit end this.player.resetLastActionTime(); + Entity entity; IJumpable ijumpable; - -@@ -1583,6 +2308,12 @@ +@@ -1583,6 +2304,12 @@ } public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) { @@ -1218,7 +1203,7 @@ this.send(new ClientboundPlayerChatPacket(playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a.toNetwork(this.player.level.registryAccess()))); this.addPendingMessage(playerchatmessage); } -@@ -1594,6 +2325,7 @@ +@@ -1598,6 +2325,7 @@ @Override public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.getLevel()); @@ -1226,9 +1211,9 @@ final WorldServer worldserver = this.player.getLevel(); final Entity entity = packetplayinuseentity.getTarget(worldserver); -@@ -1606,13 +2338,51 @@ +@@ -1612,13 +2340,51 @@ - if (entity.distanceToSqr(this.player.getEyePosition()) < PlayerConnection.MAX_INTERACTION_DISTANCE) { + if (axisalignedbb.distanceToSqr(this.player.getEyePosition()) < PlayerConnection.MAX_INTERACTION_DISTANCE) { packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() { - private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a) { + private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit @@ -1279,7 +1264,7 @@ if (enuminteractionresult.consumesAction()) { CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack1, entity); if (enuminteractionresult.shouldSwing()) { -@@ -1625,23 +2395,29 @@ +@@ -1631,23 +2397,29 @@ @Override public void onInteraction(EnumHand enumhand) { @@ -1312,7 +1297,7 @@ } } else { PlayerConnection.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.invalid_entity_attacked")); -@@ -1687,15 +2463,21 @@ +@@ -1693,15 +2465,21 @@ @Override public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.getLevel()); @@ -1336,7 +1321,7 @@ this.player.containerMenu.sendAllDataToRemote(); } else if (!this.player.containerMenu.stillValid(this.player)) { PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); -@@ -1708,7 +2490,284 @@ +@@ -1714,7 +2492,284 @@ boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); @@ -1622,7 +1607,7 @@ ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator(); while (objectiterator.hasNext()) { -@@ -1748,6 +2807,7 @@ +@@ -1754,6 +2809,7 @@ @Override public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.getLevel()); @@ -1630,7 +1615,7 @@ this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) { if (!this.player.containerMenu.stillValid(this.player)) { -@@ -1790,6 +2850,43 @@ +@@ -1796,6 +2852,43 @@ boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45; boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); @@ -1673,8 +1658,8 @@ + // CraftBukkit end if (flag1 && flag2) { - this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).set(itemstack); -@@ -1812,6 +2909,7 @@ + this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).setByPlayer(itemstack); +@@ -1818,6 +2911,7 @@ } private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List list) { @@ -1682,7 +1667,7 @@ this.player.resetLastActionTime(); WorldServer worldserver = this.player.getLevel(); BlockPosition blockposition = packetplayinupdatesign.getPos(); -@@ -1828,18 +2926,37 @@ +@@ -1834,18 +2928,37 @@ if (!tileentitysign.isEditable() || !this.player.getUUID().equals(tileentitysign.getPlayerWhoMayEdit())) { PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getName().getString()); @@ -1722,7 +1707,7 @@ tileentitysign.setChanged(); worldserver.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3); -@@ -1849,6 +2966,7 @@ +@@ -1855,6 +2968,7 @@ @Override public void handleKeepAlive(PacketPlayInKeepAlive packetplayinkeepalive) { @@ -1730,7 +1715,7 @@ if (this.keepAlivePending && packetplayinkeepalive.getId() == this.keepAliveChallenge) { int i = (int) (SystemUtils.getMillis() - this.keepAliveTime); -@@ -1863,7 +2981,17 @@ +@@ -1869,7 +2983,17 @@ @Override public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.getLevel()); @@ -1749,7 +1734,7 @@ } @Override -@@ -1872,8 +3000,50 @@ +@@ -1878,8 +3002,50 @@ this.player.updateOptions(packetplayinsettings); } diff --git a/paper-server/nms-patches/net/minecraft/server/network/ServerConnection.patch b/paper-server/nms-patches/net/minecraft/server/network/ServerConnection.patch index 25d5c733bc..43d0944a71 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/ServerConnection.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/ServerConnection.patch @@ -1,12 +1,14 @@ --- a/net/minecraft/server/network/ServerConnection.java +++ b/net/minecraft/server/network/ServerConnection.java -@@ -98,14 +98,24 @@ - int j = ServerConnection.this.server.getRateLimitPacketsPerSecond(); - Object object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND); +@@ -95,16 +95,26 @@ -- ServerConnection.this.connections.add(object); -+ ServerConnection.this.connections.add((NetworkManager) object); // CraftBukkit - decompile error - channel.pipeline().addLast("packet_handler", (ChannelHandler) object); + NetworkManager.configureSerialization(channelpipeline, EnumProtocolDirection.SERVERBOUND); + int j = ServerConnection.this.server.getRateLimitPacketsPerSecond(); +- Object object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND); ++ NetworkManager object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND); // CraftBukkit - decompile error + + ServerConnection.this.connections.add(object); + channelpipeline.addLast("packet_handler", (ChannelHandler) object); ((NetworkManager) object).setListener(new HandshakeListener(ServerConnection.this.server, (NetworkManager) object)); } - }).group((EventLoopGroup) lazyinitvar.get()).localAddress(inetaddress, i)).bind().syncUninterruptibly()); diff --git a/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch b/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch index 05abde4403..fa1eb26777 100644 --- a/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch +++ b/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -107,6 +107,25 @@ +@@ -108,6 +108,25 @@ import net.minecraft.world.scores.ScoreboardTeamBase; import org.slf4j.Logger; @@ -26,7 +26,7 @@ public abstract class PlayerList { public static final File USERBANLIST_FILE = new File("banned-players.json"); -@@ -118,14 +137,16 @@ +@@ -119,14 +138,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; @@ -46,7 +46,7 @@ public final WorldNBTStorage playerIo; private boolean doWhiteList; private final LayeredRegistryAccess registries; -@@ -137,13 +158,23 @@ +@@ -138,13 +159,23 @@ private static final boolean ALLOW_LOGOUTIVATOR = false; private int sendAllPlayerInfoIn; @@ -72,7 +72,7 @@ this.server = minecraftserver; this.registries = layeredregistryaccess; this.synchronizedRegistries = (new IRegistryCustom.c(RegistrySynchronization.networkedRegistries(layeredregistryaccess))).freeze(); -@@ -160,9 +191,15 @@ +@@ -161,9 +192,15 @@ usercache.add(gameprofile); NBTTagCompound nbttagcompound = this.load(entityplayer); ResourceKey resourcekey; @@ -89,7 +89,7 @@ Logger logger = PlayerList.LOGGER; Objects.requireNonNull(logger); -@@ -189,7 +226,8 @@ +@@ -190,7 +227,8 @@ s1 = networkmanager.getRemoteAddress().toString(); } @@ -99,7 +99,7 @@ WorldData worlddata = worldserver1.getLevelData(); entityplayer.loadGameTypes(nbttagcompound); -@@ -199,6 +237,7 @@ +@@ -200,6 +238,7 @@ boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO); playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), entityplayer.gameMode.getGameModeForPlayer(), entityplayer.gameMode.getPreviousGameModeForPlayer(), this.server.levelKeys(), this.synchronizedRegistries, worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, worldserver1.isDebug(), worldserver1.isFlat(), entityplayer.getLastDeathLocation())); @@ -107,7 +107,7 @@ playerconnection.send(new ClientboundUpdateEnabledFeaturesPacket(FeatureFlags.REGISTRY.toNames(worldserver1.enabledFeatures()))); playerconnection.send(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.BRAND, (new PacketDataSerializer(Unpooled.buffer())).writeUtf(this.getServer().getServerModName()))); playerconnection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); -@@ -218,16 +257,68 @@ +@@ -219,8 +258,10 @@ } else { ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.player.joined.renamed", entityplayer.getDisplayName(), s); } @@ -117,13 +117,13 @@ - this.broadcastSystemMessage(ichatmutablecomponent.withStyle(EnumChatFormat.YELLOW), false); playerconnection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot()); - entityplayer.sendServerStatus(this.server.getStatus()); + ServerPing serverping = this.server.getStatus(); + +@@ -231,10 +272,61 @@ entityplayer.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(this.players)); this.players.add(entityplayer); this.playersByUUID.put(entityplayer.getUUID(), entityplayer); - this.broadcastAll(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityplayer))); -- worldserver1.addNewPlayer(entityplayer); -- this.server.getCustomBossEvents().onPlayerConnect(entityplayer); + // this.broadcastAll(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityplayer))); // CraftBukkit - replaced with loop below + + // CraftBukkit start @@ -135,7 +135,7 @@ + PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(bukkitPlayer, joinMessage); + cserver.getPluginManager().callEvent(playerJoinEvent); + -+ if (!entityplayer.connection.connection.isConnected()) { ++ if (!entityplayer.connection.isAcceptingMessages()) { + return; + } + @@ -168,6 +168,10 @@ + // CraftBukkit end + + entityplayer.getEntityData().refresh(entityplayer); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn ++ + this.sendLevelInfo(entityplayer, worldserver1); +- worldserver1.addNewPlayer(entityplayer); +- this.server.getCustomBossEvents().onPlayerConnect(entityplayer); + + // CraftBukkit start - Only add if the player wasn't moved in the event + if (entityplayer.level == worldserver1 && !worldserver1.players().contains(entityplayer)) { @@ -177,10 +181,10 @@ + + worldserver1 = entityplayer.getLevel(); // CraftBukkit - Update in case join event changed it + // CraftBukkit end - this.sendLevelInfo(entityplayer, worldserver1); this.server.getServerResourcePack().ifPresent((minecraftserver_serverresourcepackinfo) -> { entityplayer.sendTexturePack(minecraftserver_serverresourcepackinfo.url(), minecraftserver_serverresourcepackinfo.hash(), minecraftserver_serverresourcepackinfo.isRequired(), minecraftserver_serverresourcepackinfo.prompt()); -@@ -242,8 +333,11 @@ + }); +@@ -248,8 +340,11 @@ if (nbttagcompound != null && nbttagcompound.contains("RootVehicle", 10)) { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle"); @@ -194,7 +198,7 @@ }); if (entity != null) { -@@ -286,6 +380,8 @@ +@@ -292,6 +387,8 @@ } entityplayer.initInventoryMenu(); @@ -203,7 +207,7 @@ } public void updateEntireScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { -@@ -318,30 +414,31 @@ +@@ -324,30 +421,31 @@ } public void addWorldborderListener(WorldServer worldserver) { @@ -240,7 +244,7 @@ } @Override -@@ -369,14 +466,15 @@ +@@ -375,14 +473,15 @@ } protected void save(EntityPlayer entityplayer) { @@ -258,7 +262,7 @@ if (advancementdataplayer != null) { advancementdataplayer.save(); -@@ -384,10 +482,24 @@ +@@ -390,10 +489,24 @@ } @@ -284,7 +288,7 @@ this.save(entityplayer); if (entityplayer.isPassenger()) { Entity entity = entityplayer.getRootVehicle(); -@@ -411,18 +523,66 @@ +@@ -417,18 +530,66 @@ if (entityplayer1 == entityplayer) { this.playersByUUID.remove(uuid); @@ -357,7 +361,7 @@ GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile); ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason()); -@@ -430,10 +590,12 @@ +@@ -436,10 +597,12 @@ ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires()))); } @@ -373,7 +377,7 @@ IpBanEntry ipbanentry = this.ipBans.get(socketaddress); ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.reason", ipbanentry.getReason()); -@@ -441,13 +603,25 @@ +@@ -447,13 +610,25 @@ ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires()))); } @@ -402,7 +406,7 @@ UUID uuid = UUIDUtil.getOrCreatePlayerUUID(gameprofile); List list = Lists.newArrayList(); -@@ -474,14 +648,24 @@ +@@ -480,14 +655,24 @@ } return new EntityPlayer(this.server, this.server.overworld(), gameprofile); @@ -427,7 +431,7 @@ WorldServer worldserver = this.server.getLevel(entityplayer.getRespawnDimension()); Optional optional; -@@ -493,6 +677,11 @@ +@@ -499,6 +684,11 @@ WorldServer worldserver1 = worldserver != null && optional.isPresent() ? worldserver : this.server.overworld(); EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getGameProfile()); @@ -439,7 +443,7 @@ entityplayer1.connection = entityplayer.connection; entityplayer1.restoreFrom(entityplayer, flag); -@@ -508,50 +697,112 @@ +@@ -514,50 +704,112 @@ boolean flag2 = false; @@ -464,8 +468,7 @@ + } else { + optional = Optional.empty(); + } - -- f1 = (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); ++ + if (optional.isPresent()) { + IBlockData iblockdata = worldserver1.getBlockState(blockposition); + boolean flag3 = iblockdata.is(Blocks.RESPAWN_ANCHOR); @@ -489,7 +492,8 @@ + entityplayer1.setRespawnPosition(null, null, 0f, false, false); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed + } + } -+ + +- f1 = (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); + if (location == null) { + worldserver1 = this.server.getLevel(World.OVERWORLD); + blockposition = entityplayer1.getSpawnPoint(worldserver1); @@ -560,13 +564,13 @@ + + // Fire advancement trigger + entityplayer.triggerDimensionChangeTriggers(((CraftWorld) fromWorld).getHandle()); -+ + + // Don't fire on respawn + if (fromWorld != location.getWorld()) { + PlayerChangedWorldEvent event = new PlayerChangedWorldEvent(entityplayer.getBukkitEntity(), fromWorld); + server.server.getPluginManager().callEvent(event); + } - ++ + // Save player file again if they were disconnected + if (entityplayer.connection.isDisconnected()) { + this.save(entityplayer); @@ -575,7 +579,7 @@ return entityplayer1; } -@@ -564,7 +815,18 @@ +@@ -570,7 +822,18 @@ public void tick() { if (++this.sendAllPlayerInfoIn > 600) { @@ -595,7 +599,7 @@ this.sendAllPlayerInfoIn = 0; } -@@ -581,6 +843,25 @@ +@@ -587,6 +850,25 @@ } @@ -621,7 +625,7 @@ public void broadcastAll(Packet packet, ResourceKey resourcekey) { Iterator iterator = this.players.iterator(); -@@ -659,7 +940,7 @@ +@@ -665,7 +947,7 @@ } public void deop(GameProfile gameprofile) { @@ -630,7 +634,7 @@ EntityPlayer entityplayer = this.getPlayer(gameprofile.getId()); if (entityplayer != null) { -@@ -683,6 +964,7 @@ +@@ -689,6 +971,7 @@ entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0)); } @@ -638,7 +642,7 @@ this.server.getCommands().sendCommands(entityplayer); } -@@ -715,6 +997,12 @@ +@@ -721,6 +1004,12 @@ for (int i = 0; i < this.players.size(); ++i) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(i); @@ -651,7 +655,7 @@ if (entityplayer != entityhuman && entityplayer.level.dimension() == resourcekey) { double d4 = d0 - entityplayer.getX(); double d5 = d1 - entityplayer.getY(); -@@ -754,23 +1042,35 @@ +@@ -760,23 +1049,35 @@ public void reloadWhiteList() {} public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) { @@ -692,7 +696,7 @@ } public int getPlayerCount() { -@@ -826,12 +1126,22 @@ +@@ -832,12 +1133,22 @@ } public void removeAll() { @@ -717,7 +721,7 @@ public void broadcastSystemMessage(IChatBaseComponent ichatbasecomponent, boolean flag) { this.broadcastSystemMessage(ichatbasecomponent, (entityplayer) -> { return ichatbasecomponent; -@@ -889,16 +1199,23 @@ +@@ -895,16 +1206,23 @@ return playerchatmessage.hasSignature() && !playerchatmessage.hasExpiredServer(Instant.now()); } @@ -745,7 +749,7 @@ Path path = file2.toPath(); if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) { -@@ -907,7 +1224,7 @@ +@@ -913,7 +1231,7 @@ } serverstatisticmanager = new ServerStatisticManager(this.server, file1); @@ -754,7 +758,7 @@ } return serverstatisticmanager; -@@ -915,14 +1232,14 @@ +@@ -921,13 +1239,13 @@ public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) { UUID uuid = entityplayer.getUUID(); @@ -762,16 +766,15 @@ + AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancements(); // CraftBukkit if (advancementdataplayer == null) { - File file = this.server.getWorldPath(SavedFile.PLAYER_ADVANCEMENTS_DIR).toFile(); - File file1 = new File(file, uuid + ".json"); + Path path = this.server.getWorldPath(SavedFile.PLAYER_ADVANCEMENTS_DIR).resolve(uuid + ".json"); - advancementdataplayer = new AdvancementDataPlayer(this.server.getFixerUpper(), this, this.server.getAdvancements(), file1, entityplayer); + advancementdataplayer = new AdvancementDataPlayer(this.server.getFixerUpper(), this, this.server.getAdvancements(), path, entityplayer); - this.advancements.put(uuid, advancementdataplayer); + // this.advancements.put(uuid, advancementdataplayer); // CraftBukkit } advancementdataplayer.setPlayer(entityplayer); -@@ -973,13 +1290,20 @@ +@@ -978,13 +1296,20 @@ } public void reloadResources() { diff --git a/paper-server/nms-patches/net/minecraft/stats/ServerStatisticManager.patch b/paper-server/nms-patches/net/minecraft/stats/ServerStatisticManager.patch index 81bf5fa5a9..ac3c4fffdf 100644 --- a/paper-server/nms-patches/net/minecraft/stats/ServerStatisticManager.patch +++ b/paper-server/nms-patches/net/minecraft/stats/ServerStatisticManager.patch @@ -5,7 +5,7 @@ package net.minecraft.stats; import com.google.common.collect.Maps; -@@ -162,13 +163,12 @@ +@@ -158,13 +159,12 @@ } private Optional> getStat(StatisticWrapper statisticwrapper, String s) { diff --git a/paper-server/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch b/paper-server/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch index 042c4ebd22..8e4b61026e 100644 --- a/paper-server/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch +++ b/paper-server/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/util/datafix/DataConverterRegistry.java +++ b/net/minecraft/util/datafix/DataConverterRegistry.java -@@ -444,6 +444,18 @@ - datafixerbuilder.addFixer(new DataConverterItemFrame(schema46, false)); - Schema schema47 = datafixerbuilder.addSchema(1458, DataConverterRegistry.SAME_NAMESPACED); +@@ -434,6 +434,18 @@ + datafixerbuilder.addFixer(new DataConverterItemFrame(schema44, false)); + Schema schema45 = datafixerbuilder.addSchema(1458, DataConverterRegistry.SAME_NAMESPACED); + // CraftBukkit start -+ datafixerbuilder.addFixer(new com.mojang.datafixers.DataFix(schema47, false) { ++ datafixerbuilder.addFixer(new com.mojang.datafixers.DataFix(schema45, false) { + @Override + protected com.mojang.datafixers.TypeRewriteRule makeRule() { + return this.fixTypeEverywhereTyped("Player CustomName", this.getInputSchema().getType(DataConverterTypes.PLAYER), (typed) -> { @@ -16,57 +16,57 @@ + } + }); + // CraftBukkit end - datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema47, false)); - datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema47, false)); - datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema47, false)); -@@ -761,12 +773,14 @@ - datafixerbuilder.addFixer(new DataConverterAddChoices(schema131, "Added Glow Squid", DataConverterTypes.ENTITY)); - datafixerbuilder.addFixer(new DataConverterAddChoices(schema131, "Added Glow Item Frame", DataConverterTypes.ENTITY)); - Schema schema132 = datafixerbuilder.addSchema(2690, DataConverterRegistry.SAME_NAMESPACED); + datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema45, false)); + datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema45, false)); + datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema45, false)); +@@ -751,12 +763,14 @@ + datafixerbuilder.addFixer(new DataConverterAddChoices(schema129, "Added Glow Squid", DataConverterTypes.ENTITY)); + datafixerbuilder.addFixer(new DataConverterAddChoices(schema129, "Added Glow Item Frame", DataConverterTypes.ENTITY)); + Schema schema130 = datafixerbuilder.addSchema(2690, DataConverterRegistry.SAME_NAMESPACED); - ImmutableMap immutablemap = ImmutableMap.builder().put("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block").put("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block").put("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block").put("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper").put("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper").put("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper").put("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs").put("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs").put("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs").put("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab").put("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab").put("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab").put("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper").put("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper").put("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper").put("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper").put("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs").put("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs").put("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab").put("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab").build(); + // CraftBukkit - decompile error + ImmutableMap immutablemap = ImmutableMap.builder().put("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block").put("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block").put("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block").put("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper").put("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper").put("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper").put("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs").put("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs").put("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs").put("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab").put("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab").put("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab").put("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper").put("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper").put("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper").put("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper").put("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs").put("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs").put("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab").put("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab").build(); - datafixerbuilder.addFixer(DataConverterItemName.create(schema132, "Renamed copper block items to new oxidized terms", createRenamer(immutablemap))); - datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema132, "Renamed copper blocks to new oxidized terms", createRenamer(immutablemap))); - Schema schema133 = datafixerbuilder.addSchema(2691, DataConverterRegistry.SAME_NAMESPACED); + datafixerbuilder.addFixer(DataConverterItemName.create(schema130, "Renamed copper block items to new oxidized terms", createRenamer(immutablemap))); + datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema130, "Renamed copper blocks to new oxidized terms", createRenamer(immutablemap))); + Schema schema131 = datafixerbuilder.addSchema(2691, DataConverterRegistry.SAME_NAMESPACED); - ImmutableMap immutablemap1 = ImmutableMap.builder().put("minecraft:waxed_copper", "minecraft:waxed_copper_block").put("minecraft:oxidized_copper_block", "minecraft:oxidized_copper").put("minecraft:weathered_copper_block", "minecraft:weathered_copper").put("minecraft:exposed_copper_block", "minecraft:exposed_copper").build(); + // CraftBukkit - decompile error + ImmutableMap immutablemap1 = ImmutableMap.builder().put("minecraft:waxed_copper", "minecraft:waxed_copper_block").put("minecraft:oxidized_copper_block", "minecraft:oxidized_copper").put("minecraft:weathered_copper_block", "minecraft:weathered_copper").put("minecraft:exposed_copper_block", "minecraft:exposed_copper").build(); - datafixerbuilder.addFixer(DataConverterItemName.create(schema133, "Rename copper item suffixes", createRenamer(immutablemap1))); - datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema133, "Rename copper blocks suffixes", createRenamer(immutablemap1))); -@@ -774,7 +788,8 @@ + datafixerbuilder.addFixer(DataConverterItemName.create(schema131, "Rename copper item suffixes", createRenamer(immutablemap1))); + datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema131, "Rename copper blocks suffixes", createRenamer(immutablemap1))); +@@ -764,7 +778,8 @@ - datafixerbuilder.addFixer(new AddFlagIfNotPresentFix(schema134, DataConverterTypes.WORLD_GEN_SETTINGS, "has_increased_height_already", false)); - Schema schema135 = datafixerbuilder.addSchema(2696, DataConverterRegistry.SAME_NAMESPACED); + datafixerbuilder.addFixer(new AddFlagIfNotPresentFix(schema132, DataConverterTypes.WORLD_GEN_SETTINGS, "has_increased_height_already", false)); + 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.create(schema135, "Renamed grimstone block items to deepslate", createRenamer(immutablemap2))); - datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema135, "Renamed grimstone blocks to deepslate", createRenamer(immutablemap2))); -@@ -861,10 +876,11 @@ - datafixerbuilder.addFixer(new DataConverterAddChoices(schema160, "Added Allay", DataConverterTypes.ENTITY)); - Schema schema161 = datafixerbuilder.addSchema(3084, DataConverterRegistry.SAME_NAMESPACED); + datafixerbuilder.addFixer(DataConverterItemName.create(schema133, "Renamed grimstone block items to deepslate", createRenamer(immutablemap2))); + datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema133, "Renamed grimstone blocks to deepslate", createRenamer(immutablemap2))); +@@ -851,10 +866,11 @@ + datafixerbuilder.addFixer(new DataConverterAddChoices(schema158, "Added Allay", DataConverterTypes.ENTITY)); + Schema schema159 = datafixerbuilder.addSchema(3084, DataConverterRegistry.SAME_NAMESPACED); -- datafixerbuilder.addFixer(new SimpleRenameFix(schema161, DataConverterTypes.GAME_EVENT_NAME, ImmutableMap.builder().put("minecraft:block_press", "minecraft:block_activate").put("minecraft:block_switch", "minecraft:block_activate").put("minecraft:block_unpress", "minecraft:block_deactivate").put("minecraft:block_unswitch", "minecraft:block_deactivate").put("minecraft:drinking_finish", "minecraft:drink").put("minecraft:elytra_free_fall", "minecraft:elytra_glide").put("minecraft:entity_damaged", "minecraft:entity_damage").put("minecraft:entity_dying", "minecraft:entity_die").put("minecraft:entity_killed", "minecraft:entity_die").put("minecraft:mob_interact", "minecraft:entity_interact").put("minecraft:ravager_roar", "minecraft:entity_roar").put("minecraft:ring_bell", "minecraft:block_change").put("minecraft:shulker_close", "minecraft:container_close").put("minecraft:shulker_open", "minecraft:container_open").put("minecraft:wolf_shaking", "minecraft:entity_shake").build())); +- datafixerbuilder.addFixer(new SimpleRenameFix(schema159, DataConverterTypes.GAME_EVENT_NAME, ImmutableMap.builder().put("minecraft:block_press", "minecraft:block_activate").put("minecraft:block_switch", "minecraft:block_activate").put("minecraft:block_unpress", "minecraft:block_deactivate").put("minecraft:block_unswitch", "minecraft:block_deactivate").put("minecraft:drinking_finish", "minecraft:drink").put("minecraft:elytra_free_fall", "minecraft:elytra_glide").put("minecraft:entity_damaged", "minecraft:entity_damage").put("minecraft:entity_dying", "minecraft:entity_die").put("minecraft:entity_killed", "minecraft:entity_die").put("minecraft:mob_interact", "minecraft:entity_interact").put("minecraft:ravager_roar", "minecraft:entity_roar").put("minecraft:ring_bell", "minecraft:block_change").put("minecraft:shulker_close", "minecraft:container_close").put("minecraft:shulker_open", "minecraft:container_open").put("minecraft:wolf_shaking", "minecraft:entity_shake").build())); + // CraftBukkit - decompile error -+ datafixerbuilder.addFixer(new SimpleRenameFix(schema161, DataConverterTypes.GAME_EVENT_NAME, ImmutableMap.builder().put("minecraft:block_press", "minecraft:block_activate").put("minecraft:block_switch", "minecraft:block_activate").put("minecraft:block_unpress", "minecraft:block_deactivate").put("minecraft:block_unswitch", "minecraft:block_deactivate").put("minecraft:drinking_finish", "minecraft:drink").put("minecraft:elytra_free_fall", "minecraft:elytra_glide").put("minecraft:entity_damaged", "minecraft:entity_damage").put("minecraft:entity_dying", "minecraft:entity_die").put("minecraft:entity_killed", "minecraft:entity_die").put("minecraft:mob_interact", "minecraft:entity_interact").put("minecraft:ravager_roar", "minecraft:entity_roar").put("minecraft:ring_bell", "minecraft:block_change").put("minecraft:shulker_close", "minecraft:container_close").put("minecraft:shulker_open", "minecraft:container_open").put("minecraft:wolf_shaking", "minecraft:entity_shake").build())); - Schema schema162 = datafixerbuilder.addSchema(3086, DataConverterRegistry.SAME_NAMESPACED); ++ datafixerbuilder.addFixer(new SimpleRenameFix(schema159, DataConverterTypes.GAME_EVENT_NAME, ImmutableMap.builder().put("minecraft:block_press", "minecraft:block_activate").put("minecraft:block_switch", "minecraft:block_activate").put("minecraft:block_unpress", "minecraft:block_deactivate").put("minecraft:block_unswitch", "minecraft:block_deactivate").put("minecraft:drinking_finish", "minecraft:drink").put("minecraft:elytra_free_fall", "minecraft:elytra_glide").put("minecraft:entity_damaged", "minecraft:entity_damage").put("minecraft:entity_dying", "minecraft:entity_die").put("minecraft:entity_killed", "minecraft:entity_die").put("minecraft:mob_interact", "minecraft:entity_interact").put("minecraft:ravager_roar", "minecraft:entity_roar").put("minecraft:ring_bell", "minecraft:block_change").put("minecraft:shulker_close", "minecraft:container_close").put("minecraft:shulker_open", "minecraft:container_open").put("minecraft:wolf_shaking", "minecraft:entity_shake").build())); + Schema schema160 = datafixerbuilder.addSchema(3086, DataConverterRegistry.SAME_NAMESPACED); TypeReference typereference = DataConverterTypes.ENTITY; - Int2ObjectOpenHashMap int2objectopenhashmap = (Int2ObjectOpenHashMap) SystemUtils.make(new Int2ObjectOpenHashMap(), (int2objectopenhashmap1) -> { + Int2ObjectOpenHashMap int2objectopenhashmap = (Int2ObjectOpenHashMap) SystemUtils.make(new Int2ObjectOpenHashMap(), (int2objectopenhashmap1) -> { // CraftBukkit - decompile error int2objectopenhashmap1.defaultReturnValue("minecraft:tabby"); int2objectopenhashmap1.put(0, "minecraft:tabby"); int2objectopenhashmap1.put(1, "minecraft:black"); -@@ -881,7 +897,8 @@ +@@ -871,7 +887,8 @@ Objects.requireNonNull(int2objectopenhashmap); - datafixerbuilder.addFixer(new EntityVariantFix(schema162, "Change cat variant type", typereference, "minecraft:cat", "CatType", int2objectopenhashmap::get)); + datafixerbuilder.addFixer(new EntityVariantFix(schema160, "Change cat variant type", typereference, "minecraft:cat", "CatType", int2objectopenhashmap::get)); - ImmutableMap immutablemap3 = ImmutableMap.builder().put("textures/entity/cat/tabby.png", "minecraft:tabby").put("textures/entity/cat/black.png", "minecraft:black").put("textures/entity/cat/red.png", "minecraft:red").put("textures/entity/cat/siamese.png", "minecraft:siamese").put("textures/entity/cat/british_shorthair.png", "minecraft:british").put("textures/entity/cat/calico.png", "minecraft:calico").put("textures/entity/cat/persian.png", "minecraft:persian").put("textures/entity/cat/ragdoll.png", "minecraft:ragdoll").put("textures/entity/cat/white.png", "minecraft:white").put("textures/entity/cat/jellie.png", "minecraft:jellie").put("textures/entity/cat/all_black.png", "minecraft:all_black").build(); + // CraftBukkit - decompile error + ImmutableMap immutablemap3 = ImmutableMap.builder().put("textures/entity/cat/tabby.png", "minecraft:tabby").put("textures/entity/cat/black.png", "minecraft:black").put("textures/entity/cat/red.png", "minecraft:red").put("textures/entity/cat/siamese.png", "minecraft:siamese").put("textures/entity/cat/british_shorthair.png", "minecraft:british").put("textures/entity/cat/calico.png", "minecraft:calico").put("textures/entity/cat/persian.png", "minecraft:persian").put("textures/entity/cat/ragdoll.png", "minecraft:ragdoll").put("textures/entity/cat/white.png", "minecraft:white").put("textures/entity/cat/jellie.png", "minecraft:jellie").put("textures/entity/cat/all_black.png", "minecraft:all_black").build(); - datafixerbuilder.addFixer(new CriteriaRenameFix(schema162, "Migrate cat variant advancement", "minecraft:husbandry/complete_catalogue", (s) -> { + datafixerbuilder.addFixer(new CriteriaRenameFix(schema160, "Migrate cat variant advancement", "minecraft:husbandry/complete_catalogue", (s) -> { return (String) immutablemap3.getOrDefault(s, s); diff --git a/paper-server/nms-patches/net/minecraft/world/IInventory.patch b/paper-server/nms-patches/net/minecraft/world/IInventory.patch index 1f0d7f2f7b..20655e4444 100644 --- a/paper-server/nms-patches/net/minecraft/world/IInventory.patch +++ b/paper-server/nms-patches/net/minecraft/world/IInventory.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/IInventory.java +++ b/net/minecraft/world/IInventory.java -@@ -6,6 +6,11 @@ - import net.minecraft.world.item.Item; - import net.minecraft.world.item.ItemStack; +@@ -9,6 +9,11 @@ + import net.minecraft.world.level.World; + import net.minecraft.world.level.block.entity.TileEntity; +// CraftBukkit start +import net.minecraft.world.item.crafting.IRecipe; @@ -12,7 +12,7 @@ public interface IInventory extends Clearable { int LARGE_MAX_STACK_SIZE = 64; -@@ -22,9 +27,7 @@ +@@ -26,9 +31,7 @@ void setItem(int i, ItemStack itemstack); @@ -23,9 +23,9 @@ void setChanged(); -@@ -69,4 +72,29 @@ +@@ -88,4 +91,29 @@ - return false; + return world == null ? false : (world.getBlockEntity(blockposition) != tileentity ? false : entityhuman.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) <= (double) (i * i)); } + + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/world/damagesource/DamageSource.patch b/paper-server/nms-patches/net/minecraft/world/damagesource/DamageSource.patch index 2923a51f48..d05a3b1119 100644 --- a/paper-server/nms-patches/net/minecraft/world/damagesource/DamageSource.patch +++ b/paper-server/nms-patches/net/minecraft/world/damagesource/DamageSource.patch @@ -1,11 +1,13 @@ --- a/net/minecraft/world/damagesource/DamageSource.java +++ b/net/minecraft/world/damagesource/DamageSource.java -@@ -49,6 +49,18 @@ - private boolean isFall; - private boolean noAggro; - public final String msgId; +@@ -20,6 +20,38 @@ + private final Entity directEntity; + @Nullable + private final Vec3D damageSourcePosition; + // CraftBukkit start + private boolean sweep; ++ private boolean melting; ++ private boolean poison; + + public boolean isSweep() { + return sweep; @@ -15,7 +17,25 @@ + this.sweep = true; + return this; + } ++ ++ public boolean isMelting() { ++ return melting; ++ } ++ ++ public DamageSource melting() { ++ this.melting = true; ++ return this; ++ } ++ ++ public boolean isPoison() { ++ return poison; ++ } ++ ++ public DamageSource poison() { ++ this.poison = true; ++ return this; ++ } + // CraftBukkit end - public static DamageSource fallingBlock(Entity entity) { - return (new EntityDamageSource("fallingBlock", entity)).damageHelmet(); + public String toString() { + return "DamageSource (" + this.type().msgId() + ")"; diff --git a/paper-server/nms-patches/net/minecraft/world/damagesource/DamageSources.patch b/paper-server/nms-patches/net/minecraft/world/damagesource/DamageSources.patch new file mode 100644 index 0000000000..561959560d --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/damagesource/DamageSources.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/world/damagesource/DamageSources.java ++++ b/net/minecraft/world/damagesource/DamageSources.java +@@ -39,9 +39,15 @@ + private final DamageSource sweetBerryBush; + private final DamageSource freeze; + private final DamageSource stalagmite; ++ // CraftBukkit start ++ public final DamageSource melting; ++ public final DamageSource poison; + + public DamageSources(IRegistryCustom iregistrycustom) { + this.damageTypes = iregistrycustom.registryOrThrow(Registries.DAMAGE_TYPE); ++ this.melting = this.source(DamageTypes.ON_FIRE).melting(); ++ this.poison = this.source(DamageTypes.MAGIC).poison(); ++ // CraftBukkit end + this.inFire = this.source(DamageTypes.IN_FIRE); + this.lightningBolt = this.source(DamageTypes.LIGHTNING_BOLT); + this.onFire = this.source(DamageTypes.ON_FIRE); diff --git a/paper-server/nms-patches/net/minecraft/world/damagesource/EntityDamageSourceIndirect.patch b/paper-server/nms-patches/net/minecraft/world/damagesource/EntityDamageSourceIndirect.patch deleted file mode 100644 index f608ea6fd3..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/damagesource/EntityDamageSourceIndirect.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/world/damagesource/EntityDamageSourceIndirect.java -+++ b/net/minecraft/world/damagesource/EntityDamageSourceIndirect.java -@@ -53,4 +53,10 @@ - return IChatBaseComponent.translatable(s, entityliving.getDisplayName(), ichatbasecomponent); - } - } -+ -+ // CraftBukkit start -+ public Entity getProximateDamageSource() { -+ return super.getEntity(); -+ } -+ // CraftBukkit end - } diff --git a/paper-server/nms-patches/net/minecraft/world/effect/MobEffectList.patch b/paper-server/nms-patches/net/minecraft/world/effect/MobEffectList.patch index d663b79af6..5dd7e11f5b 100644 --- a/paper-server/nms-patches/net/minecraft/world/effect/MobEffectList.patch +++ b/paper-server/nms-patches/net/minecraft/world/effect/MobEffectList.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/MobEffectList.java +++ b/net/minecraft/world/effect/MobEffectList.java -@@ -20,6 +20,13 @@ +@@ -19,6 +19,13 @@ import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.player.EntityHuman; @@ -14,7 +14,7 @@ public class MobEffectList { private final Map attributeModifiers = Maps.newHashMap(); -@@ -56,26 +63,37 @@ +@@ -55,26 +62,37 @@ public void applyEffectTick(EntityLiving entityliving, int i) { if (this == MobEffects.REGENERATION) { if (entityliving.getHealth() < entityliving.getMaxHealth()) { @@ -23,11 +23,11 @@ } } else if (this == MobEffects.POISON) { if (entityliving.getHealth() > 1.0F) { -- entityliving.hurt(DamageSource.MAGIC, 1.0F); -+ entityliving.hurt(CraftEventFactory.POISON, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON +- entityliving.hurt(entityliving.damageSources().magic(), 1.0F); ++ entityliving.hurt(entityliving.damageSources().poison, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON } } else if (this == MobEffects.WITHER) { - entityliving.hurt(DamageSource.WITHER, 1.0F); + entityliving.hurt(entityliving.damageSources().wither(), 1.0F); } else if (this == MobEffects.HUNGER && entityliving instanceof EntityHuman) { - ((EntityHuman) entityliving).causeFoodExhaustion(0.005F * (float) (i + 1)); + ((EntityHuman) entityliving).causeFoodExhaustion(0.005F * (float) (i + 1), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.HUNGER_EFFECT); // CraftBukkit - EntityExhaustionEvent @@ -49,7 +49,7 @@ } } else if ((this != MobEffects.HEAL || entityliving.isInvertedHealAndHarm()) && (this != MobEffects.HARM || !entityliving.isInvertedHealAndHarm())) { if (this == MobEffects.HARM && !entityliving.isInvertedHealAndHarm() || this == MobEffects.HEAL && entityliving.isInvertedHealAndHarm()) { - entityliving.hurt(DamageSource.MAGIC, (float) (6 << i)); + entityliving.hurt(entityliving.damageSources().magic(), (float) (6 << i)); } } else { - entityliving.heal((float) Math.max(4 << i, 0)); @@ -57,7 +57,7 @@ } } -@@ -96,7 +114,7 @@ +@@ -95,7 +113,7 @@ } } else { j = (int) (d0 * (double) (4 << i) + 0.5D); diff --git a/paper-server/nms-patches/net/minecraft/world/effect/MobEffectUtil.patch b/paper-server/nms-patches/net/minecraft/world/effect/MobEffectUtil.patch index ceca27f2b2..f243643eea 100644 --- a/paper-server/nms-patches/net/minecraft/world/effect/MobEffectUtil.patch +++ b/paper-server/nms-patches/net/minecraft/world/effect/MobEffectUtil.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/MobEffectUtil.java +++ b/net/minecraft/world/effect/MobEffectUtil.java -@@ -44,13 +44,19 @@ +@@ -49,13 +49,19 @@ } public static List addEffectToPlayersAround(WorldServer worldserver, @Nullable Entity entity, Vec3D vec3d, double d0, MobEffect mobeffect, int i) { @@ -12,7 +12,7 @@ + // CraftBukkit end MobEffectList mobeffectlist = mobeffect.getEffect(); List list = worldserver.getPlayers((entityplayer) -> { - return entityplayer.gameMode.isSurvival() && (entity == null || !entity.isAlliedTo((Entity) entityplayer)) && vec3d.closerThan(entityplayer.position(), d0) && (!entityplayer.hasEffect(mobeffectlist) || entityplayer.getEffect(mobeffectlist).getAmplifier() < mobeffect.getAmplifier() || entityplayer.getEffect(mobeffectlist).getDuration() < i); + return entityplayer.gameMode.isSurvival() && (entity == null || !entity.isAlliedTo((Entity) entityplayer)) && vec3d.closerThan(entityplayer.position(), d0) && (!entityplayer.hasEffect(mobeffectlist) || entityplayer.getEffect(mobeffectlist).getAmplifier() < mobeffect.getAmplifier() || entityplayer.getEffect(mobeffectlist).endsWithin(i - 1)); }); list.forEach((entityplayer) -> { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch b/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch index 0adfde47b2..62398bc9ec 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -122,8 +122,65 @@ +@@ -124,8 +124,65 @@ import net.minecraft.world.scores.ScoreboardTeamBase; import org.slf4j.Logger; @@ -66,7 +66,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); public static final String ID_TAG = "id"; public static final String PASSENGERS_TAG = "Passengers"; -@@ -234,6 +291,25 @@ +@@ -236,6 +293,25 @@ public boolean hasVisualFire; @Nullable private IBlockData feetBlockState; @@ -92,7 +92,7 @@ public Entity(EntityTypes entitytypes, World world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -365,6 +441,12 @@ +@@ -367,6 +443,12 @@ public void onClientRemoval() {} public void setPose(EntityPose entitypose) { @@ -105,7 +105,7 @@ this.entityData.set(Entity.DATA_POSE, entitypose); } -@@ -389,6 +471,33 @@ +@@ -391,6 +473,33 @@ } protected void setRot(float f, float f1) { @@ -139,7 +139,7 @@ this.setYRot(f % 360.0F); this.setXRot(f1 % 360.0F); } -@@ -430,6 +539,15 @@ +@@ -432,6 +541,15 @@ this.baseTick(); } @@ -155,7 +155,7 @@ public void baseTick() { this.level.getProfiler().push("entityBaseTick"); this.feetBlockState = null; -@@ -444,7 +562,7 @@ +@@ -446,7 +564,7 @@ this.walkDistO = this.walkDist; this.xRotO = this.getXRot(); this.yRotO = this.getYRot(); @@ -164,7 +164,7 @@ if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -479,6 +597,10 @@ +@@ -481,6 +599,10 @@ if (this.isInLava()) { this.lavaHurt(); this.fallDistance *= 0.5F; @@ -175,7 +175,7 @@ } this.checkOutOfWorld(); -@@ -522,15 +644,48 @@ +@@ -524,15 +646,48 @@ public void lavaHurt() { if (!this.fireImmune()) { @@ -196,7 +196,7 @@ + this.setSecondsOnFire(15, false); + } + CraftEventFactory.blockDamage = (lastLavaContact) == null ? null : org.bukkit.craftbukkit.block.CraftBlock.at(level, lastLavaContact); - if (this.hurt(DamageSource.LAVA, 4.0F)) { + if (this.hurt(this.damageSources().lava(), 4.0F)) { this.playSound(SoundEffects.GENERIC_BURN, 0.4F, 2.0F + this.random.nextFloat() * 0.4F); } + CraftEventFactory.blockDamage = null; @@ -225,7 +225,7 @@ int j = i * 20; if (this instanceof EntityLiving) { -@@ -644,6 +799,28 @@ +@@ -646,6 +801,28 @@ block.updateEntityAfterFallOn(this.level, this); } @@ -254,7 +254,7 @@ if (this.onGround) { block.stepOn(this.level, blockposition, iblockdata, this); } -@@ -946,6 +1123,20 @@ +@@ -948,6 +1125,20 @@ return SoundEffects.GENERIC_SPLASH; } @@ -274,8 +274,8 @@ + protected void checkInsideBlocks() { AxisAlignedBB axisalignedbb = this.getBoundingBox(); - BlockPosition blockposition = new BlockPosition(axisalignedbb.minX + 1.0E-7D, axisalignedbb.minY + 1.0E-7D, axisalignedbb.minZ + 1.0E-7D); -@@ -1305,6 +1496,7 @@ + BlockPosition blockposition = BlockPosition.containing(axisalignedbb.minX + 1.0E-7D, axisalignedbb.minY + 1.0E-7D, axisalignedbb.minZ + 1.0E-7D); +@@ -1311,6 +1502,7 @@ this.yo = d1; this.zo = d4; this.setPos(d3, d1, d4); @@ -283,7 +283,7 @@ } public void moveTo(Vec3D vec3d) { -@@ -1495,6 +1687,12 @@ +@@ -1505,6 +1697,12 @@ return false; } @@ -296,7 +296,7 @@ public void awardKillScore(Entity entity, int i, DamageSource damagesource) { if (entity instanceof EntityPlayer) { CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource); -@@ -1528,7 +1726,7 @@ +@@ -1538,7 +1736,7 @@ } else { String s = this.getEncodeId(); @@ -305,7 +305,7 @@ return false; } else { nbttagcompound.putString("id", s); -@@ -1553,6 +1751,18 @@ +@@ -1563,6 +1761,18 @@ Vec3D vec3d = this.getDeltaMovement(); nbttagcompound.put("Motion", this.newDoubleList(vec3d.x, vec3d.y, vec3d.z)); @@ -324,7 +324,7 @@ nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot())); nbttagcompound.putFloat("FallDistance", this.fallDistance); nbttagcompound.putShort("Fire", (short) this.remainingFireTicks); -@@ -1561,6 +1771,25 @@ +@@ -1571,6 +1781,25 @@ nbttagcompound.putBoolean("Invulnerable", this.invulnerable); nbttagcompound.putInt("PortalCooldown", this.portalCooldown); nbttagcompound.putUUID("UUID", this.getUUID()); @@ -350,7 +350,7 @@ IChatBaseComponent ichatbasecomponent = this.getCustomName(); if (ichatbasecomponent != null) { -@@ -1628,6 +1857,11 @@ +@@ -1638,6 +1867,11 @@ } } @@ -362,7 +362,7 @@ return nbttagcompound; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); -@@ -1711,6 +1945,45 @@ +@@ -1721,6 +1955,45 @@ } else { throw new IllegalStateException("Entity has invalid position"); } @@ -408,7 +408,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded"); -@@ -1786,9 +2059,22 @@ +@@ -1796,9 +2069,22 @@ } else if (this.level.isClientSide) { return null; } else { @@ -431,7 +431,7 @@ this.level.addFreshEntity(entityitem); return entityitem; } -@@ -1882,7 +2168,7 @@ +@@ -1894,7 +2180,7 @@ this.setPose(EntityPose.STANDING); this.vehicle = entity; @@ -440,7 +440,7 @@ entity.getIndirectPassengersStream().filter((entity2) -> { return entity2 instanceof EntityPlayer; }).forEach((entity2) -> { -@@ -1913,7 +2199,7 @@ +@@ -1925,7 +2211,7 @@ Entity entity = this.vehicle; this.vehicle = null; @@ -449,7 +449,7 @@ } } -@@ -1926,10 +2212,31 @@ +@@ -1934,10 +2220,31 @@ this.removeVehicle(); } @@ -482,9 +482,9 @@ if (this.passengers.isEmpty()) { this.passengers = ImmutableList.of(entity); } else { -@@ -1945,12 +2252,32 @@ - } +@@ -1954,12 +2261,32 @@ + this.gameEvent(GameEvent.ENTITY_MOUNT, entity); } + return true; // CraftBukkit } @@ -516,15 +516,15 @@ if (this.passengers.size() == 1 && this.passengers.get(0) == entity) { this.passengers = ImmutableList.of(); } else { -@@ -1961,6 +2288,7 @@ - +@@ -1971,6 +2298,7 @@ entity.boardingCooldown = 60; + this.gameEvent(GameEvent.ENTITY_DISMOUNT, entity); } + return true; // CraftBukkit } protected boolean canAddPassenger(Entity entity) { -@@ -2023,14 +2351,20 @@ +@@ -2037,14 +2365,20 @@ if (this.isInsidePortal) { MinecraftServer minecraftserver = worldserver.getServer(); @@ -548,7 +548,7 @@ this.level.getProfiler().pop(); } -@@ -2148,6 +2482,13 @@ +@@ -2164,6 +2498,13 @@ } public void setSwimming(boolean flag) { @@ -562,7 +562,7 @@ this.setSharedFlag(4, flag); } -@@ -2193,8 +2534,12 @@ +@@ -2209,8 +2550,12 @@ return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false; } @@ -576,7 +576,7 @@ } public boolean getSharedFlag(int i) { -@@ -2213,7 +2558,7 @@ +@@ -2229,7 +2574,7 @@ } public int getMaxAirSupply() { @@ -585,7 +585,7 @@ } public int getAirSupply() { -@@ -2221,7 +2566,18 @@ +@@ -2237,7 +2582,18 @@ } public void setAirSupply(int i) { @@ -605,7 +605,7 @@ } public int getTicksFrozen() { -@@ -2248,11 +2604,41 @@ +@@ -2264,11 +2620,41 @@ public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -624,9 +624,8 @@ + this.setSecondsOnFire(entityCombustEvent.getDuration(), false); + } + // CraftBukkit end - } - -- this.hurt(DamageSource.LIGHTNING_BOLT, 5.0F); ++ } ++ + // CraftBukkit start + if (thisBukkitEntity instanceof Hanging) { + HangingBreakByEntityEvent hangingEvent = new HangingBreakByEntityEvent((Hanging) thisBukkitEntity, stormBukkitEntity); @@ -635,13 +634,14 @@ + if (hangingEvent.isCancelled()) { + return; + } -+ } -+ + } + +- this.hurt(this.damageSources().lightningBolt(), 5.0F); + if (this.fireImmune()) { + return; + } + CraftEventFactory.entityDamage = entitylightning; -+ if (!this.hurt(DamageSource.LIGHTNING_BOLT, 5.0F)) { ++ if (!this.hurt(this.damageSources().lightningBolt(), 5.0F)) { + CraftEventFactory.entityDamage = null; + return; + } @@ -649,7 +649,7 @@ } public void onAboveBubbleCol(boolean flag) { -@@ -2417,15 +2803,38 @@ +@@ -2433,15 +2819,38 @@ @Nullable public Entity changeDimension(WorldServer worldserver) { @@ -690,7 +690,7 @@ this.level.getProfiler().popPush("reloading"); Entity entity = this.getType().create(worldserver); -@@ -2434,9 +2843,17 @@ +@@ -2450,9 +2859,17 @@ entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot()); entity.setDeltaMovement(shapedetectorshape.speed); worldserver.addDuringTeleport(entity); @@ -710,7 +710,7 @@ } this.removeAfterChangingDimensions(); -@@ -2457,20 +2874,34 @@ +@@ -2473,20 +2890,34 @@ @Nullable protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) { @@ -750,7 +750,7 @@ IBlockData iblockdata = this.level.getBlockState(this.portalEntrancePos); EnumDirection.EnumAxis enumdirection_enumaxis; Vec3D vec3d; -@@ -2487,8 +2918,8 @@ +@@ -2503,8 +2934,8 @@ vec3d = new Vec3D(0.5D, 0.0D, 0.0D); } @@ -761,7 +761,7 @@ } } else { BlockPosition blockposition1; -@@ -2498,8 +2929,14 @@ +@@ -2514,8 +2945,14 @@ } else { blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos()); } @@ -777,7 +777,7 @@ } } -@@ -2507,8 +2944,23 @@ +@@ -2523,8 +2960,23 @@ return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose())); } @@ -803,7 +803,7 @@ } public boolean canChangeDimensions() { -@@ -2731,7 +3183,26 @@ +@@ -2773,7 +3225,26 @@ } public final void setBoundingBox(AxisAlignedBB axisalignedbb) { @@ -831,7 +831,7 @@ } protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) { -@@ -3023,6 +3494,11 @@ +@@ -3084,6 +3555,11 @@ vec3d = vec3d.add(vec3d1); ++k1; } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityAgeable.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityAgeable.patch index fa57995fb0..aba475a606 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityAgeable.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityAgeable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityAgeable.java +++ b/net/minecraft/world/entity/EntityAgeable.java -@@ -19,6 +19,7 @@ +@@ -20,6 +20,7 @@ protected int age; protected int forcedAge; protected int forcedAgeTimer; @@ -8,7 +8,7 @@ protected EntityAgeable(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -102,6 +103,7 @@ +@@ -103,6 +104,7 @@ super.addAdditionalSaveData(nbttagcompound); nbttagcompound.putInt("Age", this.getAge()); nbttagcompound.putInt("ForcedAge", this.forcedAge); @@ -16,7 +16,7 @@ } @Override -@@ -109,6 +111,7 @@ +@@ -110,6 +112,7 @@ super.readAdditionalSaveData(nbttagcompound); this.setAge(nbttagcompound.getInt("Age")); this.forcedAge = nbttagcompound.getInt("ForcedAge"); @@ -24,7 +24,7 @@ } @Override -@@ -123,7 +126,7 @@ +@@ -124,7 +127,7 @@ @Override public void aiStep() { super.aiStep(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch index 89c29c0221..eb94f95689 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch @@ -10,7 +10,7 @@ +import org.bukkit.entity.LivingEntity; +// CraftBukkit end + - public class EntityAreaEffectCloud extends Entity { + public class EntityAreaEffectCloud extends Entity implements TraceableEntity { private static final Logger LOGGER = LogUtils.getLogger(); @@ -129,6 +135,22 @@ @@ -36,7 +36,7 @@ public int getColor() { return (Integer) this.getEntityData().get(EntityAreaEffectCloud.DATA_COLOR); } -@@ -261,6 +283,7 @@ +@@ -263,6 +285,7 @@ if (!list1.isEmpty()) { Iterator iterator1 = list1.iterator(); @@ -44,7 +44,7 @@ while (iterator1.hasNext()) { EntityLiving entityliving = (EntityLiving) iterator1.next(); -@@ -270,6 +293,17 @@ +@@ -272,6 +295,17 @@ double d8 = d6 * d6 + d7 * d7; if (d8 <= (double) (f * f)) { @@ -62,7 +62,7 @@ this.victims.put(entityliving, this.tickCount + this.reapplicationDelay); Iterator iterator2 = list.iterator(); -@@ -279,7 +313,7 @@ +@@ -281,7 +315,7 @@ if (mobeffect1.getEffect().isInstantenous()) { mobeffect1.getEffect().applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D); } else { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityInsentient.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityInsentient.patch index b2f789f37b..4e9a5910d0 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityInsentient.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityInsentient.patch @@ -17,7 +17,7 @@ +import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason; +// CraftBukkit end + - public abstract class EntityInsentient extends EntityLiving { + public abstract class EntityInsentient extends EntityLiving implements Targeting { private static final DataWatcherObject DATA_MOB_FLAGS_ID = DataWatcher.defineId(EntityInsentient.class, DataWatcherRegistry.BYTE); @@ -121,6 +134,8 @@ @@ -42,7 +42,7 @@ protected void registerGoals() {} public static AttributeProvider.Builder createMobAttributes() { -@@ -224,7 +245,38 @@ +@@ -254,7 +275,38 @@ } public void setTarget(@Nullable EntityLiving entityliving) { @@ -81,7 +81,7 @@ } @Override -@@ -364,6 +416,12 @@ +@@ -394,6 +446,12 @@ return null; } @@ -94,7 +94,7 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(nbttagcompound); -@@ -453,16 +511,26 @@ +@@ -483,16 +541,26 @@ nbttagcompound.putBoolean("NoAI", this.isNoAi()); } @@ -123,7 +123,7 @@ NBTTagList nbttaglist; int i; -@@ -509,6 +577,11 @@ +@@ -539,6 +607,11 @@ } this.setNoAi(nbttagcompound.getBoolean("NoAI")); @@ -135,7 +135,7 @@ } @Override -@@ -576,7 +649,7 @@ +@@ -606,7 +679,7 @@ protected void pickUpItem(EntityItem entityitem) { ItemStack itemstack = entityitem.getItem(); @@ -144,7 +144,7 @@ if (!itemstack1.isEmpty()) { this.onItemPickup(entityitem); -@@ -590,15 +663,29 @@ +@@ -620,6 +693,12 @@ } public ItemStack equipItemIfPossible(ItemStack itemstack) { @@ -154,9 +154,12 @@ + + public ItemStack equipItemIfPossible(ItemStack itemstack, EntityItem entityitem) { + // CraftBukkit end - EnumItemSlot enumitemslot = this.getEquipmentSlotForItemStack(itemstack); + EnumItemSlot enumitemslot = getEquipmentSlotForItem(itemstack); ItemStack itemstack1 = this.getItemBySlot(enumitemslot); boolean flag = this.canReplaceCurrentItem(itemstack, itemstack1); +@@ -630,11 +709,19 @@ + flag = this.canReplaceCurrentItem(itemstack, itemstack1); + } - if (flag && this.canHoldItem(itemstack)) { + // CraftBukkit start @@ -175,7 +178,7 @@ } if (enumitemslot.isArmor() && itemstack.getCount() > 1) { -@@ -750,6 +837,7 @@ +@@ -779,6 +866,7 @@ @Override protected final void serverAiStep() { ++this.noActionTime; @@ -183,7 +186,7 @@ this.level.getProfiler().push("sensing"); this.sensing.tick(); this.level.getProfiler().pop(); -@@ -1143,6 +1231,12 @@ +@@ -1172,6 +1260,12 @@ if (!this.isAlive()) { return EnumInteractionResult.PASS; } else if (this.getLeashHolder() == entityhuman) { @@ -194,9 +197,9 @@ + } + // CraftBukkit end this.dropLeash(true, !entityhuman.getAbilities().instabuild); + this.gameEvent(GameEvent.ENTITY_INTERACT, entityhuman); return EnumInteractionResult.sidedSuccess(this.level.isClientSide); - } else { -@@ -1166,6 +1260,12 @@ +@@ -1197,6 +1291,12 @@ ItemStack itemstack = entityhuman.getItemInHand(enumhand); if (itemstack.is(Items.LEAD) && this.canBeLeashed(entityhuman)) { @@ -209,7 +212,7 @@ this.setLeashedTo(entityhuman, true); itemstack.shrink(1); return EnumInteractionResult.sidedSuccess(this.level.isClientSide); -@@ -1181,7 +1281,7 @@ +@@ -1212,7 +1312,7 @@ if (itemstack.getItem() instanceof ItemMonsterEgg) { if (this.level instanceof WorldServer) { ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem(); @@ -218,7 +221,7 @@ optional.ifPresent((entityinsentient) -> { this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient); -@@ -1231,12 +1331,19 @@ +@@ -1262,12 +1362,19 @@ return this.restrictRadius != -1.0F; } @@ -239,7 +242,7 @@ if (t0 == null) { return null; -@@ -1271,7 +1378,12 @@ +@@ -1302,7 +1409,12 @@ } } @@ -253,7 +256,7 @@ if (this.isPassenger()) { Entity entity = this.getVehicle(); -@@ -1292,6 +1404,7 @@ +@@ -1323,6 +1435,7 @@ if (this.leashHolder != null) { if (!this.isAlive() || !this.leashHolder.isAlive()) { @@ -261,7 +264,7 @@ this.dropLeash(true, true); } -@@ -1303,7 +1416,9 @@ +@@ -1334,7 +1447,9 @@ this.leashHolder = null; this.leashInfoTag = null; if (!this.level.isClientSide && flag1) { @@ -271,7 +274,7 @@ } if (!this.level.isClientSide && flag && this.level instanceof WorldServer) { -@@ -1353,6 +1468,7 @@ +@@ -1384,6 +1499,7 @@ boolean flag1 = super.startRiding(entity, flag); if (flag1 && this.isLeashed()) { @@ -279,7 +282,7 @@ this.dropLeash(true, true); } -@@ -1377,7 +1493,9 @@ +@@ -1408,7 +1524,9 @@ } if (this.tickCount > 100) { @@ -289,7 +292,7 @@ this.leashInfoTag = null; } } -@@ -1458,7 +1576,14 @@ +@@ -1484,7 +1602,14 @@ int i = EnchantmentManager.getFireAspect(this); if (i > 0) { @@ -304,8 +307,8 @@ + // CraftBukkit end } - boolean flag = entity.hurt(DamageSource.mobAttack(this), f); -@@ -1532,9 +1657,10 @@ + boolean flag = entity.hurt(this.damageSources().mobAttack(this), f); +@@ -1558,9 +1683,10 @@ @Override protected void removeAfterChangingDimensions() { super.removeAfterChangingDimensions(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityLiving.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityLiving.patch index 69ab093ed0..94126d5e8f 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityLiving.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityLiving.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityLiving.java +++ b/net/minecraft/world/entity/EntityLiving.java -@@ -119,6 +119,30 @@ +@@ -117,6 +117,30 @@ import net.minecraft.world.scores.ScoreboardTeam; import org.slf4j.Logger; @@ -28,10 +28,10 @@ +import org.bukkit.event.player.PlayerItemConsumeEvent; +// CraftBukkit end + - public abstract class EntityLiving extends Entity { + public abstract class EntityLiving extends Entity implements Attackable { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -229,6 +253,20 @@ +@@ -224,6 +248,20 @@ private float swimAmountO; protected BehaviorController brain; private boolean skipDropExperience; @@ -52,7 +52,7 @@ protected EntityLiving(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -241,7 +279,9 @@ +@@ -236,7 +274,9 @@ this.useItem = ItemStack.EMPTY; this.lastClimbablePos = Optional.empty(); this.attributes = new AttributeMapBase(AttributeDefaults.getSupplier(entitytypes)); @@ -63,7 +63,7 @@ this.blocksBuilding = true; this.rotA = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); this.reapplyPosition(); -@@ -308,7 +348,13 @@ +@@ -303,7 +343,13 @@ double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D); int i = (int) (150.0D * d1); @@ -78,7 +78,7 @@ } } -@@ -660,10 +706,16 @@ +@@ -655,13 +701,19 @@ } public void onEquipItem(EnumItemSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1) { @@ -90,13 +90,16 @@ + // CraftBukkit end boolean flag = itemstack1.isEmpty() && itemstack.isEmpty(); - if (!flag && !ItemStack.isSame(itemstack, itemstack1) && !this.firstTick) { -- if (enumitemslot.getType() == EnumItemSlot.Function.ARMOR) { -+ if (enumitemslot.getType() == EnumItemSlot.Function.ARMOR && !silent) { // CraftBukkit - this.playEquipSound(itemstack1); - } + if (!flag && !ItemStack.isSameItemSameTags(itemstack, itemstack1) && !this.firstTick) { + Equipable equipable = Equipable.get(itemstack1); -@@ -741,6 +793,17 @@ + if (equipable != null && !this.isSpectator() && equipable.getEquipmentSlot() == enumitemslot) { +- if (!this.level.isClientSide() && !this.isSilent()) { ++ if (!this.level.isClientSide() && !this.isSilent() && !silent) { // CraftBukkit + this.level.playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), equipable.getEquipSound(), this.getSoundSource(), 1.0F, 1.0F); + } + +@@ -735,6 +787,17 @@ } } @@ -114,7 +117,7 @@ if (nbttagcompound.contains("Health", 99)) { this.setHealth(nbttagcompound.getFloat("Health")); } -@@ -778,9 +841,32 @@ +@@ -772,9 +835,32 @@ } @@ -147,7 +150,7 @@ try { while (iterator.hasNext()) { MobEffectList mobeffectlist = (MobEffectList) iterator.next(); -@@ -790,6 +876,12 @@ +@@ -784,6 +870,12 @@ this.onEffectUpdated(mobeffect, true, (Entity) null); })) { if (!this.level.isClientSide) { @@ -160,7 +163,7 @@ iterator.remove(); this.onEffectRemoved(mobeffect); } -@@ -800,6 +892,17 @@ +@@ -794,6 +886,17 @@ } catch (ConcurrentModificationException concurrentmodificationexception) { ; } @@ -178,7 +181,7 @@ if (this.effectsDirty) { if (!this.level.isClientSide) { -@@ -926,7 +1029,13 @@ +@@ -920,7 +1023,13 @@ this.entityData.set(EntityLiving.DATA_EFFECT_COLOR_ID, 0); } @@ -192,7 +195,7 @@ if (this.level.isClientSide) { return false; } else { -@@ -935,7 +1044,14 @@ +@@ -929,7 +1038,14 @@ boolean flag; for (flag = false; iterator.hasNext(); flag = true) { @@ -208,7 +211,7 @@ iterator.remove(); } -@@ -964,18 +1080,48 @@ +@@ -958,18 +1074,48 @@ return this.addEffect(mobeffect, (Entity) null); } @@ -258,7 +261,7 @@ return true; } else { return false; -@@ -1012,13 +1158,39 @@ +@@ -1006,13 +1152,39 @@ return this.getMobType() == EnumMonsterType.UNDEAD; } @@ -299,7 +302,7 @@ if (mobeffect != null) { this.onEffectRemoved(mobeffect); -@@ -1055,20 +1227,55 @@ +@@ -1049,20 +1221,55 @@ } @@ -356,16 +359,16 @@ this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.clamp(f, 0.0F, this.getMaxHealth())); } -@@ -1082,7 +1289,7 @@ +@@ -1076,7 +1283,7 @@ return false; } else if (this.level.isClientSide) { return false; - } else if (this.isDeadOrDying()) { + } else if (this.isRemoved() || this.dead || this.getHealth() <= 0.0F) { // CraftBukkit - Don't allow entities that got set to dead/killed elsewhere to get damaged and die return false; - } else if (damagesource.isFire() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { + } else if (damagesource.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -1093,10 +1300,11 @@ +@@ -1087,10 +1294,11 @@ this.noActionTime = 0; float f1 = f; @@ -379,12 +382,12 @@ this.hurtCurrentlyUsedShield(f); f2 = f; f = 0.0F; -@@ -1116,27 +1324,46 @@ - this.animationSpeed = 1.5F; +@@ -1114,27 +1322,46 @@ + this.walkAnimation.setSpeed(1.5F); boolean flag1 = true; -- if ((float) this.invulnerableTime > 10.0F) { -+ if ((float) this.invulnerableTime > (float) this.invulnerableDuration / 2.0F) { // CraftBukkit - restore use of maxNoDamageTicks +- if ((float) this.invulnerableTime > 10.0F && !damagesource.is(DamageTypeTags.BYPASSES_COOLDOWN)) { ++ if ((float) this.invulnerableTime > (float) this.invulnerableDuration / 2.0F && !damagesource.is(DamageTypeTags.BYPASSES_COOLDOWN)) { // CraftBukkit - restore use of maxNoDamageTicks if (f <= this.lastHurt) { return false; } @@ -412,9 +415,9 @@ this.hurtTime = this.hurtDuration; } -- if (damagesource.isDamageHelmet() && !this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) { +- if (damagesource.is(DamageTypeTags.DAMAGES_HELMET) && !this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) { + // CraftBukkit - Moved into damageEntity0(DamageSource, float) -+ if (false && damagesource.isDamageHelmet() && !this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) { ++ if (false && damagesource.is(DamageTypeTags.DAMAGES_HELMET) && !this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) { this.hurtHelmet(damagesource, f); f *= 0.75F; } @@ -428,10 +431,10 @@ + } + // CraftBukkit end + - this.hurtDir = 0.0F; Entity entity1 = damagesource.getEntity(); -@@ -1259,19 +1486,32 @@ + if (entity1 != null) { +@@ -1248,19 +1475,32 @@ EnumHand[] aenumhand = EnumHand.values(); int i = aenumhand.length; @@ -468,7 +471,7 @@ EntityPlayer entityplayer = (EntityPlayer) this; entityplayer.awardStat(StatisticList.ITEM_USED.get(Items.TOTEM_OF_UNDYING)); -@@ -1279,14 +1519,16 @@ +@@ -1268,14 +1508,16 @@ } this.setHealth(1.0F); @@ -490,7 +493,7 @@ } } -@@ -1391,14 +1633,22 @@ +@@ -1380,14 +1622,22 @@ IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState(); if (this.level.getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level, blockposition)) { @@ -515,7 +518,7 @@ this.level.addFreshEntity(entityitem); } } -@@ -1418,21 +1668,40 @@ +@@ -1407,21 +1657,40 @@ boolean flag = this.lastHurtByPlayerTime > 0; @@ -559,7 +562,7 @@ } -@@ -1517,6 +1786,28 @@ +@@ -1512,6 +1781,28 @@ return itemstack.getEatingSound(); } @@ -588,7 +591,7 @@ @Override public void setOnGround(boolean flag) { super.setOnGround(flag); -@@ -1572,9 +1863,14 @@ +@@ -1567,9 +1858,14 @@ int i = this.calculateFallDamage(f, f1); if (i > 0) { @@ -604,26 +607,26 @@ return true; } else { return flag; -@@ -1623,7 +1919,7 @@ +@@ -1621,7 +1917,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) { - if (!damagesource.isBypassArmor()) { + if (!damagesource.is(DamageTypeTags.BYPASSES_ARMOR)) { - this.hurtArmor(damagesource, f); -+ // this.damageArmor(damagesource, f); // CraftBukkit - Moved into damageEntity0(DamageSource, float) ++ // this.hurtArmor(damagesource, f); // CraftBukkit - Moved into damageEntity0(DamageSource, float) f = CombatMath.getDamageAfterAbsorb(f, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS)); } -@@ -1636,7 +1932,8 @@ +@@ -1634,7 +1930,8 @@ } else { int i; -- if (this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { +- if (this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && !damagesource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { + // CraftBukkit - Moved to damageEntity0(DamageSource, float) -+ if (false && this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { ++ if (false && this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && !damagesource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f1 = f * (float) j; -@@ -1669,29 +1966,172 @@ +@@ -1667,16 +1964,125 @@ } } @@ -640,7 +643,7 @@ + Function hardHat = new Function() { + @Override + public Double apply(Double f) { -+ if (damagesource.isDamageHelmet() && !EntityLiving.this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) { ++ if (damagesource.is(DamageTypeTags.DAMAGES_HELMET) && !EntityLiving.this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) { + return -(f - (f * 0.75F)); + + } @@ -671,7 +674,7 @@ + Function resistance = new Function() { + @Override + public Double apply(Double f) { -+ if (!damagesource.isBypassMagic() && EntityLiving.this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { ++ if (!damagesource.is(DamageTypeTags.BYPASSES_EFFECTS) && EntityLiving.this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && !damagesource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { + int i = (EntityLiving.this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; + int j = 25 - i; + float f1 = f.floatValue() * (float) j; @@ -723,12 +726,12 @@ + } + + // Apply damage to helmet -+ if (damagesource.isDamageHelmet() && !this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) { ++ if (damagesource.is(DamageTypeTags.DAMAGES_HELMET) && !this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) { + this.hurtHelmet(damagesource, f); + } + + // Apply damage to armor -+ if (!damagesource.isBypassArmor()) { ++ if (!damagesource.is(DamageTypeTags.BYPASSES_ARMOR)) { + float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT)); + this.hurtArmor(damagesource, armorDamage); + } @@ -754,8 +757,11 @@ + if (f2 > 0.0F && f2 < 3.4028235E37F && this instanceof EntityHuman) { + ((EntityHuman) this).awardStat(StatisticList.DAMAGE_ABSORBED, Math.round(f2 * 10.0F)); + } - if (f2 > 0.0F && f2 < 3.4028235E37F && damagesource.getEntity() instanceof EntityPlayer) { - ((EntityPlayer) damagesource.getEntity()).awardStat(StatisticList.DAMAGE_DEALT_ABSORBED, Math.round(f2 * 10.0F)); + if (f2 > 0.0F && f2 < 3.4028235E37F) { + Entity entity = damagesource.getEntity(); + +@@ -1687,15 +2093,49 @@ + } } - if (f != 0.0F) { @@ -770,8 +776,8 @@ + // CraftBukkit end float f3 = this.getHealth(); - this.setHealth(f3 - f); this.getCombatTracker().recordDamage(damagesource, f3, f); + this.setHealth(f3 - f); - this.setAbsorptionAmount(this.getAbsorptionAmount() - f); + // CraftBukkit start + if (!human) { @@ -806,7 +812,7 @@ } public CombatTracker getCombatTracker() { -@@ -1712,9 +2152,19 @@ +@@ -1716,9 +2156,19 @@ } public final void setArrowCount(int i) { @@ -827,7 +833,7 @@ public final int getStingerCount() { return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID); } -@@ -2017,6 +2467,12 @@ +@@ -1959,6 +2409,12 @@ public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot); @@ -840,7 +846,7 @@ @Override public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack); -@@ -2256,6 +2712,7 @@ +@@ -2198,6 +2654,7 @@ } if (this.onGround && !this.level.isClientSide) { @@ -848,7 +854,7 @@ this.setSharedFlag(7, false); } } else { -@@ -2793,6 +3250,7 @@ +@@ -2757,6 +3214,7 @@ } if (!this.level.isClientSide) { @@ -856,7 +862,7 @@ this.setSharedFlag(7, flag); } -@@ -2956,14 +3414,21 @@ +@@ -2916,14 +3374,21 @@ @Override public boolean isPickable() { @@ -880,7 +886,7 @@ @Override public float getYHeadRot() { return this.yHeadRot; -@@ -3158,7 +3623,26 @@ +@@ -3118,7 +3583,26 @@ } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { this.triggerItemUseEffects(this.useItem, 16); @@ -908,7 +914,7 @@ if (itemstack != this.useItem) { this.setItemInHand(enumhand, itemstack); -@@ -3236,6 +3720,12 @@ +@@ -3196,6 +3680,12 @@ } public boolean randomTeleport(double d0, double d1, double d2, boolean flag) { @@ -921,7 +927,7 @@ double d3 = this.getX(); double d4 = this.getY(); double d5 = this.getZ(); -@@ -3260,16 +3750,41 @@ +@@ -3220,16 +3710,41 @@ } if (flag2) { @@ -949,7 +955,7 @@ + } + } else { + // player teleport event is called in the underlining code -+ if (((EntityPlayer) this).connection.teleport(d0, d6, d2, this.getYRot(), this.getXRot(), java.util.Collections.emptySet(), false, cause)) { ++ if (((EntityPlayer) this).connection.teleport(d0, d6, d2, this.getYRot(), this.getXRot(), java.util.Collections.emptySet(), cause)) { + return Optional.empty(); + } + } @@ -966,7 +972,7 @@ } else { if (flag) { world.broadcastEntityEvent(this, (byte) 46); -@@ -3279,7 +3794,7 @@ +@@ -3239,7 +3754,7 @@ ((EntityCreature) this).getNavigation().stop(); } @@ -975,7 +981,7 @@ } } -@@ -3357,7 +3872,7 @@ +@@ -3322,7 +3837,7 @@ } public void stopSleeping() { @@ -984,7 +990,7 @@ World world = this.level; java.util.Objects.requireNonNull(this.level); -@@ -3391,7 +3906,7 @@ +@@ -3356,7 +3871,7 @@ @Nullable public EnumDirection getBedOrientation() { @@ -993,7 +999,7 @@ return blockposition != null ? BlockBed.getBedOrientation(this.level, blockposition) : null; } -@@ -3439,7 +3954,7 @@ +@@ -3404,7 +3919,7 @@ Pair pair = (Pair) iterator.next(); if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityTypes.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityTypes.patch index 1a398aa2dd..b9e22a7997 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityTypes.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityTypes.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityTypes.java +++ b/net/minecraft/world/entity/EntityTypes.java -@@ -156,6 +156,7 @@ +@@ -157,6 +157,7 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -8,16 +8,16 @@ import org.slf4j.Logger; public class EntityTypes implements FeatureElement, EntityTypeTest { -@@ -165,7 +166,7 @@ - private final Holder.c> builtInRegistryHolder; +@@ -167,7 +168,7 @@ private static final float MAGIC_HORSE_WIDTH = 1.3964844F; + private static final int DISPLAY_TRACKING_RANGE = 10; public static final EntityTypes ALLAY = register("allay", EntityTypes.Builder.of(Allay::new, EnumCreatureType.CREATURE).sized(0.35F, 0.6F).clientTrackingRange(8).updateInterval(2)); - public static final EntityTypes AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(Integer.MAX_VALUE)); + public static final EntityTypes AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds public static final EntityTypes ARMOR_STAND = register("armor_stand", EntityTypes.Builder.of(EntityArmorStand::new, EnumCreatureType.MISC).sized(0.5F, 1.975F).clientTrackingRange(10)); public static final EntityTypes ARROW = register("arrow", EntityTypes.Builder.of(EntityTippedArrow::new, EnumCreatureType.MISC).sized(0.5F, 0.5F).clientTrackingRange(4).updateInterval(20)); public static final EntityTypes AXOLOTL = register("axolotl", EntityTypes.Builder.of(Axolotl::new, EnumCreatureType.AXOLOTLS).sized(0.75F, 0.42F).clientTrackingRange(10)); -@@ -301,8 +302,8 @@ +@@ -308,8 +309,8 @@ private final EntitySize dimensions; private final FeatureFlagSet requiredFeatures; @@ -28,7 +28,7 @@ } public static MinecraftKey getKey(EntityTypes entitytypes) { -@@ -330,8 +331,15 @@ +@@ -337,8 +338,15 @@ @Nullable public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) { @@ -45,7 +45,7 @@ if (itemstack != null) { nbttagcompound = itemstack.getTag(); -@@ -342,7 +350,7 @@ +@@ -349,7 +357,7 @@ nbttagcompound = null; } @@ -54,7 +54,7 @@ } public static Consumer createDefaultStackConfig(WorldServer worldserver, ItemStack itemstack, @Nullable EntityHuman entityhuman) { -@@ -363,21 +371,37 @@ +@@ -371,21 +379,37 @@ NBTTagCompound nbttagcompound = itemstack.getTag(); return nbttagcompound != null ? consumer.andThen((entity) -> { @@ -95,7 +95,7 @@ } return t0; -@@ -564,7 +588,7 @@ +@@ -572,7 +596,7 @@ } return entity; @@ -104,7 +104,7 @@ } public static Stream loadEntitiesRecursive(final List list, final World world) { -@@ -621,7 +645,7 @@ +@@ -629,7 +653,7 @@ @Nullable public T tryCast(Entity entity) { @@ -113,7 +113,7 @@ } @Override -@@ -656,7 +680,7 @@ +@@ -664,7 +688,7 @@ this.canSpawnFarFromPlayer = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC; } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/SaddleStorage.patch b/paper-server/nms-patches/net/minecraft/world/entity/SaddleStorage.patch index 996fa69bad..087cd81c37 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/SaddleStorage.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/SaddleStorage.patch @@ -1,15 +1,14 @@ --- a/net/minecraft/world/entity/SaddleStorage.java +++ b/net/minecraft/world/entity/SaddleStorage.java -@@ -40,6 +40,15 @@ - } +@@ -53,6 +53,14 @@ + return (Integer) this.entityData.get(this.boostTimeAccessor); } + // CraftBukkit add setBoostTicks(int) + public void setBoostTicks(int ticks) { + this.boosting = true; + this.boostTime = 0; -+ this.boostTimeTotal = ticks; -+ this.entityData.set(this.boostTimeAccessor, this.boostTimeTotal); ++ this.entityData.set(this.boostTimeAccessor, ticks); + } + // CraftBukkit end + diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter.patch deleted file mode 100644 index 364417de50..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter.java -+++ b/net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter.java -@@ -42,7 +42,7 @@ - BlockPosition blockposition = globalpos.pos(); - - if ((Integer) iblockdata.getValue(BlockComposter.LEVEL) == 8) { -- iblockdata = BlockComposter.extractProduce(iblockdata, worldserver, blockposition); -+ iblockdata = BlockComposter.extractProduce(iblockdata, worldserver, blockposition, entityvillager); // CraftBukkit - } - - int i = 20; -@@ -67,7 +67,7 @@ - i -= k1; - - for (int l1 = 0; l1 < k1; ++l1) { -- iblockdata1 = BlockComposter.insertItem(iblockdata1, worldserver, itemstack, blockposition); -+ iblockdata1 = BlockComposter.insertItem(iblockdata1, worldserver, itemstack, blockposition, entityvillager); // CraftBukkit - if ((Integer) iblockdata1.getValue(BlockComposter.LEVEL) == 7) { - this.spawnComposterFillEffects(worldserver, iblockdata, blockposition, iblockdata1); - return; diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.patch index 432694f3aa..f23150a95b 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.patch @@ -13,7 +13,7 @@ public class PathfinderGoalFollowOwner extends PathfinderGoal { public static final int TELEPORT_WHEN_DISTANCE_IS = 12; -@@ -120,7 +126,18 @@ +@@ -122,7 +128,18 @@ } else if (!this.canTeleportTo(new BlockPosition(i, j, k))) { return false; } else { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.patch index 0611fdf552..e4d7bc52f6 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.patch @@ -12,7 +12,7 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget { private final Block blockToRemove; -@@ -100,6 +105,14 @@ +@@ -96,6 +101,14 @@ } if (this.ticksSinceReachedGoal > 60) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch b/paper-server/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch index f62b644206..e2755de4a6 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch @@ -52,7 +52,7 @@ } } -@@ -203,7 +217,11 @@ +@@ -198,7 +212,11 @@ return false; } else { if (!this.level.isClientSide && this.isResting()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch index c8770e4238..76fb97ab63 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch @@ -9,7 +9,7 @@ } } -@@ -646,11 +646,15 @@ +@@ -641,11 +641,15 @@ if (this.isInvulnerableTo(damagesource)) { return false; } else { @@ -27,7 +27,7 @@ } } -@@ -1226,7 +1230,7 @@ +@@ -1221,7 +1225,7 @@ } } @@ -36,7 +36,7 @@ EntityBee.this.level.levelEvent(2005, blockposition, 0); EntityBee.this.level.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(blockstateinteger, (Integer) iblockdata.getValue(blockstateinteger) + 1)); EntityBee.this.incrementNumCropsGrownSincePollination(); -@@ -1299,7 +1303,7 @@ +@@ -1294,7 +1298,7 @@ @Override protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) { if (entityinsentient instanceof EntityBee && this.mob.hasLineOfSight(entityliving)) { @@ -45,7 +45,7 @@ } } -@@ -1308,7 +1312,7 @@ +@@ -1303,7 +1307,7 @@ private static class c extends PathfinderGoalNearestAttackableTarget { c(EntityBee entitybee) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch index 170bd5db74..139d6632dc 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityCat.java +++ b/net/minecraft/world/entity/animal/EntityCat.java -@@ -415,7 +415,7 @@ +@@ -412,7 +412,7 @@ } } else if (this.isFood(itemstack)) { this.usePlayerItem(entityhuman, enumhand, itemstack); @@ -9,7 +9,7 @@ this.tame(entityhuman); this.setOrderedToSit(true); this.level.broadcastEntityEvent(this, (byte) 7); -@@ -472,7 +472,7 @@ +@@ -469,7 +469,7 @@ private static class PathfinderGoalTemptChance extends PathfinderGoalTempt { @Nullable @@ -18,7 +18,7 @@ private final EntityCat cat; public PathfinderGoalTemptChance(EntityCat entitycat, double d0, RecipeItemStack recipeitemstack, boolean flag) { -@@ -613,7 +613,15 @@ +@@ -610,7 +610,15 @@ while (iterator.hasNext()) { ItemStack itemstack = (ItemStack) iterator.next(); @@ -35,7 +35,7 @@ } } -@@ -645,10 +653,10 @@ +@@ -642,10 +650,10 @@ private final EntityCat cat; public a(EntityCat entitycat, Class oclass, float f, double d0, double d1) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch index 034dfba6a4..f3a4740457 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityFox.java +++ b/net/minecraft/world/entity/animal/EntityFox.java -@@ -516,7 +516,8 @@ +@@ -517,7 +517,8 @@ protected void pickUpItem(EntityItem entityitem) { ItemStack itemstack = entityitem.getItem(); @@ -10,7 +10,7 @@ int i = itemstack.getCount(); if (i > 1) { -@@ -871,6 +872,16 @@ +@@ -872,6 +873,16 @@ if (entityplayer1 != null && entityplayer != entityplayer1) { entityfox.addTrustedUUID(entityplayer1.getUUID()); } @@ -27,7 +27,7 @@ if (entityplayer2 != null) { entityplayer2.awardStat(StatisticList.ANIMALS_BRED); -@@ -881,12 +892,14 @@ +@@ -882,12 +893,14 @@ this.partner.setAge(6000); this.animal.resetLove(); this.partner.resetLove(); @@ -46,15 +46,7 @@ } } -@@ -1277,13 +1290,18 @@ - } - - private void pickGlowBerry(IBlockData iblockdata) { -- CaveVines.use(iblockdata, EntityFox.this.level, this.blockPos); -+ CaveVines.use(iblockdata, EntityFox.this.level, this.blockPos, EntityFox.this); // CraftBukkit - } - - private void pickSweetBerries(IBlockData iblockdata) { +@@ -1285,6 +1298,11 @@ int i = (Integer) iblockdata.getValue(BlockSweetBerryBush.AGE); iblockdata.setValue(BlockSweetBerryBush.AGE, 1); @@ -66,7 +58,7 @@ int j = 1 + EntityFox.this.level.random.nextInt(2) + (i == 3 ? 1 : 0); ItemStack itemstack = EntityFox.this.getItemBySlot(EnumItemSlot.MAINHAND); -@@ -1440,7 +1458,7 @@ +@@ -1441,7 +1459,7 @@ private EntityLiving trustedLastHurt; private int timestamp; diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch index 46bd745c50..498a128d12 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityOcelot.java +++ b/net/minecraft/world/entity/animal/EntityOcelot.java -@@ -182,7 +182,8 @@ +@@ -177,7 +177,8 @@ if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemstack) && entityhuman.distanceToSqr((Entity) this) < 9.0D) { this.usePlayerItem(entityhuman, enumhand, itemstack); if (!this.level.isClientSide) { @@ -10,7 +10,7 @@ this.setTrusting(true); this.spawnTrustingParticles(true); this.level.broadcastEntityEvent(this, (byte) 41); -@@ -313,10 +314,10 @@ +@@ -308,10 +309,10 @@ private final EntityOcelot ocelot; public a(EntityOcelot entityocelot, Class oclass, float f, double d0, double d1) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch index bf2e2006dc..487f7035aa 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch @@ -16,9 +16,9 @@ - this.addEffect(new MobEffect(MobEffects.POISON, 900)); + this.addEffect(new MobEffect(MobEffects.POISON, 900), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit if (entityhuman.isCreative() || !this.isInvulnerable()) { - this.hurt(DamageSource.playerAttack(entityhuman), Float.MAX_VALUE); + this.hurt(this.damageSources().playerAttack(entityhuman), Float.MAX_VALUE); } -@@ -387,7 +387,7 @@ +@@ -382,7 +382,7 @@ @Override public boolean isPushable() { @@ -27,7 +27,7 @@ } @Override -@@ -403,7 +403,7 @@ +@@ -398,7 +398,7 @@ return false; } else { if (!this.level.isClientSide) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch index c5f8c33cd3..e01702784b 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch @@ -3,7 +3,7 @@ @@ -144,7 +144,7 @@ int i = this.getPuffState(); - if (entityinsentient.hurt(DamageSource.mobAttack(this), (float) (1 + i))) { + if (entityinsentient.hurt(this.damageSources().mobAttack(this), (float) (1 + i))) { - entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this); + entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit this.playSound(SoundEffects.PUFFER_FISH_STING, 1.0F, 1.0F); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch index 43864f3574..cb3d307364 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch @@ -56,7 +56,7 @@ InventoryCrafting inventorycrafting = makeContainer(enumcolor, enumcolor1); - Optional optional = this.level.getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level).map((recipecrafting) -> { + Optional optional = this.level.getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level).map((recipecrafting) -> { // CraftBukkit - decompile error - return recipecrafting.assemble(inventorycrafting); + return recipecrafting.assemble(inventorycrafting, this.level.registryAccess()); }).map(ItemStack::getItem); @@ -399,10 +420,18 @@ diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch index 4a4a4fa3e4..83dcf05153 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch @@ -11,29 +11,29 @@ public class EntitySnowman extends EntityGolem implements IShearable, IRangedEntity { private static final DataWatcherObject DATA_PUMPKIN_ID = DataWatcher.defineId(EntitySnowman.class, DataWatcherRegistry.BYTE); -@@ -103,7 +107,7 @@ - BiomeBase biomebase = (BiomeBase) this.level.getBiome(blockposition).value(); - - if (biomebase.shouldSnowGolemBurn(blockposition)) { -- this.hurt(DamageSource.ON_FIRE, 1.0F); -+ this.hurt(CraftEventFactory.MELTING, 1.0F); // CraftBukkit - DamageSource.BURN -> CraftEventFactory.MELTING +@@ -97,7 +101,7 @@ + super.aiStep(); + if (!this.level.isClientSide) { + if (this.level.getBiome(this.blockPosition()).is(BiomeTags.SNOW_GOLEM_MELTS)) { +- this.hurt(this.damageSources().onFire(), 1.0F); ++ this.hurt(this.damageSources().melting, 1.0F); // CraftBukkit - DamageSource.BURN -> CraftEventFactory.MELTING } if (!this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -@@ -119,7 +123,11 @@ - BlockPosition blockposition1 = new BlockPosition(i, j, k); +@@ -113,7 +117,11 @@ + BlockPosition blockposition = new BlockPosition(j, k, l); - if (this.level.getBlockState(blockposition1).isAir() && iblockdata.canSurvive(this.level, blockposition1)) { -- this.level.setBlockAndUpdate(blockposition1, iblockdata); + if (this.level.getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level, blockposition)) { +- this.level.setBlockAndUpdate(blockposition, iblockdata); + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level, blockposition1, iblockdata, this)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level, blockposition, iblockdata, this)) { + continue; + } + // CraftBukkit end - this.level.gameEvent(GameEvent.BLOCK_PLACE, blockposition1, GameEvent.a.of(this, iblockdata)); + this.level.gameEvent(GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(this, iblockdata)); } } -@@ -151,6 +159,11 @@ +@@ -145,6 +153,11 @@ ItemStack itemstack = entityhuman.getItemInHand(enumhand); if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { @@ -45,7 +45,7 @@ this.shear(SoundCategory.PLAYERS); this.gameEvent(GameEvent.SHEAR, entityhuman); if (!this.level.isClientSide) { -@@ -170,7 +183,9 @@ +@@ -164,7 +177,9 @@ this.level.playSound((EntityHuman) null, (Entity) this, SoundEffects.SNOW_GOLEM_SHEAR, soundcategory, 1.0F, 1.0F); if (!this.level.isClientSide()) { this.setPumpkin(false); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch index 165db82c71..89f0e2e193 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityTurtle.java +++ b/net/minecraft/world/entity/animal/EntityTurtle.java -@@ -307,7 +307,9 @@ +@@ -308,7 +308,9 @@ protected void ageBoundaryReached() { super.ageBoundaryReached(); if (!this.isBaby() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { @@ -10,24 +10,28 @@ } } -@@ -334,7 +336,9 @@ +@@ -335,7 +337,9 @@ @Override public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = entitylightning; // CraftBukkit - this.hurt(DamageSource.LIGHTNING_BOLT, Float.MAX_VALUE); + this.hurt(this.damageSources().lightningBolt(), Float.MAX_VALUE); + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = null; // CraftBukkit } private static class e extends ControllerMove { -@@ -482,8 +486,12 @@ +@@ -487,12 +491,16 @@ } else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) { World world = this.turtle.level; + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), (IBlockData) Blocks.TURTLE_EGG.defaultBlockState().setValue(BlockTurtleEgg.EGGS, this.turtle.random.nextInt(4) + 1)).isCancelled()) { world.playSound((EntityHuman) null, blockposition, SoundEffects.TURTLE_LAY_EGG, SoundCategory.BLOCKS, 0.3F, 0.9F + world.random.nextFloat() * 0.2F); - world.setBlock(this.blockPos.above(), (IBlockData) Blocks.TURTLE_EGG.defaultBlockState().setValue(BlockTurtleEgg.EGGS, this.turtle.random.nextInt(4) + 1), 3); + BlockPosition blockposition1 = this.blockPos.above(); + IBlockData iblockdata = (IBlockData) Blocks.TURTLE_EGG.defaultBlockState().setValue(BlockTurtleEgg.EGGS, this.turtle.random.nextInt(4) + 1); + + world.setBlock(blockposition1, iblockdata, 3); + world.gameEvent(GameEvent.BLOCK_PLACE, blockposition1, GameEvent.a.of(this.turtle, iblockdata)); + } + // CraftBukkit end this.turtle.setHasEgg(false); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/allay/Allay.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/allay/Allay.patch index bd3542eae4..ece69d697b 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/allay/Allay.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/allay/Allay.patch @@ -39,7 +39,7 @@ } public static AttributeProvider.Builder createAttributes() { -@@ -236,7 +243,7 @@ +@@ -231,7 +238,7 @@ public void aiStep() { super.aiStep(); if (!this.level.isClientSide && this.isAlive() && this.tickCount % 10 == 0) { @@ -48,7 +48,7 @@ } if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) { -@@ -306,7 +313,12 @@ +@@ -301,7 +308,12 @@ ItemStack itemstack1 = this.getItemInHand(EnumHand.MAIN_HAND); if (this.isDancing() && this.isDuplicationItem(itemstack) && this.canDuplicate()) { @@ -62,7 +62,7 @@ this.level.broadcastEntityEvent(this, (byte) 18); this.level.playSound(entityhuman, (Entity) this, SoundEffects.AMETHYST_BLOCK_CHIME, SoundCategory.NEUTRAL, 2.0F, 1.0F); this.removeInteractionItem(entityhuman, itemstack); -@@ -318,7 +330,7 @@ +@@ -313,7 +325,7 @@ this.setItemInHand(EnumHand.MAIN_HAND, itemstack2); this.removeInteractionItem(entityhuman, itemstack); this.level.playSound(entityhuman, (Entity) this, SoundEffects.ALLAY_ITEM_GIVEN, SoundCategory.NEUTRAL, 2.0F, 1.0F); @@ -71,7 +71,7 @@ return EnumInteractionResult.SUCCESS; } else if (!itemstack1.isEmpty() && enumhand == EnumHand.MAIN_HAND && itemstack.isEmpty()) { this.setItemSlot(EnumItemSlot.MAINHAND, ItemStack.EMPTY); -@@ -439,6 +451,7 @@ +@@ -434,6 +446,7 @@ } private boolean shouldStopDancing() { @@ -79,7 +79,7 @@ return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), (double) GameEvent.JUKEBOX_PLAY.getNotificationRadius()) || !this.level.getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX); } -@@ -483,7 +496,7 @@ +@@ -478,7 +491,7 @@ public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(nbttagcompound); this.writeInventoryToTag(nbttagcompound); @@ -88,7 +88,7 @@ Logger logger = Allay.LOGGER; Objects.requireNonNull(logger); -@@ -499,7 +512,7 @@ +@@ -494,7 +507,7 @@ super.readAdditionalSaveData(nbttagcompound); this.readInventoryFromTag(nbttagcompound); if (nbttagcompound.contains("listener", 10)) { @@ -97,7 +97,7 @@ Logger logger = Allay.LOGGER; Objects.requireNonNull(logger); -@@ -532,7 +545,7 @@ +@@ -527,7 +540,7 @@ return Allay.DUPLICATION_ITEM.test(itemstack); } @@ -106,7 +106,7 @@ Allay allay = (Allay) EntityTypes.ALLAY.create(this.level); if (allay != null) { -@@ -540,17 +553,17 @@ +@@ -535,17 +548,17 @@ allay.setPersistenceRequired(); allay.resetDuplicationCooldown(); this.resetDuplicationCooldown(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch index 54e1ed8333..18e86b0297 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch @@ -27,16 +27,16 @@ } @Override -@@ -418,7 +425,7 @@ +@@ -419,7 +426,7 @@ + int i = mobeffect != null ? mobeffect.getDuration() : 0; + int j = Math.min(2400, 100 + i); - 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.addEffect(new MobEffect(MobEffects.REGENERATION, j, 0), this); ++ entityhuman.addEffect(new MobEffect(MobEffects.REGENERATION, j, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AXOLOTL); // CraftBukkit } entityhuman.removeEffect(MobEffects.DIG_SLOWDOWN); -@@ -468,7 +475,7 @@ +@@ -469,7 +476,7 @@ @Override public BehaviorController getBrain() { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch index f3517cde52..c583d674de 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java +++ b/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java -@@ -74,6 +74,8 @@ - import net.minecraft.world.phys.AxisAlignedBB; +@@ -78,6 +78,8 @@ + import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit + - public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, HasCustomInventoryScreen, IJumpable, ISaddleable { + public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, HasCustomInventoryScreen, OwnableEntity, IJumpable, ISaddleable { public static final int EQUIPMENT_SLOT_OFFSET = 400; -@@ -113,6 +115,7 @@ - private float mouthAnimO; - protected boolean canGallop = true; +@@ -139,6 +141,7 @@ protected int gallopSoundCounter; + @Nullable + private UUID owner; + public int maxDomestication = 100; // CraftBukkit - store max domestication value protected EntityHorseAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -312,7 +315,7 @@ +@@ -338,7 +341,7 @@ public void createInventory() { InventorySubcontainer inventorysubcontainer = this.inventory; @@ -26,7 +26,7 @@ if (inventorysubcontainer != null) { inventorysubcontainer.removeListener(this); int i = Math.min(inventorysubcontainer.getContainerSize(), this.inventory.getContainerSize()); -@@ -416,7 +419,7 @@ +@@ -442,7 +445,7 @@ } public int getMaxTemper() { @@ -35,7 +35,7 @@ } @Override -@@ -487,7 +490,7 @@ +@@ -513,7 +516,7 @@ } if (this.getHealth() < this.getMaxHealth() && f > 0.0F) { @@ -44,7 +44,7 @@ flag = true; } -@@ -564,7 +567,7 @@ +@@ -590,7 +593,7 @@ super.aiStep(); if (!this.level.isClientSide && this.isAlive()) { if (this.random.nextInt(900) == 0 && this.deathTime == 0) { @@ -53,7 +53,7 @@ } if (this.canEatGrass()) { -@@ -838,6 +841,7 @@ +@@ -857,6 +860,7 @@ if (this.getOwnerUUID() != null) { nbttagcompound.putUUID("Owner", this.getOwnerUUID()); } @@ -61,7 +61,7 @@ if (!this.inventory.getItem(0).isEmpty()) { nbttagcompound.put("SaddleItem", this.inventory.getItem(0).save(new NBTTagCompound())); -@@ -865,6 +869,11 @@ +@@ -884,6 +888,11 @@ if (uuid != null) { this.setOwnerUUID(uuid); } @@ -73,7 +73,7 @@ if (nbttagcompound.contains("SaddleItem", 10)) { ItemStack itemstack = ItemStack.of(nbttagcompound.getCompound("SaddleItem")); -@@ -942,6 +951,18 @@ +@@ -986,6 +995,18 @@ @Override public void handleStartJump(int i) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch b/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch index 5669175b78..29b33de614 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.java +++ b/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.java -@@ -19,6 +19,11 @@ +@@ -20,6 +20,11 @@ import net.minecraft.world.level.block.BlockFireAbstract; import net.minecraft.world.level.dimension.end.EnderDragonBattle; @@ -12,7 +12,7 @@ public class EntityEnderCrystal extends Entity { private static final DataWatcherObject> DATA_BEAM_TARGET = DataWatcher.defineId(EntityEnderCrystal.class, DataWatcherRegistry.OPTIONAL_BLOCK_POS); -@@ -54,7 +59,11 @@ +@@ -55,7 +60,11 @@ BlockPosition blockposition = this.blockPosition(); if (((WorldServer) this.level).dragonFight() != null && this.level.getBlockState(blockposition).isAir()) { @@ -25,7 +25,7 @@ } } -@@ -94,11 +103,24 @@ +@@ -95,11 +104,24 @@ return false; } else { if (!this.isRemoved() && !this.level.isClientSide) { @@ -35,8 +35,8 @@ + } + // CraftBukkit end this.remove(Entity.RemovalReason.KILLED); - if (!damagesource.isExplosion()) { - DamageSource damagesource1 = damagesource.getEntity() != null ? DamageSource.explosion(this, damagesource.getEntity()) : null; + if (!damagesource.is(DamageTypeTags.IS_EXPLOSION)) { + DamageSource damagesource1 = damagesource.getEntity() != null ? this.damageSources().explosion(this, damagesource.getEntity()) : null; - this.level.explode(this, damagesource1, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), 6.0F, false, World.a.BLOCK); + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch b/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch index 3141e7fa02..ed0b5b661d 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java +++ b/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java -@@ -50,6 +50,18 @@ +@@ -51,6 +51,18 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -19,15 +19,23 @@ public class EntityEnderDragon extends EntityInsentient implements IMonster { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -86,6 +98,7 @@ +@@ -87,6 +99,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() ++ private final Explosion explosionSource; // CraftBukkit - reusable source for CraftTNTPrimed.getSource() public EntityEnderDragon(EntityTypes entitytypes, World world) { super(EntityTypes.ENDER_DRAGON, world); -@@ -233,7 +246,7 @@ +@@ -101,6 +114,7 @@ + } + + this.phaseManager = new DragonControllerManager(this); ++ this.explosionSource = new Explosion(world, this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.Effect.DESTROY); // CraftBukkit + } + + public static AttributeProvider.Builder createAttributes() { +@@ -234,7 +248,7 @@ Vec3D vec3d1 = idragoncontroller.getFlyTargetLocation(); @@ -36,7 +44,7 @@ d0 = vec3d1.x - this.getX(); d1 = vec3d1.y - this.getY(); d2 = vec3d1.z - this.getZ(); -@@ -374,7 +387,14 @@ +@@ -375,7 +389,14 @@ if (this.nearestCrystal.isRemoved()) { this.nearestCrystal = null; } else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) { @@ -52,7 +60,7 @@ } } -@@ -449,6 +469,9 @@ +@@ -450,6 +471,9 @@ int j1 = MathHelper.floor(axisalignedbb.maxZ); boolean flag = false; boolean flag1 = false; @@ -62,7 +70,7 @@ for (int k1 = i; k1 <= l; ++k1) { for (int l1 = j; l1 <= i1; ++l1) { -@@ -458,7 +481,11 @@ +@@ -459,7 +483,11 @@ if (!iblockdata.isAir() && !iblockdata.is(TagsBlock.DRAGON_TRANSPARENT)) { if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.is(TagsBlock.DRAGON_IMMUNE)) { @@ -75,7 +83,7 @@ } else { flag = true; } -@@ -467,6 +494,51 @@ +@@ -468,6 +496,51 @@ } } @@ -127,7 +135,7 @@ if (flag1) { BlockPosition blockposition1 = new BlockPosition(i + this.random.nextInt(l - i + 1), j + this.random.nextInt(i1 - j + 1), k + this.random.nextInt(j1 - k + 1)); -@@ -531,6 +603,21 @@ +@@ -532,6 +605,21 @@ } @@ -149,7 +157,7 @@ @Override protected void tickDeath() { if (this.dragonFight != null) { -@@ -546,15 +633,20 @@ +@@ -547,15 +635,20 @@ this.level.addParticle(Particles.EXPLOSION_EMITTER, this.getX() + (double) f, this.getY() + 2.0D + (double) f1, this.getZ() + (double) f2, 0.0D, 0.0D, 0.0D); } @@ -171,16 +179,16 @@ EntityExperienceOrb.award((WorldServer) this.level, this.position(), MathHelper.floor((float) short0 * 0.08F)); } -@@ -567,7 +659,7 @@ - this.setYRot(this.getYRot() + 20.0F); - this.yBodyRot = this.getYRot(); +@@ -566,7 +659,7 @@ + + this.move(EnumMoveType.SELF, new Vec3D(0.0D, 0.10000000149011612D, 0.0D)); if (this.dragonDeathTime == 200 && this.level instanceof WorldServer) { - if (flag) { + if (true) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp EntityExperienceOrb.award((WorldServer) this.level, this.position(), MathHelper.floor((float) short0 * 0.2F)); } -@@ -788,6 +880,7 @@ +@@ -787,6 +880,7 @@ super.addAdditionalSaveData(nbttagcompound); nbttagcompound.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId()); nbttagcompound.putInt("DragonDeathTime", this.dragonDeathTime); @@ -188,7 +196,7 @@ } @Override -@@ -801,6 +894,11 @@ +@@ -800,6 +894,11 @@ this.dragonDeathTime = nbttagcompound.getInt("DragonDeathTime"); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch b/paper-server/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch index d008dc60b6..76dca9a9d5 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/wither/EntityWither.java +++ b/net/minecraft/world/entity/boss/wither/EntityWither.java -@@ -54,6 +54,17 @@ +@@ -55,6 +55,17 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.Vec3D; @@ -18,7 +18,7 @@ public class EntityWither extends EntityMonster implements PowerableMob, IRangedEntity { private static final DataWatcherObject DATA_TARGET_A = DataWatcher.defineId(EntityWither.class, DataWatcherRegistry.INT); -@@ -247,15 +258,40 @@ +@@ -248,15 +259,40 @@ i = this.getInvulnerableTicks() - 1; this.bossEvent.setProgress(1.0F - (float) i / 220.0F); if (i <= 0) { @@ -62,7 +62,7 @@ } } else { -@@ -300,6 +336,7 @@ +@@ -301,6 +337,7 @@ if (!list.isEmpty()) { EntityLiving entityliving1 = (EntityLiving) list.get(this.random.nextInt(list.size())); @@ -70,7 +70,7 @@ this.setAlternativeTarget(i, entityliving1.getId()); } } -@@ -330,6 +367,11 @@ +@@ -331,6 +368,11 @@ IBlockData iblockdata = this.level.getBlockState(blockposition); if (canDestroy(iblockdata)) { @@ -82,7 +82,7 @@ flag = this.level.destroyBlock(blockposition, true, this) || flag; } } -@@ -343,7 +385,7 @@ +@@ -344,7 +386,7 @@ } if (this.tickCount % 20 == 0) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch index 8e68e94c9b..0c84531e3e 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/EntityArmorStand.java +++ b/net/minecraft/world/entity/decoration/EntityArmorStand.java -@@ -43,6 +43,15 @@ +@@ -44,6 +44,15 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -16,7 +16,7 @@ public class EntityArmorStand extends EntityLiving { public static final int WOBBLE_TIME = 5; -@@ -105,6 +114,13 @@ +@@ -106,6 +115,13 @@ this.setPos(d0, d1, d2); } @@ -30,7 +30,7 @@ @Override public void refreshDimensions() { double d0 = this.getX(); -@@ -160,13 +176,20 @@ +@@ -161,13 +177,20 @@ @Override public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { @@ -53,7 +53,7 @@ } } -@@ -402,6 +425,22 @@ +@@ -403,6 +426,22 @@ return false; } else { ItemStack itemstack2; @@ -76,10 +76,10 @@ if (entityhuman.getAbilities().instabuild && itemstack1.isEmpty() && !itemstack.isEmpty()) { itemstack2 = itemstack.copy(); -@@ -430,9 +469,19 @@ +@@ -431,9 +470,19 @@ public boolean hurt(DamageSource damagesource, float f) { if (!this.level.isClientSide && !this.isRemoved()) { - if (DamageSource.OUT_OF_WORLD.equals(damagesource)) { + if (damagesource.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { + return false; @@ -94,24 +94,24 @@ + return false; + } + // CraftBukkit end - if (damagesource.isExplosion()) { + if (damagesource.is(DamageTypeTags.IS_EXPLOSION)) { this.brokenByAnything(damagesource); this.kill(); -@@ -472,7 +521,7 @@ - } else { - this.brokenByPlayer(damagesource); - this.showBreakingParticles(); -- this.kill(); -+ this.discard(); // CraftBukkit - SPIGOT-4890: remain as this.die() since above damagesource method will call death event - } +@@ -482,7 +531,7 @@ + } else { + this.brokenByPlayer(damagesource); + this.showBreakingParticles(); +- this.kill(); ++ this.discard(); // CraftBukkit - SPIGOT-4890: remain as this.discard() since above damagesource method will call death event + } - return true; -@@ -533,13 +582,13 @@ - } + return true; +@@ -550,13 +599,13 @@ + itemstack.setHoverName(this.getCustomName()); + } - private void brokenByPlayer(DamageSource damagesource) { -- Block.popResource(this.level, this.blockPosition(), new ItemStack(Items.ARMOR_STAND)); -+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(new ItemStack(Items.ARMOR_STAND))); // CraftBukkit - add to drops +- Block.popResource(this.level, this.blockPosition(), itemstack); ++ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops this.brokenByAnything(damagesource); } @@ -122,7 +122,7 @@ ItemStack itemstack; int i; -@@ -547,7 +596,7 @@ +@@ -564,7 +613,7 @@ for (i = 0; i < this.handItems.size(); ++i) { itemstack = (ItemStack) this.handItems.get(i); if (!itemstack.isEmpty()) { @@ -131,7 +131,7 @@ this.handItems.set(i, ItemStack.EMPTY); } } -@@ -555,10 +604,11 @@ +@@ -572,10 +621,11 @@ for (i = 0; i < this.armorItems.size(); ++i) { itemstack = (ItemStack) this.armorItems.get(i); if (!itemstack.isEmpty()) { @@ -144,7 +144,7 @@ } -@@ -659,8 +709,16 @@ +@@ -676,8 +726,16 @@ return this.isSmall(); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityHanging.patch b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityHanging.patch index e993f26170..f39a39136f 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityHanging.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityHanging.patch @@ -5,7 +5,7 @@ import org.slf4j.Logger; +// CraftBukkit start -+import net.minecraft.world.damagesource.EntityDamageSourceIndirect; ++import net.minecraft.tags.DamageTypeTags; +import net.minecraft.world.level.material.Material; +import org.bukkit.entity.Hanging; +import org.bukkit.event.hanging.HangingBreakByEntityEvent; @@ -111,12 +111,12 @@ } else { if (!this.isRemoved() && !this.level.isClientSide) { + // CraftBukkit start - fire break events -+ Entity damager = (damagesource instanceof EntityDamageSourceIndirect) ? ((EntityDamageSourceIndirect) damagesource).getProximateDamageSource() : damagesource.getEntity(); ++ Entity damager = (damagesource.isIndirect()) ? damagesource.getEntity() : damagesource.getDirectEntity(); + HangingBreakEvent event; + if (damager != null) { -+ event = new HangingBreakByEntityEvent((Hanging) this.getBukkitEntity(), damager.getBukkitEntity(), damagesource.isExplosion() ? HangingBreakEvent.RemoveCause.EXPLOSION : HangingBreakEvent.RemoveCause.ENTITY); ++ event = new HangingBreakByEntityEvent((Hanging) this.getBukkitEntity(), damager.getBukkitEntity(), damagesource.is(DamageTypeTags.IS_EXPLOSION) ? HangingBreakEvent.RemoveCause.EXPLOSION : HangingBreakEvent.RemoveCause.ENTITY); + } else { -+ event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), damagesource.isExplosion() ? HangingBreakEvent.RemoveCause.EXPLOSION : HangingBreakEvent.RemoveCause.DEFAULT); ++ event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), damagesource.is(DamageTypeTags.IS_EXPLOSION) ? HangingBreakEvent.RemoveCause.EXPLOSION : HangingBreakEvent.RemoveCause.DEFAULT); + } + + this.level.getCraftServer().getPluginManager().callEvent(event); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch index 05c00ed41a..1207997e69 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/EntityItemFrame.java +++ b/net/minecraft/world/entity/decoration/EntityItemFrame.java -@@ -94,16 +94,27 @@ +@@ -96,16 +96,27 @@ @Override protected void recalculateBoundingBox() { if (this.direction != null) { @@ -37,7 +37,7 @@ switch (enumdirection_enumaxis) { case X: -@@ -119,9 +130,10 @@ +@@ -121,9 +132,10 @@ d4 /= 32.0D; d5 /= 32.0D; d6 /= 32.0D; @@ -49,9 +49,9 @@ @Override public boolean survives() { -@@ -171,6 +183,11 @@ +@@ -173,6 +185,11 @@ return false; - } else if (!damagesource.isExplosion() && !this.getItem().isEmpty()) { + } else if (!damagesource.is(DamageTypeTags.IS_EXPLOSION) && !this.getItem().isEmpty()) { if (!this.level.isClientSide) { + // CraftBukkit start - fire EntityDamageEvent + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false) || this.isRemoved()) { @@ -59,9 +59,9 @@ + } + // CraftBukkit end this.dropItem(damagesource.getEntity(), false); + this.gameEvent(GameEvent.BLOCK_CHANGE, damagesource.getEntity()); this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F); - } -@@ -298,6 +315,12 @@ +@@ -302,6 +319,12 @@ } public void setItem(ItemStack itemstack, boolean flag) { @@ -74,7 +74,7 @@ if (!itemstack.isEmpty()) { itemstack = itemstack.copy(); itemstack.setCount(1); -@@ -305,7 +328,7 @@ +@@ -309,7 +332,7 @@ this.onItemChanged(itemstack); this.getEntityData().set(EntityItemFrame.DATA_ITEM, itemstack); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch index aee917fc7c..e07f3e2b8b 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/EntityLeash.java +++ b/net/minecraft/world/entity/decoration/EntityLeash.java -@@ -25,6 +25,12 @@ +@@ -26,6 +26,12 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -13,9 +13,9 @@ public class EntityLeash extends EntityHanging { public static final double OFFSET_Y = 0.375D; -@@ -96,22 +102,42 @@ - while (iterator.hasNext()) { - entityinsentient = (EntityInsentient) iterator.next(); +@@ -96,6 +102,12 @@ + EntityInsentient entityinsentient = (EntityInsentient) iterator.next(); + if (entityinsentient.getLeashHolder() == entityhuman) { + // CraftBukkit start + if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman, enumhand).isCancelled()) { @@ -26,7 +26,8 @@ entityinsentient.setLeashedTo(this, true); flag = true; } - } +@@ -104,18 +116,32 @@ + boolean flag1 = false; if (!flag) { - this.discard(); @@ -36,19 +37,21 @@ + boolean die = true; + // CraftBukkit end + if (true || entityhuman.getAbilities().instabuild) { // CraftBukkit - Process for non-creative as well - iterator = list.iterator(); + Iterator iterator1 = list.iterator(); - while (iterator.hasNext()) { - entityinsentient = (EntityInsentient) iterator.next(); - if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == this) { -- entityinsentient.dropLeash(true, false); + while (iterator1.hasNext()) { + EntityInsentient entityinsentient1 = (EntityInsentient) iterator1.next(); + + if (entityinsentient1.isLeashed() && entityinsentient1.getLeashHolder() == this) { +- entityinsentient1.dropLeash(true, false); + // CraftBukkit start -+ if (CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient, entityhuman, enumhand).isCancelled()) { ++ if (CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient1, entityhuman, enumhand).isCancelled()) { + die = false; + continue; + } -+ entityinsentient.dropLeash(true, !entityhuman.getAbilities().instabuild); // false -> survival mode boolean ++ entityinsentient1.dropLeash(true, !entityhuman.getAbilities().instabuild); // false -> survival mode boolean + // CraftBukkit end + flag1 = true; } } + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch index cf5861eaa8..1944e092e1 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/EntityFallingBlock.java +++ b/net/minecraft/world/entity/item/EntityFallingBlock.java -@@ -48,6 +48,8 @@ +@@ -49,6 +49,8 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -9,7 +9,7 @@ public class EntityFallingBlock extends Entity { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -82,10 +84,17 @@ +@@ -83,10 +85,17 @@ } public static EntityFallingBlock fall(World world, BlockPosition blockposition, IBlockData iblockdata) { @@ -28,7 +28,7 @@ return entityfallingblock; } -@@ -168,6 +177,12 @@ +@@ -169,6 +178,12 @@ this.blockState = (IBlockData) this.blockState.setValue(BlockProperties.WATERLOGGED, true); } @@ -41,7 +41,7 @@ if (this.level.setBlock(blockposition, this.blockState, 3)) { ((WorldServer) this.level).getChunkSource().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition))); this.discard(); -@@ -238,7 +253,7 @@ +@@ -239,7 +254,7 @@ if (i < 0) { return false; } else { @@ -50,7 +50,7 @@ DamageSource damagesource1; if (this.blockState.getBlock() instanceof Fallable) { -@@ -254,7 +269,9 @@ +@@ -255,7 +270,9 @@ float f2 = (float) Math.min(MathHelper.floor((float) i * this.fallDamagePerDistance), this.fallDamageMax); this.level.getEntities((Entity) this, this.getBoundingBox(), predicate).forEach((entity) -> { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityItem.patch b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityItem.patch index d8903753ed..fdd0a7adee 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityItem.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityItem.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/EntityItem.java +++ b/net/minecraft/world/entity/item/EntityItem.java -@@ -30,6 +30,12 @@ +@@ -31,6 +31,12 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.Vec3D; @@ -10,18 +10,18 @@ +import org.bukkit.event.player.PlayerPickupItemEvent; +// CraftBukkit end + - public class EntityItem extends Entity { + public class EntityItem extends Entity implements TraceableEntity { private static final DataWatcherObject DATA_ITEM = DataWatcher.defineId(EntityItem.class, DataWatcherRegistry.ITEM_STACK); -@@ -44,6 +50,7 @@ +@@ -45,6 +51,7 @@ @Nullable - private UUID owner; + public UUID target; public final float bobOffs; + private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit public EntityItem(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -101,9 +108,12 @@ +@@ -110,9 +117,12 @@ this.discard(); } else { super.tick(); @@ -37,7 +37,7 @@ this.xo = this.getX(); this.yo = this.getY(); -@@ -153,9 +163,11 @@ +@@ -162,9 +172,11 @@ this.mergeWithNeighbours(); } @@ -49,7 +49,7 @@ this.hasImpulse |= this.updateInWaterStateAndDoFluidPushing(); if (!this.level.isClientSide) { -@@ -167,6 +179,12 @@ +@@ -176,6 +188,12 @@ } if (!this.level.isClientSide && this.age >= 6000) { @@ -62,7 +62,7 @@ this.discard(); } -@@ -242,10 +260,11 @@ +@@ -251,10 +269,11 @@ private static void merge(EntityItem entityitem, ItemStack itemstack, ItemStack itemstack1) { ItemStack itemstack2 = merge(itemstack, itemstack1, 64); @@ -75,7 +75,7 @@ merge(entityitem, itemstack, itemstack1); entityitem.pickupDelay = Math.max(entityitem.pickupDelay, entityitem1.pickupDelay); entityitem.age = Math.min(entityitem.age, entityitem1.age); -@@ -271,6 +290,11 @@ +@@ -280,6 +299,11 @@ } else if (this.level.isClientSide) { return true; } else { @@ -87,7 +87,7 @@ this.markHurt(); this.health = (int) ((float) this.health - f); this.gameEvent(GameEvent.ENTITY_DAMAGE, damagesource.getEntity()); -@@ -334,6 +358,46 @@ +@@ -343,6 +367,46 @@ Item item = itemstack.getItem(); int i = itemstack.getCount(); @@ -131,10 +131,10 @@ + } + // CraftBukkit end + - if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(entityhuman.getUUID())) && entityhuman.getInventory().add(itemstack)) { + if (this.pickupDelay == 0 && (this.target == null || this.target.equals(entityhuman.getUUID())) && entityhuman.getInventory().add(itemstack)) { entityhuman.take(this, i); if (itemstack.isEmpty()) { -@@ -377,7 +441,9 @@ +@@ -386,7 +450,9 @@ } public void setItem(ItemStack itemstack) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch index 41f495b050..c88f4c1d9b 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/entity/item/EntityTNTPrimed.java +++ b/net/minecraft/world/entity/item/EntityTNTPrimed.java -@@ -14,12 +14,16 @@ - import net.minecraft.world.entity.EnumMoveType; +@@ -15,12 +15,16 @@ + import net.minecraft.world.entity.TraceableEntity; import net.minecraft.world.level.World; +import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit + - public class EntityTNTPrimed extends Entity { + public class EntityTNTPrimed extends Entity implements TraceableEntity { private static final DataWatcherObject DATA_FUSE_ID = DataWatcher.defineId(EntityTNTPrimed.class, DataWatcherRegistry.INT); private static final int DEFAULT_FUSE_TIME = 80; @@ -17,7 +17,7 @@ public EntityTNTPrimed(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -70,10 +74,13 @@ +@@ -71,10 +75,13 @@ this.setFuse(i); if (i <= 0) { @@ -32,7 +32,7 @@ } else { this.updateInWaterStateAndDoFluidPushing(); if (this.level.isClientSide) { -@@ -84,9 +91,16 @@ +@@ -85,9 +92,16 @@ } private void explode() { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch index 52cb0fb0cc..3b3589608a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch @@ -34,7 +34,7 @@ @Override protected EnumInteractionResult mobInteract(EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.getItemInHand(enumhand); -@@ -246,10 +262,18 @@ +@@ -250,10 +266,18 @@ if (!this.level.isClientSide) { float f = this.isPowered() ? 2.0F : 1.0F; @@ -57,7 +57,7 @@ } } -@@ -260,6 +284,7 @@ +@@ -264,6 +288,7 @@ if (!collection.isEmpty()) { EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level, this.getX(), this.getY(), this.getZ()); @@ -65,7 +65,7 @@ entityareaeffectcloud.setRadius(2.5F); entityareaeffectcloud.setRadiusOnUse(-0.5F); entityareaeffectcloud.setWaitTime(10); -@@ -273,7 +298,7 @@ +@@ -277,7 +302,7 @@ entityareaeffectcloud.addEffect(new MobEffect(mobeffect)); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityDrowned.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityDrowned.patch index f0e16cd30f..b6916ad7b4 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityDrowned.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityDrowned.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityDrowned.java +++ b/net/minecraft/world/entity/monster/EntityDrowned.java -@@ -239,7 +239,7 @@ +@@ -244,7 +244,7 @@ @Override public void performRangedAttack(EntityLiving entityliving, float f) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch index 1dc295b04a..2295a5b1f3 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch @@ -27,7 +27,7 @@ } -@@ -490,9 +501,13 @@ +@@ -487,9 +498,13 @@ if (iblockdata2 != null) { iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level, blockposition); if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) { @@ -41,7 +41,7 @@ } } -@@ -531,9 +546,13 @@ +@@ -528,9 +543,13 @@ boolean flag = movingobjectpositionblock.getBlockPos().equals(blockposition); if (iblockdata.is(TagsBlock.ENDERMAN_HOLDABLE) && flag) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch index e4fc48213c..529a384433 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityPhantom.java +++ b/net/minecraft/world/entity/monster/EntityPhantom.java -@@ -533,14 +533,14 @@ +@@ -538,14 +538,14 @@ List list = EntityPhantom.this.level.getNearbyPlayers(this.attackTargeting, EntityPhantom.this, EntityPhantom.this.getBoundingBox().inflate(16.0D, 64.0D, 16.0D)); if (!list.isEmpty()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch index 45849f2f2b..3baa64d8f3 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityRavager.java +++ b/net/minecraft/world/entity/monster/EntityRavager.java -@@ -171,7 +171,7 @@ +@@ -170,7 +170,7 @@ IBlockData iblockdata = this.level.getBlockState(blockposition); Block block = iblockdata.getBlock(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch index 2c77b6759d..84067d66dd 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityShulker.java +++ b/net/minecraft/world/entity/monster/EntityShulker.java -@@ -59,6 +59,12 @@ +@@ -60,6 +60,12 @@ import net.minecraft.world.phys.Vec3D; import org.joml.Vector3f; @@ -13,7 +13,7 @@ public class EntityShulker extends EntityGolem implements VariantHolder>, IMonster { private static final UUID COVERED_ARMOR_MODIFIER_UUID = UUID.fromString("7E0292F2-9434-48D5-A29F-9583AF7DF27F"); -@@ -407,6 +413,16 @@ +@@ -408,6 +414,16 @@ EnumDirection enumdirection = this.findAttachableSurface(blockposition1); if (enumdirection != null) { @@ -22,7 +22,7 @@ + this.level.getCraftServer().getPluginManager().callEvent(teleport); + if (!teleport.isCancelled()) { + Location to = teleport.getTo(); -+ blockposition1 = new BlockPosition(to.getX(), to.getY(), to.getZ()); ++ blockposition1 = BlockPosition.containing(to.getX(), to.getY(), to.getZ()); + } else { + return false; + } @@ -30,7 +30,7 @@ this.unRide(); this.setAttachFace(enumdirection); this.playSound(SoundEffects.SHULKER_TELEPORT, 1.0F, 1.0F); -@@ -477,7 +493,7 @@ +@@ -478,7 +494,7 @@ if (entityshulker != null) { entityshulker.setVariant(this.getVariant()); entityshulker.moveTo(vec3d); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch index 5a06d75c2b..cf31770d49 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java +++ b/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java -@@ -197,8 +197,19 @@ +@@ -200,8 +200,19 @@ double d3 = Math.sqrt(d0 * d0 + d2 * d2); entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.level.getDifficulty().getId() * 4)); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySpider.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySpider.patch index f09ac2ca82..4ba9a4b61c 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySpider.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySpider.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/monster/EntitySpider.java +++ b/net/minecraft/world/entity/monster/EntitySpider.java -@@ -179,7 +179,7 @@ - MobEffectList mobeffectlist = ((EntitySpider.GroupDataSpider) object).effect; +@@ -180,7 +180,7 @@ + MobEffectList mobeffectlist = entityspider_groupdataspider.effect; if (mobeffectlist != null) { -- this.addEffect(new MobEffect(mobeffectlist, Integer.MAX_VALUE)); -+ this.addEffect(new MobEffect(mobeffectlist, Integer.MAX_VALUE), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN); // CraftBukkit +- this.addEffect(new MobEffect(mobeffectlist, -1)); ++ this.addEffect(new MobEffect(mobeffectlist, -1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN); // CraftBukkit } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch index 6dd3aa911f..66789b5315 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch @@ -1,14 +1,15 @@ --- a/net/minecraft/world/entity/monster/EntityStrider.java +++ b/net/minecraft/world/entity/monster/EntityStrider.java -@@ -320,7 +320,13 @@ - IBlockData iblockdata1 = this.getBlockStateOnLegacy(); - boolean flag = iblockdata.is(TagsBlock.STRIDER_WARM_BLOCKS) || iblockdata1.is(TagsBlock.STRIDER_WARM_BLOCKS) || this.getFluidHeight(TagsFluid.LAVA) > 0.0D; +@@ -349,7 +349,14 @@ -- this.setSuffocating(!flag); + boolean flag2 = flag1; + +- this.setSuffocating(!flag || flag2); + // CraftBukkit start -+ if (!flag ^ this.isSuffocating()) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callStriderTemperatureChangeEvent(this, !flag)) { -+ this.setSuffocating(!flag); ++ boolean suffocating = !flag || flag2; ++ if (suffocating ^ this.isSuffocating()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callStriderTemperatureChangeEvent(this, suffocating)) { ++ this.setSuffocating(suffocating); + } + } + // CraftBukkit end diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch index e6995b4a0b..d56a27fc76 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityVex.java +++ b/net/minecraft/world/entity/monster/EntityVex.java -@@ -386,7 +386,7 @@ +@@ -388,7 +388,7 @@ @Override public void start() { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch index d82ea1e0c1..e1ca8f1a91 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityWitch.java +++ b/net/minecraft/world/entity/monster/EntityWitch.java -@@ -131,7 +131,7 @@ +@@ -132,7 +132,7 @@ while (iterator.hasNext()) { MobEffect mobeffect = (MobEffect) iterator.next(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch b/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch index 92f87d2ddf..65f712b008 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch @@ -47,8 +47,8 @@ + // CraftBukkit end } - this.lastRestockGameTime = this.level.getGameTime(); -@@ -417,7 +431,13 @@ + this.resendOffersToTradingPlayer(); +@@ -428,7 +442,13 @@ while (iterator.hasNext()) { MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next(); @@ -63,7 +63,7 @@ } } -@@ -476,7 +496,7 @@ +@@ -488,7 +508,7 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(nbttagcompound); @@ -72,7 +72,7 @@ Logger logger = EntityVillager.LOGGER; Objects.requireNonNull(logger); -@@ -820,7 +840,12 @@ +@@ -832,7 +852,12 @@ } entitywitch.setPersistenceRequired(); @@ -86,7 +86,7 @@ this.releaseAllPois(); this.discard(); } else { -@@ -909,7 +934,7 @@ +@@ -921,7 +946,7 @@ }).limit(5L).collect(Collectors.toList()); if (list1.size() >= j) { @@ -95,7 +95,7 @@ list.forEach(SensorGolemLastSeen::golemDetected); } } -@@ -966,7 +991,7 @@ +@@ -978,7 +1003,7 @@ @Override public void startSleeping(BlockPosition blockposition) { super.startSleeping(blockposition); @@ -104,7 +104,7 @@ this.brain.eraseMemory(MemoryModuleType.WALK_TARGET); this.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); } -@@ -974,7 +999,7 @@ +@@ -986,7 +1011,7 @@ @Override public void stopSleeping() { super.stopSleeping(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch b/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch index a3be4da981..602578a506 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/npc/EntityVillagerTrader.java +++ b/net/minecraft/world/entity/npc/EntityVillagerTrader.java -@@ -44,6 +44,13 @@ - import net.minecraft.world.level.World; +@@ -46,6 +46,13 @@ import net.minecraft.world.phys.Vec3D; + import org.apache.commons.lang3.ArrayUtils; +// CraftBukkit start +import org.bukkit.Bukkit; @@ -14,7 +14,7 @@ public class EntityVillagerTrader extends EntityVillagerAbstract { private static final int NUMBER_OF_TRADE_OFFERS = 5; -@@ -53,6 +60,7 @@ +@@ -55,6 +62,7 @@ public EntityVillagerTrader(EntityTypes entitytypes, World world) { super(entitytypes, world); @@ -22,7 +22,7 @@ } @Override -@@ -130,7 +138,16 @@ +@@ -140,7 +148,16 @@ MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.getOffer(this, this.random); if (merchantrecipe != null) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch b/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch index 644b9ac2c7..e5c4cf16c3 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/EntityHuman.java +++ b/net/minecraft/world/entity/player/EntityHuman.java -@@ -115,6 +115,20 @@ +@@ -117,6 +117,20 @@ import net.minecraft.world.scores.ScoreboardTeamBase; import org.slf4j.Logger; @@ -21,7 +21,7 @@ public abstract class EntityHuman extends EntityLiving { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -128,7 +142,8 @@ +@@ -130,7 +144,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.scalable(0.6F, 1.8F); @@ -31,7 +31,7 @@ private static final int FLY_ACHIEVEMENT_SPEED = 25; private static final DataWatcherObject DATA_PLAYER_ABSORPTION_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.FLOAT); private static final DataWatcherObject DATA_SCORE_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.INT); -@@ -138,10 +153,10 @@ +@@ -140,10 +155,10 @@ protected static final DataWatcherObject DATA_SHOULDER_RIGHT = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.COMPOUND_TAG); private long timeEntitySatOnShoulder; private final PlayerInventory inventory = new PlayerInventory(this); @@ -44,18 +44,9 @@ protected int jumpTriggerTime; public float oBob; public float bob; -@@ -158,7 +173,7 @@ - public int experienceLevel; - public int totalExperience; - public float experienceProgress; -- protected int enchantmentSeed; -+ public int enchantmentSeed; - protected final float defaultFlySpeed = 0.02F; - private int lastLevelUpTime; - private final GameProfile gameProfile; -@@ -169,6 +184,16 @@ - @Nullable +@@ -172,6 +187,16 @@ public EntityFishingHook fishing; + protected float hurtDir; + // CraftBukkit start + public boolean fauxSleeping; @@ -70,7 +61,7 @@ public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile) { super(EntityTypes.PLAYER, world); this.lastItemInMainHand = ItemStack.EMPTY; -@@ -308,7 +333,7 @@ +@@ -311,7 +336,7 @@ ItemStack itemstack = this.getItemBySlot(EnumItemSlot.HEAD); if (itemstack.is(Items.TURTLE_HELMET) && !this.isEyeInFluid(TagsFluid.WATER)) { @@ -79,7 +70,7 @@ } } -@@ -502,7 +527,8 @@ +@@ -505,7 +530,8 @@ if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL && this.level.getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { if (this.getHealth() < this.getMaxHealth() && this.tickCount % 20 == 0) { @@ -89,7 +80,7 @@ } if (this.foodData.needsFood() && this.tickCount % 10 == 0) { -@@ -666,6 +692,13 @@ +@@ -664,6 +690,13 @@ @Nullable public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1) { @@ -103,7 +94,7 @@ if (itemstack.isEmpty()) { return null; } else { -@@ -700,6 +733,33 @@ +@@ -698,6 +731,33 @@ entityitem.setDeltaMovement((double) (-f3 * f2 * 0.3F) + Math.cos((double) f5) * (double) f6, (double) (-f1 * 0.3F + 0.1F + (this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (f4 * f2 * 0.3F) + Math.sin((double) f5) * (double) f6); } @@ -137,7 +128,7 @@ return entityitem; } } -@@ -790,7 +850,7 @@ +@@ -788,7 +848,7 @@ } if (nbttagcompound.contains("LastDeathLocation", 10)) { @@ -146,7 +137,7 @@ Logger logger = EntityHuman.LOGGER; Objects.requireNonNull(logger); -@@ -823,7 +883,7 @@ +@@ -821,7 +881,7 @@ } this.getLastDeathLocation().flatMap((globalpos) -> { @@ -155,7 +146,7 @@ Logger logger = EntityHuman.LOGGER; Objects.requireNonNull(logger); -@@ -850,12 +910,12 @@ +@@ -848,12 +908,12 @@ return false; } else { if (!this.level.isClientSide) { @@ -170,7 +161,7 @@ } if (this.level.getDifficulty() == EnumDifficulty.EASY) { -@@ -867,7 +927,13 @@ +@@ -865,7 +925,13 @@ } } @@ -185,7 +176,7 @@ } } } -@@ -887,10 +953,29 @@ +@@ -885,10 +951,29 @@ } public boolean canHarmPlayer(EntityHuman entityhuman) { @@ -218,7 +209,7 @@ } @Override -@@ -932,8 +1017,13 @@ +@@ -930,8 +1015,13 @@ } } @@ -233,7 +224,7 @@ if (!this.isInvulnerableTo(damagesource)) { f = this.getDamageAfterArmorAbsorb(damagesource, f); f = this.getDamageAfterMagicAbsorb(damagesource, f); -@@ -948,7 +1038,7 @@ +@@ -946,7 +1036,7 @@ } if (f != 0.0F) { @@ -241,8 +232,8 @@ + this.causeFoodExhaustion(damagesource.getFoodExhaustion(), EntityExhaustionEvent.ExhaustionReason.DAMAGED); // CraftBukkit - EntityExhaustionEvent float f3 = this.getHealth(); - this.setHealth(this.getHealth() - f); -@@ -959,6 +1049,7 @@ + this.getCombatTracker().recordDamage(damagesource, f3, f); +@@ -957,6 +1047,7 @@ } } @@ -250,7 +241,7 @@ } @Override -@@ -1122,7 +1213,7 @@ +@@ -1121,7 +1212,7 @@ f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; @@ -259,7 +250,7 @@ if (f > 0.0F || f1 > 0.0F) { boolean flag = f2 > 0.9F; boolean flag1 = false; -@@ -1161,8 +1252,15 @@ +@@ -1160,8 +1251,15 @@ if (entity instanceof EntityLiving) { f3 = ((EntityLiving) entity).getHealth(); if (j > 0 && !entity.isOnFire()) { @@ -277,20 +268,20 @@ } } -@@ -1190,8 +1288,11 @@ +@@ -1189,8 +1287,11 @@ EntityLiving entityliving = (EntityLiving) iterator.next(); if (entityliving != this && entityliving != entity && !this.isAlliedTo((Entity) entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) { + // CraftBukkit start - Only apply knockback if the damage hits -+ if (entityliving.hurt(DamageSource.playerAttack(this).sweep(), f4)) { ++ if (entityliving.hurt(this.damageSources().playerAttack(this).sweep(), f4)) { entityliving.knockback(0.4000000059604645D, (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F))); -- entityliving.hurt(DamageSource.playerAttack(this), f4); +- entityliving.hurt(this.damageSources().playerAttack(this), f4); + } + // CraftBukkit end } } -@@ -1200,9 +1301,26 @@ +@@ -1199,9 +1300,26 @@ } if (entity instanceof EntityPlayer && entity.hurtMarked) { @@ -317,7 +308,7 @@ } if (flag2) { -@@ -1247,7 +1365,14 @@ +@@ -1246,7 +1364,14 @@ this.awardStat(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F)); if (j > 0) { @@ -333,7 +324,7 @@ } if (this.level instanceof WorldServer && f5 > 2.0F) { -@@ -1257,12 +1382,17 @@ +@@ -1256,12 +1381,17 @@ } } @@ -352,7 +343,7 @@ } } -@@ -1339,6 +1469,12 @@ +@@ -1338,6 +1468,12 @@ } public Either startSleepInBed(BlockPosition blockposition) { @@ -365,7 +356,7 @@ this.startSleeping(blockposition); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1423,9 +1559,9 @@ +@@ -1422,9 +1558,9 @@ super.jumpFromGround(); this.awardStat(StatisticList.JUMP); if (this.isSprinting()) { @@ -377,9 +368,9 @@ } } -@@ -1459,7 +1595,11 @@ +@@ -1454,7 +1590,11 @@ + this.setDeltaMovement(vec3d2.x, d3 * 0.6D, vec3d2.z); - this.flyingSpeed = f; this.resetFallDistance(); - this.setSharedFlag(7, false); + // CraftBukkit start @@ -390,7 +381,7 @@ } else { super.travel(vec3d); } -@@ -1494,19 +1634,19 @@ +@@ -1489,19 +1629,19 @@ i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); if (i > 0) { this.awardStat(StatisticList.SWIM_ONE_CM, i); @@ -413,7 +404,7 @@ } } else if (this.onClimbable()) { if (d1 > 0.0D) { -@@ -1517,13 +1657,13 @@ +@@ -1512,13 +1652,13 @@ if (i > 0) { if (this.isSprinting()) { this.awardStat(StatisticList.SPRINT_ONE_CM, i); @@ -430,7 +421,7 @@ } } } else if (this.isFallFlying()) { -@@ -1589,12 +1729,24 @@ +@@ -1584,12 +1724,24 @@ } public void startFallFlying() { @@ -456,7 +447,7 @@ } @Override -@@ -1685,10 +1837,21 @@ +@@ -1680,10 +1832,21 @@ return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2); } @@ -479,7 +470,7 @@ } } -@@ -1774,13 +1937,20 @@ +@@ -1769,13 +1932,20 @@ @Override public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { @@ -503,7 +494,7 @@ } } -@@ -1819,26 +1989,31 @@ +@@ -1814,26 +1984,31 @@ protected void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level.getGameTime()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch b/paper-server/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch index deb27b2717..b579293e22 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/PlayerInventory.java +++ b/net/minecraft/world/entity/player/PlayerInventory.java -@@ -25,6 +25,13 @@ +@@ -26,6 +26,13 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.IBlockData; @@ -14,7 +14,7 @@ public class PlayerInventory implements IInventory, INamableTileEntity { public static final int POP_TIME_DURATION = 5; -@@ -42,6 +49,54 @@ +@@ -43,6 +50,54 @@ public final EntityHuman player; private int timesChanged; @@ -69,7 +69,7 @@ public PlayerInventory(EntityHuman entityhuman) { this.items = NonNullList.withSize(36, ItemStack.EMPTY); this.armor = NonNullList.withSize(4, ItemStack.EMPTY); -@@ -62,6 +117,28 @@ +@@ -63,6 +118,28 @@ return !itemstack.isEmpty() && ItemStack.isSameItemSameTags(itemstack, itemstack1) && itemstack.isStackable() && itemstack.getCount() < itemstack.getMaxStackSize() && itemstack.getCount() < this.getMaxStackSize(); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch index a63e15e5c1..d0ff328bb8 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityEgg.java +++ b/net/minecraft/world/entity/projectile/EntityEgg.java -@@ -12,6 +12,15 @@ +@@ -11,6 +11,15 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.MovingObjectPositionEntity; @@ -16,7 +16,7 @@ public class EntityEgg extends EntityProjectileThrowable { public EntityEgg(EntityTypes entitytypes, World world) { -@@ -48,22 +57,42 @@ +@@ -47,22 +56,42 @@ protected void onHit(MovingObjectPosition movingobjectposition) { super.onHit(movingobjectposition); if (!this.level.isClientSide) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch index d1d1d52ceb..c3332e0182 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityEnderPearl.java +++ b/net/minecraft/world/entity/projectile/EntityEnderPearl.java -@@ -17,6 +17,13 @@ +@@ -16,6 +16,13 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.MovingObjectPositionEntity; @@ -14,10 +14,10 @@ public class EntityEnderPearl extends EntityProjectileThrowable { public EntityEnderPearl(EntityTypes entitytypes, World world) { -@@ -53,23 +60,36 @@ +@@ -52,23 +59,36 @@ EntityPlayer entityplayer = (EntityPlayer) entity; - if (entityplayer.connection.getConnection().isConnected() && entityplayer.level == this.level && !entityplayer.isSleeping()) { + if (entityplayer.connection.isAcceptingMessages() && entityplayer.level == this.level && !entityplayer.isSleeping()) { - if (this.random.nextFloat() < 0.05F && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { - EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(this.level); + // CraftBukkit start - Fire PlayerTeleportEvent @@ -29,7 +29,7 @@ + PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL); + Bukkit.getPluginManager().callEvent(teleEvent); + -+ if (!teleEvent.isCancelled() && !entityplayer.connection.isDisconnected()) { ++ if (!teleEvent.isCancelled() && !entityplayer.connection.isAcceptingMessages()) { + if (this.random.nextFloat() < 0.05F && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { + EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(this.level); + @@ -54,17 +54,17 @@ + entityplayer.connection.teleport(teleEvent.getTo()); + entity.resetFallDistance(); + CraftEventFactory.entityDamage = this; -+ entity.hurt(DamageSource.FALL, 5.0F); ++ entity.hurt(this.damageSources().fall(), 5.0F); + CraftEventFactory.entityDamage = null; } - - entity.resetFallDistance(); -- entity.hurt(DamageSource.FALL, 5.0F); +- entity.hurt(this.damageSources().fall(), 5.0F); + // CraftBukkit end } } else if (entity != null) { entity.teleportTo(this.getX(), this.getY(), this.getZ()); -@@ -98,7 +118,7 @@ +@@ -97,7 +117,7 @@ public Entity changeDimension(WorldServer worldserver) { Entity entity = this.getOwner(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch index 34cb63ad9f..89000e6e43 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/EntityEvokerFangs.java +++ b/net/minecraft/world/entity/projectile/EntityEvokerFangs.java -@@ -128,7 +128,9 @@ +@@ -129,7 +129,9 @@ if (entityliving.isAlive() && !entityliving.isInvulnerable() && entityliving != entityliving1) { if (entityliving1 == null) { + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = this; // CraftBukkit - entityliving.hurt(DamageSource.MAGIC, 6.0F); + entityliving.hurt(this.damageSources().magic(), 6.0F); + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = null; // CraftBukkit } else { if (entityliving1.isAlliedTo((Entity) entityliving)) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch index cdd7d162a7..5b9fda7288 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityFireworks.java +++ b/net/minecraft/world/entity/projectile/EntityFireworks.java -@@ -29,6 +29,8 @@ +@@ -28,6 +28,8 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -9,7 +9,7 @@ public class EntityFireworks extends IProjectile implements ItemSupplier { public static final DataWatcherObject DATA_ID_FIREWORKS_ITEM = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.ITEM_STACK); -@@ -144,7 +146,7 @@ +@@ -143,7 +145,7 @@ MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity); if (!this.noPhysics) { @@ -18,7 +18,7 @@ this.hasImpulse = true; } -@@ -159,7 +161,11 @@ +@@ -158,7 +160,11 @@ } if (!this.level.isClientSide && this.life > this.lifetime) { @@ -31,7 +31,7 @@ } } -@@ -175,7 +181,11 @@ +@@ -174,7 +180,11 @@ protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) { super.onHitEntity(movingobjectpositionentity); if (!this.level.isClientSide) { @@ -44,7 +44,7 @@ } } -@@ -185,7 +195,11 @@ +@@ -184,7 +194,11 @@ this.level.getBlockState(blockposition).entityInside(this.level, blockposition, this); if (!this.level.isClientSide() && this.hasExplosion()) { @@ -57,22 +57,22 @@ } super.onHitBlock(movingobjectpositionblock); -@@ -211,7 +225,9 @@ +@@ -210,7 +224,9 @@ if (f > 0.0F) { if (this.attachedToEntity != null) { + CraftEventFactory.entityDamage = this; // CraftBukkit - this.attachedToEntity.hurt(DamageSource.fireworks(this, this.getOwner()), 5.0F + (float) (nbttaglist.size() * 2)); + this.attachedToEntity.hurt(this.damageSources().fireworks(this, this.getOwner()), 5.0F + (float) (nbttaglist.size() * 2)); + CraftEventFactory.entityDamage = null; // CraftBukkit } double d0 = 5.0D; -@@ -238,7 +254,9 @@ +@@ -237,7 +253,9 @@ if (flag) { float f1 = f * (float) Math.sqrt((5.0D - (double) this.distanceTo(entityliving)) / 5.0D); + CraftEventFactory.entityDamage = this; // CraftBukkit - entityliving.hurt(DamageSource.fireworks(this, this.getOwner()), f1); + entityliving.hurt(this.damageSources().fireworks(this, this.getOwner()), f1); + CraftEventFactory.entityDamage = null; // CraftBukkit } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch index 32a91fe405..7fa395e8f8 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityLargeFireball.java +++ b/net/minecraft/world/entity/projectile/EntityLargeFireball.java -@@ -10,17 +10,21 @@ +@@ -9,17 +9,21 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.MovingObjectPositionEntity; @@ -22,7 +22,7 @@ } @Override -@@ -29,7 +33,15 @@ +@@ -28,7 +32,15 @@ if (!this.level.isClientSide) { boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); @@ -39,7 +39,7 @@ this.discard(); } -@@ -60,7 +72,8 @@ +@@ -59,7 +71,8 @@ public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { super.readAdditionalSaveData(nbttagcompound); if (nbttagcompound.contains("ExplosionPower", 99)) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch index 4bc2d3b3fb..8576fa4ef8 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityLlamaSpit.java +++ b/net/minecraft/world/entity/projectile/EntityLlamaSpit.java -@@ -33,7 +33,7 @@ +@@ -32,7 +32,7 @@ Vec3D vec3d = this.getDeltaMovement(); MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch index f5157116b1..ec66fe3332 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityPotion.java +++ b/net/minecraft/world/entity/projectile/EntityPotion.java -@@ -32,6 +32,16 @@ +@@ -31,6 +31,16 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.MovingObjectPositionEntity; @@ -17,7 +17,7 @@ public class EntityPotion extends EntityProjectileThrowable implements ItemSupplier { public static final double SPLASH_RANGE = 4.0D; -@@ -100,7 +110,7 @@ +@@ -99,7 +109,7 @@ if (flag) { this.applyWater(); @@ -26,7 +26,7 @@ if (this.isLingering()) { this.makeAreaOfEffectCloud(itemstack, potionregistry); } else { -@@ -149,6 +159,7 @@ +@@ -148,6 +158,7 @@ private void applySplash(List list, @Nullable Entity entity) { AxisAlignedBB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D); List list1 = this.level.getEntitiesOfClass(EntityLiving.class, axisalignedbb); @@ -34,8 +34,8 @@ if (!list1.isEmpty()) { Entity entity1 = this.getEffectSource(); -@@ -167,21 +178,47 @@ - d1 = 1.0D; +@@ -168,24 +179,50 @@ + d1 = 1.0D - Math.sqrt(d0) / 4.0D; } - Iterator iterator1 = list.iterator(); @@ -76,7 +76,10 @@ + if (mobeffectlist.isInstantenous()) { + mobeffectlist.applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect.getAmplifier(), d1); + } else { -+ int i = (int) (d1 * (double) mobeffect.getDuration() + 0.5D); ++ int i = mobeffect.mapDuration((j) -> { ++ return (int) (d1 * (double) j + 0.5D); ++ }); ++ MobEffect mobeffect1 = new MobEffect(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible()); - while (iterator1.hasNext()) { - MobEffect mobeffect = (MobEffect) iterator1.next(); @@ -85,18 +88,21 @@ - if (mobeffectlist.isInstantenous()) { - mobeffectlist.applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect.getAmplifier(), d1); - } else { -- int i = (int) (d1 * (double) mobeffect.getDuration() + 0.5D); +- int i = mobeffect.mapDuration((j) -> { +- return (int) (d1 * (double) j + 0.5D); +- }); +- MobEffect mobeffect1 = new MobEffect(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible()); - -- if (i > 20) { -- entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible()), entity1); +- if (!mobeffect1.endsWithin(20)) { +- entityliving.addEffect(mobeffect1, entity1); - } - } -+ if (i > 20) { -+ entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible()), entity1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_SPLASH); // CraftBukkit ++ if (!mobeffect1.endsWithin(20)) { ++ entityliving.addEffect(mobeffect1, entity1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_SPLASH); // CraftBukkit } } } -@@ -217,7 +254,14 @@ +@@ -221,7 +258,14 @@ entityareaeffectcloud.setFixedColor(nbttagcompound.getInt("CustomPotionColor")); } @@ -112,7 +118,7 @@ } public boolean isLingering() { -@@ -228,13 +272,25 @@ +@@ -232,13 +276,25 @@ IBlockData iblockdata = this.level.getBlockState(blockposition); if (iblockdata.is(TagsBlock.FIRE)) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch index 18ef2fdcdc..b90ff03a36 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityShulkerBullet.java +++ b/net/minecraft/world/entity/projectile/EntityShulkerBullet.java -@@ -59,8 +59,21 @@ +@@ -60,8 +60,21 @@ this.finalTarget = entity; this.currentMoveDirection = EnumDirection.UP; this.selectNextMoveDirection(enumdirection_enumaxis); @@ -22,7 +22,7 @@ @Override public SoundCategory getSoundSource() { return SoundCategory.HOSTILE; -@@ -224,7 +237,7 @@ +@@ -225,7 +238,7 @@ MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity); if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { @@ -31,16 +31,16 @@ } } -@@ -291,7 +304,7 @@ - if (flag) { - this.doEnchantDamageEffects(entityliving, entity); +@@ -294,7 +307,7 @@ if (entity instanceof EntityLiving) { -- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.LEVITATION, 200), (Entity) MoreObjects.firstNonNull(entity1, this)); -+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.LEVITATION, 200), (Entity) MoreObjects.firstNonNull(entity1, this), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit + EntityLiving entityliving1 = (EntityLiving) entity; + +- entityliving1.addEffect(new MobEffect(MobEffects.LEVITATION, 200), (Entity) MoreObjects.firstNonNull(entity1, this)); ++ entityliving1.addEffect(new MobEffect(MobEffects.LEVITATION, 200), (Entity) MoreObjects.firstNonNull(entity1, this), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } } -@@ -317,6 +330,11 @@ +@@ -325,6 +338,11 @@ @Override public boolean hurt(DamageSource damagesource, float f) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch index b67d45bca6..943e4464fb 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch @@ -34,7 +34,7 @@ + entity.setSecondsOnFire(event.getDuration(), false); + } + // CraftBukkit end - if (!entity.hurt(DamageSource.fireball(this, entity1), 5.0F)) { + if (!entity.hurt(this.damageSources().fireball(this, entity1), 5.0F)) { entity.setRemainingFireTicks(i); } else if (entity1 instanceof EntityLiving) { @@ -51,10 +65,10 @@ diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch index 7498e9828d..7314f0d0b7 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch @@ -26,16 +26,16 @@ public int getColor() { return (Integer) this.entityData.get(EntityTippedArrow.ID_EFFECT_COLOR); } -@@ -210,7 +229,7 @@ - - while (iterator.hasNext()) { +@@ -212,7 +231,7 @@ mobeffect = (MobEffect) iterator.next(); -- entityliving.addEffect(new MobEffect(mobeffect.getEffect(), Math.max(mobeffect.getDuration() / 8, 1), mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible()), entity); -+ entityliving.addEffect(new MobEffect(mobeffect.getEffect(), Math.max(mobeffect.getDuration() / 8, 1), mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible()), entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit + entityliving.addEffect(new MobEffect(mobeffect.getEffect(), Math.max(mobeffect.mapDuration((i) -> { + return i / 8; +- }), 1), mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible()), entity); ++ }), 1), mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible()), entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit } if (!this.effects.isEmpty()) { -@@ -218,7 +237,7 @@ +@@ -220,7 +239,7 @@ while (iterator.hasNext()) { mobeffect = (MobEffect) iterator.next(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch index f59e6ad66e..ff7357bc3e 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch @@ -18,16 +18,16 @@ } } } else { -@@ -80,7 +82,7 @@ +@@ -81,7 +83,7 @@ } if (b0 > 0) { -- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1), this.getEffectSource()); -+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1), this.getEffectSource(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit +- entityliving.addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1), this.getEffectSource()); ++ entityliving.addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1), this.getEffectSource(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } } -@@ -91,7 +93,15 @@ +@@ -92,7 +94,15 @@ protected void onHit(MovingObjectPosition movingobjectposition) { super.onHit(movingobjectposition); if (!this.level.isClientSide) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch index 2254dcf3c2..4372f58d51 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/IProjectile.java +++ b/net/minecraft/world/entity/projectile/IProjectile.java -@@ -23,6 +23,10 @@ +@@ -24,6 +24,10 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -8,10 +8,10 @@ +import org.bukkit.projectiles.ProjectileSource; +// CraftBukkit end + - public abstract class IProjectile extends Entity { + public abstract class IProjectile extends Entity implements TraceableEntity { @Nullable -@@ -32,6 +36,10 @@ +@@ -33,6 +37,10 @@ private boolean leftOwner; private boolean hasBeenShot; @@ -22,7 +22,7 @@ IProjectile(EntityTypes entitytypes, World world) { super(entitytypes, world); } -@@ -41,6 +49,7 @@ +@@ -42,6 +50,7 @@ this.ownerUUID = entity.getUUID(); this.cachedOwner = entity; } @@ -30,7 +30,7 @@ } -@@ -144,6 +153,16 @@ +@@ -146,6 +155,16 @@ this.setDeltaMovement(this.getDeltaMovement().add(vec3d.x, entity.isOnGround() ? 0.0D : vec3d.y, vec3d.z)); } @@ -47,7 +47,7 @@ protected void onHit(MovingObjectPosition movingobjectposition) { MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType(); -@@ -164,6 +183,11 @@ +@@ -166,6 +185,11 @@ protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) {} protected void onHitBlock(MovingObjectPositionBlock movingobjectpositionblock) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/ChestBoat.patch b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/ChestBoat.patch index e3eded3fa9..421724dd3e 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/ChestBoat.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/ChestBoat.patch @@ -14,9 +14,9 @@ public class ChestBoat extends EntityBoat implements HasCustomInventoryScreen, ContainerEntity { -@@ -218,4 +225,51 @@ - public void clearItemStacks() { - this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); +@@ -237,4 +244,51 @@ + public void stopOpen(EntityHuman entityhuman) { + this.level.gameEvent(GameEvent.CONTAINER_CLOSE, this.position(), GameEvent.a.of((Entity) entityhuman)); } + + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch index e46bdb3bbd..71330b09bf 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch @@ -97,7 +97,7 @@ super.push(entity); } -@@ -276,6 +335,7 @@ +@@ -279,6 +338,7 @@ return this.getDirection().getClockWise(); } @@ -105,7 +105,7 @@ @Override public void tick() { this.oldStatus = this.status; -@@ -316,6 +376,22 @@ +@@ -319,6 +379,22 @@ this.setDeltaMovement(Vec3D.ZERO); } @@ -128,9 +128,9 @@ this.tickBubbleColumn(); for (int i = 0; i <= 1; ++i) { -@@ -823,6 +899,11 @@ +@@ -830,6 +906,11 @@ - this.causeFallDamage(this.fallDistance, 1.0F, DamageSource.FALL); + this.causeFallDamage(this.fallDistance, 1.0F, this.damageSources().fall()); if (!this.level.isClientSide && !this.isRemoved()) { + // CraftBukkit start + Vehicle vehicle = (Vehicle) this.getBukkitEntity(); @@ -140,7 +140,7 @@ this.kill(); if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { int i; -@@ -836,6 +917,7 @@ +@@ -843,6 +924,7 @@ } } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartTNT.patch b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartTNT.patch index 4c636eae76..6a20eeb483 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartTNT.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartTNT.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/EntityMinecartTNT.java +++ b/net/minecraft/world/entity/vehicle/EntityMinecartTNT.java -@@ -22,6 +22,10 @@ +@@ -23,6 +23,10 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.material.Fluid; @@ -11,7 +11,7 @@ public class EntityMinecartTNT extends EntityMinecartAbstract { private static final byte EVENT_PRIME = 10; -@@ -114,7 +118,15 @@ +@@ -115,7 +119,15 @@ d1 = 5.0D; } diff --git a/paper-server/nms-patches/net/minecraft/world/food/FoodMetaData.patch b/paper-server/nms-patches/net/minecraft/world/food/FoodMetaData.patch index 5045ecd2bc..ea2002c264 100644 --- a/paper-server/nms-patches/net/minecraft/world/food/FoodMetaData.patch +++ b/paper-server/nms-patches/net/minecraft/world/food/FoodMetaData.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/food/FoodMetaData.java +++ b/net/minecraft/world/food/FoodMetaData.java -@@ -8,15 +8,33 @@ +@@ -7,15 +7,33 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.GameRules; @@ -35,7 +35,7 @@ public void eat(int i, float f) { this.foodLevel = Math.min(i + this.foodLevel, 20); -@@ -26,8 +44,17 @@ +@@ -25,8 +43,17 @@ public void eat(Item item, ItemStack itemstack) { if (item.isEdible()) { FoodInfo foodinfo = item.getFoodProperties(); @@ -54,7 +54,7 @@ } } -@@ -41,7 +68,15 @@ +@@ -40,7 +67,15 @@ if (this.saturationLevel > 0.0F) { this.saturationLevel = Math.max(this.saturationLevel - 1.0F, 0.0F); } else if (enumdifficulty != EnumDifficulty.PEACEFUL) { @@ -71,7 +71,7 @@ } } -@@ -49,23 +84,25 @@ +@@ -48,23 +83,25 @@ if (flag && this.saturationLevel > 0.0F && entityhuman.isHurt() && this.foodLevel >= 20) { ++this.tickTimer; @@ -102,5 +102,5 @@ - if (this.tickTimer >= 80) { + if (this.tickTimer >= this.starvationRate) { // CraftBukkit - add regen rate manipulation if (entityhuman.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || entityhuman.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL) { - entityhuman.hurt(DamageSource.STARVE, 1.0F); + entityhuman.hurt(entityhuman.damageSources().starve(), 1.0F); } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/Container.patch b/paper-server/nms-patches/net/minecraft/world/inventory/Container.patch index 9c269c7d05..408681934c 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/Container.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/Container.patch @@ -86,8 +86,8 @@ } l -= itemstack3.getCount() - j1; -- slot1.set(itemstack3); -+ // slot1.set(itemstack3); +- slot1.setByPlayer(itemstack3); ++ // slot1.setByPlayer(itemstack3); + draggedSlots.put(slot1.index, itemstack3); // CraftBukkit - Put in map instead of setting } } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch index 32217e226f..b72f4f314c 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch @@ -10,11 +10,11 @@ + public class ContainerAnvil extends ContainerAnvilAbstract { - private static final Logger LOGGER = LogUtils.getLogger(); -@@ -32,6 +36,11 @@ - private static final int COST_REPAIR_SACRIFICE = 2; - private static final int COST_INCOMPATIBLE_PENALTY = 1; - private static final int COST_RENAME = 1; + public static final int INPUT_SLOT = 0; +@@ -39,6 +43,11 @@ + private static final int ADDITIONAL_SLOT_X_PLACEMENT = 76; + private static final int RESULT_SLOT_X_PLACEMENT = 134; + private static final int SLOT_Y_PLACEMENT = 47; + // CraftBukkit start + public static final int DEFAULT_DENIED_COST = -1; + public int maximumRepairCost = 40; @@ -23,7 +23,7 @@ public ContainerAnvil(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); -@@ -50,7 +59,7 @@ +@@ -66,7 +75,7 @@ @Override protected boolean mayPickup(EntityHuman entityhuman, boolean flag) { @@ -32,7 +32,7 @@ } @Override -@@ -73,7 +82,7 @@ +@@ -89,7 +98,7 @@ this.inputSlots.setItem(1, ItemStack.EMPTY); } @@ -41,7 +41,7 @@ this.access.execute((world, blockposition) -> { IBlockData iblockdata = world.getBlockState(blockposition); -@@ -104,8 +113,8 @@ +@@ -120,8 +129,8 @@ byte b1 = 0; if (itemstack.isEmpty()) { @@ -52,7 +52,7 @@ } else { ItemStack itemstack1 = itemstack.copy(); ItemStack itemstack2 = this.inputSlots.getItem(1); -@@ -122,8 +131,8 @@ +@@ -138,8 +147,8 @@ if (itemstack1.isDamageableItem() && itemstack1.getItem().isValidRepairItem(itemstack, itemstack2)) { k = Math.min(itemstack1.getDamageValue(), itemstack1.getMaxDamage() / 4); if (k <= 0) { @@ -63,7 +63,7 @@ return; } -@@ -137,8 +146,8 @@ +@@ -153,8 +162,8 @@ this.repairItemCountCost = i1; } else { if (!flag && (!itemstack1.is(itemstack2.getItem()) || !itemstack1.isDamageableItem())) { @@ -74,7 +74,7 @@ return; } -@@ -227,8 +236,8 @@ +@@ -243,8 +252,8 @@ } if (flag2 && !flag1) { @@ -85,7 +85,7 @@ return; } } -@@ -251,11 +260,11 @@ +@@ -267,11 +276,11 @@ itemstack1 = ItemStack.EMPTY; } @@ -100,7 +100,7 @@ itemstack1 = ItemStack.EMPTY; } -@@ -274,7 +283,8 @@ +@@ -290,7 +299,8 @@ EnchantmentManager.setEnchantments(map, itemstack1); } @@ -110,7 +110,7 @@ this.broadcastChanges(); } } -@@ -301,4 +311,18 @@ +@@ -317,4 +327,18 @@ public int getCost() { return this.cost.get(); } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch index 29007cd3bf..e90413e53d 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerAnvilAbstract.java +++ b/net/minecraft/world/inventory/ContainerAnvilAbstract.java -@@ -92,6 +92,7 @@ +@@ -124,6 +124,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch index f5ff5cd67a..0e44ec9e9a 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch +++ b/paper-server/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 -@@ -12,6 +12,12 @@ +@@ -13,6 +13,12 @@ import net.minecraft.world.item.crafting.IRecipe; import net.minecraft.world.item.enchantment.EnchantmentManager; @@ -13,7 +13,7 @@ public class ContainerPlayer extends ContainerRecipeBook { public static final int CONTAINER_ID = 0; -@@ -33,15 +39,28 @@ +@@ -34,15 +40,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}; @@ -44,7 +44,7 @@ this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 154, 28)); int i; -@@ -250,4 +269,17 @@ +@@ -264,4 +283,17 @@ public boolean shouldMoveToInventory(int i) { return i != this.getResultSlotIndex(); } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch index ce5d94be3f..d4fd6d831a 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch +++ b/paper-server/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 -@@ -11,12 +11,17 @@ +@@ -12,6 +12,8 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; @@ -8,29 +8,30 @@ + public class ContainerSmithing extends ContainerAnvilAbstract { - private final World level; + public static final int TEMPLATE_SLOT = 0; +@@ -27,6 +29,9 @@ @Nullable - private RecipeSmithing selectedRecipe; - private final List recipes; + private SmithingRecipe selectedRecipe; + private final List recipes; + // CraftBukkit start + private CraftInventoryView bukkitEntity; + // CraftBukkit end public ContainerSmithing(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); -@@ -61,7 +66,7 @@ - List list = this.level.getRecipeManager().getRecipesFor(Recipes.SMITHING, this.inputSlots, this.level); +@@ -89,7 +94,7 @@ + List list = this.level.getRecipeManager().getRecipesFor(Recipes.SMITHING, this.inputSlots, this.level); if (list.isEmpty()) { - this.resultSlots.setItem(0, ItemStack.EMPTY); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit } else { - RecipeSmithing recipesmithing = (RecipeSmithing) list.get(0); - ItemStack itemstack = recipesmithing.assemble(this.inputSlots); -@@ -69,7 +74,9 @@ + SmithingRecipe smithingrecipe = (SmithingRecipe) list.get(0); + ItemStack itemstack = smithingrecipe.assemble(this.inputSlots, this.level.registryAccess()); +@@ -97,7 +102,9 @@ if (itemstack.isItemEnabled(this.level.enabledFeatures())) { - this.selectedRecipe = recipesmithing; - this.resultSlots.setRecipeUsed(recipesmithing); + this.selectedRecipe = smithingrecipe; + this.resultSlots.setRecipeUsed(smithingrecipe); - this.resultSlots.setItem(0, itemstack); + // CraftBukkit start + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack); @@ -38,9 +39,9 @@ } } -@@ -86,4 +93,18 @@ - public boolean canTakeItemForPickAll(ItemStack itemstack, Slot slot) { - return slot.container != this.resultSlots && super.canTakeItemForPickAll(itemstack, slot); +@@ -125,4 +132,18 @@ + return findSlotMatchingIngredient(smithingrecipe, itemstack); + }).anyMatch(Optional::isPresent); } + + // CraftBukkit start @@ -50,7 +51,7 @@ + return bukkitEntity; + } + -+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventorySmithing( ++ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventorySmithingNew( + access.getLocation(), this.inputSlots, this.resultSlots); + bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this); + return bukkitEntity; diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/Containers.patch b/paper-server/nms-patches/net/minecraft/world/inventory/Containers.patch index 4e752911a9..45041fcf3d 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/Containers.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/Containers.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/inventory/Containers.java +++ b/net/minecraft/world/inventory/Containers.java -@@ -4,6 +4,10 @@ - import net.minecraft.core.registries.BuiltInRegistries; - import net.minecraft.world.entity.player.PlayerInventory; +@@ -8,6 +8,10 @@ + import net.minecraft.world.flag.FeatureFlagSet; + import net.minecraft.world.flag.FeatureFlags; +// CraftBukkit start +import net.minecraft.world.entity.player.PlayerInventory; +// CraftBukkit end + - public class Containers { + public class Containers implements FeatureElement { public static final Containers GENERIC_9x1 = register("generic_9x1", ContainerChest::oneRow); -@@ -23,7 +27,7 @@ +@@ -27,7 +31,7 @@ public static final Containers GRINDSTONE = register("grindstone", ContainerGrindstone::new); public static final Containers HOPPER = register("hopper", ContainerHopper::new); public static final Containers LECTERN = register("lectern", (i, playerinventory) -> { diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/LegacySmithingMenu.patch b/paper-server/nms-patches/net/minecraft/world/inventory/LegacySmithingMenu.patch new file mode 100644 index 0000000000..4d4f02b25e --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/inventory/LegacySmithingMenu.patch @@ -0,0 +1,60 @@ +--- a/net/minecraft/world/inventory/LegacySmithingMenu.java ++++ b/net/minecraft/world/inventory/LegacySmithingMenu.java +@@ -11,6 +11,8 @@ + import net.minecraft.world.level.block.Blocks; + import net.minecraft.world.level.block.state.IBlockData; + ++import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit ++ + /** @deprecated */ + @Deprecated(forRemoval = true) + public class LegacySmithingMenu extends ContainerAnvilAbstract { +@@ -26,6 +28,9 @@ + @Nullable + private LegacyUpgradeRecipe selectedRecipe; + private final List recipes; ++ // CraftBukkit start ++ private CraftInventoryView bukkitEntity; ++ // CraftBukkit end + + public LegacySmithingMenu(int i, PlayerInventory playerinventory) { + this(i, playerinventory, ContainerAccess.NULL); +@@ -87,7 +92,7 @@ + }).toList(); + + if (list.isEmpty()) { +- this.resultSlots.setItem(0, ItemStack.EMPTY); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit + } else { + LegacyUpgradeRecipe legacyupgraderecipe = (LegacyUpgradeRecipe) list.get(0); + ItemStack itemstack = legacyupgraderecipe.assemble(this.inputSlots, this.level.registryAccess()); +@@ -95,7 +100,9 @@ + if (itemstack.isItemEnabled(this.level.enabledFeatures())) { + this.selectedRecipe = legacyupgraderecipe; + this.resultSlots.setRecipeUsed(legacyupgraderecipe); +- this.resultSlots.setItem(0, itemstack); ++ // CraftBukkit start ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack); ++ // CraftBukkit end + } + } + +@@ -116,4 +123,18 @@ + public boolean canTakeItemForPickAll(ItemStack itemstack, Slot slot) { + return slot.container != this.resultSlots && super.canTakeItemForPickAll(itemstack, slot); + } ++ ++ // CraftBukkit start ++ @Override ++ public CraftInventoryView getBukkitView() { ++ if (bukkitEntity != null) { ++ return bukkitEntity; ++ } ++ ++ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventorySmithing( ++ access.getLocation(), this.inputSlots, this.resultSlots); ++ bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this); ++ return bukkitEntity; ++ } ++ // CraftBukkit end + } diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemArmor.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemArmor.patch index 999c1df653..171bed2699 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemArmor.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemArmor.patch @@ -9,10 +9,10 @@ +import org.bukkit.event.block.BlockDispenseArmorEvent; +// CraftBukkit end + - public class ItemArmor extends Item implements ItemWearable { + public class ItemArmor extends Item implements Equipable { - 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")}; -@@ -53,8 +58,34 @@ + private static final EnumMap ARMOR_MODIFIER_UUID_PER_TYPE = (EnumMap) SystemUtils.make(new EnumMap(ItemArmor.a.class), (enummap) -> { +@@ -58,8 +63,34 @@ EntityLiving entityliving = (EntityLiving) list.get(0); EnumItemSlot enumitemslot = EntityInsentient.getEquipmentSlotForItem(itemstack); ItemStack itemstack1 = itemstack.split(1); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemArmorStand.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemArmorStand.patch index 507c297b3f..6069029c14 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemArmorStand.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemArmorStand.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/item/ItemArmorStand.java +++ b/net/minecraft/world/item/ItemArmorStand.java -@@ -57,6 +57,11 @@ +@@ -53,6 +53,11 @@ + float f = (float) MathHelper.floor((MathHelper.wrapDegrees(itemactioncontext.getRotation() - 180.0F) + 22.5F) / 45.0F) * 45.0F; entityarmorstand.moveTo(entityarmorstand.getX(), entityarmorstand.getY(), entityarmorstand.getZ(), f, 0.0F); - this.randomizePose(entityarmorstand, world.random); + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(itemactioncontext, entityarmorstand).isCancelled()) { + return EnumInteractionResult.FAIL; diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemCrossbow.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemCrossbow.patch index b0629ccb4b..78f8b114c4 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemCrossbow.patch +++ b/paper-server/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 -@@ -112,6 +112,10 @@ +@@ -113,6 +113,10 @@ if (itemstack1.isEmpty() && flag) { itemstack1 = new ItemStack(Items.ARROW); itemstack2 = itemstack1.copy(); @@ -11,7 +11,7 @@ } if (!loadProjectile(entityliving, itemstack, itemstack1, k > 0, flag)) { -@@ -235,11 +239,27 @@ +@@ -236,11 +240,27 @@ ((IProjectile) object).shoot((double) vector3f.x(), (double) vector3f.y(), (double) vector3f.z(), f1, f2); } diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemHanging.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemHanging.patch index 63bccc74c6..e259a2f2fb 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemHanging.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemHanging.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemHanging.java +++ b/net/minecraft/world/item/ItemHanging.java -@@ -16,6 +16,11 @@ +@@ -22,6 +22,11 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.gameevent.GameEvent; @@ -11,8 +11,8 @@ + public class ItemHanging extends Item { - private final EntityTypes type; -@@ -65,6 +70,19 @@ + private static final IChatBaseComponent TOOLTIP_RANDOM_VARIANT = IChatBaseComponent.translatable("painting.random").withStyle(EnumChatFormat.GRAY); +@@ -72,6 +77,19 @@ if (((EntityHanging) object).survives()) { if (!world.isClientSide) { diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemLeash.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemLeash.patch index 1b1729e0c8..53a585f225 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemLeash.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemLeash.patch @@ -20,8 +20,8 @@ + bindPlayerMobs(entityhuman, world, blockposition, itemactioncontext.getHand()); // CraftBukkit - Pass hand } - world.gameEvent(GameEvent.BLOCK_ATTACH, blockposition, GameEvent.a.of((Entity) entityhuman)); -@@ -41,7 +46,7 @@ + return EnumInteractionResult.sidedSuccess(world.isClientSide); +@@ -40,7 +45,7 @@ } } @@ -30,7 +30,7 @@ EntityLeash entityleash = null; boolean flag = false; double d0 = 7.0D; -@@ -57,9 +62,26 @@ +@@ -56,9 +61,26 @@ if (entityinsentient.getLeashHolder() == entityhuman) { if (entityleash == null) { entityleash = EntityLeash.getOrCreateKnot(world, blockposition); @@ -57,7 +57,7 @@ entityinsentient.setLeashedTo(entityleash, true); flag = true; } -@@ -67,4 +89,10 @@ +@@ -70,4 +92,10 @@ return flag ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS; } diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemRecord.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemRecord.patch index 70f084537c..74b4bd490d 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemRecord.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemRecord.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/item/ItemRecord.java +++ b/net/minecraft/world/item/ItemRecord.java -@@ -43,6 +43,7 @@ +@@ -46,6 +46,7 @@ ItemStack itemstack = itemactioncontext.getItemInHand(); if (!world.isClientSide) { + if (true) return EnumInteractionResult.SUCCESS; // CraftBukkit - handled in ItemStack - ((BlockJukeBox) Blocks.JUKEBOX).setRecord(itemactioncontext.getPlayer(), world, blockposition, iblockdata, itemstack); - world.levelEvent((EntityHuman) null, 1010, blockposition, Item.getId(this)); - itemstack.shrink(1); + EntityHuman entityhuman = itemactioncontext.getPlayer(); + TileEntity tileentity = world.getBlockEntity(blockposition); + diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemStack.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemStack.patch index 529e865459..8bf60f5c58 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemStack.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemStack.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -74,6 +74,40 @@ +@@ -75,6 +75,40 @@ import net.minecraft.world.level.block.state.pattern.ShapeDetectorBlock; import org.slf4j.Logger; @@ -16,15 +16,15 @@ +import net.minecraft.server.level.WorldServer; +import net.minecraft.sounds.SoundCategory; +import net.minecraft.util.datafix.fixes.DataConverterTypes; -+import net.minecraft.world.level.block.BlockJukeBox; +import net.minecraft.world.level.block.BlockSapling; +import net.minecraft.world.level.block.BlockTileEntity; +import net.minecraft.world.level.block.BlockWitherSkull; -+import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.SoundEffectType; +import net.minecraft.world.level.block.entity.TileEntity; ++import net.minecraft.world.level.block.entity.TileEntityJukeBox; +import net.minecraft.world.level.block.entity.TileEntitySign; +import net.minecraft.world.level.block.entity.TileEntitySkull; ++import net.minecraft.world.level.gameevent.GameEvent; +import org.bukkit.Location; +import org.bukkit.TreeType; +import org.bukkit.block.BlockState; @@ -41,7 +41,7 @@ public final class ItemStack { public static final Codec CODEC = RecordCodecBuilder.create((instance) -> { -@@ -150,16 +184,30 @@ +@@ -151,16 +185,30 @@ this.updateEmptyCacheFlag(); } @@ -74,7 +74,7 @@ this.getItem().verifyTagAfterLoad(this.tag); } -@@ -167,6 +215,11 @@ +@@ -168,6 +216,11 @@ this.setDamageValue(this.getDamageValue()); } @@ -86,7 +86,7 @@ this.updateEmptyCacheFlag(); } -@@ -224,7 +277,7 @@ +@@ -225,7 +278,7 @@ return this.getItem().builtInRegistryHolder().tags(); } @@ -95,7 +95,7 @@ EntityHuman entityhuman = itemactioncontext.getPlayer(); BlockPosition blockposition = itemactioncontext.getClickedPos(); ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getLevel(), blockposition, false); -@@ -232,12 +285,158 @@ +@@ -233,12 +286,171 @@ if (entityhuman != null && !entityhuman.getAbilities().mayBuild && !this.hasAdventureModePlaceTagForBlock(itemactioncontext.getLevel().registryAccess().registryOrThrow(Registries.BLOCK), shapedetectorblock)) { return EnumInteractionResult.PASS; } else { @@ -208,8 +208,21 @@ + // Special case juke boxes as they update their tile entity. Copied from ItemRecord. + // PAIL: checkme on updates. + if (this.item instanceof ItemRecord) { -+ ((BlockJukeBox) Blocks.JUKEBOX).setRecord(entityhuman, world, blockposition, world.getBlockState(blockposition), this); -+ world.levelEvent((EntityHuman) null, 1010, blockposition, Item.getId(this.item)); ++ TileEntity tileentity = world.getBlockEntity(blockposition); ++ ++ if (tileentity instanceof TileEntityJukeBox) { ++ TileEntityJukeBox tileentityjukebox = (TileEntityJukeBox) tileentity; ++ ++ // There can only be one ++ ItemStack record = this.copy(); ++ if (!record.isEmpty()) { ++ record.setCount(1); ++ } ++ ++ tileentityjukebox.setFirstItem(record); ++ world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entityhuman, world.getBlockState(blockposition))); ++ } ++ + this.shrink(1); + entityhuman.awardStat(StatisticList.PLAY_RECORD); + } @@ -255,7 +268,7 @@ return enuminteractionresult; } -@@ -318,6 +517,21 @@ +@@ -319,6 +531,21 @@ } i -= k; @@ -277,7 +290,7 @@ if (i <= 0) { return false; } -@@ -339,6 +553,11 @@ +@@ -340,6 +567,11 @@ if (this.hurt(i, t0.getRandom(), t0 instanceof EntityPlayer ? (EntityPlayer) t0 : null)) { consumer.accept(t0); Item item = this.getItem(); @@ -289,7 +302,7 @@ this.shrink(1); if (t0 instanceof EntityHuman) { -@@ -493,6 +712,17 @@ +@@ -494,6 +726,17 @@ return this.tag; } @@ -307,7 +320,7 @@ public NBTTagCompound getOrCreateTag() { if (this.tag == null) { this.setTag(new NBTTagCompound()); -@@ -859,6 +1089,12 @@ +@@ -864,6 +1107,12 @@ } public void setRepairCost(int i) { @@ -320,7 +333,7 @@ this.getOrCreateTag().putInt("RepairCost", i); } -@@ -908,6 +1144,13 @@ +@@ -913,6 +1162,13 @@ nbttaglist.add(nbttagcompound); } diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch index c48e8af360..24c9cde507 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/IRecipe.java +++ b/net/minecraft/world/item/crafting/IRecipe.java -@@ -61,4 +61,6 @@ +@@ -66,4 +66,6 @@ return recipeitemstack.getItems().length == 0; }); } diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch index eae352e7fe..68a83f37e8 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/IRecipeComplex.java +++ b/net/minecraft/world/item/crafting/IRecipeComplex.java -@@ -32,4 +32,11 @@ +@@ -33,4 +33,11 @@ public CraftingBookCategory category() { return this.category; } diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeSmithing.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/LegacyUpgradeRecipe.patch similarity index 68% rename from paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeSmithing.patch rename to paper-server/nms-patches/net/minecraft/world/item/crafting/LegacyUpgradeRecipe.patch index eec286af8a..e1454343ec 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeSmithing.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/LegacyUpgradeRecipe.patch @@ -1,8 +1,8 @@ ---- a/net/minecraft/world/item/crafting/RecipeSmithing.java -+++ b/net/minecraft/world/item/crafting/RecipeSmithing.java +--- a/net/minecraft/world/item/crafting/LegacyUpgradeRecipe.java ++++ b/net/minecraft/world/item/crafting/LegacyUpgradeRecipe.java @@ -11,6 +11,14 @@ + import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.World; - import net.minecraft.world.level.block.Blocks; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -12,10 +12,10 @@ +import org.bukkit.inventory.Recipe; +// CraftBukkit end + - public class RecipeSmithing implements IRecipe { - - final RecipeItemStack base; -@@ -83,6 +91,17 @@ + /** @deprecated */ + @Deprecated(forRemoval = true) + public class LegacyUpgradeRecipe implements SmithingRecipe { +@@ -86,6 +94,17 @@ }); } @@ -30,6 +30,6 @@ + } + // CraftBukkit end + - public static class a implements RecipeSerializer { + public static class a implements RecipeSerializer { public a() {} diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch index 90d2aad992..a25886ed8c 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/ShapedRecipes.java +++ b/net/minecraft/world/item/crafting/ShapedRecipes.java -@@ -23,6 +23,13 @@ +@@ -24,6 +24,13 @@ import net.minecraft.world.item.Items; import net.minecraft.world.level.World; @@ -14,8 +14,8 @@ public class ShapedRecipes implements RecipeCrafting { final int width; -@@ -43,6 +50,67 @@ - this.result = itemstack; +@@ -50,6 +57,67 @@ + this(minecraftkey, s, craftingbookcategory, i, j, nonnulllist, itemstack, true); } + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch index 7b40730971..3e0711daef 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/ShapelessRecipes.java +++ b/net/minecraft/world/item/crafting/ShapelessRecipes.java -@@ -14,6 +14,12 @@ +@@ -15,6 +15,12 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.World; @@ -13,7 +13,7 @@ public class ShapelessRecipes implements RecipeCrafting { private final MinecraftKey id; -@@ -30,6 +36,21 @@ +@@ -31,6 +37,21 @@ this.ingredients = nonnulllist; } diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.patch new file mode 100644 index 0000000000..0b440d00fb --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.patch @@ -0,0 +1,35 @@ +--- a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java ++++ b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java +@@ -11,6 +11,14 @@ + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.level.World; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.craftbukkit.inventory.CraftRecipe; ++import org.bukkit.craftbukkit.inventory.CraftSmithingTransformRecipe; ++import org.bukkit.craftbukkit.util.CraftNamespacedKey; ++import org.bukkit.inventory.Recipe; ++// CraftBukkit end ++ + public class SmithingTransformRecipe implements SmithingRecipe { + + private final MinecraftKey id; +@@ -79,6 +87,17 @@ + return Stream.of(this.template, this.base, this.addition).anyMatch(RecipeItemStack::isEmpty); + } + ++ // CraftBukkit start ++ @Override ++ public Recipe toBukkitRecipe() { ++ CraftItemStack result = CraftItemStack.asCraftMirror(this.result); ++ ++ CraftSmithingTransformRecipe recipe = new CraftSmithingTransformRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition)); ++ ++ return recipe; ++ } ++ // CraftBukkit end ++ + public static class a implements RecipeSerializer { + + public a() {} diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.patch new file mode 100644 index 0000000000..2e66fa5ec7 --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java ++++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java +@@ -19,6 +19,13 @@ + import net.minecraft.world.item.armortrim.TrimPatterns; + import net.minecraft.world.level.World; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.inventory.CraftRecipe; ++import org.bukkit.craftbukkit.inventory.CraftSmithingTrimRecipe; ++import org.bukkit.craftbukkit.util.CraftNamespacedKey; ++import org.bukkit.inventory.Recipe; ++// CraftBukkit end ++ + public class SmithingTrimRecipe implements SmithingRecipe { + + private final MinecraftKey id; +@@ -115,6 +122,13 @@ + return Stream.of(this.template, this.base, this.addition).anyMatch(RecipeItemStack::isEmpty); + } + ++ // CraftBukkit start ++ @Override ++ public Recipe toBukkitRecipe() { ++ return new CraftSmithingTrimRecipe(CraftNamespacedKey.fromMinecraft(this.id), CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition)); ++ } ++ // CraftBukkit end ++ + public static class a implements RecipeSerializer { + + public a() {} diff --git a/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch b/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch index 1e269ca6e6..f2ea8bc486 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch @@ -83,10 +83,10 @@ + continue; + } + // CraftBukkit end - double d14 = d13; + double d14; if (entity instanceof EntityLiving) { -@@ -254,6 +301,51 @@ +@@ -263,6 +310,51 @@ SystemUtils.shuffle(this.toBlow, this.level.random); ObjectListIterator objectlistiterator = this.toBlow.iterator(); @@ -138,7 +138,7 @@ while (objectlistiterator.hasNext()) { BlockPosition blockposition = (BlockPosition) objectlistiterator.next(); -@@ -272,8 +364,8 @@ +@@ -281,8 +373,8 @@ TileEntity tileentity = iblockdata.hasBlockEntity() ? this.level.getBlockEntity(blockposition) : null; LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder(worldserver)).withRandom(this.level.random).withParameter(LootContextParameters.ORIGIN, Vec3D.atCenterOf(blockposition)).withParameter(LootContextParameters.TOOL, ItemStack.EMPTY).withOptionalParameter(LootContextParameters.BLOCK_ENTITY, tileentity).withOptionalParameter(LootContextParameters.THIS_ENTITY, this.source); @@ -149,7 +149,7 @@ } iblockdata.spawnAfterBreak(worldserver, blockposition, ItemStack.EMPTY, flag2); -@@ -305,7 +397,11 @@ +@@ -314,7 +406,11 @@ BlockPosition blockposition2 = (BlockPosition) objectlistiterator1.next(); if (this.random.nextInt(3) == 0 && this.level.getBlockState(blockposition2).isAir() && this.level.getBlockState(blockposition2.below()).isSolidRender(this.level, blockposition2.below())) { @@ -162,7 +162,7 @@ } } } -@@ -317,6 +413,7 @@ +@@ -326,6 +422,7 @@ } private static void addBlockDrops(ObjectArrayList> objectarraylist, ItemStack itemstack, BlockPosition blockposition) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/GameRules.patch b/paper-server/nms-patches/net/minecraft/world/level/GameRules.patch index a5f6d93cc8..48a469734e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/GameRules.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/GameRules.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/GameRules.java +++ b/net/minecraft/world/level/GameRules.java -@@ -126,7 +126,7 @@ +@@ -128,7 +128,7 @@ } public > T getRule(GameRules.GameRuleKey gamerules_gamerulekey) { @@ -9,7 +9,7 @@ } public NBTTagCompound createTag() { -@@ -140,7 +140,7 @@ +@@ -142,7 +142,7 @@ private void loadFromTag(DynamicLike dynamiclike) { this.rules.forEach((gamerules_gamerulekey, gamerules_gamerulevalue) -> { @@ -18,7 +18,7 @@ Objects.requireNonNull(gamerules_gamerulevalue); optional.ifPresent(gamerules_gamerulevalue::deserialize); -@@ -160,8 +160,8 @@ +@@ -162,8 +162,8 @@ } private static > void callVisitorCap(GameRules.GameRuleVisitor gamerules_gamerulevisitor, GameRules.GameRuleKey gamerules_gamerulekey, GameRules.GameRuleDefinition gamerules_gameruledefinition) { @@ -29,7 +29,7 @@ } public void assignFrom(GameRules gamerules, @Nullable MinecraftServer minecraftserver) { -@@ -253,7 +253,7 @@ +@@ -255,7 +255,7 @@ } public T createRule() { @@ -38,7 +38,7 @@ } public void callVisitor(GameRules.GameRuleVisitor gamerules_gamerulevisitor, GameRules.GameRuleKey gamerules_gamerulekey) { -@@ -283,7 +283,7 @@ +@@ -285,7 +285,7 @@ } @@ -47,7 +47,7 @@ public abstract String serialize(); -@@ -349,7 +349,7 @@ +@@ -351,7 +351,7 @@ } @Override @@ -56,7 +56,7 @@ this.value = Boolean.parseBoolean(s); } -@@ -414,7 +414,7 @@ +@@ -416,7 +416,7 @@ } @Override diff --git a/paper-server/nms-patches/net/minecraft/world/level/StructureManager.patch b/paper-server/nms-patches/net/minecraft/world/level/StructureManager.patch deleted file mode 100644 index 964c556e4f..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/level/StructureManager.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/StructureManager.java -+++ b/net/minecraft/world/level/StructureManager.java -@@ -32,7 +32,7 @@ - - public class StructureManager { - -- private final GeneratorAccess level; -+ public final GeneratorAccess level; // PAIL private -> public - private final WorldOptions worldOptions; - private final StructureCheck structureCheck; - diff --git a/paper-server/nms-patches/net/minecraft/world/level/World.patch b/paper-server/nms-patches/net/minecraft/world/level/World.patch index aa2aa3ecf2..0200c24569 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/World.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/World.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/World.java +++ b/net/minecraft/world/level/World.java -@@ -70,6 +70,31 @@ +@@ -72,6 +72,31 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.scores.Scoreboard; @@ -32,11 +32,11 @@ public abstract class World implements GeneratorAccess, AutoCloseable { public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); -@@ -111,7 +136,43 @@ - private final ResourceKey dimension; +@@ -115,7 +140,43 @@ + private final DamageSources damageSources; private long subTickCount; -- protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j) { +- protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, IRegistryCustom iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j) { + // CraftBukkit start Added the following + private final CraftWorld world; + public boolean pvpMode; @@ -62,7 +62,7 @@ + + public abstract ResourceKey getTypeKey(); + -+ protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env) { ++ protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, IRegistryCustom iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env) { + this.generator = gen; + this.world = new CraftWorld((WorldServer) this, gen, biomeProvider, env); + @@ -77,7 +77,7 @@ this.profiler = supplier; this.levelData = worlddatamutable; this.dimensionTypeRegistration = holder; -@@ -126,12 +187,12 @@ +@@ -130,12 +191,12 @@ this.worldBorder = new WorldBorder() { @Override public double getCenterX() { @@ -92,10 +92,10 @@ } }; } else { -@@ -142,6 +203,42 @@ - this.biomeManager = new BiomeManager(this, i); - this.isDebug = flag1; +@@ -148,6 +209,42 @@ this.neighborUpdater = new CollectingNeighborUpdater(this, j); + this.registryAccess = iregistrycustom; + this.damageSources = new DamageSources(iregistrycustom); + // CraftBukkit start + getWorldBorder().world = (WorldServer) this; + // From PlayerList.setPlayerFileData @@ -135,7 +135,7 @@ } @Override -@@ -199,6 +296,17 @@ +@@ -205,6 +302,17 @@ @Override public boolean setBlock(BlockPosition blockposition, IBlockData iblockdata, int i, int j) { @@ -153,7 +153,7 @@ if (this.isOutsideBuildHeight(blockposition)) { return false; } else if (!this.isClientSide && this.isDebug()) { -@@ -206,9 +314,24 @@ +@@ -212,9 +320,24 @@ } else { Chunk chunk = this.getChunkAt(blockposition); Block block = iblockdata.getBlock(); @@ -179,7 +179,7 @@ return false; } else { IBlockData iblockdata2 = this.getBlockState(blockposition); -@@ -219,6 +342,7 @@ +@@ -225,6 +348,7 @@ this.getProfiler().pop(); } @@ -187,7 +187,7 @@ if (iblockdata2 == iblockdata) { if (iblockdata1 != iblockdata2) { this.setBlocksDirty(blockposition, iblockdata1, iblockdata2); -@@ -245,12 +369,69 @@ +@@ -251,12 +375,69 @@ this.onBlockStateChange(blockposition, iblockdata1, iblockdata2); } @@ -257,7 +257,7 @@ public void onBlockStateChange(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {} @Override -@@ -336,6 +517,14 @@ +@@ -342,6 +523,14 @@ @Override public IBlockData getBlockState(BlockPosition blockposition) { @@ -272,7 +272,7 @@ if (this.isOutsideBuildHeight(blockposition)) { return Blocks.VOID_AIR.defaultBlockState(); } else { -@@ -527,6 +716,16 @@ +@@ -533,6 +722,16 @@ @Nullable @Override public TileEntity getBlockEntity(BlockPosition blockposition) { @@ -289,7 +289,7 @@ return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, Chunk.EnumTileEntityState.IMMEDIATE)); } -@@ -534,6 +733,12 @@ +@@ -540,6 +739,12 @@ BlockPosition blockposition = tileentity.getBlockPos(); if (!this.isOutsideBuildHeight(blockposition)) { @@ -302,7 +302,7 @@ this.getChunkAt(blockposition).addAndRegisterBlockEntity(tileentity); } } -@@ -664,7 +869,7 @@ +@@ -670,7 +875,7 @@ for (int k = 0; k < j; ++k) { EntityComplexPart entitycomplexpart = aentitycomplexpart[k]; diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockBed.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockBed.patch index 07ae9f9337..8898f0f040 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockBed.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockBed.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockBed.java +++ b/net/minecraft/world/level/block/BlockBed.java -@@ -86,7 +86,8 @@ +@@ -85,7 +85,8 @@ } } @@ -10,7 +10,7 @@ world.removeBlock(blockposition, false); BlockPosition blockposition1 = blockposition.relative(((EnumDirection) iblockdata.getValue(BlockBed.FACING)).getOpposite()); -@@ -105,7 +106,16 @@ +@@ -104,7 +105,16 @@ return EnumInteractionResult.SUCCESS; } else { @@ -27,7 +27,7 @@ if (entityhuman_enumbedresult.getMessage() != null) { entityhuman.displayClientMessage(entityhuman_enumbedresult.getMessage(), true); } -@@ -116,8 +126,29 @@ +@@ -115,8 +125,29 @@ } } @@ -44,7 +44,7 @@ + + Vec3D vec3d = blockposition.getCenter(); + -+ world.explode((Entity) null, DamageSource.badRespawnPointExplosion(vec3d), (ExplosionDamageCalculator) null, vec3d, 5.0F, true, World.a.BLOCK); ++ world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d), (ExplosionDamageCalculator) null, vec3d, 5.0F, true, World.a.BLOCK); + return EnumInteractionResult.SUCCESS; + } + } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch index c1915f8016..2505d16e8d 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch @@ -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; @@ -12,7 +12,7 @@ public class BlockButtonAbstract extends BlockAttachable { public static final BlockStateBoolean POWERED = BlockProperties.POWERED; -@@ -109,6 +114,19 @@ +@@ -108,6 +113,19 @@ if ((Boolean) iblockdata.getValue(BlockButtonAbstract.POWERED)) { return EnumInteractionResult.CONSUME; } else { @@ -32,7 +32,7 @@ this.press(iblockdata, world, blockposition); this.playSound(entityhuman, world, blockposition, true); world.gameEvent((Entity) entityhuman, GameEvent.BLOCK_ACTIVATE, blockposition); -@@ -171,11 +189,36 @@ +@@ -170,11 +188,36 @@ } protected void checkPressed(IBlockData iblockdata, World world, BlockPosition blockposition) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCactus.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCactus.patch index 3e7669daee..78465ceef5 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCactus.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCactus.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCactus.java +++ b/net/minecraft/world/level/block/BlockCactus.java -@@ -22,6 +22,8 @@ +@@ -21,6 +21,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -9,7 +9,7 @@ public class BlockCactus extends Block { public static final BlockStateInteger AGE = BlockProperties.AGE_15; -@@ -58,7 +60,7 @@ +@@ -57,7 +59,7 @@ int j = (Integer) iblockdata.getValue(BlockCactus.AGE); if (j == 15) { @@ -18,12 +18,12 @@ IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockCactus.AGE, 0); worldserver.setBlock(blockposition, iblockdata1, 4); -@@ -115,7 +117,9 @@ +@@ -114,7 +116,9 @@ @Override public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + CraftEventFactory.blockDamage = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit - entity.hurt(DamageSource.CACTUS, 1.0F); + entity.hurt(world.damageSources().cactus(), 1.0F); + CraftEventFactory.blockDamage = null; // CraftBukkit } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch index f469cec33a..e32ea1aefb 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCampfire.java +++ b/net/minecraft/world/level/block/BlockCampfire.java -@@ -47,6 +47,10 @@ +@@ -46,6 +46,10 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -11,17 +11,17 @@ public class BlockCampfire extends BlockTileEntity implements IBlockWaterlogged { protected static final VoxelShape SHAPE = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 7.0D, 16.0D); -@@ -91,7 +95,9 @@ +@@ -90,7 +94,9 @@ @Override public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { if ((Boolean) iblockdata.getValue(BlockCampfire.LIT) && entity instanceof EntityLiving && !EnchantmentManager.hasFrostWalker((EntityLiving) entity)) { + org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); // CraftBukkit - entity.hurt(DamageSource.IN_FIRE, (float) this.fireDamage); + entity.hurt(world.damageSources().inFire(), (float) this.fireDamage); + org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = null; // CraftBukkit } super.entityInside(iblockdata, world, blockposition, entity); -@@ -201,6 +207,11 @@ +@@ -200,6 +206,11 @@ BlockPosition blockposition = movingobjectpositionblock.getBlockPos(); if (!world.isClientSide && iprojectile.isOnFire() && iprojectile.mayInteract(world, blockposition) && !(Boolean) iblockdata.getValue(BlockCampfire.LIT) && !(Boolean) iblockdata.getValue(BlockCampfire.WATERLOGGED)) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockComposter.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockComposter.patch index ca1d1731cc..823c5917f7 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockComposter.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockComposter.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockComposter.java +++ b/net/minecraft/world/level/block/BlockComposter.java -@@ -37,6 +37,12 @@ +@@ -40,6 +40,12 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -13,61 +13,46 @@ public class BlockComposter extends Block implements IInventoryHolder { public static final int READY = 8; -@@ -227,18 +233,25 @@ - - return EnumInteractionResult.sidedSuccess(world.isClientSide); - } else if (i == 8) { -- extractProduce(iblockdata, world, blockposition); -+ extractProduce(iblockdata, world, blockposition, (Entity) null); // CraftBukkit - no event for players - return EnumInteractionResult.sidedSuccess(world.isClientSide); - } else { - return EnumInteractionResult.PASS; - } - } - -- public static IBlockData insertItem(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition) { -+ public static IBlockData insertItem(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition, Entity entity) { // CraftBukkit +@@ -246,7 +252,14 @@ int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL); if (i < 7 && BlockComposter.COMPOSTABLES.containsKey(itemstack.getItem())) { -- IBlockData iblockdata1 = addItem(iblockdata, worldserver, blockposition, itemstack); +- IBlockData iblockdata1 = addItem(entity, iblockdata, worldserver, blockposition, itemstack); + // CraftBukkit start + double rand = worldserver.getRandom().nextDouble(); -+ IBlockData iblockdata1 = addItem(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack, rand); ++ IBlockData iblockdata1 = addItem(entity, iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack, rand); + if (iblockdata == iblockdata1 || org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) { + return iblockdata; + } -+ iblockdata1 = addItem(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack, rand); ++ iblockdata1 = addItem(entity, iblockdata, worldserver, blockposition, itemstack, rand); + // CraftBukkit end itemstack.shrink(1); return iblockdata1; -@@ -247,7 +260,15 @@ - } +@@ -256,6 +269,14 @@ } -- public static IBlockData extractProduce(IBlockData iblockdata, World world, BlockPosition blockposition) { -+ // CraftBukkit start -+ public static IBlockData extractProduce(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { -+ if (entity != null) { -+ IBlockData iblockdata1 = empty(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition); + public static IBlockData extractProduce(Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) { ++ // CraftBukkit start ++ if (entity != null && !(entity instanceof EntityHuman)) { ++ IBlockData iblockdata1 = empty(entity, iblockdata, DummyGeneratorAccess.INSTANCE, blockposition); + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) { + return iblockdata; + } + } + // CraftBukkit end if (!world.isClientSide) { - float f = 0.7F; - double d0 = (double) (world.random.nextFloat() * 0.7F) + 0.15000000596046448D; -@@ -273,10 +294,16 @@ + Vec3D vec3d = Vec3D.atLowerCornerWithOffset(blockposition, 0.5D, 1.01D, 0.5D).offsetRandom(world.random, 0.7F); + EntityItem entityitem = new EntityItem(world, vec3d.x(), vec3d.y(), vec3d.z(), new ItemStack(Items.BONE_MEAL)); +@@ -279,10 +300,16 @@ } - static IBlockData addItem(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) { + static IBlockData addItem(@Nullable Entity entity, IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) { + // CraftBukkit start -+ return addItem(iblockdata, generatoraccess, blockposition, itemstack, generatoraccess.getRandom().nextDouble()); ++ return addItem(entity, iblockdata, generatoraccess, blockposition, itemstack, generatoraccess.getRandom().nextDouble()); + } + -+ static IBlockData addItem(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack, double rand) { ++ static IBlockData addItem(@Nullable Entity entity, IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack, double rand) { + // CraftBukkit end int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL); float f = BlockComposter.COMPOSTABLES.getFloat(itemstack.getItem()); @@ -77,7 +62,7 @@ return iblockdata; } else { int j = i + 1; -@@ -324,7 +351,8 @@ +@@ -331,7 +358,8 @@ public IWorldInventory getContainer(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL); @@ -87,7 +72,7 @@ } public static class ContainerOutput extends InventorySubcontainer implements IWorldInventory { -@@ -339,6 +367,7 @@ +@@ -346,6 +374,7 @@ this.state = iblockdata; this.level = generatoraccess; this.pos = blockposition; @@ -95,15 +80,15 @@ } @Override -@@ -363,8 +392,15 @@ +@@ -370,8 +399,15 @@ @Override public void setChanged() { -- BlockComposter.empty(this.state, this.level, this.pos); +- BlockComposter.empty((Entity) null, this.state, this.level, this.pos); - this.changed = true; + // CraftBukkit start - allow putting items back (eg cancelled InventoryMoveItemEvent) + if (this.isEmpty()) { -+ BlockComposter.empty(this.state, this.level, this.pos); ++ BlockComposter.empty((Entity) null, this.state, this.level, this.pos); + this.changed = true; + } else { + this.level.setBlock(this.pos, this.state, 3); @@ -113,7 +98,7 @@ } } -@@ -377,6 +413,7 @@ +@@ -384,6 +420,7 @@ public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { super(1); @@ -121,7 +106,7 @@ this.state = iblockdata; this.level = generatoraccess; this.pos = blockposition; -@@ -419,8 +456,9 @@ +@@ -426,8 +463,9 @@ public static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDaylightDetector.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDaylightDetector.patch index 8a3d7944b7..adfc2a389a 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDaylightDetector.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDaylightDetector.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/level/block/BlockDaylightDetector.java @@ -67,6 +67,7 @@ - i = MathHelper.clamp(i, (int) 0, (int) 15); + i = MathHelper.clamp(i, 0, 15); if ((Integer) iblockdata.getValue(BlockDaylightDetector.POWER) != i) { + i = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, blockposition, ((Integer) iblockdata.getValue(POWER)), i).getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockDaylightDetector.POWER, i), 3); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDoor.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDoor.patch index ce966a4a49..fcfc330d8e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDoor.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDoor.patch @@ -9,7 +9,7 @@ public class BlockDoor extends Block { public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING; -@@ -189,9 +191,24 @@ +@@ -187,9 +189,24 @@ @Override public void neighborChanged(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch index 3829f1c462..8dde4993ef 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch @@ -17,7 +17,7 @@ @@ -40,13 +47,22 @@ @Override public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { - if (world instanceof WorldServer && !entity.isPassenger() && !entity.isVehicle() && entity.canChangeDimensions() && VoxelShapes.joinIsNotEmpty(VoxelShapes.create(entity.getBoundingBox().move((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), iblockdata.getShape(world, blockposition), OperatorBoolean.AND)) { + if (world instanceof WorldServer && entity.canChangeDimensions() && VoxelShapes.joinIsNotEmpty(VoxelShapes.create(entity.getBoundingBox().move((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), iblockdata.getShape(world, blockposition), OperatorBoolean.AND)) { - ResourceKey resourcekey = world.dimension() == World.END ? World.OVERWORLD : World.END; + ResourceKey resourcekey = world.getTypeKey() == WorldDimension.END ? World.OVERWORLD : World.END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends WorldServer worldserver = ((WorldServer) world).getServer().getLevel(resourcekey); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch index abcc5ac60a..0e617f3d73 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockFenceGate.java +++ b/net/minecraft/world/level/block/BlockFenceGate.java -@@ -142,6 +142,17 @@ +@@ -140,6 +140,17 @@ public void neighborChanged(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) { if (!world.isClientSide) { boolean flag1 = world.hasNeighborSignal(blockposition); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFire.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFire.patch index 207c91695b..d7e3dc9048 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFire.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFire.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockFire.java +++ b/net/minecraft/world/level/block/BlockFire.java -@@ -27,6 +27,14 @@ +@@ -28,6 +28,14 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -15,7 +15,7 @@ public class BlockFire extends BlockFireAbstract { public static final int MAX_AGE = 15; -@@ -92,7 +100,24 @@ +@@ -93,7 +101,24 @@ @Override public IBlockData updateShape(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { @@ -41,7 +41,7 @@ } @Override -@@ -141,7 +166,7 @@ +@@ -142,7 +167,7 @@ worldserver.scheduleTick(blockposition, (Block) this, getFireTickDelay(worldserver.random)); if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { if (!iblockdata.canSurvive(worldserver, blockposition)) { @@ -50,7 +50,7 @@ } IBlockData iblockdata1 = worldserver.getBlockState(blockposition.below()); -@@ -149,7 +174,7 @@ +@@ -150,7 +175,7 @@ int i = (Integer) iblockdata.getValue(BlockFire.AGE); if (!flag && worldserver.isRaining() && this.isNearRain(worldserver, blockposition) && randomsource.nextFloat() < 0.2F + (float) i * 0.03F) { @@ -59,7 +59,7 @@ } else { int j = Math.min(15, i + randomsource.nextInt(3) / 2); -@@ -163,14 +188,14 @@ +@@ -164,14 +189,14 @@ BlockPosition blockposition1 = blockposition.below(); if (!worldserver.getBlockState(blockposition1).isFaceSturdy(worldserver, blockposition1, EnumDirection.UP) || i > 3) { @@ -76,8 +76,8 @@ return; } } -@@ -178,12 +203,14 @@ - boolean flag1 = worldserver.isHumidAt(blockposition); +@@ -179,12 +204,14 @@ + boolean flag1 = worldserver.getBiome(blockposition).is(BiomeTags.INCREASED_FIRE_BURNOUT); int k = flag1 ? -50 : 0; - this.checkBurnOut(worldserver, blockposition.east(), 300 + k, randomsource, i); @@ -97,7 +97,7 @@ BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition(); for (int l = -1; l <= 1; ++l) { -@@ -209,7 +236,15 @@ +@@ -210,7 +237,15 @@ if (i2 > 0 && randomsource.nextInt(k1) <= i2 && (!worldserver.isRaining() || !this.isNearRain(worldserver, blockposition_mutableblockposition))) { int j2 = Math.min(15, i + randomsource.nextInt(5) / 4); @@ -114,7 +114,7 @@ } } } -@@ -233,12 +268,24 @@ +@@ -234,12 +269,24 @@ return iblockdata.hasProperty(BlockProperties.WATERLOGGED) && (Boolean) iblockdata.getValue(BlockProperties.WATERLOGGED) ? 0 : this.igniteOdds.getInt(iblockdata.getBlock()); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch index bf5623e48e..cd5f7bc26a 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockFireAbstract.java +++ b/net/minecraft/world/level/block/BlockFireAbstract.java -@@ -124,7 +124,14 @@ +@@ -123,7 +123,14 @@ if (!entity.fireImmune()) { entity.setRemainingFireTicks(entity.getRemainingFireTicks() + 1); if (entity.getRemainingFireTicks() == 0) { @@ -16,7 +16,7 @@ } } -@@ -145,14 +152,14 @@ +@@ -144,14 +151,14 @@ } if (!iblockdata.canSurvive(world, blockposition)) { @@ -33,7 +33,7 @@ } @Override -@@ -200,4 +207,12 @@ +@@ -199,4 +206,12 @@ } } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockGrassPath.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockGrassPath.patch index cb75ba4206..9e86e2d544 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockGrassPath.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockGrassPath.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockGrassPath.java +++ b/net/minecraft/world/level/block/BlockGrassPath.java -@@ -43,6 +43,11 @@ +@@ -44,6 +44,11 @@ @Override public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, RandomSource randomsource) { @@ -9,6 +9,6 @@ + return; + } + // CraftBukkit end - BlockSoil.turnToDirt(iblockdata, worldserver, blockposition); + BlockSoil.turnToDirt((Entity) null, iblockdata, worldserver, blockposition); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockJukeBox.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockJukeBox.patch deleted file mode 100644 index 092c8b12c4..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockJukeBox.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- a/net/minecraft/world/level/block/BlockJukeBox.java -+++ b/net/minecraft/world/level/block/BlockJukeBox.java -@@ -67,7 +67,13 @@ - if (tileentity instanceof TileEntityJukeBox) { - TileEntityJukeBox tileentityjukebox = (TileEntityJukeBox) tileentity; - -- tileentityjukebox.setRecord(itemstack.copy()); -+ // CraftBukkit start - There can only be one -+ itemstack = itemstack.copy(); -+ if (!itemstack.isEmpty()) { -+ itemstack.setCount(1); -+ } -+ tileentityjukebox.setRecord(itemstack); -+ // CraftBukkit end - tileentityjukebox.playRecord(); - generatoraccess.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockJukeBox.HAS_RECORD, true), 2); - generatoraccess.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entity, iblockdata)); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch index 332a9517ac..b060213b97 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockLeaves.java +++ b/net/minecraft/world/level/block/BlockLeaves.java -@@ -22,6 +22,8 @@ +@@ -23,6 +23,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -9,7 +9,7 @@ public class BlockLeaves extends Block implements IBlockWaterlogged { public static final int DECAY_DISTANCE = 7; -@@ -48,6 +50,14 @@ +@@ -49,6 +51,14 @@ @Override public void randomTick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, RandomSource randomsource) { if (this.decaying(iblockdata)) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockLectern.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockLectern.patch index 369e7104ea..4d8e35a794 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockLectern.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockLectern.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockLectern.java +++ b/net/minecraft/world/level/block/BlockLectern.java -@@ -198,12 +198,13 @@ +@@ -200,12 +200,13 @@ } private void popBook(IBlockData iblockdata, World world, BlockPosition blockposition) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockMagma.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockMagma.patch index 410347edf5..10a03635b0 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockMagma.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockMagma.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/BlockMagma.java +++ b/net/minecraft/world/level/block/BlockMagma.java -@@ -29,7 +29,9 @@ +@@ -28,7 +28,9 @@ @Override public void stepOn(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { if (!entity.isSteppingCarefully() && entity instanceof EntityLiving && !EnchantmentManager.hasFrostWalker((EntityLiving) entity)) { + org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit - entity.hurt(DamageSource.HOT_FLOOR, 1.0F); + entity.hurt(world.damageSources().hotFloor(), 1.0F); + org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = null; // CraftBukkit } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockNote.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockNote.patch index a00e29d47c..6145a974d4 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockNote.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockNote.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockNote.java +++ b/net/minecraft/world/level/block/BlockNote.java -@@ -77,6 +77,7 @@ +@@ -79,6 +79,7 @@ if (flag1 != (Boolean) iblockdata.getValue(BlockNote.POWERED)) { if (flag1) { this.playNote((Entity) null, iblockdata, world, blockposition); @@ -8,7 +8,7 @@ } world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockNote.POWERED, flag1), 3); -@@ -86,6 +87,12 @@ +@@ -88,6 +89,12 @@ private void playNote(@Nullable Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) { if (!((BlockPropertyInstrument) iblockdata.getValue(BlockNote.INSTRUMENT)).requiresAirAbove() || world.getBlockState(blockposition.above()).isAir()) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPortal.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPortal.patch index 0c8d6f52be..238e68bf40 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPortal.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPortal.patch @@ -24,7 +24,7 @@ @@ -77,6 +82,10 @@ @Override public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { - if (!entity.isPassenger() && !entity.isVehicle() && entity.canChangeDimensions()) { + if (entity.canChangeDimensions()) { + // CraftBukkit start - Entity in portal + EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ())); + world.getCraftServer().getPluginManager().callEvent(event); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateAbstract.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateAbstract.patch index 54843b3dfc..a912c63a12 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockPressurePlateAbstract.java +++ b/net/minecraft/world/level/block/BlockPressurePlateAbstract.java -@@ -18,6 +18,8 @@ +@@ -21,6 +21,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -9,7 +9,7 @@ public abstract class BlockPressurePlateAbstract extends Block { protected static final VoxelShape PRESSED_AABB = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 0.5D, 15.0D); -@@ -81,6 +83,19 @@ +@@ -86,6 +88,19 @@ boolean flag = i > 0; boolean flag1 = j > 0; diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateBinary.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateBinary.patch index fef2be4895..924d30e68e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateBinary.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateBinary.patch @@ -1,15 +1,18 @@ --- a/net/minecraft/world/level/block/BlockPressurePlateBinary.java +++ b/net/minecraft/world/level/block/BlockPressurePlateBinary.java -@@ -17,6 +17,8 @@ +@@ -14,6 +14,11 @@ import net.minecraft.world.level.block.state.properties.BlockStateBoolean; import net.minecraft.world.phys.AxisAlignedBB; -+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit ++// CraftBukkit start ++import net.minecraft.world.entity.player.EntityHuman; ++import org.bukkit.event.entity.EntityInteractEvent; ++// CraftBukkit end + public class BlockPressurePlateBinary extends BlockPressurePlateAbstract { public static final BlockStateBoolean POWERED = BlockProperties.POWERED; -@@ -74,6 +76,26 @@ +@@ -57,6 +62,26 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateWeighted.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateWeighted.patch index 49f2abe0b8..1ef6d67fc6 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateWeighted.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPressurePlateWeighted.patch @@ -1,15 +1,18 @@ --- a/net/minecraft/world/level/block/BlockPressurePlateWeighted.java +++ b/net/minecraft/world/level/block/BlockPressurePlateWeighted.java -@@ -14,6 +14,8 @@ - import net.minecraft.world.level.block.state.properties.BlockProperties; +@@ -11,6 +11,11 @@ + import net.minecraft.world.level.block.state.properties.BlockSetType; import net.minecraft.world.level.block.state.properties.BlockStateInteger; -+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit ++// CraftBukkit start ++import net.minecraft.world.entity.player.EntityHuman; ++import org.bukkit.event.entity.EntityInteractEvent; ++// CraftBukkit end + public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract { public static final BlockStateInteger POWER = BlockProperties.POWER; -@@ -31,7 +33,31 @@ +@@ -24,7 +29,31 @@ @Override protected int getSignalStrength(World world, BlockPosition blockposition) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch index df573e6c9f..b70b6b511e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockPumpkinCarved.java +++ b/net/minecraft/world/level/block/BlockPumpkinCarved.java -@@ -26,6 +26,10 @@ +@@ -27,6 +27,10 @@ import net.minecraft.world.level.block.state.properties.BlockStateDirection; import net.minecraft.world.level.material.Material; @@ -8,10 +8,10 @@ +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +// CraftBukkit end + - public class BlockPumpkinCarved extends BlockFacingHorizontal implements ItemWearable { + public class BlockPumpkinCarved extends BlockFacingHorizontal implements Equipable { public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING; -@@ -82,9 +86,14 @@ +@@ -83,9 +87,14 @@ } private static void spawnGolemInWorld(World world, ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection, Entity entity, BlockPosition blockposition) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSoil.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSoil.patch index 76a4f105da..cecd65f316 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSoil.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSoil.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockSoil.java +++ b/net/minecraft/world/level/block/BlockSoil.java -@@ -25,6 +25,11 @@ +@@ -27,6 +27,11 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -12,14 +12,14 @@ public class BlockSoil extends Block { public static final BlockStateInteger MOISTURE = BlockProperties.MOISTURE; -@@ -81,26 +86,49 @@ +@@ -83,26 +88,49 @@ if (!isNearWater(worldserver, blockposition) && !worldserver.isRainingAt(blockposition.above())) { if (i > 0) { - worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockSoil.MOISTURE, i - 1), 2); + org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(worldserver, blockposition, (IBlockData) iblockdata.setValue(BlockSoil.MOISTURE, i - 1), 2); // CraftBukkit } else if (!isUnderCrops(worldserver, blockposition)) { - turnToDirt(iblockdata, worldserver, blockposition); + turnToDirt((Entity) null, iblockdata, worldserver, blockposition); } } else if (i < 7) { - worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockSoil.MOISTURE, 7), 2); @@ -49,19 +49,19 @@ + return; + } + // CraftBukkit end - turnToDirt(iblockdata, world, blockposition); + turnToDirt(entity, iblockdata, world, blockposition); } - super.fallOn(world, iblockdata, blockposition, entity, f); + // super.fallOn(world, iblockdata, blockposition, entity, f); // CraftBukkit - moved up } - public static void turnToDirt(IBlockData iblockdata, World world, BlockPosition blockposition) { + public static void turnToDirt(@Nullable Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) { + // CraftBukkit start + if (CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.DIRT.defaultBlockState()).isCancelled()) { + return; + } + // CraftBukkit end - world.setBlockAndUpdate(blockposition, pushEntitiesUp(iblockdata, Blocks.DIRT.defaultBlockState(), world, blockposition)); - } + IBlockData iblockdata1 = pushEntitiesUp(iblockdata, Blocks.DIRT.defaultBlockState(), world, blockposition); + world.setBlockAndUpdate(blockposition, iblockdata1); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch index 48254eb353..a02d7b3869 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockSweetBerryBush.java +++ b/net/minecraft/world/level/block/BlockSweetBerryBush.java -@@ -28,6 +28,14 @@ +@@ -27,6 +27,14 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -15,7 +15,7 @@ public class BlockSweetBerryBush extends BlockPlant implements IBlockFragilePlantElement { private static final float HURT_SPEED_THRESHOLD = 0.003F; -@@ -63,7 +71,7 @@ +@@ -62,7 +70,7 @@ if (i < 3 && randomsource.nextInt(5) == 0 && worldserver.getRawBrightness(blockposition.above(), 0) >= 9) { IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSweetBerryBush.AGE, i + 1); @@ -24,17 +24,17 @@ worldserver.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1)); } -@@ -78,7 +86,9 @@ +@@ -77,7 +85,9 @@ double d1 = Math.abs(entity.getZ() - entity.zOld); if (d0 >= 0.003000000026077032D || d1 >= 0.003000000026077032D) { + CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); // CraftBukkit - entity.hurt(DamageSource.SWEET_BERRY_BUSH, 1.0F); + entity.hurt(world.damageSources().sweetBerryBush(), 1.0F); + CraftEventFactory.blockDamage = null; // CraftBukkit } } -@@ -95,7 +105,15 @@ +@@ -94,7 +104,15 @@ } else if (i > 1) { int j = 1 + world.random.nextInt(2); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch index 6bc1d195e2..c5c971db9a 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch @@ -9,7 +9,7 @@ public class BlockTrapdoor extends BlockFacingHorizontal implements IBlockWaterlogged { public static final BlockStateBoolean OPEN = BlockProperties.OPEN; -@@ -113,6 +115,19 @@ +@@ -111,6 +113,19 @@ boolean flag1 = world.hasNeighborSignal(blockposition); if (flag1 != (Boolean) iblockdata.getValue(BlockTrapdoor.POWERED)) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockVine.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockVine.patch index 17eb91cb53..fca8a413b8 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockVine.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockVine.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockVine.java +++ b/net/minecraft/world/level/block/BlockVine.java -@@ -23,6 +23,8 @@ +@@ -24,6 +24,8 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -9,51 +9,51 @@ public class BlockVine extends Block { public static final BlockStateBoolean UP = BlockSprawling.UP; -@@ -194,20 +196,24 @@ - BlockPosition blockposition3 = blockposition2.relative(enumdirection1); - BlockPosition blockposition4 = blockposition2.relative(enumdirection2); +@@ -196,20 +198,24 @@ + BlockPosition blockposition3 = blockposition2.relative(enumdirection1); + BlockPosition blockposition4 = blockposition2.relative(enumdirection2); -+ // CraftBukkit start - Call BlockSpreadEvent -+ BlockPosition source = blockposition; ++ // CraftBukkit start - Call BlockSpreadEvent ++ BlockPosition source = blockposition; + - if (flag && isAcceptableNeighbour(worldserver, blockposition3, enumdirection1)) { -- worldserver.setBlock(blockposition2, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection1), true), 2); -+ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition2, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection1), true), 2); - } else if (flag1 && isAcceptableNeighbour(worldserver, blockposition4, enumdirection2)) { -- worldserver.setBlock(blockposition2, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection2), true), 2); -+ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition2, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection2), true), 2); - } else { - EnumDirection enumdirection3 = enumdirection.getOpposite(); + if (flag && isAcceptableNeighbour(worldserver, blockposition3, enumdirection1)) { +- worldserver.setBlock(blockposition2, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection1), true), 2); ++ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition2, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection1), true), 2); + } else if (flag1 && isAcceptableNeighbour(worldserver, blockposition4, enumdirection2)) { +- worldserver.setBlock(blockposition2, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection2), true), 2); ++ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition2, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection2), true), 2); + } else { + EnumDirection enumdirection3 = enumdirection.getOpposite(); - if (flag && worldserver.isEmptyBlock(blockposition3) && isAcceptableNeighbour(worldserver, blockposition.relative(enumdirection1), enumdirection3)) { -- worldserver.setBlock(blockposition3, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection3), true), 2); -+ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition3, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection3), true), 2); - } else if (flag1 && worldserver.isEmptyBlock(blockposition4) && isAcceptableNeighbour(worldserver, blockposition.relative(enumdirection2), enumdirection3)) { -- worldserver.setBlock(blockposition4, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection3), true), 2); -+ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition4, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection3), true), 2); - } else if ((double) randomsource.nextFloat() < 0.05D && isAcceptableNeighbour(worldserver, blockposition2.above(), EnumDirection.UP)) { -- worldserver.setBlock(blockposition2, (IBlockData) this.defaultBlockState().setValue(BlockVine.UP, true), 2); -+ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition2, (IBlockData) this.defaultBlockState().setValue(BlockVine.UP, true), 2); + if (flag && worldserver.isEmptyBlock(blockposition3) && isAcceptableNeighbour(worldserver, blockposition.relative(enumdirection1), enumdirection3)) { +- worldserver.setBlock(blockposition3, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection3), true), 2); ++ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition3, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection3), true), 2); + } else if (flag1 && worldserver.isEmptyBlock(blockposition4) && isAcceptableNeighbour(worldserver, blockposition.relative(enumdirection2), enumdirection3)) { +- worldserver.setBlock(blockposition4, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection3), true), 2); ++ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition4, (IBlockData) this.defaultBlockState().setValue(getPropertyForFace(enumdirection3), true), 2); + } else if ((double) randomsource.nextFloat() < 0.05D && isAcceptableNeighbour(worldserver, blockposition2.above(), EnumDirection.UP)) { +- worldserver.setBlock(blockposition2, (IBlockData) this.defaultBlockState().setValue(BlockVine.UP, true), 2); ++ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition2, (IBlockData) this.defaultBlockState().setValue(BlockVine.UP, true), 2); + } ++ // CraftBukkit end + } + } else if (isAcceptableNeighbour(worldserver, blockposition2, enumdirection)) { + worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(getPropertyForFace(enumdirection), true), 2); +@@ -239,7 +245,7 @@ } -+ // CraftBukkit end - } - } else if (isAcceptableNeighbour(worldserver, blockposition2, enumdirection)) { - worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(getPropertyForFace(enumdirection), true), 2); -@@ -237,7 +243,7 @@ - } - if (this.hasHorizontalConnection(iblockdata2)) { -- worldserver.setBlock(blockposition1, iblockdata2, 2); -+ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, iblockdata2, 2); // CraftBukkit - } + if (this.hasHorizontalConnection(iblockdata2)) { +- worldserver.setBlock(blockposition1, iblockdata2, 2); ++ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, iblockdata2, 2); // CraftBukkit + } - return; -@@ -252,7 +258,7 @@ - IBlockData iblockdata4 = this.copyRandomFaces(iblockdata, iblockdata3, randomsource); + return; +@@ -254,7 +260,7 @@ + IBlockData iblockdata4 = this.copyRandomFaces(iblockdata, iblockdata3, randomsource); - if (iblockdata3 != iblockdata4 && this.hasHorizontalConnection(iblockdata4)) { -- worldserver.setBlock(blockposition2, iblockdata4, 2); -+ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition2, iblockdata4, 2); // CraftBukkit + if (iblockdata3 != iblockdata4 && this.hasHorizontalConnection(iblockdata4)) { +- worldserver.setBlock(blockposition2, iblockdata4, 2); ++ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition2, iblockdata4, 2); // CraftBukkit + } } } - } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch index 7a3a2730ad..df365ea75e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/BlockWitherRose.java +++ b/net/minecraft/world/level/block/BlockWitherRose.java -@@ -51,7 +51,7 @@ +@@ -50,7 +50,7 @@ EntityLiving entityliving = (EntityLiving) entity; - if (!entityliving.isInvulnerableTo(DamageSource.WITHER)) { + if (!entityliving.isInvulnerableTo(world.damageSources().wither())) { - entityliving.addEffect(new MobEffect(MobEffects.WITHER, 40)); + entityliving.addEffect(new MobEffect(MobEffects.WITHER, 40), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.WITHER_ROSE); // CraftBukkit } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/CaveVines.patch b/paper-server/nms-patches/net/minecraft/world/level/block/CaveVines.patch index d07a483e6e..bc3d5a4c02 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/CaveVines.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/CaveVines.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/CaveVines.java +++ b/net/minecraft/world/level/block/CaveVines.java -@@ -15,14 +15,39 @@ - import net.minecraft.world.level.block.state.properties.BlockStateBoolean; +@@ -18,6 +18,14 @@ + import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.shapes.VoxelShape; +// CraftBukkit start @@ -15,10 +15,9 @@ public interface CaveVines { VoxelShape SHAPE = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D); - BlockStateBoolean BERRIES = BlockProperties.BERRIES; +@@ -25,7 +33,24 @@ -- static EnumInteractionResult use(IBlockData iblockdata, World world, BlockPosition blockposition) { -+ static EnumInteractionResult use(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + static EnumInteractionResult use(@Nullable Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) { if ((Boolean) iblockdata.getValue(CaveVines.BERRIES)) { - Block.popResource(world, blockposition, new ItemStack(Items.GLOW_BERRIES, 1)); + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/CaveVinesBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/CaveVinesBlock.patch deleted file mode 100644 index db14d66238..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/level/block/CaveVinesBlock.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/block/CaveVinesBlock.java -+++ b/net/minecraft/world/level/block/CaveVinesBlock.java -@@ -58,7 +58,7 @@ - - @Override - public EnumInteractionResult use(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) { -- return CaveVines.use(iblockdata, world, blockposition); -+ return CaveVines.use(iblockdata, world, blockposition, entityhuman); // CraftBukkit - } - - @Override diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/CaveVinesPlantBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/CaveVinesPlantBlock.patch deleted file mode 100644 index 15243ccf44..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/level/block/CaveVinesPlantBlock.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/block/CaveVinesPlantBlock.java -+++ b/net/minecraft/world/level/block/CaveVinesPlantBlock.java -@@ -41,7 +41,7 @@ - - @Override - public EnumInteractionResult use(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) { -- return CaveVines.use(iblockdata, world, blockposition); -+ return CaveVines.use(iblockdata, world, blockposition, entityhuman); // CraftBukkit - } - - @Override diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch index f56a0f7281..55ccc81511 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch @@ -29,7 +29,7 @@ public void fallOn(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, float f) { if (iblockdata.getValue(PointedDripstoneBlock.TIP_DIRECTION) == EnumDirection.UP && iblockdata.getValue(PointedDripstoneBlock.THICKNESS) == DripstoneThickness.TIP) { + CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); // CraftBukkit - entity.causeFallDamage(f + 2.0F, 2.0F, DamageSource.STALAGMITE); + entity.causeFallDamage(f + 2.0F, 2.0F, world.damageSources().stalagmite()); + CraftEventFactory.blockDamage = null; // CraftBukkit } else { super.fallOn(world, iblockdata, blockposition, entity, f); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch index 7c920860c6..74b4b219cc 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityBrewingStand.java +++ b/net/minecraft/world/level/block/entity/TileEntityBrewingStand.java -@@ -24,6 +24,20 @@ +@@ -25,6 +25,20 @@ import net.minecraft.world.level.block.BlockBrewingStand; import net.minecraft.world.level.block.state.IBlockData; @@ -21,7 +21,7 @@ public class TileEntityBrewingStand extends TileEntityContainer implements IWorldInventory { private static final int INGREDIENT_SLOT = 3; -@@ -41,6 +55,36 @@ +@@ -42,6 +56,36 @@ private Item ingredient; public int fuel; protected final IContainerProperties dataAccess; @@ -58,7 +58,7 @@ public TileEntityBrewingStand(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.BREWING_STAND, blockposition, iblockdata); -@@ -108,8 +152,19 @@ +@@ -109,8 +153,19 @@ ItemStack itemstack = (ItemStack) tileentitybrewingstand.items.get(4); if (tileentitybrewingstand.fuel <= 0 && itemstack.is(Items.BLAZE_POWDER)) { @@ -80,7 +80,7 @@ setChanged(world, blockposition, iblockdata); } -@@ -117,12 +172,17 @@ +@@ -118,12 +173,17 @@ boolean flag1 = tileentitybrewingstand.brewTime > 0; ItemStack itemstack1 = (ItemStack) tileentitybrewingstand.items.get(3); @@ -101,7 +101,7 @@ setChanged(world, blockposition, iblockdata); } else if (!flag || !itemstack1.is(tileentitybrewingstand.ingredient)) { tileentitybrewingstand.brewTime = 0; -@@ -130,7 +190,11 @@ +@@ -131,7 +191,11 @@ } } else if (flag && tileentitybrewingstand.fuel > 0) { --tileentitybrewingstand.fuel; @@ -114,7 +114,7 @@ tileentitybrewingstand.ingredient = itemstack1.getItem(); setChanged(world, blockposition, iblockdata); } -@@ -186,11 +250,33 @@ +@@ -187,11 +251,33 @@ } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch index 3002ce3ec0..ed07d7116d 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityConduit.java +++ b/net/minecraft/world/level/block/entity/TileEntityConduit.java -@@ -28,6 +28,11 @@ +@@ -27,6 +27,11 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -12,7 +12,7 @@ public class TileEntityConduit extends TileEntity { private static final int BLOCK_REFRESH_RATE = 2; -@@ -202,7 +207,7 @@ +@@ -201,7 +206,7 @@ EntityHuman entityhuman = (EntityHuman) iterator.next(); if (blockposition.closerThan(entityhuman.blockPosition(), (double) j) && entityhuman.isInWaterOrRain()) { @@ -21,15 +21,15 @@ } } -@@ -231,8 +236,13 @@ +@@ -230,8 +235,13 @@ } if (tileentityconduit.destroyTarget != null) { - world.playSound((EntityHuman) null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F); -- tileentityconduit.destroyTarget.hurt(DamageSource.MAGIC, 4.0F); +- tileentityconduit.destroyTarget.hurt(world.damageSources().magic(), 4.0F); + // CraftBukkit start + CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); -+ if (tileentityconduit.destroyTarget.hurt(DamageSource.MAGIC, 4.0F)) { ++ if (tileentityconduit.destroyTarget.hurt(world.damageSources().magic(), 4.0F)) { + world.playSound((EntityHuman) null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F); + } + CraftEventFactory.blockDamage = null; diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch index a7766b64ab..4b0c1e7694 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityFurnace.java +++ b/net/minecraft/world/level/block/entity/TileEntityFurnace.java -@@ -46,6 +46,20 @@ +@@ -47,6 +47,20 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.Vec3D; @@ -21,7 +21,7 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeHolder, AutoRecipeOutput { protected static final int SLOT_INPUT = 0; -@@ -114,7 +128,7 @@ +@@ -115,7 +129,7 @@ } }; this.recipesUsed = new Object2IntOpenHashMap(); @@ -30,7 +30,7 @@ } public static Map getFuel() { -@@ -182,6 +196,40 @@ +@@ -183,6 +197,40 @@ return map; } @@ -71,7 +71,7 @@ private static boolean isNeverAFurnaceFuel(Item item) { return item.builtInRegistryHolder().is(TagsItem.NON_FLAMMABLE_WOOD); } -@@ -270,7 +318,7 @@ +@@ -271,7 +319,7 @@ IRecipe irecipe; if (flag2) { @@ -80,10 +80,10 @@ } else { irecipe = null; } -@@ -278,9 +326,20 @@ +@@ -279,9 +327,20 @@ int i = tileentityfurnace.getMaxStackSize(); - if (!tileentityfurnace.isLit() && canBurn(irecipe, tileentityfurnace.items, i)) { + if (!tileentityfurnace.isLit() && canBurn(world.registryAccess(), irecipe, tileentityfurnace.items, i)) { - tileentityfurnace.litTime = tileentityfurnace.getBurnDuration(itemstack); + // CraftBukkit start + CraftItemStack fuel = CraftItemStack.asCraftMirror(itemstack); @@ -103,10 +103,10 @@ flag1 = true; if (flag3) { Item item = itemstack.getItem(); -@@ -296,11 +355,23 @@ +@@ -297,11 +356,23 @@ } - if (tileentityfurnace.isLit() && canBurn(irecipe, tileentityfurnace.items, i)) { + if (tileentityfurnace.isLit() && canBurn(world.registryAccess(), irecipe, tileentityfurnace.items, i)) { + // CraftBukkit start + if (irecipe != null && tileentityfurnace.cookingProgress == 0) { + CraftItemStack source = CraftItemStack.asCraftMirror(tileentityfurnace.items.get(0)); @@ -123,20 +123,20 @@ if (tileentityfurnace.cookingProgress == tileentityfurnace.cookingTotalTime) { tileentityfurnace.cookingProgress = 0; tileentityfurnace.cookingTotalTime = getTotalCookTime(world, tileentityfurnace); -- if (burn(irecipe, tileentityfurnace.items, i)) { -+ if (burn(tileentityfurnace.level, tileentityfurnace.worldPosition, irecipe, tileentityfurnace.items, i)) { // CraftBukkit +- if (burn(world.registryAccess(), irecipe, tileentityfurnace.items, i)) { ++ if (burn(tileentityfurnace.level, tileentityfurnace.worldPosition, world.registryAccess(), irecipe, tileentityfurnace.items, i)) { // CraftBukkit tileentityfurnace.setRecipeUsed(irecipe); } -@@ -339,17 +410,44 @@ +@@ -340,17 +411,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)) { +- private static boolean burn(IRegistryCustom iregistrycustom, @Nullable IRecipe irecipe, NonNullList nonnulllist, int i) { ++ private static boolean burn(World world, BlockPosition blockposition, IRegistryCustom iregistrycustom, @Nullable IRecipe irecipe, NonNullList nonnulllist, int i) { // CraftBukkit + if (irecipe != null && canBurn(iregistrycustom, irecipe, nonnulllist, i)) { ItemStack itemstack = (ItemStack) nonnulllist.get(0); - ItemStack itemstack1 = irecipe.getResultItem(); + ItemStack itemstack1 = irecipe.getResultItem(iregistrycustom); ItemStack itemstack2 = (ItemStack) nonnulllist.get(2); + // CraftBukkit start - fire FurnaceSmeltEvent @@ -174,7 +174,7 @@ if (itemstack.is(Blocks.WET_SPONGE.asItem()) && !((ItemStack) nonnulllist.get(1)).isEmpty() && ((ItemStack) nonnulllist.get(1)).is(Items.BUCKET)) { nonnulllist.set(1, new ItemStack(Items.WATER_BUCKET)); -@@ -373,7 +471,7 @@ +@@ -374,7 +472,7 @@ } private static int getTotalCookTime(World world, TileEntityFurnace tileentityfurnace) { @@ -183,7 +183,7 @@ } public static boolean isFuel(ItemStack itemstack) { -@@ -492,14 +590,20 @@ +@@ -493,14 +591,20 @@ @Override public void awardUsedRecipes(EntityHuman entityhuman) {} @@ -206,7 +206,7 @@ List> list = Lists.newArrayList(); ObjectIterator objectiterator = this.recipesUsed.object2IntEntrySet().iterator(); -@@ -508,14 +612,14 @@ +@@ -509,14 +613,14 @@ worldserver.getRecipeManager().byKey((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> { list.add(irecipe); @@ -223,7 +223,7 @@ int j = MathHelper.floor((float) i * f); float f1 = MathHelper.frac((float) i * f); -@@ -523,6 +627,17 @@ +@@ -524,6 +628,17 @@ ++j; } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityHopper.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityHopper.patch index 765ada6f07..f6c7f252df 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityHopper.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityHopper.patch @@ -109,9 +109,9 @@ if (itemstack1.isEmpty()) { iinventory1.setChanged(); -@@ -226,7 +294,36 @@ +@@ -226,7 +294,34 @@ - if (!itemstack.isEmpty() && canTakeItemFromContainer(iinventory, itemstack, i, enumdirection)) { + if (!itemstack.isEmpty() && canTakeItemFromContainer(ihopper, iinventory, itemstack, i, enumdirection)) { ItemStack itemstack1 = itemstack.copy(); - ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.removeItem(i, 1), (EnumDirection) null); + // ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.removeItem(i, 1), (EnumDirection) null); @@ -136,8 +136,6 @@ + + if (ihopper instanceof TileEntityHopper) { + ((TileEntityHopper) ihopper).setCooldown(8); // Delay hopper checks -+ } else if (ihopper instanceof EntityMinecartHopper) { -+ ((EntityMinecartHopper) ihopper).setCooldown(4); // Delay hopper minecart checks + } + + return false; @@ -147,7 +145,7 @@ if (itemstack2.isEmpty()) { iinventory.setChanged(); -@@ -241,6 +338,13 @@ +@@ -241,6 +336,13 @@ public static boolean addItem(IInventory iinventory, EntityItem entityitem) { boolean flag = false; @@ -161,7 +159,7 @@ ItemStack itemstack = entityitem.getItem().copy(); ItemStack itemstack1 = addItem((IInventory) null, iinventory, itemstack, (EnumDirection) null); -@@ -327,16 +431,40 @@ +@@ -366,16 +468,40 @@ return itemstack; } @@ -196,7 +194,7 @@ + // CraftBukkit start + IInventory inventory = getContainerAt(world, ihopper.getLevelX(), ihopper.getLevelY() + 1.0D, ihopper.getLevelZ()); + -+ BlockPosition blockPosition = new BlockPosition(ihopper.getLevelX(), ihopper.getLevelY(), ihopper.getLevelZ()); ++ BlockPosition blockPosition = BlockPosition.containing(ihopper.getLevelX(), ihopper.getLevelY(), ihopper.getLevelZ()); + CraftBlock hopper = CraftBlock.at(world, blockPosition); + CraftBlock container = CraftBlock.at(world, blockPosition.above()); + return runHopperInventorySearchEvent(inventory, hopper, container, HopperInventorySearchEvent.ContainerType.SOURCE); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch index fc5525d25f..abe72eb95b 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityLectern.java +++ b/net/minecraft/world/level/block/entity/TileEntityLectern.java -@@ -24,13 +24,71 @@ +@@ -25,13 +25,71 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; @@ -74,7 +74,7 @@ @Override public int getContainerSize() { return 1; -@@ -75,11 +133,20 @@ +@@ -76,11 +134,20 @@ } @Override @@ -84,7 +84,7 @@ + if (i == 0) { + TileEntityLectern.this.setBook(itemstack); + if (TileEntityLectern.this.getLevel() != null) { -+ BlockLectern.resetBookState(TileEntityLectern.this.getLevel(), TileEntityLectern.this.getBlockPos(), TileEntityLectern.this.getBlockState(), TileEntityLectern.this.hasBook()); ++ BlockLectern.resetBookState(null, TileEntityLectern.this.getLevel(), TileEntityLectern.this.getBlockPos(), TileEntityLectern.this.getBlockState(), TileEntityLectern.this.hasBook()); + } + } + } @@ -97,7 +97,7 @@ } @Override -@@ -159,7 +226,7 @@ +@@ -160,7 +227,7 @@ if (j != this.page) { this.page = j; this.setChanged(); @@ -106,7 +106,7 @@ } } -@@ -182,6 +249,32 @@ +@@ -183,6 +250,32 @@ return itemstack; } @@ -139,7 +139,7 @@ private CommandListenerWrapper createCommandSourceStack(@Nullable EntityHuman entityhuman) { String s; Object object; -@@ -196,7 +289,8 @@ +@@ -197,7 +290,8 @@ Vec3D vec3d = Vec3D.atCenterOf(this.worldPosition); @@ -149,7 +149,7 @@ } @Override -@@ -234,7 +328,7 @@ +@@ -235,7 +329,7 @@ @Override public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntitySkull.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntitySkull.patch deleted file mode 100644 index 98f24e98df..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntitySkull.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/world/level/block/entity/TileEntitySkull.java -+++ b/net/minecraft/world/level/block/entity/TileEntitySkull.java -@@ -33,7 +33,7 @@ - @Nullable - public GameProfile owner; - @Nullable -- private MinecraftKey noteBlockSound; -+ public MinecraftKey noteBlockSound; // PAIL private->public - private int animationTickCount; - private boolean isAnimating; - -@@ -148,9 +148,12 @@ - gameprofile1 = TileEntitySkull.sessionService.fillProfileProperties(gameprofile1, true); - } - -+ // CraftBukkit start - decompile error -+ final GameProfile finalgameprofile1 = gameprofile1; - TileEntitySkull.mainThreadExecutor.execute(() -> { -- TileEntitySkull.profileCache.add(gameprofile1); -- consumer.accept(gameprofile1); -+ TileEntitySkull.profileCache.add(finalgameprofile1); -+ consumer.accept(finalgameprofile1); -+ // CraftBukkit end - }); - }, () -> { - TileEntitySkull.mainThreadExecutor.execute(() -> { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch b/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch index cd90f3836e..2993774835 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch @@ -27,7 +27,7 @@ WorldGenFeatureConfigured worldgenfeatureconfigured = (WorldGenFeatureConfigured) holder.value(); IBlockData iblockdata1 = worldserver.getFluidState(blockposition).createLegacyBlock(); -@@ -65,4 +72,53 @@ +@@ -65,4 +72,55 @@ return true; } @@ -75,6 +75,8 @@ + BlockSapling.treeType = TreeType.MANGROVE; + } else if (worldgentreeabstract == TreeFeatures.TALL_MANGROVE) { + BlockSapling.treeType = TreeType.TALL_MANGROVE; ++ } else if (worldgentreeabstract == TreeFeatures.CHERRY || worldgentreeabstract == TreeFeatures.CHERRY_BEES_005) { ++ BlockSapling.treeType = TreeType.CHERRY; + } else { + throw new IllegalArgumentException("Unknown tree generator " + worldgentreeabstract); + } diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/Chunk.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/Chunk.patch index 0d6d691e48..5d3ffc729f 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/Chunk.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/Chunk.patch @@ -174,7 +174,7 @@ public boolean isEmpty() { return false; } -@@ -682,7 +773,7 @@ +@@ -694,7 +785,7 @@ private void updateBlockEntityTicker(T t0) { IBlockData iblockdata = t0.getBlockState(); @@ -183,7 +183,7 @@ if (blockentityticker == null) { this.removeBlockEntityTicker(t0.getBlockPos()); -@@ -775,7 +866,7 @@ +@@ -787,7 +878,7 @@ private boolean loggedInvalidBlockState; a(TileEntity tileentity, BlockEntityTicker blockentityticker) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch index 9ac068eaf0..6edbdac25e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch @@ -14,7 +14,7 @@ this.bottomBlockY = getBottomBlockY(i); this.states = datapaletteblock; this.biomes = palettedcontainerro; -@@ -193,6 +195,12 @@ +@@ -200,6 +202,12 @@ return (Holder) this.biomes.get(i, j, k); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch index fd8424238c..1ba1576bf2 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch @@ -83,8 +83,8 @@ + public static NBTTagCompound write(WorldServer worldserver, IChunkAccess ichunkaccess) { ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos(); - NBTTagCompound nbttagcompound = new NBTTagCompound(); -@@ -340,7 +353,7 @@ + NBTTagCompound nbttagcompound = GameProfileSerializer.addCurrentDataVersion(new NBTTagCompound()); +@@ -339,7 +352,7 @@ nbttagcompound.putLong("InhabitedTime", ichunkaccess.getInhabitedTime()); nbttagcompound.putString("Status", ichunkaccess.getStatus().getName()); BlendingData blendingdata = ichunkaccess.getBlendingData(); @@ -93,7 +93,7 @@ Logger logger; if (blendingdata != null) { -@@ -387,7 +400,7 @@ +@@ -386,7 +399,7 @@ if (flag1) { ChunkSection chunksection = achunksection[j]; @@ -102,7 +102,7 @@ Logger logger1 = ChunkRegionLoader.LOGGER; Objects.requireNonNull(logger1); -@@ -471,6 +484,11 @@ +@@ -470,6 +483,11 @@ nbttagcompound.put("Heightmaps", nbttagcompound3); nbttagcompound.put("structures", packStructureData(StructurePieceSerializationContext.fromLevel(worldserver), chunkcoordintpair, ichunkaccess.getAllStarts(), ichunkaccess.getAllReferences())); diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch index 88369f4ce5..3b86f06e19 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch @@ -69,7 +69,7 @@ + // CraftBukkit end + if (i < 1493) { - nbttagcompound = GameProfileSerializer.update(this.fixerUpper, DataFixTypes.CHUNK, nbttagcompound, i, 1493); + nbttagcompound = DataFixTypes.CHUNK.update(this.fixerUpper, nbttagcompound, i, 1493); if (nbttagcompound.getCompound("Level").getBoolean("hasLegacyStructureData")) { @@ -58,7 +111,7 @@ return nbttagcompound; diff --git a/paper-server/nms-patches/net/minecraft/world/level/gameevent/GameEventDispatcher.patch b/paper-server/nms-patches/net/minecraft/world/level/gameevent/GameEventDispatcher.patch index 44296cb98b..910379a6cc 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/gameevent/GameEventDispatcher.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/gameevent/GameEventDispatcher.patch @@ -18,7 +18,7 @@ @@ -22,6 +30,14 @@ public void post(GameEvent gameevent, Vec3D vec3d, GameEvent.a gameevent_a) { int i = gameevent.getNotificationRadius(); - BlockPosition blockposition = new BlockPosition(vec3d); + BlockPosition blockposition = BlockPosition.containing(vec3d); + // CraftBukkit start + GenericGameEvent event = new GenericGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.GAME_EVENT.getKey(gameevent))), new Location(level.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()), (gameevent_a.sourceEntity() == null) ? null : gameevent_a.sourceEntity().getBukkitEntity(), i, !Bukkit.isPrimaryThread()); + level.getCraftServer().getPluginManager().callEvent(event); diff --git a/paper-server/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationListener.patch b/paper-server/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationListener.patch index 570dac0212..8fe15813c2 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationListener.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationListener.patch @@ -14,7 +14,7 @@ public class VibrationListener implements GameEventListener { @VisibleForTesting -@@ -96,7 +103,7 @@ +@@ -98,7 +105,7 @@ }), ExtraCodecs.NON_NEGATIVE_INT.fieldOf("event_delay").orElse(0).forGetter((vibrationlistener) -> { return vibrationlistener.travelTimeInTicks; })).apply(instance, (positionsource, integer, optional, vibrationselector, integer1) -> { @@ -23,24 +23,25 @@ }); }); } -@@ -138,7 +145,7 @@ +@@ -140,7 +147,8 @@ --this.travelTimeInTicks; if (this.travelTimeInTicks <= 0) { this.travelTimeInTicks = 0; -- this.config.onSignalReceive(worldserver, this, new BlockPosition(this.currentVibration.pos()), this.currentVibration.gameEvent(), (Entity) this.currentVibration.getEntity(worldserver).orElse((Object) null), (Entity) this.currentVibration.getProjectileOwner(worldserver).orElse((Object) null), this.currentVibration.distance()); -+ this.config.onSignalReceive(worldserver, this, new BlockPosition(this.currentVibration.pos()), this.currentVibration.gameEvent(), (Entity) this.currentVibration.getEntity(worldserver).orElse(null), (Entity) this.currentVibration.getProjectileOwner(worldserver).orElse(null), this.currentVibration.distance()); // CraftBukkit - decompile error +- this.config.onSignalReceive(worldserver, this, BlockPosition.containing(this.currentVibration.pos()), this.currentVibration.gameEvent(), (Entity) this.currentVibration.getEntity(worldserver).orElse((Object) null), (Entity) this.currentVibration.getProjectileOwner(worldserver).orElse((Object) null), this.currentVibration.distance()); ++ // CraftBukkit - decompile error ++ this.config.onSignalReceive(worldserver, this, BlockPosition.containing(this.currentVibration.pos()), this.currentVibration.gameEvent(), (Entity) this.currentVibration.getEntity(worldserver).orElse(null), (Entity) this.currentVibration.getProjectileOwner(worldserver).orElse(null), this.currentVibration.distance()); this.currentVibration = null; } } -@@ -170,7 +177,14 @@ +@@ -172,7 +180,14 @@ } else { Vec3D vec3d1 = (Vec3D) optional.get(); -- if (!this.config.shouldListen(worldserver, this, new BlockPosition(vec3d), gameevent, gameevent_a)) { +- if (!this.config.shouldListen(worldserver, this, BlockPosition.containing(vec3d), gameevent, gameevent_a)) { + // CraftBukkit start -+ boolean defaultCancel = !this.config.shouldListen(worldserver, this, new BlockPosition(vec3d), gameevent, gameevent_a); ++ boolean defaultCancel = !this.config.shouldListen(worldserver, this, BlockPosition.containing(vec3d), gameevent, gameevent_a); + Entity entity = gameevent_a.sourceEntity(); -+ BlockReceiveGameEvent event = new BlockReceiveGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.GAME_EVENT.getKey(gameevent))), CraftBlock.at(worldserver, new BlockPosition(vec3d1)), (entity == null) ? null : entity.getBukkitEntity()); ++ BlockReceiveGameEvent event = new BlockReceiveGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.GAME_EVENT.getKey(gameevent))), CraftBlock.at(worldserver, BlockPosition.containing(vec3d1)), (entity == null) ? null : entity.getBukkitEntity()); + event.setCancelled(defaultCancel); + worldserver.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch index 2c78f77e79..c056443fcb 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java -@@ -52,6 +52,12 @@ +@@ -51,6 +51,12 @@ import net.minecraft.world.phys.shapes.VoxelShapeBitSet; import net.minecraft.world.phys.shapes.VoxelShapeDiscrete; @@ -13,7 +13,7 @@ public class DefinedStructure { public static final String PALETTE_TAG = "palette"; -@@ -71,6 +77,11 @@ +@@ -69,6 +75,11 @@ private BaseBlockPosition size; private String author; @@ -25,7 +25,7 @@ public DefinedStructure() { this.size = BaseBlockPosition.ZERO; this.author = "?"; -@@ -144,7 +155,7 @@ +@@ -142,7 +153,7 @@ } private static List buildInfoList(List list, List list1, List list2) { @@ -34,7 +34,7 @@ return definedstructure_blockinfo.pos.getY(); }).thenComparingInt((definedstructure_blockinfo) -> { return definedstructure_blockinfo.pos.getX(); -@@ -465,11 +476,13 @@ +@@ -471,11 +482,13 @@ } private static Optional createEntityIgnoreException(WorldAccess worldaccess, NBTTagCompound nbttagcompound) { @@ -52,21 +52,19 @@ } public BaseBlockPosition getSize(EnumBlockRotation enumblockrotation) { -@@ -684,6 +697,13 @@ +@@ -689,6 +702,11 @@ + nbttagcompound.put("entities", nbttaglist3); nbttagcompound.put("size", this.newIntegerList(this.size.getX(), this.size.getY(), this.size.getZ())); - nbttagcompound.putInt("DataVersion", SharedConstants.getCurrentVersion().getWorldVersion()); -+ -+ // CraftBukkit Start - PDC ++ // CraftBukkit start - PDC + if (!this.persistentDataContainer.isEmpty()) { + nbttagcompound.put("BukkitValues", this.persistentDataContainer.toTagCompound()); + } + // CraftBukkit end -+ - return nbttagcompound; + return GameProfileSerializer.addCurrentDataVersion(nbttagcompound); } -@@ -723,6 +743,12 @@ +@@ -728,6 +746,12 @@ } } @@ -79,7 +77,7 @@ } private void loadPalette(HolderGetter holdergetter, NBTTagList nbttaglist, NBTTagList nbttaglist1) { -@@ -862,7 +888,7 @@ +@@ -867,7 +891,7 @@ public IBlockData stateFor(int i) { IBlockData iblockdata = (IBlockData) this.ids.byId(i); diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/Convertable.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/Convertable.patch index fc64e3ad35..86d795c4cc 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/Convertable.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/Convertable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/Convertable.java +++ b/net/minecraft/world/level/storage/Convertable.java -@@ -69,6 +69,10 @@ +@@ -68,6 +68,10 @@ import net.minecraft.world.level.levelgen.WorldDimensions; import org.slf4j.Logger; @@ -11,7 +11,7 @@ public class Convertable { static final Logger LOGGER = LogUtils.getLogger(); -@@ -115,7 +119,7 @@ +@@ -114,7 +118,7 @@ } private static WorldDataConfiguration readDataConfig(Dynamic dynamic) { @@ -20,7 +20,7 @@ Logger logger = Convertable.LOGGER; Objects.requireNonNull(logger); -@@ -253,6 +257,7 @@ +@@ -252,6 +256,7 @@ WorldDimensions.b worlddimensions_b = generatorsettings.dimensions().bake(iregistry); Lifecycle lifecycle1 = worlddimensions_b.lifecycle().add(lifecycle); WorldDataServer worlddataserver = WorldDataServer.parse(dynamic, datafixer, i, nbttagcompound2, worldsettings, levelversion, worlddimensions_b.specialWorldProperty(), generatorsettings.options(), lifecycle1); @@ -28,7 +28,7 @@ return Pair.of(worlddataserver, worlddimensions_b); }; -@@ -334,9 +339,23 @@ +@@ -333,9 +338,23 @@ return this.backupDir; } @@ -54,7 +54,7 @@ public static record a(List levels) implements Iterable { -@@ -389,8 +408,12 @@ +@@ -388,8 +407,12 @@ public final Convertable.b levelDirectory; private final String levelId; private final Map resources = Maps.newHashMap(); @@ -68,7 +68,7 @@ this.levelId = s; this.levelDirectory = new Convertable.b(Convertable.this.baseDir.resolve(s)); this.lock = SessionLock.create(this.levelDirectory.path()); -@@ -401,7 +424,7 @@ +@@ -400,7 +423,7 @@ } public Path getLevelPath(SavedFile savedfile) { @@ -77,7 +77,7 @@ Convertable.b convertable_b = this.levelDirectory; Objects.requireNonNull(this.levelDirectory); -@@ -409,7 +432,7 @@ +@@ -408,7 +431,7 @@ } public Path getDimensionPath(ResourceKey resourcekey) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch index 36d2fa5b2c..469665ecdd 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch @@ -42,8 +42,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, WorldOptions worldoptions, WorldDataServer.a worlddataserver_a, Lifecycle lifecycle) { this.fixerUpper = datafixer; @@ -127,7 +154,8 @@ - return (NBTBase) dynamic.get("DimensionData").get("1").get("DragonFight").orElseEmptyMap().getValue(); - }); + return dynamic.get("DimensionData").get("1").get("DragonFight").orElseEmptyMap(); + })).convert(DynamicOpsNBT.INSTANCE).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.levelDataVersion(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.read(dynamic, WorldBorder.DEFAULT_SETTINGS), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(UUIDUtil.CODEC).result().orElse((Object) null), (Set) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> { + // CraftBukkit - decompile error @@ -62,7 +62,7 @@ stream.forEach(nbttaglist::add); @@ -162,7 +190,7 @@ nbttagcompound.put("Version", nbttagcompound2); - nbttagcompound.putInt("DataVersion", SharedConstants.getCurrentVersion().getWorldVersion()); + GameProfileSerializer.addCurrentDataVersion(nbttagcompound); DynamicOps dynamicops = RegistryOps.create(DynamicOpsNBT.INSTANCE, (HolderLookup.b) iregistrycustom); - DataResult dataresult = GeneratorSettings.encode(dynamicops, this.worldOptions, iregistrycustom); + DataResult dataresult = GeneratorSettings.encode(dynamicops, this.worldOptions, new WorldDimensions(this.customDimensions != null ? this.customDimensions : iregistrycustom.registryOrThrow(Registries.LEVEL_STEM))); // CraftBukkit diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/WorldNBTStorage.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/WorldNBTStorage.patch index 54680bac3b..89458a8fd4 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/WorldNBTStorage.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/WorldNBTStorage.patch @@ -28,9 +28,9 @@ + } + } + // CraftBukkit end - int i = nbttagcompound.contains("DataVersion", 3) ? nbttagcompound.getInt("DataVersion") : -1; + int i = GameProfileSerializer.getDataVersion(nbttagcompound, -1); - entityhuman.load(GameProfileSerializer.update(this.fixerUpper, DataFixTypes.PLAYER, nbttagcompound, i)); + entityhuman.load(DataFixTypes.PLAYER.updateToCurrentVersion(this.fixerUpper, nbttagcompound, i)); @@ -63,6 +80,22 @@ return nbttagcompound; } diff --git a/paper-server/pom.xml b/paper-server/pom.xml index 2bc1445a97..f2b51f20b7 100644 --- a/paper-server/pom.xml +++ b/paper-server/pom.xml @@ -4,7 +4,7 @@ org.bukkit craftbukkit jar - 1.19.3-R0.1-SNAPSHOT + 1.19.4-R0.1-SNAPSHOT CraftBukkit https://www.spigotmc.org/ @@ -13,7 +13,7 @@ UTF-8 unknown git - 1_19_R2 + 1_19_R3 17 17 @@ -67,7 +67,7 @@ com.mojang authlib - 3.16.29 + 3.17.30 compile @@ -79,13 +79,7 @@ com.mojang datafixerupper - 5.0.28 - compile - - - com.mojang - javabridge - 2.0.25 + 6.0.6 compile @@ -204,12 +198,6 @@ 2.19.0 compile - - org.joml - joml - 1.10.5 - compile - org.slf4j slf4j-api @@ -233,13 +221,13 @@ org.xerial sqlite-jdbc - 3.36.0.3 + 3.41.0.0 runtime - mysql - mysql-connector-java - 8.0.29 + com.mysql + mysql-connector-j + 8.0.32 runtime @@ -529,26 +517,6 @@ - - org.codehaus.mojo - animal-sniffer-maven-plugin - 1.21 - - - process-classes - - - - - - - - org.codehaus.mojo.signature - java18 - 1.0 - - - diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java index b8b6036bdd..bccb15ec8f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java @@ -92,7 +92,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { if (context.getLootedEntity() != null) { Entity nmsLootedEntity = ((CraftEntity) context.getLootedEntity()).getHandle(); setMaybe(builder, LootContextParameters.THIS_ENTITY, nmsLootedEntity); - setMaybe(builder, LootContextParameters.DAMAGE_SOURCE, DamageSource.GENERIC); + setMaybe(builder, LootContextParameters.DAMAGE_SOURCE, handle.damageSources().generic()); setMaybe(builder, LootContextParameters.ORIGIN, nmsLootedEntity.position()); } @@ -100,7 +100,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { EntityHuman nmsKiller = ((CraftHumanEntity) context.getKiller()).getHandle(); setMaybe(builder, LootContextParameters.KILLER_ENTITY, nmsKiller); // If there is a player killer, damage source should reflect that in case loot tables use that information - setMaybe(builder, LootContextParameters.DAMAGE_SOURCE, DamageSource.playerAttack(nmsKiller)); + setMaybe(builder, LootContextParameters.DAMAGE_SOURCE, handle.damageSources().playerAttack(nmsKiller)); setMaybe(builder, LootContextParameters.LAST_DAMAGE_PLAYER, nmsKiller); // SPIGOT-5603 - Set minecraft:killed_by_player setMaybe(builder, LootContextParameters.TOOL, nmsKiller.getUseItem()); // SPIGOT-6925 - Set minecraft:match_tool } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java index 0f6fff0865..25ba0b43b6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java @@ -132,6 +132,9 @@ public enum CraftParticle { SCULK_CHARGE("sculk_charge"), SCULK_CHARGE_POP("sculk_charge_pop"), SHRIEK("shriek"), + DRIPPING_CHERRY_LEAVES("dripping_cherry_leaves"), + FALLING_CHERRY_LEAVES("falling_cherry_leaves"), + LANDING_CHERRY_LEAVES("landing_cherry_leaves"), // ----- Legacy Separator ----- LEGACY_BLOCK_CRACK("block"), LEGACY_BLOCK_DUST("block"), diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java index cf5ba40807..297540d046 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java @@ -10,8 +10,6 @@ import java.util.function.Predicate; import net.minecraft.core.BlockPosition; import net.minecraft.core.EnumDirection; import net.minecraft.core.Holder; -import net.minecraft.core.IRegistry; -import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.data.worldgen.features.TreeFeatures; import net.minecraft.resources.ResourceKey; @@ -81,6 +79,7 @@ import org.bukkit.entity.Axolotl; import org.bukkit.entity.Bat; import org.bukkit.entity.Bee; import org.bukkit.entity.Blaze; +import org.bukkit.entity.BlockDisplay; import org.bukkit.entity.Boat; import org.bukkit.entity.Camel; import org.bukkit.entity.Cat; @@ -92,6 +91,7 @@ import org.bukkit.entity.Cod; import org.bukkit.entity.ComplexLivingEntity; import org.bukkit.entity.Cow; import org.bukkit.entity.Creeper; +import org.bukkit.entity.Display; import org.bukkit.entity.Dolphin; import org.bukkit.entity.Donkey; import org.bukkit.entity.DragonFireball; @@ -127,7 +127,9 @@ import org.bukkit.entity.Hoglin; import org.bukkit.entity.Husk; import org.bukkit.entity.Illager; import org.bukkit.entity.Illusioner; +import org.bukkit.entity.Interaction; import org.bukkit.entity.IronGolem; +import org.bukkit.entity.ItemDisplay; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.LeashHitch; import org.bukkit.entity.LightningStrike; @@ -165,6 +167,7 @@ import org.bukkit.entity.Skeleton; import org.bukkit.entity.SkeletonHorse; import org.bukkit.entity.Slime; import org.bukkit.entity.SmallFireball; +import org.bukkit.entity.Sniffer; import org.bukkit.entity.Snowball; import org.bukkit.entity.Snowman; import org.bukkit.entity.SpectralArrow; @@ -176,6 +179,7 @@ import org.bukkit.entity.Strider; import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.Tadpole; import org.bukkit.entity.Tameable; +import org.bukkit.entity.TextDisplay; import org.bukkit.entity.ThrownExpBottle; import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.TippedArrow; @@ -396,6 +400,9 @@ public abstract class CraftRegionAccessor implements RegionAccessor { case TALL_MANGROVE: gen = TreeFeatures.TALL_MANGROVE; break; + case CHERRY: + gen = TreeFeatures.CHERRY; + break; case TREE: default: gen = TreeFeatures.OAK; @@ -579,7 +586,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor { } entity.moveTo(x, y, z, yaw, pitch); } else if (FallingBlock.class.isAssignableFrom(clazz)) { - BlockPosition pos = new BlockPosition(x, y, z); + BlockPosition pos = BlockPosition.containing(x, y, z); entity = EntityFallingBlock.fall(world, pos, getHandle().getBlockState(pos)); } else if (Projectile.class.isAssignableFrom(clazz)) { if (Snowball.class.isAssignableFrom(clazz)) { @@ -856,6 +863,8 @@ public abstract class CraftRegionAccessor implements RegionAccessor { entity = EntityTypes.FROG.create(world); } else if (Warden.class.isAssignableFrom(clazz)) { entity = EntityTypes.WARDEN.create(world); + } else if (Sniffer.class.isAssignableFrom(clazz)) { + entity = EntityTypes.SNIFFER.create(world); } if (entity != null) { @@ -865,7 +874,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor { } else if (Hanging.class.isAssignableFrom(clazz)) { if (LeashHitch.class.isAssignableFrom(clazz)) { // SPIGOT-5732: LeashHitch has no direction and is always centered at a block - entity = new EntityLeash(world, new BlockPosition(x, y, z)); + entity = new EntityLeash(world, BlockPosition.containing(x, y, z)); } else { BlockFace face = BlockFace.SELF; BlockFace[] faces = new BlockFace[]{BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH}; @@ -879,7 +888,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor { faces = new BlockFace[]{BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH, BlockFace.UP, BlockFace.DOWN}; } - final BlockPosition pos = new BlockPosition(x, y, z); + final BlockPosition pos = BlockPosition.containing(x, y, z); for (BlockFace dir : faces) { IBlockData nmsBlock = getHandle().getBlockState(pos.relative(CraftBlock.blockFaceToNotch(dir))); if (nmsBlock.getMaterial().isSolid() || BlockDiodeAbstract.isDiode(nmsBlock)) { @@ -920,9 +929,9 @@ public abstract class CraftRegionAccessor implements RegionAccessor { } } else if (ItemFrame.class.isAssignableFrom(clazz)) { if (GlowItemFrame.class.isAssignableFrom(clazz)) { - entity = new net.minecraft.world.entity.decoration.GlowItemFrame(world, new BlockPosition(x, y, z), dir); + entity = new net.minecraft.world.entity.decoration.GlowItemFrame(world, BlockPosition.containing(x, y, z), dir); } else { - entity = new EntityItemFrame(world, new BlockPosition(x, y, z), dir); + entity = new EntityItemFrame(world, BlockPosition.containing(x, y, z), dir); } } } @@ -940,6 +949,21 @@ public abstract class CraftRegionAccessor implements RegionAccessor { } else if (Marker.class.isAssignableFrom(clazz)) { entity = EntityTypes.MARKER.create(world); entity.setPos(x, y, z); + } else if (Interaction.class.isAssignableFrom(clazz)) { + entity = EntityTypes.INTERACTION.create(world); + entity.setPos(x, y, z); + } else if (Display.class.isAssignableFrom(clazz)) { + if (BlockDisplay.class.isAssignableFrom(clazz)) { + entity = EntityTypes.BLOCK_DISPLAY.create(world); + } else if (ItemDisplay.class.isAssignableFrom(clazz)) { + entity = EntityTypes.ITEM_DISPLAY.create(world); + } else if (TextDisplay.class.isAssignableFrom(clazz)) { + entity = EntityTypes.TEXT_DISPLAY.create(world); + } + + if (entity != null) { + entity.setPos(x, y, z); + } } if (entity != null) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index d7425cee85..fba49a3a49 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -7,7 +7,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterators; import com.google.common.collect.Lists; import com.google.common.collect.MapMaker; -import com.google.gson.JsonObject; import com.mojang.authlib.GameProfile; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -16,20 +15,15 @@ import com.mojang.brigadier.tree.LiteralCommandNode; import com.mojang.datafixers.util.Pair; import com.mojang.serialization.DynamicOps; import com.mojang.serialization.Lifecycle; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufOutputStream; -import io.netty.buffer.Unpooled; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Base64; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -39,7 +33,6 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.UUID; @@ -108,12 +101,10 @@ import net.minecraft.world.level.WorldSettings; import net.minecraft.world.level.biome.BiomeManager; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.dimension.WorldDimension; -import net.minecraft.world.level.levelgen.GeneratorSettings; import net.minecraft.world.level.levelgen.MobSpawnerPatrol; import net.minecraft.world.level.levelgen.MobSpawnerPhantom; import net.minecraft.world.level.levelgen.WorldDimensions; import net.minecraft.world.level.levelgen.WorldOptions; -import net.minecraft.world.level.levelgen.presets.WorldPresets; import net.minecraft.world.level.material.FluidType; import net.minecraft.world.level.saveddata.maps.MapIcon; import net.minecraft.world.level.saveddata.maps.WorldMap; @@ -232,6 +223,8 @@ import org.bukkit.inventory.Recipe; import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.ShapelessRecipe; import org.bukkit.inventory.SmithingRecipe; +import org.bukkit.inventory.SmithingTransformRecipe; +import org.bukkit.inventory.SmithingTrimRecipe; import org.bukkit.inventory.SmokingRecipe; import org.bukkit.inventory.StonecuttingRecipe; import org.bukkit.loot.LootTable; @@ -256,6 +249,7 @@ import org.bukkit.scoreboard.Criteria; import org.bukkit.structure.StructureManager; import org.bukkit.util.StringUtil; import org.bukkit.util.permissions.DefaultPermissions; +import org.yaml.snakeyaml.LoaderOptions; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.SafeConstructor; import org.yaml.snakeyaml.error.MarkedYAMLException; @@ -278,7 +272,7 @@ public final class CraftServer implements Server { private final Map, Registry> registries = new HashMap<>(); private YamlConfiguration configuration; private YamlConfiguration commandsConfiguration; - private final Yaml yaml = new Yaml(new SafeConstructor()); + private final Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions())); private final Map offlinePlayers = new MapMaker().weakValues().makeMap(); private final EntityMetadataStore entityMetadata = new EntityMetadataStore(); private final PlayerMetadataStore playerMetadata = new PlayerMetadataStore(); @@ -1256,6 +1250,10 @@ public final class CraftServer implements Server { toAdd = CraftStonecuttingRecipe.fromBukkitRecipe((StonecuttingRecipe) recipe); } else if (recipe instanceof SmithingRecipe) { toAdd = CraftSmithingRecipe.fromBukkitRecipe((SmithingRecipe) recipe); + } else if (recipe instanceof SmithingTransformRecipe) { + toAdd = CraftSmithingRecipe.fromBukkitRecipe((SmithingTransformRecipe) recipe); + } else if (recipe instanceof SmithingTrimRecipe) { + toAdd = CraftSmithingRecipe.fromBukkitRecipe((SmithingTrimRecipe) recipe); } else if (recipe instanceof ComplexRecipe) { throw new UnsupportedOperationException("Cannot add custom complex recipe"); } else { @@ -1337,7 +1335,7 @@ public final class CraftServer implements Server { if (recipe.isPresent()) { RecipeCrafting recipeCrafting = recipe.get(); if (craftResult.setRecipeUsed(craftWorld.getHandle(), craftPlayer.getHandle(), recipeCrafting)) { - itemstack = recipeCrafting.assemble(inventoryCrafting); + itemstack = recipeCrafting.assemble(inventoryCrafting, craftWorld.getHandle().registryAccess()); } } @@ -2050,14 +2048,13 @@ public final class CraftServer implements Server { } static CraftIconCache loadServerIcon0(BufferedImage image) throws Exception { - ByteBuf bytebuf = Unpooled.buffer(); - Validate.isTrue(image.getWidth() == 64, "Must be 64 pixels wide"); Validate.isTrue(image.getHeight() == 64, "Must be 64 pixels high"); - ImageIO.write(image, "PNG", new ByteBufOutputStream(bytebuf)); - ByteBuffer bytebuffer = Base64.getEncoder().encode(bytebuf.nioBuffer()); - return new CraftIconCache("data:image/png;base64," + StandardCharsets.UTF_8.decode(bytebuffer)); + ByteArrayOutputStream bytebuf = new ByteArrayOutputStream(); + ImageIO.write(image, "PNG", bytebuf); + + return new CraftIconCache(bytebuf.toByteArray()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index c8603ef06a..d0934ff020 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -796,7 +796,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public double getHumidity(int x, int y, int z) { - return this.world.getNoiseBiome(x >> 2, y >> 2, z >> 2).value().getDownfall(); + return this.world.getNoiseBiome(x >> 2, y >> 2, z >> 2).value().climateSettings.downfall(); } @Override @@ -1158,7 +1158,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { Validate.notNull(material, "Material cannot be null"); Validate.isTrue(material.isBlock(), "Material must be a block"); - EntityFallingBlock entity = EntityFallingBlock.fall(world, new BlockPosition(location.getX(), location.getY(), location.getZ()), CraftMagicNumbers.getBlock(material).defaultBlockState(), SpawnReason.CUSTOM); + EntityFallingBlock entity = EntityFallingBlock.fall(world, BlockPosition.containing(location.getX(), location.getY(), location.getZ()), CraftMagicNumbers.getBlock(material).defaultBlockState(), SpawnReason.CUSTOM); return (FallingBlock) entity.getBukkitEntity(); } @@ -1167,7 +1167,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { Validate.notNull(location, "Location cannot be null"); Validate.notNull(data, "BlockData cannot be null"); - EntityFallingBlock entity = EntityFallingBlock.fall(world, new BlockPosition(location.getX(), location.getY(), location.getZ()), ((CraftBlockData) data).getState(), SpawnReason.CUSTOM); + EntityFallingBlock entity = EntityFallingBlock.fall(world, BlockPosition.containing(location.getX(), location.getY(), location.getZ()), ((CraftBlockData) data).getState(), SpawnReason.CUSTOM); return (FallingBlock) entity.getBukkitEntity(); } @@ -1862,7 +1862,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { } public StructureSearchResult locateNearestStructure(Location origin, List structures, int radius, boolean findUnexplored) { - BlockPosition originPos = new BlockPosition(origin.getX(), origin.getY(), origin.getZ()); + BlockPosition originPos = BlockPosition.containing(origin.getX(), origin.getY(), origin.getZ()); List> holders = new ArrayList<>(); for (Structure structure : structures) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java index 18a99b1012..063d202cb9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java @@ -125,7 +125,7 @@ public class CraftWorldBorder implements WorldBorder { public boolean isInside(Location location) { Preconditions.checkArgument(location != null, "location cannot be null"); - return (world == null || location.getWorld().equals(this.world)) && this.handle.isWithinBounds(new BlockPosition(location.getX(), location.getY(), location.getZ())); + return (world == null || location.getWorld().equals(this.world)) && this.handle.isWithinBounds(BlockPosition.containing(location.getX(), location.getY(), location.getZ())); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java index 3224904a2e..b1a53255e5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java @@ -12,6 +12,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import joptsimple.OptionParser; import joptsimple.OptionSet; +import joptsimple.util.PathConverter; import org.fusesource.jansi.AnsiConsole; public class Main { @@ -57,6 +58,15 @@ public class Main { .ofType(Integer.class) .describedAs("Port"); + accepts("serverId", "Server ID") + .withRequiredArg(); + + accepts("jfrProfile", "Enable JFR profiling"); + + accepts("pidFile", "pid File") + .withRequiredArg() + .withValuesConvertedBy(new PathConverter()); + acceptsAll(asList("o", "online-mode"), "Whether to use online authentication") .withRequiredArg() .ofType(Boolean.class) @@ -183,11 +193,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/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java index 25fc1249d4..8506d2dcc5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java @@ -12,10 +12,12 @@ import net.minecraft.core.BlockPosition; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.level.GeneratorAccess; import net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity; +import net.minecraft.world.level.block.entity.DecoratedPotBlockEntity; import net.minecraft.world.level.block.entity.HangingSignBlockEntity; import net.minecraft.world.level.block.entity.SculkCatalystBlockEntity; import net.minecraft.world.level.block.entity.SculkSensorBlockEntity; import net.minecraft.world.level.block.entity.SculkShriekerBlockEntity; +import net.minecraft.world.level.block.entity.SuspiciousSandBlockEntity; import net.minecraft.world.level.block.entity.TileEntity; import net.minecraft.world.level.block.entity.TileEntityBanner; import net.minecraft.world.level.block.entity.TileEntityBarrel; @@ -130,6 +132,8 @@ public final class CraftBlockStates { Material.BAMBOO_WALL_SIGN, Material.BIRCH_SIGN, Material.BIRCH_WALL_SIGN, + Material.CHERRY_SIGN, + Material.CHERRY_WALL_SIGN, Material.CRIMSON_SIGN, Material.CRIMSON_WALL_SIGN, Material.DARK_OAK_SIGN, @@ -155,6 +159,8 @@ public final class CraftBlockStates { Material.BAMBOO_WALL_HANGING_SIGN, Material.BIRCH_HANGING_SIGN, Material.BIRCH_WALL_HANGING_SIGN, + Material.CHERRY_HANGING_SIGN, + Material.CHERRY_WALL_HANGING_SIGN, Material.CRIMSON_HANGING_SIGN, Material.CRIMSON_WALL_HANGING_SIGN, Material.DARK_OAK_HANGING_SIGN, @@ -303,6 +309,7 @@ public final class CraftBlockStates { register(Material.COMPARATOR, CraftComparator.class, CraftComparator::new, TileEntityComparator::new); register(Material.CONDUIT, CraftConduit.class, CraftConduit::new, TileEntityConduit::new); register(Material.DAYLIGHT_DETECTOR, CraftDaylightDetector.class, CraftDaylightDetector::new, TileEntityLightDetector::new); + register(Material.DECORATED_POT, CraftDecoratedPot.class, CraftDecoratedPot::new, DecoratedPotBlockEntity::new); register(Material.DISPENSER, CraftDispenser.class, CraftDispenser::new, TileEntityDispenser::new); register(Material.DROPPER, CraftDropper.class, CraftDropper::new, TileEntityDropper::new); register(Material.ENCHANTING_TABLE, CraftEnchantingTable.class, CraftEnchantingTable::new, TileEntityEnchantTable::new); @@ -321,6 +328,7 @@ public final class CraftBlockStates { register(Material.SMOKER, CraftSmoker.class, CraftSmoker::new, TileEntitySmoker::new); register(Material.SPAWNER, CraftCreatureSpawner.class, CraftCreatureSpawner::new, TileEntityMobSpawner::new); register(Material.STRUCTURE_BLOCK, CraftStructureBlock.class, CraftStructureBlock::new, TileEntityStructure::new); + register(Material.SUSPICIOUS_SAND, CraftSuspiciousSand.class, CraftSuspiciousSand::new, SuspiciousSandBlockEntity::new); register(Material.TRAPPED_CHEST, CraftChest.class, CraftChest::new, TileEntityChestTrapped::new); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDecoratedPot.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDecoratedPot.java new file mode 100644 index 0000000000..224563dec2 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDecoratedPot.java @@ -0,0 +1,38 @@ +package org.bukkit.craftbukkit.block; + +import com.google.common.base.Preconditions; +import java.util.List; +import java.util.stream.Collectors; +import net.minecraft.world.level.block.entity.DecoratedPotBlockEntity; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.DecoratedPot; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; + +public class CraftDecoratedPot extends CraftBlockEntityState implements DecoratedPot { + + public CraftDecoratedPot(World world, DecoratedPotBlockEntity tileEntity) { + super(world, tileEntity); + } + + @Override + public List getShards() { + return getSnapshot().getShards().stream().map(CraftMagicNumbers::getMaterial).collect(Collectors.toUnmodifiableList()); + } + + @Override + public void addShard(Material material) { + Preconditions.checkArgument(material != null && material.isItem(), "Material must be an item"); + + getSnapshot().getShards().add(CraftMagicNumbers.getItem(material)); + } + + @Override + public void setShards(List shard) { + getSnapshot().getShards().clear(); + + for (Material material : shard) { + addShard(material); + } + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java index 8950b032e2..c15cde5054 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java @@ -54,14 +54,14 @@ public class CraftJukebox extends CraftBlockEntityState imple @Override public org.bukkit.inventory.ItemStack getRecord() { - ItemStack record = this.getSnapshot().getRecord(); + ItemStack record = this.getSnapshot().getFirstItem(); return CraftItemStack.asBukkitCopy(record); } @Override public void setRecord(org.bukkit.inventory.ItemStack record) { ItemStack nms = CraftItemStack.asNMSCopy(record); - this.getSnapshot().setRecord(nms); + this.getSnapshot().setRecordWithoutPlaying(nms); if (nms.isEmpty()) { this.data = this.data.setValue(BlockJukeBox.HAS_RECORD, false); } else { @@ -87,9 +87,8 @@ public class CraftJukebox extends CraftBlockEntityState imple if (!(tileEntity instanceof TileEntityJukeBox)) return false; TileEntityJukeBox jukebox = (TileEntityJukeBox) tileEntity; - boolean result = !jukebox.getRecord().isEmpty(); - CraftWorld world = (CraftWorld) this.getWorld(); - ((BlockJukeBox) Blocks.JUKEBOX).dropRecording(world.getHandle(), getPosition()); + boolean result = !jukebox.getFirstItem().isEmpty(); + jukebox.popOutRecord(); return result; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSuspiciousSand.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSuspiciousSand.java new file mode 100644 index 0000000000..a2c50590f2 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSuspiciousSand.java @@ -0,0 +1,67 @@ +package org.bukkit.craftbukkit.block; + +import net.minecraft.resources.MinecraftKey; +import net.minecraft.world.level.block.entity.SuspiciousSandBlockEntity; +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.block.SuspiciousSand; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.inventory.ItemStack; +import org.bukkit.loot.LootTable; + +public class CraftSuspiciousSand extends CraftBlockEntityState implements SuspiciousSand { + + public CraftSuspiciousSand(World world, SuspiciousSandBlockEntity tileEntity) { + super(world, tileEntity); + } + + @Override + public ItemStack getItem() { + return CraftItemStack.asBukkitCopy(getSnapshot().getItem()); + } + + @Override + public void setItem(ItemStack item) { + getSnapshot().item = CraftItemStack.asNMSCopy(item); + } + + @Override + public void applyTo(SuspiciousSandBlockEntity lootable) { + super.applyTo(lootable); + + if (this.getSnapshot().lootTable == null) { + lootable.setLootTable((MinecraftKey) null, 0L); + } + } + + @Override + public LootTable getLootTable() { + if (getSnapshot().lootTable == null) { + return null; + } + + MinecraftKey key = getSnapshot().lootTable; + return Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(key)); + } + + @Override + public void setLootTable(LootTable table) { + setLootTable(table, getSeed()); + } + + @Override + public long getSeed() { + return getSnapshot().lootTableSeed; + } + + @Override + public void setSeed(long seed) { + setLootTable(getLootTable(), seed); + } + + private void setLootTable(LootTable table, long seed) { + MinecraftKey key = (table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey()); + getSnapshot().setLootTable(key, seed); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java index 4e4ea3e548..c0556baa79 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java @@ -480,7 +480,9 @@ public class CraftBlockData implements BlockData { 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.CeilingHangingSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftCeilingHangingSign::new); + register(net.minecraft.world.level.block.CherryLeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftCherryLeaves::new); register(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, org.bukkit.craftbukkit.block.impl.CraftChiseledBookShelf::new); + register(net.minecraft.world.level.block.DecoratedPotBlock.class, org.bukkit.craftbukkit.block.impl.CraftDecoratedPot::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); @@ -491,6 +493,7 @@ public class CraftBlockData implements BlockData { register(net.minecraft.world.level.block.MangrovePropaguleBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangrovePropagule::new); register(net.minecraft.world.level.block.MangroveRootsBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangroveRoots::new); register(net.minecraft.world.level.block.PiglinWallSkullBlock.class, org.bukkit.craftbukkit.block.impl.CraftPiglinWallSkull::new); + register(net.minecraft.world.level.block.PinkPetalsBlock.class, org.bukkit.craftbukkit.block.impl.CraftPinkPetals::new); register(net.minecraft.world.level.block.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.SculkCatalystBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkCatalyst::new); @@ -498,7 +501,9 @@ public class CraftBlockData implements BlockData { register(net.minecraft.world.level.block.SculkShriekerBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkShrieker::new); register(net.minecraft.world.level.block.SculkVeinBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkVein::new); register(net.minecraft.world.level.block.SmallDripleafBlock.class, org.bukkit.craftbukkit.block.impl.CraftSmallDripleaf::new); + register(net.minecraft.world.level.block.SuspiciousSandBlock.class, org.bukkit.craftbukkit.block.impl.CraftSuspiciousSand::new); register(net.minecraft.world.level.block.TallSeagrassBlock.class, org.bukkit.craftbukkit.block.impl.CraftTallSeagrass::new); + register(net.minecraft.world.level.block.TorchflowerCropBlock.class, org.bukkit.craftbukkit.block.impl.CraftTorchflowerCrop::new); register(net.minecraft.world.level.block.WallHangingSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftWallHangingSign::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); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPinkPetals.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPinkPetals.java new file mode 100644 index 0000000000..cbf3f5cb9e --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPinkPetals.java @@ -0,0 +1,24 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.PinkPetals; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftPinkPetals extends CraftBlockData implements PinkPetals { + + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger FLOWER_AMOUNT = getInteger("flower_amount"); + + @Override + public int getFlowerAmount() { + return get(FLOWER_AMOUNT); + } + + @Override + public void setFlowerAmount(int flower_amount) { + set(FLOWER_AMOUNT, flower_amount); + } + + @Override + public int getMaximumFlowerAmount() { + return getMax(FLOWER_AMOUNT); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSuspiciousSand.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSuspiciousSand.java new file mode 100644 index 0000000000..afcb9e096c --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSuspiciousSand.java @@ -0,0 +1,24 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.SuspiciousSand; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftSuspiciousSand extends CraftBlockData implements SuspiciousSand { + + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger DUSTED = getInteger("dusted"); + + @Override + public int getDusted() { + return get(DUSTED); + } + + @Override + public void setDusted(int dusted) { + set(DUSTED, dusted); + } + + @Override + public int getMaximumDusted() { + return getMax(DUSTED); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCherryLeaves.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCherryLeaves.java new file mode 100644 index 0000000000..e21a2c2a8c --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCherryLeaves.java @@ -0,0 +1,54 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftCherryLeaves extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Leaves, org.bukkit.block.data.Waterlogged { + + public CraftCherryLeaves() { + super(); + } + + public CraftCherryLeaves(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftLeaves + + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger DISTANCE = getInteger(net.minecraft.world.level.block.CherryLeavesBlock.class, "distance"); + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean PERSISTENT = getBoolean(net.minecraft.world.level.block.CherryLeavesBlock.class, "persistent"); + + @Override + public boolean isPersistent() { + return get(PERSISTENT); + } + + @Override + public void setPersistent(boolean persistent) { + set(PERSISTENT, persistent); + } + + @Override + public int getDistance() { + return get(DISTANCE); + } + + @Override + public void setDistance(int distance) { + set(DISTANCE, distance); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.CherryLeavesBlock.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDecoratedPot.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDecoratedPot.java new file mode 100644 index 0000000000..c21c7bc174 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDecoratedPot.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftDecoratedPot extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.DecoratedPot, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged { + + public CraftDecoratedPot() { + super(); + } + + public CraftDecoratedPot(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.DecoratedPotBlock.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.DecoratedPotBlock.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPinkPetals.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPinkPetals.java new file mode 100644 index 0000000000..7d3bc82e7d --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPinkPetals.java @@ -0,0 +1,53 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftPinkPetals extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.PinkPetals, org.bukkit.block.data.Directional { + + public CraftPinkPetals() { + super(); + } + + public CraftPinkPetals(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftPinkPetals + + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger FLOWER_AMOUNT = getInteger(net.minecraft.world.level.block.PinkPetalsBlock.class, "flower_amount"); + + @Override + public int getFlowerAmount() { + return get(FLOWER_AMOUNT); + } + + @Override + public void setFlowerAmount(int flower_amount) { + set(FLOWER_AMOUNT, flower_amount); + } + + @Override + public int getMaximumFlowerAmount() { + return getMax(FLOWER_AMOUNT); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACING = getEnum(net.minecraft.world.level.block.PinkPetalsBlock.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSuspiciousSand.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSuspiciousSand.java new file mode 100644 index 0000000000..b92f320ba6 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSuspiciousSand.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftSuspiciousSand extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.SuspiciousSand { + + public CraftSuspiciousSand() { + super(); + } + + public CraftSuspiciousSand(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftSuspiciousSand + + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger DUSTED = getInteger(net.minecraft.world.level.block.SuspiciousSandBlock.class, "dusted"); + + @Override + public int getDusted() { + return get(DUSTED); + } + + @Override + public void setDusted(int dusted) { + set(DUSTED, dusted); + } + + @Override + public int getMaximumDusted() { + return getMax(DUSTED); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTorchflowerCrop.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTorchflowerCrop.java new file mode 100644 index 0000000000..8d8cd4f1be --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTorchflowerCrop.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftTorchflowerCrop extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Ageable { + + public CraftTorchflowerCrop() { + super(); + } + + public CraftTorchflowerCrop(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.TorchflowerCropBlock.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); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java index 01793e1691..b10197558f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java @@ -70,7 +70,7 @@ public class CraftAllay extends CraftCreature implements org.bukkit.entity.Allay public void startDancing(Location location) { Preconditions.checkArgument(location != null, "Location cannot be null"); Preconditions.checkArgument(location.getBlock().getType().equals(Material.JUKEBOX), "The Block in the Location need to be a JukeBox"); - getHandle().setJukeboxPlaying(new BlockPosition(location.getX(), location.getY(), location.getZ()), true); + getHandle().setJukeboxPlaying(BlockPosition.containing(location.getX(), location.getY(), location.getZ()), true); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java new file mode 100644 index 0000000000..a965dc7b8b --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java @@ -0,0 +1,42 @@ +package org.bukkit.craftbukkit.entity; + +import com.google.common.base.Preconditions; +import org.bukkit.block.data.BlockData; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.entity.BlockDisplay; +import org.bukkit.entity.EntityType; + +public class CraftBlockDisplay extends CraftDisplay implements BlockDisplay { + + public CraftBlockDisplay(CraftServer server, net.minecraft.world.entity.Display.BlockDisplay entity) { + super(server, entity); + } + + @Override + public net.minecraft.world.entity.Display.BlockDisplay getHandle() { + return (net.minecraft.world.entity.Display.BlockDisplay) super.getHandle(); + } + + @Override + public String toString() { + return "CraftBlockDisplay"; + } + + @Override + public EntityType getType() { + return EntityType.BLOCK_DISPLAY; + } + + @Override + public BlockData getBlock() { + return CraftBlockData.fromData(getHandle().getBlockState()); + } + + @Override + public void setBlock(BlockData block) { + Preconditions.checkArgument(block != null, "Block cannot be null"); + + getHandle().setBlockState(((CraftBlockData) block).getState()); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java index dad97bfa84..21dc6e1e45 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java @@ -107,6 +107,7 @@ public class CraftBoat extends CraftVehicle implements Boat { case OAK -> Type.OAK; case BIRCH -> Type.BIRCH; case ACACIA -> Type.ACACIA; + case CHERRY -> Type.CHERRY; case JUNGLE -> Type.JUNGLE; case SPRUCE -> Type.SPRUCE; case DARK_OAK -> Type.DARK_OAK; @@ -123,6 +124,7 @@ public class CraftBoat extends CraftVehicle implements Boat { case SPRUCE -> EntityBoat.EnumBoatType.SPRUCE; case DARK_OAK -> EntityBoat.EnumBoatType.DARK_OAK; case JUNGLE -> EntityBoat.EnumBoatType.JUNGLE; + case CHERRY -> EntityBoat.EnumBoatType.CHERRY; case ACACIA -> EntityBoat.EnumBoatType.ACACIA; case BIRCH -> EntityBoat.EnumBoatType.BIRCH; case OAK -> EntityBoat.EnumBoatType.OAK; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java index 942dc58ddc..c765139d22 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit.entity; +import net.minecraft.world.entity.EntityPose; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Camel; import org.bukkit.entity.EntityType; @@ -43,7 +44,7 @@ public class CraftCamel extends CraftAbstractHorse implements Camel { @Override public boolean isSitting() { - return getHandle().isPoseSitting(); + return getHandle().getPose() == EntityPose.SITTING; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java new file mode 100644 index 0000000000..0e7d587ba4 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java @@ -0,0 +1,158 @@ +package org.bukkit.craftbukkit.entity; + +import com.google.common.base.Preconditions; +import org.bukkit.Color; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Display; +import org.bukkit.entity.EntityType; +import org.bukkit.util.Transformation; + +public class CraftDisplay extends CraftEntity implements Display { + + public CraftDisplay(CraftServer server, net.minecraft.world.entity.Display entity) { + super(server, entity); + } + + @Override + public net.minecraft.world.entity.Display getHandle() { + return (net.minecraft.world.entity.Display) super.getHandle(); + } + + @Override + public String toString() { + return "CraftDisplay"; + } + + @Override + public EntityType getType() { + return EntityType.UNKNOWN; + } + + @Override + public Transformation getTransformation() { + com.mojang.math.Transformation nms = net.minecraft.world.entity.Display.createTransformation(getHandle().getEntityData()); + + return new Transformation(nms.getTranslation(), nms.getLeftRotation(), nms.getScale(), nms.getRightRotation()); + } + + @Override + public void setTransformation(Transformation transformation) { + Preconditions.checkArgument(transformation != null, "Transformation cannot be null"); + + getHandle().setTransformation(new com.mojang.math.Transformation(transformation.getTranslation(), transformation.getLeftRotation(), transformation.getScale(), transformation.getRightRotation())); + } + + @Override + public int getInterpolationDuration() { + return getHandle().getInterpolationDuration(); + } + + @Override + public void setInterpolationDuration(int duration) { + getHandle().setInterpolationDuration(duration); + } + + @Override + public float getViewRange() { + return getHandle().getViewRange(); + } + + @Override + public void setViewRange(float range) { + getHandle().setViewRange(range); + } + + @Override + public float getShadowRadius() { + return getHandle().getShadowRadius(); + } + + @Override + public void setShadowRadius(float radius) { + getHandle().setShadowRadius(radius); + } + + @Override + public float getShadowStrength() { + return getHandle().getShadowStrength(); + } + + @Override + public void setShadowStrength(float strength) { + getHandle().setShadowStrength(strength); + } + + @Override + public float getDisplayWidth() { + return getHandle().getWidth(); + } + + @Override + public void setDisplayWidth(float width) { + getHandle().setWidth(width); + } + + @Override + public float getDisplayHeight() { + return getHandle().getHeight(); + } + + @Override + public void setDisplayHeight(float height) { + getHandle().setHeight(height); + } + + @Override + public int getInterpolationDelay() { + return getHandle().getInterpolationDelay(); + } + + @Override + public void setInterpolationDelay(int ticks) { + getHandle().setInterpolationDelay(ticks); + } + + @Override + public Billboard getBillboard() { + return Billboard.valueOf(getHandle().getBillboardConstraints().name()); + } + + @Override + public void setBillboard(Billboard billboard) { + Preconditions.checkArgument(billboard != null, "Billboard cannot be null"); + + getHandle().setBillboardConstraints(net.minecraft.world.entity.Display.BillboardConstraints.valueOf(billboard.name())); + } + + @Override + public Color getGlowColorOverride() { + int color = getHandle().getGlowColorOverride(); + + return (color == -1) ? null : Color.fromRGB(color); + } + + @Override + public void setGlowColorOverride(Color color) { + if (color == null) { + getHandle().setGlowColorOverride(-1); + } else { + getHandle().setGlowColorOverride(color.asRGB()); + } + } + + @Override + public Brightness getBrightness() { + net.minecraft.util.Brightness nms = getHandle().getBrightnessOverride(); + + return (nms != null) ? new Brightness(nms.block(), nms.sky()) : null; + } + + @Override + public void setBrightness(Brightness brightness) { + if (brightness != null) { + getHandle().setBrightnessOverride(new net.minecraft.util.Brightness(brightness.getBlockLight(), brightness.getSkyLight())); + } else { + getHandle().setBrightnessOverride(null); + } + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java index ffa4e57abc..cc3d364088 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java @@ -39,7 +39,7 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal { @Override public void setTargetLocation(Location location) { Preconditions.checkArgument(getWorld().equals(location.getWorld()), "Cannot target EnderSignal across worlds"); - getHandle().signalTo(new BlockPosition(location.getX(), location.getY(), location.getZ())); + getHandle().signalTo(BlockPosition.containing(location.getX(), location.getY(), location.getZ())); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 13a219b1e5..b8ef570b65 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -7,7 +7,6 @@ import com.google.common.collect.Lists; import java.util.List; import java.util.Set; import java.util.UUID; -import net.minecraft.core.BlockPosition; import net.minecraft.core.Position; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; @@ -15,8 +14,7 @@ import net.minecraft.network.chat.IChatBaseComponent; import net.minecraft.server.level.EntityPlayer; import net.minecraft.server.level.PlayerChunkMap; import net.minecraft.server.level.WorldServer; -import net.minecraft.sounds.SoundEffect; -import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Display; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityAreaEffectCloud; import net.minecraft.world.entity.EntityCreature; @@ -26,6 +24,7 @@ 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.Interaction; import net.minecraft.world.entity.Marker; import net.minecraft.world.entity.ambient.EntityAmbient; import net.minecraft.world.entity.ambient.EntityBat; @@ -71,6 +70,7 @@ import net.minecraft.world.entity.animal.horse.EntityHorseSkeleton; import net.minecraft.world.entity.animal.horse.EntityHorseZombie; import net.minecraft.world.entity.animal.horse.EntityLlama; import net.minecraft.world.entity.animal.horse.EntityLlamaTrader; +import net.minecraft.world.entity.animal.sniffer.Sniffer; import net.minecraft.world.entity.boss.EntityComplexPart; import net.minecraft.world.entity.boss.enderdragon.EntityEnderCrystal; import net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon; @@ -273,6 +273,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (entity instanceof Axolotl) { return new CraftAxolotl(server, (Axolotl) entity); } else if (entity instanceof Goat) { return new CraftGoat(server, (Goat) entity); } else if (entity instanceof Frog) { return new CraftFrog(server, (Frog) entity); } + else if (entity instanceof Sniffer) { return new CraftSniffer(server, (Sniffer) entity); } else { return new CraftAnimals(server, (EntityAnimal) entity); } } // Monsters @@ -422,6 +423,13 @@ public abstract class CraftEntity implements org.bukkit.entity.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); } + else if (entity instanceof Interaction) { return new CraftInteraction(server, (Interaction) entity); } + else if (entity instanceof Display) { + if (entity instanceof Display.BlockDisplay) { return new CraftBlockDisplay(server, (Display.BlockDisplay) entity); } + else if (entity instanceof Display.ItemDisplay) { return new CraftItemDisplay(server, (Display.ItemDisplay) entity); } + else if (entity instanceof Display.TextDisplay) { return new CraftTextDisplay(server, (Display.TextDisplay) entity); } + else { return new CraftDisplay(server, (Display) entity); } + } // CHECKSTYLE:ON throw new AssertionError("Unknown entity " + (entity == null ? null : entity.getClass())); @@ -1012,7 +1020,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public boolean isInvulnerable() { - return getHandle().isInvulnerableTo(DamageSource.GENERIC); + return getHandle().isInvulnerableTo(getHandle().damageSources().generic()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftInteraction.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftInteraction.java new file mode 100644 index 0000000000..74ca421147 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftInteraction.java @@ -0,0 +1,95 @@ +package org.bukkit.craftbukkit.entity; + +import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Interaction; + +public class CraftInteraction extends CraftEntity implements Interaction { + + public CraftInteraction(CraftServer server, net.minecraft.world.entity.Interaction entity) { + super(server, entity); + } + + @Override + public net.minecraft.world.entity.Interaction getHandle() { + return (net.minecraft.world.entity.Interaction) super.getHandle(); + } + + @Override + public String toString() { + return "CraftInteraction"; + } + + @Override + public EntityType getType() { + return EntityType.INTERACTION; + } + + @Override + public float getInteractionWidth() { + return getHandle().getWidth(); + } + + @Override + public void setInteractionWidth(float width) { + getHandle().setWidth(width); + } + + @Override + public float getInteractionHeight() { + return getHandle().getHeight(); + } + + @Override + public void setInteractionHeight(float height) { + getHandle().setHeight(height); + } + + @Override + public boolean isResponsive() { + return getHandle().getResponse(); + } + + @Override + public void setResponsive(boolean response) { + getHandle().setResponse(response); + } + + @Override + public PreviousInteraction getLastAttack() { + net.minecraft.world.entity.Interaction.PlayerAction last = getHandle().attack; + + return (last != null) ? new CraftPreviousInteraction(last.player(), last.timestamp()) : null; + } + + @Override + public PreviousInteraction getLastInteraction() { + net.minecraft.world.entity.Interaction.PlayerAction last = getHandle().interaction; + + return (last != null) ? new CraftPreviousInteraction(last.player(), last.timestamp()) : null; + } + + private static class CraftPreviousInteraction implements PreviousInteraction { + + private final UUID uuid; + private final long timestamp; + + public CraftPreviousInteraction(UUID uuid, long timestamp) { + this.uuid = uuid; + this.timestamp = timestamp; + } + + @Override + public OfflinePlayer getPlayer() { + return Bukkit.getOfflinePlayer(uuid); + } + + @Override + public long getTimestamp() { + return timestamp; + } + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java index daf264ca2a..b468361092 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java @@ -68,12 +68,12 @@ public class CraftItem extends CraftEntity implements Item { @Override public void setOwner(UUID uuid) { - item.setOwner(uuid); + item.setTarget(uuid); } @Override public UUID getOwner() { - return item.getOwner(); + return item.target; } @Override @@ -83,7 +83,7 @@ public class CraftItem extends CraftEntity implements Item { @Override public UUID getThrower() { - return item.getThrower(); + return item.thrower; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemDisplay.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemDisplay.java new file mode 100644 index 0000000000..81b4a56d3c --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemDisplay.java @@ -0,0 +1,53 @@ +package org.bukkit.craftbukkit.entity; + +import com.google.common.base.Preconditions; +import net.minecraft.world.item.ItemDisplayContext; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.ItemDisplay; +import org.bukkit.inventory.ItemStack; + +public class CraftItemDisplay extends CraftDisplay implements ItemDisplay { + + public CraftItemDisplay(CraftServer server, net.minecraft.world.entity.Display.ItemDisplay entity) { + super(server, entity); + } + + @Override + public net.minecraft.world.entity.Display.ItemDisplay getHandle() { + return (net.minecraft.world.entity.Display.ItemDisplay) super.getHandle(); + } + + @Override + public String toString() { + return "CraftItemDisplay"; + } + + @Override + public EntityType getType() { + return EntityType.ITEM_DISPLAY; + } + + @Override + public ItemStack getItemStack() { + return CraftItemStack.asBukkitCopy(getHandle().getItemStack()); + } + + @Override + public void setItemStack(ItemStack item) { + getHandle().setItemStack(CraftItemStack.asNMSCopy(item)); + } + + @Override + public ItemDisplayTransform getItemDisplayTransform() { + return ItemDisplayTransform.values()[getHandle().getItemTransform().ordinal()]; + } + + @Override + public void setItemDisplayTransform(ItemDisplayTransform display) { + Preconditions.checkArgument(display != null, "Display cannot be null"); + + getHandle().setItemTransform(ItemDisplayContext.BY_ID.apply(display.ordinal())); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index e372264f5a..aa9c4cb13c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -126,7 +126,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { getHandle().setHealth((float) health); if (health == 0) { - getHandle().die(DamageSource.GENERIC); + getHandle().die(getHandle().damageSources().generic()); } } @@ -289,12 +289,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public void damage(double amount, org.bukkit.entity.Entity source) { Preconditions.checkState(!getHandle().generation, "Cannot damage entity during world generation"); - DamageSource reason = DamageSource.GENERIC; + DamageSource reason = getHandle().damageSources().generic(); if (source instanceof HumanEntity) { - reason = DamageSource.playerAttack(((CraftHumanEntity) source).getHandle()); + reason = getHandle().damageSources().playerAttack(((CraftHumanEntity) source).getHandle()); } else if (source instanceof LivingEntity) { - reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle()); + reason = getHandle().damageSources().mobAttack(((CraftLivingEntity) source).getHandle()); } entity.hurt(reason, (float) amount); @@ -702,7 +702,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public Sound getHurtSound() { - SoundEffect sound = getHandle().getHurtSound0(DamageSource.GENERIC); + SoundEffect sound = getHandle().getHurtSound0(getHandle().damageSources().generic()); return (sound != null) ? CraftSound.getBukkit(sound) : null; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java index 13592783ad..762571ab28 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java @@ -25,7 +25,7 @@ public class CraftPig extends CraftAnimals implements Pig { @Override public int getBoostTicks() { - return getHandle().steering.boosting ? getHandle().steering.boostTimeTotal : 0; + return getHandle().steering.boosting ? getHandle().steering.boostTimeTotal() : 0; } @Override @@ -46,7 +46,7 @@ public class CraftPig extends CraftAnimals implements Pig { return; } - int max = getHandle().steering.boostTimeTotal; + int max = getHandle().steering.boostTimeTotal(); Preconditions.checkArgument(ticks >= 0 && ticks <= max, "boost ticks must not exceed 0 or %d (inclusive)", max); this.getHandle().steering.boostTime = ticks; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 41206e6977..05f2258adc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -216,7 +216,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public InetSocketAddress getAddress() { if (getHandle().connection == null) return null; - SocketAddress addr = getHandle().connection.connection.getRemoteAddress(); + SocketAddress addr = getHandle().connection.getRemoteAddress(); if (addr instanceof InetSocketAddress) { return (InetSocketAddress) addr; } else { @@ -842,20 +842,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void addCustomChatCompletions(Collection completions) { - this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.a.ADD); + this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.Action.ADD); } @Override public void removeCustomChatCompletions(Collection completions) { - this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.a.REMOVE); + this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.Action.REMOVE); } @Override public void setCustomChatCompletions(Collection completions) { - this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.a.SET); + this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.Action.SET); } - private void sendCustomChatCompletionPacket(Collection completions, ClientboundCustomChatCompletionsPacket.a action) { // PAIL rename Action + private void sendCustomChatCompletionPacket(Collection completions, ClientboundCustomChatCompletionsPacket.Action action) { if (getHandle().connection == null) return; ClientboundCustomChatCompletionsPacket packet = new ClientboundCustomChatCompletionsPacket(action, new ArrayList<>(completions)); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java new file mode 100644 index 0000000000..92d1c7943c --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.entity; + +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Sniffer; + +public class CraftSniffer extends CraftAnimals implements Sniffer { + + public CraftSniffer(CraftServer server, net.minecraft.world.entity.animal.sniffer.Sniffer entity) { + super(server, entity); + } + + @Override + public net.minecraft.world.entity.animal.sniffer.Sniffer getHandle() { + return (net.minecraft.world.entity.animal.sniffer.Sniffer) super.getHandle(); + } + + @Override + public String toString() { + return "CraftSniffer"; + } + + @Override + public EntityType getType() { + return EntityType.SNIFFER; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java index 5ce84a6cf2..1537ae3bbc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java @@ -35,7 +35,7 @@ public class CraftStrider extends CraftAnimals implements Strider { @Override public int getBoostTicks() { - return getHandle().steering.boosting ? getHandle().steering.boostTimeTotal : 0; + return getHandle().steering.boosting ? getHandle().steering.boostTimeTotal() : 0; } @Override @@ -56,7 +56,7 @@ public class CraftStrider extends CraftAnimals implements Strider { return; } - int max = getHandle().steering.boostTimeTotal; + int max = getHandle().steering.boostTimeTotal(); Preconditions.checkArgument(ticks >= 0 && ticks <= max, "boost ticks must not exceed 0 or %d (inclusive)", max); this.getHandle().steering.boostTime = ticks; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTextDisplay.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTextDisplay.java new file mode 100644 index 0000000000..ff7775887a --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTextDisplay.java @@ -0,0 +1,151 @@ +package org.bukkit.craftbukkit.entity; + +import com.google.common.base.Preconditions; +import net.minecraft.world.entity.Display; +import org.bukkit.Color; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.util.CraftChatMessage; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.TextDisplay; + +public class CraftTextDisplay extends CraftDisplay implements TextDisplay { + + public CraftTextDisplay(CraftServer server, net.minecraft.world.entity.Display.TextDisplay entity) { + super(server, entity); + } + + @Override + public net.minecraft.world.entity.Display.TextDisplay getHandle() { + return (net.minecraft.world.entity.Display.TextDisplay) super.getHandle(); + } + + @Override + public String toString() { + return "CraftTextDisplay"; + } + + @Override + public EntityType getType() { + return EntityType.TEXT_DISPLAY; + } + + @Override + public String getText() { + return CraftChatMessage.fromComponent(getHandle().getText()); + } + + @Override + public void setText(String text) { + getHandle().setText(CraftChatMessage.fromString(text, true)[0]); + } + + @Override + public int getLineWidth() { + return getHandle().getLineWidth(); + } + + @Override + public void setLineWidth(int width) { + getHandle().setLineWidth(width); + } + + @Override + public Color getBackgroundColor() { + int color = getHandle().getBackgroundColor(); + + return (color == -1) ? null : Color.fromRGB(color); + } + + @Override + public void setBackgroundColor(Color color) { + if (color == null) { + getHandle().setBackgroundColor(-1); + } else { + getHandle().setBackgroundColor(color.asRGB()); + } + } + + @Override + public byte getTextOpacity() { + return getHandle().getTextOpacity(); + } + + @Override + public void setTextOpacity(byte opacity) { + getHandle().setTextOpacity(opacity); + } + + @Override + public boolean isShadowed() { + return getFlag(Display.TextDisplay.FLAG_SHADOW); + } + + @Override + public void setShadowed(boolean shadow) { + setFlag(Display.TextDisplay.FLAG_SHADOW, shadow); + } + + @Override + public boolean isSeeThrough() { + return getFlag(Display.TextDisplay.FLAG_SEE_THROUGH); + } + + @Override + public void setSeeThrough(boolean seeThrough) { + setFlag(Display.TextDisplay.FLAG_SEE_THROUGH, seeThrough); + } + + @Override + public boolean isDefaultBackground() { + return getFlag(Display.TextDisplay.FLAG_USE_DEFAULT_BACKGROUND); + } + + @Override + public void setDefaultBackground(boolean defaultBackground) { + setFlag(Display.TextDisplay.FLAG_USE_DEFAULT_BACKGROUND, defaultBackground); + } + + @Override + public TextAligment getAlignment() { + Display.TextDisplay.Align nms = Display.TextDisplay.getAlign(getHandle().getFlags()); + return TextAligment.valueOf(nms.name()); + } + + @Override + public void setAlignment(TextAligment alignment) { + Preconditions.checkArgument(alignment != null, "Alignment cannot be null"); + + switch (alignment) { + case LEFT: + setFlag(Display.TextDisplay.FLAG_ALIGN_LEFT, true); + setFlag(Display.TextDisplay.FLAG_ALIGN_RIGHT, false); + break; + case RIGHT: + setFlag(Display.TextDisplay.FLAG_ALIGN_LEFT, false); + setFlag(Display.TextDisplay.FLAG_ALIGN_RIGHT, true); + break; + case CENTER: + setFlag(Display.TextDisplay.FLAG_ALIGN_LEFT, false); + setFlag(Display.TextDisplay.FLAG_ALIGN_RIGHT, false); + break; + default: + throw new IllegalArgumentException("Unknown alignment " + alignment); + } + } + + private boolean getFlag(int flag) { + return (getHandle().getFlags() & flag) != 0; + } + + private void setFlag(int flag, boolean set) { + byte flagBits = getHandle().getFlags(); + + if (set) { + flagBits |= flag; + } else { + flagBits &= ~flag; + } + + getHandle().setFlags(flagBits); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java index 7a168c3e94..e25047bf1b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java @@ -74,7 +74,7 @@ public class CraftWarden extends CraftMonster implements org.bukkit.entity.Warde public void setDisturbanceLocation(Location location) { Preconditions.checkArgument(location != null, "Location cannot be null"); - WardenAi.setDisturbanceLocation(getHandle(), new BlockPosition(location.getX(), location.getY(), location.getZ())); + WardenAi.setDisturbanceLocation(getHandle(), BlockPosition.containing(location.getX(), location.getY(), location.getZ())); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryMapper.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryMapper.java index e6bf588a5d..33dc274f92 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryMapper.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryMapper.java @@ -51,6 +51,6 @@ public final class CraftMemoryMapper { } public static GlobalPos toNms(Location location) { - return GlobalPos.of(((CraftWorld) location.getWorld()).getHandle().dimension(), new BlockPosition(location.getX(), location.getY(), location.getZ())); + return GlobalPos.of(((CraftWorld) location.getWorld()).getHandle().dimension(), BlockPosition.containing(location.getX(), location.getY(), location.getZ())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 1b64ab4e0d..7a37c193fc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -16,14 +16,16 @@ import net.minecraft.core.BlockPosition; import net.minecraft.core.EnumDirection; import net.minecraft.network.protocol.game.PacketPlayInCloseWindow; import net.minecraft.resources.MinecraftKey; +import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.EntityPlayer; import net.minecraft.server.level.WorldServer; +import net.minecraft.tags.DamageTypeTags; import net.minecraft.util.Unit; import net.minecraft.world.EnumHand; import net.minecraft.world.IInventory; import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.damagesource.EntityDamageSource; -import net.minecraft.world.damagesource.EntityDamageSourceIndirect; +import net.minecraft.world.damagesource.DamageType; +import net.minecraft.world.damagesource.DamageTypes; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityAreaEffectCloud; @@ -97,7 +99,6 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.inventory.CraftMetaBook; import org.bukkit.craftbukkit.potion.CraftPotionUtil; -import org.bukkit.craftbukkit.util.CraftDamageSource; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.entity.AbstractHorse; @@ -235,8 +236,6 @@ import org.bukkit.inventory.meta.BookMeta; import org.bukkit.potion.PotionEffect; public class CraftEventFactory { - 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 @@ -852,7 +851,8 @@ public class CraftEventFactory { } private static EntityDamageEvent handleEntityDamageEvent(Entity entity, DamageSource source, Map modifiers, Map> modifierFunctions, boolean cancelled) { - if (source.isExplosion()) { + ResourceKey sourceType = source.typeHolder().unwrapKey().get(); + if (source.is(DamageTypeTags.IS_EXPLOSION)) { DamageCause damageCause; Entity damager = entityDamage; entityDamage = null; @@ -879,25 +879,25 @@ public class CraftEventFactory { entity.lastDamageCancelled = true; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled } return event; - } else if (source instanceof EntityDamageSource) { - Entity damager = source.getEntity(); + } else if (source.getEntity() != null) { + Entity damager = source.getDirectEntity(); DamageCause cause = (source.isSweep()) ? DamageCause.ENTITY_SWEEP_ATTACK : DamageCause.ENTITY_ATTACK; - if (source instanceof EntityDamageSourceIndirect) { - damager = ((EntityDamageSourceIndirect) source).getProximateDamageSource(); + if (source.isIndirect()) { + damager = source.getEntity(); if (damager.getBukkitEntity() instanceof ThrownPotion) { cause = DamageCause.MAGIC; } else if (damager.getBukkitEntity() instanceof Projectile) { cause = DamageCause.PROJECTILE; } - } else if ("thorns".equals(source.msgId)) { + } else if ("thorns".equals(source.getMsgId())) { cause = DamageCause.THORNS; - } else if ("sonic_boom".equals(source.msgId)) { + } else if ("sonic_boom".equals(source.getMsgId())) { cause = DamageCause.SONIC_BOOM; } return callEntityDamageEvent(damager, entity, cause, modifiers, modifierFunctions, cancelled); - } else if (source == DamageSource.OUT_OF_WORLD) { + } else if (sourceType == DamageTypes.OUT_OF_WORLD) { EntityDamageEvent event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.VOID, modifiers, modifierFunctions); event.setCancelled(cancelled); callEvent(event); @@ -907,7 +907,7 @@ public class CraftEventFactory { entity.lastDamageCancelled = true; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled } return event; - } else if (source == DamageSource.LAVA) { + } else if (sourceType == DamageTypes.LAVA) { EntityDamageEvent event = (new EntityDamageByBlockEvent(blockDamage, entity.getBukkitEntity(), DamageCause.LAVA, modifiers, modifierFunctions)); event.setCancelled(cancelled); @@ -925,16 +925,16 @@ public class CraftEventFactory { } else if (blockDamage != null) { DamageCause cause = null; Block damager = blockDamage; - if (source == DamageSource.CACTUS || source == DamageSource.SWEET_BERRY_BUSH || source == DamageSource.STALAGMITE || "fallingStalactite".equals(source.msgId) || "anvil".equals(source.msgId)) { + if (sourceType == DamageTypes.CACTUS || sourceType == DamageTypes.SWEET_BERRY_BUSH || sourceType == DamageTypes.STALAGMITE || "fallingStalactite".equals(source.getMsgId()) || "anvil".equals(source.getMsgId())) { cause = DamageCause.CONTACT; - } else if (source == DamageSource.HOT_FLOOR) { + } else if (sourceType == DamageTypes.HOT_FLOOR) { cause = DamageCause.HOT_FLOOR; - } else if (source == DamageSource.MAGIC) { + } else if (sourceType == DamageTypes.MAGIC) { cause = DamageCause.MAGIC; - } else if (source == DamageSource.IN_FIRE) { + } else if (sourceType == DamageTypes.IN_FIRE) { cause = DamageCause.FIRE; } else { - throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager, source.msgId)); + throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager, source.getMsgId())); } EntityDamageEvent event = new EntityDamageByBlockEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions); event.setCancelled(cancelled); @@ -953,18 +953,18 @@ public class CraftEventFactory { DamageCause cause = null; CraftEntity damager = entityDamage.getBukkitEntity(); entityDamage = null; - if ("fallingStalactite".equals(source.msgId) || "fallingBlock".equals(source.msgId) || "anvil".equals(source.msgId)) { + if ("fallingStalactite".equals(source.getMsgId()) || "fallingBlock".equals(source.getMsgId()) || "anvil".equals(source.getMsgId())) { cause = DamageCause.FALLING_BLOCK; } else if (damager instanceof LightningStrike) { cause = DamageCause.LIGHTNING; - } else if (source == DamageSource.FALL) { + } else if (sourceType == DamageTypes.FALL) { cause = DamageCause.FALL; - } else if (source == DamageSource.DRAGON_BREATH) { + } else if (sourceType == DamageTypes.DRAGON_BREATH) { cause = DamageCause.DRAGON_BREATH; - } else if (source == DamageSource.MAGIC) { + } else if (sourceType == DamageTypes.MAGIC) { cause = DamageCause.MAGIC; } else { - throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager.getHandle(), source.msgId)); + throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager.getHandle(), source.getMsgId())); } EntityDamageEvent event = new EntityDamageByEntityEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions); event.setCancelled(cancelled); @@ -978,35 +978,35 @@ public class CraftEventFactory { } DamageCause cause = null; - if (source == DamageSource.IN_FIRE) { + if (sourceType == DamageTypes.IN_FIRE) { cause = DamageCause.FIRE; - } else if (source == DamageSource.STARVE) { + } else if (sourceType == DamageTypes.STARVE) { cause = DamageCause.STARVATION; - } else if (source == DamageSource.WITHER) { + } else if (sourceType == DamageTypes.WITHER) { cause = DamageCause.WITHER; - } else if (source == DamageSource.IN_WALL) { + } else if (sourceType == DamageTypes.IN_WALL) { cause = DamageCause.SUFFOCATION; - } else if (source == DamageSource.DROWN) { + } else if (sourceType == DamageTypes.DROWN) { cause = DamageCause.DROWNING; - } else if (source == DamageSource.ON_FIRE) { + } else if (sourceType == DamageTypes.ON_FIRE) { cause = DamageCause.FIRE_TICK; - } else if (source == MELTING) { + } else if (source.isMelting()) { cause = DamageCause.MELTING; - } else if (source == POISON) { + } else if (source.isPoison()) { cause = DamageCause.POISON; - } else if (source == DamageSource.MAGIC) { + } else if (sourceType == DamageTypes.MAGIC) { cause = DamageCause.MAGIC; - } else if (source == DamageSource.FALL) { + } else if (sourceType == DamageTypes.FALL) { cause = DamageCause.FALL; - } else if (source == DamageSource.FLY_INTO_WALL) { + } else if (sourceType == DamageTypes.FLY_INTO_WALL) { cause = DamageCause.FLY_INTO_WALL; - } else if (source == DamageSource.CRAMMING) { + } else if (sourceType == DamageTypes.CRAMMING) { cause = DamageCause.CRAMMING; - } else if (source == DamageSource.DRY_OUT) { + } else if (sourceType == DamageTypes.DRY_OUT) { cause = DamageCause.DRYOUT; - } else if (source == DamageSource.FREEZE) { + } else if (sourceType == DamageTypes.FREEZE) { cause = DamageCause.FREEZE; - } else if (source == DamageSource.GENERIC) { + } else { cause = DamageCause.CUSTOM; } @@ -1014,7 +1014,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.msgId)); + throw new IllegalStateException(String.format("Unhandled damage of %s from %s", entity, source.getMsgId())); } private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map modifiers, Map> modifierFunctions) { @@ -1047,7 +1047,7 @@ public class CraftEventFactory { Map> modifierFunctions = new EnumMap>(DamageModifier.class); modifiers.put(DamageModifier.BASE, rawDamage); modifierFunctions.put(DamageModifier.BASE, ZERO); - if ("fallingBlock".equals(source.msgId) || "anvil".equals(source.msgId)) { + if ("fallingBlock".equals(source.getMsgId()) || "anvil".equals(source.getMsgId())) { modifiers.put(DamageModifier.HARD_HAT, hardHatModifier); modifierFunctions.put(DamageModifier.HARD_HAT, hardHat); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java index 58fdd379ea..0b2417d411 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java @@ -4,6 +4,7 @@ import com.google.common.base.Preconditions; import com.mojang.serialization.Codec; import java.util.ArrayList; import java.util.List; +import java.util.stream.Stream; import net.minecraft.core.Holder; import net.minecraft.core.IRegistry; import net.minecraft.world.level.biome.BiomeBase; @@ -32,8 +33,6 @@ public class CustomWorldChunkManager extends WorldChunkManager { } public CustomWorldChunkManager(WorldInfo worldInfo, BiomeProvider biomeProvider, IRegistry registry) { - super(biomeListToBiomeBaseList(biomeProvider.getBiomes(worldInfo), registry)); - this.worldInfo = worldInfo; this.biomeProvider = biomeProvider; this.registry = registry; @@ -51,4 +50,9 @@ public class CustomWorldChunkManager extends WorldChunkManager { return CraftBlock.biomeToBiomeBase(registry, biome); } + + @Override + protected Stream> collectPossibleBiomes() { + return biomeListToBiomeBaseList(biomeProvider.getBiomes(worldInfo), registry).stream(); + } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java index 4ea3914aaa..336ba3884f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit.inventory; +import net.minecraft.core.IRegistryCustom; import net.minecraft.server.MinecraftServer; import net.minecraft.world.item.crafting.IRecipeComplex; import org.bukkit.NamespacedKey; @@ -17,7 +18,7 @@ public class CraftComplexRecipe implements CraftRecipe, ComplexRecipe { @Override public ItemStack getResult() { - return CraftItemStack.asCraftMirror(recipe.getResultItem()); + return CraftItemStack.asCraftMirror(recipe.getResultItem(IRegistryCustom.EMPTY)); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java index 4fc1290c02..7dc5939eee 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java @@ -119,7 +119,7 @@ public class CraftContainer extends Container { case ANVIL: return Containers.ANVIL; case SMITHING: - return Containers.SMITHING; + return Containers.LEGACY_SMITHING; case HOPPER: return Containers.HOPPER; case DROPPER: @@ -140,6 +140,8 @@ public class CraftContainer extends Container { return Containers.GRINDSTONE; case STONECUTTER: return Containers.STONECUTTER; + case SMITHING_NEW: + return Containers.SMITHING; case CREATIVE: case CRAFTING: case MERCHANT: @@ -215,6 +217,9 @@ public class CraftContainer extends Container { case MERCHANT: delegate = new ContainerMerchant(windowId, bottom); break; + case SMITHING_NEW: + setupSmithing(top, bottom); // SPIGOT-6783 - manually set up slots so we can use the delegated inventory and not the automatically created one + break; } if (delegate != null) { @@ -280,6 +285,28 @@ public class CraftContainer extends Container { // End copy from ContainerAnvilAbstract } + private void setupSmithing(IInventory top, IInventory bottom) { + // This code copied from ContainerSmithing + this.addSlot(new Slot(top, 0, 8, 48)); + this.addSlot(new Slot(top, 1, 26, 48)); + this.addSlot(new Slot(top, 2, 44, 48)); + this.addSlot(new Slot(top, 3, 98, 48)); + + int row; + int col; + + for (row = 0; row < 3; ++row) { + for (col = 0; col < 9; ++col) { + this.addSlot(new Slot(bottom, col + row * 9 + 9, 8 + col * 18, 84 + row * 18)); + } + } + + for (row = 0; row < 9; ++row) { + this.addSlot(new Slot(bottom, row, 8 + row * 18, 142)); + } + // End copy from ContainerSmithing + } + @Override public ItemStack quickMoveStack(EntityHuman entityhuman, int i) { return (delegate != null) ? delegate.quickMoveStack(entityhuman, i) : ItemStack.EMPTY; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java index df59694e70..581d2fc0bc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -502,6 +502,8 @@ public class CraftInventory implements Inventory { return InventoryType.STONECUTTER; } else if (inventory instanceof BlockComposter.ContainerEmpty || inventory instanceof BlockComposter.ContainerInput || inventory instanceof BlockComposter.ContainerOutput) { return InventoryType.COMPOSTER; + } else if (this instanceof CraftInventorySmithingNew) { + return InventoryType.SMITHING_NEW; } else { return InventoryType.CHEST; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySmithingNew.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySmithingNew.java new file mode 100644 index 0000000000..a49aa02dd1 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySmithingNew.java @@ -0,0 +1,45 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.world.IInventory; +import net.minecraft.world.inventory.InventoryCraftResult; +import net.minecraft.world.item.crafting.IRecipe; +import org.bukkit.Location; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.Recipe; +import org.bukkit.inventory.SmithingInventory; + +public class CraftInventorySmithingNew extends CraftResultInventory implements SmithingInventory { + + private final Location location; + + public CraftInventorySmithingNew(Location location, IInventory inventory, InventoryCraftResult resultInventory) { + super(inventory, resultInventory); + this.location = location; + } + + @Override + public InventoryCraftResult getResultInventory() { + return (InventoryCraftResult) super.getResultInventory(); + } + + @Override + public Location getLocation() { + return location; + } + + @Override + public ItemStack getResult() { + return getItem(3); + } + + @Override + public void setResult(ItemStack item) { + setItem(3, item); + } + + @Override + public Recipe getRecipe() { + IRecipe recipe = getResultInventory().getRecipeUsed(); + return (recipe == null) ? null : recipe.toBukkitRecipe(); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java index c973b45a5b..d43bbd2006 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -184,6 +184,7 @@ public final class CraftItemFactory implements ItemFactory { case SKELETON_HORSE_SPAWN_EGG: case SKELETON_SPAWN_EGG: case SLIME_SPAWN_EGG: + case SNIFFER_SPAWN_EGG: case SNOW_GOLEM_SPAWN_EGG: case SPIDER_SPAWN_EGG: case SQUID_SPAWN_EGG: @@ -230,6 +231,10 @@ public final class CraftItemFactory implements ItemFactory { case BIRCH_SIGN: case BIRCH_WALL_HANGING_SIGN: case BIRCH_WALL_SIGN: + case CHERRY_HANGING_SIGN: + case CHERRY_SIGN: + case CHERRY_WALL_HANGING_SIGN: + case CHERRY_WALL_SIGN: case CRIMSON_HANGING_SIGN: case CRIMSON_SIGN: case CRIMSON_WALL_HANGING_SIGN: @@ -302,6 +307,8 @@ public final class CraftItemFactory implements ItemFactory { case SCULK_SHRIEKER: case SCULK_SENSOR: case CHISELED_BOOKSHELF: + case DECORATED_POT: + case SUSPICIOUS_SAND: return new CraftMetaBlockState(meta, material); case TROPICAL_FISH_BUCKET: return meta instanceof CraftMetaTropicalFishBucket ? meta : new CraftMetaTropicalFishBucket(meta); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index 977065a412..0b0406aec8 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -447,6 +447,7 @@ public final class CraftItemStack extends ItemStack { case SKELETON_HORSE_SPAWN_EGG: case SKELETON_SPAWN_EGG: case SLIME_SPAWN_EGG: + case SNIFFER_SPAWN_EGG: case SNOW_GOLEM_SPAWN_EGG: case SPIDER_SPAWN_EGG: case SQUID_SPAWN_EGG: @@ -493,6 +494,10 @@ public final class CraftItemStack extends ItemStack { case BIRCH_SIGN: case BIRCH_WALL_HANGING_SIGN: case BIRCH_WALL_SIGN: + case CHERRY_HANGING_SIGN: + case CHERRY_SIGN: + case CHERRY_WALL_HANGING_SIGN: + case CHERRY_WALL_SIGN: case CRIMSON_HANGING_SIGN: case CRIMSON_SIGN: case CRIMSON_WALL_HANGING_SIGN: @@ -565,6 +570,8 @@ public final class CraftItemStack extends ItemStack { case SCULK_SHRIEKER: case SCULK_SENSOR: case CHISELED_BOOKSHELF: + case DECORATED_POT: + case SUSPICIOUS_SAND: return new CraftMetaBlockState(item.getTag(), CraftMagicNumbers.getMaterial(item.getItem())); case TROPICAL_FISH_BUCKET: return new CraftMetaTropicalFishBucket(item.getTag()); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java index 671c395747..76b946dfa2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java @@ -59,6 +59,10 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta Material.BIRCH_SIGN, Material.BIRCH_WALL_HANGING_SIGN, Material.BIRCH_WALL_SIGN, + Material.CHERRY_HANGING_SIGN, + Material.CHERRY_SIGN, + Material.CHERRY_WALL_HANGING_SIGN, + Material.CHERRY_WALL_SIGN, Material.CRIMSON_HANGING_SIGN, Material.CRIMSON_SIGN, Material.CRIMSON_WALL_HANGING_SIGN, @@ -113,7 +117,9 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta Material.SCULK_CATALYST, Material.SCULK_SHRIEKER, Material.SCULK_SENSOR, - Material.CHISELED_BOOKSHELF + Material.CHISELED_BOOKSHELF, + Material.DECORATED_POT, + Material.SUSPICIOUS_SAND ); static { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java index 1f49a8cbf9..5a57131bcc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java @@ -71,6 +71,7 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { Material.SKELETON_HORSE_SPAWN_EGG, Material.SKELETON_SPAWN_EGG, Material.SLIME_SPAWN_EGG, + Material.SNIFFER_SPAWN_EGG, Material.SNOW_GOLEM_SPAWN_EGG, Material.SPIDER_SPAWN_EGG, Material.SQUID_SPAWN_EGG, diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java index 4454061228..d3e149d9d9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java @@ -24,6 +24,6 @@ public class CraftSmithingRecipe extends SmithingRecipe implements CraftRecipe { public void addToCraftingManager() { ItemStack result = this.getResult(); - MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeSmithing(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result))); + MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.LegacyUpgradeRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result))); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java new file mode 100644 index 0000000000..872baa62d5 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java @@ -0,0 +1,29 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.server.MinecraftServer; +import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.RecipeChoice; +import org.bukkit.inventory.SmithingTransformRecipe; + +public class CraftSmithingTransformRecipe extends SmithingTransformRecipe implements CraftRecipe { + public CraftSmithingTransformRecipe(NamespacedKey key, ItemStack result, RecipeChoice template, RecipeChoice base, RecipeChoice addition) { + super(key, result, template, base, addition); + } + + public static CraftSmithingTransformRecipe fromBukkitRecipe(SmithingTransformRecipe recipe) { + if (recipe instanceof CraftSmithingTransformRecipe) { + return (CraftSmithingTransformRecipe) recipe; + } + CraftSmithingTransformRecipe ret = new CraftSmithingTransformRecipe(recipe.getKey(), recipe.getResult(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition()); + return ret; + } + + @Override + public void addToCraftingManager() { + ItemStack result = this.getResult(); + + MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.SmithingTransformRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result))); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java new file mode 100644 index 0000000000..6ef43f58d8 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.server.MinecraftServer; +import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.inventory.RecipeChoice; +import org.bukkit.inventory.SmithingTrimRecipe; + +public class CraftSmithingTrimRecipe extends SmithingTrimRecipe implements CraftRecipe { + + public CraftSmithingTrimRecipe(NamespacedKey key, RecipeChoice template, RecipeChoice base, RecipeChoice addition) { + super(key, template, base, addition); + } + + public static CraftSmithingTrimRecipe fromBukkitRecipe(SmithingTrimRecipe recipe) { + if (recipe instanceof CraftSmithingTrimRecipe) { + return (CraftSmithingTrimRecipe) recipe; + } + CraftSmithingTrimRecipe ret = new CraftSmithingTrimRecipe(recipe.getKey(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition()); + return ret; + } + + @Override + public void addToCraftingManager() { + MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.SmithingTrimRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true))); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java index b51321c8dd..638db4b5ec 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java @@ -37,6 +37,7 @@ public final class CraftInventoryCreator { converterMap.put(InventoryType.CARTOGRAPHY, DEFAULT_CONVERTER); converterMap.put(InventoryType.GRINDSTONE, DEFAULT_CONVERTER); converterMap.put(InventoryType.STONECUTTER, DEFAULT_CONVERTER); + converterMap.put(InventoryType.SMITHING_NEW, DEFAULT_CONVERTER); } public Inventory createInventory(InventoryHolder holder, InventoryType type) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftDamageSource.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftDamageSource.java deleted file mode 100644 index c2cfb00ae4..0000000000 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftDamageSource.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.bukkit.craftbukkit.util; - -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.msgId); - - // Check ignoresArmor - if (original.isBypassArmor()) { - newSource.bypassArmor(); - } - - // Check magic - if (original.isMagic()) { - newSource.setMagic(); - } - - // Check fire - if (original.isFire()) { - newSource.setIsFire(); - } - - return newSource; - } - - private CraftDamageSource(String identifier) { - super(identifier); - } -} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java index e52ef47b78..f97eccb6a1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java @@ -3,9 +3,9 @@ package org.bukkit.craftbukkit.util; import org.bukkit.util.CachedServerIcon; public class CraftIconCache implements CachedServerIcon { - public final String value; + public final byte[] value; - public CraftIconCache(final String value) { + public CraftIconCache(final byte[] value) { this.value = value; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 68546700fd..178a32989d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -237,12 +237,12 @@ public final class CraftMagicNumbers implements UnsafeValues { * @return string */ public String getMappingsVersion() { - return "1afe2ffe8a9d7fc510442a168b3d4338"; + return "3009edc0fff87fa34680686663bd59df"; } @Override public int getDataVersion() { - return SharedConstants.getCurrentVersion().getWorldVersion(); + return SharedConstants.getCurrentVersion().getDataVersion().getVersion(); } @Override diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java index 0599eae35c..2b8b5224ed 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java @@ -99,6 +99,13 @@ public class LegacyTest extends AbstractTestingBase { Material.DARK_OAK_HANGING_SIGN, Material.DARK_OAK_WALL_HANGING_SIGN, Material.ENDER_DRAGON_SPAWN_EGG, Material.IRON_GOLEM_SPAWN_EGG, Material.JUNGLE_HANGING_SIGN, Material.JUNGLE_WALL_HANGING_SIGN, Material.MANGROVE_HANGING_SIGN, Material.MANGROVE_WALL_HANGING_SIGN, Material.OAK_HANGING_SIGN, Material.OAK_WALL_HANGING_SIGN, Material.PIGLIN_HEAD, Material.PIGLIN_WALL_HEAD, Material.SNOW_GOLEM_SPAWN_EGG, Material.SPRUCE_HANGING_SIGN, Material.SPRUCE_WALL_HANGING_SIGN, Material.STRIPPED_BAMBOO_BLOCK, Material.WARPED_HANGING_SIGN, Material.WARPED_WALL_HANGING_SIGN, Material.WITHER_SPAWN_EGG, + // 1.19.4 + Material.BRUSH, Material.CHERRY_BOAT, Material.CHERRY_BUTTON, Material.CHERRY_CHEST_BOAT, Material.CHERRY_DOOR, Material.CHERRY_FENCE, Material.CHERRY_FENCE_GATE, Material.CHERRY_HANGING_SIGN, Material.CHERRY_LEAVES, Material.CHERRY_LOG, + Material.CHERRY_PLANKS, Material.CHERRY_PRESSURE_PLATE, Material.CHERRY_SAPLING, Material.CHERRY_SIGN, Material.CHERRY_SLAB, Material.CHERRY_STAIRS, Material.CHERRY_TRAPDOOR, Material.CHERRY_WALL_HANGING_SIGN, Material.CHERRY_WALL_SIGN, + Material.CHERRY_WOOD, Material.COAST_ARMOR_TRIM_SMITHING_TEMPLATE, Material.DECORATED_POT, Material.DUNE_ARMOR_TRIM_SMITHING_TEMPLATE, Material.EYE_ARMOR_TRIM_SMITHING_TEMPLATE, Material.NETHERITE_UPGRADE_SMITHING_TEMPLATE, Material.PINK_PETALS, + Material.POTTED_CHERRY_SAPLING, Material.POTTED_TORCHFLOWER, Material.POTTERY_SHARD_ARCHER, Material.POTTERY_SHARD_ARMS_UP, Material.POTTERY_SHARD_PRIZE, Material.POTTERY_SHARD_SKULL, Material.RIB_ARMOR_TRIM_SMITHING_TEMPLATE, + Material.SENTRY_ARMOR_TRIM_SMITHING_TEMPLATE, Material.SNIFFER_SPAWN_EGG, Material.SNOUT_ARMOR_TRIM_SMITHING_TEMPLATE, Material.SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE, Material.STRIPPED_CHERRY_LOG, Material.STRIPPED_CHERRY_WOOD, Material.SUSPICIOUS_SAND, + Material.TIDE_ARMOR_TRIM_SMITHING_TEMPLATE, Material.TORCHFLOWER, Material.TORCHFLOWER_CROP, Material.TORCHFLOWER_SEEDS, Material.VEX_ARMOR_TRIM_SMITHING_TEMPLATE, Material.WARD_ARMOR_TRIM_SMITHING_TEMPLATE, Material.WILD_ARMOR_TRIM_SMITHING_TEMPLATE, // Material.LEGACY_AIR, Material.LEGACY_DEAD_BUSH, Material.LEGACY_BURNING_FURNACE, Material.LEGACY_WALL_SIGN, Material.LEGACY_REDSTONE_TORCH_OFF, Material.LEGACY_SKULL, Material.LEGACY_REDSTONE_COMPARATOR_ON, Material.LEGACY_WALL_BANNER, Material.LEGACY_MONSTER_EGG)); diff --git a/paper-server/src/test/java/org/bukkit/support/AbstractTestingBase.java b/paper-server/src/test/java/org/bukkit/support/AbstractTestingBase.java index 2426a840b0..8dec5490ac 100644 --- a/paper-server/src/test/java/org/bukkit/support/AbstractTestingBase.java +++ b/paper-server/src/test/java/org/bukkit/support/AbstractTestingBase.java @@ -66,6 +66,6 @@ public abstract class AbstractTestingBase { } } INVALIDATED_MATERIALS = builder.build(); - Assert.assertEquals("Expected 604 invalidated materials (got " + INVALIDATED_MATERIALS.size() + ")", 604, INVALIDATED_MATERIALS.size()); + Assert.assertEquals("Expected 609 invalidated materials (got " + INVALIDATED_MATERIALS.size() + ")", 609, INVALIDATED_MATERIALS.size()); } }