From 5381ea78f76d890cf4bd34ea5f49e21932f84530 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Wed, 4 Dec 2024 03:20:00 +1100 Subject: [PATCH] Update to Minecraft 1.21.4 By: md_5 --- .../core/dispenser/IDispenseBehavior.patch | 2 +- .../minecraft/server/DispenserRegistry.patch | 10 +- .../net/minecraft/server/Main.patch | 28 +- .../minecraft/server/MinecraftServer.patch | 2 +- .../server/commands/CommandTime.patch | 6 +- .../minecraft/server/level/EntityPlayer.patch | 138 ++--- .../minecraft/server/level/TicketType.patch | 4 +- .../minecraft/server/level/WorldServer.patch | 98 ++-- .../server/network/PlayerConnection.patch | 530 +++++++++--------- .../net/minecraft/util/SpawnUtil.patch | 12 +- .../util/datafix/DataConverterRegistry.patch | 12 +- .../world/effect/PoisonMobEffect.patch | 2 +- .../net/minecraft/world/entity/Entity.patch | 94 ++-- .../world/entity/EntityExperienceOrb.patch | 12 +- .../world/entity/EntityInsentient.patch | 51 +- .../minecraft/world/entity/EntityLiving.patch | 64 +-- .../world/entity/EntityTameableAnimal.patch | 2 +- .../minecraft/world/entity/EntityTypes.patch | 17 +- .../minecraft/world/entity/Interaction.patch | 8 +- .../minecraft/world/entity/Leashable.patch | 45 +- .../world/entity/animal/EntityBee.patch | 22 +- .../world/entity/animal/EntityCat.patch | 8 +- .../entity/animal/EntityMushroomCow.patch | 8 +- .../world/entity/animal/EntityParrot.patch | 8 +- .../world/entity/animal/EntitySheep.patch | 17 +- .../world/entity/animal/allay/Allay.patch | 12 +- .../animal/horse/EntityLlamaTrader.patch | 2 +- .../boss/enderdragon/EntityEnderDragon.patch | 20 +- .../entity/boss/wither/EntityWither.patch | 10 +- .../world/entity/decoration/EntityLeash.patch | 10 +- .../world/entity/monster/EntityEnderman.patch | 10 +- .../world/entity/monster/EntityPillager.patch | 4 +- .../world/entity/monster/EntityRavager.patch | 4 +- .../monster/EntitySkeletonAbstract.patch | 2 +- .../entity/monster/EntitySkeletonWither.patch | 2 +- .../world/entity/monster/breeze/Breeze.patch | 2 +- .../entity/monster/creaking/Creaking.patch | 38 ++ .../monster/creaking/CreakingTransient.patch | 20 - .../entity/monster/piglin/EntityPiglin.patch | 28 +- .../world/entity/monster/warden/Warden.patch | 3 +- .../world/entity/npc/EntityVillager.patch | 4 +- .../world/entity/player/EntityHuman.patch | 50 +- .../world/entity/projectile/EntityArrow.patch | 24 +- .../entity/projectile/EntityFireball.patch | 6 +- .../projectile/EntityThrownExpBottle.patch | 10 +- .../projectile/EntityThrownTrident.patch | 4 +- .../world/entity/raid/EntityRaider.patch | 9 - .../world/entity/vehicle/AbstractBoat.patch | 2 +- .../vehicle/EntityMinecartCommandBlock.patch | 2 +- .../entity/vehicle/EntityMinecartTNT.patch | 10 +- .../inventory/ContainerBrewingStand.patch | 12 +- .../inventory/ContainerEnchantTable.patch | 22 +- .../world/inventory/ContainerHorse.patch | 16 +- .../world/inventory/ContainerPlayer.patch | 8 +- .../inventory/ContainerStonecutter.patch | 2 +- .../net/minecraft/world/item/ItemEgg.patch | 6 +- .../minecraft/world/item/ItemEnderPearl.patch | 6 +- .../minecraft/world/item/ItemFishingRod.patch | 4 +- .../minecraft/world/item/ItemSnowball.patch | 6 +- .../net/minecraft/world/item/ItemStack.patch | 23 +- .../minecraft/world/item/ItemTrident.patch | 4 +- .../world/item/alchemy/PotionContents.patch | 2 +- .../world/item/crafting/CraftingManager.patch | 12 +- .../world/item/crafting/RecipeItemStack.patch | 26 +- .../world/item/trading/IMerchant.patch | 6 +- .../world/level/ServerExplosion.patch | 2 +- .../net/minecraft/world/level/World.patch | 22 +- .../minecraft/world/level/block/Block.patch | 2 +- .../world/level/block/BlockBed.patch | 2 +- .../world/level/block/BlockBeehive.patch | 11 +- .../world/level/block/BlockCampfire.patch | 2 +- .../world/level/block/BlockChest.patch | 4 +- .../world/level/block/BlockComposter.patch | 16 +- .../level/block/BlockDirtSnowSpreadable.patch | 4 +- .../world/level/block/BlockLectern.patch | 2 +- .../world/level/block/BlockSponge.patch | 10 +- .../world/level/block/BlockWitherRose.patch | 4 +- .../level/block/SculkCatalystBlock.patch | 2 +- .../world/level/block/SculkSensorBlock.patch | 6 +- .../level/block/SculkShriekerBlock.patch | 2 +- .../world/level/block/SculkVeinBlock.patch | 4 +- .../world/level/block/entity/TileEntity.patch | 13 +- .../level/block/entity/TileEntityBanner.patch | 6 +- .../block/entity/TileEntityBeehive.patch | 44 +- .../level/block/entity/TileEntityChest.patch | 12 - .../block/entity/TileEntityFurnace.patch | 34 +- .../block/entity/TileEntityJukeBox.patch | 4 +- .../block/entity/TileEntityLectern.patch | 2 +- .../block/entity/TileEntityShulkerBox.patch | 4 +- .../level/block/entity/TileEntitySign.patch | 2 +- .../level/block/entity/TileEntityTypes.patch | 20 + .../trialspawner/TrialSpawnerData.patch | 4 +- .../world/level/block/state/BlockBase.patch | 2 +- .../minecraft/world/level/chunk/Chunk.patch | 26 +- .../world/level/chunk/ChunkGenerator.patch | 10 +- .../world/level/chunk/IChunkAccess.patch | 2 +- .../level/chunk/status/ChunkStatusTasks.patch | 2 +- paper-server/pom.xml | 62 +- .../org/bukkit/craftbukkit/CraftParticle.java | 10 +- .../org/bukkit/craftbukkit/CraftWorld.java | 6 +- .../java/org/bukkit/craftbukkit/Main.java | 4 +- .../craftbukkit/block/CraftFurnace.java | 8 +- .../block/data/CraftBlockData.java | 3 +- .../block/data/type/CraftCreakingHeart.java | 21 +- .../block/impl/CraftCreakingHeart.java | 21 +- .../block/impl/CraftMultiface.java | 79 +++ ...ryLeaves.java => CraftParticleLeaves.java} | 12 +- .../entity/CraftCreakingTransient.java | 21 - .../craftbukkit/entity/CraftEntityTypes.java | 2 - .../craftbukkit/entity/CraftLivingEntity.java | 4 +- .../craftbukkit/entity/CraftMinecartTNT.java | 10 + .../craftbukkit/entity/CraftPlayer.java | 17 +- .../generator/CustomChunkGenerator.java | 6 +- .../inventory/CraftItemFactory.java | 2 + .../inventory/CraftMerchantCustom.java | 5 + .../craftbukkit/inventory/CraftMetaItem.java | 41 +- .../craftbukkit/inventory/CraftRecipe.java | 14 +- .../inventory/SerializableMeta.java | 37 ++ .../CraftCustomModelDataComponent.java | 119 ++++ .../components/CraftEquippableComponent.java | 26 +- .../bukkit/craftbukkit/util/ApiVersion.java | 2 +- .../craftbukkit/util/CraftMagicNumbers.java | 2 +- .../src/test/java/org/bukkit/ChatTest.java | 2 +- .../test/java/org/bukkit/ParticleTest.java | 12 +- .../bukkit/craftbukkit/legacy/LegacyTest.java | 3 + 125 files changed, 1383 insertions(+), 1093 deletions(-) create mode 100644 paper-server/nms-patches/net/minecraft/world/entity/monster/creaking/Creaking.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/entity/monster/creaking/CreakingTransient.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityTypes.patch create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMultiface.java rename paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/{CraftCherryLeaves.java => CraftParticleLeaves.java} (72%) delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCreakingTransient.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftCustomModelDataComponent.java 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 502a05bc75..9ea817d606 100644 --- a/paper-server/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch +++ b/paper-server/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch @@ -25,7 +25,7 @@ Logger LOGGER = LogUtils.getLogger(); @@ -90,14 +106,42 @@ EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING); - EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(itemstack); + EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(sourceblock.level().registryAccess(), itemstack); + // CraftBukkit start + WorldServer worldserver = sourceblock.level(); diff --git a/paper-server/nms-patches/net/minecraft/server/DispenserRegistry.patch b/paper-server/nms-patches/net/minecraft/server/DispenserRegistry.patch index 5d9a081597..2c354a2c04 100644 --- a/paper-server/nms-patches/net/minecraft/server/DispenserRegistry.patch +++ b/paper-server/nms-patches/net/minecraft/server/DispenserRegistry.patch @@ -1,19 +1,21 @@ --- a/net/minecraft/server/DispenserRegistry.java +++ b/net/minecraft/server/DispenserRegistry.java -@@ -29,6 +29,12 @@ +@@ -30,7 +30,13 @@ import net.minecraft.world.level.block.state.BlockBase; import org.slf4j.Logger; +-@SuppressForbidden(a = "System.out setup") +// CraftBukkit start +import net.minecraft.util.datafix.fixes.DataConverterFlattenData; +import net.minecraft.util.datafix.fixes.DataConverterMaterialId; +import net.minecraft.util.datafix.fixes.DataConverterSpawnEgg; -+// CraftBukkit end + ++@SuppressForbidden(reason = "System.out setup") ++// CraftBukkit end public class DispenserRegistry { public static final PrintStream STDOUT = System.out; -@@ -40,6 +46,23 @@ +@@ -42,6 +48,23 @@ public static void bootStrap() { if (!DispenserRegistry.isBootstrapped) { @@ -37,7 +39,7 @@ DispenserRegistry.isBootstrapped = true; Instant instant = Instant.now(); -@@ -59,6 +82,69 @@ +@@ -61,6 +84,69 @@ wrapStreams(); DispenserRegistry.bootstrapDuration.set(Duration.between(instant, Instant.now()).toMillis()); } diff --git a/paper-server/nms-patches/net/minecraft/server/Main.patch b/paper-server/nms-patches/net/minecraft/server/Main.patch index 43088e1c11..416ed85cdc 100644 --- a/paper-server/nms-patches/net/minecraft/server/Main.patch +++ b/paper-server/nms-patches/net/minecraft/server/Main.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -60,6 +60,17 @@ +@@ -61,16 +61,28 @@ import net.minecraft.world.level.storage.WorldInfo; import org.slf4j.Logger; @@ -18,9 +18,11 @@ public class Main { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -67,8 +78,9 @@ + public Main() {} +- @SuppressForbidden(a = "System.out needed before bootstrap") ++ @SuppressForbidden(reason = "System.out needed before bootstrap") // CraftBukkit - decompile error @DontObfuscate - public static void main(String[] astring) { + public static void main(final OptionSet optionset) { // CraftBukkit - replaces main(String[] astring) @@ -29,7 +31,7 @@ OptionParser optionparser = new OptionParser(); OptionSpec optionspec = optionparser.accepts("nogui"); OptionSpec optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); -@@ -94,15 +106,18 @@ +@@ -96,15 +108,18 @@ optionparser.printHelpOn(System.err); return; } @@ -50,7 +52,7 @@ JvmProfiler.INSTANCE.start(Environment.SERVER); } -@@ -110,14 +125,27 @@ +@@ -112,14 +127,27 @@ DispenserRegistry.validate(); SystemUtils.startTimerHackThread(); Path path1 = Paths.get("server.properties"); @@ -80,7 +82,7 @@ Main.LOGGER.info("Initialized '{}' and '{}'", path1.toAbsolutePath(), path2.toAbsolutePath()); return; } -@@ -127,11 +155,13 @@ +@@ -129,11 +157,13 @@ return; } @@ -97,7 +99,7 @@ Dynamic dynamic; if (convertable_conversionsession.hasWorldData()) { -@@ -172,13 +202,31 @@ +@@ -174,13 +204,31 @@ } Dynamic dynamic1 = dynamic; @@ -130,7 +132,7 @@ WorldStem worldstem; -@@ -187,6 +235,7 @@ +@@ -189,6 +237,7 @@ worldstem = (WorldStem) SystemUtils.blockUntilDone((executor) -> { return WorldLoader.load(worldloader_c, (worldloader_a) -> { @@ -138,7 +140,7 @@ IRegistry iregistry = worldloader_a.datapackDimensions().lookupOrThrow(Registries.LEVEL_STEM); if (dynamic1 != null) { -@@ -199,7 +248,7 @@ +@@ -201,7 +250,7 @@ WorldOptions worldoptions; WorldDimensions worlddimensions; @@ -147,7 +149,7 @@ worldsettings = MinecraftServer.DEMO_SETTINGS; worldoptions = WorldOptions.DEMO_OPTIONS; worlddimensions = WorldPresets.createNormalWorldDimensions(worldloader_a.datapackWorldgen()); -@@ -207,7 +256,7 @@ +@@ -209,7 +258,7 @@ DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.getProperties(); worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(worldloader_a.dataConfiguration().enabledFeatures()), worldloader_a.dataConfiguration()); @@ -156,7 +158,7 @@ worlddimensions = dedicatedserverproperties.createDimensions(worldloader_a.datapackWorldgen()); } -@@ -223,6 +272,7 @@ +@@ -225,6 +274,7 @@ return; } @@ -164,7 +166,7 @@ IRegistryCustom.Dimension iregistrycustom_dimension = worldstem.registries().compositeAccess(); boolean flag1 = optionset.has(optionspec6); -@@ -235,20 +285,31 @@ +@@ -237,20 +287,31 @@ SaveData savedata = worldstem.worldData(); convertable_conversionsession.saveDataTag(iregistrycustom_dimension, savedata); @@ -198,7 +200,7 @@ Thread thread = new Thread("Server Shutdown Thread") { public void run() { dedicatedserver.halt(true); -@@ -257,6 +318,7 @@ +@@ -259,6 +320,7 @@ thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER)); Runtime.getRuntime().addShutdownHook(thread); @@ -206,7 +208,7 @@ } catch (Exception exception1) { Main.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", exception1); } -@@ -293,7 +355,7 @@ +@@ -295,7 +357,7 @@ } public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, IRegistryCustom iregistrycustom, boolean flag1) { diff --git a/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch b/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch index fd9dbabc74..a5c4537e4a 100644 --- a/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch +++ b/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch @@ -141,7 +141,7 @@ - this.forceDifficulty(); - this.prepareLevels(worldloadlistener); if (profiledduration != null) { - profiledduration.finish(); + profiledduration.finish(true); } @@ -387,23 +448,217 @@ diff --git a/paper-server/nms-patches/net/minecraft/server/commands/CommandTime.patch b/paper-server/nms-patches/net/minecraft/server/commands/CommandTime.patch index 8711223f84..6fd4ab8ae6 100644 --- a/paper-server/nms-patches/net/minecraft/server/commands/CommandTime.patch +++ b/paper-server/nms-patches/net/minecraft/server/commands/CommandTime.patch @@ -32,8 +32,8 @@ + // CraftBukkit end } - commandlistenerwrapper.sendSuccess(() -> { -@@ -64,12 +75,18 @@ + commandlistenerwrapper.getServer().forceTimeSynchronization(); +@@ -65,12 +76,18 @@ } public static int addTime(CommandListenerWrapper commandlistenerwrapper, int i) { @@ -53,4 +53,4 @@ + // CraftBukkit end } - int j = getDayTime(commandlistenerwrapper.getLevel()); + commandlistenerwrapper.getServer().forceTimeSynchronization(); 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 c8e70068b9..f93ce72b60 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 -@@ -184,6 +184,41 @@ +@@ -183,6 +183,41 @@ import net.minecraft.world.scores.criteria.IScoreboardCriteria; import org.slf4j.Logger; @@ -42,7 +42,7 @@ public class EntityPlayer extends EntityHuman { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -227,7 +262,7 @@ +@@ -225,7 +260,7 @@ private int levitationStartTime; private boolean disconnected; private int requestedViewDistance; @@ -51,7 +51,7 @@ @Nullable private Vec3D startingToFallPosition; @Nullable -@@ -261,6 +296,22 @@ +@@ -259,6 +294,22 @@ private int containerCounter; public boolean wonGame; @@ -74,7 +74,7 @@ public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, ClientInformation clientinformation) { super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile); this.chatVisibility = EnumChatVisibility.FULL; -@@ -342,6 +393,13 @@ +@@ -340,6 +391,13 @@ public void sendSystemMessage(IChatBaseComponent ichatbasecomponent) { EntityPlayer.this.sendSystemMessage(ichatbasecomponent); } @@ -88,7 +88,7 @@ }; this.textFilter = minecraftserver.createTextFilterForPlayer(this); this.gameMode = minecraftserver.createGameModeForPlayer(this); -@@ -354,14 +412,67 @@ +@@ -352,14 +410,67 @@ this.moveTo(this.adjustSpawnLocation(worldserver, worldserver.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F); this.updateOptions(clientinformation); this.object = null; @@ -157,7 +157,7 @@ int i = Math.max(0, this.server.getSpawnRadius(worldserver)); int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ())); -@@ -397,14 +508,20 @@ +@@ -395,14 +506,20 @@ Objects.requireNonNull(blockposition); crashreportsystemdetails.setDetail("Origin", blockposition::toString); @@ -180,7 +180,7 @@ }); throw new ReportedException(crashreport); } -@@ -442,7 +559,7 @@ +@@ -440,7 +557,7 @@ dataresult = WardenSpawnTracker.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("warden_spawn_tracker"))); logger = EntityPlayer.LOGGER; Objects.requireNonNull(logger); @@ -189,7 +189,7 @@ this.wardenSpawnTracker = wardenspawntracker; }); } -@@ -459,17 +576,26 @@ +@@ -457,17 +574,26 @@ return this.server.getRecipeManager().byKey(resourcekey).isPresent(); }); } @@ -217,7 +217,7 @@ Logger logger1 = EntityPlayer.LOGGER; Objects.requireNonNull(logger1); -@@ -484,7 +610,7 @@ +@@ -482,7 +608,7 @@ dataresult = BlockPosition.CODEC.parse(DynamicOpsNBT.INSTANCE, nbtbase); logger = EntityPlayer.LOGGER; Objects.requireNonNull(logger); @@ -226,7 +226,7 @@ this.raidOmenPosition = blockposition; }); } -@@ -494,7 +620,7 @@ +@@ -492,7 +618,7 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(nbttagcompound); @@ -235,7 +235,7 @@ Logger logger = EntityPlayer.LOGGER; Objects.requireNonNull(logger); -@@ -528,6 +654,7 @@ +@@ -526,6 +652,7 @@ nbttagcompound.put("SpawnDimension", nbtbase); }); } @@ -243,7 +243,7 @@ nbttagcompound.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall); if (this.raidOmenPosition != null) { -@@ -546,7 +673,20 @@ +@@ -544,7 +671,20 @@ Entity entity = this.getRootVehicle(); Entity entity1 = this.getVehicle(); @@ -265,7 +265,7 @@ NBTTagCompound nbttagcompound1 = new NBTTagCompound(); NBTTagCompound nbttagcompound2 = new NBTTagCompound(); -@@ -600,12 +740,12 @@ +@@ -598,12 +738,12 @@ if (!this.isPassenger()) { EntityPlayer.LOGGER.warn("Couldn't reattach entity to player"); @@ -280,7 +280,7 @@ } } } -@@ -627,7 +767,7 @@ +@@ -625,7 +765,7 @@ NBTTagCompound nbttagcompound1 = new NBTTagCompound(); entityenderpearl.save(nbttagcompound1); @@ -289,7 +289,7 @@ Logger logger = EntityPlayer.LOGGER; Objects.requireNonNull(logger); -@@ -653,7 +793,7 @@ +@@ -651,7 +791,7 @@ nbttaglist.forEach((nbtbase1) -> { if (nbtbase1 instanceof NBTTagCompound nbttagcompound) { if (nbttagcompound.contains("ender_pearl_dimension")) { @@ -298,7 +298,7 @@ Logger logger = EntityPlayer.LOGGER; Objects.requireNonNull(logger); -@@ -688,6 +828,29 @@ +@@ -686,6 +826,29 @@ } @@ -328,7 +328,7 @@ public void setExperiencePoints(int i) { float f = (float) this.getXpNeededForNextLevel(); float f1 = (f - 1.0F) / f; -@@ -746,6 +909,11 @@ +@@ -744,6 +907,11 @@ @Override public void tick() { @@ -337,10 +337,10 @@ + this.joining = false; + } + // CraftBukkit end + this.tickClientLoadTimeout(); this.gameMode.tick(); this.wardenSpawnTracker.tick(); - --this.spawnInvulnerableTime; -@@ -822,7 +990,7 @@ +@@ -820,7 +988,7 @@ } if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -349,7 +349,7 @@ this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -853,6 +1021,12 @@ +@@ -851,6 +1019,12 @@ this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience)); } @@ -362,7 +362,7 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel)); -@@ -867,6 +1041,20 @@ +@@ -865,6 +1039,20 @@ CriterionTriggers.LOCATION.trigger(this); } @@ -383,7 +383,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked"); -@@ -895,7 +1083,7 @@ +@@ -893,7 +1081,7 @@ if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.serverLevel().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { if (this.tickCount % 20 == 0) { if (this.getHealth() < this.getMaxHealth()) { @@ -392,7 +392,7 @@ } float f = this.foodData.getSaturationLevel(); -@@ -948,7 +1136,8 @@ +@@ -946,7 +1134,8 @@ } private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) { @@ -402,7 +402,7 @@ scoreaccess.set(i); }); } -@@ -957,9 +1146,47 @@ +@@ -955,9 +1144,47 @@ public void die(DamageSource damagesource) { this.gameEvent(GameEvent.ENTITY_DIE); boolean flag = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); @@ -452,7 +452,7 @@ this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> { boolean flag1 = true; -@@ -990,12 +1217,18 @@ +@@ -988,12 +1215,18 @@ if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) { this.tellNeutralMobsThatIDied(); } @@ -475,10 +475,10 @@ EntityLiving entityliving = this.getKillCredit(); if (entityliving != null) { -@@ -1030,10 +1263,12 @@ +@@ -1028,10 +1261,12 @@ + public void awardKillScore(Entity entity, DamageSource damagesource) { if (entity != this) { - super.awardKillScore(entity, i, damagesource); - this.increaseScore(i); + super.awardKillScore(entity, damagesource); - this.getScoreboard().forAllObjectives(IScoreboardCriteria.KILL_COUNT_ALL, this, ScoreAccess::increment); + // CraftBukkit - Get our scores instead + this.level().getCraftServer().getScoreboardManager().forAllObjectives(IScoreboardCriteria.KILL_COUNT_ALL, this, ScoreAccess::increment); @@ -490,7 +490,7 @@ } else { this.awardStat(StatisticList.MOB_KILLS); } -@@ -1051,7 +1286,8 @@ +@@ -1049,7 +1284,8 @@ int i = scoreboardteam.getColor().getId(); if (i >= 0 && i < aiscoreboardcriteria.length) { @@ -500,7 +500,7 @@ } } -@@ -1101,10 +1337,16 @@ +@@ -1093,10 +1329,16 @@ } private boolean isPvpAllowed() { @@ -519,7 +519,7 @@ BlockPosition blockposition = this.getRespawnPosition(); float f = this.getRespawnAngle(); boolean flag1 = this.isRespawnForced(); -@@ -1116,13 +1358,32 @@ +@@ -1108,13 +1350,32 @@ if (optional.isPresent()) { EntityPlayer.RespawnPosAngle entityplayer_respawnposangle = (EntityPlayer.RespawnPosAngle) optional.get(); @@ -555,7 +555,7 @@ } public static Optional findRespawnAndUseSpawnBlock(WorldServer worldserver, BlockPosition blockposition, float f, boolean flag, boolean flag1) { -@@ -1137,11 +1398,11 @@ +@@ -1129,11 +1390,11 @@ } return optional.map((vec3d) -> { @@ -569,7 +569,7 @@ }); } else if (!flag) { return Optional.empty(); -@@ -1150,7 +1411,7 @@ +@@ -1142,7 +1403,7 @@ IBlockData iblockdata1 = worldserver.getBlockState(blockposition.above()); boolean flag3 = iblockdata1.getBlock().isPossibleToRespawnInThis(iblockdata1); @@ -578,7 +578,7 @@ } } -@@ -1168,6 +1429,7 @@ +@@ -1160,6 +1421,7 @@ @Nullable @Override public EntityPlayer teleport(TeleportTransition teleporttransition) { @@ -586,7 +586,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1177,18 +1439,38 @@ +@@ -1169,18 +1431,38 @@ WorldServer worldserver = teleporttransition.newLevel(); WorldServer worldserver1 = this.serverLevel(); @@ -628,7 +628,7 @@ this.isChangingDimension = true; WorldData worlddata = worldserver.getLevelData(); -@@ -1199,17 +1481,31 @@ +@@ -1191,17 +1473,31 @@ playerlist.sendPlayerPermissionLevel(this); worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); this.unsetRemoved(); @@ -662,7 +662,7 @@ this.connection.resetPosition(); worldserver.addDuringTeleport(this); gameprofilerfiller.pop(); -@@ -1223,11 +1519,29 @@ +@@ -1215,11 +1511,29 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -692,7 +692,7 @@ @Override public void forceSetRotation(float f, float f1) { this.connection.send(new ClientboundPlayerRotationPacket(f, f1)); -@@ -1236,13 +1550,21 @@ +@@ -1228,13 +1542,21 @@ public void triggerDimensionChangeTriggers(WorldServer worldserver) { ResourceKey resourcekey = worldserver.dimension(); ResourceKey resourcekey1 = this.level().dimension(); @@ -717,7 +717,7 @@ this.enteredNetherPosition = null; } -@@ -1259,19 +1581,17 @@ +@@ -1251,19 +1573,17 @@ this.containerMenu.broadcastChanges(); } @@ -741,7 +741,7 @@ if (this.level().isDay()) { return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_NOW); } else { -@@ -1288,7 +1608,36 @@ +@@ -1280,7 +1600,36 @@ } } @@ -779,7 +779,7 @@ this.awardStat(StatisticList.SLEEP_IN_BED); CriterionTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -1301,9 +1650,8 @@ +@@ -1293,9 +1642,8 @@ return either; } } @@ -790,7 +790,7 @@ } @Override -@@ -1330,13 +1678,31 @@ +@@ -1322,13 +1670,31 @@ @Override public void stopSleepInBed(boolean flag, boolean flag1) { @@ -823,7 +823,7 @@ } } -@@ -1403,8 +1769,9 @@ +@@ -1387,8 +1753,9 @@ this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos(), flag)); } @@ -834,7 +834,7 @@ } @Override -@@ -1412,13 +1779,35 @@ +@@ -1396,13 +1763,35 @@ if (itileinventory == null) { return OptionalInt.empty(); } else { @@ -870,7 +870,7 @@ if (container == null) { if (this.isSpectator()) { this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true); -@@ -1426,9 +1815,11 @@ +@@ -1410,9 +1799,11 @@ return OptionalInt.empty(); } else { @@ -884,7 +884,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1441,15 +1832,26 @@ +@@ -1425,15 +1816,26 @@ @Override public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { @@ -913,7 +913,7 @@ this.initMenu(this.containerMenu); } -@@ -1472,6 +1874,7 @@ +@@ -1456,6 +1858,7 @@ @Override public void closeContainer() { @@ -921,7 +921,7 @@ this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId)); this.doCloseContainer(); } -@@ -1501,19 +1904,19 @@ +@@ -1485,19 +1888,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); @@ -944,7 +944,7 @@ } } else if (this.onClimbable()) { if (d1 > 0.0D) { -@@ -1524,13 +1927,13 @@ +@@ -1508,13 +1911,13 @@ if (i > 0) { if (this.isSprinting()) { this.awardStat(StatisticList.SPRINT_ONE_CM, i); @@ -961,7 +961,7 @@ } } } else if (this.isFallFlying()) { -@@ -1573,7 +1976,7 @@ +@@ -1557,7 +1960,7 @@ @Override public void awardStat(Statistic statistic, int i) { this.stats.increment(this, statistic, i); @@ -970,7 +970,7 @@ scoreaccess.add(i); }); } -@@ -1581,7 +1984,7 @@ +@@ -1565,7 +1968,7 @@ @Override public void resetStat(Statistic statistic) { this.stats.setValue(this, statistic, 0); @@ -979,7 +979,7 @@ } @Override -@@ -1613,9 +2016,9 @@ +@@ -1597,9 +2000,9 @@ super.jumpFromGround(); this.awardStat(StatisticList.JUMP); if (this.isSprinting()) { @@ -991,7 +991,7 @@ } } -@@ -1641,6 +2044,7 @@ +@@ -1625,6 +2028,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -999,7 +999,7 @@ } @Override -@@ -1677,7 +2081,7 @@ +@@ -1661,7 +2065,7 @@ this.onUpdateAbilities(); if (flag) { this.getAttributes().assignBaseValues(entityplayer.getAttributes()); @@ -1008,7 +1008,7 @@ this.setHealth(entityplayer.getHealth()); this.foodData = entityplayer.foodData; Iterator iterator = entityplayer.getActiveEffects().iterator(); -@@ -1685,7 +2089,7 @@ +@@ -1669,7 +2073,7 @@ while (iterator.hasNext()) { MobEffect mobeffect = (MobEffect) iterator.next(); @@ -1017,7 +1017,7 @@ } this.getInventory().replaceWith(entityplayer.getInventory()); -@@ -1696,7 +2100,7 @@ +@@ -1680,7 +2084,7 @@ this.portalProcess = entityplayer.portalProcess; } else { this.getAttributes().assignBaseValues(entityplayer.getAttributes()); @@ -1026,7 +1026,7 @@ if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || entityplayer.isSpectator()) { this.getInventory().replaceWith(entityplayer.getInventory()); this.experienceLevel = entityplayer.experienceLevel; -@@ -1712,7 +2116,7 @@ +@@ -1696,7 +2100,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -1035,16 +1035,16 @@ this.seenCredits = entityplayer.seenCredits; this.enteredNetherPosition = entityplayer.enteredNetherPosition; this.chunkTrackingView = entityplayer.chunkTrackingView; -@@ -1768,7 +2172,7 @@ +@@ -1752,7 +2156,7 @@ } @Override - public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1, boolean flag) { + public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1, boolean flag, TeleportCause cause) { // CraftBukkit - ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(BlockPosition.containing(d0, d1, d2)); - - worldserver.getChunkSource().addRegionTicket(TicketType.POST_TELEPORT, chunkcoordintpair, 1, this.getId()); -@@ -1780,7 +2184,7 @@ + if (this.isSleeping()) { + this.stopSleepInBed(true, true); + } +@@ -1761,7 +2165,7 @@ this.setCamera(this); } @@ -1053,7 +1053,7 @@ if (flag1) { this.setYHeadRot(set.contains(Relative.Y_ROT) ? this.getYHeadRot() + f : f); -@@ -1897,6 +2301,16 @@ +@@ -1878,6 +2282,16 @@ } public void updateOptions(ClientInformation clientinformation) { @@ -1070,7 +1070,7 @@ this.language = clientinformation.language(); this.requestedViewDistance = clientinformation.viewDistance(); this.chatVisibility = clientinformation.chatVisibility(); -@@ -1981,7 +2395,7 @@ +@@ -1962,7 +2376,7 @@ if (world instanceof WorldServer) { WorldServer worldserver = (WorldServer) world; @@ -1079,7 +1079,7 @@ } if (entity != null) { -@@ -2018,11 +2432,11 @@ +@@ -1999,11 +2413,11 @@ @Nullable public IChatBaseComponent getTabListDisplayName() { @@ -1093,7 +1093,7 @@ } @Override -@@ -2065,6 +2479,32 @@ +@@ -2046,6 +2460,32 @@ } public void setRespawnPosition(ResourceKey resourcekey, @Nullable BlockPosition blockposition, float f, boolean flag, boolean flag1) { @@ -1126,7 +1126,7 @@ if (blockposition != null) { boolean flag2 = blockposition.equals(this.respawnPosition) && resourcekey.equals(this.respawnDimension); -@@ -2107,12 +2547,38 @@ +@@ -2088,12 +2528,38 @@ } @Override @@ -1166,7 +1166,7 @@ this.level().addFreshEntity(entityitem); ItemStack itemstack1 = entityitem.getItem(); -@@ -2394,10 +2860,12 @@ +@@ -2375,10 +2841,12 @@ return TicketType.ENDER_PEARL.timeout(); } @@ -1182,7 +1182,7 @@ } private static float calculateLookAtYaw(Vec3D vec3d, BlockPosition blockposition) { -@@ -2406,4 +2874,146 @@ +@@ -2387,4 +2855,146 @@ return (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); } } diff --git a/paper-server/nms-patches/net/minecraft/server/level/TicketType.patch b/paper-server/nms-patches/net/minecraft/server/level/TicketType.patch index 641764302f..6f0d819692 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/TicketType.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/TicketType.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/level/TicketType.java +++ b/net/minecraft/server/level/TicketType.java -@@ -23,6 +23,8 @@ +@@ -22,6 +22,8 @@ + public static final TicketType PORTAL = create("portal", BaseBlockPosition::compareTo, 300); public static final TicketType ENDER_PEARL = create("ender_pearl", Comparator.comparingLong(ChunkCoordIntPair::toLong), 40); - public static final TicketType POST_TELEPORT = create("post_teleport", Integer::compareTo, 5); public static final TicketType UNKNOWN = create("unknown", Comparator.comparingLong(ChunkCoordIntPair::toLong), 1); + public static final TicketType PLUGIN = create("plugin", (a, b) -> 0); // CraftBukkit + public static final TicketType PLUGIN_TICKET = create("plugin_ticket", (plugin1, plugin2) -> plugin1.getClass().getName().compareTo(plugin2.getClass().getName())); // CraftBukkit 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 170108a5ab..9105ba5801 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 -@@ -173,6 +173,23 @@ +@@ -174,6 +174,23 @@ import net.minecraft.world.ticks.TickListServer; import org.slf4j.Logger; @@ -24,7 +24,7 @@ public class WorldServer extends World implements ServerEntityGetter, GeneratorAccessSeed { public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0); -@@ -186,7 +203,7 @@ +@@ -187,7 +204,7 @@ final List players = Lists.newArrayList(); private final ChunkProviderServer chunkSource; private final MinecraftServer server; @@ -33,7 +33,7 @@ private int lastSpawnChunkRadius; final EntityTickList entityTickList = new EntityTickList(); public final PersistentEntitySectionManager entityManager; -@@ -213,13 +230,47 @@ +@@ -214,13 +231,47 @@ private final boolean tickTime; private final RandomSequences randomSequences; @@ -83,7 +83,7 @@ boolean flag2 = minecraftserver.forceSynchronousWrites(); DataFixer datafixer = minecraftserver.getFixerUpper(); EntityPersistentStorage entitypersistentstorage = new EntityStorage(new SimpleRegionStorage(new RegionStorageInfo(convertable_conversionsession.getLevelId(), resourcekey, "entities"), convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, DataFixTypes.ENTITY_CHUNK), this, minecraftserver); -@@ -247,9 +298,9 @@ +@@ -248,9 +299,9 @@ long l = minecraftserver.getWorldData().worldGenOptions().seed(); this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer); @@ -96,7 +96,7 @@ } else { this.dragonFight = null; } -@@ -259,6 +310,7 @@ +@@ -260,6 +311,7 @@ this.randomSequences = (RandomSequences) Objects.requireNonNullElseGet(randomsequences, () -> { return (RandomSequences) this.getDataStorage().computeIfAbsent(RandomSequences.factory(l), "random_sequences"); }); @@ -104,7 +104,7 @@ } /** @deprecated */ -@@ -304,12 +356,20 @@ +@@ -305,12 +357,20 @@ long j; if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { @@ -128,7 +128,7 @@ if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) { this.resetWeatherCycle(); } -@@ -344,7 +404,7 @@ +@@ -345,7 +405,7 @@ this.handlingTick = false; gameprofilerfiller.pop(); @@ -137,7 +137,7 @@ if (flag1) { this.resetEmptyTime(); -@@ -428,7 +488,7 @@ +@@ -429,7 +489,7 @@ private void wakeUpAllPlayers() { this.sleepStatus.removeAllSleepers(); @@ -146,7 +146,7 @@ entityplayer.stopSleepInBed(false, false); }); } -@@ -455,7 +515,7 @@ +@@ -456,7 +516,7 @@ entityhorseskeleton.setTrap(true); entityhorseskeleton.setAge(0); entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); @@ -155,7 +155,7 @@ } } -@@ -464,7 +524,7 @@ +@@ -465,7 +525,7 @@ if (entitylightning != null) { entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition)); entitylightning.setVisualOnly(flag1); @@ -164,7 +164,7 @@ } } } -@@ -520,7 +580,7 @@ +@@ -521,7 +581,7 @@ BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition1).value(); if (biomebase.shouldFreeze(this, blockposition2)) { @@ -173,7 +173,7 @@ } if (this.isRaining()) { -@@ -536,10 +596,10 @@ +@@ -537,10 +597,10 @@ IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, j + 1); Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition1); @@ -186,7 +186,7 @@ } } -@@ -700,6 +760,7 @@ +@@ -701,6 +761,7 @@ this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F); } @@ -194,7 +194,7 @@ if (this.oRainLevel != this.rainLevel) { this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension()); } -@@ -718,15 +779,48 @@ +@@ -719,15 +780,48 @@ this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } @@ -245,7 +245,7 @@ } public void resetEmptyTime() { -@@ -762,6 +856,7 @@ +@@ -763,6 +857,7 @@ }); gameprofilerfiller.incrementCounter("tickNonPassenger"); entity.tick(); @@ -253,7 +253,7 @@ gameprofilerfiller.pop(); Iterator iterator = entity.getPassengers().iterator(); -@@ -785,6 +880,7 @@ +@@ -786,6 +881,7 @@ }); gameprofilerfiller.incrementCounter("tickPassenger"); entity1.rideTick(); @@ -261,7 +261,7 @@ gameprofilerfiller.pop(); Iterator iterator = entity1.getPassengers().iterator(); -@@ -809,6 +905,7 @@ +@@ -810,6 +906,7 @@ ChunkProviderServer chunkproviderserver = this.getChunkSource(); if (!flag1) { @@ -269,7 +269,7 @@ if (iprogressupdate != null) { iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel")); } -@@ -826,11 +923,19 @@ +@@ -827,11 +924,19 @@ } } @@ -290,7 +290,7 @@ } WorldPersistentData worldpersistentdata = this.getChunkSource().getDataStorage(); -@@ -902,18 +1007,40 @@ +@@ -903,18 +1008,40 @@ @Override public boolean addFreshEntity(Entity entity) { @@ -334,7 +334,7 @@ } } -@@ -938,24 +1065,37 @@ +@@ -939,24 +1066,37 @@ this.entityManager.addNewEntity(entityplayer); } @@ -376,19 +376,19 @@ return true; } } -@@ -966,13 +1106,35 @@ +@@ -967,13 +1107,35 @@ } public void removePlayerImmediately(EntityPlayer entityplayer, Entity.RemovalReason entity_removalreason) { - entityplayer.remove(entity_removalreason); + entityplayer.remove(entity_removalreason, null); // CraftBukkit - add Bukkit remove cause -+ } -+ + } + + // CraftBukkit start + public boolean strikeLightning(Entity entitylightning) { + return this.strikeLightning(entitylightning, LightningStrikeEvent.Cause.UNKNOWN); - } - ++ } ++ + public boolean strikeLightning(Entity entitylightning, LightningStrikeEvent.Cause cause) { + LightningStrikeEvent lightning = CraftEventFactory.callLightningStrikeEvent((org.bukkit.entity.LightningStrike) entitylightning.getBukkitEntity(), cause); + @@ -413,7 +413,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -981,6 +1143,12 @@ +@@ -982,6 +1144,12 @@ double d1 = (double) blockposition.getY() - entityplayer.getY(); double d2 = (double) blockposition.getZ() - entityplayer.getZ(); @@ -426,7 +426,7 @@ if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); } -@@ -1059,7 +1227,18 @@ +@@ -1060,7 +1228,18 @@ Iterator iterator = this.navigatingMobs.iterator(); while (iterator.hasNext()) { @@ -446,7 +446,7 @@ NavigationAbstract navigationabstract = entityinsentient.getNavigation(); if (navigationabstract.shouldRecomputePath(blockposition)) { -@@ -1125,6 +1304,12 @@ +@@ -1126,6 +1305,12 @@ @Override public void explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, World.a world_a, ParticleParam particleparam, ParticleParam particleparam1, Holder holder) { @@ -459,7 +459,7 @@ Explosion.Effect explosion_effect; switch (world_a) { -@@ -1143,6 +1328,11 @@ +@@ -1144,6 +1329,11 @@ case TRIGGER: explosion_effect = Explosion.Effect.TRIGGER_BLOCK; break; @@ -471,7 +471,7 @@ default: throw new MatchException((String) null, (Throwable) null); } -@@ -1152,6 +1342,11 @@ +@@ -1153,6 +1343,11 @@ ServerExplosion serverexplosion = new ServerExplosion(this, entity, damagesource, explosiondamagecalculator, vec3d, f, flag, explosion_effect1); serverexplosion.explode(); @@ -483,7 +483,7 @@ ParticleParam particleparam2 = serverexplosion.isSmall() ? particleparam : particleparam1; Iterator iterator = this.players.iterator(); -@@ -1165,6 +1360,7 @@ +@@ -1166,6 +1361,7 @@ } } @@ -491,30 +491,28 @@ } private Explosion.Effect getDestroyType(GameRules.GameRuleKey gamerules_gamerulekey) { -@@ -1225,13 +1421,20 @@ +@@ -1226,15 +1422,18 @@ } public int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { -- PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, false, d0, d1, d2, (float) d3, (float) d4, (float) d5, (float) d6, i); +- return this.sendParticles(t0, false, false, d0, d1, d2, i, d3, d4, d5, d6); + // CraftBukkit - visibility api support -+ return sendParticles(null, t0, d0, d1, d2, i, d3, d4, d5, d6, false); -+ } -+ -+ public int sendParticles(EntityPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, boolean force) { -+ PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, force, d0, d1, d2, (float) d3, (float) d4, (float) d5, (float) d6, i); ++ return this.sendParticlesSource(null, t0, false, false, d0, d1, d2, i, d3, d4, d5, d6); + } + +- public int sendParticles(T t0, boolean flag, boolean flag1, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { ++ public int sendParticlesSource(EntityPlayer sender, T t0, boolean flag, boolean flag1, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { + // CraftBukkit end + PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, flag, flag1, d0, d1, d2, (float) d3, (float) d4, (float) d5, (float) d6, i); int j = 0; for (int k = 0; k < this.players.size(); ++k) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(k); + if (sender != null && !entityplayer.getBukkitEntity().canSee(sender.getBukkitEntity())) continue; // CraftBukkit -- if (this.sendParticles(entityplayer, false, d0, d1, d2, packetplayoutworldparticles)) { -+ if (this.sendParticles(entityplayer, force, d0, d1, d2, packetplayoutworldparticles)) { // CraftBukkit + if (this.sendParticles(entityplayer, flag, d0, d1, d2, packetplayoutworldparticles)) { ++j; - } - } -@@ -1282,7 +1485,7 @@ +@@ -1292,7 +1491,7 @@ @Nullable public BlockPosition findNearestMapStructure(TagKey tagkey, BlockPosition blockposition, int i, boolean flag) { @@ -523,7 +521,7 @@ return null; } else { Optional> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(tagkey); -@@ -1324,11 +1527,22 @@ +@@ -1334,11 +1533,22 @@ @Nullable @Override public WorldMap getMapData(MapId mapid) { @@ -547,7 +545,7 @@ this.getServer().overworld().getDataStorage().set(mapid.key(), worldmap); } -@@ -1639,6 +1853,11 @@ +@@ -1649,6 +1859,11 @@ @Override public void blockUpdated(BlockPosition blockposition, Block block) { if (!this.isDebug()) { @@ -559,7 +557,7 @@ this.updateNeighborsAt(blockposition, block); } -@@ -1658,12 +1877,12 @@ +@@ -1668,12 +1883,12 @@ } public boolean isFlat() { @@ -574,7 +572,7 @@ } @Nullable -@@ -1686,7 +1905,7 @@ +@@ -1696,7 +1911,7 @@ private static String getTypeCount(Iterable iterable, Function function) { try { Object2IntOpenHashMap object2intopenhashmap = new Object2IntOpenHashMap(); @@ -583,7 +581,7 @@ while (iterator.hasNext()) { T t0 = iterator.next(); -@@ -1695,7 +1914,7 @@ +@@ -1705,7 +1920,7 @@ object2intopenhashmap.addTo(s, 1); } @@ -592,7 +590,7 @@ String s1 = (String) entry.getKey(); return s1 + ":" + entry.getIntValue(); -@@ -1854,6 +2073,8 @@ +@@ -1864,6 +2079,8 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -601,7 +599,7 @@ } public void onTrackingEnd(Entity entity) { -@@ -1885,6 +2106,14 @@ +@@ -1895,6 +2112,14 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); 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 7d996ba2fe..d02df844e2 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 -@@ -196,6 +196,71 @@ +@@ -198,6 +198,71 @@ import net.minecraft.world.phys.shapes.VoxelShapes; import org.slf4j.Logger; @@ -72,7 +72,7 @@ public class PlayerConnection extends ServerCommonPacketListenerImpl implements PacketListenerPlayIn, ServerPlayerConnection, TickablePacketListener { static final Logger LOGGER = LogUtils.getLogger(); -@@ -245,7 +310,7 @@ +@@ -247,7 +312,7 @@ private boolean waitingForSwitchToConfig; public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer, CommonListenerCookie commonlistenercookie) { @@ -81,7 +81,7 @@ this.chunkSender = new PlayerChunkSender(networkmanager.isMemoryConnection()); this.player = entityplayer; entityplayer.connection = this; -@@ -254,9 +319,25 @@ +@@ -256,9 +321,25 @@ Objects.requireNonNull(minecraftserver); this.signedMessageDecoder = SignedMessageChain.b.unsigned(uuid, minecraftserver::enforceSecureProfile); @@ -108,7 +108,7 @@ @Override public void tick() { if (this.ackBlockChangesUpTo > -1) { -@@ -311,6 +392,7 @@ +@@ -313,6 +394,7 @@ this.chatSpamThrottler.tick(); this.dropSpamThrottler.tick(); if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && SystemUtils.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L) { @@ -116,7 +116,7 @@ this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.idling")); } -@@ -374,6 +456,12 @@ +@@ -376,6 +458,12 @@ @Override public void handlePlayerInput(PacketPlayInSteerVehicle packetplayinsteervehicle) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinsteervehicle, this, this.player.serverLevel()); @@ -129,7 +129,7 @@ this.player.setLastClientInput(packetplayinsteervehicle.input()); } -@@ -399,6 +487,13 @@ +@@ -401,6 +489,13 @@ if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) { WorldServer worldserver = this.player.serverLevel(); @@ -143,7 +143,7 @@ double d0 = entity.getX(); double d1 = entity.getY(); double d2 = entity.getZ(); -@@ -413,7 +508,33 @@ +@@ -415,7 +510,33 @@ double d9 = entity.getDeltaMovement().lengthSqr(); double d10 = d6 * d6 + d7 * d7 + d8 * d8; @@ -176,9 +176,9 @@ + if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { + // CraftBukkit end PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8}); - this.send(new PacketPlayOutVehicleMove(entity)); + this.send(PacketPlayOutVehicleMove.fromEntity(entity)); return; -@@ -453,14 +574,76 @@ +@@ -455,14 +576,67 @@ } entity.absMoveTo(d3, d4, d5, f, f1); @@ -188,7 +188,7 @@ if (flag && (flag2 || !flag3)) { entity.absMoveTo(d0, d1, d2, f, f1); + player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit - this.send(new PacketPlayOutVehicleMove(entity)); + this.send(PacketPlayOutVehicleMove.fromEntity(entity)); return; } @@ -203,16 +203,7 @@ + this.hasMoved = true; + } + Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location. -+ Location to = player.getLocation().clone(); // Start off the To location as the Players current location. -+ -+ // If the packet contains movement information then we update the To location with the correct XYZ. -+ to.setX(packetplayinvehiclemove.getX()); -+ to.setY(packetplayinvehiclemove.getY()); -+ to.setZ(packetplayinvehiclemove.getZ()); -+ -+ // If the packet contains look information then we update the To location with the correct Yaw & Pitch. -+ to.setYaw(packetplayinvehiclemove.getYRot()); -+ to.setPitch(packetplayinvehiclemove.getXRot()); ++ Location to = CraftLocation.toBukkit(packetplayinvehiclemove.position(), player.getWorld(), packetplayinvehiclemove.yRot(), packetplayinvehiclemove.xRot()); + + // Prevent 40 event-calls for less than a single pixel of movement >.> + double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2); @@ -255,15 +246,15 @@ this.player.serverLevel().getChunkSource().move(this.player); entity.recordMovementThroughBlocks(new Vec3D(d0, d1, d2), entity.position()); Vec3D vec3d = new Vec3D(entity.getX() - d0, entity.getY() - d1, entity.getZ() - d2); -@@ -498,6 +681,7 @@ - } - +@@ -499,6 +673,7 @@ + this.lastGoodZ = this.awaitingPositionFromClient.z; + this.player.hasChangedDimension(); this.awaitingPositionFromClient = null; + this.player.serverLevel().getChunkSource().move(this.player); // CraftBukkit } } -@@ -521,6 +705,7 @@ +@@ -528,6 +703,7 @@ @Override public void handleRecipeBookChangeSettingsPacket(PacketPlayInRecipeSettings packetplayinrecipesettings) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipesettings, this, this.player.serverLevel()); @@ -271,7 +262,7 @@ this.player.getRecipeBook().setBookSetting(packetplayinrecipesettings.getBookType(), packetplayinrecipesettings.isOpen(), packetplayinrecipesettings.isFiltering()); } -@@ -541,6 +726,12 @@ +@@ -548,6 +724,12 @@ @Override public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.serverLevel()); @@ -284,7 +275,7 @@ StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand()); if (stringreader.canRead() && stringreader.peek() == '/') { -@@ -550,6 +741,7 @@ +@@ -557,6 +739,7 @@ ParseResults parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { @@ -292,7 +283,7 @@ Suggestions suggestions1 = suggestions.getList().size() <= 1000 ? suggestions : new Suggestions(suggestions.getRange(), suggestions.getList().subList(0, 1000)); this.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions1)); -@@ -796,6 +988,13 @@ +@@ -866,6 +1049,13 @@ Container container = this.player.containerMenu; if (container instanceof ContainerMerchant containermerchant) { @@ -306,7 +297,7 @@ if (!containermerchant.stillValid(this.player)) { PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant); return; -@@ -809,6 +1008,13 @@ +@@ -879,6 +1069,13 @@ @Override public void handleEditBook(PacketPlayInBEdit packetplayinbedit) { @@ -320,7 +311,7 @@ int i = packetplayinbedit.slot(); if (PlayerInventory.isHotbarSlot(i) || i == 40) { -@@ -829,12 +1035,16 @@ +@@ -899,12 +1096,16 @@ } private void updateBookContents(List list, int i) { @@ -338,7 +329,7 @@ } } -@@ -845,12 +1055,13 @@ +@@ -915,12 +1116,13 @@ ItemStack itemstack1 = itemstack.transmuteCopy(Items.WRITTEN_BOOK); itemstack1.remove(DataComponents.WRITABLE_BOOK_CONTENT); @@ -354,7 +345,7 @@ } } -@@ -912,7 +1123,7 @@ +@@ -982,7 +1184,7 @@ } else { WorldServer worldserver = this.player.serverLevel(); @@ -363,7 +354,7 @@ if (this.tickCount == 0) { this.resetPosition(); } -@@ -927,7 +1138,15 @@ +@@ -997,7 +1199,15 @@ if (this.player.isPassenger()) { this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); this.player.serverLevel().getChunkSource().move(this.player); @@ -379,7 +370,7 @@ double d3 = this.player.getX(); double d4 = this.player.getY(); double d5 = this.player.getZ(); -@@ -949,15 +1168,33 @@ +@@ -1019,15 +1229,33 @@ ++this.receivedMovePacketCount; int i = this.receivedMovePacketCount - this.knownMovePacketCount; @@ -415,7 +406,7 @@ PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8}); this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot()); return; -@@ -979,6 +1216,7 @@ +@@ -1049,6 +1277,7 @@ boolean flag2 = this.player.verticalCollisionBelow; this.player.move(EnumMoveType.PLAYER, new Vec3D(d6, d7, d8)); @@ -423,7 +414,7 @@ double d11 = d7; d6 = d0 - this.player.getX(); -@@ -997,9 +1235,75 @@ +@@ -1067,9 +1296,75 @@ } if (!this.player.noPhysics && !this.player.isSleeping() && (flag3 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) { @@ -500,7 +491,7 @@ this.player.absMoveTo(d0, d1, d2, f, f1); boolean flag4 = this.player.isAutoSpinAttack(); -@@ -1049,6 +1353,7 @@ +@@ -1119,6 +1414,7 @@ this.awaitingTeleportTime = this.tickCount; this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); } @@ -508,7 +499,7 @@ return true; } else { -@@ -1077,10 +1382,62 @@ +@@ -1147,10 +1443,62 @@ } public void teleport(double d0, double d1, double d2, float f, float f1) { @@ -572,7 +563,7 @@ this.awaitingTeleportTime = this.tickCount; if (++this.awaitingTeleport == Integer.MAX_VALUE) { this.awaitingTeleport = 0; -@@ -1088,12 +1445,20 @@ +@@ -1158,12 +1506,20 @@ this.player.teleportSetPosition(positionmoverotation, set); this.awaitingPositionFromClient = this.player.position(); @@ -590,131 +581,131 @@ public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.serverLevel()); + if (this.player.isImmobile()) return; // CraftBukkit - BlockPosition blockposition = packetplayinblockdig.getPos(); + if (this.player.hasClientLoaded()) { + BlockPosition blockposition = packetplayinblockdig.getPos(); - this.player.resetLastActionTime(); -@@ -1104,14 +1469,46 @@ - if (!this.player.isSpectator()) { - ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND); +@@ -1175,14 +1531,46 @@ + if (!this.player.isSpectator()) { + ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND); -- this.player.setItemInHand(EnumHand.OFF_HAND, this.player.getItemInHand(EnumHand.MAIN_HAND)); -- this.player.setItemInHand(EnumHand.MAIN_HAND, itemstack); -+ // CraftBukkit start - inspiration taken from DispenserRegistry (See SpigotCraft#394) -+ CraftItemStack mainHand = CraftItemStack.asCraftMirror(itemstack); -+ CraftItemStack offHand = CraftItemStack.asCraftMirror(this.player.getItemInHand(EnumHand.MAIN_HAND)); -+ PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(getCraftPlayer(), mainHand.clone(), offHand.clone()); -+ this.cserver.getPluginManager().callEvent(swapItemsEvent); -+ if (swapItemsEvent.isCancelled()) { -+ return; -+ } -+ if (swapItemsEvent.getOffHandItem().equals(offHand)) { -+ this.player.setItemInHand(EnumHand.OFF_HAND, this.player.getItemInHand(EnumHand.MAIN_HAND)); -+ } else { -+ this.player.setItemInHand(EnumHand.OFF_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem())); -+ } -+ if (swapItemsEvent.getMainHandItem().equals(mainHand)) { -+ this.player.setItemInHand(EnumHand.MAIN_HAND, itemstack); -+ } else { -+ this.player.setItemInHand(EnumHand.MAIN_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem())); -+ } -+ // CraftBukkit end - this.player.stopUsingItem(); - } - - return; - case DROP_ITEM: - if (!this.player.isSpectator()) { -+ // limit how quickly items can be dropped -+ // If the ticks aren't the same then the count starts from 0 and we update the lastDropTick. -+ if (this.lastDropTick != MinecraftServer.currentTick) { -+ this.dropCount = 0; -+ this.lastDropTick = MinecraftServer.currentTick; -+ } else { -+ // Else we increment the drop count and check the amount. -+ this.dropCount++; -+ if (this.dropCount >= 20) { -+ LOGGER.warn(this.player.getScoreboardName() + " dropped their items too quickly!"); -+ this.disconnect(IChatBaseComponent.literal("You dropped your items too quickly (Hacking?)")); +- this.player.setItemInHand(EnumHand.OFF_HAND, this.player.getItemInHand(EnumHand.MAIN_HAND)); +- this.player.setItemInHand(EnumHand.MAIN_HAND, itemstack); ++ // CraftBukkit start - inspiration taken from DispenserRegistry (See SpigotCraft#394) ++ CraftItemStack mainHand = CraftItemStack.asCraftMirror(itemstack); ++ CraftItemStack offHand = CraftItemStack.asCraftMirror(this.player.getItemInHand(EnumHand.MAIN_HAND)); ++ PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(getCraftPlayer(), mainHand.clone(), offHand.clone()); ++ this.cserver.getPluginManager().callEvent(swapItemsEvent); ++ if (swapItemsEvent.isCancelled()) { + return; + } -+ } -+ // CraftBukkit end - this.player.drop(false); - } ++ if (swapItemsEvent.getOffHandItem().equals(offHand)) { ++ this.player.setItemInHand(EnumHand.OFF_HAND, this.player.getItemInHand(EnumHand.MAIN_HAND)); ++ } else { ++ this.player.setItemInHand(EnumHand.OFF_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem())); ++ } ++ if (swapItemsEvent.getMainHandItem().equals(mainHand)) { ++ this.player.setItemInHand(EnumHand.MAIN_HAND, itemstack); ++ } else { ++ this.player.setItemInHand(EnumHand.MAIN_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem())); ++ } ++ // CraftBukkit end + this.player.stopUsingItem(); + } -@@ -1149,6 +1546,7 @@ + return; + case DROP_ITEM: + if (!this.player.isSpectator()) { ++ // limit how quickly items can be dropped ++ // If the ticks aren't the same then the count starts from 0 and we update the lastDropTick. ++ if (this.lastDropTick != MinecraftServer.currentTick) { ++ this.dropCount = 0; ++ this.lastDropTick = MinecraftServer.currentTick; ++ } else { ++ // Else we increment the drop count and check the amount. ++ this.dropCount++; ++ if (this.dropCount >= 20) { ++ LOGGER.warn(this.player.getScoreboardName() + " dropped their items too quickly!"); ++ this.disconnect(IChatBaseComponent.literal("You dropped your items too quickly (Hacking?)")); ++ return; ++ } ++ } ++ // CraftBukkit end + this.player.drop(false); + } + +@@ -1221,6 +1609,7 @@ @Override public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.serverLevel()); + if (this.player.isImmobile()) return; // CraftBukkit - this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence()); - WorldServer worldserver = this.player.serverLevel(); - EnumHand enumhand = packetplayinuseitem.getHand(); -@@ -1171,6 +1569,7 @@ + if (this.player.hasClientLoaded()) { + this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence()); + WorldServer worldserver = this.player.serverLevel(); +@@ -1244,6 +1633,7 @@ - if (blockposition.getY() <= i) { - if (this.awaitingPositionFromClient == null && worldserver.mayInteract(this.player, blockposition)) { -+ this.player.stopUsingItem(); // CraftBukkit - SPIGOT-4706 - EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); + if (blockposition.getY() <= i) { + if (this.awaitingPositionFromClient == null && worldserver.mayInteract(this.player, blockposition)) { ++ this.player.stopUsingItem(); // CraftBukkit - SPIGOT-4706 + EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); - if (enuminteractionresult.consumesAction()) { -@@ -1207,6 +1606,7 @@ + if (enuminteractionresult.consumesAction()) { +@@ -1281,6 +1671,7 @@ @Override public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.serverLevel()); + if (this.player.isImmobile()) return; // CraftBukkit - this.ackBlockChangesUpTo(packetplayinblockplace.getSequence()); - WorldServer worldserver = this.player.serverLevel(); - EnumHand enumhand = packetplayinblockplace.getHand(); -@@ -1221,6 +1621,47 @@ - this.player.absRotateTo(f, f1); - } + if (this.player.hasClientLoaded()) { + this.ackBlockChangesUpTo(packetplayinblockplace.getSequence()); + WorldServer worldserver = this.player.serverLevel(); +@@ -1296,6 +1687,47 @@ + this.player.absRotateTo(f, f1); + } -+ // CraftBukkit start -+ // Raytrace to look for 'rogue armswings' -+ double d0 = this.player.getX(); -+ double d1 = this.player.getY() + (double) this.player.getEyeHeight(); -+ double d2 = this.player.getZ(); -+ Vec3D vec3d = new Vec3D(d0, d1, d2); ++ // CraftBukkit start ++ // Raytrace to look for 'rogue armswings' ++ double d0 = this.player.getX(); ++ double d1 = this.player.getY() + (double) this.player.getEyeHeight(); ++ double d2 = this.player.getZ(); ++ Vec3D vec3d = new Vec3D(d0, d1, d2); + -+ float f3 = MathHelper.cos(-f * 0.017453292F - 3.1415927F); -+ float f4 = MathHelper.sin(-f * 0.017453292F - 3.1415927F); -+ float f5 = -MathHelper.cos(-f1 * 0.017453292F); -+ float f6 = MathHelper.sin(-f1 * 0.017453292F); -+ float f7 = f4 * f5; -+ float f8 = f3 * f5; -+ double d3 = player.blockInteractionRange(); -+ Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); -+ MovingObjectPosition movingobjectposition = this.player.level().clip(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.OUTLINE, RayTrace.FluidCollisionOption.NONE, player)); ++ float f3 = MathHelper.cos(-f * 0.017453292F - 3.1415927F); ++ float f4 = MathHelper.sin(-f * 0.017453292F - 3.1415927F); ++ float f5 = -MathHelper.cos(-f1 * 0.017453292F); ++ float f6 = MathHelper.sin(-f1 * 0.017453292F); ++ float f7 = f4 * f5; ++ float f8 = f3 * f5; ++ double d3 = player.blockInteractionRange(); ++ Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); ++ MovingObjectPosition movingobjectposition = this.player.level().clip(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.OUTLINE, RayTrace.FluidCollisionOption.NONE, player)); + -+ boolean cancelled; -+ if (movingobjectposition == null || movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.BLOCK) { -+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack, enumhand); -+ cancelled = event.useItemInHand() == Event.Result.DENY; -+ } else { -+ MovingObjectPositionBlock movingobjectpositionblock = (MovingObjectPositionBlock) movingobjectposition; -+ if (player.gameMode.firedInteract && player.gameMode.interactPosition.equals(movingobjectpositionblock.getBlockPos()) && player.gameMode.interactHand == enumhand && ItemStack.isSameItemSameComponents(player.gameMode.interactItemStack, itemstack)) { -+ cancelled = player.gameMode.interactResult; -+ } else { -+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), itemstack, true, enumhand, movingobjectpositionblock.getLocation()); ++ boolean cancelled; ++ if (movingobjectposition == null || movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.BLOCK) { ++ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack, enumhand); + cancelled = event.useItemInHand() == Event.Result.DENY; ++ } else { ++ MovingObjectPositionBlock movingobjectpositionblock = (MovingObjectPositionBlock) movingobjectposition; ++ if (player.gameMode.firedInteract && player.gameMode.interactPosition.equals(movingobjectpositionblock.getBlockPos()) && player.gameMode.interactHand == enumhand && ItemStack.isSameItemSameComponents(player.gameMode.interactItemStack, itemstack)) { ++ cancelled = player.gameMode.interactResult; ++ } else { ++ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), itemstack, true, enumhand, movingobjectpositionblock.getLocation()); ++ cancelled = event.useItemInHand() == Event.Result.DENY; ++ } ++ player.gameMode.firedInteract = false; + } -+ player.gameMode.firedInteract = false; -+ } + -+ if (cancelled) { -+ this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524 -+ return; -+ } -+ itemstack = this.player.getItemInHand(enumhand); // Update in case it was changed in the event -+ if (itemstack.isEmpty()) { -+ return; -+ } -+ // CraftBukkit end - EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand); ++ if (cancelled) { ++ this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524 ++ return; ++ } ++ itemstack = this.player.getItemInHand(enumhand); // Update in case it was changed in the event ++ if (itemstack.isEmpty()) { ++ return; ++ } ++ // CraftBukkit end + EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand); - if (enuminteractionresult instanceof EnumInteractionResult.d) { -@@ -1245,7 +1686,7 @@ + if (enuminteractionresult instanceof EnumInteractionResult.d) { +@@ -1321,7 +1753,7 @@ Entity entity = packetplayinspectate.getEntity(worldserver); if (entity != null) { @@ -723,7 +714,7 @@ return; } } -@@ -1266,6 +1707,13 @@ +@@ -1342,6 +1774,13 @@ @Override public void onDisconnect(DisconnectionDetails disconnectiondetails) { @@ -737,7 +728,7 @@ PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), disconnectiondetails.reason().getString()); this.removePlayerFromWorld(); super.onDisconnect(disconnectiondetails); -@@ -1273,10 +1721,18 @@ +@@ -1349,10 +1788,18 @@ private void removePlayerFromWorld() { this.chatMessageChain.close(); @@ -757,7 +748,7 @@ this.player.getTextFilter().leave(); } -@@ -1291,7 +1747,16 @@ +@@ -1367,7 +1814,16 @@ @Override public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.serverLevel()); @@ -774,7 +765,7 @@ if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) { this.player.stopUsingItem(); } -@@ -1300,11 +1765,18 @@ +@@ -1376,11 +1832,18 @@ this.player.resetLastActionTime(); } else { PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString()); @@ -793,7 +784,7 @@ Optional optional = this.unpackAndApplyLastSeen(packetplayinchat.lastSeenMessages()); if (!optional.isEmpty()) { -@@ -1318,7 +1790,7 @@ +@@ -1394,7 +1857,7 @@ return; } @@ -802,7 +793,7 @@ IChatBaseComponent ichatbasecomponent = this.server.getChatDecorator().decorate(this.player, playerchatmessage.decoratedContent()); this.chatMessageChain.append(completablefuture, (filteredtext) -> { -@@ -1326,19 +1798,36 @@ +@@ -1402,19 +1865,36 @@ this.broadcastChatMessage(playerchatmessage1); }); @@ -841,7 +832,7 @@ ParseResults parseresults = this.parseCommand(s); if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) { -@@ -1355,19 +1844,37 @@ +@@ -1431,19 +1911,37 @@ if (!optional.isEmpty()) { this.tryHandleChat(serverboundchatcommandsignedpacket.command(), () -> { @@ -882,7 +873,7 @@ } catch (SignedMessageChain.a signedmessagechain_a) { this.handleMessageDecodeFailure(signedmessagechain_a); return; -@@ -1375,10 +1882,10 @@ +@@ -1451,10 +1949,10 @@ CommandSigningContext.a commandsigningcontext_a = new CommandSigningContext.a(map); @@ -895,7 +886,7 @@ } private void handleMessageDecodeFailure(SignedMessageChain.a signedmessagechain_a) { -@@ -1454,14 +1961,20 @@ +@@ -1530,14 +2028,20 @@ return com_mojang_brigadier_commanddispatcher.parse(s, this.player.createCommandSourceStack()); } @@ -919,7 +910,7 @@ } } -@@ -1490,6 +2003,116 @@ +@@ -1566,6 +2070,116 @@ return false; } @@ -1036,7 +1027,7 @@ private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a { SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages); -@@ -1497,13 +2120,33 @@ +@@ -1573,13 +2187,33 @@ } private void broadcastChatMessage(PlayerChatMessage playerchatmessage) { @@ -1073,7 +1064,7 @@ this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("disconnect.spam")); } -@@ -1525,13 +2168,62 @@ +@@ -1601,7 +2235,33 @@ @Override public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.serverLevel()); @@ -1107,36 +1098,37 @@ this.player.swing(packetplayinarmanimation.getHand()); } - @Override +@@ -1609,6 +2269,29 @@ public void handlePlayerCommand(PacketPlayInEntityAction packetplayinentityaction) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinentityaction, this, this.player.serverLevel()); -+ // CraftBukkit start -+ if (this.player.isRemoved()) return; -+ switch (packetplayinentityaction.getAction()) { -+ case PRESS_SHIFT_KEY: -+ case RELEASE_SHIFT_KEY: -+ PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getCraftPlayer(), packetplayinentityaction.getAction() == PacketPlayInEntityAction.EnumPlayerAction.PRESS_SHIFT_KEY); -+ this.cserver.getPluginManager().callEvent(event); + if (this.player.hasClientLoaded()) { ++ // CraftBukkit start ++ if (this.player.isRemoved()) return; ++ switch (packetplayinentityaction.getAction()) { ++ case PRESS_SHIFT_KEY: ++ case RELEASE_SHIFT_KEY: ++ PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getCraftPlayer(), packetplayinentityaction.getAction() == PacketPlayInEntityAction.EnumPlayerAction.PRESS_SHIFT_KEY); ++ this.cserver.getPluginManager().callEvent(event); + -+ if (event.isCancelled()) { -+ return; -+ } -+ break; -+ case START_SPRINTING: -+ case STOP_SPRINTING: -+ PlayerToggleSprintEvent e2 = new PlayerToggleSprintEvent(this.getCraftPlayer(), packetplayinentityaction.getAction() == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING); -+ this.cserver.getPluginManager().callEvent(e2); ++ if (event.isCancelled()) { ++ return; ++ } ++ break; ++ case START_SPRINTING: ++ case STOP_SPRINTING: ++ PlayerToggleSprintEvent e2 = new PlayerToggleSprintEvent(this.getCraftPlayer(), packetplayinentityaction.getAction() == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING); ++ this.cserver.getPluginManager().callEvent(e2); + -+ if (e2.isCancelled()) { -+ return; -+ } -+ break; -+ } -+ // CraftBukkit end - this.player.resetLastActionTime(); - Entity entity; - -@@ -1608,6 +2300,12 @@ ++ if (e2.isCancelled()) { ++ return; ++ } ++ break; ++ } ++ // CraftBukkit end + this.player.resetLastActionTime(); + Entity entity; + IJumpable ijumpable; +@@ -1691,6 +2374,12 @@ } public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) { @@ -1149,104 +1141,104 @@ this.send(new ClientboundPlayerChatPacket(playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a)); this.addPendingMessage(playerchatmessage); } -@@ -1635,6 +2333,7 @@ +@@ -1718,6 +2407,7 @@ @Override public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.serverLevel()); + if (this.player.isImmobile()) return; // CraftBukkit - final WorldServer worldserver = this.player.serverLevel(); - final Entity entity = packetplayinuseentity.getTarget(worldserver); + if (this.player.hasClientLoaded()) { + final WorldServer worldserver = this.player.serverLevel(); + final Entity entity = packetplayinuseentity.getTarget(worldserver); +@@ -1733,13 +2423,51 @@ -@@ -1649,13 +2348,51 @@ + if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) { + packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() { +- private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a) { ++ private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit + ItemStack itemstack = PlayerConnection.this.player.getItemInHand(enumhand); - if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) { - packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() { -- private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a) { -+ private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit - ItemStack itemstack = PlayerConnection.this.player.getItemInHand(enumhand); - - if (itemstack.isItemEnabled(worldserver.enabledFeatures())) { - ItemStack itemstack1 = itemstack.copy(); -+ // CraftBukkit start -+ ItemStack itemInHand = PlayerConnection.this.player.getItemInHand(enumhand); -+ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient; -+ Item origItem = player.getInventory().getSelected() == null ? null : player.getInventory().getSelected().getItem(); + if (itemstack.isItemEnabled(worldserver.enabledFeatures())) { + ItemStack itemstack1 = itemstack.copy(); ++ // CraftBukkit start ++ ItemStack itemInHand = PlayerConnection.this.player.getItemInHand(enumhand); ++ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient; ++ Item origItem = player.getInventory().getSelected() == null ? null : player.getInventory().getSelected().getItem(); + -+ cserver.getPluginManager().callEvent(event); ++ cserver.getPluginManager().callEvent(event); + -+ // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a -+ if ((entity instanceof Bucketable && entity instanceof EntityLiving && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) { -+ entity.getBukkitEntity().update(player); -+ player.containerMenu.sendAllDataToRemote(); -+ } -+ -+ if (triggerLeashUpdate && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) { -+ // Refresh the current leash state -+ send(new PacketPlayOutAttachEntity(entity, ((EntityInsentient) entity).getLeashHolder())); -+ } -+ -+ if (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem) { -+ // Refresh the current entity metadata -+ entity.refreshEntityData(player); -+ // SPIGOT-7136 - Allays -+ if (entity instanceof Allay) { -+ send(new PacketPlayOutEntityEquipment(entity.getId(), Arrays.stream(EnumItemSlot.values()).map((slot) -> Pair.of(slot, ((EntityLiving) entity).getItemBySlot(slot).copy())).collect(Collectors.toList()))); ++ // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a ++ if ((entity instanceof Bucketable && entity instanceof EntityLiving && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) { ++ entity.getBukkitEntity().update(player); + player.containerMenu.sendAllDataToRemote(); + } -+ } + -+ if (event.isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - EnumInteractionResult enuminteractionresult = playerconnection_a.run(PlayerConnection.this.player, entity, enumhand); - -+ // CraftBukkit start -+ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { -+ player.containerMenu.sendAllDataToRemote(); -+ } -+ // CraftBukkit end ++ if (triggerLeashUpdate && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) { ++ // Refresh the current leash state ++ send(new PacketPlayOutAttachEntity(entity, ((EntityInsentient) entity).getLeashHolder())); ++ } + - if (enuminteractionresult instanceof EnumInteractionResult.d) { - EnumInteractionResult.d enuminteractionresult_d = (EnumInteractionResult.d) enuminteractionresult; - ItemStack itemstack2 = enuminteractionresult_d.wasItemInteraction() ? itemstack1 : ItemStack.EMPTY; -@@ -1671,19 +2408,20 @@ ++ if (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem) { ++ // Refresh the current entity metadata ++ entity.refreshEntityData(player); ++ // SPIGOT-7136 - Allays ++ if (entity instanceof Allay) { ++ send(new PacketPlayOutEntityEquipment(entity.getId(), Arrays.stream(EnumItemSlot.values()).map((slot) -> Pair.of(slot, ((EntityLiving) entity).getItemBySlot(slot).copy())).collect(Collectors.toList()))); ++ player.containerMenu.sendAllDataToRemote(); ++ } ++ } ++ ++ if (event.isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + EnumInteractionResult enuminteractionresult = playerconnection_a.run(PlayerConnection.this.player, entity, enumhand); - @Override - public void onInteraction(EnumHand enumhand) { -- this.performInteraction(enumhand, EntityHuman::interactOn); -+ this.performInteraction(enumhand, EntityHuman::interactOn, new PlayerInteractEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), (enumhand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); // CraftBukkit - } - - @Override - public void onInteraction(EnumHand enumhand, Vec3D vec3d) { - this.performInteraction(enumhand, (entityplayer, entity1, enumhand1) -> { - return entity1.interactAt(entityplayer, vec3d, enumhand1); -- }); -+ }, new PlayerInteractAtEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), new org.bukkit.util.Vector(vec3d.x, vec3d.y, vec3d.z), (enumhand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); // CraftBukkit - } - - @Override - public void onAttack() { -- if (!(entity instanceof EntityItem) && !(entity instanceof EntityExperienceOrb) && entity != PlayerConnection.this.player) { -+ // CraftBukkit -+ if (!(entity instanceof EntityItem) && !(entity instanceof EntityExperienceOrb) && (entity != PlayerConnection.this.player || player.isSpectator())) { - label23: - { - if (entity instanceof EntityArrow) { -@@ -1701,6 +2439,11 @@ - } - - PlayerConnection.this.player.attack(entity); + // CraftBukkit start -+ if (!itemstack.isEmpty() && itemstack.getCount() <= -1) { ++ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { + player.containerMenu.sendAllDataToRemote(); + } + // CraftBukkit end - return; - } ++ + if (enuminteractionresult instanceof EnumInteractionResult.d) { + EnumInteractionResult.d enuminteractionresult_d = (EnumInteractionResult.d) enuminteractionresult; + ItemStack itemstack2 = enuminteractionresult_d.wasItemInteraction() ? itemstack1 : ItemStack.EMPTY; +@@ -1755,19 +2483,20 @@ + + @Override + public void onInteraction(EnumHand enumhand) { +- this.performInteraction(enumhand, EntityHuman::interactOn); ++ this.performInteraction(enumhand, EntityHuman::interactOn, new PlayerInteractEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), (enumhand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); // CraftBukkit } -@@ -1724,7 +2467,7 @@ + + @Override + public void onInteraction(EnumHand enumhand, Vec3D vec3d) { + this.performInteraction(enumhand, (entityplayer, entity1, enumhand1) -> { + return entity1.interactAt(entityplayer, vec3d, enumhand1); +- }); ++ }, new PlayerInteractAtEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), new org.bukkit.util.Vector(vec3d.x, vec3d.y, vec3d.z), (enumhand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); // CraftBukkit + } + + @Override + public void onAttack() { +- if (!(entity instanceof EntityItem) && !(entity instanceof EntityExperienceOrb) && entity != PlayerConnection.this.player) { ++ // CraftBukkit ++ if (!(entity instanceof EntityItem) && !(entity instanceof EntityExperienceOrb) && (entity != PlayerConnection.this.player || player.isSpectator())) { + label23: + { + if (entity instanceof EntityArrow) { +@@ -1785,6 +2514,11 @@ + } + + PlayerConnection.this.player.attack(entity); ++ // CraftBukkit start ++ if (!itemstack.isEmpty() && itemstack.getCount() <= -1) { ++ player.containerMenu.sendAllDataToRemote(); ++ } ++ // CraftBukkit end + return; + } + } +@@ -1809,7 +2543,7 @@ case PERFORM_RESPAWN: if (this.player.wonGame) { this.player.wonGame = false; @@ -1255,7 +1247,7 @@ this.resetPosition(); CriterionTriggers.CHANGED_DIMENSION.trigger(this.player, World.END, World.OVERWORLD); } else { -@@ -1732,11 +2475,11 @@ +@@ -1817,11 +2551,11 @@ return; } @@ -1269,7 +1261,7 @@ } } break; -@@ -1749,15 +2492,21 @@ +@@ -1834,15 +2568,21 @@ @Override public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.serverLevel()); @@ -1293,7 +1285,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); -@@ -1770,7 +2519,284 @@ +@@ -1855,7 +2595,284 @@ boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); @@ -1579,7 +1571,7 @@ ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator(); while (objectiterator.hasNext()) { -@@ -1816,7 +2842,21 @@ +@@ -1901,7 +2918,21 @@ return; } @@ -1602,7 +1594,7 @@ if (containerrecipebook_a == ContainerRecipeBook.a.PLACE_GHOST_RECIPE) { this.player.connection.send(new PacketPlayOutAutoRecipe(this.player.containerMenu.containerId, craftingmanager_d.display().display())); -@@ -1832,6 +2872,7 @@ +@@ -1917,6 +2948,7 @@ @Override public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.serverLevel()); @@ -1610,7 +1602,7 @@ this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packetplayinenchantitem.containerId() && !this.player.isSpectator()) { if (!this.player.containerMenu.stillValid(this.player)) { -@@ -1875,6 +2916,43 @@ +@@ -1945,6 +2977,43 @@ boolean flag1 = packetplayinsetcreativeslot.slotNum() >= 1 && packetplayinsetcreativeslot.slotNum() <= 45; boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize(); @@ -1654,7 +1646,7 @@ if (flag1 && flag2) { this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.slotNum()).setByPlayer(itemstack); -@@ -1902,6 +2980,7 @@ +@@ -1972,6 +3041,7 @@ } private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List list) { @@ -1662,7 +1654,7 @@ this.player.resetLastActionTime(); WorldServer worldserver = this.player.serverLevel(); BlockPosition blockposition = packetplayinupdatesign.getPos(); -@@ -1923,7 +3002,17 @@ +@@ -1993,7 +3063,17 @@ @Override public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.serverLevel()); @@ -1681,7 +1673,7 @@ } @Override -@@ -1982,7 +3071,7 @@ +@@ -2058,7 +3138,7 @@ if (!this.waitingForSwitchToConfig) { throw new IllegalStateException("Client acknowledged config, but none was requested"); } else { @@ -1690,7 +1682,7 @@ } } -@@ -2007,8 +3096,10 @@ +@@ -2083,8 +3163,10 @@ }); } diff --git a/paper-server/nms-patches/net/minecraft/util/SpawnUtil.patch b/paper-server/nms-patches/net/minecraft/util/SpawnUtil.patch index 47da6b1143..7e75aa0c21 100644 --- a/paper-server/nms-patches/net/minecraft/util/SpawnUtil.patch +++ b/paper-server/nms-patches/net/minecraft/util/SpawnUtil.patch @@ -3,20 +3,20 @@ @@ -21,6 +21,12 @@ public SpawnUtil() {} - public static Optional trySpawnMob(EntityTypes entitytypes, EntitySpawnReason entityspawnreason, WorldServer worldserver, BlockPosition blockposition, int i, int j, int k, SpawnUtil.a spawnutil_a) { + public static Optional trySpawnMob(EntityTypes entitytypes, EntitySpawnReason entityspawnreason, WorldServer worldserver, BlockPosition blockposition, int i, int j, int k, SpawnUtil.a spawnutil_a, boolean flag) { + // CraftBukkit start -+ return trySpawnMob(entitytypes, entityspawnreason, worldserver, blockposition, i, j, k, spawnutil_a, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); ++ return trySpawnMob(entitytypes, entityspawnreason, worldserver, blockposition, i, j, k, spawnutil_a, flag, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } + -+ public static Optional trySpawnMob(EntityTypes entitytypes, EntitySpawnReason entityspawnreason, WorldServer worldserver, BlockPosition blockposition, int i, int j, int k, SpawnUtil.a spawnutil_a, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ public static Optional trySpawnMob(EntityTypes entitytypes, EntitySpawnReason entityspawnreason, WorldServer worldserver, BlockPosition blockposition, int i, int j, int k, SpawnUtil.a spawnutil_a, boolean flag, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + // CraftBukkit end BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable(); for (int l = 0; l < i; ++l) { -@@ -29,15 +35,15 @@ +@@ -29,16 +35,17 @@ blockposition_mutableblockposition.setWithOffset(blockposition, i1, k, j1); - if (worldserver.getWorldBorder().isWithinBounds((BlockPosition) blockposition_mutableblockposition) && moveToPossibleSpawnPosition(worldserver, k, blockposition_mutableblockposition, spawnutil_a)) { + if (worldserver.getWorldBorder().isWithinBounds((BlockPosition) blockposition_mutableblockposition) && moveToPossibleSpawnPosition(worldserver, k, blockposition_mutableblockposition, spawnutil_a) && (!flag || worldserver.noCollision(entitytypes.getSpawnAABB((double) blockposition_mutableblockposition.getX() + 0.5D, (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + 0.5D)))) { - T t0 = (EntityInsentient) entitytypes.create(worldserver, (Consumer) null, blockposition_mutableblockposition, entityspawnreason, false, false); + T t0 = entitytypes.create(worldserver, (Consumer) null, blockposition_mutableblockposition, entityspawnreason, false, false); // CraftBukkit - decompile error @@ -24,6 +24,8 @@ if (t0.checkSpawnRules(worldserver, entityspawnreason) && t0.checkSpawnObstruction(worldserver)) { - worldserver.addFreshEntityWithPassengers(t0); + worldserver.addFreshEntityWithPassengers(t0, reason); // CraftBukkit ++ if (t0.isRemoved()) return Optional.empty(); // CraftBukkit + t0.playAmbientSound(); return Optional.of(t0); } 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 f5fa33fc6b..f801d05570 100644 --- a/paper-server/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch +++ b/paper-server/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/datafix/DataConverterRegistry.java +++ b/net/minecraft/util/datafix/DataConverterRegistry.java -@@ -511,6 +511,18 @@ +@@ -517,6 +517,18 @@ datafixerbuilder.addFixer(new DataConverterItemFrame(schema44, false)); Schema schema45 = datafixerbuilder.addSchema(1458, DataConverterRegistry.SAME_NAMESPACED); @@ -19,7 +19,7 @@ datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema45, false)); datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema45, false)); datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema45, false)); -@@ -769,7 +781,8 @@ +@@ -775,7 +787,8 @@ datafixerbuilder.addFixer(new DataConverterAddChoices(schema110, "Added Zoglin", DataConverterTypes.ENTITY)); Schema schema111 = datafixerbuilder.addSchema(2523, DataConverterRegistry.SAME_NAMESPACED); @@ -29,7 +29,7 @@ Schema schema112 = datafixerbuilder.addSchema(2527, DataConverterRegistry.SAME_NAMESPACED); datafixerbuilder.addFixer(new DataConverterBitStorageAlign(schema112)); -@@ -832,12 +845,14 @@ +@@ -838,12 +851,14 @@ datafixerbuilder.addFixer(new DataConverterAddChoices(schema130, "Added Glow Squid", DataConverterTypes.ENTITY)); datafixerbuilder.addFixer(new DataConverterAddChoices(schema130, "Added Glow Item Frame", DataConverterTypes.ENTITY)); Schema schema131 = datafixerbuilder.addSchema(2690, DataConverterRegistry.SAME_NAMESPACED); @@ -46,7 +46,7 @@ datafixerbuilder.addFixer(DataConverterItemName.create(schema132, "Rename copper item suffixes", createRenamer(immutablemap1))); datafixerbuilder.addFixer(DataConverterBlockRename.create(schema132, "Rename copper blocks suffixes", createRenamer(immutablemap1))); -@@ -845,7 +860,8 @@ +@@ -851,7 +866,8 @@ datafixerbuilder.addFixer(new AddFlagIfNotPresentFix(schema133, DataConverterTypes.WORLD_GEN_SETTINGS, "has_increased_height_already", false)); Schema schema134 = datafixerbuilder.addSchema(2696, DataConverterRegistry.SAME_NAMESPACED); @@ -56,7 +56,7 @@ datafixerbuilder.addFixer(DataConverterItemName.create(schema134, "Renamed grimstone block items to deepslate", createRenamer(immutablemap2))); datafixerbuilder.addFixer(DataConverterBlockRename.create(schema134, "Renamed grimstone blocks to deepslate", createRenamer(immutablemap2))); -@@ -932,10 +948,11 @@ +@@ -938,10 +954,11 @@ datafixerbuilder.addFixer(new DataConverterAddChoices(schema159, "Added Allay", DataConverterTypes.ENTITY)); Schema schema160 = datafixerbuilder.addSchema(3084, DataConverterRegistry.SAME_NAMESPACED); @@ -70,7 +70,7 @@ int2objectopenhashmap1.defaultReturnValue("minecraft:tabby"); int2objectopenhashmap1.put(0, "minecraft:tabby"); int2objectopenhashmap1.put(1, "minecraft:black"); -@@ -952,7 +969,8 @@ +@@ -958,7 +975,8 @@ Objects.requireNonNull(int2objectopenhashmap); datafixerbuilder.addFixer(new EntityVariantFix(schema161, "Change cat variant type", typereference, "minecraft:cat", "CatType", int2objectopenhashmap::get)); diff --git a/paper-server/nms-patches/net/minecraft/world/effect/PoisonMobEffect.patch b/paper-server/nms-patches/net/minecraft/world/effect/PoisonMobEffect.patch index 14617da0f4..0b9b1aa748 100644 --- a/paper-server/nms-patches/net/minecraft/world/effect/PoisonMobEffect.patch +++ b/paper-server/nms-patches/net/minecraft/world/effect/PoisonMobEffect.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/PoisonMobEffect.java +++ b/net/minecraft/world/effect/PoisonMobEffect.java -@@ -12,7 +12,7 @@ +@@ -14,7 +14,7 @@ @Override public boolean applyEffectTick(WorldServer worldserver, EntityLiving entityliving, int i) { if (entityliving.getHealth() > 1.0F) { 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 317981d911..4a5f08dd3f 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch @@ -200,7 +200,7 @@ this.setYRot(f % 360.0F); this.setXRot(f1 % 360.0F); } -@@ -458,6 +597,15 @@ +@@ -462,6 +601,15 @@ this.baseTick(); } @@ -216,7 +216,7 @@ public void baseTick() { GameProfilerFiller gameprofilerfiller = Profiler.get(); -@@ -471,7 +619,7 @@ +@@ -475,7 +623,7 @@ --this.boardingCooldown; } @@ -225,7 +225,7 @@ if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -510,6 +658,10 @@ +@@ -514,6 +662,10 @@ if (this.isInLava()) { this.lavaHurt(); this.fallDistance *= 0.5F; @@ -236,7 +236,7 @@ } this.checkBelowWorld(); -@@ -521,7 +673,7 @@ +@@ -525,7 +677,7 @@ world = this.level(); if (world instanceof WorldServer worldserver) { if (this instanceof Leashable) { @@ -245,7 +245,7 @@ } } -@@ -564,15 +716,32 @@ +@@ -568,15 +720,32 @@ public void lavaHurt() { if (!this.fireImmune()) { @@ -280,7 +280,7 @@ } } -@@ -583,6 +752,22 @@ +@@ -587,6 +756,22 @@ } public final void igniteForSeconds(float f) { @@ -303,7 +303,7 @@ this.igniteForTicks(MathHelper.floor(f * 20.0F)); } -@@ -606,7 +791,7 @@ +@@ -610,7 +795,7 @@ } protected void onBelowWorld() { @@ -312,7 +312,7 @@ } public boolean isFree(double d0, double d1, double d2) { -@@ -739,6 +924,28 @@ +@@ -750,6 +935,28 @@ } } @@ -341,7 +341,7 @@ if (!this.level().isClientSide() || this.isControlledByLocalInstance()) { Entity.MovementEmission entity_movementemission = this.getMovementEmission(); -@@ -1120,6 +1327,20 @@ +@@ -1133,6 +1340,20 @@ return SoundEffects.GENERIC_SPLASH; } @@ -362,7 +362,7 @@ public void recordMovementThroughBlocks(Vec3D vec3d, Vec3D vec3d1) { this.movementThisTick.add(new Entity.b(vec3d, vec3d1)); } -@@ -1586,6 +1807,7 @@ +@@ -1609,6 +1830,7 @@ this.yo = d1; this.zo = d4; this.setPos(d3, d1, d4); @@ -370,7 +370,7 @@ } public void moveTo(Vec3D vec3d) { -@@ -1838,6 +2060,12 @@ +@@ -1861,6 +2083,12 @@ return false; } @@ -380,10 +380,10 @@ + } + // CraftBukkit end + - public void awardKillScore(Entity entity, int i, DamageSource damagesource) { + public void awardKillScore(Entity entity, DamageSource damagesource) { if (entity instanceof EntityPlayer) { CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource); -@@ -1866,16 +2094,22 @@ +@@ -1889,16 +2117,22 @@ } public boolean saveAsPassenger(NBTTagCompound nbttagcompound) { @@ -408,7 +408,7 @@ return true; } } -@@ -1886,16 +2120,38 @@ +@@ -1909,16 +2143,38 @@ } public NBTTagCompound saveWithoutId(NBTTagCompound nbttagcompound) { @@ -451,7 +451,7 @@ nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot())); nbttagcompound.putFloat("FallDistance", this.fallDistance); nbttagcompound.putShort("Fire", (short) this.remainingFireTicks); -@@ -1903,7 +2159,28 @@ +@@ -1926,7 +2182,28 @@ nbttagcompound.putBoolean("OnGround", this.onGround()); nbttagcompound.putBoolean("Invulnerable", this.invulnerable); nbttagcompound.putInt("PortalCooldown", this.portalCooldown); @@ -481,7 +481,7 @@ IChatBaseComponent ichatbasecomponent = this.getCustomName(); if (ichatbasecomponent != null) { -@@ -1952,7 +2229,7 @@ +@@ -1975,7 +2252,7 @@ nbttagcompound.put("Tags", nbttaglist); } @@ -490,7 +490,7 @@ if (this.isVehicle()) { nbttaglist = new NBTTagList(); iterator = this.getPassengers().iterator(); -@@ -1961,7 +2238,7 @@ +@@ -1984,7 +2261,7 @@ Entity entity = (Entity) iterator.next(); NBTTagCompound nbttagcompound1 = new NBTTagCompound(); @@ -499,7 +499,7 @@ nbttaglist.add(nbttagcompound1); } } -@@ -1971,6 +2248,11 @@ +@@ -1994,6 +2271,11 @@ } } @@ -511,7 +511,7 @@ return nbttagcompound; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); -@@ -2055,6 +2337,45 @@ +@@ -2080,6 +2362,45 @@ } else { throw new IllegalStateException("Entity has invalid position"); } @@ -557,7 +557,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded"); -@@ -2076,6 +2397,12 @@ +@@ -2101,6 +2422,12 @@ return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null; } @@ -570,7 +570,7 @@ protected abstract void readAdditionalSaveData(NBTTagCompound nbttagcompound); protected abstract void addAdditionalSaveData(NBTTagCompound nbttagcompound); -@@ -2128,9 +2455,22 @@ +@@ -2153,9 +2480,22 @@ if (itemstack.isEmpty()) { return null; } else { @@ -593,7 +593,7 @@ worldserver.addFreshEntity(entityitem); return entityitem; } -@@ -2159,6 +2499,12 @@ +@@ -2184,6 +2524,12 @@ if (this.isAlive() && this instanceof Leashable leashable) { if (leashable.getLeashHolder() == entityhuman) { if (!this.level().isClientSide()) { @@ -603,10 +603,10 @@ + return EnumInteractionResult.PASS; + } + // CraftBukkit end - leashable.dropLeash(true, !entityhuman.hasInfiniteMaterials()); - this.gameEvent(GameEvent.ENTITY_INTERACT, entityhuman); - } -@@ -2170,6 +2516,13 @@ + if (entityhuman.hasInfiniteMaterials()) { + leashable.removeLeash(); + } else { +@@ -2200,6 +2546,13 @@ if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) { if (!this.level().isClientSide()) { @@ -620,7 +620,7 @@ leashable.setLeashedTo(entityhuman, true); } -@@ -2243,7 +2596,7 @@ +@@ -2273,7 +2626,7 @@ return false; } else if (!entity.couldAcceptPassenger()) { return false; @@ -629,7 +629,7 @@ return false; } else { for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) { -@@ -2255,6 +2608,27 @@ +@@ -2285,6 +2638,27 @@ if (!flag && (!this.canRide(entity) || !entity.canAddPassenger(this))) { return false; } else { @@ -657,7 +657,7 @@ if (this.isPassenger()) { this.stopRiding(); } -@@ -2288,7 +2662,7 @@ +@@ -2318,7 +2692,7 @@ Entity entity = this.vehicle; this.vehicle = null; @@ -666,7 +666,7 @@ } } -@@ -2319,10 +2693,38 @@ +@@ -2349,10 +2723,38 @@ } } @@ -706,7 +706,7 @@ if (this.passengers.size() == 1 && this.passengers.get(0) == entity) { this.passengers = ImmutableList.of(); } else { -@@ -2334,6 +2736,7 @@ +@@ -2364,6 +2766,7 @@ entity.boardingCooldown = 60; this.gameEvent(GameEvent.ENTITY_DISMOUNT, entity); } @@ -714,7 +714,7 @@ } protected boolean canAddPassenger(Entity entity) { -@@ -2434,7 +2837,7 @@ +@@ -2464,7 +2867,7 @@ if (teleporttransition != null) { WorldServer worldserver1 = teleporttransition.newLevel(); @@ -723,7 +723,7 @@ this.teleport(teleporttransition); } } -@@ -2541,6 +2944,13 @@ +@@ -2571,6 +2974,13 @@ } public void setSwimming(boolean flag) { @@ -737,7 +737,7 @@ this.setSharedFlag(4, flag); } -@@ -2594,8 +3004,12 @@ +@@ -2624,8 +3034,12 @@ return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false; } @@ -751,7 +751,7 @@ } public boolean getSharedFlag(int i) { -@@ -2614,7 +3028,7 @@ +@@ -2644,7 +3058,7 @@ } public int getMaxAirSupply() { @@ -760,7 +760,7 @@ } public int getAirSupply() { -@@ -2622,7 +3036,18 @@ +@@ -2652,7 +3066,18 @@ } public void setAirSupply(int i) { @@ -780,7 +780,7 @@ } public int getTicksFrozen() { -@@ -2649,11 +3074,40 @@ +@@ -2679,11 +3104,40 @@ public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -823,7 +823,7 @@ } public void onAboveBubbleCol(boolean flag) { -@@ -2822,6 +3276,18 @@ +@@ -2852,6 +3306,18 @@ if (world instanceof WorldServer worldserver) { if (!this.isRemoved()) { @@ -842,7 +842,7 @@ WorldServer worldserver1 = teleporttransition.newLevel(); boolean flag = worldserver1.dimension() != worldserver.dimension(); -@@ -2890,8 +3356,12 @@ +@@ -2920,8 +3386,12 @@ } else { entity.restoreFrom(this); this.removeAfterChangingDimensions(); @@ -856,7 +856,7 @@ Iterator iterator1 = list1.iterator(); while (iterator1.hasNext()) { -@@ -2965,8 +3435,9 @@ +@@ -2995,8 +3465,9 @@ } protected void removeAfterChangingDimensions() { @@ -864,10 +864,10 @@ + this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION, null); // CraftBukkit - add Bukkit remove cause if (this instanceof Leashable leashable) { + this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit - leashable.dropLeash(true, false); + leashable.removeLeash(); } -@@ -2976,6 +3447,20 @@ +@@ -3006,6 +3477,20 @@ return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose())); } @@ -888,7 +888,7 @@ public boolean canUsePortal(boolean flag) { return (flag || !this.isPassenger()) && this.isAlive(); } -@@ -3104,9 +3589,15 @@ +@@ -3134,9 +3619,15 @@ return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE); } @@ -906,7 +906,7 @@ return entity != null; } -@@ -3228,7 +3719,26 @@ +@@ -3258,7 +3749,26 @@ } public final void setBoundingBox(AxisAlignedBB axisalignedbb) { @@ -934,7 +934,7 @@ } public final float getEyeHeight(EntityPose entitypose) { -@@ -3463,8 +3973,37 @@ +@@ -3489,8 +3999,37 @@ return 1; } @@ -973,7 +973,7 @@ } public void lookAt(ArgumentAnchor.Anchor argumentanchor_anchor, Vec3D vec3d) { -@@ -3525,6 +4064,11 @@ +@@ -3551,6 +4090,11 @@ vec3d = vec3d.add(vec3d1); ++k1; } @@ -985,7 +985,7 @@ } } } -@@ -3792,6 +4336,14 @@ +@@ -3818,6 +4362,14 @@ @Override public final void setRemoved(Entity.RemovalReason entity_removalreason) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch index 48c47f28a6..c41a98ad22 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch @@ -47,7 +47,7 @@ Vec3D vec3d = new Vec3D(this.followingPlayer.getX() - this.getX(), this.followingPlayer.getY() + (double) this.followingPlayer.getEyeHeight() / 2.0D - this.getY(), this.followingPlayer.getZ() - this.getZ()); double d0 = vec3d.lengthSqr(); -@@ -119,7 +143,7 @@ +@@ -121,7 +145,7 @@ ++this.age; if (this.age >= 6000) { @@ -56,7 +56,7 @@ } } -@@ -188,7 +212,7 @@ +@@ -190,7 +214,7 @@ private void merge(EntityExperienceOrb entityexperienceorb) { this.count += entityexperienceorb.count; this.age = Math.min(this.age, entityexperienceorb.age); @@ -65,7 +65,7 @@ } private void setUnderwaterMovement() { -@@ -213,7 +237,7 @@ +@@ -215,7 +239,7 @@ this.markHurt(); this.health = (int) ((float) this.health - f); if (this.health <= 0) { @@ -74,7 +74,7 @@ } return true; -@@ -240,17 +264,17 @@ +@@ -242,17 +266,17 @@ public void playerTouch(EntityHuman entityhuman) { if (entityhuman instanceof EntityPlayer entityplayer) { if (entityhuman.takeXpDelay == 0) { @@ -95,7 +95,7 @@ } } -@@ -264,12 +288,20 @@ +@@ -266,12 +290,20 @@ ItemStack itemstack = ((EnchantedItemInUse) optional.get()).itemStack(); int j = EnchantmentManager.modifyDurabilityToRepairFromXp(entityplayer.serverLevel(), itemstack, i); int k = Math.min(j, itemstack.getDamageValue()); @@ -116,7 +116,7 @@ return this.repairPlayerItems(entityplayer, l); } } -@@ -289,6 +321,24 @@ +@@ -291,6 +323,24 @@ } public static int getExperienceValue(int i) { 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 a27e32292a..08c814221f 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityInsentient.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityInsentient.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityInsentient.java +++ b/net/minecraft/world/entity/EntityInsentient.java -@@ -89,6 +89,18 @@ +@@ -85,6 +85,18 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParameters; import net.minecraft.world.phys.AxisAlignedBB; @@ -19,7 +19,7 @@ public abstract class EntityInsentient extends EntityLiving implements EquipmentUser, Leashable, Targeting { private static final DataWatcherObject DATA_MOB_FLAGS_ID = DataWatcher.defineId(EntityInsentient.class, DataWatcherRegistry.BYTE); -@@ -136,6 +148,8 @@ +@@ -132,6 +144,8 @@ private BlockPosition restrictCenter; private float restrictRadius; @@ -28,7 +28,7 @@ protected EntityInsentient(EntityTypes entitytypes, World world) { super(entitytypes, world); this.handItems = NonNullList.withSize(2, ItemStack.EMPTY); -@@ -164,6 +178,12 @@ +@@ -160,6 +174,12 @@ } @@ -41,7 +41,7 @@ protected void registerGoals() {} public static AttributeProvider.Builder createMobAttributes() { -@@ -268,11 +288,42 @@ +@@ -264,11 +284,42 @@ @Nullable protected final EntityLiving getTargetFromBrain() { @@ -85,7 +85,7 @@ } @Override -@@ -403,6 +454,12 @@ +@@ -399,6 +450,12 @@ return null; } @@ -98,7 +98,7 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(nbttagcompound); -@@ -476,16 +533,26 @@ +@@ -473,13 +530,25 @@ nbttagcompound.putBoolean("NoAI", this.isNoAi()); } @@ -108,17 +108,16 @@ @Override public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { super.readAdditionalSaveData(nbttagcompound); -+ +- this.setCanPickUpLoot(nbttagcompound.getBoolean("CanPickUpLoot")); +- this.persistenceRequired = nbttagcompound.getBoolean("PersistenceRequired"); + // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it - if (nbttagcompound.contains("CanPickUpLoot", 99)) { -- this.setCanPickUpLoot(nbttagcompound.getBoolean("CanPickUpLoot")); ++ if (nbttagcompound.contains("CanPickUpLoot", 99)) { + boolean data = nbttagcompound.getBoolean("CanPickUpLoot"); + if (isLevelAtLeast(nbttagcompound, 1) || data) { + this.setCanPickUpLoot(data); + } - } - -- this.persistenceRequired = nbttagcompound.getBoolean("PersistenceRequired"); ++ } ++ + boolean data = nbttagcompound.getBoolean("PersistenceRequired"); + if (isLevelAtLeast(nbttagcompound, 1) || data) { + this.persistenceRequired = data; @@ -127,9 +126,9 @@ NBTTagList nbttaglist; NBTTagCompound nbttagcompound1; int i; -@@ -539,6 +606,11 @@ - } +@@ -547,6 +616,11 @@ + this.lootTableSeed = nbttagcompound.getLong("DeathLootTableSeed"); this.setNoAi(nbttagcompound.getBoolean("NoAI")); + // CraftBukkit start + if (nbttagcompound.contains("Bukkit.Aware")) { @@ -139,7 +138,7 @@ } @Override -@@ -615,20 +687,26 @@ +@@ -623,20 +697,26 @@ protected void pickUpItem(WorldServer worldserver, EntityItem entityitem) { ItemStack itemstack = entityitem.getItem(); @@ -168,7 +167,7 @@ EnumItemSlot enumitemslot = this.getEquipmentSlotForItem(itemstack); ItemStack itemstack1 = this.getItemBySlot(enumitemslot); boolean flag = this.canReplaceCurrentItem(itemstack, itemstack1, enumitemslot); -@@ -639,11 +717,19 @@ +@@ -647,11 +727,19 @@ flag = itemstack1.isEmpty(); } @@ -189,7 +188,7 @@ } ItemStack itemstack2 = enumitemslot.limit(itemstack); -@@ -770,7 +856,7 @@ +@@ -768,7 +856,7 @@ @Override public void checkDespawn() { if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.shouldDespawnInPeaceful()) { @@ -198,7 +197,7 @@ } else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) { EntityHuman entityhuman = this.level().getNearestPlayer(this, -1.0D); -@@ -780,14 +866,14 @@ +@@ -778,14 +866,14 @@ int j = i * i; if (d0 > (double) j && this.removeWhenFarAway(d0)) { @@ -215,7 +214,7 @@ } else if (d0 < (double) l) { this.noActionTime = 0; } -@@ -801,6 +887,7 @@ +@@ -799,6 +887,7 @@ @Override protected final void serverAiStep() { ++this.noActionTime; @@ -223,7 +222,7 @@ GameProfilerFiller gameprofilerfiller = Profiler.get(); gameprofilerfiller.push("sensing"); -@@ -1340,7 +1427,7 @@ +@@ -1338,7 +1427,7 @@ if (itemstack.getItem() instanceof ItemMonsterEgg) { if (this.level() instanceof WorldServer) { ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem(); @@ -232,7 +231,7 @@ optional.ifPresent((entityinsentient) -> { this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient); -@@ -1391,12 +1478,19 @@ +@@ -1389,12 +1478,19 @@ return this.restrictRadius != -1.0F; } @@ -253,7 +252,7 @@ if (t0 == null) { return null; -@@ -1405,14 +1499,24 @@ +@@ -1403,14 +1499,24 @@ conversionparams_a.finalizeConversion(t0); World world = this.level(); @@ -280,7 +279,7 @@ } return t0; -@@ -1422,7 +1526,14 @@ +@@ -1420,7 +1526,14 @@ @Nullable public T convertTo(EntityTypes entitytypes, ConversionParams conversionparams, ConversionParams.a conversionparams_a) { @@ -296,15 +295,15 @@ } @Nullable -@@ -1461,6 +1572,7 @@ +@@ -1458,6 +1571,7 @@ boolean flag1 = super.startRiding(entity, flag); if (flag1 && this.isLeashed()) { + this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit - this.dropLeash(true, true); + this.dropLeash(); } -@@ -1545,7 +1657,7 @@ +@@ -1542,7 +1656,7 @@ if (f1 > 0.0F && entity instanceof EntityLiving) { entityliving = (EntityLiving) entity; 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 26012563a6..55110c5acb 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 -@@ -137,6 +137,33 @@ +@@ -136,6 +136,33 @@ import net.minecraft.world.scores.ScoreboardTeam; import org.slf4j.Logger; @@ -34,7 +34,7 @@ public abstract class EntityLiving extends Entity implements Attackable { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -262,6 +289,19 @@ +@@ -260,6 +287,19 @@ protected boolean skipDropExperience; private final EnumMap>> activeLocationDependentEnchantments; protected float appliedScale; @@ -54,7 +54,7 @@ protected EntityLiving(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -278,7 +318,9 @@ +@@ -276,7 +316,9 @@ this.activeLocationDependentEnchantments = new EnumMap(EnumItemSlot.class); this.appliedScale = 1.0F; this.attributes = new AttributeMapBase(AttributeDefaults.getSupplier(entitytypes)); @@ -65,14 +65,14 @@ this.blocksBuilding = true; this.rotA = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); this.reapplyPosition(); -@@ -358,7 +400,13 @@ +@@ -356,7 +398,13 @@ double d8 = Math.min((double) (0.2F + f / 15.0F), 2.5D); int i = (int) (150.0D * d8); - worldserver.sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); + // CraftBukkit start - visiblity api + if (this instanceof EntityPlayer) { -+ worldserver.sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false); ++ worldserver.sendParticlesSource((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), false, false, d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); + } else { + worldserver.sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); + } @@ -498,7 +498,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; } -@@ -1275,7 +1519,7 @@ +@@ -1243,7 +1487,7 @@ worldserver.broadcastDamageEvent(this, damagesource); } @@ -507,7 +507,7 @@ this.markHurt(); } -@@ -1295,7 +1539,7 @@ +@@ -1263,7 +1507,7 @@ d1 = damagesource.getSourcePosition().z() - this.getZ(); } @@ -516,7 +516,7 @@ if (!flag) { this.indicateDamage(d0, d1); } -@@ -1314,7 +1558,7 @@ +@@ -1282,7 +1526,7 @@ this.playHurtSound(damagesource); } @@ -525,7 +525,7 @@ if (flag2) { this.lastDamageSource = damagesource; -@@ -1352,7 +1596,7 @@ +@@ -1363,7 +1607,7 @@ } protected void blockedByShield(EntityLiving entityliving) { @@ -534,7 +534,7 @@ } private boolean checkTotemDeathProtection(DamageSource damagesource) { -@@ -1364,20 +1608,33 @@ +@@ -1375,20 +1619,33 @@ EnumHand[] aenumhand = EnumHand.values(); int i = aenumhand.length; @@ -572,7 +572,7 @@ EntityPlayer entityplayer = (EntityPlayer) this; entityplayer.awardStat(StatisticList.ITEM_USED.get(itemstack.getItem())); -@@ -1501,14 +1758,22 @@ +@@ -1512,14 +1769,22 @@ IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState(); if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) { @@ -597,7 +597,7 @@ this.level().addFreshEntity(entityitem); } } -@@ -1519,22 +1784,37 @@ +@@ -1530,22 +1795,37 @@ protected void dropAllDeathLoot(WorldServer worldserver, DamageSource damagesource) { boolean flag = this.lastHurtByPlayerTime > 0; @@ -638,7 +638,7 @@ } protected void dropCustomDeathLoot(WorldServer worldserver, DamageSource damagesource, boolean flag) {} -@@ -1601,9 +1881,14 @@ +@@ -1612,9 +1892,14 @@ } public void knockback(double d0, double d1, double d2) { @@ -655,7 +655,7 @@ Vec3D vec3d; -@@ -1613,7 +1898,14 @@ +@@ -1624,7 +1909,14 @@ Vec3D vec3d1 = (new Vec3D(d1, 0.0D, d2)).normalize().scale(d0); @@ -671,7 +671,7 @@ } } -@@ -1668,6 +1960,20 @@ +@@ -1683,6 +1975,20 @@ return new EntityLiving.a(SoundEffects.GENERIC_SMALL_FALL, SoundEffects.GENERIC_BIG_FALL); } @@ -692,7 +692,7 @@ public Optional getLastClimbablePos() { return this.lastClimbablePos; } -@@ -1746,9 +2052,14 @@ +@@ -1757,9 +2063,14 @@ int i = this.calculateFallDamage(f, f1); if (i > 0) { @@ -708,7 +708,7 @@ return true; } else { return flag; -@@ -1819,7 +2130,7 @@ +@@ -1830,7 +2141,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) { if (!damagesource.is(DamageTypeTags.BYPASSES_ARMOR)) { @@ -717,7 +717,7 @@ f = CombatMath.getDamageAfterAbsorb(this, f, damagesource, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS)); } -@@ -1830,7 +2141,8 @@ +@@ -1841,7 +2152,8 @@ if (damagesource.is(DamageTypeTags.BYPASSES_EFFECTS)) { return f; } else { @@ -727,7 +727,7 @@ int i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f1 = f * (float) j; -@@ -1873,15 +2185,141 @@ +@@ -1884,15 +2196,141 @@ } } @@ -876,7 +876,7 @@ if (f2 > 0.0F && f2 < 3.4028235E37F) { Entity entity = damagesource.getEntity(); -@@ -1893,13 +2331,48 @@ +@@ -1904,13 +2342,48 @@ } } @@ -927,7 +927,7 @@ } public CombatTracker getCombatTracker() { -@@ -1924,9 +2397,19 @@ +@@ -1935,9 +2408,19 @@ } public final void setArrowCount(int i) { @@ -948,7 +948,7 @@ public final int getStingerCount() { return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID); } -@@ -2171,6 +2654,12 @@ +@@ -2182,6 +2665,12 @@ public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot); @@ -961,7 +961,7 @@ public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack); public Iterable getHandSlots() { -@@ -2623,7 +3112,7 @@ +@@ -2634,7 +3123,7 @@ } } @@ -970,7 +970,7 @@ if (this.tickCount % 20 == 0) { this.getCombatTracker().recheckStatus(); } -@@ -2730,7 +3219,7 @@ +@@ -2741,7 +3230,7 @@ this.elytraAnimationState.tick(); } @@ -979,7 +979,7 @@ Map map = this.collectEquipmentChanges(); if (map != null) { -@@ -3052,6 +3541,7 @@ +@@ -3063,6 +3552,7 @@ this.checkSlowFallDistance(); if (!this.level().isClientSide) { if (!this.canGlide()) { @@ -987,7 +987,7 @@ this.setSharedFlag(7, false); return; } -@@ -3298,14 +3788,21 @@ +@@ -3305,14 +3795,21 @@ @Override public boolean isPickable() { @@ -1011,7 +1011,7 @@ @Override public float getYHeadRot() { return this.yHeadRot; -@@ -3476,7 +3973,30 @@ +@@ -3483,7 +3980,30 @@ this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -1043,7 +1043,7 @@ if (itemstack != this.useItem) { this.setItemInHand(enumhand, itemstack); -@@ -3561,6 +4081,12 @@ +@@ -3568,6 +4088,12 @@ } public boolean randomTeleport(double d0, double d1, double d2, boolean flag) { @@ -1056,7 +1056,7 @@ double d3 = this.getX(); double d4 = this.getY(); double d5 = this.getZ(); -@@ -3585,16 +4111,41 @@ +@@ -3592,16 +4118,41 @@ } if (flag2) { @@ -1101,7 +1101,7 @@ } else { if (flag) { world.broadcastEntityEvent(this, (byte) 46); -@@ -3606,7 +4157,7 @@ +@@ -3613,7 +4164,7 @@ entitycreature.getNavigation().stop(); } @@ -1110,7 +1110,7 @@ } } -@@ -3699,7 +4250,7 @@ +@@ -3706,7 +4257,7 @@ } public void stopSleeping() { @@ -1119,7 +1119,7 @@ World world = this.level(); java.util.Objects.requireNonNull(world); -@@ -3733,7 +4284,7 @@ +@@ -3740,7 +4291,7 @@ @Nullable public EnumDirection getBedOrientation() { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityTameableAnimal.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityTameableAnimal.patch index c7f83229ca..3825a9b7fc 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityTameableAnimal.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityTameableAnimal.patch @@ -13,7 +13,7 @@ public abstract class EntityTameableAnimal extends EntityAnimal implements OwnableEntity { public static final int TELEPORT_WHEN_DISTANCE_IS_SQ = 144; -@@ -292,7 +298,14 @@ +@@ -295,7 +301,14 @@ if (!this.canTeleportTo(new BlockPosition(i, j, k))) { return false; } else { 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 a57f473f3c..7f9b3654d8 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityTypes.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityTypes.patch @@ -51,7 +51,7 @@ } public static Consumer createDefaultStackConfig(World world, ItemStack itemstack, @Nullable EntityHuman entityhuman) { -@@ -464,21 +472,37 @@ +@@ -464,21 +472,40 @@ CustomData customdata = (CustomData) itemstack.getOrDefault(DataComponents.ENTITY_DATA, CustomData.EMPTY); return !customdata.isEmpty() ? consumer.andThen((entity) -> { @@ -86,13 +86,16 @@ if (t0 != null) { - worldserver.addFreshEntityWithPassengers(t0); ++ // CraftBukkit start + worldserver.addFreshEntityWithPassengers(t0, spawnReason); -+ return !t0.isRemoved() ? t0 : null; // Don't return an entity when CreatureSpawnEvent is canceled ++ if (t0.isRemoved()) { ++ return null; // Don't return an entity when CreatureSpawnEvent is canceled ++ } + // CraftBukkit end - } + if (t0 instanceof EntityInsentient) { + EntityInsentient entityinsentient = (EntityInsentient) t0; - return t0; -@@ -649,7 +673,7 @@ +@@ -657,7 +684,7 @@ } return entity; @@ -101,7 +104,7 @@ } public static Stream loadEntitiesRecursive(final List list, final World world, final EntitySpawnReason entityspawnreason) { -@@ -710,7 +734,7 @@ +@@ -718,7 +745,7 @@ @Nullable public T tryCast(Entity entity) { @@ -110,7 +113,7 @@ } @Override -@@ -779,7 +803,7 @@ +@@ -791,7 +818,7 @@ this.canSpawnFarFromPlayer = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC; } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/Interaction.patch b/paper-server/nms-patches/net/minecraft/world/entity/Interaction.patch index 69b475e87a..e19f5f6026 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/Interaction.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/Interaction.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/Interaction.java +++ b/net/minecraft/world/entity/Interaction.java -@@ -26,6 +26,12 @@ - import net.minecraft.world.phys.AxisAlignedBB; +@@ -27,6 +27,12 @@ + import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; +// CraftBukkit start @@ -13,7 +13,7 @@ public class Interaction extends Entity implements Attackable, Targeting { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -64,7 +70,7 @@ +@@ -65,7 +71,7 @@ this.setHeight(nbttagcompound.getFloat("height")); } @@ -22,7 +22,7 @@ Logger logger; if (nbttagcompound.contains("attack")) { -@@ -144,9 +150,16 @@ +@@ -145,9 +151,16 @@ @Override public boolean skipAttackInteraction(Entity entity) { if (entity instanceof EntityHuman entityhuman) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/Leashable.patch b/paper-server/nms-patches/net/minecraft/world/entity/Leashable.patch index 770872a7a1..eb60e25af7 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/Leashable.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/Leashable.patch @@ -20,8 +20,8 @@ + dropLeash((Entity & Leashable) this, false, false); // CraftBukkit - decompile error } - @Nullable -@@ -54,7 +59,7 @@ + default void readLeashData(NBTTagCompound nbttagcompound) { +@@ -64,7 +69,7 @@ return new Leashable.a(Either.left(nbttagcompound.getCompound("leash").getUUID("UUID"))); } else { if (nbttagcompound.contains("leash", 11)) { @@ -30,7 +30,7 @@ if (either != null) { return new Leashable.a(either); -@@ -69,6 +74,11 @@ +@@ -79,6 +84,11 @@ if (leashable_a != null) { Either either = leashable_a.delayedLeashInfo; Entity entity = leashable_a.leashHolder; @@ -42,7 +42,7 @@ if (entity instanceof EntityLeash) { EntityLeash entityleash = (EntityLeash) entity; -@@ -111,7 +121,9 @@ +@@ -121,7 +131,9 @@ } if (e0.tickCount > 100) { @@ -52,16 +52,21 @@ ((Leashable) e0).setLeashData((Leashable.a) null); } } -@@ -120,7 +132,7 @@ +@@ -130,11 +142,11 @@ } - default void dropLeash(boolean flag, boolean flag1) { -- dropLeash((Entity) this, flag, flag1); -+ dropLeash((Entity & Leashable) this, flag, flag1); // CraftBukkit - decompile error + default void dropLeash() { +- dropLeash((Entity) this, true, true); ++ dropLeash((Entity & Leashable) this, true, true); // CraftBukkit - decompile error } - private static void dropLeash(E e0, boolean flag, boolean flag1) { -@@ -134,7 +146,9 @@ + default void removeLeash() { +- dropLeash((Entity) this, true, false); ++ dropLeash((Entity & Leashable) this, true, false); // CraftBukkit - decompile error + } + + default void onLeashRemoved() {} +@@ -151,7 +163,9 @@ WorldServer worldserver = (WorldServer) world; if (flag1) { @@ -71,17 +76,17 @@ } if (flag) { -@@ -154,7 +168,8 @@ +@@ -171,7 +185,8 @@ if (leashable_a != null && leashable_a.leashHolder != null) { if (!e0.isAlive() || !leashable_a.leashHolder.isAlive()) { -- dropLeash(e0, true, worldserver.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)); +- if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { + worldserver.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(e0.getBukkitEntity(), (!e0.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit -+ dropLeash(e0, true, worldserver.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !e0.pluginRemoved); // CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin - } - - Entity entity = ((Leashable) e0).getLeashHolder(); -@@ -184,13 +199,18 @@ ++ if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !e0.pluginRemoved) { // CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin + ((Leashable) e0).dropLeash(); + } else { + ((Leashable) e0).removeLeash(); +@@ -205,13 +220,18 @@ } default void leashTooFarBehaviour() { @@ -90,7 +95,7 @@ + entity.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(entity.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); + } + // CraftBukkit end - this.dropLeash(true, true); + this.dropLeash(); } default void closeRangeLeashBehaviour(Entity entity) {} @@ -101,7 +106,7 @@ } private static void legacyElasticRangeLeashBehaviour(E e0, Entity entity, float f) { -@@ -202,7 +222,7 @@ +@@ -223,7 +243,7 @@ } default void setLeashedTo(Entity entity, boolean flag) { @@ -110,7 +115,7 @@ } private static void setLeashedTo(E e0, Entity entity, boolean flag) { -@@ -233,7 +253,7 @@ +@@ -254,7 +274,7 @@ @Nullable default Entity getLeashHolder() { 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 7ed8bcd274..5344d0cdaa 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityBee.java +++ b/net/minecraft/world/entity/animal/EntityBee.java -@@ -89,6 +89,12 @@ +@@ -93,6 +93,12 @@ import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.phys.Vec3D; @@ -13,7 +13,7 @@ public class EntityBee extends EntityAnimal implements IEntityAngerable, EntityBird { public static final float FLAP_DEGREES_PER_TICK = 120.32113F; -@@ -194,12 +200,19 @@ +@@ -198,12 +204,19 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { @@ -35,7 +35,7 @@ nbttagcompound.put("flower_pos", GameProfileSerializer.writeBlockPos(this.getSavedFlowerPos())); } -@@ -219,8 +232,8 @@ +@@ -223,8 +236,8 @@ this.ticksWithoutNectarSinceExitingHive = nbttagcompound.getInt("TicksSincePollination"); this.stayOutOfHiveCountdown = nbttagcompound.getInt("CannotEnterHiveTicks"); this.numCropsGrownSincePollination = nbttagcompound.getInt("CropsGrownSincePollination"); @@ -46,7 +46,7 @@ this.readPersistentAngerSaveData(this.level(), nbttagcompound); } -@@ -244,7 +257,7 @@ +@@ -248,7 +261,7 @@ } if (b0 > 0) { @@ -55,7 +55,7 @@ } } -@@ -502,7 +515,7 @@ +@@ -506,7 +519,7 @@ @Nullable TileEntityBeehive getBeehiveBlockEntity() { @@ -64,7 +64,7 @@ } boolean isHiveValid() { -@@ -638,8 +651,14 @@ +@@ -671,8 +684,14 @@ if (this.isInvulnerableTo(worldserver, damagesource)) { return false; } else { @@ -80,7 +80,7 @@ } } -@@ -1048,7 +1067,7 @@ +@@ -1082,7 +1101,7 @@ e() { super(); @@ -89,7 +89,7 @@ this.blacklistedTargets = Lists.newArrayList(); this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE)); } -@@ -1162,7 +1181,7 @@ +@@ -1196,7 +1215,7 @@ f() { super(); @@ -98,7 +98,7 @@ this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE)); } -@@ -1267,7 +1286,7 @@ +@@ -1301,7 +1320,7 @@ } } @@ -107,7 +107,7 @@ EntityBee.this.level().levelEvent(2011, blockposition, 15); EntityBee.this.level().setBlockAndUpdate(blockposition, iblockdata1); EntityBee.this.incrementNumCropsGrownSincePollination(); -@@ -1344,7 +1363,7 @@ +@@ -1378,7 +1397,7 @@ @Override protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) { if (entityinsentient instanceof EntityBee && this.mob.hasLineOfSight(entityliving)) { @@ -116,7 +116,7 @@ } } -@@ -1353,7 +1372,7 @@ +@@ -1387,7 +1406,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 c8275b2fd3..beee3ec814 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 @@ -13,7 +13,7 @@ Objects.requireNonNull(iregistry); optional.flatMap(iregistry::get).ifPresent(this::setVariant); -@@ -463,7 +463,7 @@ +@@ -462,7 +462,7 @@ } private void tryToTame(EntityHuman entityhuman) { @@ -22,7 +22,7 @@ this.tame(entityhuman); this.setOrderedToSit(true); this.level().broadcastEntityEvent(this, (byte) 7); -@@ -481,7 +481,7 @@ +@@ -480,7 +480,7 @@ private static class PathfinderGoalTemptChance extends PathfinderGoalTempt { @Nullable @@ -31,7 +31,7 @@ private final EntityCat cat; public PathfinderGoalTemptChance(EntityCat entitycat, double d0, Predicate predicate, boolean flag) { -@@ -615,7 +615,15 @@ +@@ -614,7 +614,15 @@ this.cat.randomTeleport((double) (blockposition_mutableblockposition.getX() + randomsource.nextInt(11) - 5), (double) (blockposition_mutableblockposition.getY() + randomsource.nextInt(5) - 2), (double) (blockposition_mutableblockposition.getZ() + randomsource.nextInt(11) - 5), false); blockposition_mutableblockposition.set(this.cat.blockPosition()); this.cat.dropFromGiftLootTable(getServerLevel((Entity) this.cat), LootTables.CAT_MORNING_GIFT, (worldserver, itemstack) -> { @@ -48,7 +48,7 @@ }); } -@@ -646,10 +654,10 @@ +@@ -645,10 +653,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/EntityMushroomCow.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch index 25e301c40c..13fc6bcc6a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityMushroomCow.java +++ b/net/minecraft/world/entity/animal/EntityMushroomCow.java -@@ -44,6 +44,13 @@ +@@ -43,6 +43,13 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.storage.loot.LootTables; @@ -14,7 +14,7 @@ public class EntityMushroomCow extends EntityCow implements IShearable, VariantHolder { private static final DataWatcherObject DATA_TYPE = DataWatcher.defineId(EntityMushroomCow.class, DataWatcherRegistry.STRING); -@@ -121,6 +128,11 @@ +@@ -120,6 +127,11 @@ if (world instanceof WorldServer) { WorldServer worldserver = (WorldServer) world; @@ -26,7 +26,7 @@ this.shear(worldserver, SoundCategory.PLAYERS, itemstack); this.gameEvent(GameEvent.SHEAR, entityhuman); itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand)); -@@ -162,11 +174,19 @@ +@@ -163,11 +175,19 @@ worldserver.sendParticles(Particles.EXPLOSION, this.getX(), this.getY(0.5D), this.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D); this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_MOOSHROOM, itemstack, (worldserver1, itemstack1) -> { for (int i = 0; i < itemstack1.getCount(); ++i) { @@ -48,7 +48,7 @@ } @Override -@@ -262,7 +282,7 @@ +@@ -263,7 +283,7 @@ } static EntityMushroomCow.Type byName(String s) { 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 5cdb3fbcc4..1b39ad8972 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityParrot.java +++ b/net/minecraft/world/entity/animal/EntityParrot.java -@@ -250,7 +250,7 @@ +@@ -248,7 +248,7 @@ } if (!this.level().isClientSide) { @@ -9,7 +9,7 @@ this.tame(entityhuman); this.level().broadcastEntityEvent(this, (byte) 7); } else { -@@ -271,7 +271,7 @@ +@@ -269,7 +269,7 @@ } } else { this.usePlayerItem(entityhuman, enumhand, itemstack); @@ -18,7 +18,7 @@ if (entityhuman.isCreative() || !this.isInvulnerable()) { this.hurt(this.damageSources().playerAttack(entityhuman), Float.MAX_VALUE); } -@@ -365,7 +365,7 @@ +@@ -363,7 +363,7 @@ @Override public boolean isPushable() { @@ -27,7 +27,7 @@ } @Override -@@ -380,8 +380,14 @@ +@@ -378,8 +378,14 @@ if (this.isInvulnerableTo(worldserver, damagesource)) { return false; } else { 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 b5351cb7d4..ad06fe3b28 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntitySheep.java +++ b/net/minecraft/world/entity/animal/EntitySheep.java -@@ -57,6 +57,12 @@ +@@ -50,6 +50,12 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.storage.loot.LootTables; @@ -13,7 +13,7 @@ public class EntitySheep extends EntityAnimal implements IShearable { private static final int EAT_ANIMATION_TICKS = 40; -@@ -167,6 +173,11 @@ +@@ -160,6 +166,11 @@ WorldServer worldserver = (WorldServer) world; if (this.readyForShearing()) { @@ -25,7 +25,7 @@ this.shear(worldserver, SoundCategory.PLAYERS, itemstack); this.gameEvent(GameEvent.SHEAR, entityhuman); itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand)); -@@ -185,7 +196,9 @@ +@@ -178,7 +189,9 @@ worldserver.playSound((EntityHuman) null, (Entity) this, SoundEffects.SHEEP_SHEAR, soundcategory, 1.0F, 1.0F); this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_SHEEP, itemstack, (worldserver1, itemstack1) -> { for (int i = 0; i < itemstack1.getCount(); ++i) { @@ -35,7 +35,7 @@ if (entityitem != null) { entityitem.setDeltaMovement(entityitem.getDeltaMovement().add((double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (this.random.nextFloat() * 0.05F), (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F))); -@@ -280,6 +293,12 @@ +@@ -276,6 +289,12 @@ @Override public void ate() { @@ -48,12 +48,3 @@ super.ate(); this.setSheared(false); if (this.isBaby()) { -@@ -299,7 +318,7 @@ - EnumColor enumcolor = entitysheep.getColor(); - EnumColor enumcolor1 = entitysheep1.getColor(); - CraftingInput craftinginput = makeCraftInput(enumcolor, enumcolor1); -- Optional optional = worldserver.recipeAccess().getRecipeFor(Recipes.CRAFTING, craftinginput, worldserver).map((recipeholder) -> { -+ Optional optional = worldserver.recipeAccess().getRecipeFor(Recipes.CRAFTING, craftinginput, worldserver).map((recipeholder) -> { // CraftBukkit - decompile error - return ((RecipeCrafting) recipeholder.value()).assemble(craftinginput, worldserver.registryAccess()); - }).map(ItemStack::getItem); - 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 bb113dd9a6..4f81cea4a4 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 @@ -30,7 +30,7 @@ } public static AttributeProvider.Builder createAttributes() { -@@ -229,7 +236,7 @@ +@@ -233,7 +240,7 @@ public void aiStep() { super.aiStep(); if (!this.level().isClientSide && this.isAlive() && this.tickCount % 10 == 0) { @@ -39,7 +39,7 @@ } if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) { -@@ -299,7 +306,12 @@ +@@ -303,7 +310,12 @@ ItemStack itemstack1 = this.getItemInHand(EnumHand.MAIN_HAND); if (this.isDancing() && itemstack.is(TagsItem.DUPLICATES_ALLAYS) && this.canDuplicate()) { @@ -53,7 +53,7 @@ this.level().broadcastEntityEvent(this, (byte) 18); this.level().playSound(entityhuman, (Entity) this, SoundEffects.AMETHYST_BLOCK_CHIME, SoundCategory.NEUTRAL, 2.0F, 1.0F); this.removeInteractionItem(entityhuman, itemstack); -@@ -310,7 +322,7 @@ +@@ -314,7 +326,7 @@ this.setItemInHand(EnumHand.MAIN_HAND, itemstack2); this.removeInteractionItem(entityhuman, itemstack); this.level().playSound(entityhuman, (Entity) this, SoundEffects.ALLAY_ITEM_GIVEN, SoundCategory.NEUTRAL, 2.0F, 1.0F); @@ -62,7 +62,7 @@ return EnumInteractionResult.SUCCESS; } else if (!itemstack1.isEmpty() && enumhand == EnumHand.MAIN_HAND && itemstack.isEmpty()) { this.setItemSlot(EnumItemSlot.MAINHAND, ItemStack.EMPTY); -@@ -411,6 +423,7 @@ +@@ -415,6 +427,7 @@ } private boolean shouldStopDancing() { @@ -70,7 +70,7 @@ return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), (double) ((GameEvent) GameEvent.JUKEBOX_PLAY.value()).notificationRadius()) || !this.level().getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX); } -@@ -502,7 +515,7 @@ +@@ -506,7 +519,7 @@ } @@ -79,7 +79,7 @@ Allay allay = (Allay) EntityTypes.ALLAY.create(this.level(), EntitySpawnReason.BREEDING); if (allay != null) { -@@ -510,9 +523,9 @@ +@@ -514,9 +527,9 @@ allay.setPersistenceRequired(); allay.resetDuplicationCooldown(); this.resetDuplicationCooldown(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch index d43f6038e3..0c8602cd25 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch @@ -14,7 +14,7 @@ @@ -94,7 +98,7 @@ this.despawnDelay = this.isLeashedToWanderingTrader() ? ((EntityVillagerTrader) this.getLeashHolder()).getDespawnDelay() - 1 : this.despawnDelay - 1; if (this.despawnDelay <= 0) { - this.dropLeash(true, false); + this.removeLeash(); - this.discard(); + this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } 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 6b683c7a9c..d98583e7f2 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 @@ -191,18 +191,16 @@ EntityExperienceOrb.award(worldserver, this.position(), MathHelper.floor((float) short0 * 0.08F)); } -@@ -577,8 +672,8 @@ - if (this.dragonDeathTime == 200) { - world = this.level(); - if (world instanceof WorldServer) { -- worldserver = (WorldServer) world; -- if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { -+ WorldServer worldserver = (WorldServer) world; // CraftBukkit - decompile error +@@ -592,7 +687,7 @@ + if (world1 instanceof WorldServer) { + WorldServer worldserver1 = (WorldServer) world1; + +- if (worldserver1.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + if (true) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp - EntityExperienceOrb.award(worldserver, this.position(), MathHelper.floor((float) short0 * 0.2F)); + EntityExperienceOrb.award(worldserver1, this.position(), MathHelper.floor((float) short0 * 0.2F)); } -@@ -586,7 +681,7 @@ +@@ -600,7 +695,7 @@ this.dragonFight.setDragonKilled(this); } @@ -211,7 +209,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); } } -@@ -800,6 +895,7 @@ +@@ -814,6 +909,7 @@ super.addAdditionalSaveData(nbttagcompound); nbttagcompound.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId()); nbttagcompound.putInt("DragonDeathTime", this.dragonDeathTime); @@ -219,7 +217,7 @@ } @Override -@@ -813,6 +909,11 @@ +@@ -827,6 +923,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 27bbc62a0b..d814839e75 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 @@ -19,7 +19,7 @@ public class EntityWither extends EntityMonster implements IRangedEntity { private static final DataWatcherObject DATA_TARGET_A = DataWatcher.defineId(EntityWither.class, DataWatcherRegistry.INT); -@@ -253,15 +265,40 @@ +@@ -252,15 +264,40 @@ i = this.getInvulnerableTicks() - 1; this.bossEvent.setProgress(1.0F - (float) i / 220.0F); if (i <= 0) { @@ -63,7 +63,7 @@ } } else { -@@ -306,6 +343,7 @@ +@@ -305,6 +342,7 @@ if (!list.isEmpty()) { EntityLiving entityliving1 = (EntityLiving) list.get(this.random.nextInt(list.size())); @@ -71,7 +71,7 @@ this.setAlternativeTarget(i, entityliving1.getId()); } } -@@ -332,6 +370,11 @@ +@@ -331,6 +369,11 @@ IBlockData iblockdata = worldserver.getBlockState(blockposition); if (canDestroy(iblockdata)) { @@ -83,7 +83,7 @@ flag = worldserver.destroyBlock(blockposition, true, this) || flag; } } -@@ -343,7 +386,7 @@ +@@ -342,7 +385,7 @@ } if (this.tickCount % 20 == 0) { @@ -92,7 +92,7 @@ } this.bossEvent.setProgress(this.getHealth() / this.getMaxHealth()); -@@ -500,7 +543,7 @@ +@@ -499,7 +542,7 @@ @Override public void checkDespawn() { if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.shouldDespawnInPeaceful()) { 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 db338150fc..ea827c1f59 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 @@ -30,7 +30,7 @@ leashable.setLeashedTo(this, true); flag = true; } -@@ -93,18 +109,34 @@ +@@ -93,18 +109,38 @@ boolean flag1 = false; if (!flag) { @@ -47,7 +47,7 @@ Leashable leashable1 = (Leashable) iterator1.next(); if (leashable1.isLeashed() && leashable1.getLeashHolder() == this) { -- leashable1.dropLeash(true, false); +- leashable1.removeLeash(); + // CraftBukkit start + if (leashable1 instanceof Entity leashed) { + if (CraftEventFactory.callPlayerUnleashEntityEvent(leashed, entityhuman, enumhand).isCancelled()) { @@ -55,7 +55,11 @@ + continue; + } + } -+ leashable1.dropLeash(true, !entityhuman.getAbilities().instabuild); // false -> survival mode boolean ++ if (entityhuman.getAbilities().instabuild){ ++ leashable1.removeLeash(); ++ } else { ++ leashable1.dropLeash(); ++ } + // CraftBukkit end flag1 = true; } 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 4f24f25981..a8a1cf4063 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityEnderman.java +++ b/net/minecraft/world/entity/monster/EntityEnderman.java -@@ -70,6 +70,11 @@ +@@ -69,6 +69,11 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.Vec3D; @@ -12,7 +12,7 @@ public class EntityEnderman extends EntityMonster implements IEntityAngerable { private static final MinecraftKey SPEED_MODIFIER_ATTACKING_ID = MinecraftKey.withDefaultNamespace("attacking"); -@@ -113,7 +118,17 @@ +@@ -112,7 +117,17 @@ @Override public void setTarget(@Nullable EntityLiving entityliving) { @@ -31,7 +31,7 @@ AttributeModifiable attributemodifiable = this.getAttribute(GenericAttributes.MOVEMENT_SPEED); if (entityliving == null) { -@@ -128,6 +143,7 @@ +@@ -127,6 +142,7 @@ attributemodifiable.addTransientModifier(EntityEnderman.SPEED_MODIFIER_ATTACKING); } } @@ -39,7 +39,7 @@ } -@@ -466,9 +482,11 @@ +@@ -465,9 +481,11 @@ if (iblockdata2 != null) { iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level(), blockposition); if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) { @@ -51,7 +51,7 @@ } } -@@ -507,9 +525,11 @@ +@@ -506,9 +524,11 @@ 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/EntityPillager.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch index 45b728cf99..5a09874003 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityPillager.java +++ b/net/minecraft/world/entity/monster/EntityPillager.java -@@ -50,6 +50,10 @@ +@@ -53,6 +53,10 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.WorldAccess; @@ -11,7 +11,7 @@ public class EntityPillager extends EntityIllagerAbstract implements ICrossbow, InventoryCarrier { private static final DataWatcherObject IS_CHARGING_CROSSBOW = DataWatcher.defineId(EntityPillager.class, DataWatcherRegistry.BOOLEAN); -@@ -198,7 +202,7 @@ +@@ -206,7 +210,7 @@ ItemStack itemstack1 = this.inventory.addItem(itemstack); if (itemstack1.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 ac3d0c8513..886c966a0f 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 -@@ -45,6 +45,10 @@ +@@ -43,6 +43,10 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public class EntityRavager extends EntityRaider { private static final Predicate ROAR_TARGET_WITH_GRIEFING = (entity) -> { -@@ -161,6 +165,11 @@ +@@ -158,6 +162,11 @@ Block block = iblockdata.getBlock(); if (block instanceof BlockLeaves) { 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 4fceb68c81..3b3d0eb4e0 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 -@@ -207,7 +207,17 @@ +@@ -209,7 +209,17 @@ World world = this.level(); if (world instanceof WorldServer worldserver) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonWither.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonWither.patch index a42658911b..b34685d97a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonWither.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonWither.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntitySkeletonWither.java +++ b/net/minecraft/world/entity/monster/EntitySkeletonWither.java -@@ -97,7 +97,7 @@ +@@ -110,7 +110,7 @@ return false; } else { if (entity instanceof EntityLiving) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/breeze/Breeze.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/breeze/Breeze.patch index a397ebdf67..2050f356f6 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/breeze/Breeze.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/breeze/Breeze.patch @@ -9,7 +9,7 @@ } @Override -@@ -255,6 +255,7 @@ +@@ -252,6 +252,7 @@ @Override public boolean canAttackType(EntityTypes entitytypes) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/creaking/Creaking.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/creaking/Creaking.patch new file mode 100644 index 0000000000..80e612bda4 --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/creaking/Creaking.patch @@ -0,0 +1,38 @@ +--- a/net/minecraft/world/entity/monster/creaking/Creaking.java ++++ b/net/minecraft/world/entity/monster/creaking/Creaking.java +@@ -206,7 +206,7 @@ + + @Override + public BehaviorController getBrain() { +- return super.getBrain(); ++ return (BehaviorController) super.getBrain(); // CraftBukkit - decompile error + } + + @Override +@@ -329,7 +329,7 @@ + } + + this.makeSound(this.getDeathSound()); +- this.remove(Entity.RemovalReason.DISCARDED); ++ this.remove(Entity.RemovalReason.DISCARDED, null); // CraftBukkit - add Bukkit remove cause + } + + public void creakingDeathEffects(DamageSource damagesource) { +@@ -476,7 +476,7 @@ + + @Override + protected SoundEffect getHurtSound(DamageSource damagesource) { +- return this.isHeartBound() ? SoundEffects.CREAKING_SWAY : super.getHurtSound(damagesource); ++ return SoundEffects.CREAKING_SWAY; + } + + @Override +@@ -549,7 +549,7 @@ + } + + public void activate(EntityHuman entityhuman) { +- this.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, (Object) entityhuman); ++ this.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, entityhuman); // CraftBukkit - decompile error + this.gameEvent(GameEvent.ENTITY_ACTION); + this.makeSound(SoundEffects.CREAKING_ACTIVATE); + this.setIsActive(true); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/creaking/CreakingTransient.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/creaking/CreakingTransient.patch deleted file mode 100644 index bbce5b442c..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/creaking/CreakingTransient.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/world/entity/monster/creaking/CreakingTransient.java -+++ b/net/minecraft/world/entity/monster/creaking/CreakingTransient.java -@@ -97,7 +97,7 @@ - } - } - -- this.setRemoved(Entity.RemovalReason.DISCARDED); -+ this.setRemoved(Entity.RemovalReason.DISCARDED, null); // CraftBukkit - add Bukkit remove cause - return; - } - } -@@ -149,7 +149,7 @@ - } - } - -- this.remove(Entity.RemovalReason.DISCARDED); -+ this.remove(Entity.RemovalReason.DISCARDED, null); // CraftBukkit - add Bukkit remove cause - } - - @Override diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch index a18f0f5845..3e139a4f32 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/EntityPiglin.java +++ b/net/minecraft/world/entity/monster/piglin/EntityPiglin.java -@@ -57,6 +57,18 @@ +@@ -60,6 +60,18 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; @@ -19,7 +19,7 @@ public class EntityPiglin extends EntityPiglinAbstract implements ICrossbow, InventoryCarrier { private static final DataWatcherObject DATA_BABY_ID = DataWatcher.defineId(EntityPiglin.class, DataWatcherRegistry.BOOLEAN); -@@ -76,6 +88,10 @@ +@@ -79,6 +91,10 @@ public boolean cannotHunt; protected static final ImmutableList>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.NEAREST_ITEMS, SensorType.HURT_BY, SensorType.PIGLIN_SPECIFIC_SENSOR); protected static final ImmutableList> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.DOORS_TO_CLOSE, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLINS, MemoryModuleType.NEARBY_ADULT_PIGLINS, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryModuleType.ITEM_PICKUP_COOLDOWN_TICKS, MemoryModuleType.HURT_BY, MemoryModuleType.HURT_BY_ENTITY, new MemoryModuleType[]{MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.INTERACTION_TARGET, MemoryModuleType.PATH, MemoryModuleType.ANGRY_AT, MemoryModuleType.UNIVERSAL_ANGER, MemoryModuleType.AVOID_TARGET, MemoryModuleType.ADMIRING_ITEM, MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM, MemoryModuleType.ADMIRING_DISABLED, MemoryModuleType.DISABLE_WALK_TO_ADMIRE_ITEM, MemoryModuleType.CELEBRATE_LOCATION, MemoryModuleType.DANCING, MemoryModuleType.HUNTED_RECENTLY, MemoryModuleType.NEAREST_VISIBLE_BABY_HOGLIN, MemoryModuleType.NEAREST_VISIBLE_NEMESIS, MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, MemoryModuleType.RIDE_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_HUNTABLE_HOGLIN, MemoryModuleType.NEAREST_TARGETABLE_PLAYER_NOT_WEARING_GOLD, MemoryModuleType.NEAREST_PLAYER_HOLDING_WANTED_ITEM, MemoryModuleType.ATE_RECENTLY, MemoryModuleType.NEAREST_REPELLENT}); @@ -30,7 +30,7 @@ public EntityPiglin(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -94,6 +110,14 @@ +@@ -97,6 +113,14 @@ } this.writeInventoryToTag(nbttagcompound, this.registryAccess()); @@ -45,7 +45,7 @@ } @Override -@@ -102,6 +126,10 @@ +@@ -105,6 +129,10 @@ this.setBaby(nbttagcompound.getBoolean("IsBaby")); this.setCannotHunt(nbttagcompound.getBoolean("CannotHunt")); this.readInventoryFromTag(nbttagcompound, this.registryAccess()); @@ -56,7 +56,7 @@ } @VisibleForDebug -@@ -221,7 +249,7 @@ +@@ -224,7 +252,7 @@ @Override public BehaviorController getBrain() { @@ -65,7 +65,7 @@ } @Override -@@ -366,7 +394,7 @@ +@@ -374,7 +402,7 @@ } protected void holdInOffHand(ItemStack itemstack) { @@ -74,18 +74,18 @@ this.setItemSlot(EnumItemSlot.OFFHAND, itemstack); this.setGuaranteedDrop(EnumItemSlot.OFFHAND); } else { -@@ -392,8 +420,8 @@ - if (EnchantmentManager.has(itemstack1, EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE)) { +@@ -401,8 +429,8 @@ return false; } else { -- boolean flag = PiglinAI.isLovedItem(itemstack) || itemstack.is(Items.CROSSBOW); -- boolean flag1 = PiglinAI.isLovedItem(itemstack1) || itemstack1.is(Items.CROSSBOW); -+ boolean flag = PiglinAI.isLovedItem(itemstack, this) || itemstack.is(Items.CROSSBOW); // CraftBukkit -+ boolean flag1 = PiglinAI.isLovedItem(itemstack1, this) || itemstack1.is(Items.CROSSBOW); // CraftBukkit + TagKey tagkey = this.getPreferredWeaponType(); +- boolean flag = PiglinAI.isLovedItem(itemstack) || tagkey != null && itemstack.is(tagkey); +- boolean flag1 = PiglinAI.isLovedItem(itemstack1) || tagkey != null && itemstack1.is(tagkey); ++ boolean flag = PiglinAI.isLovedItem(itemstack, this) || tagkey != null && itemstack.is(tagkey); // CraftBukkit ++ boolean flag1 = PiglinAI.isLovedItem(itemstack1, this) || tagkey != null && itemstack1.is(tagkey); // CraftBukkit - return flag && !flag1 ? true : (!flag && flag1 ? false : (this.isAdult() && !itemstack.is(Items.CROSSBOW) && itemstack1.is(Items.CROSSBOW) ? false : super.canReplaceCurrentItem(itemstack, itemstack1, enumitemslot))); + return flag && !flag1 ? true : (!flag && flag1 ? false : super.canReplaceCurrentItem(itemstack, itemstack1, enumitemslot)); } -@@ -422,7 +450,7 @@ +@@ -431,7 +459,7 @@ @Override protected SoundEffect getAmbientSound() { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/warden/Warden.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/warden/Warden.patch index 45b48afff7..ca1bdf194d 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/warden/Warden.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/warden/Warden.patch @@ -27,7 +27,7 @@ this.getBrain().eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); SonicBoom.setCooldown(this, 200); } -@@ -582,12 +582,12 @@ +@@ -582,11 +582,11 @@ @Override protected NavigationAbstract createNavigation(World world) { @@ -36,7 +36,6 @@ @Override protected Pathfinder createPathFinder(int i) { this.nodeEvaluator = new PathfinderNormal(); - this.nodeEvaluator.setCanPassDoors(true); - return new Pathfinder(this, this.nodeEvaluator, i) { + return new Pathfinder(this.nodeEvaluator, i) { // CraftBukkit - decompile error @Override 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 0f03f2ba65..8bb9958567 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 @@ -95,8 +95,8 @@ }).limit(5L).toList(); if (list1.size() >= j) { -- if (!SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM).isEmpty()) { -+ if (!SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE).isEmpty()) { // CraftBukkit +- if (!SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM, false).isEmpty()) { ++ if (!SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE).isEmpty()) { // CraftBukkit list.forEach(SensorGolemLastSeen::golemDetected); } } 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 a09799fd3f..5827903e3d 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 @@ -30,8 +30,8 @@ private static final DataWatcherObject DATA_PLAYER_ABSORPTION_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.FLOAT); private static final DataWatcherObject DATA_SCORE_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.INT); protected static final DataWatcherObject DATA_PLAYER_MODE_CUSTOMISATION = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.BYTE); -@@ -148,7 +162,7 @@ - protected static final DataWatcherObject DATA_SHOULDER_RIGHT = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.COMPOUND_TAG); +@@ -149,7 +163,7 @@ + public static final int CLIENT_LOADED_TIMEOUT_TIME = 60; private long timeEntitySatOnShoulder; final PlayerInventory inventory = new PlayerInventory(this); - protected InventoryEnderChest enderChestInventory = new InventoryEnderChest(); @@ -39,7 +39,7 @@ public final ContainerPlayer inventoryMenu; public Container containerMenu; protected FoodMetaData foodData = new FoodMetaData(); -@@ -186,6 +200,16 @@ +@@ -189,6 +203,16 @@ private boolean ignoreFallDamageFromCurrentImpulse; private int currentImpulseContextResetGraceTime; @@ -56,7 +56,7 @@ public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile) { super(EntityTypes.PLAYER, world); this.lastItemInMainHand = ItemStack.EMPTY; -@@ -350,7 +374,7 @@ +@@ -353,7 +377,7 @@ } private void turtleHelmetTick() { @@ -65,7 +65,7 @@ } private boolean isEquipped(Item item) { -@@ -520,8 +544,14 @@ +@@ -523,8 +547,14 @@ public void rideTick() { if (!this.level().isClientSide && this.wantsToStopRiding() && this.isPassenger()) { this.stopRiding(); @@ -82,7 +82,7 @@ super.rideTick(); this.oBob = this.bob; this.bob = 0.0F; -@@ -716,6 +746,13 @@ +@@ -719,6 +749,13 @@ @Nullable public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1) { @@ -96,7 +96,7 @@ if (!itemstack.isEmpty() && this.level().isClientSide) { this.swing(EnumHand.MAIN_HAND); } -@@ -806,7 +843,7 @@ +@@ -809,7 +846,7 @@ } if (nbttagcompound.contains("LastDeathLocation", 10)) { @@ -105,7 +105,7 @@ Logger logger = EntityHuman.LOGGER; Objects.requireNonNull(logger); -@@ -814,7 +851,7 @@ +@@ -817,7 +854,7 @@ } if (nbttagcompound.contains("current_explosion_impact_pos", 9)) { @@ -114,7 +114,7 @@ Logger logger1 = EntityHuman.LOGGER; Objects.requireNonNull(logger1); -@@ -851,7 +888,7 @@ +@@ -854,7 +891,7 @@ } this.getLastDeathLocation().flatMap((globalpos) -> { @@ -123,7 +123,7 @@ Logger logger = EntityHuman.LOGGER; Objects.requireNonNull(logger); -@@ -883,10 +920,10 @@ +@@ -886,10 +923,10 @@ if (this.isDeadOrDying()) { return false; } else { @@ -136,7 +136,7 @@ } if (worldserver.getDifficulty() == EnumDifficulty.EASY) { -@@ -898,7 +935,13 @@ +@@ -901,7 +938,13 @@ } } @@ -151,7 +151,7 @@ } } } -@@ -920,10 +963,29 @@ +@@ -923,10 +966,29 @@ } public boolean canHarmPlayer(EntityHuman entityhuman) { @@ -184,7 +184,7 @@ } @Override -@@ -963,8 +1025,13 @@ +@@ -966,8 +1028,13 @@ } } @@ -199,7 +199,7 @@ if (!this.isInvulnerableTo(worldserver, damagesource)) { f = this.getDamageAfterArmorAbsorb(damagesource, f); f = this.getDamageAfterMagicAbsorb(damagesource, f); -@@ -979,7 +1046,7 @@ +@@ -982,7 +1049,7 @@ } if (f != 0.0F) { @@ -208,7 +208,7 @@ this.getCombatTracker().recordDamage(damagesource, f); this.setHealth(this.getHealth() - f); if (f < 3.4028235E37F) { -@@ -989,6 +1056,7 @@ +@@ -992,6 +1059,7 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE); } } @@ -216,7 +216,7 @@ } public boolean isTextFilteringEnabled() { -@@ -1141,10 +1209,15 @@ +@@ -1144,10 +1212,15 @@ f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; @@ -233,7 +233,7 @@ if (iprojectile.deflect(ProjectileDeflection.AIM_DEFLECT, this, this, true)) { this.level().playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_ATTACK_NODAMAGE, this.getSoundSource()); return; -@@ -1220,8 +1293,13 @@ +@@ -1223,8 +1296,13 @@ if (entityliving2 != this && entityliving2 != entity && !this.isAlliedTo((Entity) entityliving2) && (!(entityliving2 instanceof EntityArmorStand) || !((EntityArmorStand) entityliving2).isMarker()) && this.distanceToSqr((Entity) entityliving2) < 9.0D) { float f7 = this.getEnchantedDamage(entityliving2, f6, damagesource) * f2; @@ -248,7 +248,7 @@ World world = this.level(); if (world instanceof WorldServer) { -@@ -1237,9 +1315,26 @@ +@@ -1240,9 +1318,26 @@ } if (entity instanceof EntityPlayer && entity.hurtMarked) { @@ -275,7 +275,7 @@ } if (flag2) { -@@ -1305,9 +1400,14 @@ +@@ -1308,9 +1403,14 @@ } } @@ -291,7 +291,7 @@ } } -@@ -1348,7 +1448,14 @@ +@@ -1351,7 +1451,14 @@ @Override public void remove(Entity.RemovalReason entity_removalreason) { @@ -307,7 +307,7 @@ this.inventoryMenu.removed(this); if (this.containerMenu != null && this.hasContainerOpen()) { this.doCloseContainer(); -@@ -1388,6 +1495,12 @@ +@@ -1391,6 +1498,12 @@ } public Either startSleepInBed(BlockPosition blockposition) { @@ -320,7 +320,7 @@ this.startSleeping(blockposition); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1542,12 +1655,24 @@ +@@ -1545,12 +1658,24 @@ } public void startFallFlying() { @@ -346,7 +346,7 @@ } @Override -@@ -1662,10 +1787,21 @@ +@@ -1665,10 +1790,21 @@ return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2); } @@ -369,7 +369,7 @@ } } -@@ -1745,13 +1881,20 @@ +@@ -1748,13 +1884,20 @@ @Override public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { @@ -393,7 +393,7 @@ } } -@@ -1795,26 +1938,31 @@ +@@ -1798,26 +1941,31 @@ protected void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch index 288af4b6f5..a63d42d3bc 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch @@ -14,7 +14,7 @@ public abstract class EntityArrow extends IProjectile { private static final double ARROW_BASE_DAMAGE = 2.0D; -@@ -86,7 +93,14 @@ +@@ -88,7 +95,14 @@ } protected EntityArrow(EntityTypes entitytypes, double d0, double d1, double d2, World world, ItemStack itemstack, @Nullable ItemStack itemstack1) { @@ -29,7 +29,7 @@ this.pickupItemStack = itemstack.copy(); this.setCustomName((IChatBaseComponent) itemstack.get(DataComponents.CUSTOM_NAME)); Unit unit = (Unit) itemstack.remove(DataComponents.INTANGIBLE_PROJECTILE); -@@ -112,8 +126,8 @@ +@@ -114,8 +128,8 @@ } protected EntityArrow(EntityTypes entitytypes, EntityLiving entityliving, World world, ItemStack itemstack, @Nullable ItemStack itemstack1) { @@ -40,7 +40,7 @@ } public void setSoundEvent(SoundEffect soundeffect) { -@@ -276,7 +290,7 @@ +@@ -282,7 +296,7 @@ if (movingobjectpositionentity == null) { if (this.isAlive() && movingobjectpositionblock.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { @@ -49,7 +49,7 @@ this.hasImpulse = true; } } else { -@@ -284,7 +298,7 @@ +@@ -290,7 +304,7 @@ continue; } @@ -58,7 +58,7 @@ this.hasImpulse = true; if (this.getPierceLevel() > 0 && projectiledeflection == ProjectileDeflection.NONE) { -@@ -356,7 +370,7 @@ +@@ -357,7 +371,7 @@ protected void tickDespawn() { ++this.life; if (this.life >= 1200) { @@ -67,7 +67,7 @@ } } -@@ -408,7 +422,7 @@ +@@ -423,7 +437,7 @@ } if (this.piercingIgnoreEntityIds.size() >= this.getPierceLevel() + 1) { @@ -76,7 +76,7 @@ return; } -@@ -429,7 +443,13 @@ +@@ -444,7 +458,13 @@ int k = entity.getRemainingFireTicks(); if (this.isOnFire() && !flag) { @@ -91,7 +91,7 @@ } if (entity.hurtOrSimulate(damagesource, (float) i)) { -@@ -475,7 +495,7 @@ +@@ -490,7 +510,7 @@ this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); if (this.getPierceLevel() <= 0) { @@ -100,7 +100,7 @@ } } else { entity.setRemainingFireTicks(k); -@@ -491,7 +511,7 @@ +@@ -506,7 +526,7 @@ this.spawnAtLocation(worldserver2, this.getPickupItem(), 0.1F); } @@ -109,7 +109,7 @@ } } } -@@ -660,7 +680,7 @@ +@@ -675,7 +695,7 @@ } if (nbttagcompound.contains("weapon", 10)) { @@ -118,7 +118,7 @@ } else { this.firedFromWeapon = null; } -@@ -673,34 +693,31 @@ +@@ -688,34 +708,31 @@ Entity entity1 = entity; byte b0 = 0; @@ -165,7 +165,7 @@ } this.pickup = entityarrow_pickupstatus; -@@ -709,9 +726,24 @@ +@@ -724,9 +741,24 @@ @Override public void playerTouch(EntityHuman entityhuman) { if (!this.level().isClientSide && (this.isInGround() || this.isNoPhysics()) && this.shakeTime <= 0) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch index 45aaffc66b..3be5bee50f 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityFireball.java +++ b/net/minecraft/world/entity/projectile/EntityFireball.java -@@ -19,11 +19,17 @@ +@@ -15,11 +15,17 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.Vec3D; @@ -18,7 +18,7 @@ protected EntityFireball(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -73,7 +79,7 @@ +@@ -69,7 +75,7 @@ this.applyInertia(); if (!this.level().isClientSide && (entity != null && entity.isRemoved() || !this.level().hasChunkAt(this.blockPosition()))) { @@ -27,7 +27,7 @@ } else { MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity, this.getClipType()); Vec3D vec3d; -@@ -93,7 +99,7 @@ +@@ -89,7 +95,7 @@ } if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS && this.isAlive()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch index ab6f2fdb1c..99263bbaab 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityThrownExpBottle.java +++ b/net/minecraft/world/entity/projectile/EntityThrownExpBottle.java -@@ -12,6 +12,10 @@ +@@ -10,6 +10,10 @@ import net.minecraft.world.level.World; import net.minecraft.world.phys.MovingObjectPosition; @@ -11,20 +11,20 @@ public class EntityThrownExpBottle extends EntityProjectileThrowable { public EntityThrownExpBottle(EntityTypes entitytypes, World world) { -@@ -40,11 +44,20 @@ +@@ -38,11 +42,20 @@ protected void onHit(MovingObjectPosition movingobjectposition) { super.onHit(movingobjectposition); if (this.level() instanceof WorldServer) { -- this.level().levelEvent(2002, this.blockPosition(), PotionContents.getColor(Potions.WATER)); +- this.level().levelEvent(2002, this.blockPosition(), -13083194); + // CraftBukkit - moved to after event -+ // this.level().levelEvent(2002, this.blockPosition(), PotionContents.getColor(Potions.WATER)); ++ // this.level().levelEvent(2002, this.blockPosition(), -13083194); int i = 3 + this.level().random.nextInt(5) + this.level().random.nextInt(5); + // CraftBukkit start + org.bukkit.event.entity.ExpBottleEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callExpBottleEvent(this, movingobjectposition, i); + i = event.getExperience(); + if (event.getShowEffect()) { -+ this.level().levelEvent(2002, this.blockPosition(), PotionContents.getColor(Potions.WATER)); ++ this.level().levelEvent(2002, this.blockPosition(), -13083194); + } + // CraftBukkit end + diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch index a4d00d7bc1..15f4e7f0f9 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch @@ -11,7 +11,7 @@ public class EntityThrownTrident extends EntityArrow { private static final DataWatcherObject ID_LOYALTY = DataWatcher.defineId(EntityThrownTrident.class, DataWatcherRegistry.BYTE); -@@ -75,10 +79,10 @@ +@@ -76,10 +80,10 @@ } } @@ -24,7 +24,7 @@ return; } -@@ -136,7 +140,7 @@ +@@ -137,7 +141,7 @@ world = this.level(); if (world instanceof WorldServer) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch b/paper-server/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch index 40e734c409..d38532195a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch @@ -29,15 +29,6 @@ this.mob = entityraider; this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE)); } -@@ -524,7 +528,7 @@ - private final float hostileRadiusSqr; - public final PathfinderTargetCondition shoutTargeting = PathfinderTargetCondition.forNonCombat().range(8.0D).ignoreLineOfSight().ignoreInvisibilityTesting(); - -- public a(final EntityRaider entityraider, final EntityIllagerAbstract entityillagerabstract, final float f) { -+ public a(final EntityIllagerAbstract entityillagerabstract, final float f) { // CraftBukkit - decompile error - this.mob = entityillagerabstract; - this.hostileRadiusSqr = f * f; - this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE, PathfinderGoal.Type.LOOK)); @@ -547,7 +551,7 @@ while (iterator.hasNext()) { EntityRaider entityraider = (EntityRaider) iterator.next(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/AbstractBoat.patch b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/AbstractBoat.patch index f6c41ac0bf..bc5ef3553c 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/AbstractBoat.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/AbstractBoat.patch @@ -103,7 +103,7 @@ + public void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) { + // CraftBukkit end if (!this.level().isClientSide && entity_removalreason.shouldDestroy() && this.isLeashed()) { - this.dropLeash(true, true); + this.dropLeash(); } - super.remove(entity_removalreason); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.patch b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.patch index 19b0628ecc..3d8ea2b73a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.java +++ b/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.java -@@ -140,5 +140,12 @@ +@@ -135,5 +135,12 @@ public boolean isValid() { return !EntityMinecartCommandBlock.this.isRemoved(); } 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 c43684fd34..0adf2b5f87 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 @@ -12,22 +12,22 @@ public class EntityMinecartTNT extends EntityMinecartAbstract { private static final byte EVENT_PRIME = 10; -@@ -33,6 +38,7 @@ - private static final float DEFAULT_EXPLOSION_POWER_BASE = 4.0F; +@@ -37,6 +42,7 @@ public int fuse = -1; public float explosionPowerBase = 4.0F; + public float explosionSpeedFactor = 1.0F; + public boolean isIncendiary = false; // CraftBukkit - add field public EntityMinecartTNT(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -113,8 +119,16 @@ +@@ -117,8 +123,16 @@ if (world instanceof WorldServer worldserver) { double d1 = Math.min(Math.sqrt(d0), 5.0D); -- worldserver.explode(this, damagesource, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), (float) ((double) this.explosionPowerBase + this.random.nextDouble() * 1.5D * d1), false, World.a.TNT); +- worldserver.explode(this, damagesource, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), (float) ((double) this.explosionPowerBase + (double) this.explosionSpeedFactor * this.random.nextDouble() * 1.5D * d1), false, World.a.TNT); - this.discard(); + // CraftBukkit start -+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), (float) ((double) this.explosionPowerBase + this.random.nextDouble() * 1.5D * d1), this.isIncendiary); ++ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), (float) ((double) this.explosionPowerBase + (double) this.explosionSpeedFactor * this.random.nextDouble() * 1.5D * d1), this.isIncendiary); + worldserver.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + fuse = -1; diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerBrewingStand.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerBrewingStand.patch index ea84f45258..8c31a1e8d1 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerBrewingStand.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerBrewingStand.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerBrewingStand.java +++ b/net/minecraft/world/inventory/ContainerBrewingStand.java -@@ -16,6 +16,11 @@ +@@ -17,6 +17,11 @@ import net.minecraft.world.item.alchemy.PotionContents; import net.minecraft.world.item.alchemy.PotionRegistry; @@ -11,8 +11,8 @@ + public class ContainerBrewingStand extends Container { - private static final int BOTTLE_SLOT_START = 0; -@@ -32,12 +37,18 @@ + static final MinecraftKey EMPTY_SLOT_FUEL = MinecraftKey.withDefaultNamespace("container/slot/brewing_fuel"); +@@ -35,12 +40,18 @@ private final IContainerProperties brewingStandData; private final Slot ingredientSlot; @@ -31,7 +31,7 @@ checkContainerSize(iinventory, 5); checkContainerDataCount(icontainerproperties, 2); this.brewingStand = iinventory; -@@ -55,6 +66,7 @@ +@@ -58,6 +69,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { @@ -39,8 +39,8 @@ return this.brewingStand.stillValid(entityhuman); } -@@ -185,4 +197,17 @@ - return itemstack.is(TagsItem.BREWING_FUEL); +@@ -198,4 +210,17 @@ + return ContainerBrewingStand.EMPTY_SLOT_FUEL; } } + diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch index b30ed5ecb9..1b01560110 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerEnchantTable.java +++ b/net/minecraft/world/inventory/ContainerEnchantTable.java -@@ -31,6 +31,19 @@ +@@ -30,6 +30,19 @@ import net.minecraft.world.level.block.BlockEnchantmentTable; import net.minecraft.world.level.block.Blocks; @@ -19,8 +19,8 @@ + public class ContainerEnchantTable extends Container { - static final MinecraftKey EMPTY_SLOT_LAPIS_LAZULI = MinecraftKey.withDefaultNamespace("item/empty_slot_lapis_lazuli"); -@@ -41,6 +54,10 @@ + static final MinecraftKey EMPTY_SLOT_LAPIS_LAZULI = MinecraftKey.withDefaultNamespace("container/slot/lapis_lazuli"); +@@ -40,6 +53,10 @@ public final int[] costs; public final int[] enchantClue; public final int[] levelClue; @@ -31,7 +31,7 @@ public ContainerEnchantTable(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); -@@ -54,6 +71,13 @@ +@@ -53,6 +70,13 @@ super.setChanged(); ContainerEnchantTable.this.slotsChanged(this); } @@ -45,7 +45,7 @@ }; this.random = RandomSource.create(); this.enchantmentSeed = ContainerProperty.standalone(); -@@ -61,13 +85,13 @@ +@@ -60,13 +84,13 @@ this.enchantClue = new int[]{-1, -1, -1}; this.levelClue = new int[]{-1, -1, -1}; this.access = containeraccess; @@ -61,7 +61,7 @@ @Override public boolean mayPlace(ItemStack itemstack) { return itemstack.is(Items.LAPIS_LAZULI); -@@ -89,6 +113,9 @@ +@@ -88,6 +112,9 @@ this.addDataSlot(ContainerProperty.shared(this.levelClue, 0)); this.addDataSlot(ContainerProperty.shared(this.levelClue, 1)); this.addDataSlot(ContainerProperty.shared(this.levelClue, 2)); @@ -71,7 +71,7 @@ } @Override -@@ -96,7 +123,7 @@ +@@ -95,7 +122,7 @@ if (iinventory == this.enchantSlots) { ItemStack itemstack = iinventory.getItem(0); @@ -80,7 +80,7 @@ this.access.execute((world, blockposition) -> { Registry> registry = world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); int i = 0; -@@ -136,6 +163,41 @@ +@@ -135,6 +162,41 @@ } } @@ -122,7 +122,7 @@ this.broadcastChanges(); }); } else { -@@ -163,21 +225,46 @@ +@@ -162,21 +224,46 @@ ItemStack itemstack2 = itemstack; List list = this.getEnchantmentList(world.registryAccess(), itemstack, i, this.costs[i]); @@ -175,7 +175,7 @@ itemstack1.consume(j, entityhuman); if (itemstack1.isEmpty()) { this.enchantSlots.setItem(1, ItemStack.EMPTY); -@@ -244,6 +331,7 @@ +@@ -243,6 +330,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { @@ -183,7 +183,7 @@ return stillValid(this.access, entityhuman, Blocks.ENCHANTING_TABLE); } -@@ -294,4 +382,17 @@ +@@ -293,4 +381,17 @@ return itemstack; } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch index ef136c313f..9113652d4c 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerHorse.java +++ b/net/minecraft/world/inventory/ContainerHorse.java -@@ -10,6 +10,11 @@ +@@ -11,6 +11,11 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -11,8 +11,8 @@ + public class ContainerHorse extends Container { - private final IInventory horseContainer; -@@ -18,13 +23,28 @@ + static final MinecraftKey SADDLE_SLOT_SPRITE = MinecraftKey.withDefaultNamespace("container/slot/saddle"); +@@ -22,13 +27,28 @@ private static final int SLOT_BODY_ARMOR = 1; private static final int SLOT_HORSE_INVENTORY_START = 2; @@ -42,12 +42,12 @@ @Override public boolean mayPlace(ItemStack itemstack) { return itemstack.is(Items.SADDLE) && !this.hasItem() && entityhorseabstract.isSaddleable(); -@@ -35,7 +55,7 @@ - return entityhorseabstract.isSaddleable(); - } +@@ -46,7 +66,7 @@ }); -- this.addSlot(new ArmorSlot(this, this.armorContainer, entityhorseabstract, EnumItemSlot.BODY, 0, 8, 36, (MinecraftKey) null) { -+ this.addSlot(new ArmorSlot(this.armorContainer, entityhorseabstract, EnumItemSlot.BODY, 0, 8, 36, (MinecraftKey) null) { // CraftBukkit - decompile error + MinecraftKey minecraftkey = entityhorseabstract instanceof EntityLlama ? ContainerHorse.LLAMA_ARMOR_SLOT_SPRITE : ContainerHorse.ARMOR_SLOT_SPRITE; + +- this.addSlot(new ArmorSlot(this, this.armorContainer, entityhorseabstract, EnumItemSlot.BODY, 0, 8, 36, minecraftkey) { ++ this.addSlot(new ArmorSlot(this.armorContainer, entityhorseabstract, EnumItemSlot.BODY, 0, 8, 36, minecraftkey) { // CraftBukkit - decompile error @Override public boolean mayPlace(ItemStack itemstack) { return entityhorseabstract.isEquippableInSlot(itemstack, EnumItemSlot.BODY); diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch index f66a82c799..35cd2ec5b2 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 -@@ -13,6 +13,12 @@ +@@ -12,6 +12,12 @@ import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.level.World; @@ -13,7 +13,7 @@ public class ContainerPlayer extends AbstractCraftingMenu { public static final int CONTAINER_ID = 0; -@@ -40,9 +46,15 @@ +@@ -38,9 +44,15 @@ private static final EnumItemSlot[] SLOT_IDS = new EnumItemSlot[]{EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET}; public final boolean active; private final EntityHuman owner; @@ -30,7 +30,7 @@ this.active = flag; this.owner = entityhuman; this.addResultSlot(entityhuman, 154, 28); -@@ -56,7 +68,7 @@ +@@ -54,7 +66,7 @@ } this.addStandardInventorySlots(playerinventory, 8, 84); @@ -39,7 +39,7 @@ @Override public void setByPlayer(ItemStack itemstack, ItemStack itemstack1) { entityhuman.onEquipItem(EnumItemSlot.OFFHAND, itemstack1, itemstack); -@@ -192,4 +204,17 @@ +@@ -190,4 +202,17 @@ protected EntityHuman owner() { return this.owner; } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch index e3c0b04af6..88d269485e 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch @@ -66,7 +66,7 @@ return stillValid(this.access, entityhuman, Blocks.STONECUTTER); } -@@ -154,7 +185,7 @@ +@@ -158,7 +189,7 @@ } void setupResultSlot(int i) { diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemEgg.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemEgg.patch index 185fb658eb..29a269378f 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemEgg.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemEgg.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/item/ItemEgg.java +++ b/net/minecraft/world/item/ItemEgg.java -@@ -23,10 +23,18 @@ +@@ -25,10 +25,18 @@ public EnumInteractionResult use(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.getItemInHand(enumhand); - world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); + // world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down if (world instanceof WorldServer worldserver) { -- IProjectile.spawnProjectileFromRotation(EntityEgg::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F); +- IProjectile.spawnProjectileFromRotation(EntityEgg::new, worldserver, itemstack, entityhuman, 0.0F, ItemEgg.PROJECTILE_SHOOT_POWER, 1.0F); + // CraftBukkit start -+ if (IProjectile.spawnProjectileFromRotation(EntityEgg::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F).isRemoved()) { ++ if (IProjectile.spawnProjectileFromRotation(EntityEgg::new, worldserver, itemstack, entityhuman, 0.0F, ItemEgg.PROJECTILE_SHOOT_POWER, 1.0F).isRemoved()) { + if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { + ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); + } diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch index fc2a620745..32f38cf3cc 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/item/ItemEnderPearl.java +++ b/net/minecraft/world/item/ItemEnderPearl.java -@@ -21,10 +21,17 @@ +@@ -23,10 +23,17 @@ public EnumInteractionResult use(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.getItemInHand(enumhand); - world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); if (world instanceof WorldServer worldserver) { -- IProjectile.spawnProjectileFromRotation(EntityEnderPearl::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F); +- IProjectile.spawnProjectileFromRotation(EntityEnderPearl::new, worldserver, itemstack, entityhuman, 0.0F, ItemEnderPearl.PROJECTILE_SHOOT_POWER, 1.0F); + // CraftBukkit start -+ if (IProjectile.spawnProjectileFromRotation(EntityEnderPearl::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F).isRemoved()) { ++ if (IProjectile.spawnProjectileFromRotation(EntityEnderPearl::new, worldserver, itemstack, entityhuman, 0.0F, ItemEnderPearl.PROJECTILE_SHOOT_POWER, 1.0F).isRemoved()) { + if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { + ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); + } diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemFishingRod.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemFishingRod.patch index 80a8d1b9db..e75d434c7a 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemFishingRod.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemFishingRod.patch @@ -23,9 +23,9 @@ int j = (int) (EnchantmentManager.getFishingTimeReduction(worldserver, itemstack, entityhuman) * 20.0F); int k = EnchantmentManager.getFishingLuckBonus(worldserver, itemstack, entityhuman); -- IProjectile.spawnProjectile(new EntityFishingHook(entityhuman, world, k, j, itemstack), worldserver, itemstack); +- IProjectile.spawnProjectile(new EntityFishingHook(entityhuman, world, k, j), worldserver, itemstack); + // CraftBukkit start -+ EntityFishingHook entityfishinghook = new EntityFishingHook(entityhuman, world, k, j, itemstack); ++ EntityFishingHook entityfishinghook = new EntityFishingHook(entityhuman, world, k, j); + PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.FishHook) entityfishinghook.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand), PlayerFishEvent.State.FISHING); + world.getCraftServer().getPluginManager().callEvent(playerFishEvent); + diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemSnowball.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemSnowball.patch index b670cf0f83..1bbc3503dc 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemSnowball.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemSnowball.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemSnowball.java +++ b/net/minecraft/world/item/ItemSnowball.java -@@ -23,13 +23,21 @@ +@@ -25,13 +25,21 @@ public EnumInteractionResult use(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.getItemInHand(enumhand); @@ -8,8 +8,8 @@ + // CraftBukkit start - moved down + // world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); if (world instanceof WorldServer worldserver) { -- IProjectile.spawnProjectileFromRotation(EntitySnowball::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F); -+ if (IProjectile.spawnProjectileFromRotation(EntitySnowball::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F).isAlive()) { +- IProjectile.spawnProjectileFromRotation(EntitySnowball::new, worldserver, itemstack, entityhuman, 0.0F, ItemSnowball.PROJECTILE_SHOOT_POWER, 1.0F); ++ if (IProjectile.spawnProjectileFromRotation(EntitySnowball::new, worldserver, itemstack, entityhuman, 0.0F, ItemSnowball.PROJECTILE_SHOOT_POWER, 1.0F).isAlive()) { + itemstack.consume(1, entityhuman); + + world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); 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 bf9aba516c..5cb394abff 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 -@@ -96,17 +96,51 @@ +@@ -96,18 +96,52 @@ import org.apache.commons.lang3.mutable.MutableBoolean; import org.slf4j.Logger; @@ -40,6 +40,7 @@ + public final class ItemStack implements DataComponentHolder { + private static final List OP_NBT_WARNING = List.of(IChatBaseComponent.translatable("item.op_warning.line1").withStyle(EnumChatFormat.RED, EnumChatFormat.BOLD), IChatBaseComponent.translatable("item.op_warning.line2").withStyle(EnumChatFormat.RED), IChatBaseComponent.translatable("item.op_warning.line3").withStyle(EnumChatFormat.RED)); public static final Codec CODEC = Codec.lazyInitialized(() -> { - return RecordCodecBuilder.create((instance) -> { + return RecordCodecBuilder.create((instance) -> { // CraftBukkit - decompile error @@ -54,7 +55,7 @@ return instance.group(Item.CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> { return itemstack.components.asPatch(); })).apply(instance, (holder, datacomponentpatch) -> { -@@ -131,19 +165,25 @@ +@@ -132,19 +166,25 @@ if (i <= 0) { return ItemStack.EMPTY; } else { @@ -84,7 +85,7 @@ DataComponentPatch.STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.components.asPatch()); } } -@@ -186,7 +226,7 @@ +@@ -187,7 +227,7 @@ return dataresult.isError() ? dataresult.map((unit) -> { return itemstack; @@ -93,7 +94,7 @@ int i = itemstack.getCount(); return "Item stack with stack size of " + i + " was larger than maximum: " + itemstack.getMaxStackSize(); -@@ -289,8 +329,9 @@ +@@ -294,8 +334,9 @@ j = itemstack.getMaxStackSize(); } while (i <= j); @@ -104,7 +105,7 @@ }); } } -@@ -372,15 +413,173 @@ +@@ -377,15 +418,173 @@ return EnumInteractionResult.PASS; } else { Item item = this.getItem(); @@ -280,7 +281,7 @@ return enuminteractionresult; } -@@ -487,6 +686,21 @@ +@@ -492,6 +691,21 @@ public void hurtAndBreak(int i, WorldServer worldserver, @Nullable EntityPlayer entityplayer, Consumer consumer) { int j = this.processDurabilityChange(i, worldserver, entityplayer); @@ -302,7 +303,7 @@ if (j != 0) { this.applyDamage(this.getDamageValue() + j, entityplayer, consumer); -@@ -506,6 +720,11 @@ +@@ -511,6 +725,11 @@ this.setDamageValue(i); if (this.isBroken()) { Item item = this.getItem(); @@ -314,7 +315,7 @@ this.shrink(1); consumer.accept(item); -@@ -765,6 +984,12 @@ +@@ -770,6 +989,12 @@ return this.getItem().useOnRelease(this); } @@ -327,7 +328,7 @@ @Nullable public T set(DataComponentType datacomponenttype, @Nullable T t0) { return this.components.set(datacomponenttype, t0); -@@ -846,7 +1071,7 @@ +@@ -858,7 +1083,7 @@ } private void addToTooltip(DataComponentType datacomponenttype, Item.b item_b, Consumer consumer, TooltipFlag tooltipflag) { @@ -336,7 +337,7 @@ if (t0 != null) { t0.addToTooltip(item_b, consumer, tooltipflag); -@@ -1073,6 +1298,13 @@ +@@ -1091,6 +1316,13 @@ EnchantmentManager.forEachModifier(this, enumitemslot, biconsumer); } @@ -350,7 +351,7 @@ public IChatBaseComponent getDisplayName() { IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.empty().append(this.getHoverName()); -@@ -1135,7 +1367,7 @@ +@@ -1153,7 +1385,7 @@ } public void consume(int i, @Nullable EntityLiving entityliving) { diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemTrident.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemTrident.patch index dcc3a868c9..ec20c66e6b 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemTrident.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemTrident.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemTrident.java +++ b/net/minecraft/world/item/ItemTrident.java -@@ -85,9 +85,19 @@ +@@ -86,9 +86,19 @@ if (world instanceof WorldServer) { WorldServer worldserver = (WorldServer) world; @@ -21,7 +21,7 @@ if (entityhuman.hasInfiniteMaterials()) { entitythrowntrident.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY; -@@ -97,6 +107,10 @@ +@@ -98,6 +108,10 @@ world.playSound((EntityHuman) null, (Entity) entitythrowntrident, (SoundEffect) holder.value(), SoundCategory.PLAYERS, 1.0F, 1.0F); return true; diff --git a/paper-server/nms-patches/net/minecraft/world/item/alchemy/PotionContents.patch b/paper-server/nms-patches/net/minecraft/world/item/alchemy/PotionContents.patch index a6181a2c5b..63fdb46f42 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/alchemy/PotionContents.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/alchemy/PotionContents.patch @@ -9,7 +9,7 @@ } public int getColor() { -@@ -176,7 +176,7 @@ +@@ -172,7 +172,7 @@ if (((MobEffectList) mobeffect.getEffect().value()).isInstantenous()) { ((MobEffectList) mobeffect.getEffect().value()).applyInstantenousEffect(worldserver, entityhuman2, entityhuman2, entityliving, mobeffect.getAmplifier(), 1.0D); } else { diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch index e69ac74e7d..82f29fa191 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/CraftingManager.java +++ b/net/minecraft/world/item/crafting/CraftingManager.java -@@ -38,6 +38,11 @@ +@@ -39,6 +39,11 @@ import net.minecraft.world.level.World; import org.slf4j.Logger; @@ -12,7 +12,7 @@ public class CraftingManager extends ResourceDataAbstract implements RecipeAccess { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -109,7 +114,25 @@ +@@ -111,7 +116,25 @@ CraftingManager.LOGGER.info("Loaded {} recipes", recipemap.values().size()); } @@ -38,7 +38,7 @@ List> list = new ArrayList(); List list1 = CraftingManager.RECIPE_PROPERTY_SETS.entrySet().stream().map((entry) -> { return new CraftingManager.b((ResourceKey) entry.getKey(), (CraftingManager.c) entry.getValue()); -@@ -128,7 +151,7 @@ +@@ -130,7 +153,7 @@ RecipeStonecutting recipestonecutting = (RecipeStonecutting) irecipe; if (isIngredientEnabled(featureflagset, recipestonecutting.input()) && recipestonecutting.resultDisplay().isEnabled(featureflagset)) { @@ -47,7 +47,7 @@ } } -@@ -170,7 +193,10 @@ +@@ -172,7 +195,10 @@ } public > Optional> getRecipeFor(Recipes recipes, I i0, World world) { @@ -59,7 +59,7 @@ } public Optional> byKey(ResourceKey> resourcekey) { -@@ -181,7 +207,7 @@ +@@ -183,7 +209,7 @@ private > RecipeHolder byKeyTyped(Recipes recipes, ResourceKey> resourcekey) { RecipeHolder recipeholder = this.recipes.byKey(resourcekey); @@ -68,7 +68,7 @@ } public Map, RecipePropertySet> getSynchronizedItemProperties() { -@@ -229,6 +255,22 @@ +@@ -231,6 +257,22 @@ return new RecipeHolder<>(resourcekey, irecipe); } diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch index 207242eaf8..bf6a66a895 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch @@ -1,9 +1,21 @@ --- a/net/minecraft/world/item/crafting/RecipeItemStack.java +++ b/net/minecraft/world/item/crafting/RecipeItemStack.java -@@ -42,6 +42,24 @@ +@@ -21,6 +21,11 @@ + import net.minecraft.world.item.crafting.display.SlotDisplay; + import net.minecraft.world.level.IMaterial; + ++// CraftBukkit start ++import java.util.List; ++import javax.annotation.Nullable; ++// CraftBukkit end ++ + public final class RecipeItemStack implements AutoRecipeStackManager.a>, Predicate { + + public static final StreamCodec CONTENTS_STREAM_CODEC = ByteBufCodecs.holderSet(Registries.ITEM).map(RecipeItemStack::new, (recipeitemstack) -> { +@@ -38,6 +43,24 @@ + return recipeitemstack.values; + }); private final HolderSet values; - @Nullable - private List> items; + // CraftBukkit start + @Nullable + private List itemStacks; @@ -25,7 +37,7 @@ private RecipeItemStack(HolderSet holderset) { holderset.unwrap().ifRight((list) -> { -@@ -72,6 +90,17 @@ +@@ -70,6 +93,17 @@ } public boolean test(ItemStack itemstack) { @@ -40,10 +52,10 @@ + return false; + } + // CraftBukkit end - List> list = this.items(); + return itemstack.is(this.values); + } - for (int i = 0; i < list.size(); ++i) { -@@ -85,7 +114,7 @@ +@@ -79,7 +113,7 @@ public boolean equals(Object object) { if (object instanceof RecipeItemStack recipeitemstack) { diff --git a/paper-server/nms-patches/net/minecraft/world/item/trading/IMerchant.patch b/paper-server/nms-patches/net/minecraft/world/item/trading/IMerchant.patch index 0ea0e940d0..86c4e4db67 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/trading/IMerchant.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/trading/IMerchant.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/item/trading/IMerchant.java +++ b/net/minecraft/world/item/trading/IMerchant.java -@@ -52,4 +52,6 @@ - } - +@@ -54,4 +54,6 @@ boolean isClientSide(); + + boolean stillValid(EntityHuman entityhuman); + + org.bukkit.craftbukkit.inventory.CraftMerchant getCraftMerchant(); // CraftBukkit } diff --git a/paper-server/nms-patches/net/minecraft/world/level/ServerExplosion.patch b/paper-server/nms-patches/net/minecraft/world/level/ServerExplosion.patch index e2c17adb06..424ef5419e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/ServerExplosion.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/ServerExplosion.patch @@ -93,7 +93,7 @@ + vec3d = (event.isCancelled()) ? Vec3D.ZERO : new Vec3D(event.getFinalKnockback().getX(), event.getFinalKnockback().getY(), event.getFinalKnockback().getZ()).subtract(entity.getDeltaMovement()); + } + // CraftBukkit end - entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d)); + entity.push(vec3d); if (entity instanceof EntityHuman) { EntityHuman entityhuman = (EntityHuman) entity; @@ -235,10 +290,62 @@ 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 1fdff914ea..37e1193dd7 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 -@@ -80,6 +80,28 @@ +@@ -81,6 +81,28 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.scores.Scoreboard; @@ -29,7 +29,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable { public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); -@@ -120,7 +142,42 @@ +@@ -121,7 +143,42 @@ private final DamageSources damageSources; private long subTickCount; @@ -73,7 +73,7 @@ this.levelData = worlddatamutable; this.dimensionTypeRegistration = holder; final DimensionManager dimensionmanager = (DimensionManager) holder.value(); -@@ -128,15 +185,15 @@ +@@ -129,15 +186,15 @@ this.dimension = resourcekey; this.isClientSide = flag; if (dimensionmanager.coordinateScale() != 1.0D) { @@ -92,7 +92,7 @@ } }; } else { -@@ -149,6 +206,42 @@ +@@ -150,6 +207,42 @@ this.neighborUpdater = new CollectingNeighborUpdater(this, j); this.registryAccess = iregistrycustom; this.damageSources = new DamageSources(iregistrycustom); @@ -135,7 +135,7 @@ } @Override -@@ -206,6 +299,18 @@ +@@ -207,6 +300,18 @@ @Override public boolean setBlock(BlockPosition blockposition, IBlockData iblockdata, int i, int j) { @@ -154,7 +154,7 @@ if (this.isOutsideBuildHeight(blockposition)) { return false; } else if (!this.isClientSide && this.isDebug()) { -@@ -213,13 +318,29 @@ +@@ -214,13 +319,29 @@ } else { Chunk chunk = this.getChunkAt(blockposition); Block block = iblockdata.getBlock(); @@ -185,7 +185,7 @@ if (iblockdata2 == iblockdata) { if (iblockdata1 != iblockdata2) { this.setBlocksDirty(blockposition, iblockdata1, iblockdata2); -@@ -246,12 +367,69 @@ +@@ -247,12 +368,69 @@ this.onBlockStateChange(blockposition, iblockdata1, iblockdata2); } @@ -255,7 +255,7 @@ public void onBlockStateChange(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {} @Override -@@ -339,6 +517,14 @@ +@@ -340,6 +518,14 @@ @Override public IBlockData getBlockState(BlockPosition blockposition) { @@ -270,7 +270,7 @@ if (this.isOutsideBuildHeight(blockposition)) { return Blocks.VOID_AIR.defaultBlockState(); } else { -@@ -509,6 +695,16 @@ +@@ -510,6 +696,16 @@ @Nullable @Override public TileEntity getBlockEntity(BlockPosition blockposition) { @@ -287,7 +287,7 @@ return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, Chunk.EnumTileEntityState.IMMEDIATE)); } -@@ -516,6 +712,12 @@ +@@ -517,6 +713,12 @@ BlockPosition blockposition = tileentity.getBlockPos(); if (!this.isOutsideBuildHeight(blockposition)) { @@ -300,7 +300,7 @@ this.getChunkAt(blockposition).addAndRegisterBlockEntity(tileentity); } } -@@ -645,7 +847,7 @@ +@@ -643,7 +845,7 @@ for (int k = 0; k < j; ++k) { EntityComplexPart entitycomplexpart = aentitycomplexpart[k]; diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/Block.patch b/paper-server/nms-patches/net/minecraft/world/level/block/Block.patch index fe2c722992..883f508361 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/Block.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/Block.patch @@ -24,7 +24,7 @@ dropResources(iblockdata, world, blockposition, tileentity, entityhuman, itemstack); } -@@ -494,15 +500,23 @@ +@@ -490,15 +496,23 @@ return this.builtInRegistryHolder; } 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 87549359ab..cbeb65ab02 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 @@ -59,7 +59,7 @@ } private boolean kickVillagerOutOfBed(World world, BlockPosition blockposition) { -@@ -325,6 +357,11 @@ +@@ -320,6 +352,11 @@ BlockPosition blockposition1 = blockposition.relative((EnumDirection) iblockdata.getValue(BlockBed.FACING)); world.setBlock(blockposition1, (IBlockData) iblockdata.setValue(BlockBed.PART, BlockPropertyBedPart.HEAD), 3); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch index 7ad5aa9850..181c4a8700 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch @@ -9,7 +9,7 @@ } } } -@@ -302,7 +302,7 @@ +@@ -297,7 +297,7 @@ ItemStack itemstack = new ItemStack(this); itemstack.applyComponents(tileentitybeehive.collectComponents()); @@ -18,3 +18,12 @@ EntityItem entityitem = new EntityItem(world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack); entityitem.setDefaultPickUpDelay(); +@@ -332,7 +332,7 @@ + ItemStack itemstack = super.getCloneItemStack(iworldreader, blockposition, iblockdata, flag); + + if (flag) { +- itemstack.set(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY.with(BlockBeehive.HONEY_LEVEL, (Comparable) ((Integer) iblockdata.getValue(BlockBeehive.HONEY_LEVEL)))); ++ itemstack.set(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY.with(BlockBeehive.HONEY_LEVEL, ((Integer) iblockdata.getValue(BlockBeehive.HONEY_LEVEL)))); // CraftBukkit - decompile error + } + + return itemstack; diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch index dcc6445b40..b1895f817a 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 @@ -9,7 +9,7 @@ } super.entityInside(iblockdata, world, blockposition, entity); -@@ -224,6 +224,11 @@ +@@ -219,6 +219,11 @@ if (world instanceof WorldServer worldserver) { if (iprojectile.isOnFire() && iprojectile.mayInteract(worldserver, blockposition) && !(Boolean) iblockdata.getValue(BlockCampfire.LIT) && !(Boolean) iblockdata.getValue(BlockCampfire.WATERLOGGED)) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockChest.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockChest.patch index 4f8016bc7f..6c31f92f11 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockChest.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockChest.patch @@ -65,7 +65,7 @@ @Override public MapCodec codec() { return BlockChest.CODEC; -@@ -262,7 +277,7 @@ +@@ -257,7 +272,7 @@ @Override public DoubleBlockFinder.Result combine(IBlockData iblockdata, World world, BlockPosition blockposition, boolean flag) { @@ -74,7 +74,7 @@ if (flag) { bipredicate = (generatoraccess, blockposition1) -> { -@@ -278,7 +293,14 @@ +@@ -273,7 +288,14 @@ @Nullable @Override protected ITileInventory getMenuProvider(IBlockData iblockdata, World world, BlockPosition blockposition) { 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 e858180ce0..c6903bbe80 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 @@ -12,7 +12,7 @@ public class BlockComposter extends Block implements IInventoryHolder { public static final MapCodec CODEC = simpleCodec(BlockComposter::new); -@@ -267,7 +272,14 @@ +@@ -269,7 +274,14 @@ int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL); if (i < 7 && BlockComposter.COMPOSTABLES.containsKey(itemstack.getItem())) { @@ -28,7 +28,7 @@ itemstack.shrink(1); return iblockdata1; -@@ -277,6 +289,14 @@ +@@ -279,6 +291,14 @@ } public static IBlockData extractProduce(Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) { @@ -43,7 +43,7 @@ if (!world.isClientSide) { Vec3D vec3d = Vec3D.atLowerCornerWithOffset(blockposition, 0.5D, 1.01D, 0.5D).offsetRandom(world.random, 0.7F); EntityItem entityitem = new EntityItem(world, vec3d.x(), vec3d.y(), vec3d.z(), new ItemStack(Items.BONE_MEAL)); -@@ -300,10 +320,16 @@ +@@ -302,10 +322,16 @@ } static IBlockData addItem(@Nullable Entity entity, IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) { @@ -61,7 +61,7 @@ return iblockdata; } else { int j = i + 1; -@@ -352,7 +378,8 @@ +@@ -354,7 +380,8 @@ public IWorldInventory getContainer(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL); @@ -71,7 +71,7 @@ } public static class ContainerOutput extends InventorySubcontainer implements IWorldInventory { -@@ -367,6 +394,7 @@ +@@ -369,6 +396,7 @@ this.state = iblockdata; this.level = generatoraccess; this.pos = blockposition; @@ -79,7 +79,7 @@ } @Override -@@ -391,8 +419,15 @@ +@@ -393,8 +421,15 @@ @Override public void setChanged() { @@ -95,7 +95,7 @@ } } -@@ -405,6 +440,7 @@ +@@ -407,6 +442,7 @@ public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { super(1); @@ -103,7 +103,7 @@ this.state = iblockdata; this.level = generatoraccess; this.pos = blockposition; -@@ -447,8 +483,9 @@ +@@ -449,8 +485,9 @@ public static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDirtSnowSpreadable.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDirtSnowSpreadable.patch index 187fabc567..9254168a75 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDirtSnowSpreadable.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDirtSnowSpreadable.patch @@ -16,8 +16,8 @@ BlockPosition blockposition1 = blockposition.offset(randomsource.nextInt(3) - 1, randomsource.nextInt(5) - 3, randomsource.nextInt(3) - 1); if (worldserver.getBlockState(blockposition1).is(Blocks.DIRT) && canPropagate(iblockdata1, worldserver, blockposition1)) { -- worldserver.setBlockAndUpdate(blockposition1, (IBlockData) iblockdata1.setValue(BlockDirtSnowSpreadable.SNOWY, worldserver.getBlockState(blockposition1.above()).is(Blocks.SNOW))); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, (IBlockData) iblockdata1.setValue(BlockDirtSnowSpreadable.SNOWY, worldserver.getBlockState(blockposition1.above()).is(Blocks.SNOW))); // CraftBukkit +- worldserver.setBlockAndUpdate(blockposition1, (IBlockData) iblockdata1.setValue(BlockDirtSnowSpreadable.SNOWY, isSnowySetting(worldserver.getBlockState(blockposition1.above())))); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, (IBlockData) iblockdata1.setValue(BlockDirtSnowSpreadable.SNOWY, isSnowySetting(worldserver.getBlockState(blockposition1.above())))); // CraftBukkit } } } 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 2e2f29d8df..0ca61f9a60 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 -@@ -211,11 +211,12 @@ +@@ -206,11 +206,12 @@ } private void popBook(IBlockData iblockdata, World world, BlockPosition blockposition) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSponge.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSponge.patch index cb7d20fd1b..485c397648 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSponge.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSponge.patch @@ -26,7 +26,7 @@ @@ -67,8 +75,10 @@ if (blockposition1.equals(blockposition)) { - return true; + return BlockPosition.b.ACCEPT; } else { - IBlockData iblockdata = world.getBlockState(blockposition1); - Fluid fluid = world.getFluidState(blockposition1); @@ -36,14 +36,14 @@ + // CraftBukkit end if (!fluid.is(TagsFluid.WATER)) { - return false; + return BlockPosition.b.SKIP; @@ -78,27 +88,64 @@ if (block instanceof IFluidSource) { IFluidSource ifluidsource = (IFluidSource) block; - if (!ifluidsource.pickupBlock((EntityHuman) null, world, blockposition1, iblockdata).isEmpty()) { + if (!ifluidsource.pickupBlock((EntityHuman) null, blockList, blockposition1, iblockdata).isEmpty()) { // CraftBukkit - return true; + return BlockPosition.b.ACCEPT; } } @@ -52,7 +52,7 @@ + blockList.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3); // CraftBukkit } else { if (!iblockdata.is(Blocks.KELP) && !iblockdata.is(Blocks.KELP_PLANT) && !iblockdata.is(Blocks.SEAGRASS) && !iblockdata.is(Blocks.TALL_SEAGRASS)) { - return false; + return BlockPosition.b.SKIP; } - TileEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition1) : null; @@ -66,7 +66,7 @@ + // CraftBukkit end } - return true; + return BlockPosition.b.ACCEPT; } } - }) > 1; 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 355fb68c3d..cfe307b6d2 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 @@ -4,8 +4,8 @@ if (world instanceof WorldServer worldserver) { if (world.getDifficulty() != EnumDifficulty.PEACEFUL && entity instanceof EntityLiving entityliving) { if (!entityliving.isInvulnerableTo(worldserver, 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 +- entityliving.addEffect(this.getBeeInteractionEffect()); ++ entityliving.addEffect(this.getBeeInteractionEffect(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.WITHER_ROSE); // CraftBukkit } } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/SculkCatalystBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/SculkCatalystBlock.patch index adff3a8d5a..8c2b3aa355 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/SculkCatalystBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/SculkCatalystBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkCatalystBlock.java +++ b/net/minecraft/world/level/block/SculkCatalystBlock.java -@@ -68,9 +68,16 @@ +@@ -63,9 +63,16 @@ @Override protected void spawnAfterBreak(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) { super.spawnAfterBreak(iblockdata, worldserver, blockposition, itemstack, flag); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch index d66c4e3ea6..7621da01e6 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch @@ -31,7 +31,7 @@ TileEntity tileentity = world.getBlockEntity(blockposition); if (tileentity instanceof SculkSensorBlockEntity) { -@@ -207,6 +224,15 @@ +@@ -202,6 +219,15 @@ } public static void deactivate(World world, BlockPosition blockposition, IBlockData iblockdata) { @@ -47,7 +47,7 @@ world.setBlock(blockposition, (IBlockData) ((IBlockData) iblockdata.setValue(SculkSensorBlock.PHASE, SculkSensorPhase.COOLDOWN)).setValue(SculkSensorBlock.POWER, 0), 3); world.scheduleTick(blockposition, iblockdata.getBlock(), 10); updateNeighbours(world, blockposition, iblockdata); -@@ -218,6 +244,15 @@ +@@ -213,6 +239,15 @@ } public void activate(@Nullable Entity entity, World world, BlockPosition blockposition, IBlockData iblockdata, int i, int j) { @@ -63,7 +63,7 @@ world.setBlock(blockposition, (IBlockData) ((IBlockData) iblockdata.setValue(SculkSensorBlock.PHASE, SculkSensorPhase.ACTIVE)).setValue(SculkSensorBlock.POWER, i), 3); world.scheduleTick(blockposition, iblockdata.getBlock(), this.getActiveTicks()); updateNeighbours(world, blockposition, iblockdata); -@@ -298,9 +333,16 @@ +@@ -293,9 +328,16 @@ @Override protected void spawnAfterBreak(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) { super.spawnAfterBreak(iblockdata, worldserver, blockposition, itemstack, flag); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/SculkShriekerBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/SculkShriekerBlock.patch index 41ec5aee1c..57ab988569 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/SculkShriekerBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/SculkShriekerBlock.patch @@ -8,7 +8,7 @@ worldserver.getBlockEntity(blockposition, TileEntityTypes.SCULK_SHRIEKER).ifPresent((sculkshriekerblockentity) -> { sculkshriekerblockentity.tryShriek(worldserver, entityplayer); }); -@@ -145,10 +146,17 @@ +@@ -140,10 +141,17 @@ @Override protected void spawnAfterBreak(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) { super.spawnAfterBreak(iblockdata, worldserver, blockposition, itemstack, flag); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/SculkVeinBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/SculkVeinBlock.patch index f9aa1f541a..768898a5e6 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/SculkVeinBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/SculkVeinBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkVeinBlock.java +++ b/net/minecraft/world/level/block/SculkVeinBlock.java -@@ -110,10 +110,11 @@ +@@ -101,10 +101,11 @@ @Override public int attemptUseCharge(SculkSpreader.a sculkspreader_a, GeneratorAccess generatoraccess, BlockPosition blockposition, RandomSource randomsource, SculkSpreader sculkspreader, boolean flag) { @@ -14,7 +14,7 @@ IBlockData iblockdata = generatoraccess.getBlockState(blockposition); TagKey tagkey = sculkspreader.replaceableBlocks(); Iterator iterator = EnumDirection.allShuffled(randomsource).iterator(); -@@ -128,7 +129,11 @@ +@@ -119,7 +120,11 @@ if (iblockdata1.is(tagkey)) { IBlockData iblockdata2 = Blocks.SCULK.defaultBlockState(); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch index 28bcd24247..5f4ff8d39b 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntity.java +++ b/net/minecraft/world/level/block/entity/TileEntity.java -@@ -27,8 +27,18 @@ +@@ -26,8 +26,18 @@ import net.minecraft.world.level.block.state.IBlockData; import org.slf4j.Logger; @@ -19,7 +19,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); private final TileEntityTypes type; @Nullable -@@ -75,7 +85,16 @@ +@@ -74,7 +84,16 @@ return this.level != null; } @@ -37,7 +37,7 @@ public final void loadWithComponents(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) { this.loadAdditional(nbttagcompound, holderlookup_a); -@@ -115,6 +134,11 @@ +@@ -114,6 +133,11 @@ }).ifPresent((nbtbase) -> { nbttagcompound.merge((NBTTagCompound) nbtbase); }); @@ -49,7 +49,7 @@ return nbttagcompound; } -@@ -277,12 +301,18 @@ +@@ -263,13 +287,19 @@ } public final void applyComponents(DataComponentMap datacomponentmap, DataComponentPatch datacomponentpatch) { @@ -62,6 +62,7 @@ final Set> set = new HashSet(); set.add(DataComponents.BLOCK_ENTITY_DATA); + set.add(DataComponents.BLOCK_STATE); final PatchedDataComponentMap patcheddatacomponentmap = PatchedDataComponentMap.fromPatch(datacomponentmap, datacomponentpatch); - this.applyImplicitComponents(new TileEntity.b(this) { @@ -69,7 +70,7 @@ @Nullable @Override public T get(DataComponentType datacomponenttype) { -@@ -300,6 +330,10 @@ +@@ -287,6 +317,10 @@ DataComponentPatch datacomponentpatch1 = datacomponentpatch.forget(set::contains); this.components = datacomponentpatch1.split().added(); @@ -80,7 +81,7 @@ } protected void collectImplicitComponents(DataComponentMap.a datacomponentmap_a) {} -@@ -334,6 +368,15 @@ +@@ -321,6 +355,15 @@ } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBanner.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBanner.patch index bacad409a1..ab67e1893e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBanner.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBanner.patch @@ -11,7 +11,7 @@ public class TileEntityBanner extends TileEntity implements INamableTileEntity { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -80,7 +84,7 @@ +@@ -74,7 +78,7 @@ BannerPatternLayers.CODEC.parse(holderlookup_a.createSerializationContext(DynamicOpsNBT.INSTANCE), nbttagcompound.get("patterns")).resultOrPartial((s) -> { TileEntityBanner.LOGGER.error("Failed to parse banner patterns: '{}'", s); }).ifPresent((bannerpatternlayers) -> { @@ -20,7 +20,7 @@ }); } -@@ -114,7 +118,7 @@ +@@ -108,7 +112,7 @@ @Override protected void applyImplicitComponents(TileEntity.b tileentity_b) { super.applyImplicitComponents(tileentity_b); @@ -29,7 +29,7 @@ this.name = (IChatBaseComponent) tileentity_b.get(DataComponents.CUSTOM_NAME); } -@@ -130,4 +134,13 @@ +@@ -124,4 +128,13 @@ nbttagcompound.remove("patterns"); nbttagcompound.remove("CustomName"); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch index 8874e64496..28593a6d48 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch @@ -55,37 +55,35 @@ }); if (!list.isEmpty()) { super.setChanged(); -@@ -151,7 +162,19 @@ +@@ -151,7 +162,17 @@ } - public void addOccupant(Entity entity) { + public void addOccupant(EntityBee entitybee) { - if (this.stored.size() < 3) { + if (this.stored.size() < this.maxBees) { // CraftBukkit + // CraftBukkit start + if (this.level != null) { -+ org.bukkit.event.entity.EntityEnterBlockEvent event = new org.bukkit.event.entity.EntityEnterBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, getBlockPos())); ++ org.bukkit.event.entity.EntityEnterBlockEvent event = new org.bukkit.event.entity.EntityEnterBlockEvent(entitybee.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, getBlockPos())); + org.bukkit.Bukkit.getPluginManager().callEvent(event); + if (event.isCancelled()) { -+ if (entity instanceof EntityBee) { -+ ((EntityBee) entity).setStayOutOfHiveCountdown(400); -+ } ++ entitybee.setStayOutOfHiveCountdown(400); + return; + } + } + // CraftBukkit end - entity.stopRiding(); - entity.ejectPassengers(); - this.storeBee(TileEntityBeehive.c.of(entity)); -@@ -170,7 +193,7 @@ - this.level.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entity, this.getBlockState())); + entitybee.stopRiding(); + entitybee.ejectPassengers(); + entitybee.dropLeash(); +@@ -167,7 +188,7 @@ + this.level.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entitybee, this.getBlockState())); } -- entity.discard(); -+ entity.discard(EntityRemoveEvent.Cause.ENTER_BLOCK); // CraftBukkit - add Bukkit remove cause +- entitybee.discard(); ++ entitybee.discard(EntityRemoveEvent.Cause.ENTER_BLOCK); // CraftBukkit - add Bukkit remove cause super.setChanged(); } } -@@ -180,7 +203,13 @@ +@@ -177,7 +198,13 @@ } private static boolean releaseOccupant(World world, BlockPosition blockposition, IBlockData iblockdata, TileEntityBeehive.c tileentitybeehive_c, @Nullable List list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, @Nullable BlockPosition blockposition1) { @@ -100,7 +98,7 @@ return false; } else { EnumDirection enumdirection = (EnumDirection) iblockdata.getValue(BlockBeehive.FACING); -@@ -193,6 +222,18 @@ +@@ -190,6 +217,18 @@ Entity entity = tileentitybeehive_c.createEntity(world, blockposition); if (entity != null) { @@ -119,7 +117,7 @@ if (entity instanceof EntityBee) { EntityBee entitybee = (EntityBee) entity; -@@ -223,6 +264,7 @@ +@@ -220,6 +259,7 @@ list.add(entitybee); } @@ -127,7 +125,7 @@ float f = entity.getBbWidth(); double d0 = flag ? 0.0D : 0.55D + (double) (f / 2.0F); double d1 = (double) blockposition.getX() + 0.5D + d0 * (double) enumdirection.getStepX(); -@@ -230,11 +272,12 @@ +@@ -227,11 +267,12 @@ double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getStepZ(); entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot()); @@ -141,7 +139,7 @@ } else { return false; } -@@ -259,6 +302,10 @@ +@@ -256,6 +297,10 @@ if (releaseOccupant(world, blockposition, iblockdata, tileentitybeehive_hivebee.toOccupant(), (List) null, tileentitybeehive_releasestatus, blockposition1)) { flag = true; iterator.remove(); @@ -152,7 +150,7 @@ } } } -@@ -285,7 +332,7 @@ +@@ -282,7 +327,7 @@ @Override protected void loadAdditional(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) { super.loadAdditional(nbttagcompound, holderlookup_a); @@ -161,7 +159,7 @@ if (nbttagcompound.contains("bees")) { TileEntityBeehive.c.LIST_CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("bees")).resultOrPartial((s) -> { TileEntityBeehive.LOGGER.error("Failed to parse bees: '{}'", s); -@@ -294,7 +341,12 @@ +@@ -291,7 +336,12 @@ }); } @@ -175,7 +173,7 @@ } @Override -@@ -304,13 +356,14 @@ +@@ -301,13 +351,14 @@ if (this.hasSavedFlowerPos()) { nbttagcompound.put("flower_pos", GameProfileSerializer.writeBlockPos(this.savedFlowerPos)); } @@ -191,7 +189,7 @@ List list = (List) tileentity_b.getOrDefault(DataComponents.BEES, List.of()); list.forEach(this::storeBee); -@@ -351,7 +404,7 @@ +@@ -348,7 +399,7 @@ NBTTagCompound nbttagcompound = new NBTTagCompound(); entity.save(nbttagcompound); @@ -200,7 +198,7 @@ Objects.requireNonNull(nbttagcompound); list.forEach(nbttagcompound::remove); -@@ -370,7 +423,7 @@ +@@ -367,7 +418,7 @@ @Nullable public Entity createEntity(World world, BlockPosition blockposition) { NBTTagCompound nbttagcompound = this.entityData.copyTag(); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityChest.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityChest.patch index 328ceec04e..fe85c696ac 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityChest.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityChest.patch @@ -50,15 +50,3 @@ protected TileEntityChest(TileEntityTypes tileentitytypes, BlockPosition blockposition, IBlockData iblockdata) { super(tileentitytypes, blockposition, iblockdata); this.items = NonNullList.withSize(27, ItemStack.EMPTY); -@@ -199,4 +235,11 @@ - - world.blockEvent(blockposition, block, 1, j); - } -+ -+ // CraftBukkit start -+ @Override -+ public boolean onlyOpCanSetNbt() { -+ return true; -+ } -+ // CraftBukkit end - } 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 be3111dcd8..f70c7ce402 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 @@ -22,7 +22,7 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeCraftingHolder, AutoRecipeOutput { protected static final int SLOT_INPUT = 0; -@@ -112,9 +127,39 @@ +@@ -110,9 +125,39 @@ } }; this.recipesUsed = new Reference2IntOpenHashMap(); @@ -61,9 +61,9 @@ + // CraftBukkit end + private boolean isLit() { - return this.litTime > 0; + return this.litTimeRemaining > 0; } -@@ -180,7 +225,7 @@ +@@ -175,7 +220,7 @@ RecipeHolder recipeholder; if (flag2) { @@ -72,11 +72,11 @@ } else { recipeholder = null; } -@@ -188,9 +233,20 @@ +@@ -183,9 +228,20 @@ int i = tileentityfurnace.getMaxStackSize(); if (!tileentityfurnace.isLit() && canBurn(worldserver.registryAccess(), recipeholder, singlerecipeinput, tileentityfurnace.items, i)) { -- tileentityfurnace.litTime = tileentityfurnace.getBurnDuration(worldserver.fuelValues(), itemstack); +- tileentityfurnace.litTimeRemaining = tileentityfurnace.getBurnDuration(worldserver.fuelValues(), itemstack); + // CraftBukkit start + CraftItemStack fuel = CraftItemStack.asCraftMirror(itemstack); + @@ -87,20 +87,20 @@ + return; + } + -+ tileentityfurnace.litTime = furnaceBurnEvent.getBurnTime(); - tileentityfurnace.litDuration = tileentityfurnace.litTime; ++ tileentityfurnace.litTimeRemaining = furnaceBurnEvent.getBurnTime(); + tileentityfurnace.litTotalTime = tileentityfurnace.litTimeRemaining; - if (tileentityfurnace.isLit()) { + if (tileentityfurnace.isLit() && furnaceBurnEvent.isBurning()) { + // CraftBukkit end flag1 = true; if (flag3) { Item item = itemstack.getItem(); -@@ -204,11 +260,23 @@ +@@ -199,11 +255,23 @@ } if (tileentityfurnace.isLit() && canBurn(worldserver.registryAccess(), recipeholder, singlerecipeinput, tileentityfurnace.items, i)) { + // CraftBukkit start -+ if (recipeholder != null && tileentityfurnace.cookingProgress == 0) { ++ if (recipeholder != null && tileentityfurnace.cookingTimer == 0) { + CraftItemStack source = CraftItemStack.asCraftMirror(tileentityfurnace.items.get(0)); + CookingRecipe recipe = (CookingRecipe) recipeholder.toBukkitRecipe(); + @@ -111,16 +111,16 @@ + } + // CraftBukkit end + - ++tileentityfurnace.cookingProgress; - if (tileentityfurnace.cookingProgress == tileentityfurnace.cookingTotalTime) { - tileentityfurnace.cookingProgress = 0; + ++tileentityfurnace.cookingTimer; + if (tileentityfurnace.cookingTimer == tileentityfurnace.cookingTotalTime) { + tileentityfurnace.cookingTimer = 0; tileentityfurnace.cookingTotalTime = getTotalCookTime(worldserver, tileentityfurnace); - if (burn(worldserver.registryAccess(), recipeholder, singlerecipeinput, tileentityfurnace.items, i)) { + if (burn(tileentityfurnace.level, tileentityfurnace.worldPosition, worldserver.registryAccess(), recipeholder, singlerecipeinput, tileentityfurnace.items, i)) { // CraftBukkit tileentityfurnace.setRecipeUsed(recipeholder); } -@@ -247,17 +315,44 @@ +@@ -242,17 +310,44 @@ } } @@ -166,7 +166,7 @@ if (itemstack.is(Blocks.WET_SPONGE.asItem()) && !((ItemStack) nonnulllist.get(1)).isEmpty() && ((ItemStack) nonnulllist.get(1)).is(Items.BUCKET)) { nonnulllist.set(1, new ItemStack(Items.WATER_BUCKET)); -@@ -275,6 +370,7 @@ +@@ -270,6 +365,7 @@ } private static int getTotalCookTime(WorldServer worldserver, TileEntityFurnace tileentityfurnace) { @@ -174,7 +174,7 @@ SingleRecipeInput singlerecipeinput = new SingleRecipeInput(tileentityfurnace.getItem(0)); return (Integer) tileentityfurnace.quickCheck.getRecipeFor(singlerecipeinput, worldserver).map((recipeholder) -> { -@@ -365,8 +461,8 @@ +@@ -360,8 +456,8 @@ @Override public void awardUsedRecipes(EntityHuman entityhuman, List list) {} @@ -185,7 +185,7 @@ entityplayer.awardRecipes(list); Iterator iterator = list.iterator(); -@@ -383,22 +479,28 @@ +@@ -378,22 +474,28 @@ } public List> getRecipesToAwardAndPopExperience(WorldServer worldserver, Vec3D vec3d) { @@ -217,7 +217,7 @@ int j = MathHelper.floor((float) i * f); float f1 = MathHelper.frac((float) i * f); -@@ -406,6 +508,17 @@ +@@ -401,6 +503,17 @@ ++j; } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityJukeBox.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityJukeBox.patch index cd40785808..d86298736c 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityJukeBox.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityJukeBox.patch @@ -57,7 +57,7 @@ public TileEntityJukeBox(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.JUKEBOX, blockposition, iblockdata); -@@ -133,7 +177,7 @@ +@@ -137,7 +181,7 @@ @Override public int getMaxStackSize() { @@ -66,7 +66,7 @@ } @Override -@@ -152,12 +196,17 @@ +@@ -156,12 +200,17 @@ } @VisibleForTesting 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 9ac9529fb7..cd05061138 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 @@ -152,7 +152,7 @@ } @Override -@@ -241,7 +339,7 @@ +@@ -236,7 +334,7 @@ @Override public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch index 971f7399e7..7b3f170d34 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch @@ -50,7 +50,7 @@ public TileEntityShulkerBox(@Nullable EnumColor enumcolor, BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.SHULKER_BOX, blockposition, iblockdata); this.itemStacks = NonNullList.withSize(27, ItemStack.EMPTY); -@@ -173,6 +209,7 @@ +@@ -184,6 +220,7 @@ } ++this.openCount; @@ -58,7 +58,7 @@ this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount); if (this.openCount == 1) { this.level.gameEvent((Entity) entityhuman, (Holder) GameEvent.CONTAINER_OPEN, this.worldPosition); -@@ -186,6 +223,7 @@ +@@ -197,6 +234,7 @@ public void stopOpen(EntityHuman entityhuman) { if (!this.remove && !entityhuman.isSpectator()) { --this.openCount; diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch index 4c2e6b7344..8c27e83ce3 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch @@ -133,7 +133,7 @@ } @Override -@@ -278,12 +342,17 @@ +@@ -273,12 +337,17 @@ @Nullable public UUID getPlayerWhoMayEdit() { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityTypes.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityTypes.patch new file mode 100644 index 0000000000..89d94c46d7 --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityTypes.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/level/block/entity/TileEntityTypes.java ++++ b/net/minecraft/world/level/block/entity/TileEntityTypes.java +@@ -66,7 +66,7 @@ + public static final TileEntityTypes CRAFTER = register("crafter", CrafterBlockEntity::new, Blocks.CRAFTER); + public static final TileEntityTypes TRIAL_SPAWNER = register("trial_spawner", TrialSpawnerBlockEntity::new, Blocks.TRIAL_SPAWNER); + public static final TileEntityTypes VAULT = register("vault", VaultBlockEntity::new, Blocks.VAULT); +- private static final Set> OP_ONLY_CUSTOM_DATA = Set.of(TileEntityTypes.COMMAND_BLOCK, TileEntityTypes.LECTERN, TileEntityTypes.SIGN, TileEntityTypes.HANGING_SIGN, TileEntityTypes.MOB_SPAWNER, TileEntityTypes.TRIAL_SPAWNER); ++ private static final Set> OP_ONLY_CUSTOM_DATA = Set.of(TileEntityTypes.COMMAND_BLOCK, TileEntityTypes.LECTERN, TileEntityTypes.SIGN, TileEntityTypes.HANGING_SIGN, TileEntityTypes.MOB_SPAWNER, TileEntityTypes.TRIAL_SPAWNER, TileEntityTypes.CHEST); // CraftBukkit + private final TileEntityTypes.a factory; + private final Set validBlocks; + private final Holder.c> builtInRegistryHolder; +@@ -110,7 +110,7 @@ + public T getBlockEntity(IBlockAccess iblockaccess, BlockPosition blockposition) { + TileEntity tileentity = iblockaccess.getBlockEntity(blockposition); + +- return tileentity != null && tileentity.getType() == this ? tileentity : null; ++ return tileentity != null && tileentity.getType() == this ? (T) tileentity : null; // CraftBukkit - decompile error + } + + public boolean onlyOpCanSetNbt() { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.patch index d9d12313b6..e69745a455 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java +++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java -@@ -211,7 +211,7 @@ +@@ -210,7 +210,7 @@ } public void resetAfterBecomingOminous(TrialSpawner trialspawner, WorldServer worldserver) { @@ -9,7 +9,7 @@ Objects.requireNonNull(worldserver); stream.map(worldserver::getEntity).forEach((entity) -> { -@@ -223,7 +223,7 @@ +@@ -222,7 +222,7 @@ entityinsentient.dropPreservedEquipment(worldserver); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/state/BlockBase.patch b/paper-server/nms-patches/net/minecraft/world/level/block/state/BlockBase.patch index bc6135f2f2..55d783e127 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/state/BlockBase.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/state/BlockBase.patch @@ -38,7 +38,7 @@ } iblockdata.spawnAfterBreak(worldserver, blockposition, ItemStack.EMPTY, flag); -@@ -1121,7 +1134,13 @@ +@@ -1125,7 +1138,13 @@ } public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata, boolean flag) { 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 245064ce44..4937f5fc74 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/Chunk.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/Chunk.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/Chunk.java +++ b/net/minecraft/world/level/chunk/Chunk.java -@@ -78,7 +78,7 @@ +@@ -79,7 +79,7 @@ }; private final Map tickersInLevel; public boolean loaded; @@ -9,7 +9,7 @@ @Nullable private Supplier fullStatus; @Nullable -@@ -97,7 +97,7 @@ +@@ -98,7 +98,7 @@ this.tickersInLevel = Maps.newHashMap(); this.unsavedListener = (chunkcoordintpair1) -> { }; @@ -18,7 +18,7 @@ this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap(); HeightMap.Type[] aheightmap_type = HeightMap.Type.values(); int j = aheightmap_type.length; -@@ -115,6 +115,11 @@ +@@ -116,6 +116,11 @@ this.fluidTicks = levelchunkticks1; } @@ -29,8 +29,8 @@ + public Chunk(WorldServer worldserver, ProtoChunk protochunk, @Nullable Chunk.c chunk_c) { this(worldserver, protochunk.getPos(), protochunk.getUpgradeData(), protochunk.unpackBlockTicks(), protochunk.unpackFluidTicks(), protochunk.getInhabitedTime(), protochunk.getSections(), chunk_c, protochunk.getBlendingData()); - Iterator iterator = protochunk.getBlockEntities().values().iterator(); -@@ -146,6 +151,10 @@ + if (!Collections.disjoint(protochunk.pendingBlockEntities.keySet(), protochunk.blockEntities.keySet())) { +@@ -151,6 +156,10 @@ this.skyLightSources = protochunk.skyLightSources; this.setLightCorrect(protochunk.isLightCorrect()); this.markUnsaved(); @@ -41,7 +41,7 @@ } public void setUnsavedListener(Chunk.e chunk_e) { -@@ -267,9 +276,16 @@ +@@ -272,9 +281,16 @@ } } @@ -58,7 +58,7 @@ int i = blockposition.getY(); ChunkSection chunksection = this.getSection(this.getSectionIndex(i)); boolean flag1 = chunksection.hasOnlyAir(); -@@ -319,7 +335,8 @@ +@@ -324,7 +340,8 @@ if (!chunksection.getBlockState(j, k, l).is(block)) { return null; } else { @@ -68,7 +68,7 @@ iblockdata.onPlace(this.level, blockposition, iblockdata1, flag); } -@@ -370,7 +387,12 @@ +@@ -375,7 +392,12 @@ @Nullable public TileEntity getBlockEntity(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) { @@ -82,7 +82,7 @@ if (tileentity == null) { NBTTagCompound nbttagcompound = (NBTTagCompound) this.pendingBlockEntities.remove(blockposition); -@@ -442,6 +464,7 @@ +@@ -447,6 +469,7 @@ if (!iblockdata.hasBlockEntity()) { Chunk.LOGGER.warn("Trying to set block entity {} at position {}, but state {} does not allow it", new Object[]{tileentity, blockposition, iblockdata}); @@ -90,7 +90,7 @@ } else { IBlockData iblockdata1 = tileentity.getBlockState(); -@@ -495,6 +518,12 @@ +@@ -500,6 +523,12 @@ if (this.isInLevel()) { TileEntity tileentity = (TileEntity) this.blockEntities.remove(blockposition); @@ -103,7 +103,7 @@ if (tileentity != null) { World world = this.level; -@@ -548,6 +577,57 @@ +@@ -553,6 +582,57 @@ } @@ -161,7 +161,7 @@ public boolean isEmpty() { return false; } -@@ -745,7 +825,7 @@ +@@ -750,7 +830,7 @@ private void updateBlockEntityTicker(T t0) { IBlockData iblockdata = t0.getBlockState(); @@ -170,7 +170,7 @@ if (blockentityticker == null) { this.removeBlockEntityTicker(t0.getBlockPos()); -@@ -836,7 +916,7 @@ +@@ -841,7 +921,7 @@ private boolean loggedInvalidBlockState; a(final TileEntity tileentity, final BlockEntityTicker blockentityticker) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch index 80b8ff67ee..1d0aecddd6 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/net/minecraft/world/level/chunk/ChunkGenerator.java -@@ -311,7 +311,7 @@ +@@ -312,7 +312,7 @@ } } @@ -9,7 +9,7 @@ ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos(); if (!SharedConstants.debugVoidTerrain(chunkcoordintpair)) { -@@ -333,7 +333,7 @@ +@@ -334,7 +334,7 @@ for (int k = 0; k < j; ++k) { ChunkSection chunksection = achunksection[k]; @@ -18,7 +18,7 @@ Objects.requireNonNull(set); palettedcontainerro.getAll(set::add); -@@ -444,6 +444,33 @@ +@@ -445,6 +445,33 @@ } } @@ -52,8 +52,8 @@ private static StructureBoundingBox getWritableArea(IChunkAccess ichunkaccess) { ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos(); int i = chunkcoordintpair.getMinBlockX(); -@@ -581,6 +608,14 @@ - StructureStart structurestart = structure.generate(iregistrycustom, this, this.biomeSource, randomstate, structuretemplatemanager, i, chunkcoordintpair, j, ichunkaccess, predicate); +@@ -582,6 +609,14 @@ + StructureStart structurestart = structure.generate(structureset_a.structure(), resourcekey, iregistrycustom, this, this.biomeSource, randomstate, structuretemplatemanager, i, chunkcoordintpair, j, ichunkaccess, predicate); if (structurestart.isValid()) { + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch index b8d23e44e8..427607fb1c 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch @@ -41,7 +41,7 @@ } public abstract ChunkStatus getPersistedStatus(); -@@ -458,6 +468,27 @@ +@@ -463,6 +473,27 @@ } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.patch index 520b5c69c5..6e9daada0e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.patch @@ -6,7 +6,7 @@ - if (worldserver.getServer().getWorldData().worldGenOptions().generateStructures()) { + if (worldserver.serverLevelData.worldGenOptions().generateStructures()) { // CraftBukkit - worldgencontext.generator().createStructures(worldserver.registryAccess(), worldserver.getChunkSource().getGeneratorState(), worldserver.structureManager(), ichunkaccess, worldgencontext.structureManager()); + worldgencontext.generator().createStructures(worldserver.registryAccess(), worldserver.getChunkSource().getGeneratorState(), worldserver.structureManager(), ichunkaccess, worldgencontext.structureManager(), worldserver.dimension()); } @@ -170,7 +170,17 @@ diff --git a/paper-server/pom.xml b/paper-server/pom.xml index e64f605662..9ac9a7581a 100644 --- a/paper-server/pom.xml +++ b/paper-server/pom.xml @@ -4,7 +4,7 @@ org.bukkit craftbukkit jar - 1.21.3-R0.1-SNAPSHOT + 1.21.4-R0.1-SNAPSHOT CraftBukkit https://www.spigotmc.org/ @@ -14,7 +14,7 @@ UTF-8 unknown git - 1_21_R2 + 1_21_R3 21 @@ -48,7 +48,7 @@ org.apache.logging.log4j log4j-iostreams - 2.22.1 + 2.24.1 compile @@ -79,7 +79,7 @@ com.github.oshi oshi-core - 6.4.10 + 6.6.5 compile @@ -91,13 +91,13 @@ com.microsoft.azure msal4j - 1.15.0 + 1.17.2 compile com.mojang authlib - 6.0.55 + 6.0.57 compile @@ -121,7 +121,7 @@ com.mojang logging - 1.4.9 + 1.5.10 compile @@ -139,111 +139,111 @@ com.nimbusds nimbus-jose-jwt - 9.37.3 + 9.40 compile com.nimbusds oauth2-oidc-sdk - 11.9.1 + 11.18 compile commons-io commons-io - 2.15.1 + 2.17.0 compile io.netty netty-buffer - 4.1.97.Final + 4.1.115.Final compile io.netty netty-codec - 4.1.97.Final + 4.1.115.Final compile io.netty netty-common - 4.1.97.Final + 4.1.115.Final compile io.netty netty-handler - 4.1.97.Final + 4.1.115.Final compile io.netty netty-resolver - 4.1.97.Final + 4.1.115.Final compile io.netty netty-transport - 4.1.97.Final + 4.1.115.Final compile io.netty netty-transport-classes-epoll - 4.1.97.Final + 4.1.115.Final compile io.netty netty-transport-native-epoll - 4.1.97.Final + 4.1.115.Final linux-x86_64 compile io.netty netty-transport-native-epoll - 4.1.97.Final + 4.1.115.Final linux-aarch_64 compile io.netty netty-transport-native-unix-common - 4.1.97.Final + 4.1.115.Final compile it.unimi.dsi fastutil - 8.5.12 + 8.5.15 compile net.java.dev.jna jna - 5.14.0 + 5.15.0 compile net.java.dev.jna jna-platform - 5.14.0 + 5.15.0 compile net.minidev accessors-smart - 2.5.0 + 2.5.1 compile net.minidev json-smart - 2.5.0 + 2.5.1 compile @@ -255,25 +255,25 @@ org.apache.commons commons-lang3 - 3.14.0 + 3.17.0 compile org.apache.logging.log4j log4j-api - 2.22.1 + 2.24.1 compile org.apache.logging.log4j log4j-core - 2.22.1 + 2.24.1 compile org.apache.logging.log4j log4j-slf4j2-impl - 2.22.1 + 2.24.1 compile @@ -285,7 +285,7 @@ org.slf4j slf4j-api - 2.0.9 + 2.0.16 compile @@ -312,7 +312,7 @@ org.xerial sqlite-jdbc - 3.46.1.3 + 3.47.0.0 runtime 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 14364d6d0f..cbe78c2221 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java @@ -14,7 +14,7 @@ import net.minecraft.core.particles.ParticleParamRedstone; import net.minecraft.core.particles.ParticleType; import net.minecraft.core.particles.SculkChargeParticleOptions; import net.minecraft.core.particles.ShriekParticleOption; -import net.minecraft.core.particles.TargetColorParticleOption; +import net.minecraft.core.particles.TrailParticleOption; import net.minecraft.core.particles.VibrationParticleOption; import net.minecraft.core.registries.Registries; import net.minecraft.world.entity.Entity; @@ -190,10 +190,10 @@ public abstract class CraftParticle implements Keyed { } }; - BiFunction, CraftParticle> targetColorFunction = (name, particle) -> new CraftParticle<>(name, particle, Particle.TargetColor.class) { + BiFunction, CraftParticle> trailFunction = (name, particle) -> new CraftParticle<>(name, particle, Particle.Trail.class) { @Override - public ParticleParam createParticleParam(Particle.TargetColor data) { - return new TargetColorParticleOption(CraftLocation.toVec3D(data.getTarget()), data.getColor().asRGB()); + public ParticleParam createParticleParam(Particle.Trail data) { + return new TrailParticleOption(CraftLocation.toVec3D(data.getTarget()), data.getColor().asRGB(), data.getDuration()); } }; @@ -209,7 +209,7 @@ public abstract class CraftParticle implements Keyed { add("entity_effect", colorFunction); add("dust_pillar", blockDataFunction); add("block_crumble", blockDataFunction); - add("trail", targetColorFunction); + add("trail", trailFunction); } private static void add(String name, BiFunction, CraftParticle> function) { 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 cde1bf28fd..0c25788e88 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1905,14 +1905,14 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) { - getHandle().sendParticles( + getHandle().sendParticlesSource( null, // Sender CraftParticle.createParticleParam(particle, data), // Particle + false, force, x, y, z, // Position count, // Count offsetX, offsetY, offsetZ, // Random offset - extra, // Speed? - force + extra // Speed? ); } 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 95d4bb718a..c2c4126b3f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java @@ -190,11 +190,11 @@ public class Main { useConsole = false; } - if (false && Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { + if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { Date buildDate = new Date(Integer.parseInt(Main.class.getPackage().getImplementationVendor()) * 1000L); Calendar deadline = Calendar.getInstance(); - deadline.add(Calendar.DAY_OF_YEAR, -14); + deadline.add(Calendar.DAY_OF_YEAR, -2); if (buildDate.before(deadline.getTime())) { System.err.println("*** Error, this build is outdated ***"); System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***"); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java index 9b0c39bd47..3f8f3e8c83 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java @@ -40,24 +40,24 @@ public abstract class CraftFurnace extends CraftCon @Override public short getBurnTime() { - return (short) this.getSnapshot().litTime; + return (short) this.getSnapshot().litTimeRemaining; } @Override public void setBurnTime(short burnTime) { - this.getSnapshot().litTime = burnTime; + this.getSnapshot().litTimeRemaining = burnTime; // SPIGOT-844: Allow lighting and relighting using this API this.data = this.data.setValue(BlockFurnace.LIT, burnTime > 0); } @Override public short getCookTime() { - return (short) this.getSnapshot().cookingProgress; + return (short) this.getSnapshot().cookingTimer; } @Override public void setCookTime(short cookTime) { - this.getSnapshot().cookingProgress = cookTime; + this.getSnapshot().cookingTimer = cookTime; } @Override 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 032e381ba9..1177b36af2 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 @@ -499,7 +499,6 @@ 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.CopperBulbBlock.class, org.bukkit.craftbukkit.block.impl.CraftCopperBulb::new); register(net.minecraft.world.level.block.CrafterBlock.class, org.bukkit.craftbukkit.block.impl.CraftCrafter::new); @@ -517,6 +516,8 @@ 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.MossyCarpetBlock.class, org.bukkit.craftbukkit.block.impl.CraftMossyCarpet::new); + register(net.minecraft.world.level.block.MultifaceBlock.class, org.bukkit.craftbukkit.block.impl.CraftMultiface::new); + register(net.minecraft.world.level.block.ParticleLeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftParticleLeaves::new); register(net.minecraft.world.level.block.PiglinWallSkullBlock.class, org.bukkit.craftbukkit.block.impl.CraftPiglinWallSkull::new); register(net.minecraft.world.level.block.PinkPetalsBlock.class, org.bukkit.craftbukkit.block.impl.CraftPinkPetals::new); register(net.minecraft.world.level.block.PitcherCropBlock.class, org.bukkit.craftbukkit.block.impl.CraftPitcherCrop::new); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCreakingHeart.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCreakingHeart.java index a4461a7df3..1dd3689f27 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCreakingHeart.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCreakingHeart.java @@ -5,15 +5,26 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData; public abstract class CraftCreakingHeart extends CraftBlockData implements CreakingHeart { - private static final net.minecraft.world.level.block.state.properties.BlockStateEnum CREAKING = getEnum("creaking"); + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean ACTIVE = getBoolean("active"); + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean NATURAL = getBoolean("natural"); @Override - public org.bukkit.block.data.type.CreakingHeart.Creaking getCreaking() { - return get(CREAKING, org.bukkit.block.data.type.CreakingHeart.Creaking.class); + public boolean isActive() { + return get(ACTIVE); } @Override - public void setCreaking(org.bukkit.block.data.type.CreakingHeart.Creaking creaking) { - set(CREAKING, creaking); + public void setActive(boolean active) { + set(ACTIVE, active); + } + + @Override + public boolean isNatural() { + return get(NATURAL); + } + + @Override + public void setNatural(boolean natural) { + set(NATURAL, natural); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCreakingHeart.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCreakingHeart.java index 3d01917e53..11f73f3de7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCreakingHeart.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCreakingHeart.java @@ -15,16 +15,27 @@ public final class CraftCreakingHeart extends org.bukkit.craftbukkit.block.data. // org.bukkit.craftbukkit.block.data.type.CraftCreakingHeart - private static final net.minecraft.world.level.block.state.properties.BlockStateEnum CREAKING = getEnum(net.minecraft.world.level.block.CreakingHeartBlock.class, "creaking"); + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean ACTIVE = getBoolean(net.minecraft.world.level.block.CreakingHeartBlock.class, "active"); + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean NATURAL = getBoolean(net.minecraft.world.level.block.CreakingHeartBlock.class, "natural"); @Override - public org.bukkit.block.data.type.CreakingHeart.Creaking getCreaking() { - return get(CREAKING, org.bukkit.block.data.type.CreakingHeart.Creaking.class); + public boolean isActive() { + return get(ACTIVE); } @Override - public void setCreaking(org.bukkit.block.data.type.CreakingHeart.Creaking creaking) { - set(CREAKING, creaking); + public void setActive(boolean active) { + set(ACTIVE, active); + } + + @Override + public boolean isNatural() { + return get(NATURAL); + } + + @Override + public void setNatural(boolean natural) { + set(NATURAL, natural); } // org.bukkit.craftbukkit.block.data.CraftOrientable diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMultiface.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMultiface.java new file mode 100644 index 0000000000..1a08fd93a3 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMultiface.java @@ -0,0 +1,79 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftMultiface extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.ResinClump, org.bukkit.block.data.MultipleFacing, org.bukkit.block.data.Waterlogged { + + public CraftMultiface() { + super(); + } + + public CraftMultiface(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftMultipleFacing + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean[] FACES = new net.minecraft.world.level.block.state.properties.BlockStateBoolean[]{ + getBoolean(net.minecraft.world.level.block.MultifaceBlock.class, "north", true), getBoolean(net.minecraft.world.level.block.MultifaceBlock.class, "east", true), getBoolean(net.minecraft.world.level.block.MultifaceBlock.class, "south", true), getBoolean(net.minecraft.world.level.block.MultifaceBlock.class, "west", true), getBoolean(net.minecraft.world.level.block.MultifaceBlock.class, "up", true), getBoolean(net.minecraft.world.level.block.MultifaceBlock.class, "down", true) + }; + + @Override + public boolean hasFace(org.bukkit.block.BlockFace face) { + net.minecraft.world.level.block.state.properties.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + return get(state); + } + + @Override + public void setFace(org.bukkit.block.BlockFace face, boolean has) { + net.minecraft.world.level.block.state.properties.BlockStateBoolean state = FACES[face.ordinal()]; + if (state == null) { + throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); + } + set(state, has); + } + + @Override + public java.util.Set getFaces() { + com.google.common.collect.ImmutableSet.Builder faces = com.google.common.collect.ImmutableSet.builder(); + + for (int i = 0; i < FACES.length; i++) { + if (FACES[i] != null && get(FACES[i])) { + faces.add(org.bukkit.block.BlockFace.values()[i]); + } + } + + return faces.build(); + } + + @Override + public java.util.Set getAllowedFaces() { + com.google.common.collect.ImmutableSet.Builder faces = com.google.common.collect.ImmutableSet.builder(); + + for (int i = 0; i < FACES.length; i++) { + if (FACES[i] != null) { + faces.add(org.bukkit.block.BlockFace.values()[i]); + } + } + + return faces.build(); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.MultifaceBlock.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/CraftCherryLeaves.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftParticleLeaves.java similarity index 72% rename from paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCherryLeaves.java rename to paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftParticleLeaves.java index e21a2c2a8c..5d0822c46e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCherryLeaves.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftParticleLeaves.java @@ -3,20 +3,20 @@ */ 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 final class CraftParticleLeaves extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Leaves, org.bukkit.block.data.Waterlogged { - public CraftCherryLeaves() { + public CraftParticleLeaves() { super(); } - public CraftCherryLeaves(net.minecraft.world.level.block.state.IBlockData state) { + public CraftParticleLeaves(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"); + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger DISTANCE = getInteger(net.minecraft.world.level.block.ParticleLeavesBlock.class, "distance"); + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean PERSISTENT = getBoolean(net.minecraft.world.level.block.ParticleLeavesBlock.class, "persistent"); @Override public boolean isPersistent() { @@ -40,7 +40,7 @@ public final class CraftCherryLeaves extends org.bukkit.craftbukkit.block.data.C // 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"); + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.ParticleLeavesBlock.class, "waterlogged"); @Override public boolean isWaterlogged() { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCreakingTransient.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCreakingTransient.java deleted file mode 100644 index 4366c35849..0000000000 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCreakingTransient.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.bukkit.craftbukkit.entity; - -import net.minecraft.world.entity.monster.creaking.CreakingTransient; -import org.bukkit.craftbukkit.CraftServer; - -public class CraftCreakingTransient extends CraftCreaking implements org.bukkit.entity.CreakingTransient { - - public CraftCreakingTransient(CraftServer server, CreakingTransient entity) { - super(server, entity); - } - - @Override - public CreakingTransient getHandle() { - return (CreakingTransient) entity; - } - - @Override - public String toString() { - return "CraftCreakingTransient"; - } -} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java index 5d35cfb774..77e1c6da76 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java @@ -83,7 +83,6 @@ import org.bukkit.entity.Chicken; import org.bukkit.entity.Cod; import org.bukkit.entity.Cow; import org.bukkit.entity.Creaking; -import org.bukkit.entity.CreakingTransient; import org.bukkit.entity.Creeper; import org.bukkit.entity.Dolphin; import org.bukkit.entity.Donkey; @@ -351,7 +350,6 @@ public final class CraftEntityTypes { register(new EntityTypeData<>(EntityType.BREEZE, Breeze.class, CraftBreeze::new, createLiving(EntityTypes.BREEZE))); register(new EntityTypeData<>(EntityType.ARMADILLO, Armadillo.class, CraftArmadillo::new, createLiving(EntityTypes.ARMADILLO))); register(new EntityTypeData<>(EntityType.CREAKING, Creaking.class, CraftCreaking::new, createLiving(EntityTypes.CREAKING))); - register(new EntityTypeData<>(EntityType.CREAKING_TRANSIENT, CreakingTransient.class, CraftCreakingTransient::new, createLiving(EntityTypes.CREAKING_TRANSIENT))); Function dragonFunction = createLiving(EntityTypes.ENDER_DRAGON); register(new EntityTypeData<>(EntityType.ENDER_DRAGON, EnderDragon.class, CraftEnderDragon::new, spawnData -> { 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 6bde0489d1..0d5d34ecdf 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 @@ -495,7 +495,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { launch = new EntityThrownExpBottle(world, getHandle(), new net.minecraft.world.item.ItemStack(Items.EXPERIENCE_BOTTLE)); ((EntityProjectile) launch).shootFromRotation(getHandle(), getHandle().getXRot(), getHandle().getYRot(), -20.0F, 0.7F, 1.0F); // ItemExpBottle } else if (FishHook.class.isAssignableFrom(projectile) && getHandle() instanceof EntityHuman) { - launch = new EntityFishingHook((EntityHuman) getHandle(), world, 0, 0, new net.minecraft.world.item.ItemStack(Items.FISHING_ROD)); + launch = new EntityFishingHook((EntityHuman) getHandle(), world, 0, 0); } else if (Fireball.class.isAssignableFrom(projectile)) { Location location = getEyeLocation(); Vector direction = location.getDirection().multiply(10); @@ -622,7 +622,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { if (!isLeashed()) { return false; } - ((EntityInsentient) getHandle()).dropLeash(true, false); + ((EntityInsentient) getHandle()).removeLeash(); return true; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java index c7f3da5e4c..31da5d03ed 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java @@ -30,6 +30,16 @@ public final class CraftMinecartTNT extends CraftMinecart implements ExplosiveMi getHandle().explosionPowerBase = yield; } + @Override + public float getExplosionSpeedFactor() { + return getHandle().explosionSpeedFactor; + } + + @Override + public void setExplosionSpeedFactor(float factor) { + getHandle().explosionSpeedFactor = factor; + } + @Override public void setFuseTicks(int ticks) { getHandle().fuse = 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 fa364aa322..92025bae9a 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 @@ -2023,21 +2023,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player { getHandle().onUpdateAbilities(); } - @Override - public int getNoDamageTicks() { - if (getHandle().spawnInvulnerableTime > 0) { - return Math.max(getHandle().spawnInvulnerableTime, getHandle().invulnerableTime); - } else { - return getHandle().invulnerableTime; - } - } - - @Override - public void setNoDamageTicks(int ticks) { - super.setNoDamageTicks(ticks); - getHandle().spawnInvulnerableTime = ticks; // SPIGOT-5921: Update both for players, like the getter above - } - @Override public void setFlySpeed(float value) { validateSpeed(value); @@ -2288,7 +2273,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) { - PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(CraftParticle.createParticleParam(particle, data), force, (float) x, (float) y, (float) z, (float) offsetX, (float) offsetY, (float) offsetZ, (float) extra, count); + PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(CraftParticle.createParticleParam(particle, data), false, force, (float) x, (float) y, (float) z, (float) offsetX, (float) offsetY, (float) offsetZ, (float) extra, count); getHandle().connection.send(packetplayoutworldparticles); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java index f2dc4dad38..ef1f476fe8 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java @@ -8,6 +8,7 @@ import java.util.concurrent.CompletableFuture; import net.minecraft.core.BlockPosition; import net.minecraft.core.Holder; import net.minecraft.core.IRegistryCustom; +import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.RegionLimitedWorldAccess; import net.minecraft.server.level.WorldServer; import net.minecraft.util.MathHelper; @@ -17,6 +18,7 @@ import net.minecraft.world.level.BlockColumn; import net.minecraft.world.level.GeneratorAccessSeed; import net.minecraft.world.level.LevelHeightAccessor; import net.minecraft.world.level.StructureManager; +import net.minecraft.world.level.World; import net.minecraft.world.level.biome.BiomeBase; import net.minecraft.world.level.biome.BiomeManager; import net.minecraft.world.level.biome.BiomeSettingsMobs; @@ -115,14 +117,14 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } @Override - public void createStructures(IRegistryCustom iregistrycustom, ChunkGeneratorStructureState chunkgeneratorstructurestate, StructureManager structuremanager, IChunkAccess ichunkaccess, StructureTemplateManager structuretemplatemanager) { + public void createStructures(IRegistryCustom iregistrycustom, ChunkGeneratorStructureState chunkgeneratorstructurestate, StructureManager structuremanager, IChunkAccess ichunkaccess, StructureTemplateManager structuretemplatemanager, ResourceKey resourcekey) { SeededRandom random = getSeededRandom(); int x = ichunkaccess.getPos().x; int z = ichunkaccess.getPos().z; random.setSeed(MathHelper.getSeed(x, "should-structures".hashCode(), z) ^ world.getSeed()); if (generator.shouldGenerateStructures(this.world.getWorld(), new RandomSourceWrapper.RandomWrapper(random), x, z)) { - super.createStructures(iregistrycustom, chunkgeneratorstructurestate, structuremanager, ichunkaccess, structuretemplatemanager); + super.createStructures(iregistrycustom, chunkgeneratorstructurestate, structuremanager, ichunkaccess, structuretemplatemanager, resourcekey); } } 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 5de47c7d12..9ee1629734 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 @@ -25,6 +25,7 @@ import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftEntityType; +import org.bukkit.craftbukkit.inventory.components.CraftCustomModelDataComponent; import org.bukkit.craftbukkit.inventory.components.CraftEquippableComponent; import org.bukkit.craftbukkit.inventory.components.CraftFoodComponent; import org.bukkit.craftbukkit.inventory.components.CraftJukeboxComponent; @@ -45,6 +46,7 @@ public final class CraftItemFactory implements ItemFactory { static { instance = new CraftItemFactory(); ConfigurationSerialization.registerClass(SerializableMeta.class); + ConfigurationSerialization.registerClass(CraftCustomModelDataComponent.class); ConfigurationSerialization.registerClass(CraftEquippableComponent.class); ConfigurationSerialization.registerClass(CraftFoodComponent.class); ConfigurationSerialization.registerClass(CraftToolComponent.class); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java index 34e49c538f..3f91111e4c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java @@ -103,5 +103,10 @@ public class CraftMerchantCustom implements CraftMerchant { public boolean isClientSide() { return false; } + + @Override + public boolean stillValid(EntityHuman entityhuman) { + return this.tradingPlayer == entityhuman; + } } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index 46216aeff2..8bc8cb093d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -98,6 +98,7 @@ import org.bukkit.craftbukkit.block.CraftBlockType; import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.enchantments.CraftEnchantment; import org.bukkit.craftbukkit.inventory.CraftMetaItem.ItemMetaKey.Specific; +import org.bukkit.craftbukkit.inventory.components.CraftCustomModelDataComponent; import org.bukkit.craftbukkit.inventory.components.CraftEquippableComponent; import org.bukkit.craftbukkit.inventory.components.CraftFoodComponent; import org.bukkit.craftbukkit.inventory.components.CraftJukeboxComponent; @@ -121,6 +122,7 @@ import org.bukkit.inventory.meta.BlockDataMeta; import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.Repairable; +import org.bukkit.inventory.meta.components.CustomModelDataComponent; import org.bukkit.inventory.meta.components.EquippableComponent; import org.bukkit.inventory.meta.components.FoodComponent; import org.bukkit.inventory.meta.components.JukeboxPlayableComponent; @@ -281,7 +283,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { private IChatBaseComponent displayName; private IChatBaseComponent itemName; private List lore; // null and empty are two different states internally - private Integer customModelData; + private CraftCustomModelDataComponent customModelData; private Integer enchantableValue; private Map blockData; private Map enchantments; @@ -328,7 +330,9 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { this.lore = new ArrayList(meta.lore); } - this.customModelData = meta.customModelData; + if (meta.hasCustomModelData()) { + this.customModelData = new CraftCustomModelDataComponent(meta.customModelData); + } this.enchantableValue = meta.enchantableValue; this.blockData = meta.blockData; @@ -398,7 +402,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { }); getOrEmpty(tag, CUSTOM_MODEL_DATA).ifPresent((i) -> { - customModelData = i.value(); + customModelData = new CraftCustomModelDataComponent(i); }); getOrEmpty(tag, ENCHANTABLE).ifPresent((i) -> { enchantableValue = i.value(); @@ -582,9 +586,11 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { safelyAdd(lore, this.lore = new ArrayList(), true); } - Integer customModelData = SerializableMeta.getObject(Integer.class, map, CUSTOM_MODEL_DATA.BUKKIT, true); - if (customModelData != null) { - setCustomModelData(customModelData); + Object customModelData = SerializableMeta.getObject(Object.class, map, CUSTOM_MODEL_DATA.BUKKIT, true); + if (customModelData instanceof CustomModelDataComponent component) { + setCustomModelDataComponent(component); + } else { + setCustomModelData((Integer) customModelData); } Integer enchantmentValue = SerializableMeta.getObject(Integer.class, map, ENCHANTABLE.BUKKIT, true); if (enchantmentValue != null) { @@ -915,7 +921,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } if (hasCustomModelData()) { - itemTag.put(CUSTOM_MODEL_DATA, new CustomModelData(customModelData)); + itemTag.put(CUSTOM_MODEL_DATA, customModelData.getHandle()); } if (hasEnchantable()) { @@ -1281,12 +1287,25 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @Override public int getCustomModelData() { Preconditions.checkState(hasCustomModelData(), "We don't have CustomModelData! Check hasCustomModelData first!"); - return customModelData; + + List floats = customModelData.getFloats(); + Preconditions.checkState(!floats.isEmpty(), "No numeric custom model data"); + return floats.get(0).intValue(); + } + + @Override + public CustomModelDataComponent getCustomModelDataComponent() { + return (this.hasCustomModelData()) ? new CraftCustomModelDataComponent(this.customModelData) : new CraftCustomModelDataComponent(new CustomModelData(List.of(), List.of(), List.of(), List.of())); } @Override public void setCustomModelData(Integer data) { - this.customModelData = data; + this.customModelData = (data == null) ? null : new CraftCustomModelDataComponent(new CustomModelData(List.of(data.floatValue()), List.of(), List.of(), List.of())); + } + + @Override + public void setCustomModelDataComponent(CustomModelDataComponent customModelData) { + this.customModelData = (customModelData == null) ? null : new CraftCustomModelDataComponent((CraftCustomModelDataComponent) customModelData); } @Override @@ -1883,7 +1902,9 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { if (this.lore != null) { clone.lore = new ArrayList(this.lore); } - clone.customModelData = this.customModelData; + if (this.hasCustomModelData()) { + clone.customModelData = new CraftCustomModelDataComponent(customModelData); + } clone.enchantableValue = this.enchantableValue; clone.blockData = this.blockData; if (this.enchantments != null) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java index f40fea0d6f..2473a1ad89 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java @@ -4,10 +4,8 @@ import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.List; import java.util.Optional; -import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.world.item.Item; import net.minecraft.world.item.crafting.IRecipe; import net.minecraft.world.item.crafting.RecipeItemStack; import org.bukkit.NamespacedKey; @@ -38,9 +36,8 @@ public interface CraftRecipe extends Recipe { throw new IllegalArgumentException("Unknown recipe stack instance " + bukkit); } - List> items = stack.items(); if (requireNotEmpty) { - Preconditions.checkArgument(!items.isEmpty(), "Recipe requires at least one non-air choice"); + Preconditions.checkArgument(!stack.isEmpty(), "Recipe requires at least one non-air choice"); } return stack; @@ -51,9 +48,7 @@ public interface CraftRecipe extends Recipe { } public static RecipeChoice toBukkit(RecipeItemStack list) { - List> items = list.items(); - - if (items.isEmpty()) { + if (list.isEmpty()) { return null; } @@ -65,10 +60,7 @@ public interface CraftRecipe extends Recipe { return new RecipeChoice.ExactChoice(choices); } else { - List choices = new ArrayList<>(items.size()); - for (Holder i : items) { - choices.add(CraftItemType.minecraftToBukkit(i.value())); - } + List choices = list.items().map((i) -> CraftItemType.minecraftToBukkit(i.value())).toList(); return new RecipeChoice.MaterialChoice(choices); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/SerializableMeta.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/SerializableMeta.java index f5c9449543..d5419df164 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/SerializableMeta.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/SerializableMeta.java @@ -4,6 +4,8 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import org.bukkit.block.Banner; @@ -136,4 +138,39 @@ public final class SerializableMeta implements ConfigurationSerializable { } throw new IllegalArgumentException(field + "(" + object + ") is not a valid " + clazz); } + + public static List getList(Class clazz, Map map, Object field) { + List result = new ArrayList<>(); + + List list = SerializableMeta.getObject(List.class, map, field, true); + if (list == null || list.isEmpty()) { + return result; + } + + for (Object object : list) { + T cast = null; + + if (clazz.isInstance(object)) { + cast = clazz.cast(object); + } + + // SPIGOT-7675 - More lenient conversion of floating point numbers from other number types: + if (clazz == Float.class || clazz == Double.class) { + if (Number.class.isInstance(object)) { + Number number = Number.class.cast(object); + if (clazz == Float.class) { + cast = clazz.cast(number.floatValue()); + } else { + cast = clazz.cast(number.doubleValue()); + } + } + } + + if (cast != null) { + result.add(cast); + } + } + + return result; + } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftCustomModelDataComponent.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftCustomModelDataComponent.java new file mode 100644 index 0000000000..634da06599 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftCustomModelDataComponent.java @@ -0,0 +1,119 @@ +package org.bukkit.craftbukkit.inventory.components; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import net.minecraft.world.item.component.CustomModelData; +import org.bukkit.Color; +import org.bukkit.configuration.serialization.SerializableAs; +import org.bukkit.craftbukkit.inventory.SerializableMeta; +import org.bukkit.inventory.meta.components.CustomModelDataComponent; + +@SerializableAs("CustomModelData") +public final class CraftCustomModelDataComponent implements CustomModelDataComponent { + + private CustomModelData handle; + + public CraftCustomModelDataComponent(CustomModelData handle) { + this.handle = handle; + } + + public CraftCustomModelDataComponent(CraftCustomModelDataComponent craft) { + this.handle = craft.handle; + } + + public CraftCustomModelDataComponent(Map map) { + handle = new CustomModelData( + SerializableMeta.getList(Float.class, map, "floats"), + SerializableMeta.getList(Boolean.class, map, "flags"), + SerializableMeta.getList(String.class, map, "strings"), + SerializableMeta.getList(Color.class, map, "colors").stream().map(Color::asRGB).toList() + ); + } + + @Override + public Map serialize() { + Map result = new LinkedHashMap<>(); + + result.put("floats", getFloats()); + result.put("flags", getFlags()); + result.put("strings", getStrings()); + result.put("colors", getColors()); + + return result; + } + + public CustomModelData getHandle() { + return handle; + } + + @Override + public List getFloats() { + return Collections.unmodifiableList(handle.floats()); + } + + @Override + public void setFloats(List floats) { + handle = new CustomModelData(new ArrayList<>(floats), handle.flags(), handle.strings(), handle.colors()); + } + + @Override + public List getFlags() { + return Collections.unmodifiableList(handle.flags()); + } + + @Override + public void setFlags(List flags) { + handle = new CustomModelData(handle.floats(), new ArrayList<>(handle.flags()), handle.strings(), handle.colors()); + } + + @Override + public List getStrings() { + return Collections.unmodifiableList(handle.strings()); + } + + @Override + public void setStrings(List strings) { + handle = new CustomModelData(handle.floats(), handle.flags(), new ArrayList<>(handle.strings()), handle.colors()); + } + + @Override + public List getColors() { + return getHandle().colors().stream().map(Color::fromRGB).toList(); + } + + @Override + public void setColors(List colors) { + handle = new CustomModelData(handle.floats(), handle.flags(), handle.strings(), new ArrayList<>(handle.colors())); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final CraftCustomModelDataComponent other = (CraftCustomModelDataComponent) obj; + return Objects.equals(this.handle, other.handle); + } + + @Override + public int hashCode() { + int hash = 7; + hash = 19 * hash + Objects.hashCode(this.handle); + return hash; + } + + @Override + public String toString() { + return "CraftCustomModelDataComponent{" + "handle=" + handle + '}'; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftEquippableComponent.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftEquippableComponent.java index f72ae5155f..56b825fe52 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftEquippableComponent.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftEquippableComponent.java @@ -12,9 +12,11 @@ import net.minecraft.core.HolderSet; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.MinecraftKey; +import net.minecraft.resources.ResourceKey; import net.minecraft.sounds.SoundEffects; import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.entity.EnumItemSlot; +import net.minecraft.world.item.equipment.EquipmentAssets; import net.minecraft.world.item.equipment.Equippable; import org.bukkit.NamespacedKey; import org.bukkit.Registry; @@ -68,7 +70,7 @@ public final class CraftEquippableComponent implements EquippableComponent { this.handle = new Equippable(slot, (equipSound != null) ? CraftSound.bukkitToMinecraftHolder(equipSound) : SoundEffects.ARMOR_EQUIP_GENERIC, - Optional.ofNullable(model).map(MinecraftKey::parse), + Optional.ofNullable(model).map(MinecraftKey::parse).map((k) -> ResourceKey.create(EquipmentAssets.ROOT_ID, k)), Optional.ofNullable(cameraOverlay).map(MinecraftKey::parse), Optional.ofNullable(allowedEntities), (dispensable != null) ? dispensable : true, @@ -116,7 +118,7 @@ public final class CraftEquippableComponent implements EquippableComponent { @Override public void setSlot(EquipmentSlot slot) { - handle = new Equippable(CraftEquipmentSlot.getNMS(slot), handle.equipSound(), handle.model(), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), handle.swappable(), handle.damageOnHurt()); + handle = new Equippable(CraftEquipmentSlot.getNMS(slot), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), handle.swappable(), handle.damageOnHurt()); } @Override @@ -126,17 +128,17 @@ public final class CraftEquippableComponent implements EquippableComponent { @Override public void setEquipSound(Sound sound) { - handle = new Equippable(handle.slot(), (sound != null) ? CraftSound.bukkitToMinecraftHolder(sound) : SoundEffects.ARMOR_EQUIP_GENERIC, handle.model(), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), handle.swappable(), handle.damageOnHurt()); + handle = new Equippable(handle.slot(), (sound != null) ? CraftSound.bukkitToMinecraftHolder(sound) : SoundEffects.ARMOR_EQUIP_GENERIC, handle.assetId(), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), handle.swappable(), handle.damageOnHurt()); } @Override public NamespacedKey getModel() { - return handle.model().map(CraftNamespacedKey::fromMinecraft).orElse(null); + return handle.assetId().map((a) -> CraftNamespacedKey.fromMinecraft(a.location())).orElse(null); } @Override public void setModel(NamespacedKey key) { - handle = new Equippable(handle.slot(), handle.equipSound(), Optional.ofNullable(key).map(CraftNamespacedKey::toMinecraft), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), handle.swappable(), handle.damageOnHurt()); + handle = new Equippable(handle.slot(), handle.equipSound(), Optional.ofNullable(key).map(CraftNamespacedKey::toMinecraft).map((k) -> ResourceKey.create(EquipmentAssets.ROOT_ID, k)), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), handle.swappable(), handle.damageOnHurt()); } @Override @@ -146,7 +148,7 @@ public final class CraftEquippableComponent implements EquippableComponent { @Override public void setCameraOverlay(NamespacedKey key) { - handle = new Equippable(handle.slot(), handle.equipSound(), handle.model(), Optional.ofNullable(key).map(CraftNamespacedKey::toMinecraft), handle.allowedEntities(), handle.dispensable(), handle.swappable(), handle.damageOnHurt()); + handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), Optional.ofNullable(key).map(CraftNamespacedKey::toMinecraft), handle.allowedEntities(), handle.dispensable(), handle.swappable(), handle.damageOnHurt()); } @Override @@ -156,7 +158,7 @@ public final class CraftEquippableComponent implements EquippableComponent { @Override public void setAllowedEntities(EntityType entities) { - handle = new Equippable(handle.slot(), handle.equipSound(), handle.model(), handle.cameraOverlay(), + handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), (entities != null) ? Optional.of(HolderSet.direct(CraftEntityType.bukkitToMinecraftHolder(entities))) : Optional.empty(), handle.dispensable(), handle.swappable(), handle.damageOnHurt() ); @@ -164,7 +166,7 @@ public final class CraftEquippableComponent implements EquippableComponent { @Override public void setAllowedEntities(Collection entities) { - handle = new Equippable(handle.slot(), handle.equipSound(), handle.model(), handle.cameraOverlay(), + handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), (entities != null) ? Optional.of(HolderSet.direct(entities.stream().map(CraftEntityType::bukkitToMinecraftHolder).collect(Collectors.toList()))) : Optional.empty(), handle.dispensable(), handle.swappable(), handle.damageOnHurt() ); @@ -174,7 +176,7 @@ public final class CraftEquippableComponent implements EquippableComponent { public void setAllowedEntities(Tag tag) { Preconditions.checkArgument(tag instanceof CraftEntityTag, "tag must be an entity tag"); - handle = new Equippable(handle.slot(), handle.equipSound(), handle.model(), handle.cameraOverlay(), + handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), (tag != null) ? Optional.of(((CraftEntityTag) tag).getHandle()) : Optional.empty(), handle.dispensable(), handle.swappable(), handle.damageOnHurt() ); @@ -187,7 +189,7 @@ public final class CraftEquippableComponent implements EquippableComponent { @Override public void setDispensable(boolean dispensable) { - handle = new Equippable(handle.slot(), handle.equipSound(), handle.model(), handle.cameraOverlay(), handle.allowedEntities(), dispensable, handle.swappable(), handle.damageOnHurt()); + handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), handle.allowedEntities(), dispensable, handle.swappable(), handle.damageOnHurt()); } @Override @@ -197,7 +199,7 @@ public final class CraftEquippableComponent implements EquippableComponent { @Override public void setSwappable(boolean swappable) { - handle = new Equippable(handle.slot(), handle.equipSound(), handle.model(), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), swappable, handle.damageOnHurt()); + handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), swappable, handle.damageOnHurt()); } @Override @@ -207,7 +209,7 @@ public final class CraftEquippableComponent implements EquippableComponent { @Override public void setDamageOnHurt(boolean damage) { - handle = new Equippable(handle.slot(), handle.equipSound(), handle.model(), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), handle.swappable(), damage); + handle = new Equippable(handle.slot(), handle.equipSound(), handle.assetId(), handle.cameraOverlay(), handle.allowedEntities(), handle.dispensable(), handle.swappable(), damage); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java index b90ee99164..b59c2cb819 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java @@ -16,7 +16,7 @@ public final class ApiVersion implements Comparable, Serializable { static { versions = new HashMap<>(); - CURRENT = getOrCreateVersion("1.21.3"); + CURRENT = getOrCreateVersion("1.21.4"); FLATTENING = getOrCreateVersion("1.13"); FIELD_NAME_PARITY = getOrCreateVersion("1.20.5"); NONE = getOrCreateVersion("none"); 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 c795b3f5bc..71cd9b42d8 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 @@ -233,7 +233,7 @@ public final class CraftMagicNumbers implements UnsafeValues { * @return string */ public String getMappingsVersion() { - return "61a218cda78417b6039da56e08194083"; + return "60ac387ca8007aa018e6aeb394a6988c"; } @Override diff --git a/paper-server/src/test/java/org/bukkit/ChatTest.java b/paper-server/src/test/java/org/bukkit/ChatTest.java index 801b6eeca4..c84d5f308b 100644 --- a/paper-server/src/test/java/org/bukkit/ChatTest.java +++ b/paper-server/src/test/java/org/bukkit/ChatTest.java @@ -31,7 +31,7 @@ public class ChatTest { CraftChatMessage.toJSON(components[0])); components = CraftChatMessage.fromString("123 " + ChatColor.GOLD + "https://spigotmc.org " + ChatColor.BOLD + "test"); - assertEquals("{\"text\":\"\",\"extra\":[\"123 \",{\"text\":\"https://spigotmc.org\",\"obfuscated\":false,\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://spigotmc.org\"},\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"color\":\"gold\",\"bold\":false},{\"text\":\" \",\"obfuscated\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"color\":\"gold\",\"bold\":false},{\"text\":\"test\",\"obfuscated\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"color\":\"gold\",\"bold\":true}]}", + assertEquals("{\"text\":\"\",\"extra\":[\"123 \",{\"text\":\"https://spigotmc.org\",\"strikethrough\":false,\"obfuscated\":false,\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://spigotmc.org\"},\"bold\":false,\"italic\":false,\"underlined\":false,\"color\":\"gold\"},{\"text\":\" \",\"strikethrough\":false,\"obfuscated\":false,\"bold\":false,\"italic\":false,\"underlined\":false,\"color\":\"gold\"},{\"text\":\"test\",\"strikethrough\":false,\"obfuscated\":false,\"bold\":true,\"italic\":false,\"underlined\":false,\"color\":\"gold\"}]}", CraftChatMessage.toJSON(components[0])); components = CraftChatMessage.fromString("multiCase http://SpigotMC.ORg/SpOngeBobMeEMeGoESHeRE"); diff --git a/paper-server/src/test/java/org/bukkit/ParticleTest.java b/paper-server/src/test/java/org/bukkit/ParticleTest.java index 598fd3ffe8..ac2808d3b4 100644 --- a/paper-server/src/test/java/org/bukkit/ParticleTest.java +++ b/paper-server/src/test/java/org/bukkit/ParticleTest.java @@ -13,7 +13,7 @@ import net.minecraft.core.particles.ParticleParamRedstone; import net.minecraft.core.particles.ParticleType; import net.minecraft.core.particles.SculkChargeParticleOptions; import net.minecraft.core.particles.ShriekParticleOption; -import net.minecraft.core.particles.TargetColorParticleOption; +import net.minecraft.core.particles.TrailParticleOption; import net.minecraft.core.particles.VibrationParticleOption; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.DynamicOpsNBT; @@ -113,8 +113,8 @@ public class ParticleTest { return; } - if (bukkit.getDataType().equals(Particle.TargetColor.class)) { - testTargetColor(bukkit, minecraft); + if (bukkit.getDataType().equals(Particle.Trail.class)) { + testTrail(bukkit, minecraft); return; } @@ -248,11 +248,11 @@ public class ParticleTest { """, bukkit.getKey(), expected, actual)); // Print expected and got since we use assert true } - private void testTargetColor(Particle bukkit, net.minecraft.core.particles.Particle minecraft) { + private void testTrail(Particle bukkit, net.minecraft.core.particles.Particle minecraft) { Color color = Color.fromRGB(236, 28, 36); - Particle.TargetColor targetColor = new Particle.TargetColor(new Location(null, 1, 5, 9), color); + Particle.Trail trail = new Particle.Trail(new Location(null, 1, 5, 9), color, 20); - TargetColorParticleOption param = createAndTest(bukkit, minecraft, targetColor, TargetColorParticleOption.class); + TrailParticleOption param = createAndTest(bukkit, minecraft, trail, TrailParticleOption.class); Vec3D pos = param.target(); assertEquals(new Vec3D(1.0, 5.0, 9.0), pos, String.format(""" 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 fc1db8b369..848730054f 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 @@ -132,6 +132,9 @@ public class LegacyTest { Material.CREAKING_SPAWN_EGG, Material.PALE_HANGING_MOSS, Material.PALE_MOSS_BLOCK, Material.PALE_MOSS_CARPET, Material.PALE_OAK_BOAT, Material.PALE_OAK_BUTTON, Material.PALE_OAK_CHEST_BOAT, Material.PALE_OAK_DOOR, Material.PALE_OAK_FENCE, Material.PALE_OAK_FENCE_GATE, Material.PALE_OAK_HANGING_SIGN, Material.PALE_OAK_LEAVES, Material.PALE_OAK_LOG, Material.PALE_OAK_PLANKS, Material.PALE_OAK_PRESSURE_PLATE, Material.PALE_OAK_SAPLING, Material.PALE_OAK_SIGN, Material.PALE_OAK_SLAB, Material.PALE_OAK_STAIRS, Material.PALE_OAK_TRAPDOOR, Material.PALE_OAK_WALL_SIGN, Material.PALE_OAK_WALL_HANGING_SIGN, Material.PALE_OAK_WOOD, Material.POTTED_PALE_OAK_SAPLING, Material.STRIPPED_PALE_OAK_LOG, Material.STRIPPED_PALE_OAK_WOOD, + // 1.21.4 + Material.OPEN_EYEBLOSSOM, Material.CLOSED_EYEBLOSSOM, Material.RESIN_CLUMP, Material.RESIN_BLOCK, Material.RESIN_BRICKS, Material.RESIN_BRICK_STAIRS, Material.RESIN_BRICK_SLAB, Material.RESIN_BRICK_WALL, Material.CHISELED_RESIN_BRICKS, + Material.RESIN_BRICK, Material.POTTED_OPEN_EYEBLOSSOM, Material.POTTED_CLOSED_EYEBLOSSOM, // 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));