diff --git a/paper-server/nms-patches/net/minecraft/commands/CommandDispatcher.patch b/paper-server/nms-patches/net/minecraft/commands/CommandDispatcher.patch index 9d902619eb..5913de86a9 100644 --- a/paper-server/nms-patches/net/minecraft/commands/CommandDispatcher.patch +++ b/paper-server/nms-patches/net/minecraft/commands/CommandDispatcher.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/commands/CommandDispatcher.java +++ b/net/minecraft/commands/CommandDispatcher.java -@@ -106,6 +106,14 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -107,6 +107,14 @@ + import net.minecraft.util.profiling.jfr.JvmProfiler; + import org.slf4j.Logger; +// CraftBukkit start +import com.google.common.base.Joiner; @@ -14,8 +14,8 @@ + public class CommandDispatcher { - private static final Logger LOGGER = LogManager.getLogger(); -@@ -117,6 +125,7 @@ + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -118,6 +126,7 @@ private final com.mojang.brigadier.CommandDispatcher dispatcher = new com.mojang.brigadier.CommandDispatcher(); public CommandDispatcher(CommandDispatcher.ServerType commanddispatcher_servertype) { @@ -23,12 +23,12 @@ CommandAdvancement.register(this.dispatcher); CommandAttribute.register(this.dispatcher); CommandExecute.register(this.dispatcher); -@@ -202,17 +211,63 @@ +@@ -204,17 +213,63 @@ } this.dispatcher.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> { -- CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.dispatcher.getPath(commandnode1), this.dispatcher.getPath(commandnode2), collection); -+ // CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.dispatcher.getPath(commandnode1), this.dispatcher.getPath(commandnode2), collection); // CraftBukkit +- CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", new Object[]{this.dispatcher.getPath(commandnode1), this.dispatcher.getPath(commandnode2), collection}); ++ // CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", new Object[]{this.dispatcher.getPath(commandnode1), this.dispatcher.getPath(commandnode2), collection}); // CraftBukkit }); + // CraftBukkit start + } @@ -89,7 +89,7 @@ stringreader.skip(); } -@@ -236,7 +291,7 @@ +@@ -238,7 +293,7 @@ if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) { int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor()); IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).withStyle(EnumChatFormat.GRAY).withStyle((chatmodifier) -> { @@ -98,7 +98,7 @@ }); if (j > 10) { -@@ -286,11 +341,36 @@ +@@ -288,11 +343,36 @@ } public void sendCommands(EntityPlayer entityplayer) { @@ -136,7 +136,7 @@ entityplayer.connection.send(new PacketPlayOutCommands(rootcommandnode)); } -@@ -301,7 +381,7 @@ +@@ -303,7 +383,7 @@ CommandNode commandnode2 = (CommandNode) iterator.next(); if (commandnode2.canUse(commandlistenerwrapper)) { @@ -145,7 +145,7 @@ argumentbuilder.requires((icompletionprovider) -> { return true; -@@ -324,7 +404,7 @@ +@@ -326,7 +406,7 @@ argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect())); } diff --git a/paper-server/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch b/paper-server/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch index 4fbe5d0d4c..bb92fd0cfd 100644 --- a/paper-server/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch +++ b/paper-server/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch @@ -50,7 +50,7 @@ entityplayer.sendMessage(ichatmutablecomponent, SystemUtils.NIL_UUID); } } -@@ -279,4 +296,10 @@ +@@ -287,4 +304,10 @@ public IRegistryCustom registryAccess() { return this.server.registryAccess(); } diff --git a/paper-server/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch b/paper-server/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch index 912accb289..99870ea711 100644 --- a/paper-server/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch +++ b/paper-server/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch @@ -9,7 +9,7 @@ private final Map vagueProperties = Maps.newHashMap(); private MinecraftKey id = new MinecraftKey(""); private BlockStateList definition; -@@ -237,7 +237,7 @@ +@@ -230,7 +230,7 @@ Iterator iterator = iblockstate.getPossibleValues().iterator(); while (iterator.hasNext()) { @@ -18,7 +18,7 @@ if (t0 instanceof Integer) { suggestionsbuilder.suggest((Integer) t0); -@@ -506,7 +506,7 @@ +@@ -493,7 +493,7 @@ Optional optional = iblockstate.getValue(s); if (optional.isPresent()) { @@ -27,7 +27,7 @@ this.properties.put(iblockstate, (Comparable) optional.get()); } else { this.reader.setCursor(i); -@@ -540,7 +540,7 @@ +@@ -527,7 +527,7 @@ private static > void appendProperty(StringBuilder stringbuilder, IBlockState iblockstate, Comparable comparable) { stringbuilder.append(iblockstate.getName()); stringbuilder.append('='); @@ -35,4 +35,4 @@ + stringbuilder.append(iblockstate.getName((T) comparable)); // CraftBukkit - decompile error } - public CompletableFuture fillSuggestions(SuggestionsBuilder suggestionsbuilder, Tags tags) { + public CompletableFuture fillSuggestions(SuggestionsBuilder suggestionsbuilder, IRegistry iregistry) { diff --git a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch index 59913877f2..96bbb6c22f 100644 --- a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch +++ b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/DispenseBehaviorBoat.java +++ b/net/minecraft/core/dispenser/DispenseBehaviorBoat.java -@@ -10,6 +10,11 @@ +@@ -9,6 +9,11 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.BlockDispenser; @@ -12,7 +12,7 @@ public class DispenseBehaviorBoat extends DispenseBehaviorItem { private final DispenseBehaviorItem defaultDispenseItemBehavior = new DispenseBehaviorItem(); -@@ -39,12 +44,40 @@ +@@ -38,12 +43,40 @@ d3 = 0.0D; } diff --git a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch index 26181a9bf2..86ae585f82 100644 --- a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch +++ b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/DispenseBehaviorShears.java +++ b/net/minecraft/core/dispenser/DispenseBehaviorShears.java -@@ -24,6 +24,12 @@ +@@ -23,6 +23,12 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AxisAlignedBB; @@ -13,7 +13,7 @@ public class DispenseBehaviorShears extends DispenseBehaviorMaybe { public DispenseBehaviorShears() {} -@@ -31,11 +37,34 @@ +@@ -30,11 +36,34 @@ @Override protected ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) { WorldServer worldserver = isourceblock.getLevel(); @@ -49,7 +49,7 @@ if (this.isSuccess() && itemstack.hurt(1, worldserver.getRandom(), (EntityPlayer) null)) { itemstack.setCount(0); } -@@ -62,7 +91,7 @@ +@@ -63,7 +92,7 @@ return false; } @@ -58,7 +58,7 @@ List list = worldserver.getEntitiesOfClass(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.NO_SPECTATORS); Iterator iterator = list.iterator(); -@@ -73,6 +102,11 @@ +@@ -74,6 +103,11 @@ IShearable ishearable = (IShearable) entityliving; if (ishearable.readyForShearing()) { diff --git a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.patch b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.patch index ae3b9e0eeb..fdced11b9f 100644 --- a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.patch +++ b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.java +++ b/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.java @@ -11,6 +11,11 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import net.minecraft.world.level.block.BlockDispenser; + import org.slf4j.Logger; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -11,7 +11,7 @@ + public class DispenseBehaviorShulkerBox extends DispenseBehaviorMaybe { - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); @@ -27,6 +32,30 @@ BlockPosition blockposition = isourceblock.getPos().relative(enumdirection); EnumDirection enumdirection1 = isourceblock.getLevel().isEmptyBlock(blockposition.below()) ? enumdirection : EnumDirection.UP; 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 2c7b9c0a21..cd0bd5e370 100644 --- a/paper-server/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch +++ b/paper-server/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/core/dispenser/IDispenseBehavior.java +++ b/net/minecraft/core/dispenser/IDispenseBehavior.java -@@ -76,6 +76,21 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -75,6 +75,21 @@ + import net.minecraft.world.phys.MovingObjectPositionBlock; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.world.item.ItemBucket; @@ -21,8 +21,8 @@ + public interface IDispenseBehavior { - Logger LOGGER = LogManager.getLogger(); -@@ -200,14 +215,42 @@ + Logger LOGGER = LogUtils.getLogger(); +@@ -199,14 +214,42 @@ EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING); EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(itemstack.getTag()); @@ -67,7 +67,7 @@ isourceblock.getLevel().gameEvent(GameEvent.ENTITY_PLACE, isourceblock.getPos()); return itemstack; } -@@ -226,12 +269,40 @@ +@@ -225,12 +268,40 @@ EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING); BlockPosition blockposition = isourceblock.getPos().relative(enumdirection); WorldServer worldserver = isourceblock.getLevel(); @@ -109,7 +109,7 @@ return itemstack; } }); -@@ -250,8 +321,35 @@ +@@ -249,8 +320,35 @@ }); if (!list.isEmpty()) { @@ -146,7 +146,7 @@ this.setSuccess(true); return itemstack; } else { -@@ -278,7 +376,35 @@ +@@ -277,7 +375,35 @@ entityhorseabstract = (EntityHorseAbstract) iterator1.next(); } while (!entityhorseabstract.isArmor(itemstack) || entityhorseabstract.isWearingArmor() || !entityhorseabstract.isTamed()); @@ -183,7 +183,7 @@ this.setSuccess(true); return itemstack; } -@@ -321,9 +447,35 @@ +@@ -320,9 +446,35 @@ } entityhorsechestedabstract = (EntityHorseChestedAbstract) iterator1.next(); @@ -221,7 +221,7 @@ this.setSuccess(true); return itemstack; } -@@ -332,12 +484,41 @@ +@@ -331,12 +483,41 @@ @Override public ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) { EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING); @@ -264,7 +264,7 @@ return itemstack; } -@@ -359,12 +540,40 @@ +@@ -358,12 +539,40 @@ double d3 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepX(); double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepY(); double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepZ(); @@ -310,7 +310,7 @@ return itemstack; } -@@ -388,9 +597,52 @@ +@@ -387,9 +596,52 @@ BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING)); WorldServer worldserver = isourceblock.getLevel(); @@ -364,7 +364,7 @@ } else { return this.defaultDispenseItemBehavior.dispense(isourceblock, itemstack); } -@@ -416,7 +668,7 @@ +@@ -415,7 +667,7 @@ Block block = iblockdata.getBlock(); if (block instanceof IFluidSource) { @@ -373,7 +373,7 @@ if (itemstack1.isEmpty()) { return super.execute(isourceblock, itemstack); -@@ -424,6 +676,32 @@ +@@ -423,6 +675,32 @@ worldserver.gameEvent((Entity) null, GameEvent.FLUID_PICKUP, blockposition); Item item = itemstack1.getItem(); @@ -406,7 +406,7 @@ itemstack.shrink(1); if (itemstack.isEmpty()) { return new ItemStack(item); -@@ -445,14 +723,42 @@ +@@ -444,14 +722,42 @@ protected ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) { WorldServer worldserver = isourceblock.getLevel(); @@ -451,7 +451,7 @@ } else if (!BlockCampfire.canLight(iblockdata) && !CandleBlock.canLight(iblockdata) && !CandleCakeBlock.canLight(iblockdata)) { if (iblockdata.getBlock() instanceof BlockTNT) { BlockTNT.explode(worldserver, blockposition); -@@ -478,12 +784,62 @@ +@@ -477,12 +783,62 @@ this.setSuccess(true); WorldServer worldserver = isourceblock.getLevel(); BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING)); @@ -514,7 +514,7 @@ return itemstack; } -@@ -493,12 +849,41 @@ +@@ -492,12 +848,41 @@ protected ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) { WorldServer worldserver = isourceblock.getLevel(); BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING)); @@ -558,7 +558,7 @@ return itemstack; } }); -@@ -522,6 +907,30 @@ +@@ -521,6 +906,30 @@ EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING); BlockPosition blockposition = isourceblock.getPos().relative(enumdirection); @@ -589,7 +589,7 @@ if (worldserver.isEmptyBlock(blockposition) && BlockWitherSkull.canSpawnMob(worldserver, blockposition, itemstack)) { worldserver.setBlock(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.defaultBlockState().setValue(BlockSkull.ROTATION, enumdirection.getAxis() == EnumDirection.EnumAxis.Y ? 0 : enumdirection.getOpposite().get2DDataValue() * 4), 3); worldserver.gameEvent((Entity) null, GameEvent.BLOCK_PLACE, blockposition); -@@ -547,6 +956,30 @@ +@@ -546,6 +955,30 @@ BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING)); BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN; @@ -620,7 +620,7 @@ if (worldserver.isEmptyBlock(blockposition) && blockpumpkincarved.canSpawnGolem(worldserver, blockposition)) { if (!worldserver.isClientSide) { worldserver.setBlock(blockposition, blockpumpkincarved.defaultBlockState(), 3); -@@ -596,6 +1029,30 @@ +@@ -595,6 +1028,30 @@ BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING)); IBlockData iblockdata = worldserver.getBlockState(blockposition); @@ -649,5 +649,5 @@ + // CraftBukkit end + if (iblockdata.is(TagsBlock.BEEHIVES, (blockbase_blockdata) -> { - return blockbase_blockdata.hasProperty(BlockBeehive.HONEY_LEVEL); + return blockbase_blockdata.hasProperty(BlockBeehive.HONEY_LEVEL) && blockbase_blockdata.getBlock() instanceof BlockBeehive; }) && (Integer) iblockdata.getValue(BlockBeehive.HONEY_LEVEL) >= 5) { diff --git a/paper-server/nms-patches/net/minecraft/nbt/NBTCompressedStreamTools.patch b/paper-server/nms-patches/net/minecraft/nbt/NBTCompressedStreamTools.patch index b6bc218ccd..e7fb3c7967 100644 --- a/paper-server/nms-patches/net/minecraft/nbt/NBTCompressedStreamTools.patch +++ b/paper-server/nms-patches/net/minecraft/nbt/NBTCompressedStreamTools.patch @@ -4,4 +4,4 @@ +// mc-dev import package net.minecraft.nbt; - import java.io.BufferedInputStream; + import java.io.BufferedOutputStream; diff --git a/paper-server/nms-patches/net/minecraft/network/NetworkManager.patch b/paper-server/nms-patches/net/minecraft/network/NetworkManager.patch index 7e444519c1..7b38d42fc8 100644 --- a/paper-server/nms-patches/net/minecraft/network/NetworkManager.patch +++ b/paper-server/nms-patches/net/minecraft/network/NetworkManager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/NetworkManager.java +++ b/net/minecraft/network/NetworkManager.java -@@ -156,7 +156,7 @@ +@@ -168,7 +168,7 @@ } private static void genericsFtw(Packet packet, PacketListener packetlistener) { @@ -9,7 +9,7 @@ } public void setListener(PacketListener packetlistener) { -@@ -268,7 +268,7 @@ +@@ -280,7 +280,7 @@ public void disconnect(IChatBaseComponent ichatbasecomponent) { if (this.channel.isOpen()) { diff --git a/paper-server/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch b/paper-server/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch index 7949555509..bc591c26f5 100644 --- a/paper-server/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch +++ b/paper-server/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/network/protocol/PlayerConnectionUtils.java +++ b/net/minecraft/network/protocol/PlayerConnectionUtils.java @@ -7,6 +7,11 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import net.minecraft.util.thread.IAsyncTaskHandler; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.server.MinecraftServer; @@ -11,16 +11,16 @@ + public class PlayerConnectionUtils { - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); @@ -20,6 +25,7 @@ public static void ensureRunningOnSameThread(Packet packet, T t0, IAsyncTaskHandler iasynctaskhandler) throws CancelledPacketHandleException { if (!iasynctaskhandler.isSameThread()) { - iasynctaskhandler.execute(() -> { + iasynctaskhandler.executeIfPossible(() -> { + if (MinecraftServer.getServer().hasStopped() || (t0 instanceof PlayerConnection && ((PlayerConnection) t0).processedDisconnect)) return; // CraftBukkit, MC-142590 if (t0.getConnection().isConnected()) { - packet.handle(t0); - } else { -@@ -28,6 +34,10 @@ + try { + packet.handle(t0); +@@ -36,6 +42,10 @@ }); throw CancelledPacketHandleException.RUNNING_ON_DIFFERENT_THREAD; diff --git a/paper-server/nms-patches/net/minecraft/server/DispenserRegistry.patch b/paper-server/nms-patches/net/minecraft/server/DispenserRegistry.patch index e01e33b283..b4760db655 100644 --- a/paper-server/nms-patches/net/minecraft/server/DispenserRegistry.patch +++ b/paper-server/nms-patches/net/minecraft/server/DispenserRegistry.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/DispenserRegistry.java +++ b/net/minecraft/server/DispenserRegistry.java -@@ -34,6 +34,12 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -33,6 +33,12 @@ + import net.minecraft.world.level.levelgen.placement.PlacedFeature; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.util.datafix.fixes.DataConverterFlattenData; @@ -13,7 +13,7 @@ public class DispenserRegistry { public static final PrintStream STDOUT = System.out; -@@ -44,6 +50,23 @@ +@@ -43,6 +49,23 @@ public static void bootStrap() { if (!DispenserRegistry.isBootstrapped) { @@ -37,8 +37,8 @@ DispenserRegistry.isBootstrapped = true; if (IRegistry.REGISTRY.keySet().isEmpty()) { throw new IllegalStateException("Unable to load registries"); -@@ -61,6 +84,69 @@ - TagStatic.bootStrap(); +@@ -60,6 +83,69 @@ + IRegistry.freezeBuiltins(); wrapStreams(); } + // CraftBukkit start - easier than fixing the decompile diff --git a/paper-server/nms-patches/net/minecraft/server/Main.patch b/paper-server/nms-patches/net/minecraft/server/Main.patch index 676a92a49b..0192c13161 100644 --- a/paper-server/nms-patches/net/minecraft/server/Main.patch +++ b/paper-server/nms-patches/net/minecraft/server/Main.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -56,6 +56,12 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -57,6 +57,12 @@ + import net.minecraft.world.level.storage.WorldInfo; + import org.slf4j.Logger; +// CraftBukkit start ++import java.util.concurrent.atomic.AtomicReference; +import net.minecraft.SharedConstants; -+import net.minecraft.world.level.dimension.DimensionManager; +import net.minecraft.world.level.dimension.WorldDimension; +// CraftBukkit end + public class Main { - private static final Logger LOGGER; -@@ -63,8 +69,9 @@ + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -64,8 +70,9 @@ public Main() {} @DontObfuscate @@ -24,7 +24,7 @@ OptionParser optionparser = new OptionParser(); OptionSpec optionspec = optionparser.accepts("nogui"); OptionSpec optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); -@@ -89,9 +96,12 @@ +@@ -90,9 +97,12 @@ optionparser.printHelpOn(System.err); return; } @@ -39,8 +39,8 @@ } @@ -100,13 +110,13 @@ + DispenserRegistry.validate(); SystemUtils.startTimerHackThread(); - IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.builtin(); Path path = Paths.get("server.properties"); - DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(path); + DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(optionset); // CraftBukkit - CLI argument support @@ -73,10 +73,10 @@ WorldInfo worldinfo = convertable_conversionsession.getSummary(); if (worldinfo != null) { -@@ -139,13 +150,30 @@ +@@ -138,13 +149,32 @@ + } } - DataPackConfiguration datapackconfiguration = convertable_conversionsession.getDataPacks(); - boolean flag = optionset.has(optionspec6); + boolean flag = optionset.has("safeMode"); @@ -101,26 +101,49 @@ + } catch (java.io.IOException ex) { + throw new RuntimeException("Could not initialize Bukkit datapack", ex); + } ++ AtomicReference config = new AtomicReference<>(); ++ AtomicReference> ops = new AtomicReference<>(); + // CraftBukkit end - DataPackConfiguration datapackconfiguration1 = MinecraftServer.configurePackRepository(resourcepackrepository, datapackconfiguration == null ? DataPackConfiguration.DEFAULT : datapackconfiguration, flag); - CompletableFuture completablefuture = DataPackResources.loadResources(resourcepackrepository.openAllSelected(), iregistrycustom_dimension, CommandDispatcher.ServerType.DEDICATED, dedicatedserversettings.getProperties().functionPermissionLevel, SystemUtils.backgroundExecutor(), Runnable::run); -@@ -160,6 +188,7 @@ + WorldStem worldstem; + +@@ -158,6 +188,12 @@ + }, (iresourcemanager, datapackconfiguration) -> { + IRegistryCustom.e iregistrycustom_e = IRegistryCustom.builtinCopy(); + DynamicOps dynamicops = RegistryOps.createAndLoad(DynamicOpsNBT.INSTANCE, iregistrycustom_e, iresourcemanager); ++ // CraftBukkit start ++ config.set(datapackconfiguration); ++ ops.set(dynamicops); ++ return Pair.of(null, iregistrycustom_e.freeze()); ++ // CraftBukkit end ++ /* + SaveData savedata = convertable_conversionsession.getDataTag(dynamicops, datapackconfiguration, iregistrycustom_e.allElementsLifecycle()); + + if (savedata != null) { +@@ -180,6 +216,7 @@ + + return Pair.of(worlddataserver, iregistrycustom_e.freeze()); + } ++ */ + }, SystemUtils.backgroundExecutor(), Runnable::run).get(); + } catch (Exception exception) { + Main.LOGGER.warn("Failed to load datapacks, can't proceed with server load. You can either fix your datapacks or reset to vanilla with --safeMode", exception); +@@ -188,6 +225,7 @@ } - datapackresources.updateGlobals(); + worldstem.updateGlobals(); + /* - RegistryReadOps registryreadops = RegistryReadOps.createAndLoad(DynamicOpsNBT.INSTANCE, datapackresources.getResourceManager(), iregistrycustom_dimension); + IRegistryCustom.Dimension iregistrycustom_dimension = worldstem.registryAccess(); dedicatedserversettings.getProperties().getWorldGenSettings(iregistrycustom_dimension); -@@ -189,21 +218,32 @@ +@@ -200,21 +238,32 @@ } - convertable_conversionsession.saveDataTag(iregistrycustom_dimension, (SaveData) object); + convertable_conversionsession.saveDataTag(iregistrycustom_dimension, savedata); + */ final DedicatedServer dedicatedserver = (DedicatedServer) MinecraftServer.spin((thread) -> { -- DedicatedServer dedicatedserver1 = new DedicatedServer(thread, iregistrycustom_dimension, convertable_conversionsession, resourcepackrepository, datapackresources, object, dedicatedserversettings, DataConverterRegistry.getDataFixer(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new); -+ DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, datapackconfiguration1, thread, iregistrycustom_dimension, convertable_conversionsession, resourcepackrepository, datapackresources, null, dedicatedserversettings, DataConverterRegistry.getDataFixer(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new); +- DedicatedServer dedicatedserver1 = new DedicatedServer(thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new); ++ DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, config.get(), ops.get(), thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new); + /* dedicatedserver1.setSingleplayerName((String) optionset.valueOf(optionspec8)); @@ -148,15 +171,15 @@ Thread thread = new Thread("Server Shutdown Thread") { public void run() { dedicatedserver.halt(true); -@@ -212,6 +252,7 @@ +@@ -223,6 +272,7 @@ thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER)); Runtime.getRuntime().addShutdownHook(thread); + */ // CraftBukkit end } catch (Exception exception1) { - Main.LOGGER.fatal("Failed to start the minecraft server", exception1); + Main.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", exception1); } -@@ -219,7 +260,7 @@ +@@ -230,7 +280,7 @@ } public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, GeneratorSettings generatorsettings) { diff --git a/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch b/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch index b2ffda4c1a..5acdddefcb 100644 --- a/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch +++ b/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -160,6 +160,27 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -163,6 +163,26 @@ + import org.apache.commons.lang3.Validate; + import org.slf4j.Logger; +// CraftBukkit start +import com.mojang.serialization.DynamicOps; @@ -11,7 +11,6 @@ +import joptsimple.OptionSet; +import net.minecraft.nbt.DynamicOpsNBT; +import net.minecraft.nbt.NBTBase; -+import net.minecraft.resources.RegistryReadOps; +import net.minecraft.server.dedicated.DedicatedServer; +import net.minecraft.server.dedicated.DedicatedServerProperties; +import net.minecraft.util.datafix.DataConverterRegistry; @@ -27,14 +26,14 @@ + public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant implements ICommandListener, AutoCloseable { - public static final Logger LOGGER = LogManager.getLogger(); -@@ -252,6 +273,21 @@ + public static final Logger LOGGER = LogUtils.getLogger(); +@@ -255,6 +275,21 @@ protected SaveData worldData; private volatile boolean isSaving; + // CraftBukkit start + public final DataPackConfiguration datapackconfiguration; -+ public final RegistryReadOps registryreadops; ++ public final DynamicOps registryreadops; + public org.bukkit.craftbukkit.CraftServer server; + public OptionSet options; + public org.bukkit.command.ConsoleCommandSender console; @@ -50,7 +49,7 @@ public static S spin(Function function) { AtomicReference atomicreference = new AtomicReference(); Thread thread = new Thread(() -> { -@@ -265,14 +301,14 @@ +@@ -268,14 +303,14 @@ thread.setPriority(8); } @@ -62,12 +61,12 @@ return s0; } -- public MinecraftServer(Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, SaveData savedata, ResourcePackRepository resourcepackrepository, Proxy proxy, DataFixer datafixer, DataPackResources datapackresources, @Nullable MinecraftSessionService minecraftsessionservice, @Nullable GameProfileRepository gameprofilerepository, @Nullable UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { -+ public MinecraftServer(OptionSet options, DataPackConfiguration datapackconfiguration, Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, SaveData savedata, ResourcePackRepository resourcepackrepository, Proxy proxy, DataFixer datafixer, DataPackResources datapackresources, @Nullable MinecraftSessionService minecraftsessionservice, @Nullable GameProfileRepository gameprofilerepository, @Nullable UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { +- public MinecraftServer(Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, @Nullable MinecraftSessionService minecraftsessionservice, @Nullable GameProfileRepository gameprofilerepository, @Nullable UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { ++ public MinecraftServer(OptionSet options, DataPackConfiguration datapackconfiguration, DynamicOps registryreadops, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, @Nullable MinecraftSessionService minecraftsessionservice, @Nullable GameProfileRepository gameprofilerepository, @Nullable UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { super("Server"); this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; this.profiler = this.metricsRecorder.getProfiler(); -@@ -284,7 +320,7 @@ +@@ -287,7 +322,7 @@ this.status = new ServerPing(); this.random = new Random(); this.port = -1; @@ -76,15 +75,15 @@ this.running = true; this.tickTimes = new long[100]; this.resourcePack = ""; -@@ -314,13 +350,41 @@ - this.structureManager = new DefinedStructureManager(datapackresources.getResourceManager(), convertable_conversionsession, datafixer); +@@ -317,13 +352,41 @@ + this.structureManager = new DefinedStructureManager(worldstem.resourceManager(), convertable_conversionsession, datafixer); this.serverThread = thread; this.executor = SystemUtils.backgroundExecutor(); + // CraftBukkit start + this.options = options; + this.datapackconfiguration = datapackconfiguration; -+ this.registryreadops = RegistryReadOps.createAndLoad(DynamicOpsNBT.INSTANCE, datapackresources.getResourceManager(), iregistrycustom_dimension); -+ this.vanillaCommandDispatcher = datapackresources.commands; // CraftBukkit ++ this.registryreadops = registryreadops; ++ this.vanillaCommandDispatcher = worldstem.dataPackResources().commands; // CraftBukkit + // Try to see if we're actually running in a terminal, disable jline if not + if (System.console() == null && System.getProperty("jline.terminal") == null) { + System.setProperty("jline.terminal", "jline.UnsupportedTerminal"); @@ -119,7 +118,7 @@ ScoreboardServer scoreboardserver1 = this.getScoreboard(); Objects.requireNonNull(scoreboardserver1); -@@ -329,7 +393,7 @@ +@@ -332,7 +395,7 @@ protected abstract boolean initServer() throws IOException; @@ -128,7 +127,7 @@ if (!JvmProfiler.INSTANCE.isRunning()) { ; } -@@ -337,13 +401,8 @@ +@@ -340,13 +403,8 @@ boolean flag = false; ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted(); @@ -143,7 +142,7 @@ if (profiledduration != null) { profiledduration.finish(); } -@@ -358,36 +417,206 @@ +@@ -361,36 +419,206 @@ } @@ -152,7 +151,7 @@ + private void loadWorld0(String s) { + Convertable.ConversionSession worldSession = this.storageSource; + IRegistryCustom.Dimension iregistrycustom_dimension = this.registryHolder; -+ WorldDataServer overworldData = (WorldDataServer) worldSession.getDataTag(registryreadops, datapackconfiguration); ++ WorldDataServer overworldData = (WorldDataServer) worldSession.getDataTag(registryreadops, datapackconfiguration, iregistrycustom_dimension.allElementsLifecycle()); + if (overworldData == null) { + WorldSettings worldsettings; + GeneratorSettings generatorsettings; @@ -170,16 +169,16 @@ - long i = generatorsettings.seed(); - long j = BiomeManager.obfuscateSeed(i); - List list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver)); -- RegistryMaterials registrymaterials = generatorsettings.dimensions(); -- WorldDimension worlddimension = (WorldDimension) registrymaterials.get(WorldDimension.OVERWORLD); -- DimensionManager dimensionmanager; +- IRegistry iregistry = generatorsettings.dimensions(); +- WorldDimension worlddimension = (WorldDimension) iregistry.get(WorldDimension.OVERWORLD); +- Holder holder; - Object object; - - if (worlddimension == null) { -- dimensionmanager = (DimensionManager) this.registryHolder.registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrThrow(DimensionManager.OVERWORLD_LOCATION); -- object = GeneratorSettings.makeDefaultOverworld(this.registryHolder, (new Random()).nextLong()); +- holder = this.registryAccess().registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrCreateHolder(DimensionManager.OVERWORLD_LOCATION); +- object = GeneratorSettings.makeDefaultOverworld(this.registryAccess(), (new Random()).nextLong()); - } else { -- dimensionmanager = worlddimension.type(); +- holder = worlddimension.typeHolder(); - object = worlddimension.generator(); + worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), datapackconfiguration); + generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.getWorldGenSettings(iregistrycustom_dimension).withBonusChest() : dedicatedserverproperties.getWorldGenSettings(iregistrycustom_dimension); @@ -189,9 +188,9 @@ + } + + GeneratorSettings overworldSettings = overworldData.worldGenSettings(); -+ RegistryMaterials registrymaterials = overworldSettings.dimensions(); -+ for (Entry, WorldDimension> entry : registrymaterials.entrySet()) { -+ ResourceKey dimensionKey = entry.getKey(); ++ IRegistry iregistry = overworldSettings.dimensions(); ++ for (WorldDimension worldDimension : iregistry) { ++ ResourceKey dimensionKey = iregistry.getResourceKey(worldDimension).get(); + + WorldServer world; + int dimension = 0; @@ -259,7 +258,7 @@ + org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name); + org.bukkit.generator.BiomeProvider biomeProvider = this.server.getBiomeProvider(name); + -+ WorldDataServer worlddata = (WorldDataServer) worldSession.getDataTag((DynamicOps) registryreadops, datapackconfiguration); ++ WorldDataServer worlddata = (WorldDataServer) worldSession.getDataTag((DynamicOps) registryreadops, datapackconfiguration, iregistrycustom_dimension.allElementsLifecycle()); + if (worlddata == null) { + WorldSettings worldsettings; + GeneratorSettings generatorsettings; @@ -289,27 +288,27 @@ + long i = generatorsettings.seed(); + long j = BiomeManager.obfuscateSeed(i); + List list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver)); -+ WorldDimension worlddimension = (WorldDimension) registrymaterials.get(dimensionKey); -+ DimensionManager dimensionmanager; ++ WorldDimension worlddimension = (WorldDimension) iregistry.get(dimensionKey); ++ Holder holder; + ChunkGenerator chunkgenerator; + + if (worlddimension == null) { -+ dimensionmanager = (DimensionManager) this.registryHolder.registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrThrow(DimensionManager.OVERWORLD_LOCATION); ++ holder = this.registryAccess().registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrCreateHolder(DimensionManager.OVERWORLD_LOCATION); + chunkgenerator = GeneratorSettings.makeDefaultOverworld(this.registryHolder, (new Random()).nextLong()); + } else { -+ dimensionmanager = worlddimension.type(); ++ holder = worlddimension.typeHolder(); + chunkgenerator = worlddimension.generator(); + } + -+ org.bukkit.generator.WorldInfo worldInfo = new org.bukkit.craftbukkit.generator.CraftWorldInfo(iworlddataserver, worldSession, org.bukkit.World.Environment.getEnvironment(dimension), dimensionmanager); ++ org.bukkit.generator.WorldInfo worldInfo = new org.bukkit.craftbukkit.generator.CraftWorldInfo(iworlddataserver, worldSession, org.bukkit.World.Environment.getEnvironment(dimension), holder.value()); + if (biomeProvider == null && gen != null) { + biomeProvider = gen.getDefaultBiomeProvider(worldInfo); + } + + if (biomeProvider != null) { + WorldChunkManager worldChunkManager = new CustomWorldChunkManager(worldInfo, biomeProvider, registryHolder.ownedRegistryOrThrow(IRegistry.BIOME_REGISTRY)); -+ if (chunkgenerator instanceof ChunkGeneratorAbstract) { -+ chunkgenerator = new ChunkGeneratorAbstract(((ChunkGeneratorAbstract) chunkgenerator).noises, worldChunkManager, chunkgenerator.strongholdSeed, ((ChunkGeneratorAbstract) chunkgenerator).settings); ++ if (chunkgenerator instanceof ChunkGeneratorAbstract cga) { ++ chunkgenerator = new ChunkGeneratorAbstract(cga.structureSets, cga.noises, worldChunkManager, chunkgenerator.ringPlacementSeed, cga.settings); + } + } + @@ -321,14 +320,14 @@ + + WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11); + -+ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, list, true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider); ++ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, holder, worldloadlistener, chunkgenerator, flag, j, list, true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider); + WorldPersistentData worldpersistentdata = world.getDataStorage(); + this.readScoreboard(worldpersistentdata); + this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard()); + this.commandStorage = new PersistentCommandStorage(worldpersistentdata); + } else { + WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11); -+ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider); ++ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, holder, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider); + } + + worlddata.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified()); @@ -348,7 +347,7 @@ + this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(worldserver.getWorld())); } -- WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, dimensionmanager, worldloadlistener, (ChunkGenerator) object, flag, j, list, true); +- WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, holder, worldloadlistener, (ChunkGenerator) object, flag, j, list, true); + this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD); + this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP)); + this.connection.acceptConnections(); @@ -374,7 +373,7 @@ if (!iworlddataserver.isInitialized()) { try { -@@ -411,31 +640,8 @@ +@@ -414,31 +642,8 @@ iworlddataserver.setInitialized(true); } @@ -383,7 +382,7 @@ - this.getCustomBossEvents().load(this.worldData.getCustomBossEvents()); - } - -- Iterator iterator = registrymaterials.entrySet().iterator(); +- Iterator iterator = iregistry.entrySet().iterator(); - - while (iterator.hasNext()) { - Entry, WorldDimension> entry = (Entry) iterator.next(); @@ -391,10 +390,10 @@ - - if (resourcekey != WorldDimension.OVERWORLD) { - ResourceKey resourcekey1 = ResourceKey.create(IRegistry.DIMENSION_REGISTRY, resourcekey.location()); -- DimensionManager dimensionmanager1 = ((WorldDimension) entry.getValue()).type(); +- Holder holder1 = ((WorldDimension) entry.getValue()).typeHolder(); - ChunkGenerator chunkgenerator = ((WorldDimension) entry.getValue()).generator(); - SecondaryWorldData secondaryworlddata = new SecondaryWorldData(this.worldData, iworlddataserver); -- WorldServer worldserver1 = new WorldServer(this, this.executor, this.storageSource, secondaryworlddata, resourcekey1, dimensionmanager1, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), false); +- WorldServer worldserver1 = new WorldServer(this, this.executor, this.storageSource, secondaryworlddata, resourcekey1, holder1, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), false); - - worldborder.addListener(new IWorldBorderListener.a(worldserver1.getWorldBorder())); - this.levels.put(resourcekey1, worldserver1); @@ -407,7 +406,7 @@ private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) { if (flag1) { -@@ -443,6 +649,21 @@ +@@ -446,6 +651,21 @@ } else { ChunkGenerator chunkgenerator = worldserver.getChunkSource().getGenerator(); ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkgenerator.climateSampler().findSpawnPosition()); @@ -429,7 +428,7 @@ int i = chunkgenerator.getSpawnHeight(worldserver); if (i < worldserver.getMinBuildHeight()) { -@@ -500,8 +721,15 @@ +@@ -503,8 +723,15 @@ iworlddataserver.setGameType(EnumGamemode.SPECTATOR); } @@ -447,7 +446,7 @@ MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location()); BlockPosition blockposition = worldserver.getSharedSpawnPos(); -@@ -514,16 +742,20 @@ +@@ -517,16 +744,20 @@ chunkproviderserver.addRegionTicket(TicketType.START, new ChunkCoordIntPair(blockposition), 11, Unit.INSTANCE); while (chunkproviderserver.getTickingGenerated() != 441) { @@ -476,7 +475,7 @@ ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk::load, "chunks"); if (forcedchunk != null) { -@@ -538,11 +770,18 @@ +@@ -541,11 +772,18 @@ } } @@ -498,7 +497,7 @@ } protected void detectBundledResources() { -@@ -587,12 +826,16 @@ +@@ -590,12 +828,16 @@ worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2); } @@ -509,13 +508,13 @@ iworlddataserver.setWorldBorder(worldserver1.getWorldBorder().createSettings()); this.worldData.setCustomBossEvents(this.getCustomBossEvents().save()); - this.storageSource.saveDataTag(this.registryHolder, this.worldData, this.getPlayerList().getSingleplayerData()); + this.storageSource.saveDataTag(this.registryAccess(), this.worldData, this.getPlayerList().getSingleplayerData()); + */ + // CraftBukkit end if (flag1) { Iterator iterator1 = this.getAllLevels().iterator(); -@@ -627,8 +870,29 @@ +@@ -630,8 +872,29 @@ this.stopServer(); } @@ -545,7 +544,7 @@ if (this.getConnection() != null) { this.getConnection().stop(); } -@@ -638,6 +902,7 @@ +@@ -641,6 +904,7 @@ MinecraftServer.LOGGER.info("Saving players"); this.playerList.saveAll(); this.playerList.removeAll(); @@ -553,7 +552,7 @@ } MinecraftServer.LOGGER.info("Saving worlds"); -@@ -712,9 +977,10 @@ +@@ -732,9 +996,10 @@ while (this.running) { long i = SystemUtils.getMillis() - this.nextTickTime; @@ -565,15 +564,15 @@ MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j); this.nextTickTime += j * 50L; this.lastOverloadWarning = this.nextTickTime; -@@ -725,6 +991,7 @@ - this.debugCommandProfiler = new MinecraftServer.a(SystemUtils.getNanos(), this.tickCount); +@@ -745,6 +1010,7 @@ + this.debugCommandProfiler = new MinecraftServer.b(SystemUtils.getNanos(), this.tickCount); } + MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit this.nextTickTime += 50L; this.startMetricsRecordingTick(); this.profiler.push("tick"); -@@ -775,6 +1042,12 @@ +@@ -789,6 +1055,12 @@ this.profileCache.clearExecutor(); } @@ -586,7 +585,7 @@ this.onServerExit(); } -@@ -783,8 +1056,15 @@ +@@ -822,8 +1094,15 @@ } private boolean haveTime() { @@ -603,7 +602,7 @@ protected void waitUntilNextTick() { this.runAllTasks(); -@@ -830,7 +1110,7 @@ +@@ -869,7 +1148,7 @@ } } @@ -612,7 +611,7 @@ this.getProfiler().incrementCounter("runTask"); super.doRunTask(ticktask); } -@@ -901,7 +1181,7 @@ +@@ -940,7 +1219,7 @@ } } @@ -621,7 +620,7 @@ MinecraftServer.LOGGER.debug("Autosave started"); this.profiler.push("save"); this.saveEverything(true, false, false); -@@ -920,22 +1200,39 @@ +@@ -959,22 +1238,39 @@ } public void tickChildren(BooleanSupplier booleansupplier) { @@ -661,7 +660,7 @@ this.profiler.push("tick"); -@@ -1024,7 +1321,7 @@ +@@ -1063,7 +1359,7 @@ @DontObfuscate public String getServerModName() { @@ -670,9 +669,9 @@ } public SystemReport fillSystemReport(SystemReport systemreport) { -@@ -1354,16 +1651,17 @@ - +@@ -1406,11 +1702,11 @@ public CompletableFuture reloadResources(Collection collection) { + IRegistryCustom.Dimension iregistrycustom_dimension = this.registryAccess(); CompletableFuture completablefuture = CompletableFuture.supplyAsync(() -> { - Stream stream = collection.stream(); + Stream stream = collection.stream(); // CraftBukkit - decompile error @@ -682,15 +681,17 @@ - return (ImmutableList) stream.map(resourcepackrepository::getPack).filter(Objects::nonNull).map(ResourcePackLoader::open).collect(ImmutableList.toImmutableList()); + return stream.map(resourcepackrepository::getPack).filter(Objects::nonNull).map(ResourcePackLoader::open).collect(ImmutableList.toImmutableList()); // CraftBukkit - decompile error }, this).thenCompose((immutablelist) -> { - return DataPackResources.loadResources(immutablelist, this.registryHolder, this.isDedicatedServer() ? CommandDispatcher.ServerType.DEDICATED : CommandDispatcher.ServerType.INTEGRATED, this.getFunctionCompilationLevel(), this.executor, this); - }).thenAcceptAsync((datapackresources) -> { + ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist); + +@@ -1425,6 +1721,7 @@ + }).thenAcceptAsync((minecraftserver_a) -> { this.resources.close(); - this.resources = datapackresources; + this.resources = minecraftserver_a; + this.server.syncCommands(); // SPIGOT-5884: Lost on reload this.packRepository.setSelected(collection); this.worldData.setDataPackConfig(getSelectedPacks(this.packRepository)); - datapackresources.updateGlobals(); -@@ -1717,7 +2015,7 @@ + this.resources.managers.updateRegistryTags(this.registryAccess()); +@@ -1774,7 +2071,7 @@ try { label51: { @@ -699,7 +700,7 @@ try { arraylist = Lists.newArrayList(NativeModuleLister.listModules()); -@@ -1767,6 +2065,22 @@ +@@ -1824,6 +2121,22 @@ } @@ -722,3 +723,24 @@ private void startMetricsRecordingTick() { if (this.willStartRecordingMetrics) { this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> { +@@ -1935,8 +2248,10 @@ + } + } + +- private static record a(IReloadableResourceManager a, DataPackResources b) implements AutoCloseable { ++ // CraftBukkit start - decompile error ++ public static record a(IReloadableResourceManager resourceManager, DataPackResources managers) implements AutoCloseable { + ++ /* + final IReloadableResourceManager resourceManager; + final DataPackResources managers; + +@@ -1944,6 +2259,8 @@ + this.resourceManager = ireloadableresourcemanager; + this.managers = datapackresources; + } ++ */ ++ // CraftBukkit end + + public void close() { + this.resourceManager.close(); diff --git a/paper-server/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch b/paper-server/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch index 0ce193f86d..291db0bda4 100644 --- a/paper-server/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch +++ b/paper-server/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/CommandSpreadPlayers.java +++ b/net/minecraft/server/commands/CommandSpreadPlayers.java -@@ -79,7 +79,7 @@ +@@ -90,7 +90,7 @@ if (entity instanceof EntityHuman) { set.add(entity.getTeam()); } else { @@ -9,7 +9,7 @@ } } -@@ -288,7 +288,7 @@ +@@ -299,7 +299,7 @@ for (boolean flag2 = iblockaccess.getBlockState(blockposition_mutableblockposition).isAir(); blockposition_mutableblockposition.getY() > iblockaccess.getMinBuildHeight(); flag2 = flag1) { blockposition_mutableblockposition.move(EnumDirection.DOWN); @@ -18,7 +18,7 @@ if (!flag1 && flag2 && flag) { return blockposition_mutableblockposition.getY() + 1; } -@@ -301,7 +301,7 @@ +@@ -312,7 +312,7 @@ public boolean isSafe(IBlockAccess iblockaccess, int i) { BlockPosition blockposition = new BlockPosition(this.x, (double) (this.getSpawnY(iblockaccess, i) - 1), this.z); @@ -27,7 +27,7 @@ Material material = iblockdata.getMaterial(); return blockposition.getY() < i && !material.isLiquid() && material != Material.FIRE; -@@ -311,5 +311,12 @@ +@@ -322,5 +322,12 @@ this.x = MathHelper.nextDouble(random, d0, d2); this.z = MathHelper.nextDouble(random, d1, d3); } diff --git a/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch b/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch index b5d366b522..e476643d21 100644 --- a/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch +++ b/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch @@ -1,12 +1,15 @@ --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -61,6 +61,15 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -59,6 +59,18 @@ + import net.minecraft.world.level.storage.Convertable; + import org.slf4j.Logger; +// CraftBukkit start ++import com.mojang.serialization.DynamicOps; ++import net.minecraft.nbt.NBTBase; +import net.minecraft.world.level.DataPackConfiguration; +import org.apache.logging.log4j.Level; ++import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.io.IoBuilder; +import org.bukkit.command.CommandSender; +import org.bukkit.event.server.ServerCommandEvent; @@ -15,21 +18,21 @@ + public class DedicatedServer extends MinecraftServer implements IMinecraftServer { - static final Logger LOGGER = LogManager.getLogger(); -@@ -81,8 +90,10 @@ + static final Logger LOGGER = LogUtils.getLogger(); +@@ -79,8 +91,10 @@ @Nullable private final IChatBaseComponent resourcePackPrompt; -- public DedicatedServer(Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, DataPackResources datapackresources, SaveData savedata, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { -- super(thread, iregistrycustom_dimension, convertable_conversionsession, savedata, resourcepackrepository, Proxy.NO_PROXY, datafixer, datapackresources, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory); +- public DedicatedServer(Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { +- super(thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory); + // CraftBukkit start - Signature changed -+ public DedicatedServer(joptsimple.OptionSet options, DataPackConfiguration datapackconfiguration, Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, DataPackResources datapackresources, SaveData savedata, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { -+ super(options, datapackconfiguration, thread, iregistrycustom_dimension, convertable_conversionsession, savedata, resourcepackrepository, Proxy.NO_PROXY, datafixer, datapackresources, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory); ++ public DedicatedServer(joptsimple.OptionSet options, DataPackConfiguration datapackconfiguration, DynamicOps registryreadops, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { ++ super(options, datapackconfiguration, registryreadops, thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory); + // CraftBukkit end this.settings = dedicatedserversettings; this.rconConsoleSource = new RemoteControlCommandListener(this); this.textFilterClient = TextFilter.createFromConfig(dedicatedserversettings.getProperties().textFilteringConfig); -@@ -93,13 +104,44 @@ +@@ -91,13 +105,44 @@ public boolean initServer() throws IOException { Thread thread = new Thread("Server console handler") { public void run() { @@ -77,7 +80,7 @@ } } catch (IOException ioexception) { DedicatedServer.LOGGER.error("Exception handling console input", ioexception); -@@ -108,6 +150,27 @@ +@@ -106,6 +151,27 @@ } }; @@ -105,7 +108,7 @@ thread.setDaemon(true); thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER)); thread.start(); -@@ -133,7 +196,7 @@ +@@ -131,7 +197,7 @@ this.setMotd(dedicatedserverproperties.motd); super.setPlayerIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get()); this.setEnforceWhitelist(dedicatedserverproperties.enforceWhitelist); @@ -114,7 +117,7 @@ DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode); InetAddress inetaddress = null; -@@ -157,6 +220,12 @@ +@@ -155,6 +221,12 @@ return false; } @@ -127,12 +130,12 @@ if (!this.usesAuthentication()) { DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); -@@ -171,13 +240,13 @@ +@@ -169,13 +241,13 @@ if (!NameReferencingFileConverter.serverReadyAfterUserconversion(this)) { return false; } else { -- this.setPlayerList(new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage)); -+ // this.setPlayerList(new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage)); // CraftBukkit - moved up +- this.setPlayerList(new DedicatedPlayerList(this, this.registryAccess(), this.playerDataStorage)); ++ // this.setPlayerList(new DedicatedPlayerList(this, this.registryAccess(), this.playerDataStorage)); // CraftBukkit - moved up long i = SystemUtils.getNanos(); TileEntitySkull.setup(this.getProfileCache(), this.getSessionService(), this); @@ -143,7 +146,7 @@ long j = SystemUtils.getNanos() - i; String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D); -@@ -194,6 +263,7 @@ +@@ -192,6 +264,7 @@ if (dedicatedserverproperties.enableRcon) { DedicatedServer.LOGGER.info("Starting remote control listener"); this.rconThread = RemoteControlListener.create(this); @@ -151,7 +154,7 @@ } if (this.getMaxTickLength() > 0L) { -@@ -337,6 +407,7 @@ +@@ -335,6 +408,7 @@ this.queryThreadGs4.stop(); } @@ -159,7 +162,7 @@ } @Override -@@ -358,7 +429,15 @@ +@@ -356,7 +430,15 @@ while (!this.consoleInput.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0); @@ -176,7 +179,7 @@ } } -@@ -568,14 +647,45 @@ +@@ -566,14 +648,45 @@ @Override public String getPluginNames() { @@ -224,7 +227,7 @@ }); return this.rconConsoleSource.getCommandResponse(); } -@@ -649,4 +759,15 @@ +@@ -647,4 +760,15 @@ public IChatBaseComponent getResourcePackPrompt() { return this.resourcePackPrompt; } diff --git a/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch b/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch index f8dacbb945..948719382d 100644 --- a/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch +++ b/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/dedicated/DedicatedServerProperties.java +++ b/net/minecraft/server/dedicated/DedicatedServerProperties.java -@@ -10,8 +10,14 @@ +@@ -13,8 +13,14 @@ import net.minecraft.world.level.EnumGamemode; import net.minecraft.world.level.levelgen.GeneratorSettings; @@ -15,7 +15,7 @@ public final boolean onlineMode = this.get("online-mode", true); public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false); public final String serverIp = this.get("server-ip", ""); -@@ -67,8 +73,10 @@ +@@ -71,8 +77,10 @@ @Nullable private GeneratorSettings worldGenSettings; @@ -28,8 +28,8 @@ this.difficulty = (EnumDifficulty) this.get("difficulty", dispatchNumberOrString(EnumDifficulty::byId, EnumDifficulty::byName), EnumDifficulty::getKey, EnumDifficulty.EASY); this.gamemode = (EnumGamemode) this.get("gamemode", dispatchNumberOrString(EnumGamemode::byId, EnumGamemode::byName), EnumGamemode::getName, EnumGamemode.SURVIVAL); this.levelName = this.get("level-name", "world"); -@@ -112,13 +120,15 @@ - this.whiteList = this.getMutable("white-list", false); +@@ -121,13 +129,15 @@ + }, "default")); } - public static DedicatedServerProperties fromFile(Path path) { @@ -48,3 +48,24 @@ dedicatedserverproperties.getWorldGenSettings(iregistrycustom); return dedicatedserverproperties; +@@ -141,8 +151,10 @@ + return this.worldGenSettings; + } + +- public static record a(String a, JsonObject b, boolean c, String d) { ++ // CraftBukkit start - decompile error ++ public static record a(String levelSeed, JsonObject generatorSettings, boolean generateStructures, String levelType) { + ++ /* + private final String levelSeed; + private final JsonObject generatorSettings; + private final boolean generateStructures; +@@ -154,6 +166,8 @@ + this.generateStructures = flag; + this.levelType = s1; + } ++ */ ++ // CraftBukkit end + + public String levelSeed() { + return this.levelSeed; diff --git a/paper-server/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch b/paper-server/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch index 9364eaa320..081898c4a9 100644 --- a/paper-server/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch +++ b/paper-server/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/dedicated/PropertyManager.java +++ b/net/minecraft/server/dedicated/PropertyManager.java @@ -17,15 +17,30 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import net.minecraft.core.IRegistryCustom; + import org.slf4j.Logger; +import joptsimple.OptionSet; // CraftBukkit + public abstract class PropertyManager> { - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); public final Properties properties; + // CraftBukkit start + private OptionSet options = null; diff --git a/paper-server/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch b/paper-server/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch index 274cbce890..dee2977df2 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ChunkMapDistance.java +++ b/net/minecraft/server/level/ChunkMapDistance.java -@@ -125,10 +125,25 @@ +@@ -126,10 +126,25 @@ } if (!this.chunksToUpdateFutures.isEmpty()) { @@ -29,7 +29,7 @@ return true; } else { if (!this.ticketsToRelease.isEmpty()) { -@@ -164,7 +179,7 @@ +@@ -165,7 +180,7 @@ } } @@ -38,7 +38,7 @@ ArraySetSorted> arraysetsorted = this.getTickets(i); int j = getTicketLevelAt(arraysetsorted); Ticket ticket1 = (Ticket) arraysetsorted.addOrGet(ticket); -@@ -174,13 +189,15 @@ +@@ -175,13 +190,15 @@ this.ticketTracker.update(i, ticket.getTicketLevel(), true); } @@ -56,7 +56,7 @@ } if (arraysetsorted.isEmpty()) { -@@ -188,6 +205,7 @@ +@@ -189,6 +206,7 @@ } this.ticketTracker.update(i, getTicketLevelAt(arraysetsorted), false); @@ -64,7 +64,7 @@ } public void addTicket(TicketType tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { -@@ -201,19 +219,33 @@ +@@ -202,19 +220,33 @@ } public void addRegionTicket(TicketType tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { @@ -100,7 +100,7 @@ } private ArraySetSorted> getTickets(long i) { -@@ -252,6 +284,7 @@ +@@ -253,6 +285,7 @@ ChunkCoordIntPair chunkcoordintpair = sectionposition.chunk(); long i = chunkcoordintpair.toLong(); ObjectSet objectset = (ObjectSet) this.playersPerChunk.get(i); @@ -108,8 +108,8 @@ objectset.remove(entityplayer); if (objectset.isEmpty()) { -@@ -347,6 +380,26 @@ - return this.tickingTicketsTracker; +@@ -382,6 +415,26 @@ + return !this.tickets.isEmpty(); } + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch b/paper-server/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch index 17df44b75b..95800dbb33 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ChunkProviderServer.java +++ b/net/minecraft/server/level/ChunkProviderServer.java -@@ -86,6 +86,24 @@ +@@ -83,6 +83,24 @@ this.clearCache(); } @@ -18,14 +18,14 @@ + if (chunk == null) { + return null; + } -+ return chunk.getFullChunkUnchecked(); ++ return chunk.getFullChunk(); + } + // CraftBukkit end + @Override public LightEngineThreaded getLightEngine() { return this.lightEngine; -@@ -130,7 +148,7 @@ +@@ -127,7 +145,7 @@ for (int l = 0; l < 4; ++l) { if (k == this.lastChunkPos[l] && chunkstatus == this.lastChunkStatus[l]) { ichunkaccess = this.lastChunk[l]; @@ -34,7 +34,7 @@ return ichunkaccess; } } -@@ -178,12 +196,12 @@ +@@ -175,12 +193,12 @@ if (playerchunk == null) { return null; } else { @@ -49,7 +49,7 @@ if (ichunkaccess1 != null) { this.storeInCache(k, ichunkaccess1, ChunkStatus.FULL); -@@ -231,7 +249,15 @@ +@@ -228,7 +246,15 @@ int l = 33 + ChunkStatus.getDistance(chunkstatus); PlayerChunk playerchunk = this.getVisibleChunkIfPresent(k); @@ -66,7 +66,7 @@ this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair); if (this.chunkAbsent(playerchunk, l)) { GameProfilerFiller gameprofilerfiller = this.level.getProfiler(); -@@ -250,7 +276,7 @@ +@@ -247,7 +273,7 @@ } private boolean chunkAbsent(@Nullable PlayerChunk playerchunk, int i) { @@ -75,7 +75,7 @@ } @Override -@@ -317,7 +343,7 @@ +@@ -314,7 +340,7 @@ } else if (!this.level.shouldTickBlocksAt(i)) { return false; } else { @@ -84,7 +84,7 @@ return either != null && either.left().isPresent(); } -@@ -330,11 +356,31 @@ +@@ -327,11 +353,31 @@ @Override public void close() throws IOException { @@ -115,7 +115,7 @@ + // CraftBukkit end + @Override - public void tick(BooleanSupplier booleansupplier) { + public void tick(BooleanSupplier booleansupplier, boolean flag) { this.level.getProfiler().push("purge"); @@ -363,7 +409,7 @@ @@ -135,7 +135,7 @@ Collections.shuffle(list); Iterator iterator1 = list.iterator(); -@@ -579,18 +625,26 @@ +@@ -581,18 +627,26 @@ } @Override @@ -164,7 +164,7 @@ final Chunk chunk; final PlayerChunk holder; -@@ -606,5 +660,7 @@ +@@ -608,5 +662,7 @@ public PlayerChunk holder() { return this.holder; } 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 8083ad0434..40d484c6eb 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/level/EntityPlayer.java +++ b/net/minecraft/server/level/EntityPlayer.java @@ -140,6 +140,33 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import net.minecraft.world.scores.criteria.IScoreboardCriteria; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.nbt.NBTBase; @@ -33,7 +33,7 @@ + public class EntityPlayer extends EntityHuman { - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); @@ -194,6 +221,20 @@ public int latency; public boolean wonGame; @@ -113,7 +113,7 @@ int i = Math.max(0, this.server.getSpawnRadius(worldserver)); int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ())); -@@ -319,11 +404,20 @@ +@@ -319,17 +404,26 @@ if (nbttagcompound.contains("recipeBook", 10)) { this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager()); } @@ -134,6 +134,13 @@ if (nbttagcompound.contains("SpawnX", 99) && nbttagcompound.contains("SpawnY", 99) && nbttagcompound.contains("SpawnZ", 99)) { this.respawnPosition = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ")); this.respawnForced = nbttagcompound.getBoolean("SpawnForced"); + this.respawnAngle = nbttagcompound.getFloat("SpawnAngle"); + if (nbttagcompound.contains("SpawnDimension")) { +- DataResult dataresult = World.RESOURCE_KEY_CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("SpawnDimension")); ++ DataResult> dataresult = World.RESOURCE_KEY_CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("SpawnDimension")); // CraftBukkit - decompile error + Logger logger = EntityPlayer.LOGGER; + + Objects.requireNonNull(logger); @@ -356,7 +450,20 @@ Entity entity = this.getRootVehicle(); Entity entity1 = this.getVehicle(); @@ -414,7 +421,7 @@ + /* WorldData worlddata = worldserver.getLevelData(); - this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionType(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true)); + this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeRegistration(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true)); @@ -780,22 +993,52 @@ playerlist.sendPlayerPermissionLevel(this); worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); @@ -454,7 +461,7 @@ + if (true) { // CraftBukkit + this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds + -+ this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionType(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true)); ++ this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeRegistration(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true)); + this.connection.send(new PacketPlayOutServerDifficulty(this.level.getDifficulty(), this.level.getLevelData().isDifficultyLocked())); + PlayerList playerlist = this.server.getPlayerList(); + diff --git a/paper-server/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch b/paper-server/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch index cddd06be26..29cf40840f 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/level/EntityTrackerEntry.java +++ b/net/minecraft/server/level/EntityTrackerEntry.java @@ -40,6 +40,12 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import net.minecraft.world.phys.Vec3D; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.server.network.ServerPlayerConnection; @@ -12,7 +12,7 @@ + public class EntityTrackerEntry { - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); @@ -61,8 +67,12 @@ private List lastPassengers; private boolean wasRiding; diff --git a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunk.patch b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunk.patch index 2625adddda..096d1de42c 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunk.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunk.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/PlayerChunk.java +++ b/net/minecraft/server/level/PlayerChunk.java -@@ -35,6 +35,10 @@ +@@ -37,6 +37,10 @@ import net.minecraft.world.level.chunk.ProtoChunkExtension; import net.minecraft.world.level.lighting.LightEngine; @@ -11,7 +11,7 @@ public class PlayerChunk { public static final Either UNLOADED_CHUNK = Either.right(PlayerChunk.Failure.UNLOADED); -@@ -72,11 +76,11 @@ +@@ -75,11 +79,11 @@ this.fullChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE; this.tickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE; this.entityTickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE; @@ -25,27 +25,7 @@ this.pos = chunkcoordintpair; this.levelHeightAccessor = levelheightaccessor; this.lightEngine = lightengine; -@@ -89,6 +93,19 @@ - this.changedBlocksPerSection = new ShortSet[levelheightaccessor.getSectionsCount()]; - } - -+ // CraftBukkit start -+ public Chunk getFullChunk() { -+ if (!getFullChunkStatus(this.oldTicketLevel).isOrAfter(PlayerChunk.State.BORDER)) return null; // note: using oldTicketLevel for isLoaded checks -+ return this.getFullChunkUnchecked(); -+ } -+ -+ public Chunk getFullChunkUnchecked() { -+ CompletableFuture> statusFuture = this.getFutureIfPresentUnchecked(ChunkStatus.FULL); -+ Either either = (Either) statusFuture.getNow(null); -+ return (either == null) ? null : (Chunk) either.left().orElse(null); -+ } -+ // CraftBukkit end -+ - public CompletableFuture> getFutureIfPresentUnchecked(ChunkStatus chunkstatus) { - CompletableFuture> completablefuture = (CompletableFuture) this.futures.get(chunkstatus.getIndex()); - -@@ -114,9 +131,9 @@ +@@ -117,17 +121,17 @@ @Nullable public Chunk getTickingChunk() { CompletableFuture> completablefuture = this.getTickingChunkFuture(); @@ -57,7 +37,17 @@ } @Nullable -@@ -161,6 +178,7 @@ + public Chunk getFullChunk() { + CompletableFuture> completablefuture = this.getFullChunkFuture(); +- Either either = (Either) completablefuture.getNow((Object) null); ++ Either either = (Either) completablefuture.getNow(null); // CraftBukkit - decompile error + +- return either == null ? null : (Chunk) either.left().orElse((Object) null); ++ return either == null ? null : (Chunk) either.left().orElse(null); // CraftBukkit - decompile error + } + + @Nullable +@@ -172,6 +176,7 @@ if (chunk != null) { int i = this.levelHeightAccessor.getSectionIndex(blockposition.getY()); @@ -65,16 +55,7 @@ if (this.changedBlocksPerSection[i] == null) { this.hasChangedSections = true; this.changedBlocksPerSection[i] = new ShortOpenHashSet(); -@@ -271,7 +289,7 @@ - CompletableFuture> completablefuture = (CompletableFuture) this.futures.get(i); - - if (completablefuture != null) { -- Either either = (Either) completablefuture.getNow((Object) null); -+ Either either = (Either) completablefuture.getNow(null); // CraftBukkit - decompile error - boolean flag = either != null && either.right().isPresent(); - - if (!flag) { -@@ -348,7 +366,7 @@ +@@ -368,7 +373,7 @@ this.pendingFullStateConfirmation = completablefuture1; completablefuture.thenAccept((either) -> { either.ifLeft((chunk) -> { @@ -83,7 +64,7 @@ }); }); } -@@ -365,6 +383,30 @@ +@@ -385,6 +390,30 @@ boolean flag1 = this.ticketLevel <= PlayerChunkMap.MAX_CHUNK_DISTANCE; PlayerChunk.State playerchunk_state = getFullChunkStatus(this.oldTicketLevel); PlayerChunk.State playerchunk_state1 = getFullChunkStatus(this.ticketLevel); @@ -103,7 +84,7 @@ + } + }).exceptionally((throwable) -> { + // ensure exceptions are printed, by default this is not the case -+ MinecraftServer.LOGGER.fatal("Failed to schedule unload callback for chunk " + PlayerChunk.this.pos, throwable); ++ MinecraftServer.LOGGER.error("Failed to schedule unload callback for chunk " + PlayerChunk.this.pos, throwable); + return null; + }); + @@ -114,7 +95,7 @@ if (flag) { Either either = Either.right(new PlayerChunk.Failure() { -@@ -435,6 +477,26 @@ +@@ -455,6 +484,26 @@ this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel); this.oldTicketLevel = this.ticketLevel; @@ -130,7 +111,7 @@ + } + }).exceptionally((throwable) -> { + // ensure exceptions are printed, by default this is not the case -+ MinecraftServer.LOGGER.fatal("Failed to schedule load callback for chunk " + PlayerChunk.this.pos, throwable); ++ MinecraftServer.LOGGER.error("Failed to schedule load callback for chunk " + PlayerChunk.this.pos, throwable); + return null; + }); + diff --git a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch index f91a56caed..c1a4dccf6c 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/level/PlayerChunkMap.java +++ b/net/minecraft/server/level/PlayerChunkMap.java -@@ -96,6 +96,11 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -98,6 +98,11 @@ + import org.apache.commons.lang3.mutable.MutableObject; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.world.level.levelgen.GeneratorSettings; @@ -12,7 +12,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.e { private static final byte CHUNK_TYPE_REPLACEABLE = -1; -@@ -135,6 +140,27 @@ +@@ -139,6 +144,27 @@ private final Queue unloadQueue; int viewDistance; @@ -40,7 +40,7 @@ public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier supplier, int i, boolean flag) { super(convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag); this.visibleChunkMap = this.updatingChunkMap.clone(); -@@ -291,9 +317,12 @@ +@@ -296,9 +322,12 @@ CompletableFuture>> completablefuture1 = SystemUtils.sequence(list); CompletableFuture, PlayerChunk.Failure>> completablefuture2 = completablefuture1.thenApply((list2) -> { List list3 = Lists.newArrayList(); @@ -53,9 +53,9 @@ + final int l1 = cnt; + // CraftBukkit end final Either either = (Either) iterator.next(); - Optional optional = either.left(); -@@ -463,7 +492,7 @@ + if (either == null) { +@@ -503,7 +532,7 @@ private void scheduleUnload(long i, PlayerChunk playerchunk) { CompletableFuture completablefuture = playerchunk.getChunkToSave(); @@ -64,7 +64,7 @@ CompletableFuture completablefuture1 = playerchunk.getChunkToSave(); if (completablefuture1 != completablefuture) { -@@ -642,7 +671,21 @@ +@@ -683,7 +712,21 @@ private static void postLoadProtoChunk(WorldServer worldserver, List list) { if (!list.isEmpty()) { @@ -87,7 +87,7 @@ } } -@@ -740,7 +783,7 @@ +@@ -782,7 +825,7 @@ if (!playerchunk.wasAccessibleSinceLastSave()) { return false; } else { @@ -96,7 +96,7 @@ if (!(ichunkaccess instanceof ProtoChunkExtension) && !(ichunkaccess instanceof Chunk)) { return false; -@@ -890,7 +933,8 @@ +@@ -944,7 +987,8 @@ return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty(); }); @@ -106,7 +106,7 @@ return chunk.getBlockEntities().size(); }).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> { return chunk.getBlockTicks().count(); -@@ -903,7 +947,7 @@ +@@ -957,7 +1001,7 @@ private static String printFuture(CompletableFuture> completablefuture) { try { @@ -115,7 +115,7 @@ return either != null ? (String) either.map((chunk) -> { return "done"; -@@ -921,7 +965,7 @@ +@@ -975,7 +1019,7 @@ private NBTTagCompound readChunk(ChunkCoordIntPair chunkcoordintpair) throws IOException { NBTTagCompound nbttagcompound = this.read(chunkcoordintpair); @@ -124,7 +124,7 @@ } boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) { -@@ -1342,7 +1386,7 @@ +@@ -1396,7 +1440,7 @@ public final Set seenBy = Sets.newIdentityHashSet(); public EntityTracker(Entity entity, int i, int j, boolean flag) { @@ -133,7 +133,7 @@ this.entity = entity; this.range = i; this.lastSectionPos = SectionPosition.of(entity); -@@ -1395,12 +1439,17 @@ +@@ -1449,12 +1493,17 @@ public void updatePlayer(EntityPlayer entityplayer) { if (entityplayer != this.entity) { diff --git a/paper-server/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch b/paper-server/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch index 1dbf787356..c929d37bb3 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/level/PlayerInteractManager.java +++ b/net/minecraft/server/level/PlayerInteractManager.java -@@ -24,6 +24,27 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -26,6 +26,27 @@ + import net.minecraft.world.phys.MovingObjectPositionBlock; + import org.slf4j.Logger; +// CraftBukkit start +import java.util.ArrayList; @@ -27,8 +27,8 @@ + public class PlayerInteractManager { - private static final Logger LOGGER = LogManager.getLogger(); -@@ -54,6 +75,13 @@ + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -56,6 +77,13 @@ if (enumgamemode == this.gameModeForPlayer) { return false; } else { @@ -42,7 +42,7 @@ this.setGameModeForPlayer(enumgamemode, this.gameModeForPlayer); return true; } -@@ -64,7 +92,7 @@ +@@ -66,7 +94,7 @@ this.gameModeForPlayer = enumgamemode; enumgamemode.updatePlayerAbilities(this.player.getAbilities()); this.player.onUpdateAbilities(); @@ -51,7 +51,7 @@ this.level.updateSleepingPlayerList(); } -@@ -86,7 +114,7 @@ +@@ -88,7 +116,7 @@ } public void tick() { @@ -60,7 +60,7 @@ IBlockData iblockdata; if (this.hasDelayedDestroy) { -@@ -142,10 +170,32 @@ +@@ -152,10 +180,32 @@ if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) { if (!this.level.mayInteract(this.player, blockposition)) { @@ -93,11 +93,11 @@ if (this.isCreative()) { this.destroyAndAck(blockposition, packetplayinblockdig_enumplayerdigtype, "creative destroy"); return; -@@ -160,11 +210,43 @@ +@@ -170,11 +220,43 @@ float f = 1.0F; - iblockdata = this.level.getBlockState(blockposition); -- if (!iblockdata.isAir()) { + iblockdata1 = this.level.getBlockState(blockposition); +- if (!iblockdata1.isAir()) { + // CraftBukkit start - Swings at air do *NOT* exist. + if (event.useInteractedBlock() == Event.Result.DENY) { + // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. @@ -110,9 +110,9 @@ + } else if (data.getBlock() instanceof BlockTrapdoor) { + this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition)); + } -+ } else if (!iblockdata.isAir()) { - iblockdata.attack(this.level, blockposition, this.player); - f = iblockdata.getDestroyProgress(this.player, this.player.level, blockposition); ++ } else if (!iblockdata1.isAir()) { + iblockdata1.attack(this.level, blockposition, this.player); + f = iblockdata1.getDestroyProgress(this.player, this.player.level, blockposition); } + if (event.useItemInHand() == Event.Result.DENY) { @@ -135,10 +135,10 @@ + } + // CraftBukkit end + - if (!iblockdata.isAir() && f >= 1.0F) { + if (!iblockdata1.isAir() && f >= 1.0F) { this.destroyAndAck(blockposition, packetplayinblockdig_enumplayerdigtype, "insta mine"); } else { -@@ -208,13 +290,15 @@ +@@ -218,13 +300,15 @@ } else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) { this.isDestroyingBlock = false; if (!Objects.equals(this.destroyPos, blockposition)) { @@ -155,7 +155,7 @@ } } -@@ -224,17 +308,72 @@ +@@ -234,17 +318,72 @@ if (this.destroyBlock(blockposition)) { this.player.connection.send(new PacketPlayOutBlockBreak(blockposition, this.level.getBlockState(blockposition), packetplayinblockdig_enumplayerdigtype, true, s)); } else { @@ -230,7 +230,7 @@ TileEntity tileentity = this.level.getBlockEntity(blockposition); Block block = iblockdata.getBlock(); -@@ -244,6 +383,10 @@ +@@ -254,6 +393,10 @@ } else if (this.player.blockActionRestricted(this.level, blockposition, this.gameModeForPlayer)) { return false; } else { @@ -241,7 +241,7 @@ block.playerWillDestroy(this.level, blockposition, iblockdata, this.player); boolean flag = this.level.removeBlock(blockposition, false); -@@ -252,19 +395,32 @@ +@@ -262,19 +405,32 @@ } if (this.isCreative()) { @@ -277,7 +277,7 @@ } } } -@@ -306,12 +462,52 @@ +@@ -316,12 +472,52 @@ } } @@ -330,7 +330,7 @@ if (itileinventory != null) { entityplayer.openMenu(itileinventory); -@@ -325,7 +521,7 @@ +@@ -335,7 +531,7 @@ ItemStack itemstack1 = itemstack.copy(); if (!flag1) { @@ -339,7 +339,7 @@ if (enuminteractionresult.consumesAction()) { CriterionTriggers.ITEM_USED_ON_BLOCK.trigger(entityplayer, blockposition, itemstack1); -@@ -333,17 +529,17 @@ +@@ -343,17 +539,17 @@ } } @@ -360,7 +360,7 @@ } if (enuminteractionresult1.consumesAction()) { -@@ -351,10 +547,10 @@ +@@ -361,10 +557,10 @@ } return enuminteractionresult1; diff --git a/paper-server/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch b/paper-server/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch index fce3851117..708f97074a 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/RegionLimitedWorldAccess.java +++ b/net/minecraft/server/level/RegionLimitedWorldAccess.java -@@ -200,7 +200,7 @@ +@@ -199,7 +199,7 @@ if (iblockdata.isAir()) { return false; } else { @@ -9,7 +9,7 @@ TileEntity tileentity = iblockdata.hasBlockEntity() ? this.getBlockEntity(blockposition) : null; Block.dropResources(iblockdata, this.level, blockposition, tileentity, entity, ItemStack.EMPTY); -@@ -319,6 +319,13 @@ +@@ -318,6 +318,13 @@ @Override public boolean addFreshEntity(Entity entity) { 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 aabb6a3a69..1b935313f3 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/WorldServer.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/WorldServer.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/level/WorldServer.java +++ b/net/minecraft/server/level/WorldServer.java -@@ -149,6 +149,20 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -150,6 +150,20 @@ + import net.minecraft.world.ticks.TickListServer; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.world.entity.monster.EntityDrowned; @@ -21,7 +21,7 @@ public class WorldServer extends World implements GeneratorAccessSeed { public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0); -@@ -166,7 +180,7 @@ +@@ -167,7 +181,7 @@ final List players; private final ChunkProviderServer chunkSource; private final MinecraftServer server; @@ -30,13 +30,13 @@ final EntityTickList entityTickList; public final PersistentEntitySectionManager entityManager; public boolean noSave; -@@ -189,9 +203,29 @@ +@@ -190,9 +204,29 @@ private final StructureCheck structureCheck; private final boolean tickTime; -- public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey resourcekey, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List list, boolean flag1) { +- public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey resourcekey, Holder holder, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List list, boolean flag1) { - Objects.requireNonNull(minecraftserver); -- super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getProfiler, false, flag, i); +- super(iworlddataserver, resourcekey, holder, minecraftserver::getProfiler, false, flag, i); + + // CraftBukkit start + private int tickPosition; @@ -53,9 +53,9 @@ + } + + // Add env and gen to constructor, WorldData -> WorldDataServer -+ public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey resourcekey, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { ++ public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey resourcekey, Holder holder, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { + // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error -+ super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getProfiler, false, flag, i, gen, biomeProvider, env); ++ super(iworlddataserver, resourcekey, holder, minecraftserver::getProfiler, false, flag, i, gen, biomeProvider, env); + this.pvpMode = minecraftserver.isPvpAllowed(); + convertable = convertable_conversionsession; + uuid = WorldUUID.getUUID(convertable_conversionsession.levelPath.toFile()); @@ -63,7 +63,7 @@ this.players = Lists.newArrayList(); this.entityTickList = new EntityTickList(); this.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier()); -@@ -203,7 +237,13 @@ +@@ -204,7 +238,13 @@ this.tickTime = flag1; this.server = minecraftserver; this.customSpawners = list; @@ -75,10 +75,10 @@ + chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen); + } + // CraftBukkit end + chunkgenerator.ensureStructuresGenerated(); boolean flag2 = minecraftserver.forceSynchronousWrites(); DataFixer datafixer = minecraftserver.getFixerUpper(); - EntityPersistentStorage entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver); -@@ -234,14 +274,15 @@ +@@ -236,14 +276,15 @@ long l = minecraftserver.getWorldData().worldGenSettings().seed(); this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this, chunkgenerator.getBiomeSource(), l, datafixer); @@ -96,7 +96,7 @@ } public void setWeatherParameters(int i, int j, boolean flag, boolean flag1) { -@@ -273,12 +314,20 @@ +@@ -275,12 +316,20 @@ long j; if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { @@ -120,7 +120,7 @@ if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) { this.resetWeatherCycle(); } -@@ -304,7 +353,7 @@ +@@ -306,7 +355,7 @@ this.runBlockEvents(); this.handlingTick = false; gameprofilerfiller.pop(); @@ -129,7 +129,7 @@ if (flag) { this.resetEmptyTime(); -@@ -320,7 +369,7 @@ +@@ -322,7 +371,7 @@ this.entityTickList.forEach((entity) -> { if (!entity.isRemoved()) { @@ -138,7 +138,7 @@ entity.discard(); } else { gameprofilerfiller.push("checkDespawn"); -@@ -392,7 +441,7 @@ +@@ -394,7 +443,7 @@ private void wakeUpAllPlayers() { this.sleepStatus.removeAllSleepers(); @@ -147,7 +147,7 @@ entityplayer.stopSleepInBed(false, false); }); } -@@ -419,14 +468,14 @@ +@@ -421,14 +470,14 @@ entityhorseskeleton.setTrap(true); entityhorseskeleton.setAge(0); entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); @@ -164,8 +164,8 @@ } } -@@ -437,12 +486,12 @@ - BiomeBase biomebase = this.getBiome(blockposition); +@@ -439,12 +488,12 @@ + BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition).value(); if (biomebase.shouldFreeze(this, blockposition1)) { - this.setBlockAndUpdate(blockposition1, Blocks.ICE.defaultBlockState()); @@ -179,7 +179,7 @@ } IBlockData iblockdata = this.getBlockState(blockposition1); -@@ -638,6 +687,7 @@ +@@ -640,6 +689,7 @@ this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F); } @@ -187,7 +187,7 @@ if (this.oRainLevel != this.rainLevel) { this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension()); } -@@ -656,14 +706,47 @@ +@@ -658,14 +708,47 @@ this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } @@ -237,7 +237,7 @@ } public void resetEmptyTime() { -@@ -698,6 +781,7 @@ +@@ -700,6 +783,7 @@ }); gameprofilerfiller.incrementCounter("tickNonPassenger"); entity.tick(); @@ -245,7 +245,7 @@ this.getProfiler().pop(); Iterator iterator = entity.getPassengers().iterator(); -@@ -721,6 +805,7 @@ +@@ -723,6 +807,7 @@ }); gameprofilerfiller.incrementCounter("tickPassenger"); entity1.rideTick(); @@ -253,7 +253,7 @@ gameprofilerfiller.pop(); Iterator iterator = entity1.getPassengers().iterator(); -@@ -745,6 +830,7 @@ +@@ -747,6 +832,7 @@ ChunkProviderServer chunkproviderserver = this.getChunkSource(); if (!flag1) { @@ -261,7 +261,7 @@ if (iprogressupdate != null) { iprogressupdate.progressStartNoAbort(new ChatMessage("menu.savingLevel")); } -@@ -762,11 +848,19 @@ +@@ -764,11 +850,19 @@ } } @@ -282,7 +282,7 @@ } this.getChunkSource().getDataStorage().save(); -@@ -812,15 +906,34 @@ +@@ -814,15 +908,34 @@ @Override public boolean addFreshEntity(Entity entity) { @@ -320,7 +320,7 @@ } public void addDuringCommandTeleport(EntityPlayer entityplayer) { -@@ -851,24 +964,36 @@ +@@ -853,24 +966,36 @@ this.entityManager.addNewEntity(entityplayer); } @@ -361,7 +361,7 @@ return true; } } -@@ -882,10 +1007,32 @@ +@@ -884,10 +1009,32 @@ entityplayer.remove(entity_removalreason); } @@ -394,7 +394,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -894,6 +1041,12 @@ +@@ -896,6 +1043,12 @@ double d1 = (double) blockposition.getY() - entityplayer.getY(); double d2 = (double) blockposition.getZ() - entityplayer.getZ(); @@ -407,7 +407,7 @@ if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); } -@@ -948,7 +1101,18 @@ +@@ -950,7 +1103,18 @@ Iterator iterator = this.navigatingMobs.iterator(); while (iterator.hasNext()) { @@ -427,7 +427,7 @@ NavigationAbstract navigationabstract = entityinsentient.getNavigation(); if (navigationabstract.shouldRecomputePath(blockposition)) { -@@ -984,10 +1148,20 @@ +@@ -986,10 +1150,20 @@ @Override public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) { @@ -448,7 +448,7 @@ if (explosion_effect == Explosion.Effect.NONE) { explosion.clearToBlow(); } -@@ -1068,13 +1242,20 @@ +@@ -1070,13 +1244,20 @@ } public int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { @@ -471,16 +471,16 @@ ++j; } } -@@ -1125,7 +1306,7 @@ +@@ -1127,7 +1308,7 @@ @Nullable - public BlockPosition findNearestMapFeature(StructureGenerator structuregenerator, BlockPosition blockposition, int i, boolean flag) { -- return !this.server.getWorldData().worldGenSettings().generateFeatures() ? null : this.getChunkSource().getGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag); -+ return !this.serverLevelData.worldGenSettings().generateFeatures() ? null : this.getChunkSource().getGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag); // CraftBukkit - } - - @Nullable -@@ -1162,11 +1343,21 @@ + public BlockPosition findNearestMapFeature(TagKey> tagkey, BlockPosition blockposition, int i, boolean flag) { +- if (!this.server.getWorldData().worldGenSettings().generateFeatures()) { ++ if (!this.serverLevelData.worldGenSettings().generateFeatures()) { // CraftBukkit + return null; + } else { + Optional>> optional = this.registryAccess().registryOrThrow(IRegistry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY).getTag(tagkey); +@@ -1169,11 +1350,21 @@ @Nullable @Override public WorldMap getMapData(String s) { @@ -503,7 +503,7 @@ this.getServer().overworld().getDataStorage().set(s, worldmap); } -@@ -1478,6 +1669,11 @@ +@@ -1485,6 +1676,11 @@ @Override public void blockUpdated(BlockPosition blockposition, Block block) { if (!this.isDebug()) { @@ -515,7 +515,7 @@ this.updateNeighborsAt(blockposition, block); } -@@ -1497,12 +1693,12 @@ +@@ -1504,12 +1700,12 @@ } public boolean isFlat() { @@ -530,7 +530,7 @@ } @Nullable -@@ -1530,7 +1726,7 @@ +@@ -1532,7 +1728,7 @@ private static String getTypeCount(Iterable iterable, Function function) { try { Object2IntOpenHashMap object2intopenhashmap = new Object2IntOpenHashMap(); @@ -539,7 +539,7 @@ while (iterator.hasNext()) { T t0 = iterator.next(); -@@ -1539,7 +1735,7 @@ +@@ -1541,7 +1737,7 @@ object2intopenhashmap.addTo(s, 1); } @@ -548,7 +548,7 @@ String s1 = (String) entry.getKey(); return s1 + ":" + entry.getIntValue(); -@@ -1550,17 +1746,33 @@ +@@ -1552,17 +1748,33 @@ } public static void makeObsidianPlatform(WorldServer worldserver) { @@ -584,7 +584,7 @@ } @Override -@@ -1666,6 +1878,7 @@ +@@ -1672,6 +1884,7 @@ } } @@ -592,7 +592,7 @@ } public void onTrackingEnd(Entity entity) { -@@ -1707,6 +1920,14 @@ +@@ -1713,6 +1926,14 @@ gameeventlistenerregistrar.onListenerRemoved(entity.level); } diff --git a/paper-server/nms-patches/net/minecraft/server/network/LoginListener.patch b/paper-server/nms-patches/net/minecraft/server/network/LoginListener.patch index 1bbda9b1c6..0b12337df4 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/LoginListener.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/LoginListener.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/network/LoginListener.java +++ b/net/minecraft/server/network/LoginListener.java @@ -36,6 +36,13 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import org.apache.commons.lang3.Validate; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.network.chat.ChatComponentText; @@ -68,7 +68,7 @@ if (entityplayer != null) { this.state = LoginListener.EnumProtocolState.DELAY_ACCEPT; -@@ -192,6 +216,43 @@ +@@ -199,6 +223,43 @@ try { LoginListener.this.gameProfile = LoginListener.this.server.getSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.getAddress()); if (LoginListener.this.gameProfile != null) { @@ -112,7 +112,7 @@ LoginListener.LOGGER.info("UUID of player {} is {}", LoginListener.this.gameProfile.getName(), LoginListener.this.gameProfile.getId()); LoginListener.this.state = LoginListener.EnumProtocolState.READY_TO_ACCEPT; } else if (LoginListener.this.server.isSingleplayer()) { -@@ -211,6 +272,11 @@ +@@ -218,6 +279,11 @@ LoginListener.this.disconnect(new ChatMessage("multiplayer.disconnect.authservers_down")); LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable"); } diff --git a/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch b/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch index 10e8a8ad85..099055718f 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/network/PlayerConnection.java +++ b/net/minecraft/server/network/PlayerConnection.java -@@ -156,6 +156,62 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -157,6 +157,62 @@ + import org.apache.commons.lang3.StringUtils; + import org.slf4j.Logger; +// CraftBukkit start +import java.util.concurrent.ExecutionException; @@ -62,8 +62,8 @@ + public class PlayerConnection implements ServerPlayerConnection, PacketListenerPlayIn { - static final Logger LOGGER = LogManager.getLogger(); -@@ -167,7 +223,9 @@ + static final Logger LOGGER = LogUtils.getLogger(); +@@ -168,7 +224,9 @@ private long keepAliveTime; private boolean keepAlivePending; private long keepAliveChallenge; @@ -74,7 +74,7 @@ private int dropSpamTickCount; private double firstGoodX; private double firstGoodY; -@@ -202,7 +260,31 @@ +@@ -203,7 +261,31 @@ entityplayer.connection = this; this.keepAliveTime = SystemUtils.getMillis(); entityplayer.getTextFilter().join(); @@ -106,7 +106,7 @@ public void tick() { this.resetPosition(); -@@ -251,7 +333,7 @@ +@@ -252,7 +334,7 @@ this.server.getProfiler().push("keepAlive"); long i = SystemUtils.getMillis(); @@ -115,7 +115,7 @@ if (this.keepAlivePending) { this.disconnect(new ChatMessage("disconnect.timeout")); } else { -@@ -263,15 +345,21 @@ +@@ -264,15 +346,21 @@ } this.server.getProfiler().pop(); @@ -137,7 +137,7 @@ this.disconnect(new ChatMessage("multiplayer.disconnect.idling")); } -@@ -295,16 +383,46 @@ +@@ -296,16 +384,46 @@ return this.server.isSingleplayerOwner(this.player.getGameProfile()); } @@ -185,7 +185,7 @@ } private void filterTextPacket(T t0, Consumer consumer, BiFunction> bifunction) { -@@ -371,7 +489,34 @@ +@@ -376,7 +494,34 @@ double d9 = entity.getDeltaMovement().lengthSqr(); double d10 = d6 * d6 + d7 * d7 + d8 * d8; @@ -218,17 +218,17 @@ + + if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { + // CraftBukkit end - PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getName().getString(), this.player.getName().getString(), d6, d7, d8); + PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8}); this.connection.send(new PacketPlayOutVehicleMove(entity)); return; -@@ -401,14 +546,72 @@ +@@ -408,14 +553,72 @@ } entity.absMoveTo(d3, d4, d5, f, f1); + player.absMoveTo(d3, d4, d5, this.player.getYRot(), this.player.getXRot()); // CraftBukkit - boolean flag2 = worldserver.noCollision(entity, entity.getBoundingBox().deflate(0.0625D)); + boolean flag3 = worldserver.noCollision(entity, entity.getBoundingBox().deflate(0.0625D)); - if (flag && (flag1 || !flag2)) { + if (flag && (flag2 || !flag3)) { entity.absMoveTo(d0, d1, d2, f, f1); + player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit this.connection.send(new PacketPlayOutVehicleMove(entity)); @@ -293,8 +293,8 @@ + this.player.getLevel().getChunkSource().move(this.player); this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2); - this.clientVehicleIsFloating = d11 >= -0.03125D && !this.server.isFlightAllowed() && this.noBlocksAround(entity); -@@ -427,7 +630,7 @@ + this.clientVehicleIsFloating = d11 >= -0.03125D && !flag1 && !this.server.isFlightAllowed() && !entity.isNoGravity() && this.noBlocksAround(entity); +@@ -434,7 +637,7 @@ @Override public void handleAcceptTeleportPacket(PacketPlayInTeleportAccept packetplayinteleportaccept) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinteleportaccept, this, this.player.getLevel()); @@ -303,7 +303,7 @@ this.player.absMoveTo(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); this.lastGoodX = this.awaitingPositionFromClient.x; this.lastGoodY = this.awaitingPositionFromClient.y; -@@ -437,6 +640,7 @@ +@@ -444,6 +647,7 @@ } this.awaitingPositionFromClient = null; @@ -311,7 +311,7 @@ } } -@@ -444,7 +648,7 @@ +@@ -451,7 +655,7 @@ @Override public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.getLevel()); @@ -320,7 +320,7 @@ RecipeBookServer recipebookserver = this.player.getRecipeBook(); Objects.requireNonNull(recipebookserver); -@@ -474,6 +678,12 @@ +@@ -481,6 +685,12 @@ @Override public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.getLevel()); @@ -333,7 +333,7 @@ StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand()); if (stringreader.canRead() && stringreader.peek() == '/') { -@@ -483,6 +693,7 @@ +@@ -490,6 +700,7 @@ ParseResults parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { @@ -341,7 +341,7 @@ this.connection.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions)); }); } -@@ -715,6 +926,13 @@ +@@ -722,6 +933,13 @@ if (container instanceof ContainerMerchant) { ContainerMerchant containermerchant = (ContainerMerchant) container; @@ -355,7 +355,7 @@ containermerchant.setSelectionHint(i); containermerchant.tryMoveItems(i); -@@ -724,6 +942,13 @@ +@@ -731,6 +949,13 @@ @Override public void handleEditBook(PacketPlayInBEdit packetplayinbedit) { @@ -369,7 +369,7 @@ int i = packetplayinbedit.getSlot(); if (PlayerInventory.isHotbarSlot(i) || i == 40) { -@@ -732,7 +957,7 @@ +@@ -739,7 +964,7 @@ Objects.requireNonNull(list); optional.ifPresent(list::add); @@ -378,7 +378,7 @@ Objects.requireNonNull(list); stream.forEach(list::add); -@@ -748,7 +973,7 @@ +@@ -755,7 +980,7 @@ ItemStack itemstack = this.player.getInventory().getItem(i); if (itemstack.is(Items.WRITABLE_BOOK)) { @@ -387,7 +387,7 @@ } } -@@ -773,16 +998,16 @@ +@@ -780,16 +1005,16 @@ this.updateBookPages(list, (s) -> { return IChatBaseComponent.ChatSerializer.toJson(new ChatComponentText(s)); @@ -408,7 +408,7 @@ return NBTTagString.valueOf((String) unaryoperator.apply(itextfilter_a.getFiltered())); }); -@@ -810,6 +1035,7 @@ +@@ -817,6 +1042,7 @@ } itemstack.addTagElement("pages", nbttaglist); @@ -416,7 +416,7 @@ } @Override -@@ -846,7 +1072,7 @@ +@@ -853,7 +1079,7 @@ } else { WorldServer worldserver = this.player.getLevel(); @@ -425,7 +425,7 @@ if (this.tickCount == 0) { this.resetPosition(); } -@@ -856,7 +1082,7 @@ +@@ -863,7 +1089,7 @@ this.awaitingTeleportTime = this.tickCount; this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); } @@ -434,7 +434,7 @@ } else { this.awaitingTeleportTime = this.tickCount; double d0 = clampHorizontal(packetplayinflying.getX(this.player.getX())); -@@ -868,7 +1094,15 @@ +@@ -875,7 +1101,15 @@ if (this.player.isPassenger()) { this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); this.player.getLevel().getChunkSource().move(this.player); @@ -450,7 +450,7 @@ double d3 = this.player.getX(); double d4 = this.player.getY(); double d5 = this.player.getZ(); -@@ -888,15 +1122,33 @@ +@@ -895,15 +1129,33 @@ ++this.receivedMovePacketCount; int i = this.receivedMovePacketCount - this.knownMovePacketCount; @@ -483,22 +483,21 @@ - if (d11 - d10 > (double) (f2 * (float) i) && !this.isSingleplayerOwner()) { + if (d11 - d10 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { + // CraftBukkit end - PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName().getString(), d7, d8, d9); + PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d7, d8, d9}); this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot()); return; -@@ -915,6 +1167,7 @@ - } +@@ -924,6 +1176,7 @@ + boolean flag1 = this.player.verticalCollisionBelow; this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9)); + this.player.onGround = packetplayinflying.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move double d12 = d8; d7 = d0 - this.player.getX(); -@@ -936,7 +1189,71 @@ - if (!this.player.noPhysics && !this.player.isSleeping() && (flag1 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb))) { +@@ -945,6 +1198,69 @@ + if (!this.player.noPhysics && !this.player.isSleeping() && (flag2 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb))) { this.teleport(d3, d4, d5, f, f1); } else { -- this.clientIsFloating = d12 >= -0.03125D && this.player.gameMode.getGameModeForPlayer() != EnumGamemode.SPECTATOR && !this.server.isFlightAllowed() && !this.player.getAbilities().mayfly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isFallFlying() && this.noBlocksAround(this.player); + // CraftBukkit start - fire PlayerMoveEvent + // Rest to old location first + this.player.absMoveTo(prevX, prevY, prevZ, prevYaw, prevPitch); @@ -560,14 +559,12 @@ + } + } + this.player.absMoveTo(d0, d1, d2, f, f1); // Copied from above -+ -+ // MC-135989, SPIGOT-5564: isRiptiding -+ this.clientIsFloating = d12 >= -0.03125D && this.player.gameMode.getGameModeForPlayer() != EnumGamemode.SPECTATOR && !this.server.isFlightAllowed() && !this.player.getAbilities().mayfly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isFallFlying() && this.noBlocksAround(this.player) && !this.player.isAutoSpinAttack(); + // CraftBukkit end ++ + this.clientIsFloating = d12 >= -0.03125D && !flag1 && this.player.gameMode.getGameModeForPlayer() != EnumGamemode.SPECTATOR && !this.server.isFlightAllowed() && !this.player.getAbilities().mayfly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isFallFlying() && !this.player.isAutoSpinAttack() && this.noBlocksAround(this.player); this.player.getLevel().getChunkSource().move(this.player); this.player.doCheckFallDamage(this.player.getY() - d6, packetplayinflying.isOnGround()); - this.player.setOnGround(packetplayinflying.isOnGround()); -@@ -974,19 +1291,80 @@ +@@ -983,19 +1299,80 @@ return true; } @@ -631,13 +628,13 @@ + + this.internalTeleport(d0, d1, d2, f, f1, set, flag); + return event.isCancelled(); // CraftBukkit - Return event status ++ } ++ ++ public void teleport(Location dest) { ++ internalTeleport(dest.getX(), dest.getY(), dest.getZ(), dest.getYaw(), dest.getPitch(), Collections.emptySet(), true); } - public void teleport(double d0, double d1, double d2, float f, float f1, Set set, boolean flag) { -+ public void teleport(Location dest) { -+ internalTeleport(dest.getX(), dest.getY(), dest.getZ(), dest.getYaw(), dest.getPitch(), Collections.emptySet(), true); -+ } -+ + private void internalTeleport(double d0, double d1, double d2, float f, float f1, Set set, boolean flag) { + // CraftBukkit start + if (Float.isNaN(f)) { @@ -652,7 +649,7 @@ double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.getX() : 0.0D; double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.getY() : 0.0D; double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.getZ() : 0.0D; -@@ -998,6 +1376,14 @@ +@@ -1007,6 +1384,14 @@ this.awaitingTeleport = 0; } @@ -667,7 +664,7 @@ this.awaitingTeleportTime = this.tickCount; this.player.absMoveTo(d0, d1, d2, f, f1); this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag)); -@@ -1006,6 +1392,7 @@ +@@ -1015,6 +1400,7 @@ @Override public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.getLevel()); @@ -675,7 +672,7 @@ BlockPosition blockposition = packetplayinblockdig.getPos(); this.player.resetLastActionTime(); -@@ -1016,14 +1403,46 @@ +@@ -1025,14 +1411,46 @@ if (!this.player.isSpectator()) { ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND); @@ -724,7 +721,7 @@ this.player.drop(false); } -@@ -1060,6 +1479,7 @@ +@@ -1069,6 +1487,7 @@ @Override public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.getLevel()); @@ -732,25 +729,15 @@ WorldServer worldserver = this.player.getLevel(); EnumHand enumhand = packetplayinuseitem.getHand(); ItemStack itemstack = this.player.getItemInHand(enumhand); -@@ -1069,9 +1489,16 @@ +@@ -1088,6 +1507,7 @@ - this.player.resetLastActionTime(); - int i = this.player.level.getMaxBuildHeight(); -+ // CraftBukkit start -+ double distanceSqr = this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D); -+ if (distanceSqr > 100.0D) { -+ return; -+ } -+ // CraftBukkit end + if (blockposition.getY() < i) { + if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) { ++ 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 && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) { -+ if (this.awaitingPositionFromClient == null && distanceSqr < 64.0D && worldserver.mayInteract(this.player, blockposition)) { // CraftBukkit - reuse value -+ this.player.stopUsingItem(); // CraftBukkit - SPIGOT-4706 - EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); - - if (enumdirection == EnumDirection.UP && !enuminteractionresult.consumesAction() && blockposition.getY() >= i - 1 && wasBlockPlacementAttempt(this.player, itemstack)) { -@@ -1095,12 +1522,51 @@ + if (enumdirection == EnumDirection.UP && !enuminteractionresult.consumesAction() && blockposition.getY() >= i - 1 && wasBlockPlacementAttempt(this.player, itemstack)) { +@@ -1117,12 +1537,51 @@ @Override public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.getLevel()); @@ -802,7 +789,7 @@ EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand); if (enuminteractionresult.shouldSwing()) { -@@ -1121,7 +1587,7 @@ +@@ -1143,7 +1602,7 @@ Entity entity = packetplayinspectate.getEntity(worldserver); if (entity != null) { @@ -811,7 +798,7 @@ return; } } -@@ -1136,6 +1602,7 @@ +@@ -1158,6 +1617,7 @@ PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName()); this.disconnect(new ChatMessage("multiplayer.requiredTexturePrompt.disconnect")); } @@ -819,7 +806,7 @@ } -@@ -1155,11 +1622,26 @@ +@@ -1177,11 +1637,26 @@ @Override public void onDisconnect(IChatBaseComponent ichatbasecomponent) { @@ -847,7 +834,7 @@ this.player.getTextFilter().leave(); if (this.isSingleplayerOwner()) { PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out"); -@@ -1174,6 +1656,15 @@ +@@ -1196,6 +1671,15 @@ } public void send(Packet packet, @Nullable GenericFutureListener> genericfuturelistener) { @@ -863,7 +850,7 @@ try { this.connection.send(packet, genericfuturelistener); } catch (Throwable throwable) { -@@ -1190,7 +1681,16 @@ +@@ -1212,7 +1696,16 @@ @Override public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.getLevel()); @@ -880,7 +867,7 @@ if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) { this.player.stopUsingItem(); } -@@ -1199,11 +1699,18 @@ +@@ -1221,11 +1714,18 @@ this.player.resetLastActionTime(); } else { PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString()); @@ -899,7 +886,7 @@ String s = StringUtils.normalizeSpace(packetplayinchat.getMessage()); for (int i = 0; i < s.length(); ++i) { -@@ -1217,20 +1724,42 @@ +@@ -1239,20 +1739,42 @@ PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinchat, this, this.player.getLevel()); this.handleChat(ITextFilter.a.passThrough(s)); } else { @@ -946,7 +933,7 @@ } else { String s1 = itextfilter_a.getFiltered(); ChatMessage chatmessage = s1.isEmpty() ? null : new ChatMessage("chat.type.text", new Object[]{this.player.getDisplayName(), s1}); -@@ -1241,28 +1770,198 @@ +@@ -1263,28 +1785,198 @@ }, ChatMessageType.CHAT, this.player.getUUID()); } @@ -1149,7 +1136,7 @@ this.player.resetLastActionTime(); IJumpable ijumpable; -@@ -1320,6 +2019,7 @@ +@@ -1342,6 +2034,7 @@ @Override public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.getLevel()); @@ -1157,7 +1144,7 @@ WorldServer worldserver = this.player.getLevel(); final Entity entity = packetplayinuseentity.getTarget(worldserver); -@@ -1334,10 +2034,44 @@ +@@ -1356,10 +2049,44 @@ if (this.player.distanceToSqr(entity) < 36.0D) { packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() { @@ -1203,7 +1190,7 @@ if (enuminteractionresult.consumesAction()) { CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack, entity); if (enuminteractionresult.shouldSwing()) { -@@ -1349,20 +2083,27 @@ +@@ -1371,20 +2098,27 @@ @Override public void onInteraction(EnumHand enumhand) { @@ -1234,7 +1221,7 @@ } else { PlayerConnection.this.disconnect(new ChatMessage("multiplayer.disconnect.invalid_entity_attacked")); PlayerConnection.LOGGER.warn("Player {} tried to attack an invalid entity", PlayerConnection.this.player.getName().getString()); -@@ -1407,21 +2148,304 @@ +@@ -1429,15 +2163,21 @@ @Override public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.getLevel()); @@ -1257,300 +1244,302 @@ + if (false/*this.player.isSpectator()*/) { // CraftBukkit this.player.containerMenu.sendAllDataToRemote(); } else { - boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId(); + int i = packetplayinwindowclick.getSlotNum(); +@@ -1448,7 +2188,284 @@ + boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId(); - this.player.containerMenu.suppressRemoteUpdates(); -- this.player.containerMenu.clicked(packetplayinwindowclick.getSlotNum(), packetplayinwindowclick.getButtonNum(), packetplayinwindowclick.getClickType(), this.player); -+ // CraftBukkit start - Call InventoryClickEvent -+ if (packetplayinwindowclick.getSlotNum() < -1 && packetplayinwindowclick.getSlotNum() != -999) { -+ return; -+ } -+ -+ InventoryView inventory = this.player.containerMenu.getBukkitView(); -+ SlotType type = inventory.getSlotType(packetplayinwindowclick.getSlotNum()); -+ -+ InventoryClickEvent event; -+ ClickType click = ClickType.UNKNOWN; -+ InventoryAction action = InventoryAction.UNKNOWN; -+ -+ ItemStack itemstack = ItemStack.EMPTY; -+ -+ switch (packetplayinwindowclick.getClickType()) { -+ case PICKUP: -+ if (packetplayinwindowclick.getButtonNum() == 0) { -+ click = ClickType.LEFT; -+ } else if (packetplayinwindowclick.getButtonNum() == 1) { -+ click = ClickType.RIGHT; -+ } -+ if (packetplayinwindowclick.getButtonNum() == 0 || packetplayinwindowclick.getButtonNum() == 1) { -+ action = InventoryAction.NOTHING; // Don't want to repeat ourselves -+ if (packetplayinwindowclick.getSlotNum() == -999) { -+ if (!player.containerMenu.getCarried().isEmpty()) { -+ action = packetplayinwindowclick.getButtonNum() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR; -+ } -+ } else if (packetplayinwindowclick.getSlotNum() < 0) { -+ action = InventoryAction.NOTHING; -+ } else { -+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); -+ if (slot != null) { -+ ItemStack clickedItem = slot.getItem(); -+ ItemStack cursor = player.containerMenu.getCarried(); -+ if (clickedItem.isEmpty()) { -+ if (!cursor.isEmpty()) { -+ action = packetplayinwindowclick.getButtonNum() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE; -+ } -+ } else if (slot.mayPickup(player)) { -+ if (cursor.isEmpty()) { -+ action = packetplayinwindowclick.getButtonNum() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF; -+ } else if (slot.mayPlace(cursor)) { -+ if (clickedItem.sameItem(cursor) && ItemStack.tagMatches(clickedItem, cursor)) { -+ int toPlace = packetplayinwindowclick.getButtonNum() == 0 ? cursor.getCount() : 1; -+ toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.getCount()); -+ toPlace = Math.min(toPlace, slot.container.getMaxStackSize() - clickedItem.getCount()); -+ if (toPlace == 1) { -+ action = InventoryAction.PLACE_ONE; -+ } else if (toPlace == cursor.getCount()) { -+ action = InventoryAction.PLACE_ALL; -+ } else if (toPlace < 0) { -+ action = toPlace != -1 ? InventoryAction.PICKUP_SOME : InventoryAction.PICKUP_ONE; // this happens with oversized stacks -+ } else if (toPlace != 0) { -+ action = InventoryAction.PLACE_SOME; -+ } -+ } else if (cursor.getCount() <= slot.getMaxStackSize()) { -+ action = InventoryAction.SWAP_WITH_CURSOR; -+ } -+ } else if (cursor.getItem() == clickedItem.getItem() && ItemStack.tagMatches(cursor, clickedItem)) { -+ if (clickedItem.getCount() >= 0) { -+ if (clickedItem.getCount() + cursor.getCount() <= cursor.getMaxStackSize()) { -+ // As of 1.5, this is result slots only -+ action = InventoryAction.PICKUP_ALL; -+ } -+ } -+ } -+ } -+ } -+ } -+ } -+ break; -+ // TODO check on updates -+ case QUICK_MOVE: -+ if (packetplayinwindowclick.getButtonNum() == 0) { -+ click = ClickType.SHIFT_LEFT; -+ } else if (packetplayinwindowclick.getButtonNum() == 1) { -+ click = ClickType.SHIFT_RIGHT; -+ } -+ if (packetplayinwindowclick.getButtonNum() == 0 || packetplayinwindowclick.getButtonNum() == 1) { -+ if (packetplayinwindowclick.getSlotNum() < 0) { -+ action = InventoryAction.NOTHING; -+ } else { -+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); -+ if (slot != null && slot.mayPickup(this.player) && slot.hasItem()) { -+ action = InventoryAction.MOVE_TO_OTHER_INVENTORY; -+ } else { -+ action = InventoryAction.NOTHING; -+ } -+ } -+ } -+ break; -+ case SWAP: -+ if ((packetplayinwindowclick.getButtonNum() >= 0 && packetplayinwindowclick.getButtonNum() < 9) || packetplayinwindowclick.getButtonNum() == 40) { -+ click = (packetplayinwindowclick.getButtonNum() == 40) ? ClickType.SWAP_OFFHAND : ClickType.NUMBER_KEY; -+ Slot clickedSlot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); -+ if (clickedSlot.mayPickup(player)) { -+ ItemStack hotbar = this.player.getInventory().getItem(packetplayinwindowclick.getButtonNum()); -+ boolean canCleanSwap = hotbar.isEmpty() || (clickedSlot.container == player.getInventory() && clickedSlot.mayPlace(hotbar)); // the slot will accept the hotbar item -+ if (clickedSlot.hasItem()) { -+ if (canCleanSwap) { -+ action = InventoryAction.HOTBAR_SWAP; -+ } else { -+ action = InventoryAction.HOTBAR_MOVE_AND_READD; -+ } -+ } else if (!clickedSlot.hasItem() && !hotbar.isEmpty() && clickedSlot.mayPlace(hotbar)) { -+ action = InventoryAction.HOTBAR_SWAP; -+ } else { -+ action = InventoryAction.NOTHING; -+ } -+ } else { -+ action = InventoryAction.NOTHING; -+ } -+ } -+ break; -+ case CLONE: -+ if (packetplayinwindowclick.getButtonNum() == 2) { -+ click = ClickType.MIDDLE; -+ if (packetplayinwindowclick.getSlotNum() < 0) { -+ action = InventoryAction.NOTHING; -+ } else { -+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); -+ if (slot != null && slot.hasItem() && player.getAbilities().instabuild && player.containerMenu.getCarried().isEmpty()) { -+ action = InventoryAction.CLONE_STACK; -+ } else { -+ action = InventoryAction.NOTHING; -+ } -+ } -+ } else { -+ click = ClickType.UNKNOWN; -+ action = InventoryAction.UNKNOWN; -+ } -+ break; -+ case THROW: -+ if (packetplayinwindowclick.getSlotNum() >= 0) { -+ if (packetplayinwindowclick.getButtonNum() == 0) { -+ click = ClickType.DROP; -+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); -+ if (slot != null && slot.hasItem() && slot.mayPickup(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.byBlock(Blocks.AIR)) { -+ action = InventoryAction.DROP_ONE_SLOT; -+ } else { -+ action = InventoryAction.NOTHING; -+ } -+ } else if (packetplayinwindowclick.getButtonNum() == 1) { -+ click = ClickType.CONTROL_DROP; -+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); -+ if (slot != null && slot.hasItem() && slot.mayPickup(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.byBlock(Blocks.AIR)) { -+ action = InventoryAction.DROP_ALL_SLOT; -+ } else { -+ action = InventoryAction.NOTHING; -+ } -+ } -+ } else { -+ // Sane default (because this happens when they are holding nothing. Don't ask why.) -+ click = ClickType.LEFT; -+ if (packetplayinwindowclick.getButtonNum() == 1) { -+ click = ClickType.RIGHT; -+ } -+ action = InventoryAction.NOTHING; -+ } -+ break; -+ case QUICK_CRAFT: -+ this.player.containerMenu.clicked(packetplayinwindowclick.getSlotNum(), packetplayinwindowclick.getButtonNum(), packetplayinwindowclick.getClickType(), this.player); -+ break; -+ case PICKUP_ALL: -+ click = ClickType.DOUBLE_CLICK; -+ action = InventoryAction.NOTHING; -+ if (packetplayinwindowclick.getSlotNum() >= 0 && !this.player.containerMenu.getCarried().isEmpty()) { -+ ItemStack cursor = this.player.containerMenu.getCarried(); -+ action = InventoryAction.NOTHING; -+ // Quick check for if we have any of the item -+ if (inventory.getTopInventory().contains(CraftMagicNumbers.getMaterial(cursor.getItem())) || inventory.getBottomInventory().contains(CraftMagicNumbers.getMaterial(cursor.getItem()))) { -+ action = InventoryAction.COLLECT_TO_CURSOR; -+ } -+ } -+ break; -+ default: -+ break; -+ } -+ -+ if (packetplayinwindowclick.getClickType() != InventoryClickType.QUICK_CRAFT) { -+ if (click == ClickType.NUMBER_KEY) { -+ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action, packetplayinwindowclick.getButtonNum()); -+ } else { -+ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action); -+ } -+ -+ org.bukkit.inventory.Inventory top = inventory.getTopInventory(); -+ if (packetplayinwindowclick.getSlotNum() == 0 && top instanceof CraftingInventory) { -+ org.bukkit.inventory.Recipe recipe = ((CraftingInventory) top).getRecipe(); -+ if (recipe != null) { -+ if (click == ClickType.NUMBER_KEY) { -+ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.getSlotNum(), click, action, packetplayinwindowclick.getButtonNum()); -+ } else { -+ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.getSlotNum(), click, action); -+ } -+ } -+ } -+ -+ if (packetplayinwindowclick.getSlotNum() == 2 && top instanceof SmithingInventory) { -+ org.bukkit.inventory.ItemStack result = ((SmithingInventory) top).getResult(); -+ if (result != null) { -+ if (click == ClickType.NUMBER_KEY) { -+ event = new SmithItemEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action, packetplayinwindowclick.getButtonNum()); -+ } else { -+ event = new SmithItemEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action); -+ } -+ } -+ } -+ -+ event.setCancelled(cancelled); -+ Container oldContainer = this.player.containerMenu; // SPIGOT-1224 -+ cserver.getPluginManager().callEvent(event); -+ if (this.player.containerMenu != oldContainer) { + this.player.containerMenu.suppressRemoteUpdates(); +- this.player.containerMenu.clicked(i, packetplayinwindowclick.getButtonNum(), packetplayinwindowclick.getClickType(), this.player); ++ // CraftBukkit start - Call InventoryClickEvent ++ if (packetplayinwindowclick.getSlotNum() < -1 && packetplayinwindowclick.getSlotNum() != -999) { + return; + } + -+ switch (event.getResult()) { -+ case ALLOW: -+ case DEFAULT: ++ InventoryView inventory = this.player.containerMenu.getBukkitView(); ++ SlotType type = inventory.getSlotType(packetplayinwindowclick.getSlotNum()); ++ ++ InventoryClickEvent event; ++ ClickType click = ClickType.UNKNOWN; ++ InventoryAction action = InventoryAction.UNKNOWN; ++ ++ ItemStack itemstack = ItemStack.EMPTY; ++ ++ switch (packetplayinwindowclick.getClickType()) { ++ case PICKUP: ++ if (packetplayinwindowclick.getButtonNum() == 0) { ++ click = ClickType.LEFT; ++ } else if (packetplayinwindowclick.getButtonNum() == 1) { ++ click = ClickType.RIGHT; ++ } ++ if (packetplayinwindowclick.getButtonNum() == 0 || packetplayinwindowclick.getButtonNum() == 1) { ++ action = InventoryAction.NOTHING; // Don't want to repeat ourselves ++ if (packetplayinwindowclick.getSlotNum() == -999) { ++ if (!player.containerMenu.getCarried().isEmpty()) { ++ action = packetplayinwindowclick.getButtonNum() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR; ++ } ++ } else if (packetplayinwindowclick.getSlotNum() < 0) { ++ action = InventoryAction.NOTHING; ++ } else { ++ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); ++ if (slot != null) { ++ ItemStack clickedItem = slot.getItem(); ++ ItemStack cursor = player.containerMenu.getCarried(); ++ if (clickedItem.isEmpty()) { ++ if (!cursor.isEmpty()) { ++ action = packetplayinwindowclick.getButtonNum() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE; ++ } ++ } else if (slot.mayPickup(player)) { ++ if (cursor.isEmpty()) { ++ action = packetplayinwindowclick.getButtonNum() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF; ++ } else if (slot.mayPlace(cursor)) { ++ if (clickedItem.sameItem(cursor) && ItemStack.tagMatches(clickedItem, cursor)) { ++ int toPlace = packetplayinwindowclick.getButtonNum() == 0 ? cursor.getCount() : 1; ++ toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.getCount()); ++ toPlace = Math.min(toPlace, slot.container.getMaxStackSize() - clickedItem.getCount()); ++ if (toPlace == 1) { ++ action = InventoryAction.PLACE_ONE; ++ } else if (toPlace == cursor.getCount()) { ++ action = InventoryAction.PLACE_ALL; ++ } else if (toPlace < 0) { ++ action = toPlace != -1 ? InventoryAction.PICKUP_SOME : InventoryAction.PICKUP_ONE; // this happens with oversized stacks ++ } else if (toPlace != 0) { ++ action = InventoryAction.PLACE_SOME; ++ } ++ } else if (cursor.getCount() <= slot.getMaxStackSize()) { ++ action = InventoryAction.SWAP_WITH_CURSOR; ++ } ++ } else if (cursor.getItem() == clickedItem.getItem() && ItemStack.tagMatches(cursor, clickedItem)) { ++ if (clickedItem.getCount() >= 0) { ++ if (clickedItem.getCount() + cursor.getCount() <= cursor.getMaxStackSize()) { ++ // As of 1.5, this is result slots only ++ action = InventoryAction.PICKUP_ALL; ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ break; ++ // TODO check on updates ++ case QUICK_MOVE: ++ if (packetplayinwindowclick.getButtonNum() == 0) { ++ click = ClickType.SHIFT_LEFT; ++ } else if (packetplayinwindowclick.getButtonNum() == 1) { ++ click = ClickType.SHIFT_RIGHT; ++ } ++ if (packetplayinwindowclick.getButtonNum() == 0 || packetplayinwindowclick.getButtonNum() == 1) { ++ if (packetplayinwindowclick.getSlotNum() < 0) { ++ action = InventoryAction.NOTHING; ++ } else { ++ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); ++ if (slot != null && slot.mayPickup(this.player) && slot.hasItem()) { ++ action = InventoryAction.MOVE_TO_OTHER_INVENTORY; ++ } else { ++ action = InventoryAction.NOTHING; ++ } ++ } ++ } ++ break; ++ case SWAP: ++ if ((packetplayinwindowclick.getButtonNum() >= 0 && packetplayinwindowclick.getButtonNum() < 9) || packetplayinwindowclick.getButtonNum() == 40) { ++ click = (packetplayinwindowclick.getButtonNum() == 40) ? ClickType.SWAP_OFFHAND : ClickType.NUMBER_KEY; ++ Slot clickedSlot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); ++ if (clickedSlot.mayPickup(player)) { ++ ItemStack hotbar = this.player.getInventory().getItem(packetplayinwindowclick.getButtonNum()); ++ boolean canCleanSwap = hotbar.isEmpty() || (clickedSlot.container == player.getInventory() && clickedSlot.mayPlace(hotbar)); // the slot will accept the hotbar item ++ if (clickedSlot.hasItem()) { ++ if (canCleanSwap) { ++ action = InventoryAction.HOTBAR_SWAP; ++ } else { ++ action = InventoryAction.HOTBAR_MOVE_AND_READD; ++ } ++ } else if (!clickedSlot.hasItem() && !hotbar.isEmpty() && clickedSlot.mayPlace(hotbar)) { ++ action = InventoryAction.HOTBAR_SWAP; ++ } else { ++ action = InventoryAction.NOTHING; ++ } ++ } else { ++ action = InventoryAction.NOTHING; ++ } ++ } ++ break; ++ case CLONE: ++ if (packetplayinwindowclick.getButtonNum() == 2) { ++ click = ClickType.MIDDLE; ++ if (packetplayinwindowclick.getSlotNum() < 0) { ++ action = InventoryAction.NOTHING; ++ } else { ++ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); ++ if (slot != null && slot.hasItem() && player.getAbilities().instabuild && player.containerMenu.getCarried().isEmpty()) { ++ action = InventoryAction.CLONE_STACK; ++ } else { ++ action = InventoryAction.NOTHING; ++ } ++ } ++ } else { ++ click = ClickType.UNKNOWN; ++ action = InventoryAction.UNKNOWN; ++ } ++ break; ++ case THROW: ++ if (packetplayinwindowclick.getSlotNum() >= 0) { ++ if (packetplayinwindowclick.getButtonNum() == 0) { ++ click = ClickType.DROP; ++ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); ++ if (slot != null && slot.hasItem() && slot.mayPickup(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.byBlock(Blocks.AIR)) { ++ action = InventoryAction.DROP_ONE_SLOT; ++ } else { ++ action = InventoryAction.NOTHING; ++ } ++ } else if (packetplayinwindowclick.getButtonNum() == 1) { ++ click = ClickType.CONTROL_DROP; ++ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); ++ if (slot != null && slot.hasItem() && slot.mayPickup(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.byBlock(Blocks.AIR)) { ++ action = InventoryAction.DROP_ALL_SLOT; ++ } else { ++ action = InventoryAction.NOTHING; ++ } ++ } ++ } else { ++ // Sane default (because this happens when they are holding nothing. Don't ask why.) ++ click = ClickType.LEFT; ++ if (packetplayinwindowclick.getButtonNum() == 1) { ++ click = ClickType.RIGHT; ++ } ++ action = InventoryAction.NOTHING; ++ } ++ break; ++ case QUICK_CRAFT: + this.player.containerMenu.clicked(packetplayinwindowclick.getSlotNum(), packetplayinwindowclick.getButtonNum(), packetplayinwindowclick.getClickType(), this.player); + break; -+ case DENY: -+ /* Needs enum constructor in InventoryAction -+ if (action.modifiesOtherSlots()) { -+ -+ } else { -+ if (action.modifiesCursor()) { -+ this.player.playerConnection.sendPacket(new Packet103SetSlot(-1, -1, this.player.inventory.getCarried())); ++ case PICKUP_ALL: ++ click = ClickType.DOUBLE_CLICK; ++ action = InventoryAction.NOTHING; ++ if (packetplayinwindowclick.getSlotNum() >= 0 && !this.player.containerMenu.getCarried().isEmpty()) { ++ ItemStack cursor = this.player.containerMenu.getCarried(); ++ action = InventoryAction.NOTHING; ++ // Quick check for if we have any of the item ++ if (inventory.getTopInventory().contains(CraftMagicNumbers.getMaterial(cursor.getItem())) || inventory.getBottomInventory().contains(CraftMagicNumbers.getMaterial(cursor.getItem()))) { ++ action = InventoryAction.COLLECT_TO_CURSOR; + } -+ if (action.modifiesClicked()) { -+ this.player.playerConnection.sendPacket(new Packet103SetSlot(this.player.activeContainer.windowId, packet102windowclick.slot, this.player.activeContainer.getSlot(packet102windowclick.slot).getItem())); -+ } -+ }*/ -+ switch (action) { -+ // Modified other slots -+ case PICKUP_ALL: -+ case MOVE_TO_OTHER_INVENTORY: -+ case HOTBAR_MOVE_AND_READD: -+ case HOTBAR_SWAP: -+ case COLLECT_TO_CURSOR: -+ case UNKNOWN: -+ this.player.containerMenu.sendAllDataToRemote(); -+ break; -+ // Modified cursor and clicked -+ case PICKUP_SOME: -+ case PICKUP_HALF: -+ case PICKUP_ONE: -+ case PLACE_ALL: -+ case PLACE_SOME: -+ case PLACE_ONE: -+ case SWAP_WITH_CURSOR: -+ this.player.connection.send(new PacketPlayOutSetSlot(-1, -1, this.player.inventoryMenu.incrementStateId(), this.player.containerMenu.getCarried())); -+ this.player.connection.send(new PacketPlayOutSetSlot(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), packetplayinwindowclick.getSlotNum(), this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()).getItem())); -+ break; -+ // Modified clicked only -+ case DROP_ALL_SLOT: -+ case DROP_ONE_SLOT: -+ this.player.connection.send(new PacketPlayOutSetSlot(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), packetplayinwindowclick.getSlotNum(), this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()).getItem())); -+ break; -+ // Modified cursor only -+ case DROP_ALL_CURSOR: -+ case DROP_ONE_CURSOR: -+ case CLONE_STACK: -+ this.player.connection.send(new PacketPlayOutSetSlot(-1, -1, this.player.inventoryMenu.incrementStateId(), this.player.containerMenu.getCarried())); -+ break; -+ // Nothing -+ case NOTHING: -+ break; + } ++ break; ++ default: ++ break; + } + -+ if (event instanceof CraftItemEvent || event instanceof SmithItemEvent) { -+ // Need to update the inventory on crafting to -+ // correctly support custom recipes -+ player.containerMenu.sendAllDataToRemote(); ++ if (packetplayinwindowclick.getClickType() != InventoryClickType.QUICK_CRAFT) { ++ if (click == ClickType.NUMBER_KEY) { ++ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action, packetplayinwindowclick.getButtonNum()); ++ } else { ++ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action); ++ } ++ ++ org.bukkit.inventory.Inventory top = inventory.getTopInventory(); ++ if (packetplayinwindowclick.getSlotNum() == 0 && top instanceof CraftingInventory) { ++ org.bukkit.inventory.Recipe recipe = ((CraftingInventory) top).getRecipe(); ++ if (recipe != null) { ++ if (click == ClickType.NUMBER_KEY) { ++ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.getSlotNum(), click, action, packetplayinwindowclick.getButtonNum()); ++ } else { ++ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.getSlotNum(), click, action); ++ } ++ } ++ } ++ ++ if (packetplayinwindowclick.getSlotNum() == 2 && top instanceof SmithingInventory) { ++ org.bukkit.inventory.ItemStack result = ((SmithingInventory) top).getResult(); ++ if (result != null) { ++ if (click == ClickType.NUMBER_KEY) { ++ event = new SmithItemEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action, packetplayinwindowclick.getButtonNum()); ++ } else { ++ event = new SmithItemEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action); ++ } ++ } ++ } ++ ++ event.setCancelled(cancelled); ++ Container oldContainer = this.player.containerMenu; // SPIGOT-1224 ++ cserver.getPluginManager().callEvent(event); ++ if (this.player.containerMenu != oldContainer) { ++ return; ++ } ++ ++ switch (event.getResult()) { ++ case ALLOW: ++ case DEFAULT: ++ this.player.containerMenu.clicked(i, packetplayinwindowclick.getButtonNum(), packetplayinwindowclick.getClickType(), this.player); ++ break; ++ case DENY: ++ /* Needs enum constructor in InventoryAction ++ if (action.modifiesOtherSlots()) { ++ ++ } else { ++ if (action.modifiesCursor()) { ++ this.player.playerConnection.sendPacket(new Packet103SetSlot(-1, -1, this.player.inventory.getCarried())); ++ } ++ if (action.modifiesClicked()) { ++ this.player.playerConnection.sendPacket(new Packet103SetSlot(this.player.activeContainer.windowId, packet102windowclick.slot, this.player.activeContainer.getSlot(packet102windowclick.slot).getItem())); ++ } ++ }*/ ++ switch (action) { ++ // Modified other slots ++ case PICKUP_ALL: ++ case MOVE_TO_OTHER_INVENTORY: ++ case HOTBAR_MOVE_AND_READD: ++ case HOTBAR_SWAP: ++ case COLLECT_TO_CURSOR: ++ case UNKNOWN: ++ this.player.containerMenu.sendAllDataToRemote(); ++ break; ++ // Modified cursor and clicked ++ case PICKUP_SOME: ++ case PICKUP_HALF: ++ case PICKUP_ONE: ++ case PLACE_ALL: ++ case PLACE_SOME: ++ case PLACE_ONE: ++ case SWAP_WITH_CURSOR: ++ this.player.connection.send(new PacketPlayOutSetSlot(-1, -1, this.player.inventoryMenu.incrementStateId(), this.player.containerMenu.getCarried())); ++ this.player.connection.send(new PacketPlayOutSetSlot(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), packetplayinwindowclick.getSlotNum(), this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()).getItem())); ++ break; ++ // Modified clicked only ++ case DROP_ALL_SLOT: ++ case DROP_ONE_SLOT: ++ this.player.connection.send(new PacketPlayOutSetSlot(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), packetplayinwindowclick.getSlotNum(), this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()).getItem())); ++ break; ++ // Modified cursor only ++ case DROP_ALL_CURSOR: ++ case DROP_ONE_CURSOR: ++ case CLONE_STACK: ++ this.player.connection.send(new PacketPlayOutSetSlot(-1, -1, this.player.inventoryMenu.incrementStateId(), this.player.containerMenu.getCarried())); ++ break; ++ // Nothing ++ case NOTHING: ++ break; ++ } ++ } ++ ++ if (event instanceof CraftItemEvent || event instanceof SmithItemEvent) { ++ // Need to update the inventory on crafting to ++ // correctly support custom recipes ++ player.containerMenu.sendAllDataToRemote(); ++ } + } -+ } -+ // CraftBukkit end - ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator(); ++ // CraftBukkit end + ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator(); - while (objectiterator.hasNext()) { -@@ -1456,6 +2480,7 @@ + while (objectiterator.hasNext()) { +@@ -1484,6 +2501,7 @@ @Override public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.getLevel()); + if (this.player.isImmobile()) return; // CraftBukkit this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) { - this.player.containerMenu.clickMenuButton(this.player, packetplayinenchantitem.getButtonId()); -@@ -1483,6 +2508,43 @@ + boolean flag = this.player.containerMenu.clickMenuButton(this.player, packetplayinenchantitem.getButtonId()); +@@ -1514,6 +2532,43 @@ boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45; boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); @@ -1594,7 +1583,7 @@ if (flag1 && flag2) { this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).set(itemstack); -@@ -1505,6 +2567,7 @@ +@@ -1536,6 +2591,7 @@ } private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List list) { @@ -1602,7 +1591,7 @@ this.player.resetLastActionTime(); WorldServer worldserver = this.player.getLevel(); BlockPosition blockposition = packetplayinupdatesign.getPos(); -@@ -1521,18 +2584,37 @@ +@@ -1552,18 +2608,37 @@ if (!tileentitysign.isEditable() || !this.player.getUUID().equals(tileentitysign.getPlayerWhoMayEdit())) { PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getName().getString()); @@ -1626,8 +1615,8 @@ } else { - tileentitysign.setMessage(i, new ChatComponentText(itextfilter_a.getRaw()), new ChatComponentText(itextfilter_a.getFiltered())); + lines[i] = EnumChatFormat.stripFormatting(new ChatComponentText(EnumChatFormat.stripFormatting(itextfilter_a.getRaw())).getString()); -+ } -+ } + } + } + SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.player.getBukkitEntity(), lines); + this.cserver.getPluginManager().callEvent(event); + @@ -1635,14 +1624,14 @@ + IChatBaseComponent[] components = org.bukkit.craftbukkit.block.CraftSign.sanitizeLines(event.getLines()); + for (int i = 0; i < components.length; i++) { + tileentitysign.setMessage(i, components[i]); - } ++ } + tileentitysign.isEditable = false; - } ++ } + // CraftBukkit end tileentitysign.setChanged(); worldserver.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3); -@@ -1542,6 +2624,7 @@ +@@ -1573,6 +2648,7 @@ @Override public void handleKeepAlive(PacketPlayInKeepAlive packetplayinkeepalive) { @@ -1650,7 +1639,7 @@ if (this.keepAlivePending && packetplayinkeepalive.getId() == this.keepAliveChallenge) { int i = (int) (SystemUtils.getMillis() - this.keepAliveTime); -@@ -1556,7 +2639,17 @@ +@@ -1587,7 +2663,17 @@ @Override public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.getLevel()); @@ -1669,7 +1658,7 @@ } @Override -@@ -1565,8 +2658,50 @@ +@@ -1596,8 +2682,50 @@ this.player.updateOptions(packetplayinsettings); } diff --git a/paper-server/nms-patches/net/minecraft/server/players/NameReferencingFileConverter.patch b/paper-server/nms-patches/net/minecraft/server/players/NameReferencingFileConverter.patch index 1aa20d26bb..4c1cfb9ae7 100644 --- a/paper-server/nms-patches/net/minecraft/server/players/NameReferencingFileConverter.patch +++ b/paper-server/nms-patches/net/minecraft/server/players/NameReferencingFileConverter.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/players/NameReferencingFileConverter.java +++ b/net/minecraft/server/players/NameReferencingFileConverter.java @@ -28,6 +28,11 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import net.minecraft.world.level.storage.SavedFile; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.nbt.NBTCompressedStreamTools; @@ -11,7 +11,7 @@ + public class NameReferencingFileConverter { - static final Logger LOGGER = LogManager.getLogger(); + static final Logger LOGGER = LogUtils.getLogger(); @@ -88,7 +93,7 @@ try { gameprofilebanlist.load(); diff --git a/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch b/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch index fd2565a25c..f8afbdfdaf 100644 --- a/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch +++ b/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -95,6 +95,26 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import net.minecraft.world.scores.ScoreboardTeamBase; + import org.slf4j.Logger; +// CraftBukkit start +import com.google.common.base.Predicate; @@ -73,7 +73,7 @@ this.server = minecraftserver; this.registryHolder = iregistrycustom_dimension; this.maxPlayers = i; -@@ -145,6 +177,12 @@ +@@ -145,9 +177,15 @@ usercache.add(gameprofile); NBTTagCompound nbttagcompound = this.load(entityplayer); ResourceKey resourcekey; @@ -85,21 +85,25 @@ + // CraftBukkit end if (nbttagcompound != null) { - DataResult dataresult = DimensionManager.parseLegacy(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("Dimension"))); +- DataResult dataresult = DimensionManager.parseLegacy(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("Dimension"))); ++ DataResult> dataresult = DimensionManager.parseLegacy(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("Dimension"))); // CraftBukkit - decompile error + Logger logger = PlayerList.LOGGER; + + Objects.requireNonNull(logger); @@ -174,7 +212,8 @@ s1 = networkmanager.getRemoteAddress().toString(); } -- PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getName().getString(), s1, entityplayer.getId(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ()); +- PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", new Object[]{entityplayer.getName().getString(), s1, entityplayer.getId(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ()}); + // CraftBukkit - Moved message to after join -+ // PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getName().getString(), s1, entityplayer.getId(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ()); ++ // PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", new Object[]{entityplayer.getName().getString(), s1, entityplayer.getId(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ()}); WorldData worlddata = worldserver1.getLevelData(); entityplayer.loadGameTypes(nbttagcompound); @@ -184,6 +223,7 @@ boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO); - playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), entityplayer.gameMode.getGameModeForPlayer(), entityplayer.gameMode.getPreviousGameModeForPlayer(), this.server.levelKeys(), this.registryHolder, worldserver1.dimensionType(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, worldserver1.isDebug(), worldserver1.isFlat())); + playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), entityplayer.gameMode.getGameModeForPlayer(), entityplayer.gameMode.getPreviousGameModeForPlayer(), this.server.levelKeys(), this.registryHolder, worldserver1.dimensionTypeRegistration(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, worldserver1.isDebug(), worldserver1.isFlat())); + entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit playerconnection.send(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.BRAND, (new PacketDataSerializer(Unpooled.buffer())).writeUtf(this.getServer().getServerModName()))); playerconnection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); @@ -451,7 +455,7 @@ + if (worldserver1 != null) { + Optional optional; -- if (!iblockdata.is((Tag) TagsBlock.BEDS) && !flag3) { +- if (!iblockdata.is(TagsBlock.BEDS) && !flag3) { - f1 = f; - } else { - Vec3D vec3d1 = Vec3D.atBottomCenterOf(blockposition).subtract(vec3d).normalize(); @@ -467,7 +471,7 @@ + Vec3D vec3d = (Vec3D) optional.get(); + float f1; + -+ if (!iblockdata.is((Tag) TagsBlock.BEDS) && !flag3) { ++ if (!iblockdata.is(TagsBlock.BEDS) && !flag3) { + f1 = f; + } else { + Vec3D vec3d1 = Vec3D.atBottomCenterOf(blockposition).subtract(vec3d).normalize(); @@ -511,12 +515,12 @@ + // CraftBukkit end - while (!worldserver1.noCollision((Entity) entityplayer1) && entityplayer1.getY() < (double) worldserver1.getMaxBuildHeight()) { -+ while (avoidSuffocation && !worldserver1.noCollision(entityplayer1) && entityplayer1.getY() < (double) worldserver1.getMaxBuildHeight()) { ++ while (avoidSuffocation && !worldserver1.noCollision((Entity) entityplayer1) && entityplayer1.getY() < (double) worldserver1.getMaxBuildHeight()) { entityplayer1.setPos(entityplayer1.getX(), entityplayer1.getY() + 1.0D, entityplayer1.getZ()); } + // CraftBukkit start + WorldData worlddata = worldserver1.getLevelData(); -+ entityplayer1.connection.send(new PacketPlayOutRespawn(worldserver1.dimensionType(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), worldserver1.isDebug(), worldserver1.isFlat(), flag)); ++ entityplayer1.connection.send(new PacketPlayOutRespawn(worldserver1.dimensionTypeRegistration(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), worldserver1.isDebug(), worldserver1.isFlat(), flag)); + entityplayer1.spawnIn(worldserver1); + entityplayer1.unsetRemoved(); + entityplayer1.connection.teleport(new Location(worldserver1.getWorld(), entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot())); @@ -524,7 +528,7 @@ - WorldData worlddata = entityplayer1.level.getLevelData(); - -- entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.level.dimensionType(), entityplayer1.level.dimension(), BiomeManager.obfuscateSeed(entityplayer1.getLevel().getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), entityplayer1.getLevel().isDebug(), entityplayer1.getLevel().isFlat(), flag)); +- entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.level.dimensionTypeRegistration(), entityplayer1.level.dimension(), BiomeManager.obfuscateSeed(entityplayer1.getLevel().getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), entityplayer1.getLevel().isDebug(), entityplayer1.getLevel().isFlat(), flag)); - entityplayer1.connection.teleport(entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot()); + // entityplayer1.connection.teleport(entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot()); entityplayer1.connection.send(new PacketPlayOutSpawnPosition(worldserver1.getSharedSpawnPos(), worldserver1.getSharedSpawnAngle())); @@ -785,5 +789,5 @@ } + // CraftBukkit end - this.broadcastAll(new PacketPlayOutTags(this.server.getTags().serializeToNetwork(this.registryHolder))); + this.broadcastAll(new PacketPlayOutTags(TagNetworkSerialization.serializeTagsToNetwork(this.registryHolder))); PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(this.server.getRecipeManager().getRecipes()); diff --git a/paper-server/nms-patches/net/minecraft/stats/RecipeBookServer.patch b/paper-server/nms-patches/net/minecraft/stats/RecipeBookServer.patch index 8c242568f2..756dc7fb8c 100644 --- a/paper-server/nms-patches/net/minecraft/stats/RecipeBookServer.patch +++ b/paper-server/nms-patches/net/minecraft/stats/RecipeBookServer.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/stats/RecipeBookServer.java +++ b/net/minecraft/stats/RecipeBookServer.java @@ -20,6 +20,8 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import net.minecraft.world.item.crafting.IRecipe; + import org.slf4j.Logger; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + 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 8889bbc25d..39c4555623 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 -@@ -391,6 +391,18 @@ +@@ -395,6 +395,18 @@ datafixerbuilder.addFixer(new DataConverterItemFrame(schema46, false)); Schema schema47 = datafixerbuilder.addSchema(1458, DataConverterRegistry.SAME_NAMESPACED); @@ -19,30 +19,30 @@ datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema47, false)); datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema47, false)); datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema47, false)); -@@ -704,12 +716,14 @@ - datafixerbuilder.addFixer(new DataConverterAddChoices(schema130, "Added Glow Squid", DataConverterTypes.ENTITY)); - datafixerbuilder.addFixer(new DataConverterAddChoices(schema130, "Added Glow Item Frame", DataConverterTypes.ENTITY)); - Schema schema131 = datafixerbuilder.addSchema(2690, DataConverterRegistry.SAME_NAMESPACED); +@@ -711,12 +723,14 @@ + datafixerbuilder.addFixer(new DataConverterAddChoices(schema131, "Added Glow Squid", DataConverterTypes.ENTITY)); + datafixerbuilder.addFixer(new DataConverterAddChoices(schema131, "Added Glow Item Frame", DataConverterTypes.ENTITY)); + Schema schema132 = datafixerbuilder.addSchema(2690, DataConverterRegistry.SAME_NAMESPACED); - ImmutableMap immutablemap = ImmutableMap.builder().put("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block").put("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block").put("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block").put("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper").put("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper").put("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper").put("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs").put("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs").put("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs").put("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab").put("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab").put("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab").put("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper").put("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper").put("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper").put("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper").put("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs").put("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs").put("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab").put("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab").build(); + // CraftBukkit - decompile error + ImmutableMap immutablemap = ImmutableMap.builder().put("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block").put("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block").put("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block").put("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper").put("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper").put("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper").put("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs").put("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs").put("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs").put("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab").put("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab").put("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab").put("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper").put("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper").put("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper").put("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper").put("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs").put("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs").put("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab").put("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab").build(); - datafixerbuilder.addFixer(DataConverterItemName.create(schema131, "Renamed copper block items to new oxidized terms", createRenamer(immutablemap))); - datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema131, "Renamed copper blocks to new oxidized terms", createRenamer(immutablemap))); - Schema schema132 = datafixerbuilder.addSchema(2691, DataConverterRegistry.SAME_NAMESPACED); + datafixerbuilder.addFixer(DataConverterItemName.create(schema132, "Renamed copper block items to new oxidized terms", createRenamer(immutablemap))); + datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema132, "Renamed copper blocks to new oxidized terms", createRenamer(immutablemap))); + Schema schema133 = datafixerbuilder.addSchema(2691, DataConverterRegistry.SAME_NAMESPACED); - ImmutableMap immutablemap1 = ImmutableMap.builder().put("minecraft:waxed_copper", "minecraft:waxed_copper_block").put("minecraft:oxidized_copper_block", "minecraft:oxidized_copper").put("minecraft:weathered_copper_block", "minecraft:weathered_copper").put("minecraft:exposed_copper_block", "minecraft:exposed_copper").build(); + // CraftBukkit - decompile error + ImmutableMap immutablemap1 = ImmutableMap.builder().put("minecraft:waxed_copper", "minecraft:waxed_copper_block").put("minecraft:oxidized_copper_block", "minecraft:oxidized_copper").put("minecraft:weathered_copper_block", "minecraft:weathered_copper").put("minecraft:exposed_copper_block", "minecraft:exposed_copper").build(); - datafixerbuilder.addFixer(DataConverterItemName.create(schema132, "Rename copper item suffixes", createRenamer(immutablemap1))); - datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema132, "Rename copper blocks suffixes", createRenamer(immutablemap1))); -@@ -717,7 +731,8 @@ + datafixerbuilder.addFixer(DataConverterItemName.create(schema133, "Rename copper item suffixes", createRenamer(immutablemap1))); + datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema133, "Rename copper blocks suffixes", createRenamer(immutablemap1))); +@@ -724,7 +738,8 @@ - datafixerbuilder.addFixer(new AddFlagIfNotPresentFix(schema133, DataConverterTypes.WORLD_GEN_SETTINGS, "has_increased_height_already", false)); - Schema schema134 = datafixerbuilder.addSchema(2696, DataConverterRegistry.SAME_NAMESPACED); + datafixerbuilder.addFixer(new AddFlagIfNotPresentFix(schema134, DataConverterTypes.WORLD_GEN_SETTINGS, "has_increased_height_already", false)); + Schema schema135 = datafixerbuilder.addSchema(2696, DataConverterRegistry.SAME_NAMESPACED); - ImmutableMap immutablemap2 = ImmutableMap.builder().put("minecraft:grimstone", "minecraft:deepslate").put("minecraft:grimstone_slab", "minecraft:cobbled_deepslate_slab").put("minecraft:grimstone_stairs", "minecraft:cobbled_deepslate_stairs").put("minecraft:grimstone_wall", "minecraft:cobbled_deepslate_wall").put("minecraft:polished_grimstone", "minecraft:polished_deepslate").put("minecraft:polished_grimstone_slab", "minecraft:polished_deepslate_slab").put("minecraft:polished_grimstone_stairs", "minecraft:polished_deepslate_stairs").put("minecraft:polished_grimstone_wall", "minecraft:polished_deepslate_wall").put("minecraft:grimstone_tiles", "minecraft:deepslate_tiles").put("minecraft:grimstone_tile_slab", "minecraft:deepslate_tile_slab").put("minecraft:grimstone_tile_stairs", "minecraft:deepslate_tile_stairs").put("minecraft:grimstone_tile_wall", "minecraft:deepslate_tile_wall").put("minecraft:grimstone_bricks", "minecraft:deepslate_bricks").put("minecraft:grimstone_brick_slab", "minecraft:deepslate_brick_slab").put("minecraft:grimstone_brick_stairs", "minecraft:deepslate_brick_stairs").put("minecraft:grimstone_brick_wall", "minecraft:deepslate_brick_wall").put("minecraft:chiseled_grimstone", "minecraft:chiseled_deepslate").build(); + // CraftBukkit - decompile error + ImmutableMap immutablemap2 = ImmutableMap.builder().put("minecraft:grimstone", "minecraft:deepslate").put("minecraft:grimstone_slab", "minecraft:cobbled_deepslate_slab").put("minecraft:grimstone_stairs", "minecraft:cobbled_deepslate_stairs").put("minecraft:grimstone_wall", "minecraft:cobbled_deepslate_wall").put("minecraft:polished_grimstone", "minecraft:polished_deepslate").put("minecraft:polished_grimstone_slab", "minecraft:polished_deepslate_slab").put("minecraft:polished_grimstone_stairs", "minecraft:polished_deepslate_stairs").put("minecraft:polished_grimstone_wall", "minecraft:polished_deepslate_wall").put("minecraft:grimstone_tiles", "minecraft:deepslate_tiles").put("minecraft:grimstone_tile_slab", "minecraft:deepslate_tile_slab").put("minecraft:grimstone_tile_stairs", "minecraft:deepslate_tile_stairs").put("minecraft:grimstone_tile_wall", "minecraft:deepslate_tile_wall").put("minecraft:grimstone_bricks", "minecraft:deepslate_bricks").put("minecraft:grimstone_brick_slab", "minecraft:deepslate_brick_slab").put("minecraft:grimstone_brick_stairs", "minecraft:deepslate_brick_stairs").put("minecraft:grimstone_brick_wall", "minecraft:deepslate_brick_wall").put("minecraft:chiseled_grimstone", "minecraft:chiseled_deepslate").build(); - datafixerbuilder.addFixer(DataConverterItemName.create(schema134, "Renamed grimstone block items to deepslate", createRenamer(immutablemap2))); - datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema134, "Renamed grimstone blocks to deepslate", createRenamer(immutablemap2))); + datafixerbuilder.addFixer(DataConverterItemName.create(schema135, "Renamed grimstone block items to deepslate", createRenamer(immutablemap2))); + datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema135, "Renamed grimstone blocks to deepslate", createRenamer(immutablemap2))); diff --git a/paper-server/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch b/paper-server/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch index c374c11ead..9dda5518b0 100644 --- a/paper-server/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch +++ b/paper-server/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/util/worldupdate/WorldUpgrader.java +++ b/net/minecraft/util/worldupdate/WorldUpgrader.java @@ -38,6 +38,10 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import net.minecraft.world.level.storage.WorldPersistentData; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.world.level.dimension.WorldDimension; @@ -10,7 +10,7 @@ + public class WorldUpgrader { - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); @@ -53,7 +57,7 @@ private volatile int totalChunks; private volatile int converted; 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 06615ca6c4..3e7b4f7471 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -116,8 +116,64 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -119,8 +119,64 @@ + import net.minecraft.world.scores.ScoreboardTeamBase; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.world.level.dimension.WorldDimension; @@ -62,10 +62,10 @@ + } + // CraftBukkit end + - protected static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); public static final String ID_TAG = "id"; public static final String PASSENGERS_TAG = "Passengers"; -@@ -228,6 +284,24 @@ +@@ -231,6 +287,24 @@ public boolean hasVisualFire; @Nullable private IBlockData feetBlockState; @@ -90,7 +90,7 @@ public Entity(EntityTypes entitytypes, World world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -365,6 +439,12 @@ +@@ -369,6 +443,12 @@ public void onClientRemoval() {} public void setPose(EntityPose entitypose) { @@ -103,7 +103,7 @@ this.entityData.set(Entity.DATA_POSE, entitypose); } -@@ -381,6 +461,33 @@ +@@ -385,6 +465,33 @@ } protected void setRot(float f, float f1) { @@ -137,7 +137,7 @@ this.setYRot(f % 360.0F); this.setXRot(f1 % 360.0F); } -@@ -422,6 +529,15 @@ +@@ -426,6 +533,15 @@ this.baseTick(); } @@ -153,7 +153,7 @@ public void baseTick() { this.level.getProfiler().push("entityBaseTick"); this.feetBlockState = null; -@@ -436,7 +552,7 @@ +@@ -440,7 +556,7 @@ this.walkDistO = this.walkDist; this.xRotO = this.getXRot(); this.yRotO = this.getYRot(); @@ -162,7 +162,7 @@ if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -471,6 +587,10 @@ +@@ -475,6 +591,10 @@ if (this.isInLava()) { this.lavaHurt(); this.fallDistance *= 0.5F; @@ -173,7 +173,7 @@ } this.checkOutOfWorld(); -@@ -514,15 +634,48 @@ +@@ -518,15 +638,48 @@ public void lavaHurt() { if (!this.fireImmune()) { @@ -223,7 +223,7 @@ int j = i * 20; if (this instanceof EntityLiving) { -@@ -627,6 +780,28 @@ +@@ -640,6 +793,28 @@ block.updateEntityAfterFallOn(this.level, this); } @@ -252,7 +252,7 @@ if (this.onGround && !this.isSteppingCarefully()) { block.stepOn(this.level, blockposition, iblockdata, this); } -@@ -1260,6 +1435,7 @@ +@@ -1265,6 +1440,7 @@ this.yo = d1; this.zo = d4; this.setPos(d3, d1, d4); @@ -260,7 +260,7 @@ } public void moveTo(Vec3D vec3d) { -@@ -1450,6 +1626,12 @@ +@@ -1455,6 +1631,12 @@ return false; } @@ -273,7 +273,7 @@ public void awardKillScore(Entity entity, int i, DamageSource damagesource) { if (entity instanceof EntityPlayer) { CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource); -@@ -1483,7 +1665,7 @@ +@@ -1488,7 +1670,7 @@ } else { String s = this.getEncodeId(); @@ -282,7 +282,7 @@ return false; } else { nbttagcompound.putString("id", s); -@@ -1508,6 +1690,18 @@ +@@ -1513,6 +1695,18 @@ Vec3D vec3d = this.getDeltaMovement(); nbttagcompound.put("Motion", this.newDoubleList(vec3d.x, vec3d.y, vec3d.z)); @@ -301,7 +301,7 @@ nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot())); nbttagcompound.putFloat("FallDistance", this.fallDistance); nbttagcompound.putShort("Fire", (short) this.remainingFireTicks); -@@ -1516,6 +1710,22 @@ +@@ -1521,6 +1715,22 @@ nbttagcompound.putBoolean("Invulnerable", this.invulnerable); nbttagcompound.putInt("PortalCooldown", this.portalCooldown); nbttagcompound.putUUID("UUID", this.getUUID()); @@ -324,7 +324,7 @@ IChatBaseComponent ichatbasecomponent = this.getCustomName(); if (ichatbasecomponent != null) { -@@ -1583,6 +1793,11 @@ +@@ -1588,6 +1798,11 @@ } } @@ -336,7 +336,7 @@ return nbttagcompound; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); -@@ -1664,6 +1879,53 @@ +@@ -1669,6 +1884,53 @@ } else { throw new IllegalStateException("Entity has invalid position"); } @@ -390,7 +390,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded"); -@@ -1739,9 +2001,22 @@ +@@ -1744,9 +2006,22 @@ } else if (this.level.isClientSide) { return null; } else { @@ -413,7 +413,7 @@ this.level.addFreshEntity(entityitem); return entityitem; } -@@ -1836,7 +2111,7 @@ +@@ -1840,7 +2115,7 @@ this.setPose(EntityPose.STANDING); this.vehicle = entity; @@ -422,7 +422,7 @@ entity.getIndirectPassengersStream().filter((entity2) -> { return entity2 instanceof EntityPlayer; }).forEach((entity2) -> { -@@ -1867,7 +2142,7 @@ +@@ -1871,7 +2146,7 @@ Entity entity = this.vehicle; this.vehicle = null; @@ -431,7 +431,7 @@ } } -@@ -1876,10 +2151,31 @@ +@@ -1880,10 +2155,31 @@ this.removeVehicle(); } @@ -464,7 +464,7 @@ if (this.passengers.isEmpty()) { this.passengers = ImmutableList.of(entity); } else { -@@ -1895,12 +2191,32 @@ +@@ -1899,12 +2195,32 @@ } } @@ -498,7 +498,7 @@ if (this.passengers.size() == 1 && this.passengers.get(0) == entity) { this.passengers = ImmutableList.of(); } else { -@@ -1911,6 +2227,7 @@ +@@ -1915,6 +2231,7 @@ entity.boardingCooldown = 60; } @@ -506,7 +506,7 @@ } protected boolean canAddPassenger(Entity entity) { -@@ -1961,14 +2278,20 @@ +@@ -1977,14 +2294,20 @@ if (this.isInsidePortal) { MinecraftServer minecraftserver = worldserver.getServer(); @@ -530,7 +530,7 @@ this.level.getProfiler().pop(); } -@@ -2086,6 +2409,13 @@ +@@ -2102,6 +2425,13 @@ } public void setSwimming(boolean flag) { @@ -544,7 +544,7 @@ this.setSharedFlag(4, flag); } -@@ -2134,8 +2464,12 @@ +@@ -2150,8 +2480,12 @@ return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false; } @@ -558,7 +558,7 @@ } public boolean getSharedFlag(int i) { -@@ -2154,7 +2488,7 @@ +@@ -2170,7 +2504,7 @@ } public int getMaxAirSupply() { @@ -567,7 +567,7 @@ } public int getAirSupply() { -@@ -2162,7 +2496,18 @@ +@@ -2178,7 +2512,18 @@ } public void setAirSupply(int i) { @@ -587,7 +587,7 @@ } public int getTicksFrozen() { -@@ -2189,11 +2534,41 @@ +@@ -2205,11 +2550,41 @@ public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -631,7 +631,7 @@ } public void onAboveBubbleCol(boolean flag) { -@@ -2349,15 +2724,38 @@ +@@ -2365,15 +2740,38 @@ @Nullable public Entity changeDimension(WorldServer worldserver) { @@ -672,7 +672,7 @@ this.level.getProfiler().popPush("reloading"); Entity entity = this.getType().create(worldserver); -@@ -2366,9 +2764,17 @@ +@@ -2382,9 +2780,17 @@ entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot()); entity.setDeltaMovement(shapedetectorshape.speed); worldserver.addDuringTeleport(entity); @@ -692,7 +692,7 @@ } this.removeAfterChangingDimensions(); -@@ -2389,20 +2795,34 @@ +@@ -2405,20 +2811,34 @@ @Nullable protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) { @@ -732,7 +732,7 @@ IBlockData iblockdata = this.level.getBlockState(this.portalEntrancePos); EnumDirection.EnumAxis enumdirection_enumaxis; Vec3D vec3d; -@@ -2419,8 +2839,8 @@ +@@ -2435,8 +2855,8 @@ vec3d = new Vec3D(0.5D, 0.0D, 0.0D); } @@ -743,7 +743,7 @@ } } else { BlockPosition blockposition1; -@@ -2430,8 +2850,15 @@ +@@ -2446,8 +2866,15 @@ } else { blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos()); } @@ -760,7 +760,7 @@ } } -@@ -2439,8 +2866,23 @@ +@@ -2455,8 +2882,23 @@ return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose())); } @@ -786,7 +786,7 @@ } public boolean canChangeDimensions() { -@@ -2649,7 +3091,26 @@ +@@ -2665,7 +3107,26 @@ } public final void setBoundingBox(AxisAlignedBB axisalignedbb) { @@ -814,12 +814,12 @@ } protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) { -@@ -2933,6 +3394,11 @@ +@@ -2949,6 +3410,11 @@ vec3d = vec3d.add(vec3d1); ++k1; } + // CraftBukkit start - store last lava contact location -+ if (tag == TagsFluid.LAVA) { ++ if (tagkey == TagsFluid.LAVA) { + this.lastLavaContact = blockposition_mutableblockposition.immutable(); + } + // CraftBukkit end diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch index 4a9525c951..3411bd03c2 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/EntityAreaEffectCloud.java +++ b/net/minecraft/world/entity/EntityAreaEffectCloud.java @@ -32,6 +32,12 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import net.minecraft.world.level.material.EnumPistonReaction; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.resources.MinecraftKey; @@ -12,7 +12,7 @@ + public class EntityAreaEffectCloud extends Entity { - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); @@ -127,6 +133,22 @@ } 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 3577ba1290..44197ed9ae 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityExperienceOrb.java +++ b/net/minecraft/world/entity/EntityExperienceOrb.java -@@ -21,6 +21,12 @@ +@@ -20,6 +20,12 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -13,7 +13,7 @@ public class EntityExperienceOrb extends Entity { private static final int LIFETIME = 6000; -@@ -59,6 +65,7 @@ +@@ -58,6 +64,7 @@ @Override public void tick() { super.tick(); @@ -21,7 +21,7 @@ this.xo = this.getX(); this.yo = this.getY(); this.zo = this.getZ(); -@@ -84,7 +91,22 @@ +@@ -83,7 +90,22 @@ this.followingPlayer = null; } @@ -45,7 +45,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(); -@@ -225,7 +247,7 @@ +@@ -226,7 +248,7 @@ int i = this.repairPlayerItems(entityhuman, this.value); if (i > 0) { @@ -54,7 +54,7 @@ } --this.count; -@@ -243,9 +265,17 @@ +@@ -244,9 +266,17 @@ if (entry != null) { ItemStack itemstack = (ItemStack) entry.getValue(); int j = Math.min(this.xpToDurability(this.value), itemstack.getDamageValue()); @@ -72,7 +72,7 @@ return k > 0 ? this.repairPlayerItems(entityhuman, k) : 0; } else { -@@ -270,6 +300,24 @@ +@@ -271,6 +301,24 @@ } public static int getExperienceValue(int i) { 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 68f067bf03..9b0f1505ba 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityLiving.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityLiving.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/EntityLiving.java +++ b/net/minecraft/world/entity/EntityLiving.java -@@ -116,6 +116,30 @@ +@@ -117,6 +117,30 @@ import net.minecraft.world.scores.ScoreboardTeam; - import org.apache.logging.log4j.Logger; + import org.slf4j.Logger; +// CraftBukkit start +import java.util.ArrayList; @@ -30,8 +30,8 @@ + public abstract class EntityLiving extends Entity { - private static final UUID SPEED_MODIFIER_SPRINTING_UUID = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); -@@ -224,6 +248,20 @@ + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -226,6 +250,20 @@ private float swimAmount; private float swimAmountO; protected BehaviorController brain; @@ -52,7 +52,7 @@ protected EntityLiving(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -236,7 +274,9 @@ +@@ -238,7 +276,9 @@ this.useItem = ItemStack.EMPTY; this.lastClimbablePos = Optional.empty(); this.attributes = new AttributeMapBase(AttributeDefaults.getSupplier(entitytypes)); @@ -63,7 +63,7 @@ this.blocksBuilding = true; this.rotA = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); this.reapplyPosition(); -@@ -303,7 +343,13 @@ +@@ -305,7 +345,13 @@ double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D); int i = (int) (150.0D * d1); @@ -78,7 +78,7 @@ } } -@@ -561,7 +607,7 @@ +@@ -563,7 +609,7 @@ protected void tickDeath() { ++this.deathTime; @@ -87,7 +87,7 @@ this.level.broadcastEntityEvent(this, (byte) 60); this.remove(Entity.RemovalReason.KILLED); } -@@ -653,9 +699,15 @@ +@@ -655,9 +701,15 @@ } protected void equipEventAndSound(ItemStack itemstack) { @@ -104,7 +104,7 @@ this.gameEvent(GameEvent.EQUIP); this.playSound(soundeffect, 1.0F, 1.0F); } -@@ -717,6 +769,17 @@ +@@ -719,6 +771,17 @@ } } @@ -122,7 +122,7 @@ if (nbttagcompound.contains("Health", 99)) { this.setHealth(nbttagcompound.getFloat("Health")); } -@@ -754,9 +817,32 @@ +@@ -756,9 +819,32 @@ } @@ -155,7 +155,7 @@ try { while (iterator.hasNext()) { MobEffectList mobeffectlist = (MobEffectList) iterator.next(); -@@ -766,6 +852,12 @@ +@@ -768,6 +854,12 @@ this.onEffectUpdated(mobeffect, true, (Entity) null); })) { if (!this.level.isClientSide) { @@ -168,7 +168,7 @@ iterator.remove(); this.onEffectRemoved(mobeffect); } -@@ -776,6 +868,17 @@ +@@ -778,6 +870,17 @@ } catch (ConcurrentModificationException concurrentmodificationexception) { ; } @@ -186,7 +186,7 @@ if (this.effectsDirty) { if (!this.level.isClientSide) { -@@ -902,7 +1005,13 @@ +@@ -904,7 +1007,13 @@ this.entityData.set(EntityLiving.DATA_EFFECT_COLOR_ID, 0); } @@ -200,7 +200,7 @@ if (this.level.isClientSide) { return false; } else { -@@ -911,7 +1020,14 @@ +@@ -913,7 +1022,14 @@ boolean flag; for (flag = false; iterator.hasNext(); flag = true) { @@ -216,7 +216,7 @@ iterator.remove(); } -@@ -940,18 +1056,48 @@ +@@ -942,18 +1058,48 @@ return this.addEffect(mobeffect, (Entity) null); } @@ -266,7 +266,7 @@ return true; } else { return false; -@@ -988,13 +1134,39 @@ +@@ -990,13 +1136,39 @@ return this.getMobType() == EnumMonsterType.UNDEAD; } @@ -307,7 +307,7 @@ if (mobeffect != null) { this.onEffectRemoved(mobeffect); -@@ -1031,20 +1203,55 @@ +@@ -1033,20 +1205,55 @@ } @@ -364,7 +364,7 @@ this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.clamp(f, 0.0F, this.getMaxHealth())); } -@@ -1058,7 +1265,7 @@ +@@ -1060,7 +1267,7 @@ return false; } else if (this.level.isClientSide) { return false; @@ -373,7 +373,7 @@ return false; } else if (damagesource.isFire() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -1069,10 +1276,11 @@ +@@ -1071,10 +1278,11 @@ this.noActionTime = 0; float f1 = f; @@ -387,7 +387,7 @@ this.hurtCurrentlyUsedShield(f); f2 = f; f = 0.0F; -@@ -1090,27 +1298,46 @@ +@@ -1092,27 +1300,46 @@ this.animationSpeed = 1.5F; boolean flag1 = true; @@ -439,7 +439,7 @@ this.hurtDir = 0.0F; Entity entity1 = damagesource.getEntity(); -@@ -1233,19 +1460,29 @@ +@@ -1235,19 +1462,29 @@ EnumHand[] aenumhand = EnumHand.values(); int i = aenumhand.length; @@ -473,7 +473,7 @@ EntityPlayer entityplayer = (EntityPlayer) this; entityplayer.awardStat(StatisticList.ITEM_USED.get(Items.TOTEM_OF_UNDYING)); -@@ -1253,14 +1490,16 @@ +@@ -1255,14 +1492,16 @@ } this.setHealth(1.0F); @@ -495,7 +495,7 @@ } } -@@ -1365,14 +1604,22 @@ +@@ -1367,14 +1606,22 @@ IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState(); if (this.level.getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level, blockposition)) { @@ -520,7 +520,7 @@ this.level.addFreshEntity(entityitem); } } -@@ -1392,21 +1639,40 @@ +@@ -1394,21 +1641,40 @@ boolean flag = this.lastHurtByPlayerTime > 0; @@ -564,7 +564,7 @@ } -@@ -1526,9 +1792,14 @@ +@@ -1528,9 +1794,14 @@ int i = this.calculateFallDamage(f, f1); if (i > 0) { @@ -580,7 +580,7 @@ return true; } else { return flag; -@@ -1577,7 +1848,7 @@ +@@ -1579,7 +1850,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) { if (!damagesource.isBypassArmor()) { @@ -589,7 +589,7 @@ f = CombatMath.getDamageAfterAbsorb(f, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS)); } -@@ -1590,7 +1861,8 @@ +@@ -1592,7 +1863,8 @@ } else { int i; @@ -599,7 +599,7 @@ i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f1 = f * (float) j; -@@ -1621,29 +1893,172 @@ +@@ -1623,29 +1895,172 @@ } } @@ -782,7 +782,7 @@ } public CombatTracker getCombatTracker() { -@@ -1664,8 +2079,18 @@ +@@ -1666,8 +2081,18 @@ } public final void setArrowCount(int i) { @@ -802,7 +802,7 @@ public final int getStingerCount() { return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID); -@@ -1961,6 +2386,12 @@ +@@ -1963,6 +2388,12 @@ public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot); @@ -815,7 +815,7 @@ @Override public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack); -@@ -2204,6 +2635,7 @@ +@@ -2206,6 +2637,7 @@ } if (this.onGround && !this.level.isClientSide) { @@ -823,7 +823,7 @@ this.setSharedFlag(7, false); } } else { -@@ -2734,6 +3166,7 @@ +@@ -2736,6 +3168,7 @@ } if (!this.level.isClientSide) { @@ -831,7 +831,7 @@ this.setSharedFlag(7, flag); } -@@ -2901,14 +3334,21 @@ +@@ -2895,14 +3328,21 @@ @Override public boolean isPickable() { @@ -853,9 +853,9 @@ + // CraftBukkit end + @Override - protected void markHurt() { - this.hurtMarked = this.random.nextDouble() >= this.getAttributeValue(GenericAttributes.KNOCKBACK_RESISTANCE); -@@ -3107,7 +3547,25 @@ + public float getYHeadRot() { + return this.yHeadRot; +@@ -3096,7 +3536,25 @@ } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { this.triggerItemUseEffects(this.useItem, 16); @@ -882,7 +882,7 @@ if (itemstack != this.useItem) { this.setItemInHand(enumhand, itemstack); -@@ -3180,6 +3638,12 @@ +@@ -3169,6 +3627,12 @@ } public boolean randomTeleport(double d0, double d1, double d2, boolean flag) { @@ -895,7 +895,7 @@ double d3 = this.getX(); double d4 = this.getY(); double d5 = this.getZ(); -@@ -3204,16 +3668,41 @@ +@@ -3193,16 +3657,41 @@ } if (flag2) { @@ -940,7 +940,7 @@ } else { if (flag) { world.broadcastEntityEvent(this, (byte) 46); -@@ -3223,7 +3712,7 @@ +@@ -3212,7 +3701,7 @@ ((EntityCreature) this).getNavigation().stop(); } @@ -949,7 +949,7 @@ } } -@@ -3306,7 +3795,7 @@ +@@ -3295,7 +3784,7 @@ } public void stopSleeping() { @@ -958,7 +958,7 @@ World world = this.level; java.util.Objects.requireNonNull(this.level); -@@ -3338,7 +3827,7 @@ +@@ -3327,7 +3816,7 @@ @Nullable public EnumDirection getBedOrientation() { @@ -967,7 +967,7 @@ return blockposition != null ? BlockBed.getBedOrientation(this.level, blockposition) : null; } -@@ -3387,7 +3876,7 @@ +@@ -3376,7 +3865,7 @@ Pair pair = (Pair) iterator.next(); if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) { @@ -976,7 +976,7 @@ } } } -@@ -3490,8 +3979,10 @@ +@@ -3479,8 +3968,10 @@ this.setDeltaMovement((double) ((float) packetplayoutspawnentityliving.getXd() / 8000.0F), (double) ((float) packetplayoutspawnentityliving.getYd() / 8000.0F), (double) ((float) packetplayoutspawnentityliving.getZd() / 8000.0F)); } @@ -988,7 +988,7 @@ private final SoundEffect small; private final SoundEffect big; -@@ -3507,5 +3998,7 @@ +@@ -3496,5 +3987,7 @@ public SoundEffect big() { return this.big; } 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 22f7d8fc2a..b8408cebbb 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityTypes.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityTypes.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/EntityTypes.java +++ b/net/minecraft/world/entity/EntityTypes.java -@@ -152,7 +152,7 @@ - private static final Logger LOGGER = LogManager.getLogger(); +@@ -154,7 +154,7 @@ public static final String ENTITY_TAG = "EntityTag"; + private final Holder.c> builtInRegistryHolder; private static final float MAGIC_HORSE_WIDTH = 1.3964844F; - public static final EntityTypes AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(Integer.MAX_VALUE)); + public static final EntityTypes AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds public static final EntityTypes ARMOR_STAND = register("armor_stand", EntityTypes.Builder.of(EntityArmorStand::new, EnumCreatureType.MISC).sized(0.5F, 1.975F).clientTrackingRange(10)); public static final EntityTypes ARROW = register("arrow", EntityTypes.Builder.of(EntityTippedArrow::new, EnumCreatureType.MISC).sized(0.5F, 0.5F).clientTrackingRange(4).updateInterval(20)); public static final EntityTypes AXOLOTL = register("axolotl", EntityTypes.Builder.of(Axolotl::new, EnumCreatureType.AXOLOTLS).sized(0.75F, 0.42F).clientTrackingRange(10)); -@@ -282,8 +282,8 @@ +@@ -284,8 +284,8 @@ private MinecraftKey lootTable; private final EntitySize dimensions; @@ -20,7 +20,7 @@ } public static MinecraftKey getKey(EntityTypes entitytypes) { -@@ -314,10 +314,18 @@ +@@ -317,10 +317,18 @@ @Nullable public T spawn(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) { @@ -40,7 +40,7 @@ } return t0; -@@ -353,7 +361,7 @@ +@@ -356,7 +364,7 @@ t0.setCustomName(ichatbasecomponent); } @@ -49,7 +49,7 @@ return t0; } } -@@ -510,7 +518,7 @@ +@@ -513,7 +521,7 @@ } return entity; @@ -58,7 +58,7 @@ } public static Stream loadEntitiesRecursive(final List list, final World world) { -@@ -567,7 +575,7 @@ +@@ -570,7 +578,7 @@ @Nullable public T tryCast(Entity entity) { @@ -67,7 +67,7 @@ } @Override -@@ -594,7 +602,7 @@ +@@ -603,7 +611,7 @@ this.canSpawnFarFromPlayer = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC; } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorCareer.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorCareer.patch index 251fa21d34..5c19316f1a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorCareer.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorCareer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorCareer.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorCareer.java -@@ -13,6 +13,12 @@ +@@ -12,6 +12,12 @@ import net.minecraft.world.entity.npc.EntityVillager; import net.minecraft.world.entity.npc.VillagerProfession; @@ -13,7 +13,7 @@ public class BehaviorCareer extends Behavior { public BehaviorCareer() { -@@ -29,7 +35,7 @@ +@@ -28,7 +34,7 @@ GlobalPos globalpos = (GlobalPos) entityvillager.getBrain().getMemory(MemoryModuleType.POTENTIAL_JOB_SITE).get(); entityvillager.getBrain().eraseMemory(MemoryModuleType.POTENTIAL_JOB_SITE); @@ -22,7 +22,7 @@ worldserver.broadcastEntityEvent(entityvillager, (byte) 14); if (entityvillager.getVillagerData().getProfession() == VillagerProfession.NONE) { MinecraftServer minecraftserver = worldserver.getServer(); -@@ -41,7 +47,14 @@ +@@ -40,7 +46,14 @@ return villagerprofession.getJobPoiType() == villageplacetype; }).findFirst(); }).ifPresent((villagerprofession) -> { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFarm.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFarm.patch index 78c3c972e7..efa46613e1 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFarm.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFarm.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java -@@ -80,8 +80,8 @@ +@@ -79,8 +79,8 @@ protected void start(WorldServer worldserver, EntityVillager entityvillager, long i) { if (i > this.nextOkStartTime && this.aboveFarmlandPos != null) { @@ -11,7 +11,7 @@ } } -@@ -101,7 +101,11 @@ +@@ -100,7 +100,11 @@ Block block1 = worldserver.getBlockState(this.aboveFarmlandPos.below()).getBlock(); if (block instanceof BlockCrops && ((BlockCrops) block).isMaxAge(iblockdata)) { @@ -24,7 +24,7 @@ } if (iblockdata.isAir() && block1 instanceof BlockSoil && entityvillager.hasFarmSeeds()) { -@@ -112,19 +116,28 @@ +@@ -111,19 +115,28 @@ boolean flag = false; if (!itemstack.isEmpty()) { @@ -57,7 +57,7 @@ } if (flag) { -@@ -143,8 +156,8 @@ +@@ -142,8 +155,8 @@ this.aboveFarmlandPos = this.getValidFarmland(worldserver); if (this.aboveFarmlandPos != null) { this.nextOkStartTime = i + 20L; diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.patch index 52d6af560a..07d0bf1615 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.patch @@ -14,7 +14,7 @@ blockdoor.setOpen(entityliving, worldserver, iblockdata, blockposition, true); } -@@ -82,6 +89,13 @@ +@@ -84,6 +91,13 @@ BlockDoor blockdoor1 = (BlockDoor) iblockdata1.getBlock(); if (!blockdoor1.isOpen(iblockdata1)) { @@ -28,7 +28,7 @@ blockdoor1.setOpen(entityliving, worldserver, iblockdata1, blockposition1, true); this.rememberDoorToClose(worldserver, entityliving, blockposition1); } -@@ -130,7 +144,7 @@ +@@ -134,7 +148,7 @@ private static boolean areOtherMobsComingThroughDoor(WorldServer worldserver, EntityLiving entityliving, BlockPosition blockposition) { BehaviorController behaviorcontroller = entityliving.getBrain(); @@ -36,8 +36,8 @@ + return !behaviorcontroller.hasMemoryValue(MemoryModuleType.NEAREST_LIVING_ENTITIES) ? false : (behaviorcontroller.getMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES).get()).stream().filter((entityliving1) -> { // CraftBukkit - decompile error return entityliving1.getType() == entityliving.getType(); }).filter((entityliving1) -> { - return blockposition.closerThan((IPosition) entityliving1.position(), 2.0D); -@@ -172,7 +186,7 @@ + return blockposition.closerToCenterThan(entityliving1.position(), 2.0D); +@@ -176,7 +190,7 @@ if (behaviorcontroller.getMemory(MemoryModuleType.DOORS_TO_CLOSE).isPresent()) { ((Set) behaviorcontroller.getMemory(MemoryModuleType.DOORS_TO_CLOSE).get()).add(globalpos); } else { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.patch index efb9ab5295..5de56bf64c 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.java +++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.java -@@ -72,6 +72,12 @@ +@@ -71,6 +71,12 @@ } if (this.breakTime == this.getDoorBreakTime() && this.isValidDifficulty(this.mob.level.getDifficulty())) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalPanic.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalPanic.patch index 0c0c52b664..d1b6a4693d 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalPanic.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalPanic.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/PathfinderGoalPanic.java +++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalPanic.java -@@ -11,6 +11,10 @@ +@@ -10,6 +10,10 @@ import net.minecraft.world.level.IBlockAccess; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public class PathfinderGoalPanic extends PathfinderGoal { public static final int WATER_CHECK_DISTANCE_VERTICAL = 1; -@@ -77,6 +81,12 @@ +@@ -80,6 +84,12 @@ @Override public boolean canContinueToUse() { @@ -24,10 +24,10 @@ return !this.mob.getNavigation().isDone(); } -@@ -86,6 +96,6 @@ +@@ -89,6 +99,6 @@ return !iblockaccess.getBlockState(blockposition).getCollisionShape(iblockaccess, blockposition).isEmpty() ? null : (BlockPosition) BlockPosition.findClosestMatch(entity.blockPosition(), i, 1, (blockposition1) -> { - return iblockaccess.getFluidState(blockposition1).is((Tag) TagsFluid.WATER); + return iblockaccess.getFluidState(blockposition1).is(TagsFluid.WATER); - }).orElse((Object) null); + }).orElse(null); // CraftBukkit - decompile error } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch b/paper-server/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch index e40668ff2f..2f35f27242 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ambient/EntityBat.java +++ b/net/minecraft/world/entity/ambient/EntityBat.java -@@ -29,6 +29,8 @@ +@@ -28,6 +28,8 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.Vec3D; @@ -9,7 +9,7 @@ public class EntityBat extends EntityAmbient { public static final float FLAP_DEGREES_PER_TICK = 74.48451F; -@@ -138,16 +140,24 @@ +@@ -137,16 +139,24 @@ } if (this.level.getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null) { @@ -39,7 +39,7 @@ } } else { if (this.targetPosition != null && (!this.level.isEmptyBlock(this.targetPosition) || this.targetPosition.getY() <= this.level.getMinBuildHeight())) { -@@ -171,7 +181,11 @@ +@@ -170,7 +180,11 @@ this.zza = 0.5F; this.setYRot(this.getYRot() + f1); if (this.random.nextInt(100) == 0 && this.level.getBlockState(blockposition1).isRedstoneConductor(this.level, blockposition1)) { @@ -52,7 +52,7 @@ } } -@@ -201,7 +215,11 @@ +@@ -200,7 +214,11 @@ return false; } else { if (!this.level.isClientSide && this.isResting()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch index 41d146e10b..31f8fd2851 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityAnimal.java +++ b/net/minecraft/world/entity/animal/EntityAnimal.java -@@ -31,12 +31,19 @@ +@@ -30,12 +30,19 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.pathfinder.PathType; @@ -20,7 +20,7 @@ protected EntityAnimal(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -73,6 +80,9 @@ +@@ -72,6 +79,9 @@ } @@ -30,7 +30,7 @@ @Override public boolean hurt(DamageSource damagesource, float f) { if (this.isInvulnerableTo(damagesource)) { -@@ -82,6 +92,7 @@ +@@ -81,6 +91,7 @@ return super.hurt(damagesource, f); } } @@ -38,7 +38,7 @@ @Override public float getWalkTargetValue(BlockPosition blockposition, IWorldReader iworldreader) { -@@ -178,10 +189,17 @@ +@@ -177,10 +188,17 @@ } public void setInLove(@Nullable EntityHuman entityhuman) { @@ -57,7 +57,7 @@ this.level.broadcastEntityEvent(this, (byte) 18); } -@@ -221,11 +239,26 @@ +@@ -220,11 +238,26 @@ EntityAgeable entityageable = this.getBreedOffspring(worldserver, entityanimal); if (entityageable != null) { @@ -84,7 +84,7 @@ if (entityplayer != null) { entityplayer.awardStat(StatisticList.ANIMALS_BRED); -@@ -236,12 +269,14 @@ +@@ -235,12 +268,14 @@ entityanimal.setAge(6000); this.resetLove(); entityanimal.resetLove(); 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 3c52b7b2fc..9614cd7dec 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 -@@ -244,7 +244,7 @@ +@@ -242,7 +242,7 @@ } if (b0 > 0) { @@ -9,7 +9,7 @@ } } -@@ -644,11 +644,15 @@ +@@ -642,11 +642,15 @@ if (this.isInvulnerableTo(damagesource)) { return false; } else { @@ -27,7 +27,7 @@ } } -@@ -1224,7 +1228,7 @@ +@@ -1222,7 +1226,7 @@ } } @@ -36,7 +36,7 @@ EntityBee.this.level.levelEvent(2005, blockposition, 0); EntityBee.this.level.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(blockstateinteger, (Integer) iblockdata.getValue(blockstateinteger) + 1)); EntityBee.this.incrementNumCropsGrownSincePollination(); -@@ -1297,7 +1301,7 @@ +@@ -1295,7 +1299,7 @@ @Override protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) { if (entityinsentient instanceof EntityBee && this.mob.hasLineOfSight(entityliving)) { @@ -45,7 +45,7 @@ } } -@@ -1306,7 +1310,7 @@ +@@ -1304,7 +1308,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 87a2dd17aa..2843ad08eb 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityCat.java +++ b/net/minecraft/world/entity/animal/EntityCat.java -@@ -434,7 +434,7 @@ +@@ -443,7 +443,7 @@ } } else if (this.isFood(itemstack)) { this.usePlayerItem(entityhuman, enumhand, itemstack); @@ -9,7 +9,7 @@ this.tame(entityhuman); this.setOrderedToSit(true); this.level.broadcastEntityEvent(this, (byte) 7); -@@ -491,7 +491,7 @@ +@@ -500,7 +500,7 @@ private static class PathfinderGoalTemptChance extends PathfinderGoalTempt { @Nullable @@ -18,7 +18,7 @@ private final EntityCat cat; public PathfinderGoalTemptChance(EntityCat entitycat, double d0, RecipeItemStack recipeitemstack, boolean flag) { -@@ -632,7 +632,15 @@ +@@ -641,7 +641,15 @@ while (iterator.hasNext()) { ItemStack itemstack = (ItemStack) iterator.next(); @@ -35,7 +35,7 @@ } } -@@ -664,10 +672,10 @@ +@@ -673,10 +681,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/EntityDolphin.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch index d1056c7872..13bb193429 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityDolphin.java +++ b/net/minecraft/world/entity/animal/EntityDolphin.java -@@ -65,6 +65,12 @@ +@@ -63,6 +63,12 @@ public class EntityDolphin extends EntityWaterAnimal { @@ -13,7 +13,7 @@ private static final DataWatcherObject TREASURE_POS = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BLOCK_POS); private static final DataWatcherObject GOT_FISH = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BOOLEAN); private static final DataWatcherObject MOISTNESS_LEVEL = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.INT); -@@ -192,7 +198,7 @@ +@@ -190,7 +196,7 @@ @Override public int getMaxAirSupply() { @@ -22,7 +22,7 @@ } @Override -@@ -233,6 +239,12 @@ +@@ -231,6 +237,12 @@ ItemStack itemstack = entityitem.getItem(); if (this.canHoldItem(itemstack)) { @@ -35,7 +35,7 @@ this.onItemPickup(entityitem); this.setItemSlot(EnumItemSlot.MAINHAND, itemstack); this.handDropChances[EnumItemSlot.MAINHAND.getIndex()] = 2.0F; -@@ -391,7 +403,7 @@ +@@ -389,7 +401,7 @@ @Override public boolean canUse() { @@ -44,7 +44,7 @@ } @Override -@@ -501,7 +513,7 @@ +@@ -489,7 +501,7 @@ @Override public void start() { @@ -53,7 +53,7 @@ } @Override -@@ -520,7 +532,7 @@ +@@ -508,7 +520,7 @@ } if (this.player.isSwimming() && this.player.level.random.nextInt(6) == 0) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch index 6325263074..5097752978 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityFox.java +++ b/net/minecraft/world/entity/animal/EntityFox.java -@@ -507,7 +507,8 @@ +@@ -509,7 +509,8 @@ protected void pickUpItem(EntityItem entityitem) { ItemStack itemstack = entityitem.getItem(); @@ -10,7 +10,7 @@ int i = itemstack.getCount(); if (i > 1) { -@@ -862,6 +863,16 @@ +@@ -864,6 +865,16 @@ if (entityplayer1 != null && entityplayer != entityplayer1) { entityfox.addTrustedUUID(entityplayer1.getUUID()); } @@ -27,7 +27,7 @@ if (entityplayer2 != null) { entityplayer2.awardStat(StatisticList.ANIMALS_BRED); -@@ -872,12 +883,14 @@ +@@ -874,12 +885,14 @@ this.partner.setAge(6000); this.animal.resetLove(); this.partner.resetLove(); @@ -46,7 +46,7 @@ } } -@@ -1268,13 +1281,18 @@ +@@ -1270,13 +1283,18 @@ } private void pickGlowBerry(IBlockData iblockdata) { @@ -66,7 +66,7 @@ int j = 1 + EntityFox.this.level.random.nextInt(2) + (i == 3 ? 1 : 0); ItemStack itemstack = EntityFox.this.getItemBySlot(EnumItemSlot.MAINHAND); -@@ -1431,7 +1449,7 @@ +@@ -1433,7 +1451,7 @@ private EntityLiving trustedLastHurt; private int timestamp; 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 5ec961d58d..b46ae761d5 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 org.apache.commons.lang3.tuple.Pair; @@ -14,7 +14,7 @@ public class EntityMushroomCow extends EntityCow implements IShearable { private static final DataWatcherObject DATA_TYPE = DataWatcher.defineId(EntityMushroomCow.class, DataWatcherRegistry.STRING); -@@ -117,6 +124,11 @@ +@@ -116,6 +123,11 @@ this.playSound(soundeffect, 1.0F, 1.0F); return EnumInteractionResult.sidedSuccess(this.level.isClientSide); } else if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { @@ -26,7 +26,7 @@ this.shear(SoundCategory.PLAYERS); this.gameEvent(GameEvent.SHEAR, (Entity) entityhuman); if (!this.level.isClientSide) { -@@ -164,7 +176,7 @@ +@@ -163,7 +175,7 @@ this.level.playSound((EntityHuman) null, (Entity) this, SoundEffects.MOOSHROOM_SHEAR, soundcategory, 1.0F, 1.0F); if (!this.level.isClientSide()) { ((WorldServer) this.level).sendParticles(Particles.EXPLOSION, this.getX(), this.getY(0.5D), this.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D); @@ -35,7 +35,7 @@ EntityCow entitycow = (EntityCow) EntityTypes.COW.create(this.level); entitycow.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); -@@ -180,10 +192,25 @@ +@@ -179,10 +191,25 @@ } entitycow.setInvulnerable(this.isInvulnerable()); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch index 0de1148380..dd18d82a5c 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityOcelot.java +++ b/net/minecraft/world/entity/animal/EntityOcelot.java -@@ -134,7 +134,7 @@ +@@ -133,7 +133,7 @@ @Override public boolean removeWhenFarAway(double d0) { @@ -9,7 +9,7 @@ } public static AttributeProvider.Builder createAttributes() { -@@ -183,7 +183,8 @@ +@@ -182,7 +182,8 @@ if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemstack) && entityhuman.distanceToSqr((Entity) this) < 9.0D) { this.usePlayerItem(entityhuman, enumhand, itemstack); if (!this.level.isClientSide) { @@ -19,7 +19,7 @@ this.setTrusting(true); this.spawnTrustingParticles(true); this.level.broadcastEntityEvent(this, (byte) 41); -@@ -313,10 +314,10 @@ +@@ -312,10 +313,10 @@ private final EntityOcelot ocelot; public a(EntityOcelot entityocelot, Class oclass, float f, double d0, double d1) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch index dd39cd2dfb..22bf133e9d 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch @@ -18,7 +18,7 @@ this.onItemPickup(entityitem); ItemStack itemstack = entityitem.getItem(); -@@ -882,10 +884,10 @@ +@@ -872,10 +874,10 @@ private final EntityPanda panda; public c(EntityPanda entitypanda, Class oclass, float f, double d0, double d1) { @@ -32,7 +32,7 @@ this.panda = entitypanda; } -@@ -1132,7 +1134,7 @@ +@@ -1114,7 +1116,7 @@ @Override protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) { if (entityinsentient instanceof EntityPanda && ((EntityPanda) entityinsentient).isAggressive()) { 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 4233be9351..f5dfe657e7 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 -@@ -258,7 +258,7 @@ +@@ -256,7 +256,7 @@ } if (!this.level.isClientSide) { @@ -9,7 +9,7 @@ this.tame(entityhuman); this.level.broadcastEntityEvent(this, (byte) 7); } else { -@@ -272,7 +272,7 @@ +@@ -270,7 +270,7 @@ itemstack.shrink(1); } @@ -18,7 +18,7 @@ if (entityhuman.isCreative() || !this.isInvulnerable()) { this.hurt(DamageSource.playerAttack(entityhuman), Float.MAX_VALUE); } -@@ -384,7 +384,7 @@ +@@ -382,7 +382,7 @@ @Override public boolean isPushable() { @@ -27,12 +27,12 @@ } @Override -@@ -399,7 +399,7 @@ - if (this.isInvulnerableTo(damagesource)) { +@@ -398,7 +398,7 @@ return false; } else { -- this.setOrderedToSit(false); -+ // this.setOrderedToSit(false); // CraftBukkit - moved into EntityLiving.damageEntity(DamageSource, float) + if (!this.level.isClientSide) { +- this.setOrderedToSit(false); ++ // this.setOrderedToSit(false); // CraftBukkit - moved into EntityLiving.damageEntity(DamageSource, float) + } + return super.hurt(damagesource, f); - } - } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch index d147bd4a07..ba938837e1 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityRabbit.java +++ b/net/minecraft/world/entity/animal/EntityRabbit.java -@@ -88,8 +88,14 @@ +@@ -89,8 +89,14 @@ super(entitytypes, world); this.jumpControl = new EntityRabbit.ControllerJumpRabbit(this); this.moveControl = new EntityRabbit.ControllerMoveRabbit(this); @@ -15,7 +15,7 @@ @Override public void registerGoals() { -@@ -556,9 +562,23 @@ +@@ -558,9 +564,23 @@ int i = (Integer) iblockdata.getValue(BlockCarrots.AGE); if (i == 0) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch index c1d142b60f..5d5c35ee6b 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch @@ -12,7 +12,7 @@ private static final DataWatcherObject DATA_PUMPKIN_ID = DataWatcher.defineId(EntitySnowman.class, DataWatcherRegistry.BYTE); @@ -103,7 +107,7 @@ - BiomeBase biomebase = this.level.getBiome(blockposition); + BiomeBase biomebase = (BiomeBase) this.level.getBiome(blockposition).value(); if (biomebase.shouldSnowGolemBurn(blockposition)) { - this.hurt(DamageSource.ON_FIRE, 1.0F); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch index 6236a5d5b3..74cd7a99a4 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityTurtle.java +++ b/net/minecraft/world/entity/animal/EntityTurtle.java -@@ -311,7 +311,9 @@ +@@ -309,7 +309,9 @@ protected void ageBoundaryReached() { super.ageBoundaryReached(); if (!this.isBaby() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { @@ -10,7 +10,7 @@ } } -@@ -338,7 +340,9 @@ +@@ -336,7 +338,9 @@ @Override public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { @@ -20,7 +20,7 @@ } private static class e extends ControllerMove { -@@ -484,8 +488,12 @@ +@@ -482,8 +486,12 @@ } else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) { World world = this.turtle.level; diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch index 8f9fd38688..5cc569db50 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/animal/EntityWolf.java +++ b/net/minecraft/world/entity/animal/EntityWolf.java -@@ -68,6 +68,11 @@ - import net.minecraft.world.level.gameevent.GameEvent; +@@ -69,6 +69,11 @@ + import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start @@ -12,7 +12,7 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable { private static final DataWatcherObject DATA_INTERESTED_ID = DataWatcher.defineId(EntityWolf.class, DataWatcherRegistry.BOOLEAN); -@@ -122,6 +127,24 @@ +@@ -126,6 +131,24 @@ return EntityInsentient.createMobAttributes().add(GenericAttributes.MOVEMENT_SPEED, 0.30000001192092896D).add(GenericAttributes.MAX_HEALTH, 8.0D).add(GenericAttributes.ATTACK_DAMAGE, 2.0D); } @@ -37,16 +37,16 @@ @Override protected void defineSynchedData() { super.defineSynchedData(); -@@ -293,7 +316,7 @@ - } else { +@@ -298,7 +321,7 @@ Entity entity = damagesource.getEntity(); -- this.setOrderedToSit(false); -+ // this.setWillSit(false); // CraftBukkit - moved into EntityLiving.damageEntity(DamageSource, float) - if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) { - f = (f + 1.0F) / 2.0F; + if (!this.level.isClientSide) { +- this.setOrderedToSit(false); ++ // this.setOrderedToSit(false); // CraftBukkit - moved into EntityLiving.damageEntity(DamageSource, float) } -@@ -318,7 +341,7 @@ + + if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) { +@@ -325,7 +348,7 @@ super.setTame(flag); if (flag) { this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(20.0D); @@ -55,7 +55,7 @@ } else { this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(8.0D); } -@@ -342,7 +365,7 @@ +@@ -349,7 +372,7 @@ itemstack.shrink(1); } @@ -64,7 +64,7 @@ this.gameEvent(GameEvent.MOB_INTERACT, this.eyeBlockPosition()); return EnumInteractionResult.SUCCESS; } -@@ -354,7 +377,7 @@ +@@ -361,7 +384,7 @@ this.setOrderedToSit(!this.isOrderedToSit()); this.jumping = false; this.navigation.stop(); @@ -73,7 +73,7 @@ return EnumInteractionResult.SUCCESS; } -@@ -376,7 +399,8 @@ +@@ -383,7 +406,8 @@ itemstack.shrink(1); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch index c771a77a79..208d337b99 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java +++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java -@@ -67,9 +67,16 @@ +@@ -68,10 +68,17 @@ public class Axolotl extends EntityAnimal implements LerpingModel, Bucketable { @@ -10,6 +10,7 @@ + return AXOLOTL_TOTAL_AIR_SUPPLY; + } + // CraftBukkit end + private static final Logger LOGGER = LogUtils.getLogger(); public static final int TOTAL_PLAYDEAD_TIME = 200; protected static final ImmutableList>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_ADULT, SensorType.HURT_BY, SensorType.AXOLOTL_ATTACKABLES, SensorType.AXOLOTL_TEMPTATIONS); - protected static final ImmutableList> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.BREED_TARGET, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT, new MemoryModuleType[]{MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.PLAY_DEAD_TICKS, MemoryModuleType.NEAREST_ATTACKABLE, MemoryModuleType.TEMPTING_PLAYER, MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, MemoryModuleType.IS_TEMPTED, MemoryModuleType.HAS_HUNTING_COOLDOWN}); @@ -18,7 +19,7 @@ private static final DataWatcherObject DATA_VARIANT = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.INT); private static final DataWatcherObject DATA_PLAYING_DEAD = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN); private static final DataWatcherObject FROM_BUCKET = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN); -@@ -185,7 +192,7 @@ +@@ -187,7 +194,7 @@ @Override public int getMaxAirSupply() { @@ -27,7 +28,7 @@ } public Axolotl.Variant getVariant() { -@@ -236,6 +243,7 @@ +@@ -238,6 +245,7 @@ @Override public void setFromBucket(boolean flag) { this.entityData.set(Axolotl.FROM_BUCKET, flag); @@ -35,7 +36,7 @@ } @Nullable -@@ -419,7 +427,7 @@ +@@ -428,7 +436,7 @@ if (i < 2400) { i = Math.min(2400, 100 + i); @@ -44,7 +45,7 @@ } entityhuman.removeEffect(MobEffects.DIG_SLOWDOWN); -@@ -469,7 +477,7 @@ +@@ -478,7 +486,7 @@ @Override public BehaviorController getBrain() { @@ -53,7 +54,7 @@ } @Override -@@ -502,7 +510,7 @@ +@@ -511,7 +519,7 @@ @Override public boolean removeWhenFarAway(double d0) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch index 04a078760c..b511eafdf9 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/animal/goat/Goat.java +++ b/net/minecraft/world/entity/animal/goat/Goat.java -@@ -52,6 +52,11 @@ - import net.minecraft.world.level.pathfinder.Pathfinder; - import net.minecraft.world.level.pathfinder.PathfinderNormal; +@@ -45,6 +45,11 @@ + import net.minecraft.world.level.block.state.IBlockData; + import net.minecraft.world.level.pathfinder.PathType; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -12,7 +12,7 @@ public class Goat extends EntityAnimal { public static final EntitySize LONG_JUMPING_DIMENSIONS = EntitySize.scalable(0.9F, 1.3F).scale(0.7F); -@@ -139,7 +144,7 @@ +@@ -134,7 +139,7 @@ @Override public BehaviorController getBrain() { @@ -21,7 +21,7 @@ } @Override -@@ -177,8 +182,15 @@ +@@ -172,8 +177,15 @@ ItemStack itemstack = entityhuman.getItemInHand(enumhand); if (itemstack.is(Items.BUCKET) && !this.isBaby()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlama.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlama.patch index 32d0e444c5..2d68a6dddd 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlama.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlama.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/EntityLlama.java +++ b/net/minecraft/world/entity/animal/horse/EntityLlama.java -@@ -78,6 +78,12 @@ +@@ -77,6 +77,12 @@ return false; } 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 0a1ac9005a..31f9613796 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java +++ b/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java -@@ -53,6 +53,18 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -51,6 +51,18 @@ + import net.minecraft.world.phys.Vec3D; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.world.item.ItemStack; @@ -18,8 +18,8 @@ + public class EntityEnderDragon extends EntityInsentient implements IMonster { - private static final Logger LOGGER = LogManager.getLogger(); -@@ -89,6 +101,7 @@ + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -87,6 +99,7 @@ private final PathPoint[] nodes = new PathPoint[24]; private final int[] nodeAdjacency = new int[24]; private final Path openSet = new Path(); @@ -27,7 +27,7 @@ public EntityEnderDragon(EntityTypes entitytypes, World world) { super(EntityTypes.ENDER_DRAGON, world); -@@ -236,7 +249,7 @@ +@@ -234,7 +247,7 @@ Vec3D vec3d1 = idragoncontroller.getFlyTargetLocation(); @@ -36,7 +36,7 @@ d0 = vec3d1.x - this.getX(); d1 = vec3d1.y - this.getY(); d2 = vec3d1.z - this.getZ(); -@@ -378,7 +391,14 @@ +@@ -375,7 +388,14 @@ if (this.nearestCrystal.isRemoved()) { this.nearestCrystal = null; } else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) { @@ -52,7 +52,7 @@ } } -@@ -453,6 +473,9 @@ +@@ -450,6 +470,9 @@ int j1 = MathHelper.floor(axisalignedbb.maxZ); boolean flag = false; boolean flag1 = false; @@ -62,10 +62,10 @@ for (int k1 = i; k1 <= l; ++k1) { for (int l1 = j; l1 <= i1; ++l1) { -@@ -462,7 +485,11 @@ +@@ -459,7 +482,11 @@ if (!iblockdata.isAir() && iblockdata.getMaterial() != Material.FIRE) { - if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.is((Tag) TagsBlock.DRAGON_IMMUNE)) { + if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.is(TagsBlock.DRAGON_IMMUNE)) { - flag1 = this.level.removeBlock(blockposition, false) || flag1; + // CraftBukkit start - Add blocks to list rather than destroying them + // flag1 = this.level.removeBlock(blockposition, false) || flag1; @@ -75,7 +75,7 @@ } else { flag = true; } -@@ -471,6 +498,51 @@ +@@ -468,6 +495,51 @@ } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.patch b/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.patch index c466412d1e..7a0a3e5575 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.java @@ -5,6 +5,11 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon; + import org.slf4j.Logger; +// CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftEnderDragon; @@ -11,7 +11,7 @@ + public class DragonControllerManager { - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); @@ -24,6 +29,19 @@ this.currentPhase.end(); } 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 7a6bd39f2d..69cacfdd2a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/wither/EntityWither.java +++ b/net/minecraft/world/entity/boss/wither/EntityWither.java -@@ -56,6 +56,17 @@ +@@ -55,6 +55,17 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.Vec3D; @@ -18,7 +18,7 @@ public class EntityWither extends EntityMonster implements PowerableMob, IRangedEntity { private static final DataWatcherObject DATA_TARGET_A = DataWatcher.defineId(EntityWither.class, DataWatcherRegistry.INT); -@@ -250,16 +261,40 @@ +@@ -249,16 +260,40 @@ this.bossEvent.setProgress(1.0F - (float) i / 220.0F); if (i <= 0) { Explosion.Effect explosion_effect = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE; @@ -62,7 +62,7 @@ } } else { -@@ -304,6 +339,7 @@ +@@ -303,6 +338,7 @@ if (!list.isEmpty()) { EntityLiving entityliving1 = (EntityLiving) list.get(this.random.nextInt(list.size())); @@ -70,7 +70,7 @@ this.setAlternativeTarget(i, entityliving1.getId()); } } -@@ -334,6 +370,11 @@ +@@ -333,6 +369,11 @@ IBlockData iblockdata = this.level.getBlockState(blockposition); if (canDestroy(iblockdata)) { @@ -82,7 +82,7 @@ flag = this.level.destroyBlock(blockposition, true, this) || flag; } } -@@ -347,7 +388,7 @@ +@@ -346,7 +387,7 @@ } if (this.tickCount % 20 == 0) { 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 04dcf8b90f..968b28c93c 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/EntityLeash.java +++ b/net/minecraft/world/entity/decoration/EntityLeash.java -@@ -25,6 +25,12 @@ +@@ -24,6 +24,12 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -13,7 +13,7 @@ public class EntityLeash extends EntityHanging { public static final double OFFSET_Y = 0.375D; -@@ -96,22 +102,42 @@ +@@ -95,22 +101,42 @@ while (iterator.hasNext()) { entityinsentient = (EntityInsentient) iterator.next(); if (entityinsentient.getLeashHolder() == entityhuman) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch index 32668b61fa..e9b1c775c3 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch @@ -1,24 +1,15 @@ --- a/net/minecraft/world/entity/item/EntityFallingBlock.java +++ b/net/minecraft/world/entity/item/EntityFallingBlock.java -@@ -45,6 +45,8 @@ - import net.minecraft.world.phys.MovingObjectPositionBlock; +@@ -46,6 +46,8 @@ import net.minecraft.world.phys.Vec3D; + import org.slf4j.Logger; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + public class EntityFallingBlock extends Entity { - private static final int REMOVAL_DELAY_MILLIS = 50; -@@ -122,7 +124,7 @@ - - if (this.time++ == 0) { - blockposition = this.blockPosition(); -- if (this.level.getBlockState(blockposition).is(block)) { -+ if (this.level.getBlockState(blockposition).is(block) && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { - this.level.removeBlock(blockposition, false); - } else if (!this.level.isClientSide) { - this.discard(); -@@ -173,6 +175,12 @@ + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -166,6 +168,12 @@ this.blockState = (IBlockData) this.blockState.setValue(BlockProperties.WATERLOGGED, true); } @@ -31,7 +22,7 @@ if (this.level.setBlock(blockposition, this.blockState, 3)) { ((WorldServer) this.level).getChunkSource().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition))); this.discard(); -@@ -252,7 +260,7 @@ +@@ -236,7 +244,7 @@ if (i < 0) { return false; } else { @@ -40,7 +31,7 @@ DamageSource damagesource1; if (this.blockState.getBlock() instanceof Fallable) { -@@ -268,7 +276,9 @@ +@@ -252,7 +260,9 @@ float f2 = (float) Math.min(MathHelper.floor((float) i * this.fallDamagePerDistance), this.fallDamageMax); this.level.getEntities((Entity) this, this.getBoundingBox(), predicate).forEach((entity) -> { @@ -48,5 +39,5 @@ entity.hurt(damagesource1, f2); + CraftEventFactory.entityDamage = null; // CraftBukkit }); - boolean flag = this.blockState.is((Tag) TagsBlock.ANVIL); + boolean flag = this.blockState.is(TagsBlock.ANVIL); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityItem.patch b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityItem.patch index 467f9150fe..84310af5d6 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityItem.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityItem.patch @@ -75,9 +75,9 @@ merge(entityitem, itemstack, itemstack1); entityitem.pickupDelay = Math.max(entityitem.pickupDelay, entityitem1.pickupDelay); entityitem.age = Math.min(entityitem.age, entityitem1.age); -@@ -263,6 +282,11 @@ - } else if (!this.getItem().getItem().canBeHurtBy(damagesource)) { - return false; +@@ -265,6 +284,11 @@ + } else if (this.level.isClientSide) { + return true; } else { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { @@ -87,7 +87,7 @@ this.markHurt(); this.health = (int) ((float) this.health - f); this.gameEvent(GameEvent.ENTITY_DAMAGED, damagesource.getEntity()); -@@ -326,6 +350,46 @@ +@@ -328,6 +352,46 @@ Item item = itemstack.getItem(); int i = itemstack.getCount(); @@ -134,7 +134,7 @@ if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(entityhuman.getUUID())) && entityhuman.getInventory().add(itemstack)) { entityhuman.take(this, i); if (itemstack.isEmpty()) { -@@ -369,7 +433,9 @@ +@@ -371,7 +435,9 @@ } public void setItem(ItemStack itemstack) { 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 c7a351df53..aa5acd48f8 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 -@@ -110,7 +110,17 @@ +@@ -109,7 +109,17 @@ @Override public void setTarget(@Nullable EntityLiving entityliving) { @@ -19,7 +19,7 @@ AttributeModifiable attributemodifiable = this.getAttribute(GenericAttributes.MOVEMENT_SPEED); if (entityliving == null) { -@@ -125,6 +135,7 @@ +@@ -124,6 +134,7 @@ attributemodifiable.addTransientModifier(EntityEnderman.SPEED_MODIFIER_ATTACKING); } } @@ -27,7 +27,7 @@ } -@@ -471,9 +482,13 @@ +@@ -470,9 +481,13 @@ if (iblockdata2 != null) { iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level, blockposition); if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) { @@ -41,10 +41,10 @@ } } -@@ -512,9 +527,13 @@ +@@ -511,9 +526,13 @@ boolean flag = movingobjectpositionblock.getBlockPos().equals(blockposition); - if (iblockdata.is((Tag) TagsBlock.ENDERMAN_HOLDABLE) && flag) { + if (iblockdata.is(TagsBlock.ENDERMAN_HOLDABLE) && flag) { - world.removeBlock(blockposition, false); - world.gameEvent(this.enderman, GameEvent.BLOCK_DESTROY, blockposition); - this.enderman.setCarriedBlock(iblockdata.getBlock().defaultBlockState()); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch index a67b811a1e..91283f89ab 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntitySilverfish.java +++ b/net/minecraft/world/entity/monster/EntitySilverfish.java -@@ -173,6 +173,11 @@ +@@ -175,6 +175,11 @@ Block block = iblockdata.getBlock(); if (block instanceof BlockMonsterEggs) { @@ -12,7 +12,7 @@ if (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { world.destroyBlock(blockposition1, true, this.silverfish); } else { -@@ -242,6 +247,11 @@ +@@ -244,6 +249,11 @@ IBlockData iblockdata = world.getBlockState(blockposition); if (BlockMonsterEggs.isCompatibleHostBlock(iblockdata)) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch index 9aff825e0e..009aac5230 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntitySlime.java +++ b/net/minecraft/world/entity/monster/EntitySlime.java -@@ -45,6 +45,14 @@ +@@ -43,6 +43,14 @@ import net.minecraft.world.level.storage.loot.LootTables; import net.minecraft.world.phys.Vec3D; @@ -15,7 +15,7 @@ public class EntitySlime extends EntityInsentient implements IMonster { private static final DataWatcherObject ID_SIZE = DataWatcher.defineId(EntitySlime.class, DataWatcherRegistry.INT); -@@ -186,7 +194,7 @@ +@@ -184,7 +192,7 @@ @Override public EntityTypes getType() { @@ -24,7 +24,7 @@ } @Override -@@ -200,6 +208,19 @@ +@@ -198,6 +206,19 @@ int j = i / 2; int k = 2 + this.random.nextInt(3); @@ -44,7 +44,7 @@ for (int l = 0; l < k; ++l) { float f1 = ((float) (l % 2) - 0.5F) * f; float f2 = ((float) (l / 2) - 0.5F) * f; -@@ -214,8 +235,18 @@ +@@ -212,8 +233,18 @@ entityslime.setInvulnerable(this.isInvulnerable()); entityslime.setSize(j, true); entityslime.moveTo(this.getX() + (double) f1, this.getY() + 0.5D, this.getZ() + (double) f2, this.random.nextFloat() * 360.0F, 0.0F); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch index 040f9af7d5..6895dcd320 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/monster/EntityStrider.java +++ b/net/minecraft/world/entity/monster/EntityStrider.java -@@ -321,7 +321,13 @@ +@@ -320,7 +320,13 @@ IBlockData iblockdata1 = this.getBlockStateOn(); - boolean flag = iblockdata.is((Tag) TagsBlock.STRIDER_WARM_BLOCKS) || iblockdata1.is((Tag) TagsBlock.STRIDER_WARM_BLOCKS) || this.getFluidHeight(TagsFluid.LAVA) > 0.0D; + boolean flag = iblockdata.is(TagsBlock.STRIDER_WARM_BLOCKS) || iblockdata1.is(TagsBlock.STRIDER_WARM_BLOCKS) || this.getFluidHeight(TagsFluid.LAVA) > 0.0D; - this.setSuffocating(!flag); + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch index 16481f2369..2c6f533b92 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/monster/EntityZombieVillager.java +++ b/net/minecraft/world/entity/monster/EntityZombieVillager.java -@@ -47,6 +47,13 @@ +@@ -48,6 +48,13 @@ import net.minecraft.world.level.gameevent.GameEvent; - import org.apache.logging.log4j.Logger; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.server.MinecraftServer; @@ -13,8 +13,8 @@ + public class EntityZombieVillager extends EntityZombie implements VillagerDataHolder { - public static final DataWatcherObject DATA_CONVERTING_ID = DataWatcher.defineId(EntityZombieVillager.class, DataWatcherRegistry.BOOLEAN); -@@ -63,6 +70,7 @@ + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -65,6 +72,7 @@ @Nullable private NBTTagCompound tradeOffers; private int villagerXp; @@ -22,7 +22,7 @@ public EntityZombieVillager(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -79,7 +87,7 @@ +@@ -83,7 +91,7 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(nbttagcompound); @@ -31,7 +31,7 @@ Logger logger = EntityZombieVillager.LOGGER; Objects.requireNonNull(logger); -@@ -135,6 +143,10 @@ +@@ -139,6 +147,10 @@ public void tick() { if (!this.level.isClientSide && this.isAlive() && this.isConverting()) { int i = this.getConversionProgress(); @@ -42,7 +42,7 @@ this.villagerConversionTime -= i; if (this.villagerConversionTime <= 0) { -@@ -143,6 +155,7 @@ +@@ -147,6 +159,7 @@ } super.tick(); @@ -50,7 +50,7 @@ } @Override -@@ -187,8 +200,11 @@ +@@ -191,8 +204,11 @@ this.conversionStarter = uuid; this.villagerConversionTime = i; this.getEntityData().set(EntityZombieVillager.DATA_CONVERTING_ID, true); @@ -64,7 +64,7 @@ this.level.broadcastEntityEvent(this, (byte) 16); } -@@ -205,7 +221,13 @@ +@@ -209,7 +225,13 @@ } private void finishConversion(WorldServer worldserver) { @@ -79,7 +79,7 @@ EnumItemSlot[] aenumitemslot = EnumItemSlot.values(); int i = aenumitemslot.length; -@@ -220,7 +242,9 @@ +@@ -224,7 +246,9 @@ double d0 = (double) this.getEquipmentDropChance(enumitemslot); if (d0 > 1.0D) { @@ -89,7 +89,7 @@ } } } -@@ -246,7 +270,7 @@ +@@ -250,7 +274,7 @@ } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch index e668bee77d..9c7df06cd2 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/PiglinAI.java +++ b/net/minecraft/world/entity/monster/piglin/PiglinAI.java -@@ -72,6 +72,13 @@ +@@ -71,6 +71,13 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParameters; import net.minecraft.world.phys.Vec3D; @@ -14,7 +14,7 @@ public class PiglinAI { public static final int REPELLENT_DETECTION_RANGE_HORIZONTAL = 8; -@@ -187,13 +194,13 @@ +@@ -186,13 +193,13 @@ protected static void updateActivity(EntityPiglin entitypiglin) { BehaviorController behaviorcontroller = entitypiglin.getBrain(); @@ -31,7 +31,7 @@ Objects.requireNonNull(entitypiglin); optional.ifPresent(entitypiglin::playSound); -@@ -225,23 +232,27 @@ +@@ -224,23 +231,27 @@ stopWalking(entitypiglin); ItemStack itemstack; @@ -63,7 +63,7 @@ if (!flag) { putInInventory(entitypiglin, itemstack); -@@ -277,9 +288,14 @@ +@@ -276,9 +287,14 @@ boolean flag1; if (entitypiglin.isAdult()) { @@ -80,7 +80,7 @@ } else if (!flag1) { boolean flag2 = entitypiglin.equipItemIfPossible(itemstack); -@@ -292,7 +308,7 @@ +@@ -291,7 +307,7 @@ if (!flag1) { ItemStack itemstack1 = entitypiglin.getMainHandItem(); @@ -89,7 +89,7 @@ putInInventory(entitypiglin, itemstack1); } else { throwItems(entitypiglin, Collections.singletonList(itemstack1)); -@@ -369,7 +385,7 @@ +@@ -368,7 +384,7 @@ return false; } else if (isAdmiringDisabled(entitypiglin) && entitypiglin.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET)) { return false; @@ -98,7 +98,7 @@ return isNotHoldingLovedItemInOffHand(entitypiglin); } else { boolean flag = entitypiglin.canAddToInventory(itemstack); -@@ -378,6 +394,12 @@ +@@ -377,6 +393,12 @@ } } @@ -109,9 +109,9 @@ + // CraftBukkit end + protected static boolean isLovedItem(ItemStack itemstack) { - return itemstack.is((Tag) TagsItem.PIGLIN_LOVED); + return itemstack.is(TagsItem.PIGLIN_LOVED); } -@@ -473,7 +495,7 @@ +@@ -472,7 +494,7 @@ } protected static boolean canAdmire(EntityPiglin entitypiglin, ItemStack itemstack) { @@ -120,7 +120,7 @@ } protected static void wasHurtBy(EntityPiglin entitypiglin, EntityLiving entityliving) { -@@ -740,6 +762,12 @@ +@@ -739,6 +761,12 @@ return entitypiglin.getBrain().hasMemoryValue(MemoryModuleType.ADMIRING_ITEM); } @@ -133,7 +133,7 @@ private static boolean isBarterCurrency(ItemStack itemstack) { return itemstack.is(PiglinAI.BARTERING_ITEM); } -@@ -777,7 +805,7 @@ +@@ -776,7 +804,7 @@ } private static boolean isNotHoldingLovedItemInOffHand(EntityPiglin entitypiglin) { 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 b03bf83940..21c209fdeb 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/npc/EntityVillager.java +++ b/net/minecraft/world/entity/npc/EntityVillager.java -@@ -89,6 +89,14 @@ +@@ -90,6 +90,14 @@ import net.minecraft.world.phys.AxisAlignedBB; - import org.apache.logging.log4j.Logger; + import org.slf4j.Logger; +// CraftBukkit start +import org.bukkit.Bukkit; @@ -14,8 +14,8 @@ + public class EntityVillager extends EntityVillagerAbstract implements ReputationHandler, VillagerDataHolder { - private static final DataWatcherObject DATA_VILLAGER_DATA = DataWatcher.defineId(EntityVillager.class, DataWatcherRegistry.VILLAGER_DATA); -@@ -146,7 +154,7 @@ + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -148,7 +156,7 @@ @Override public BehaviorController getBrain() { @@ -24,7 +24,7 @@ } @Override -@@ -229,7 +237,7 @@ +@@ -231,7 +239,7 @@ this.increaseProfessionLevelOnUpdate = false; } @@ -33,7 +33,7 @@ } } -@@ -357,7 +365,13 @@ +@@ -359,7 +367,13 @@ while (iterator.hasNext()) { MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next(); @@ -48,7 +48,7 @@ } this.lastRestockGameTime = this.level.getGameTime(); -@@ -415,7 +429,13 @@ +@@ -417,7 +431,13 @@ while (iterator.hasNext()) { MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next(); @@ -63,7 +63,7 @@ } } -@@ -474,7 +494,7 @@ +@@ -476,7 +496,7 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(nbttagcompound); @@ -72,7 +72,7 @@ Logger logger = EntityVillager.LOGGER; Objects.requireNonNull(logger); -@@ -816,7 +836,12 @@ +@@ -818,7 +838,12 @@ } entitywitch.setPersistenceRequired(); @@ -86,7 +86,7 @@ this.releaseAllPois(); this.discard(); } else { -@@ -837,6 +862,13 @@ +@@ -839,6 +864,13 @@ return; } @@ -100,7 +100,7 @@ this.onItemPickup(entityitem); this.take(entityitem, itemstack.getCount()); ItemStack itemstack1 = inventorysubcontainer.addItem(itemstack); -@@ -949,7 +981,7 @@ +@@ -951,7 +983,7 @@ if (entityirongolem != null) { if (entityirongolem.checkSpawnRules(worldserver, EnumMobSpawn.MOB_SUMMONED) && entityirongolem.checkSpawnObstruction(worldserver)) { @@ -109,7 +109,7 @@ return entityirongolem; } -@@ -1027,7 +1059,7 @@ +@@ -1029,7 +1061,7 @@ @Override public void startSleeping(BlockPosition blockposition) { super.startSleeping(blockposition); @@ -118,7 +118,7 @@ this.brain.eraseMemory(MemoryModuleType.WALK_TARGET); this.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); } -@@ -1035,7 +1067,7 @@ +@@ -1037,7 +1069,7 @@ @Override public void stopSleeping() { super.stopSleeping(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch b/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch index 7f24796b1e..a3be4da981 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/EntityVillagerTrader.java +++ b/net/minecraft/world/entity/npc/EntityVillagerTrader.java -@@ -45,6 +45,13 @@ +@@ -44,6 +44,13 @@ import net.minecraft.world.level.World; import net.minecraft.world.phys.Vec3D; @@ -14,7 +14,7 @@ public class EntityVillagerTrader extends EntityVillagerAbstract { private static final int NUMBER_OF_TRADE_OFFERS = 5; -@@ -54,6 +61,7 @@ +@@ -53,6 +60,7 @@ public EntityVillagerTrader(EntityTypes entitytypes, World world) { super(entitytypes, world); @@ -22,7 +22,7 @@ } @Override -@@ -131,7 +139,16 @@ +@@ -130,7 +138,16 @@ MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.getOffer(this, this.random); if (merchantrecipe != null) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch b/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch index a4a06a246a..ec93e1c930 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/EntityHuman.java +++ b/net/minecraft/world/entity/player/EntityHuman.java -@@ -111,6 +111,19 @@ +@@ -112,6 +112,19 @@ import net.minecraft.world.scores.ScoreboardTeam; import net.minecraft.world.scores.ScoreboardTeamBase; @@ -20,7 +20,7 @@ public abstract class EntityHuman extends EntityLiving { public static final String UUID_PREFIX_OFFLINE_PLAYER = "OfflinePlayer:"; -@@ -124,7 +137,8 @@ +@@ -125,7 +138,8 @@ public static final float SWIMMING_BB_HEIGHT = 0.6F; public static final float DEFAULT_EYE_HEIGHT = 1.62F; public static final EntitySize STANDING_DIMENSIONS = EntitySize.scalable(0.6F, 1.8F); @@ -30,7 +30,7 @@ private static final int FLY_ACHIEVEMENT_SPEED = 25; private static final DataWatcherObject DATA_PLAYER_ABSORPTION_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.FLOAT); private static final DataWatcherObject DATA_SCORE_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.INT); -@@ -134,10 +148,10 @@ +@@ -135,10 +149,10 @@ protected static final DataWatcherObject DATA_SHOULDER_RIGHT = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.COMPOUND_TAG); private long timeEntitySatOnShoulder; private final PlayerInventory inventory = new PlayerInventory(this); @@ -43,7 +43,7 @@ protected int jumpTriggerTime; public float oBob; public float bob; -@@ -164,6 +178,16 @@ +@@ -165,6 +179,16 @@ @Nullable public EntityFishingHook fishing; @@ -60,7 +60,7 @@ public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile) { super(EntityTypes.PLAYER, world); this.lastItemInMainHand = ItemStack.EMPTY; -@@ -302,7 +326,7 @@ +@@ -303,7 +327,7 @@ ItemStack itemstack = this.getItemBySlot(EnumItemSlot.HEAD); if (itemstack.is(Items.TURTLE_HELMET) && !this.isEyeInFluid(TagsFluid.WATER)) { @@ -69,7 +69,7 @@ } } -@@ -494,7 +518,8 @@ +@@ -495,7 +519,8 @@ if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL && this.level.getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { if (this.getHealth() < this.getMaxHealth() && this.tickCount % 20 == 0) { @@ -79,7 +79,7 @@ } if (this.foodData.needsFood() && this.tickCount % 10 == 0) { -@@ -682,6 +707,30 @@ +@@ -692,6 +717,30 @@ entityitem.setDeltaMovement((double) (-f3 * f2 * 0.3F) + Math.cos((double) f5) * (double) f6, (double) (-f1 * 0.3F + 0.1F + (this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (f4 * f2 * 0.3F) + Math.sin((double) f5) * (double) f6); } @@ -110,12 +110,14 @@ return entityitem; } } -@@ -814,10 +863,10 @@ - if (this.isDeadOrDying()) { +@@ -825,12 +874,12 @@ return false; } else { -- this.removeEntitiesOnShoulder(); -+ // this.releaseShoulderEntities(); // CraftBukkit - moved down + if (!this.level.isClientSide) { +- this.removeEntitiesOnShoulder(); ++ // this.removeEntitiesOnShoulder(); // CraftBukkit - moved down + } + if (damagesource.scalesWithDifficulty()) { if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL) { - f = 0.0F; @@ -123,7 +125,7 @@ } if (this.level.getDifficulty() == EnumDifficulty.EASY) { -@@ -829,7 +878,13 @@ +@@ -842,7 +891,13 @@ } } @@ -138,7 +140,7 @@ } } } -@@ -849,10 +904,29 @@ +@@ -862,10 +917,29 @@ } public boolean canHarmPlayer(EntityHuman entityhuman) { @@ -171,7 +173,7 @@ } @Override -@@ -894,8 +968,13 @@ +@@ -907,8 +981,13 @@ } } @@ -186,7 +188,7 @@ if (!this.isInvulnerableTo(damagesource)) { f = this.getDamageAfterArmorAbsorb(damagesource, f); f = this.getDamageAfterMagicAbsorb(damagesource, f); -@@ -910,7 +989,7 @@ +@@ -923,7 +1002,7 @@ } if (f != 0.0F) { @@ -195,7 +197,7 @@ float f3 = this.getHealth(); this.setHealth(this.getHealth() - f); -@@ -921,6 +1000,7 @@ +@@ -934,6 +1013,7 @@ } } @@ -203,7 +205,7 @@ } @Override -@@ -1080,7 +1160,7 @@ +@@ -1093,7 +1173,7 @@ f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; @@ -212,7 +214,7 @@ if (f > 0.0F || f1 > 0.0F) { boolean flag = f2 > 0.9F; boolean flag1 = false; -@@ -1119,8 +1199,15 @@ +@@ -1132,8 +1212,15 @@ if (entity instanceof EntityLiving) { f3 = ((EntityLiving) entity).getHealth(); if (j > 0 && !entity.isOnFire()) { @@ -230,7 +232,7 @@ } } -@@ -1148,8 +1235,11 @@ +@@ -1161,8 +1248,11 @@ EntityLiving entityliving = (EntityLiving) iterator.next(); if (entityliving != this && entityliving != entity && !this.isAlliedTo((Entity) entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) { @@ -243,7 +245,7 @@ } } -@@ -1158,9 +1248,26 @@ +@@ -1171,9 +1261,26 @@ } if (entity instanceof EntityPlayer && entity.hurtMarked) { @@ -270,7 +272,7 @@ } if (flag2) { -@@ -1205,7 +1312,14 @@ +@@ -1218,7 +1325,14 @@ this.awardStat(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F)); if (j > 0) { @@ -286,7 +288,7 @@ } if (this.level instanceof WorldServer && f5 > 2.0F) { -@@ -1215,12 +1329,17 @@ +@@ -1228,12 +1342,17 @@ } } @@ -305,7 +307,7 @@ } } -@@ -1293,6 +1412,12 @@ +@@ -1306,6 +1425,12 @@ public void updateTutorialInventoryAction(ItemStack itemstack, ItemStack itemstack1, ClickAction clickaction) {} public Either startSleepInBed(BlockPosition blockposition) { @@ -318,7 +320,7 @@ this.startSleeping(blockposition); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1377,9 +1502,9 @@ +@@ -1390,9 +1515,9 @@ super.jumpFromGround(); this.awardStat(StatisticList.JUMP); if (this.isSprinting()) { @@ -330,7 +332,7 @@ } } -@@ -1413,7 +1538,11 @@ +@@ -1426,7 +1551,11 @@ this.setDeltaMovement(vec3d2.x, d3 * 0.6D, vec3d2.z); this.flyingSpeed = f; this.resetFallDistance(); @@ -343,7 +345,7 @@ } else { super.travel(vec3d); } -@@ -1448,19 +1577,19 @@ +@@ -1461,19 +1590,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); @@ -366,7 +368,7 @@ } } else if (this.onClimbable()) { if (d1 > 0.0D) { -@@ -1471,13 +1600,13 @@ +@@ -1484,13 +1613,13 @@ if (i > 0) { if (this.isSprinting()) { this.awardStat(StatisticList.SPRINT_ONE_CM, i); @@ -383,7 +385,7 @@ } } } else if (this.isFallFlying()) { -@@ -1543,12 +1672,24 @@ +@@ -1556,12 +1685,24 @@ } public void startFallFlying() { @@ -409,7 +411,7 @@ } @Override -@@ -1638,10 +1779,21 @@ +@@ -1651,10 +1792,21 @@ return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2); } @@ -432,7 +434,7 @@ } } -@@ -1718,15 +1870,22 @@ +@@ -1731,15 +1883,22 @@ @Override public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { @@ -458,7 +460,7 @@ this.inventory.armor.set(enumitemslot.getIndex(), itemstack); } -@@ -1767,26 +1926,31 @@ +@@ -1780,26 +1939,31 @@ protected void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level.getGameTime()) { 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 03c3772dcd..eedb848ce6 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 @@ -44,15 +44,15 @@ } this.checkInsideBlocks(); -@@ -159,6 +175,11 @@ - Entity entity = damagesource.getEntity(); +@@ -160,6 +176,11 @@ if (entity != null) { -+ // CraftBukkit start -+ if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false)) { -+ return false; -+ } -+ // CraftBukkit end - Vec3D vec3d = entity.getLookAngle(); + if (!this.level.isClientSide) { ++ // CraftBukkit start ++ if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false)) { ++ return false; ++ } ++ // CraftBukkit end + Vec3D vec3d = entity.getLookAngle(); - this.setDeltaMovement(vec3d); + this.setDeltaMovement(vec3d); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch index 94cd2d75ac..cdd7d162a7 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch @@ -9,7 +9,7 @@ public class EntityFireworks extends IProjectile implements ItemSupplier { public static final DataWatcherObject DATA_ID_FIREWORKS_ITEM = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.ITEM_STACK); -@@ -141,7 +143,7 @@ +@@ -144,7 +146,7 @@ MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity); if (!this.noPhysics) { @@ -18,7 +18,7 @@ this.hasImpulse = true; } -@@ -156,7 +158,11 @@ +@@ -159,7 +161,11 @@ } if (!this.level.isClientSide && this.life > this.lifetime) { @@ -31,7 +31,7 @@ } } -@@ -172,7 +178,11 @@ +@@ -175,7 +181,11 @@ protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) { super.onHitEntity(movingobjectpositionentity); if (!this.level.isClientSide) { @@ -44,7 +44,7 @@ } } -@@ -182,7 +192,11 @@ +@@ -185,7 +195,11 @@ this.level.getBlockState(blockposition).entityInside(this.level, blockposition, this); if (!this.level.isClientSide() && this.hasExplosion()) { @@ -57,7 +57,7 @@ } super.onHitBlock(movingobjectpositionblock); -@@ -208,7 +222,9 @@ +@@ -211,7 +225,9 @@ if (f > 0.0F) { if (this.attachedToEntity != null) { @@ -67,7 +67,7 @@ } double d0 = 5.0D; -@@ -235,7 +251,9 @@ +@@ -238,7 +254,9 @@ if (flag) { float f1 = f * (float) Math.sqrt((5.0D - (double) this.distanceTo(entityliving)) / 5.0D); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch index 31c61c199a..3240b2ddf3 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/projectile/EntityFishingHook.java +++ b/net/minecraft/world/entity/projectile/EntityFishingHook.java -@@ -44,6 +44,12 @@ - import net.minecraft.world.phys.MovingObjectPositionEntity; +@@ -45,6 +45,12 @@ import net.minecraft.world.phys.Vec3D; + import org.slf4j.Logger; +// CraftBukkit start +import org.bukkit.entity.Player; @@ -12,8 +12,8 @@ + public class EntityFishingHook extends IProjectile { - private final Random syncronizedRandom; -@@ -64,6 +70,12 @@ + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -66,6 +72,12 @@ private final int luck; private final int lureSpeed; @@ -26,7 +26,7 @@ private EntityFishingHook(EntityTypes entitytypes, World world, int i, int j) { super(entitytypes, world); this.syncronizedRandom = new Random(); -@@ -258,7 +270,7 @@ +@@ -260,7 +272,7 @@ private void checkCollision() { MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity); @@ -35,7 +35,7 @@ } @Override -@@ -305,6 +317,10 @@ +@@ -307,6 +319,10 @@ this.timeUntilLured = 0; this.timeUntilHooked = 0; this.getEntityData().set(EntityFishingHook.DATA_BITING, false); @@ -46,7 +46,7 @@ } } else { float f; -@@ -338,6 +354,13 @@ +@@ -340,6 +356,13 @@ worldserver.sendParticles(Particles.FISHING, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D); } } else { @@ -60,7 +60,7 @@ this.playSound(SoundEffects.FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); double d3 = this.getY() + 0.5D; -@@ -374,8 +397,10 @@ +@@ -376,8 +399,10 @@ this.timeUntilHooked = MathHelper.nextInt(this.random, 20, 80); } } else { @@ -73,7 +73,7 @@ } } -@@ -442,6 +467,14 @@ +@@ -444,6 +469,14 @@ int i = 0; if (this.hookedIn != null) { @@ -88,7 +88,7 @@ this.pullEntity(this.hookedIn); CriterionTriggers.FISHING_ROD_HOOKED.trigger((EntityPlayer) entityhuman, itemstack, this, Collections.emptyList()); this.level.broadcastEntityEvent(this, (byte) 31); -@@ -457,6 +490,15 @@ +@@ -459,6 +492,15 @@ while (iterator.hasNext()) { ItemStack itemstack1 = (ItemStack) iterator.next(); EntityItem entityitem = new EntityItem(this.level, this.getX(), this.getY(), this.getZ(), itemstack1); @@ -104,7 +104,7 @@ double d0 = entityhuman.getX() - this.getX(); double d1 = entityhuman.getY() - this.getY(); double d2 = entityhuman.getZ() - this.getZ(); -@@ -464,7 +506,11 @@ +@@ -466,7 +508,11 @@ entityitem.setDeltaMovement(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D); this.level.addFreshEntity(entityitem); @@ -114,10 +114,10 @@ + entityhuman.level.addFreshEntity(new EntityExperienceOrb(entityhuman.level, entityhuman.getX(), entityhuman.getY() + 0.5D, entityhuman.getZ() + 0.5D, playerFishEvent.getExpToDrop())); + } + // CraftBukkit end - if (itemstack1.is((Tag) TagsItem.FISHES)) { + if (itemstack1.is(TagsItem.FISHES)) { entityhuman.awardStat(StatisticList.FISH_CAUGHT, 1); } -@@ -474,8 +520,25 @@ +@@ -476,8 +522,25 @@ } if (this.onGround) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch index d16d6d4aea..b0228f150b 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityPotion.java +++ b/net/minecraft/world/entity/projectile/EntityPotion.java -@@ -33,6 +33,16 @@ +@@ -32,6 +32,16 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.MovingObjectPositionEntity; @@ -17,7 +17,7 @@ public class EntityPotion extends EntityProjectileThrowable implements ItemSupplier { public static final double SPLASH_RANGE = 4.0D; -@@ -99,7 +109,7 @@ +@@ -98,7 +108,7 @@ if (flag) { this.applyWater(); @@ -26,7 +26,7 @@ if (this.isLingering()) { this.makeAreaOfEffectCloud(itemstack, potionregistry); } else { -@@ -145,6 +155,7 @@ +@@ -144,6 +154,7 @@ private void applySplash(List list, @Nullable Entity entity) { AxisAlignedBB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D); List list1 = this.level.getEntitiesOfClass(EntityLiving.class, axisalignedbb); @@ -34,7 +34,7 @@ if (!list1.isEmpty()) { Entity entity1 = this.getEffectSource(); -@@ -163,21 +174,47 @@ +@@ -162,21 +173,47 @@ d1 = 1.0D; } @@ -96,7 +96,7 @@ } } } -@@ -213,7 +250,14 @@ +@@ -212,7 +249,14 @@ entityareaeffectcloud.setFixedColor(nbttagcompound.getInt("CustomPotionColor")); } @@ -112,10 +112,10 @@ } public boolean isLingering() { -@@ -224,13 +268,25 @@ +@@ -223,13 +267,25 @@ IBlockData iblockdata = this.level.getBlockState(blockposition); - if (iblockdata.is((Tag) TagsBlock.FIRE)) { + if (iblockdata.is(TagsBlock.FIRE)) { - this.level.removeBlock(blockposition, false); + // CraftBukkit start + if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch index fc6bd22f7c..18ef2fdcdc 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityShulkerBullet.java +++ b/net/minecraft/world/entity/projectile/EntityShulkerBullet.java -@@ -60,8 +60,21 @@ +@@ -59,8 +59,21 @@ this.finalTarget = entity; this.currentMoveDirection = EnumDirection.UP; this.selectNextMoveDirection(enumdirection_enumaxis); @@ -22,7 +22,7 @@ @Override public SoundCategory getSoundSource() { return SoundCategory.HOSTILE; -@@ -225,7 +238,7 @@ +@@ -224,7 +237,7 @@ MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity); if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { @@ -31,7 +31,7 @@ } } -@@ -292,7 +305,7 @@ +@@ -291,7 +304,7 @@ if (flag) { this.doEnchantDamageEffects(entityliving, entity); if (entity instanceof EntityLiving) { @@ -40,7 +40,7 @@ } } -@@ -318,6 +331,11 @@ +@@ -317,6 +330,11 @@ @Override public boolean hurt(DamageSource damagesource, float f) { 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 e9e80c602d..c725271cd9 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/EntityRaider.java +++ b/net/minecraft/world/entity/raid/EntityRaider.java -@@ -166,7 +166,7 @@ +@@ -165,7 +165,7 @@ MobEffect mobeffect1 = new MobEffect(MobEffects.BAD_OMEN, 120000, i, false, false, true); if (!this.level.getGameRules().getBoolean(GameRules.RULE_DISABLE_RAIDS)) { @@ -9,7 +9,7 @@ } } } -@@ -306,7 +306,7 @@ +@@ -305,7 +305,7 @@ private final T mob; @@ -18,7 +18,7 @@ this.mob = entityraider; this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE)); } -@@ -522,7 +522,7 @@ +@@ -521,7 +521,7 @@ while (iterator.hasNext()) { EntityRaider entityraider = (EntityRaider) iterator.next(); @@ -27,7 +27,7 @@ } } -@@ -539,7 +539,7 @@ +@@ -538,7 +538,7 @@ while (iterator.hasNext()) { EntityRaider entityraider = (EntityRaider) iterator.next(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/raid/PersistentRaid.patch b/paper-server/nms-patches/net/minecraft/world/entity/raid/PersistentRaid.patch index 0dbcef7602..c14b3a78b1 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/raid/PersistentRaid.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/raid/PersistentRaid.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/PersistentRaid.java +++ b/net/minecraft/world/entity/raid/PersistentRaid.java -@@ -109,19 +109,33 @@ +@@ -110,19 +110,33 @@ boolean flag = false; if (!raid.isStarted()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch index 4240b2d613..a5716b7a30 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/EntityBoat.java +++ b/net/minecraft/world/entity/vehicle/EntityBoat.java -@@ -52,6 +52,15 @@ +@@ -51,6 +51,15 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -16,7 +16,7 @@ public class EntityBoat extends Entity { private static final DataWatcherObject DATA_ID_HURT = DataWatcher.defineId(EntityBoat.class, DataWatcherRegistry.INT); -@@ -92,6 +101,14 @@ +@@ -91,6 +100,14 @@ private float bubbleAngle; private float bubbleAngleO; @@ -31,7 +31,7 @@ public EntityBoat(EntityTypes entitytypes, World world) { super(entitytypes, world); this.paddlePositions = new float[2]; -@@ -161,6 +178,19 @@ +@@ -160,6 +177,19 @@ if (this.isInvulnerableTo(damagesource)) { return false; } else if (!this.level.isClientSide && !this.isRemoved()) { @@ -51,7 +51,7 @@ this.setHurtDir(-this.getHurtDir()); this.setHurtTime(10); this.setDamage(this.getDamage() + f * 10.0F); -@@ -169,6 +199,15 @@ +@@ -168,6 +198,15 @@ boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).getAbilities().instabuild; if (flag || this.getDamage() > 40.0F) { @@ -67,7 +67,7 @@ if (!flag && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { this.spawnAtLocation((IMaterial) this.getDropItem()); } -@@ -204,9 +243,29 @@ +@@ -203,9 +242,29 @@ public void push(Entity entity) { if (entity instanceof EntityBoat) { if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) { @@ -97,7 +97,7 @@ super.push(entity); } -@@ -257,6 +316,7 @@ +@@ -256,6 +315,7 @@ return this.getDirection().getClockWise(); } @@ -105,7 +105,7 @@ @Override public void tick() { this.oldStatus = this.status; -@@ -297,6 +357,22 @@ +@@ -296,6 +356,22 @@ this.setDeltaMovement(Vec3D.ZERO); } @@ -128,7 +128,7 @@ this.tickBubbleColumn(); for (int i = 0; i <= 1; ++i) { -@@ -801,6 +877,11 @@ +@@ -800,6 +876,11 @@ this.causeFallDamage(this.fallDistance, 1.0F, DamageSource.FALL); if (!this.level.isClientSide && !this.isRemoved()) { @@ -140,7 +140,7 @@ this.kill(); if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { int i; -@@ -814,6 +895,7 @@ +@@ -813,6 +894,7 @@ } } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch index e11804f78a..6b8eafc848 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java +++ b/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java -@@ -49,6 +49,15 @@ +@@ -48,6 +48,15 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -16,7 +16,7 @@ public abstract class EntityMinecartAbstract extends Entity { private static final DataWatcherObject DATA_ID_HURT = DataWatcher.defineId(EntityMinecartAbstract.class, DataWatcherRegistry.INT); -@@ -91,6 +100,17 @@ +@@ -90,6 +99,17 @@ private double lyd; private double lzd; @@ -34,7 +34,7 @@ protected EntityMinecartAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); this.blocksBuilding = true; -@@ -217,6 +237,19 @@ +@@ -216,6 +236,19 @@ if (this.isInvulnerableTo(damagesource)) { return false; } else { @@ -54,7 +54,7 @@ this.setHurtDir(-this.getHurtDir()); this.setHurtTime(10); this.markHurt(); -@@ -225,6 +258,15 @@ +@@ -224,6 +257,15 @@ boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).getAbilities().instabuild; if (flag || this.getDamage() > 40.0F) { @@ -70,7 +70,7 @@ this.ejectPassengers(); if (flag && !this.hasCustomName()) { this.discard(); -@@ -284,6 +326,14 @@ +@@ -283,6 +325,14 @@ @Override public void tick() { @@ -85,7 +85,7 @@ if (this.getHurtTime() > 0) { this.setHurtTime(this.getHurtTime() - 1); } -@@ -293,7 +343,7 @@ +@@ -292,7 +342,7 @@ } this.checkOutOfWorld(); @@ -94,7 +94,7 @@ double d0; if (this.level.isClientSide) { -@@ -359,6 +409,18 @@ +@@ -358,6 +408,18 @@ } this.setRot(this.getYRot(), this.getXRot()); @@ -113,7 +113,7 @@ if (this.getMinecartType() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) { List list = this.level.getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), IEntitySelector.pushableBy(this)); -@@ -367,8 +429,26 @@ +@@ -366,8 +428,26 @@ Entity entity = (Entity) list.get(l); if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.isVehicle() && !entity.isPassenger()) { @@ -140,7 +140,7 @@ entity.push(this); } } -@@ -380,6 +460,14 @@ +@@ -379,6 +459,14 @@ Entity entity1 = (Entity) iterator.next(); if (!this.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof EntityMinecartAbstract) { @@ -155,7 +155,7 @@ entity1.push(this); } } -@@ -396,7 +484,7 @@ +@@ -395,7 +483,7 @@ } protected double getMaxSpeed() { @@ -164,7 +164,7 @@ } public void activateMinecart(int i, int j, int k, boolean flag) {} -@@ -407,12 +495,16 @@ +@@ -406,12 +494,16 @@ this.setDeltaMovement(MathHelper.clamp(vec3d.x, -d0, d0), vec3d.y, MathHelper.clamp(vec3d.z, -d0, d0)); if (this.onGround) { @@ -183,7 +183,7 @@ } } -@@ -603,7 +695,7 @@ +@@ -602,7 +694,7 @@ } protected void applyNaturalSlowdown() { @@ -192,7 +192,7 @@ Vec3D vec3d = this.getDeltaMovement(); vec3d = vec3d.multiply(d0, 0.0D, d0); -@@ -742,6 +834,14 @@ +@@ -741,6 +833,14 @@ if (!this.level.isClientSide) { if (!entity.noPhysics && !this.noPhysics) { if (!this.hasPassenger(entity)) { @@ -207,7 +207,7 @@ double d0 = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double d2 = d0 * d0 + d1 * d1; -@@ -921,4 +1021,26 @@ +@@ -920,4 +1020,26 @@ private EnumMinecartType() {} } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/Container.patch b/paper-server/nms-patches/net/minecraft/world/inventory/Container.patch index 6ab716fd38..4aa7e067b0 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/Container.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/Container.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/Container.java +++ b/net/minecraft/world/inventory/Container.java -@@ -30,6 +30,20 @@ - import net.minecraft.world.level.block.Block; +@@ -32,6 +32,20 @@ import net.minecraft.world.level.block.entity.TileEntity; + import org.slf4j.Logger; +// CraftBukkit start +import com.google.common.base.Preconditions; @@ -20,8 +20,8 @@ + public abstract class Container { - public static final int SLOT_CLICKED_OUTSIDE = -999; -@@ -59,6 +73,27 @@ + private static Logger LOGGER = LogUtils.getLogger(); +@@ -62,6 +76,27 @@ private ContainerSynchronizer synchronizer; private boolean suppressRemoteUpdates; @@ -49,7 +49,7 @@ protected Container(@Nullable Containers containers, int i) { this.carried = ItemStack.EMPTY; this.remoteSlots = NonNullList.create(); -@@ -156,6 +191,15 @@ +@@ -163,6 +198,15 @@ } @@ -65,7 +65,7 @@ public void removeSlotListener(ICrafting icrafting) { this.containerListeners.remove(icrafting); } -@@ -370,7 +414,7 @@ +@@ -381,7 +425,7 @@ } } else if (this.quickcraftStatus == 2) { if (!this.quickcraftSlots.isEmpty()) { @@ -74,7 +74,7 @@ k = ((Slot) this.quickcraftSlots.iterator().next()).index; this.resetQuickCraft(); this.doClick(k, this.quickcraftType, InventoryClickType.PICKUP, entityhuman); -@@ -381,6 +425,7 @@ +@@ -392,6 +436,7 @@ l = this.getCarried().getCount(); Iterator iterator = this.quickcraftSlots.iterator(); @@ -82,7 +82,7 @@ while (iterator.hasNext()) { Slot slot1 = (Slot) iterator.next(); ItemStack itemstack2 = this.getCarried(); -@@ -397,12 +442,48 @@ +@@ -408,12 +453,48 @@ } l -= itemstack3.getCount() - j1; @@ -134,7 +134,7 @@ } this.resetQuickCraft(); -@@ -420,8 +501,11 @@ +@@ -431,8 +512,11 @@ if (i == -999) { if (!this.getCarried().isEmpty()) { if (clickaction == ClickAction.PRIMARY) { @@ -147,7 +147,7 @@ } else { entityhuman.drop(this.getCarried().split(1), true); } -@@ -484,6 +568,15 @@ +@@ -495,6 +579,15 @@ } slot.setChanged(); @@ -163,7 +163,7 @@ } } else { Slot slot2; -@@ -591,13 +684,14 @@ +@@ -602,13 +695,14 @@ ItemStack itemstack = this.getCarried(); if (!itemstack.isEmpty()) { @@ -179,7 +179,7 @@ } } -@@ -811,6 +905,11 @@ +@@ -822,6 +916,11 @@ } public ItemStack getCarried() { diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch index a723b845be..78af7889ed 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/ContainerAnvil.java +++ b/net/minecraft/world/inventory/ContainerAnvil.java -@@ -18,12 +18,16 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -17,12 +17,16 @@ + import org.apache.commons.lang3.StringUtils; + import org.slf4j.Logger; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftInventoryView; @@ -10,7 +10,7 @@ + public class ContainerAnvil extends ContainerAnvilAbstract { - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); private static final boolean DEBUG_COST = false; public static final int MAX_NAME_LENGTH = 50; - private int repairItemCountCost; @@ -18,7 +18,7 @@ public String itemName; public final ContainerProperty cost; private static final int COST_FAIL = 0; -@@ -33,6 +37,10 @@ +@@ -32,6 +36,10 @@ private static final int COST_REPAIR_SACRIFICE = 2; private static final int COST_INCOMPATIBLE_PENALTY = 1; private static final int COST_RENAME = 1; @@ -29,7 +29,7 @@ public ContainerAnvil(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); -@@ -105,7 +113,7 @@ +@@ -104,7 +112,7 @@ byte b1 = 0; if (itemstack.isEmpty()) { @@ -38,7 +38,7 @@ this.cost.set(0); } else { ItemStack itemstack1 = itemstack.copy(); -@@ -123,7 +131,7 @@ +@@ -122,7 +130,7 @@ if (itemstack1.isDamageableItem() && itemstack1.getItem().isValidRepairItem(itemstack, itemstack2)) { k = Math.min(itemstack1.getDamageValue(), itemstack1.getMaxDamage() / 4); if (k <= 0) { @@ -47,7 +47,7 @@ this.cost.set(0); return; } -@@ -138,7 +146,7 @@ +@@ -137,7 +145,7 @@ this.repairItemCountCost = i1; } else { if (!flag && (!itemstack1.is(itemstack2.getItem()) || !itemstack1.isDamageableItem())) { @@ -56,7 +56,7 @@ this.cost.set(0); return; } -@@ -228,7 +236,7 @@ +@@ -227,7 +235,7 @@ } if (flag2 && !flag1) { @@ -65,7 +65,7 @@ this.cost.set(0); return; } -@@ -252,11 +260,11 @@ +@@ -251,11 +259,11 @@ itemstack1 = ItemStack.EMPTY; } @@ -80,7 +80,7 @@ itemstack1 = ItemStack.EMPTY; } -@@ -275,7 +283,8 @@ +@@ -274,7 +282,8 @@ EnchantmentManager.setEnchantments(map, itemstack1); } @@ -90,7 +90,7 @@ this.broadcastChanges(); } } -@@ -302,4 +311,18 @@ +@@ -301,4 +310,18 @@ public int getCost() { return this.cost.get(); } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch index a44cfc0692..0cbe6f51ed 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerBeacon.java +++ b/net/minecraft/world/inventory/ContainerBeacon.java -@@ -11,6 +11,11 @@ +@@ -10,6 +10,11 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.block.Blocks; @@ -12,7 +12,7 @@ public class ContainerBeacon extends Container { private static final int PAYMENT_SLOT = 0; -@@ -24,6 +29,10 @@ +@@ -23,6 +28,10 @@ private final ContainerBeacon.SlotBeacon paymentSlot; private final ContainerAccess access; private final IContainerProperties beaconData; @@ -23,7 +23,7 @@ public ContainerBeacon(int i, IInventory iinventory) { this(i, iinventory, new ContainerProperties(3), ContainerAccess.NULL); -@@ -31,6 +40,7 @@ +@@ -30,6 +39,7 @@ public ContainerBeacon(int i, IInventory iinventory, IContainerProperties icontainerproperties, ContainerAccess containeraccess) { super(Containers.BEACON, i); @@ -31,7 +31,7 @@ this.beacon = new InventorySubcontainer(1) { @Override public boolean canPlaceItem(int j, ItemStack itemstack) { -@@ -80,6 +90,7 @@ +@@ -79,6 +89,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { @@ -39,7 +39,7 @@ return stillValid(this.access, entityhuman, Blocks.BEACON); } -@@ -180,4 +191,17 @@ +@@ -179,4 +190,17 @@ return 1; } } 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 36c5c4cc3a..41f4198411 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/inventory/ContainerEnchantTable.java +++ b/net/minecraft/world/inventory/ContainerEnchantTable.java -@@ -20,6 +20,21 @@ - import net.minecraft.world.item.enchantment.WeightedRandomEnchant; +@@ -25,6 +25,21 @@ + import net.minecraft.world.level.block.BlockEnchantmentTable; import net.minecraft.world.level.block.Blocks; +// CraftBukkit start @@ -22,7 +22,7 @@ public class ContainerEnchantTable extends Container { private final IInventory enchantSlots; -@@ -29,6 +44,10 @@ +@@ -34,6 +49,10 @@ public final int[] costs; public final int[] enchantClue; public final int[] levelClue; @@ -33,7 +33,7 @@ public ContainerEnchantTable(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); -@@ -42,6 +61,13 @@ +@@ -47,6 +66,13 @@ super.setChanged(); ContainerEnchantTable.this.slotsChanged(this); } @@ -47,7 +47,7 @@ }; this.random = new Random(); this.enchantmentSeed = ContainerProperty.standalone(); -@@ -89,6 +115,9 @@ +@@ -94,6 +120,9 @@ this.addDataSlot(ContainerProperty.shared(this.levelClue, 0)); this.addDataSlot(ContainerProperty.shared(this.levelClue, 1)); this.addDataSlot(ContainerProperty.shared(this.levelClue, 2)); @@ -57,7 +57,7 @@ } @Override -@@ -96,7 +125,7 @@ +@@ -101,7 +130,7 @@ if (iinventory == this.enchantSlots) { ItemStack itemstack = iinventory.getItem(0); @@ -65,8 +65,8 @@ + if (!itemstack.isEmpty()) { // CraftBukkit - relax condition this.access.execute((world, blockposition) -> { int i = 0; - -@@ -158,6 +187,41 @@ + Iterator iterator = BlockEnchantmentTable.BOOKSHELF_OFFSETS.iterator(); +@@ -140,6 +169,41 @@ } } @@ -108,70 +108,71 @@ this.broadcastChanges(); }); } else { -@@ -184,9 +248,24 @@ - ItemStack itemstack2 = itemstack; - List list = this.getEnchantmentList(itemstack, i, this.costs[i]); +@@ -167,9 +231,24 @@ + ItemStack itemstack2 = itemstack; + List list = this.getEnchantmentList(itemstack, i, this.costs[i]); -- if (!list.isEmpty()) { -- entityhuman.onEnchantmentPerformed(itemstack, j); -+ // CraftBukkit start -+ if (true || !list.isEmpty()) { -+ // entityhuman.onEnchantmentPerformed(itemstack, j); // Moved down - boolean flag = itemstack.is(Items.BOOK); -+ Map enchants = new java.util.HashMap(); -+ for (Object obj : list) { -+ WeightedRandomEnchant instance = (WeightedRandomEnchant) obj; -+ enchants.put(org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.ENCHANTMENT.getKey(instance.enchantment))), instance.level); -+ } -+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack2); +- if (!list.isEmpty()) { +- entityhuman.onEnchantmentPerformed(itemstack, j); ++ // CraftBukkit start ++ if (true || !list.isEmpty()) { ++ // entityhuman.onEnchantmentPerformed(itemstack, j); // Moved down + boolean flag = itemstack.is(Items.BOOK); ++ Map enchants = new java.util.HashMap(); ++ for (Object obj : list) { ++ WeightedRandomEnchant instance = (WeightedRandomEnchant) obj; ++ enchants.put(org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.ENCHANTMENT.getKey(instance.enchantment))), instance.level); ++ } ++ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack2); + -+ EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.getBukkitEntity(), this.getBukkitView(), access.getLocation().getBlock(), item, this.costs[i], enchants, i); -+ world.getCraftServer().getPluginManager().callEvent(event); ++ EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.getBukkitEntity(), this.getBukkitView(), access.getLocation().getBlock(), item, this.costs[i], enchants, i); ++ world.getCraftServer().getPluginManager().callEvent(event); + -+ int level = event.getExpLevelCost(); -+ if (event.isCancelled() || (level > entityhuman.experienceLevel && !entityhuman.getAbilities().instabuild) || event.getEnchantsToAdd().isEmpty()) { -+ return; -+ } ++ int level = event.getExpLevelCost(); ++ if (event.isCancelled() || (level > entityhuman.experienceLevel && !entityhuman.getAbilities().instabuild) || event.getEnchantsToAdd().isEmpty()) { ++ return; ++ } - if (flag) { - itemstack2 = new ItemStack(Items.ENCHANTED_BOOK); -@@ -199,16 +278,29 @@ - this.enchantSlots.setItem(0, itemstack2); - } - -- for (int k = 0; k < list.size(); ++k) { -- WeightedRandomEnchant weightedrandomenchant = (WeightedRandomEnchant) list.get(k); -+ for (Map.Entry entry : event.getEnchantsToAdd().entrySet()) { -+ try { -+ if (flag) { -+ NamespacedKey enchantId = entry.getKey().getKey(); -+ Enchantment nms = IRegistry.ENCHANTMENT.get(CraftNamespacedKey.toMinecraft(enchantId)); -+ if (nms == null) { -+ continue; -+ } - -- if (flag) { -- ItemEnchantedBook.addEnchantment(itemstack2, weightedrandomenchant); -- } else { -- itemstack2.enchant(weightedrandomenchant.enchantment, weightedrandomenchant.level); -+ WeightedRandomEnchant weightedrandomenchant = new WeightedRandomEnchant(nms, entry.getValue()); -+ ItemEnchantedBook.addEnchantment(itemstack2, weightedrandomenchant); -+ } else { -+ item.addUnsafeEnchantment(entry.getKey(), entry.getValue()); -+ } -+ } catch (IllegalArgumentException e) { -+ /* Just swallow invalid enchantments */ + if (flag) { + itemstack2 = new ItemStack(Items.ENCHANTED_BOOK); +@@ -182,16 +261,29 @@ + this.enchantSlots.setItem(0, itemstack2); } - } -+ entityhuman.onEnchantmentPerformed(itemstack, j); -+ // CraftBukkit end +- for (int k = 0; k < list.size(); ++k) { +- WeightedRandomEnchant weightedrandomenchant = (WeightedRandomEnchant) list.get(k); +- +- if (flag) { +- ItemEnchantedBook.addEnchantment(itemstack2, weightedrandomenchant); +- } else { +- itemstack2.enchant(weightedrandomenchant.enchantment, weightedrandomenchant.level); ++ for (Map.Entry entry : event.getEnchantsToAdd().entrySet()) { ++ try { ++ if (flag) { ++ NamespacedKey enchantId = entry.getKey().getKey(); ++ Enchantment nms = IRegistry.ENCHANTMENT.get(CraftNamespacedKey.toMinecraft(enchantId)); ++ if (nms == null) { ++ continue; ++ } + -+ // CraftBukkit - TODO: let plugins change this - if (!entityhuman.getAbilities().instabuild) { - itemstack1.shrink(j); - if (itemstack1.isEmpty()) { -@@ -265,6 +357,7 @@ ++ WeightedRandomEnchant weightedrandomenchant = new WeightedRandomEnchant(nms, entry.getValue()); ++ ItemEnchantedBook.addEnchantment(itemstack2, weightedrandomenchant); ++ } else { ++ item.addUnsafeEnchantment(entry.getKey(), entry.getValue()); ++ } ++ } catch (IllegalArgumentException e) { ++ /* Just swallow invalid enchantments */ + } + } + ++ entityhuman.onEnchantmentPerformed(itemstack, j); ++ // CraftBukkit end ++ ++ // CraftBukkit - TODO: let plugins change this + if (!entityhuman.getAbilities().instabuild) { + itemstack1.shrink(j); + if (itemstack1.isEmpty()) { +@@ -254,6 +346,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { @@ -179,7 +180,7 @@ return stillValid(this.access, entityhuman, Blocks.ENCHANTING_TABLE); } -@@ -316,4 +409,17 @@ +@@ -305,4 +398,17 @@ return itemstack; } diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemBoneMeal.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemBoneMeal.patch index 79a8ebdc9a..e995559ae4 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemBoneMeal.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemBoneMeal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemBoneMeal.java +++ b/net/minecraft/world/item/ItemBoneMeal.java -@@ -35,6 +35,12 @@ +@@ -33,6 +33,12 @@ @Override public EnumInteractionResult useOn(ItemActionContext itemactioncontext) { diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemEnderEye.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemEnderEye.patch index c5ee54054f..ff4d681166 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemEnderEye.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemEnderEye.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemEnderEye.java +++ b/net/minecraft/world/item/ItemEnderEye.java -@@ -85,7 +85,11 @@ +@@ -86,7 +86,11 @@ entityendersignal.setItem(itemstack); entityendersignal.signalTo(blockposition); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemLeash.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemLeash.patch index 594d080937..5f745db3f2 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemLeash.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemLeash.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemLeash.java +++ b/net/minecraft/world/item/ItemLeash.java -@@ -14,6 +14,8 @@ +@@ -13,6 +13,8 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.AxisAlignedBB; @@ -9,7 +9,7 @@ public class ItemLeash extends Item { public ItemLeash(Item.Info item_info) { -@@ -55,9 +57,25 @@ +@@ -54,9 +56,25 @@ if (entityinsentient.getLeashHolder() == entityhuman) { if (entityleash == null) { entityleash = EntityLeash.getOrCreateKnot(world, blockposition); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemMinecart.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemMinecart.patch index 4eea6ac4b5..b2a2d06f4b 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemMinecart.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemMinecart.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemMinecart.java +++ b/net/minecraft/world/item/ItemMinecart.java -@@ -18,6 +18,11 @@ +@@ -17,6 +17,11 @@ import net.minecraft.world.level.block.state.properties.BlockPropertyTrackPosition; import net.minecraft.world.level.gameevent.GameEvent; @@ -12,7 +12,7 @@ public class ItemMinecart extends Item { private static final IDispenseBehavior DISPENSE_ITEM_BEHAVIOR = new DispenseBehaviorItem() { -@@ -56,14 +61,43 @@ +@@ -55,14 +60,43 @@ } } @@ -59,7 +59,7 @@ return itemstack; } -@@ -105,7 +139,12 @@ +@@ -104,7 +138,12 @@ entityminecartabstract.setCustomName(itemstack.getHoverName()); } 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 3146ffa4cd..d42f7848ed 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemStack.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemStack.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -72,6 +72,40 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -73,6 +73,40 @@ + import net.minecraft.world.level.block.state.pattern.ShapeDetectorBlock; + import org.slf4j.Logger; +// CraftBukkit start +import com.mojang.serialization.Dynamic; @@ -41,7 +41,7 @@ public final class ItemStack { public static final Codec CODEC = RecordCodecBuilder.create((instance) -> { -@@ -139,16 +173,30 @@ +@@ -144,16 +178,30 @@ this.updateEmptyCacheFlag(); } @@ -74,7 +74,7 @@ this.getItem().verifyTagAfterLoad(this.tag); } -@@ -156,6 +204,11 @@ +@@ -161,6 +209,11 @@ this.setDamageValue(this.getDamageValue()); } @@ -86,8 +86,8 @@ this.updateEmptyCacheFlag(); } -@@ -193,7 +246,7 @@ - return this.getItem() == item; +@@ -202,7 +255,7 @@ + return this.getItem().builtInRegistryHolder().tags(); } - public EnumInteractionResult useOn(ItemActionContext itemactioncontext) { @@ -95,8 +95,8 @@ EntityHuman entityhuman = itemactioncontext.getPlayer(); BlockPosition blockposition = itemactioncontext.getClickedPos(); ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getLevel(), blockposition, false); -@@ -201,12 +254,157 @@ - if (entityhuman != null && !entityhuman.getAbilities().mayBuild && !this.hasAdventureModePlaceTagForBlock(itemactioncontext.getLevel().getTagManager(), shapedetectorblock)) { +@@ -210,12 +263,157 @@ + if (entityhuman != null && !entityhuman.getAbilities().mayBuild && !this.hasAdventureModePlaceTagForBlock(itemactioncontext.getLevel().registryAccess().registryOrThrow(IRegistry.BLOCK_REGISTRY), shapedetectorblock)) { return EnumInteractionResult.PASS; } else { + // CraftBukkit start - handle all block place event logic here @@ -254,7 +254,7 @@ return enuminteractionresult; } -@@ -287,6 +485,21 @@ +@@ -296,6 +494,21 @@ } i -= k; @@ -276,7 +276,7 @@ if (i <= 0) { return false; } -@@ -308,6 +521,11 @@ +@@ -317,6 +530,11 @@ if (this.hurt(i, t0.getRandom(), t0 instanceof EntityPlayer ? (EntityPlayer) t0 : null)) { consumer.accept(t0); Item item = this.getItem(); @@ -288,7 +288,7 @@ this.shrink(1); if (t0 instanceof EntityHuman) { -@@ -463,6 +681,17 @@ +@@ -472,6 +690,17 @@ return this.tag; } @@ -306,7 +306,7 @@ public NBTTagCompound getOrCreateTag() { if (this.tag == null) { this.setTag(new NBTTagCompound()); -@@ -843,6 +1072,12 @@ +@@ -850,6 +1079,12 @@ } public void setRepairCost(int i) { @@ -319,7 +319,7 @@ this.getOrCreateTag().putInt("RepairCost", i); } -@@ -892,6 +1127,13 @@ +@@ -899,6 +1134,13 @@ nbttaglist.add(nbttagcompound); } diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemWorldMap.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemWorldMap.patch index 8f18294a56..bc1ddddddf 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemWorldMap.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemWorldMap.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemWorldMap.java +++ b/net/minecraft/world/item/ItemWorldMap.java -@@ -33,6 +33,11 @@ +@@ -32,6 +32,11 @@ import net.minecraft.world.level.material.MaterialMapColor; import net.minecraft.world.level.saveddata.maps.WorldMap; @@ -12,7 +12,7 @@ public class ItemWorldMap extends ItemWorldMapBase { public static final int IMAGE_WIDTH = 128; -@@ -67,7 +72,7 @@ +@@ -66,7 +71,7 @@ public static Integer getMapId(ItemStack itemstack) { NBTTagCompound nbttagcompound = itemstack.getTag(); @@ -21,7 +21,7 @@ } public static int createNewSavedData(World world, int i, int j, int k, boolean flag, boolean flag1, ResourceKey resourcekey) { -@@ -75,6 +80,10 @@ +@@ -74,6 +79,10 @@ int l = world.getFreeMapId(); world.setMapData(makeKey(l), worldmap); 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 0614d702d5..f52e351b6c 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,21 +1,21 @@ --- a/net/minecraft/world/item/crafting/CraftingManager.java +++ b/net/minecraft/world/item/crafting/CraftingManager.java -@@ -33,11 +33,13 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -32,11 +32,13 @@ + import net.minecraft.world.level.World; + import org.slf4j.Logger; +import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; // CraftBukkit + public class CraftingManager extends ResourceDataJson { private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create(); - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); - public Map, Map>> recipes = ImmutableMap.of(); + public Map, Object2ObjectLinkedOpenHashMap>> recipes = ImmutableMap.of(); // CraftBukkit private Map> byName = ImmutableMap.of(); private boolean hasErrors; -@@ -47,7 +49,12 @@ +@@ -46,7 +48,12 @@ protected void apply(Map map, IResourceManager iresourcemanager, GameProfilerFiller gameprofilerfiller) { this.hasErrors = false; @@ -29,7 +29,7 @@ Builder> builder = ImmutableMap.builder(); Iterator iterator = map.entrySet().iterator(); -@@ -58,8 +65,10 @@ +@@ -57,8 +64,10 @@ try { IRecipe irecipe = fromJson(minecraftkey, ChatDeserializer.convertToJsonObject((JsonElement) entry.getValue(), "top element")); @@ -42,7 +42,7 @@ })).put(minecraftkey, irecipe); builder.put(minecraftkey, irecipe); } catch (IllegalArgumentException | JsonParseException jsonparseexception) { -@@ -68,20 +77,37 @@ +@@ -67,20 +76,37 @@ } this.recipes = (Map) map1.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry1) -> { @@ -75,7 +75,7 @@ - return this.byType(recipes).values().stream().flatMap((irecipe) -> { + // CraftBukkit start + Optional recipe = this.byType(recipes).values().stream().flatMap((irecipe) -> { - return SystemUtils.toStream(recipes.tryMatch(irecipe, world, c0)); + return recipes.tryMatch(irecipe, world, c0).stream(); }).findFirst(); + c0.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found + // CraftBukkit end @@ -83,7 +83,7 @@ } public > List getAllRecipesFor(Recipes recipes) { -@@ -99,7 +125,7 @@ +@@ -98,7 +124,7 @@ } private > Map> byType(Recipes recipes) { @@ -92,7 +92,7 @@ } public > NonNullList getRemainingItemsFor(Recipes recipes, C c0, World world) { -@@ -119,7 +145,7 @@ +@@ -118,7 +144,7 @@ } public Optional> byKey(MinecraftKey minecraftkey) { @@ -101,7 +101,7 @@ } public Collection> getRecipes() { -@@ -144,12 +170,12 @@ +@@ -143,12 +169,12 @@ public void replaceRecipes(Iterable> iterable) { this.hasErrors = false; @@ -116,7 +116,7 @@ }); MinecraftKey minecraftkey = irecipe.getId(); IRecipe irecipe1 = (IRecipe) map1.put(minecraftkey, irecipe); -@@ -160,6 +186,26 @@ +@@ -159,6 +185,26 @@ } }); this.recipes = ImmutableMap.copyOf(map); diff --git a/paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.patch b/paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.patch index b52779d4cd..42f0047156 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.java +++ b/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.java -@@ -57,8 +57,11 @@ +@@ -56,8 +56,11 @@ IBlockData iblockdata2 = world.getBlockState(blockposition1); if (iblockdata2.getMaterial() == Material.WATER && (Integer) iblockdata2.getValue(BlockFluids.LEVEL) == 0 && iblockdata.canSurvive(world, blockposition1) && world.isUnobstructed(iblockdata, blockposition1, VoxelShapeCollision.empty())) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/RayTrace.patch b/paper-server/nms-patches/net/minecraft/world/level/RayTrace.patch index d24ba0439c..3276a5f0a6 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/RayTrace.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/RayTrace.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/RayTrace.java +++ b/net/minecraft/world/level/RayTrace.java -@@ -24,7 +24,7 @@ +@@ -26,7 +26,7 @@ this.to = vec3d1; this.block = raytrace_blockcollisionoption; this.fluid = raytrace_fluidcollisionoption; @@ -9,7 +9,7 @@ } public Vec3D getTo() { -@@ -69,7 +69,7 @@ +@@ -75,7 +75,7 @@ private final Predicate canPick; diff --git a/paper-server/nms-patches/net/minecraft/world/level/SpawnerCreature.patch b/paper-server/nms-patches/net/minecraft/world/level/SpawnerCreature.patch index bd56967d95..c1030bd3b8 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/SpawnerCreature.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/SpawnerCreature.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/SpawnerCreature.java +++ b/net/minecraft/world/level/SpawnerCreature.java @@ -47,6 +47,13 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import net.minecraft.world.phys.Vec3D; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.world.level.storage.WorldData; @@ -13,7 +13,7 @@ + public final class SpawnerCreature { - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); @@ -73,7 +80,8 @@ if (entity instanceof EntityInsentient) { EntityInsentient entityinsentient = (EntityInsentient) entity; @@ -70,7 +70,7 @@ if (j >= entityinsentient.getMaxSpawnClusterSize()) { return; } -@@ -377,7 +404,7 @@ +@@ -383,7 +410,7 @@ if (entityinsentient.checkSpawnRules(worldaccess, EnumMobSpawn.CHUNK_GENERATION) && entityinsentient.checkSpawnObstruction(worldaccess)) { groupdataentity = entityinsentient.finalizeSpawn(worldaccess, worldaccess.getCurrentDifficultyAt(entityinsentient.blockPosition()), EnumMobSpawn.CHUNK_GENERATION, groupdataentity, (NBTTagCompound) null); @@ -79,7 +79,7 @@ flag = true; } } -@@ -498,8 +525,10 @@ +@@ -504,8 +531,10 @@ return this.unmodifiableMobCategoryCounts; } diff --git a/paper-server/nms-patches/net/minecraft/world/level/StructureManager.patch b/paper-server/nms-patches/net/minecraft/world/level/StructureManager.patch deleted file mode 100644 index 3730eb8b0b..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/level/StructureManager.patch +++ /dev/null @@ -1,7 +0,0 @@ ---- a/net/minecraft/world/level/StructureManager.java -+++ b/net/minecraft/world/level/StructureManager.java -@@ -1,3 +1,4 @@ -+// mc-dev import - package net.minecraft.world.level; - - import com.google.common.collect.ImmutableList; 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 001312a7dc..a7cee237b6 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/World.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/World.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/World.java +++ b/net/minecraft/world/level/World.java -@@ -67,6 +67,31 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -65,6 +65,31 @@ + import net.minecraft.world.phys.AxisAlignedBB; + import net.minecraft.world.scores.Scoreboard; +// CraftBukkit start +import java.util.HashMap; @@ -31,12 +31,12 @@ + public abstract class World implements GeneratorAccess, AutoCloseable { - protected static final Logger LOGGER = LogManager.getLogger(); -@@ -104,7 +129,43 @@ + public static final Codec> RESOURCE_KEY_CODEC = MinecraftKey.CODEC.xmap(ResourceKey.elementKey(IRegistry.DIMENSION_REGISTRY), ResourceKey::location); +@@ -102,7 +127,43 @@ private final ResourceKey dimension; private long subTickCount; -- protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, final DimensionManager dimensionmanager, Supplier supplier, boolean flag, boolean flag1, long i) { +- protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i) { + // CraftBukkit start Added the following + private final CraftWorld world; + public boolean pvpMode; @@ -62,7 +62,7 @@ + + public abstract ResourceKey getTypeKey(); + -+ protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, final DimensionManager dimensionmanager, Supplier supplier, boolean flag, boolean flag1, long i, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env) { ++ protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env) { + this.generator = gen; + this.world = new CraftWorld((WorldServer) this, gen, biomeProvider, env); + @@ -76,23 +76,23 @@ + // CraftBukkit end this.profiler = supplier; this.levelData = worlddatamutable; - this.dimensionType = dimensionmanager; -@@ -114,12 +175,12 @@ + this.dimensionTypeRegistration = holder; +@@ -113,12 +174,12 @@ this.worldBorder = new WorldBorder() { @Override public double getCenterX() { -- return super.getCenterX() / dimensionmanager.coordinateScale(); +- return super.getCenterX() / World.this.dimensionType.coordinateScale(); + return super.getCenterX(); // CraftBukkit } @Override public double getCenterZ() { -- return super.getCenterZ() / dimensionmanager.coordinateScale(); +- return super.getCenterZ() / World.this.dimensionType.coordinateScale(); + return super.getCenterZ(); // CraftBukkit } }; } else { -@@ -129,6 +190,42 @@ +@@ -128,6 +189,42 @@ this.thread = Thread.currentThread(); this.biomeManager = new BiomeManager(this, i); this.isDebug = flag1; @@ -135,7 +135,7 @@ } @Override -@@ -186,6 +283,17 @@ +@@ -185,6 +282,17 @@ @Override public boolean setBlock(BlockPosition blockposition, IBlockData iblockdata, int i, int j) { @@ -153,7 +153,7 @@ if (this.isOutsideBuildHeight(blockposition)) { return false; } else if (!this.isClientSide && this.isDebug()) { -@@ -193,9 +301,24 @@ +@@ -192,9 +300,24 @@ } else { Chunk chunk = this.getChunkAt(blockposition); Block block = iblockdata.getBlock(); @@ -179,7 +179,7 @@ return false; } else { IBlockData iblockdata2 = this.getBlockState(blockposition); -@@ -206,6 +329,7 @@ +@@ -205,6 +328,7 @@ this.getProfiler().pop(); } @@ -187,7 +187,7 @@ if (iblockdata2 == iblockdata) { if (iblockdata1 != iblockdata2) { this.setBlocksDirty(blockposition, iblockdata1, iblockdata2); -@@ -232,12 +356,69 @@ +@@ -231,12 +355,69 @@ this.onBlockStateChange(blockposition, iblockdata1, iblockdata2); } @@ -257,7 +257,7 @@ public void onBlockStateChange(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {} @Override -@@ -327,6 +508,17 @@ +@@ -326,6 +507,17 @@ IBlockData iblockdata = this.getBlockState(blockposition); try { @@ -275,7 +275,7 @@ iblockdata.neighborChanged(this, blockposition, block, blockposition1, false); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception while updating neighbours"); -@@ -369,6 +561,14 @@ +@@ -368,6 +560,14 @@ @Override public IBlockData getBlockState(BlockPosition blockposition) { @@ -290,7 +290,7 @@ if (this.isOutsideBuildHeight(blockposition)) { return Blocks.VOID_AIR.defaultBlockState(); } else { -@@ -494,6 +694,16 @@ +@@ -493,6 +693,16 @@ @Nullable @Override public TileEntity getBlockEntity(BlockPosition blockposition) { @@ -307,7 +307,7 @@ return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, Chunk.EnumTileEntityState.IMMEDIATE)); } -@@ -501,6 +711,12 @@ +@@ -500,6 +710,12 @@ BlockPosition blockposition = tileentity.getBlockPos(); if (!this.isOutsideBuildHeight(blockposition)) { @@ -320,7 +320,7 @@ this.getChunkAt(blockposition).addAndRegisterBlockEntity(tileentity); } } -@@ -605,7 +821,7 @@ +@@ -604,7 +820,7 @@ for (int j = 0; j < i; ++j) { EntityComplexPart entitycomplexpart = aentitycomplexpart[j]; @@ -329,7 +329,7 @@ if (t0 != null && predicate.test(t0)) { list.add(t0); -@@ -931,6 +1147,14 @@ +@@ -932,6 +1148,14 @@ public abstract LevelEntityGetter getEntities(); protected void postGameEventInRadius(@Nullable Entity entity, GameEvent gameevent, BlockPosition blockposition, int i) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/AbstractCandleBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/AbstractCandleBlock.patch index e1a4e22ac4..ffc9a6f24b 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/AbstractCandleBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/AbstractCandleBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/AbstractCandleBlock.java +++ b/net/minecraft/world/level/block/AbstractCandleBlock.java -@@ -38,6 +38,11 @@ +@@ -37,6 +37,11 @@ @Override public void onProjectileHit(World world, IBlockData iblockdata, MovingObjectPositionBlock movingobjectpositionblock, IProjectile iprojectile) { if (!world.isClientSide && iprojectile.isOnFire() && this.canBeLit(iblockdata)) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BigDripleafBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BigDripleafBlock.patch index b4b02cd2c1..5e09b19d81 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BigDripleafBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BigDripleafBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BigDripleafBlock.java +++ b/net/minecraft/world/level/block/BigDripleafBlock.java -@@ -42,6 +42,11 @@ +@@ -41,6 +41,11 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -12,7 +12,7 @@ public class BigDripleafBlock extends BlockFacingHorizontal implements IBlockFragilePlantElement, IBlockWaterlogged { private static final BlockStateBoolean WATERLOGGED = BlockProperties.WATERLOGGED; -@@ -110,7 +115,7 @@ +@@ -109,7 +114,7 @@ @Override public void onProjectileHit(World world, IBlockData iblockdata, MovingObjectPositionBlock movingobjectpositionblock, IProjectile iprojectile) { @@ -21,7 +21,7 @@ } @Override -@@ -169,7 +174,20 @@ +@@ -168,7 +173,20 @@ public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { if (!world.isClientSide) { if (iblockdata.getValue(BigDripleafBlock.TILT) == Tilt.NONE && canEntityTilt(blockposition, entity) && !world.hasNeighborSignal(blockposition)) { @@ -43,7 +43,7 @@ } } -@@ -183,9 +201,9 @@ +@@ -182,9 +200,9 @@ Tilt tilt = (Tilt) iblockdata.getValue(BigDripleafBlock.TILT); if (tilt == Tilt.UNSTABLE) { @@ -55,7 +55,7 @@ } else if (tilt == Tilt.FULL) { resetTilt(iblockdata, worldserver, blockposition); } -@@ -211,8 +229,10 @@ +@@ -210,8 +228,10 @@ return entity.isOnGround() && entity.position().y > (double) ((float) blockposition.getY() + 0.6875F); } @@ -68,7 +68,7 @@ if (soundeffect != null) { playTiltSound(world, blockposition, soundeffect); } -@@ -226,19 +246,27 @@ +@@ -225,19 +245,27 @@ } private static void resetTilt(IBlockData iblockdata, World world, BlockPosition blockposition) { 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 f760444853..ecdf0dbeed 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/Block.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/Block.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -352,7 +352,13 @@ +@@ -354,7 +354,13 @@ EntityItem entityitem = (EntityItem) supplier.get(); entityitem.setDefaultPickUpDelay(); @@ -15,7 +15,7 @@ } } -@@ -378,7 +384,7 @@ +@@ -380,7 +386,7 @@ public void playerDestroy(World world, EntityHuman entityhuman, BlockPosition blockposition, IBlockData iblockdata, @Nullable TileEntity tileentity, ItemStack itemstack) { entityhuman.awardStat(StatisticList.BLOCK_MINED.get(this)); @@ -24,8 +24,8 @@ dropResources(iblockdata, world, blockposition, tileentity, entityhuman, itemstack); } -@@ -512,6 +518,12 @@ - return (ImmutableMap) this.stateDefinition.getPossibleStates().stream().collect(ImmutableMap.toImmutableMap(Function.identity(), function)); +@@ -520,6 +526,12 @@ + return this.builtInRegistryHolder; } + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch index 5a707985bb..204ee4a1b8 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockBamboo.java +++ b/net/minecraft/world/level/block/BlockBamboo.java -@@ -186,7 +186,7 @@ +@@ -185,7 +185,7 @@ BlockPosition blockposition1 = blockposition.above(i); IBlockData iblockdata1 = worldserver.getBlockState(blockposition1); @@ -9,7 +9,7 @@ return; } -@@ -207,14 +207,18 @@ +@@ -206,14 +206,18 @@ BlockPosition blockposition1 = blockposition.below(2); IBlockData iblockdata2 = world.getBlockState(blockposition1); BlockPropertyBambooSize blockpropertybamboosize = BlockPropertyBambooSize.NONE; @@ -30,7 +30,7 @@ } } } else { -@@ -225,7 +229,14 @@ +@@ -224,7 +228,14 @@ int j = (Integer) iblockdata.getValue(BlockBamboo.AGE) != 1 && !iblockdata2.is(Blocks.BAMBOO) ? 0 : 1; int k = (i < 11 || random.nextFloat() >= 0.25F) && i != 15 ? 0 : 1; diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch index 22b991b815..05d9dc10ef 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockBambooSapling.java +++ b/net/minecraft/world/level/block/BlockBambooSapling.java -@@ -94,6 +94,6 @@ +@@ -93,6 +93,6 @@ } protected void growBamboo(World world, BlockPosition blockposition) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch index d49ecbe864..8c42896473 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockBeehive.java +++ b/net/minecraft/world/level/block/BlockBeehive.java -@@ -108,7 +108,7 @@ +@@ -105,7 +105,7 @@ EntityBee entitybee = (EntityBee) iterator.next(); if (entitybee.getTarget() == null) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCactus.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCactus.patch index 17fe431e80..3e7669daee 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCactus.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCactus.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCactus.java +++ b/net/minecraft/world/level/block/BlockCactus.java -@@ -23,6 +23,8 @@ +@@ -22,6 +22,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -9,7 +9,7 @@ public class BlockCactus extends Block { public static final BlockStateInteger AGE = BlockProperties.AGE_15; -@@ -59,7 +61,7 @@ +@@ -58,7 +60,7 @@ int j = (Integer) iblockdata.getValue(BlockCactus.AGE); if (j == 15) { @@ -18,7 +18,7 @@ IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockCactus.AGE, 0); worldserver.setBlock(blockposition, iblockdata1, 4); -@@ -116,7 +118,9 @@ +@@ -115,7 +117,9 @@ @Override public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCake.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCake.patch index c3c9b80ed3..873c18f1b7 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCake.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCake.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCake.java +++ b/net/minecraft/world/level/block/BlockCake.java -@@ -85,7 +85,18 @@ +@@ -84,7 +84,18 @@ return EnumInteractionResult.PASS; } else { entityhuman.awardStat(StatisticList.EAT_CAKE_SLICE); 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 96604d4bef..6166481552 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCampfire.java +++ b/net/minecraft/world/level/block/BlockCampfire.java -@@ -48,6 +48,10 @@ +@@ -47,6 +47,10 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -11,7 +11,7 @@ public class BlockCampfire extends BlockTileEntity implements IBlockWaterlogged { protected static final VoxelShape SHAPE = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 7.0D, 16.0D); -@@ -92,7 +96,9 @@ +@@ -91,7 +95,9 @@ @Override public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { if (!entity.fireImmune() && (Boolean) iblockdata.getValue(BlockCampfire.LIT) && entity instanceof EntityLiving && !EnchantmentManager.hasFrostWalker((EntityLiving) entity)) { @@ -21,7 +21,7 @@ } super.entityInside(iblockdata, world, blockposition, entity); -@@ -202,6 +208,11 @@ +@@ -201,6 +207,11 @@ BlockPosition blockposition = movingobjectpositionblock.getBlockPos(); if (!world.isClientSide && iprojectile.isOnFire() && iprojectile.mayInteract(world, blockposition) && !(Boolean) iblockdata.getValue(BlockCampfire.LIT) && !(Boolean) iblockdata.getValue(BlockCampfire.WATERLOGGED)) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCocoa.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCocoa.patch index daa5401b80..1f64aa7bcf 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCocoa.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCocoa.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCocoa.java +++ b/net/minecraft/world/level/block/BlockCocoa.java -@@ -21,6 +21,8 @@ +@@ -20,6 +20,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -9,7 +9,7 @@ public class BlockCocoa extends BlockFacingHorizontal implements IBlockFragilePlantElement { public static final int MAX_AGE = 2; -@@ -55,7 +57,7 @@ +@@ -54,7 +56,7 @@ int i = (Integer) iblockdata.getValue(BlockCocoa.AGE); if (i < 2) { @@ -18,7 +18,7 @@ } } -@@ -125,7 +127,7 @@ +@@ -124,7 +126,7 @@ @Override public void performBonemeal(WorldServer worldserver, Random random, BlockPosition blockposition, IBlockData iblockdata) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCommand.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCommand.patch index b432a5455b..d42e0f8709 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCommand.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCommand.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/BlockCommand.java +++ b/net/minecraft/world/level/block/BlockCommand.java @@ -27,6 +27,8 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import net.minecraft.world.phys.MovingObjectPositionBlock; + import org.slf4j.Logger; +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit + public class BlockCommand extends BlockTileEntity implements GameMasterBlock { - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); @@ -57,6 +59,15 @@ TileEntityCommand tileentitycommand = (TileEntityCommand) tileentity; boolean flag1 = world.hasNeighborSignal(blockposition); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch index 5ee18686b3..f30910dda2 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockConcretePowder.java +++ b/net/minecraft/world/level/block/BlockConcretePowder.java -@@ -12,6 +12,12 @@ +@@ -11,6 +11,12 @@ import net.minecraft.world.level.block.state.BlockBase; import net.minecraft.world.level.block.state.IBlockData; @@ -13,7 +13,7 @@ public class BlockConcretePowder extends BlockFalling { private final IBlockData concrete; -@@ -24,7 +30,7 @@ +@@ -23,7 +29,7 @@ @Override public void onLand(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1, EntityFallingBlock entityfallingblock) { if (shouldSolidify(world, blockposition, iblockdata1)) { @@ -22,7 +22,7 @@ } } -@@ -35,7 +41,24 @@ +@@ -34,7 +40,24 @@ BlockPosition blockposition = blockactioncontext.getClickedPos(); IBlockData iblockdata = world.getBlockState(blockposition); @@ -48,7 +48,7 @@ } private static boolean shouldSolidify(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) { -@@ -71,7 +94,25 @@ +@@ -70,7 +93,25 @@ @Override public IBlockData updateShape(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoral.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoral.patch index 0f7b10c3a9..7b9d7a222e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoral.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCoral.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCoral.java +++ b/net/minecraft/world/level/block/BlockCoral.java -@@ -26,6 +26,11 @@ +@@ -25,6 +25,11 @@ @Override public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { if (!this.scanForWater(worldserver, blockposition)) { 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 0ab947f9ea..43d78a40fa 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDirtSnowSpreadable.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDirtSnowSpreadable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockDirtSnowSpreadable.java +++ b/net/minecraft/world/level/block/BlockDirtSnowSpreadable.java -@@ -41,6 +41,11 @@ +@@ -40,6 +40,11 @@ @Override public void randomTick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { if (!canBeGrass(iblockdata, worldserver, blockposition)) { @@ -12,7 +12,7 @@ worldserver.setBlockAndUpdate(blockposition, Blocks.DIRT.defaultBlockState()); } else { if (worldserver.getMaxLocalRawBrightness(blockposition.above()) >= 9) { -@@ -50,7 +55,7 @@ +@@ -49,7 +54,7 @@ BlockPosition blockposition1 = blockposition.offset(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1); if (worldserver.getBlockState(blockposition1).is(Blocks.DIRT) && canPropagate(iblockdata1, worldserver, blockposition1)) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch index c5b6c7f839..44451a2d40 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockFenceGate.java +++ b/net/minecraft/world/level/block/BlockFenceGate.java -@@ -129,6 +129,17 @@ +@@ -128,6 +128,17 @@ public void neighborChanged(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) { if (!world.isClientSide) { boolean flag1 = world.hasNeighborSignal(blockposition); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFluids.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFluids.patch index 2f664a051c..9ee557bcf6 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFluids.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFluids.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/BlockFluids.java +++ b/net/minecraft/world/level/block/BlockFluids.java -@@ -141,14 +141,20 @@ - if (world.getFluidState(blockposition1).is((Tag) TagsFluid.WATER)) { +@@ -140,14 +140,20 @@ + if (world.getFluidState(blockposition1).is(TagsFluid.WATER)) { Block block = world.getFluidState(blockposition).isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE; - world.setBlockAndUpdate(blockposition, block.defaultBlockState()); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFungi.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFungi.patch index eafa6a78f3..d2a525d541 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFungi.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFungi.patch @@ -11,6 +11,6 @@ + BlockSapling.treeType = org.bukkit.TreeType.CRIMSON_FUNGUS; + } + // CraftBukkit end - ((WorldGenFeatureConfigured) this.feature.get()).place(worldserver, worldserver.getChunkSource().getGenerator(), random, blockposition); + ((WorldGenFeatureConfigured) ((Holder) this.feature.get()).value()).place(worldserver, worldserver.getChunkSource().getGenerator(), random, blockposition); } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch index dae8867269..2908722c7d 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockLeaves.java +++ b/net/minecraft/world/level/block/BlockLeaves.java -@@ -20,6 +20,8 @@ +@@ -19,6 +19,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -9,7 +9,7 @@ public class BlockLeaves extends Block { public static final int DECAY_DISTANCE = 7; -@@ -45,6 +47,14 @@ +@@ -44,6 +46,14 @@ @Override public void randomTick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { if (!(Boolean) iblockdata.getValue(BlockLeaves.PERSISTENT) && (Integer) iblockdata.getValue(BlockLeaves.DISTANCE) == 7) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockLectern.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockLectern.patch index 369e7104ea..76c195669c 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockLectern.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockLectern.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockLectern.java +++ b/net/minecraft/world/level/block/BlockLectern.java -@@ -198,12 +198,13 @@ +@@ -197,12 +197,13 @@ } private void popBook(IBlockData iblockdata, World world, BlockPosition blockposition) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockMagma.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockMagma.patch index d2ce08ac28..4f6b02223a 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockMagma.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockMagma.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockMagma.java +++ b/net/minecraft/world/level/block/BlockMagma.java -@@ -30,7 +30,9 @@ +@@ -29,7 +29,9 @@ @Override public void stepOn(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { if (!entity.fireImmune() && entity instanceof EntityLiving && !EnchantmentManager.hasFrostWalker((EntityLiving) entity)) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch index 5c3d9b617f..1bbe8f73b5 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch @@ -25,6 +25,6 @@ public boolean growMushroom(WorldServer worldserver, BlockPosition blockposition, IBlockData iblockdata, Random random) { worldserver.removeBlock(blockposition, false); + BlockSapling.treeType = (this == Blocks.BROWN_MUSHROOM) ? TreeType.BROWN_MUSHROOM : TreeType.BROWN_MUSHROOM; // CraftBukkit - if (((WorldGenFeatureConfigured) this.featureSupplier.get()).place(worldserver, worldserver.getChunkSource().getGenerator(), random, blockposition)) { + if (((WorldGenFeatureConfigured) ((Holder) this.featureSupplier.get()).value()).place(worldserver, worldserver.getChunkSource().getGenerator(), random, blockposition)) { return true; } else { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockNylium.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockNylium.patch index f6155a70cf..e91258faf1 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockNylium.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockNylium.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockNylium.java +++ b/net/minecraft/world/level/block/BlockNylium.java -@@ -30,6 +30,11 @@ +@@ -31,6 +31,11 @@ @Override public void randomTick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { if (!canBeNylium(iblockdata, worldserver, blockposition)) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPlant.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPlant.patch index 1e84032584..7ba1208158 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPlant.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPlant.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockPlant.java +++ b/net/minecraft/world/level/block/BlockPlant.java -@@ -23,7 +23,14 @@ +@@ -22,7 +22,14 @@ @Override public IBlockData updateShape(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockReed.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockReed.patch index 35b6c8f6ca..934739e696 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockReed.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockReed.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockReed.java +++ b/net/minecraft/world/level/block/BlockReed.java -@@ -57,7 +57,7 @@ +@@ -56,7 +56,7 @@ int j = (Integer) iblockdata.getValue(BlockReed.AGE); if (j == 15) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockScaffolding.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockScaffolding.patch index 42ee703114..004a418902 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockScaffolding.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockScaffolding.patch @@ -7,5 +7,5 @@ - if ((Integer) iblockdata1.getValue(BlockScaffolding.DISTANCE) == 7) { + if ((Integer) iblockdata1.getValue(BlockScaffolding.DISTANCE) == 7 && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { // CraftBukkit - BlockFadeEvent if ((Integer) iblockdata.getValue(BlockScaffolding.DISTANCE) == 7) { - worldserver.addFreshEntity(new EntityFallingBlock(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (IBlockData) iblockdata1.setValue(BlockScaffolding.WATERLOGGED, false))); + EntityFallingBlock.fall(worldserver, blockposition, iblockdata1); } else { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSoil.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSoil.patch index b49b2bcbec..76a4f105da 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSoil.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSoil.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockSoil.java +++ b/net/minecraft/world/level/block/BlockSoil.java -@@ -26,6 +26,11 @@ +@@ -25,6 +25,11 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -12,7 +12,7 @@ public class BlockSoil extends Block { public static final BlockStateInteger MOISTURE = BlockProperties.MOISTURE; -@@ -82,26 +87,49 @@ +@@ -81,26 +86,49 @@ if (!isNearWater(worldserver, blockposition) && !worldserver.isRainingAt(blockposition.above())) { if (i > 0) { 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 c07e213a2b..fb98a878b3 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSponge.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSponge.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockSponge.java +++ b/net/minecraft/world/level/block/BlockSponge.java -@@ -14,6 +14,13 @@ +@@ -13,6 +13,13 @@ import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Material; @@ -14,7 +14,7 @@ public class BlockSponge extends Block { public static final int MAX_DEPTH = 6; -@@ -49,6 +56,7 @@ +@@ -48,6 +55,7 @@ queue.add(new Tuple<>(blockposition, 0)); int i = 0; @@ -22,7 +22,7 @@ while (!queue.isEmpty()) { Tuple tuple = (Tuple) queue.poll(); -@@ -60,27 +68,31 @@ +@@ -59,27 +67,31 @@ for (int l = 0; l < k; ++l) { EnumDirection enumdirection = aenumdirection[l]; BlockPosition blockposition2 = blockposition1.relative(enumdirection); @@ -34,7 +34,7 @@ + // CraftBukkit end Material material = iblockdata.getMaterial(); - if (fluid.is((Tag) TagsFluid.WATER)) { + if (fluid.is(TagsFluid.WATER)) { - if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).pickupBlock(world, blockposition2, iblockdata).isEmpty()) { + if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).pickupBlock(blockList, blockposition2, iblockdata).isEmpty()) { // CraftBukkit ++i; @@ -61,7 +61,7 @@ ++i; if (j < 6) { queue.add(new Tuple<>(blockposition2, j + 1)); -@@ -93,6 +105,39 @@ +@@ -92,6 +104,39 @@ break; } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockStem.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockStem.patch index 4361a41d40..e49acece97 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockStem.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockStem.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockStem.java +++ b/net/minecraft/world/level/block/BlockStem.java -@@ -21,6 +21,8 @@ +@@ -20,6 +20,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -9,7 +9,7 @@ public class BlockStem extends BlockPlant implements IBlockFragilePlantElement { public static final int MAX_AGE = 7; -@@ -57,14 +59,18 @@ +@@ -56,14 +58,18 @@ if (i < 7) { iblockdata = (IBlockData) iblockdata.setValue(BlockStem.AGE, i + 1); @@ -20,7 +20,7 @@ BlockPosition blockposition1 = blockposition.relative(enumdirection); IBlockData iblockdata1 = worldserver.getBlockState(blockposition1.below()); - if (worldserver.getBlockState(blockposition1).isAir() && (iblockdata1.is(Blocks.FARMLAND) || iblockdata1.is((Tag) TagsBlock.DIRT))) { + if (worldserver.getBlockState(blockposition1).isAir() && (iblockdata1.is(Blocks.FARMLAND) || iblockdata1.is(TagsBlock.DIRT))) { - worldserver.setBlockAndUpdate(blockposition1, this.fruit.defaultBlockState()); + // CraftBukkit start + if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, this.fruit.defaultBlockState())) { @@ -30,7 +30,7 @@ worldserver.setBlockAndUpdate(blockposition, (IBlockData) this.fruit.getAttachedStem().defaultBlockState().setValue(BlockFacingHorizontal.FACING, enumdirection)); } } -@@ -93,7 +99,7 @@ +@@ -92,7 +98,7 @@ int i = Math.min(7, (Integer) iblockdata.getValue(BlockStem.AGE) + MathHelper.nextInt(worldserver.random, 2, 5)); IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockStem.AGE, i); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch index 5885d8f28b..38c51f7fbe 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockTurtleEgg.java +++ b/net/minecraft/world/level/block/BlockTurtleEgg.java -@@ -29,6 +29,12 @@ +@@ -28,6 +28,12 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -13,7 +13,7 @@ public class BlockTurtleEgg extends Block { public static final int MAX_HATCH_LEVEL = 2; -@@ -62,6 +68,19 @@ +@@ -61,6 +67,19 @@ private void destroyEgg(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, int i) { if (this.canDestroyEgg(world, entity)) { if (!world.isClientSide && world.random.nextInt(i) == 0 && iblockdata.is(Blocks.TURTLE_EGG)) { @@ -33,7 +33,7 @@ this.decreaseEggs(world, blockposition, iblockdata); } -@@ -87,9 +106,19 @@ +@@ -86,9 +105,19 @@ int i = (Integer) iblockdata.getValue(BlockTurtleEgg.HATCH); if (i < 2) { @@ -54,7 +54,7 @@ worldserver.playSound((EntityHuman) null, blockposition, SoundEffects.TURTLE_EGG_HATCH, SoundCategory.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F); worldserver.removeBlock(blockposition, false); -@@ -100,7 +129,7 @@ +@@ -99,7 +128,7 @@ entityturtle.setAge(-24000); entityturtle.setHomePos(blockposition); entityturtle.moveTo((double) blockposition.getX() + 0.3D + (double) j * 0.2D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.3D, 0.0F, 0.0F); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch index cd20a0b804..b50996e4d2 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockWitherSkull.java +++ b/net/minecraft/world/level/block/BlockWitherSkull.java -@@ -27,6 +27,11 @@ +@@ -26,6 +26,11 @@ import net.minecraft.world.level.block.state.predicate.MaterialPredicate; import net.minecraft.world.level.material.Material; @@ -12,7 +12,7 @@ public class BlockWitherSkull extends BlockSkull { @Nullable -@@ -50,6 +55,7 @@ +@@ -49,6 +54,7 @@ } public static void checkSpawn(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) { @@ -20,7 +20,7 @@ if (!world.isClientSide) { IBlockData iblockdata = tileentityskull.getBlockState(); boolean flag = iblockdata.is(Blocks.WITHER_SKELETON_SKULL) || iblockdata.is(Blocks.WITHER_SKELETON_WALL_SKULL); -@@ -59,12 +65,14 @@ +@@ -58,12 +64,14 @@ ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.find(world, blockposition); if (shapedetector_shapedetectorcollection != null) { @@ -37,7 +37,7 @@ } } -@@ -74,6 +82,15 @@ +@@ -73,6 +81,15 @@ entitywither.moveTo((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.55D, (double) blockposition1.getZ() + 0.5D, shapedetector_shapedetectorcollection.getForwards().getAxis() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F); entitywither.yBodyRot = shapedetector_shapedetectorcollection.getForwards().getAxis() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F; entitywither.makeInvulnerable(); @@ -53,7 +53,7 @@ Iterator iterator = world.getEntitiesOfClass(EntityPlayer.class, entitywither.getBoundingBox().inflate(50.0D)).iterator(); while (iterator.hasNext()) { -@@ -82,7 +99,7 @@ +@@ -81,7 +98,7 @@ CriterionTriggers.SUMMONED_ENTITY.trigger(entityplayer, (Entity) entitywither); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch index 01e29cbc07..f005ee20fc 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/PointedDripstoneBlock.java +++ b/net/minecraft/world/level/block/PointedDripstoneBlock.java -@@ -41,6 +41,11 @@ +@@ -43,6 +43,11 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -12,7 +12,7 @@ public class PointedDripstoneBlock extends Block implements Fallable, IBlockWaterlogged { public static final BlockStateDirection TIP_DIRECTION = BlockProperties.VERTICAL_DIRECTION; -@@ -123,6 +128,11 @@ +@@ -125,6 +130,11 @@ BlockPosition blockposition = movingobjectpositionblock.getBlockPos(); if (!world.isClientSide && iprojectile.mayInteract(world, blockposition) && iprojectile instanceof EntityThrownTrident && iprojectile.getDeltaMovement().length() > 0.6D) { @@ -24,7 +24,7 @@ world.destroyBlock(blockposition, true); } -@@ -131,7 +141,9 @@ +@@ -133,7 +143,9 @@ @Override public void fallOn(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, float f) { if (iblockdata.getValue(PointedDripstoneBlock.TIP_DIRECTION) == EnumDirection.UP && iblockdata.getValue(PointedDripstoneBlock.THICKNESS) == DripstoneThickness.TIP) { @@ -34,7 +34,7 @@ } else { super.fallOn(world, iblockdata, blockposition, entity, f); } -@@ -405,15 +417,15 @@ +@@ -380,15 +392,15 @@ if (isUnmergedTipWithDirection(iblockdata, enumdirection.getOpposite())) { createMergedTips(iblockdata, worldserver, blockposition1); } else if (iblockdata.isAir() || iblockdata.is(Blocks.WATER)) { @@ -53,7 +53,7 @@ } private static void createMergedTips(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { -@@ -428,8 +440,8 @@ +@@ -403,8 +415,8 @@ blockposition1 = blockposition.below(); } @@ -64,27 +64,30 @@ } public static void spawnDripParticle(World world, BlockPosition blockposition, IBlockData iblockdata) { -@@ -462,7 +474,7 @@ +@@ -437,7 +449,7 @@ - return (BlockPosition) findBlockVertical(generatoraccess, blockposition, enumdirection.getAxisDirection(), predicate, (iblockdata1) -> { + return (BlockPosition) findBlockVertical(generatoraccess, blockposition, enumdirection.getAxisDirection(), bipredicate, (iblockdata1) -> { return isTip(iblockdata1, flag); - }, i).orElse((Object) null); + }, i).orElse(null); // CraftBukkit - decompile error } } -@@ -575,12 +587,12 @@ - return iblockdata.getBlock() instanceof AbstractCauldronBlock && ((AbstractCauldronBlock) iblockdata.getBlock()).canReceiveStalactiteDrip(fluidtype); +@@ -553,7 +565,7 @@ + return canDripThrough(world, blockposition1, iblockdata); }; -- return (BlockPosition) findBlockVertical(world, blockposition, EnumDirection.DOWN.getAxisDirection(), BlockBase.BlockData::isAir, predicate, 11).orElse((Object) null); -+ return (BlockPosition) findBlockVertical(world, blockposition, EnumDirection.DOWN.getAxisDirection(), BlockBase.BlockData::isAir, predicate, 11).orElse(null); // CraftBukkit - decompile error +- return (BlockPosition) findBlockVertical(world, blockposition, EnumDirection.DOWN.getAxisDirection(), bipredicate, predicate, 11).orElse((Object) null); ++ return (BlockPosition) findBlockVertical(world, blockposition, EnumDirection.DOWN.getAxisDirection(), bipredicate, predicate, 11).orElse(null); // CraftBukkit - decompile error } @Nullable - public static BlockPosition findStalactiteTipAboveCauldron(World world, BlockPosition blockposition) { -- return (BlockPosition) findBlockVertical(world, blockposition, EnumDirection.UP.getAxisDirection(), BlockBase.BlockData::isAir, PointedDripstoneBlock::canDrip, 11).orElse((Object) null); -+ return (BlockPosition) findBlockVertical(world, blockposition, EnumDirection.UP.getAxisDirection(), BlockBase.BlockData::isAir, PointedDripstoneBlock::canDrip, 11).orElse(null); // CraftBukkit - decompile error +@@ -562,7 +574,7 @@ + return canDripThrough(world, blockposition1, iblockdata); + }; + +- return (BlockPosition) findBlockVertical(world, blockposition, EnumDirection.UP.getAxisDirection(), bipredicate, PointedDripstoneBlock::canDrip, 11).orElse((Object) null); ++ return (BlockPosition) findBlockVertical(world, blockposition, EnumDirection.UP.getAxisDirection(), bipredicate, PointedDripstoneBlock::canDrip, 11).orElse(null); // CraftBukkit - decompile error } public static FluidType getCauldronFillFluidType(World world, BlockPosition blockposition) { 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 ac5d27fe9b..1627b9e82c 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,8 +1,8 @@ --- a/net/minecraft/world/level/block/entity/TileEntity.java +++ b/net/minecraft/world/level/block/entity/TileEntity.java @@ -15,8 +15,18 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import net.minecraft.world.level.block.state.IBlockData; + import org.slf4j.Logger; +// CraftBukkit start +import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer; @@ -16,7 +16,7 @@ + private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry(); + public CraftPersistentDataContainer persistentDataContainer; + // CraftBukkit end - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); private final TileEntityTypes type; @Nullable @@ -48,7 +58,16 @@ diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch index 0317463839..ff2b969aee 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityBeacon.java +++ b/net/minecraft/world/level/block/entity/TileEntityBeacon.java -@@ -39,6 +39,11 @@ +@@ -38,6 +38,11 @@ import net.minecraft.world.level.levelgen.HeightMap; import net.minecraft.world.phys.AxisAlignedBB; @@ -12,7 +12,7 @@ public class TileEntityBeacon extends TileEntity implements ITileInventory { private static final int MAX_LEVELS = 4; -@@ -61,6 +66,15 @@ +@@ -60,6 +65,15 @@ public IChatBaseComponent name; public ChestLock lockKey; private final IContainerProperties dataAccess; @@ -28,7 +28,7 @@ public TileEntityBeacon(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.BEACON, blockposition, iblockdata); -@@ -229,39 +243,78 @@ +@@ -228,39 +242,78 @@ super.setRemoved(); } @@ -117,7 +117,7 @@ public static void playSound(World world, BlockPosition blockposition, SoundEffect soundeffect) { world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); } -@@ -290,8 +343,11 @@ +@@ -289,8 +342,11 @@ @Override public void load(NBTTagCompound nbttagcompound) { super.load(nbttagcompound); 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 f948cd89e6..8d67eb5c23 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityBeehive.java +++ b/net/minecraft/world/level/block/entity/TileEntityBeehive.java -@@ -43,6 +43,7 @@ +@@ -42,6 +42,7 @@ private final List stored = Lists.newArrayList(); @Nullable public BlockPosition savedFlowerPos; @@ -8,7 +8,7 @@ public TileEntityBeehive(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.BEEHIVE, blockposition, iblockdata); -@@ -82,7 +83,7 @@ +@@ -81,7 +82,7 @@ } public boolean isFull() { @@ -17,7 +17,7 @@ } public void emptyAllLivingFromHive(@Nullable EntityHuman entityhuman, IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { -@@ -99,7 +100,7 @@ +@@ -98,7 +99,7 @@ if (entityhuman.position().distanceToSqr(entity.position()) <= 16.0D) { if (!this.isSedated()) { @@ -26,7 +26,7 @@ } else { entitybee.setStayOutOfHiveCountdown(400); } -@@ -111,10 +112,16 @@ +@@ -110,10 +111,16 @@ } private List releaseAllOccupants(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { @@ -44,7 +44,7 @@ }); if (!list.isEmpty()) { super.setChanged(); -@@ -142,7 +149,19 @@ +@@ -141,7 +148,19 @@ } public void addOccupantWithPresetTicks(Entity entity, boolean flag, int i) { @@ -65,7 +65,7 @@ entity.stopRiding(); entity.ejectPassengers(); NBTTagCompound nbttagcompound = new NBTTagCompound(); -@@ -173,7 +192,13 @@ +@@ -172,7 +191,13 @@ } private static boolean releaseOccupant(World world, BlockPosition blockposition, IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, @Nullable BlockPosition blockposition1) { @@ -80,7 +80,7 @@ return false; } else { NBTTagCompound nbttagcompound = tileentitybeehive_hivebee.entityData.copy(); -@@ -196,6 +221,18 @@ +@@ -195,6 +220,18 @@ if (!entity.getType().is(TagsEntity.BEEHIVE_INHABITORS)) { return false; } else { @@ -99,7 +99,7 @@ if (entity instanceof EntityBee) { EntityBee entitybee = (EntityBee) entity; -@@ -225,6 +262,7 @@ +@@ -226,6 +263,7 @@ list.add(entitybee); } @@ -107,7 +107,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(); -@@ -232,10 +270,11 @@ +@@ -233,10 +271,11 @@ double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getStepZ(); entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot()); @@ -120,7 +120,7 @@ } } else { return false; -@@ -284,6 +323,10 @@ +@@ -285,6 +324,10 @@ if (releaseOccupant(world, blockposition, iblockdata, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus, blockposition1)) { flag = true; iterator.remove(); @@ -131,7 +131,7 @@ } } } -@@ -325,6 +368,11 @@ +@@ -326,6 +369,11 @@ this.savedFlowerPos = GameProfileSerializer.readBlockPos(nbttagcompound.getCompound("FlowerPos")); } @@ -143,7 +143,7 @@ } @Override -@@ -334,6 +382,7 @@ +@@ -335,6 +383,7 @@ if (this.hasSavedFlowerPos()) { nbttagcompound.put("FlowerPos", GameProfileSerializer.writeBlockPos(this.savedFlowerPos)); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch index faa4cc3e3e..3002ce3ec0 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityConduit.java +++ b/net/minecraft/world/level/block/entity/TileEntityConduit.java -@@ -29,6 +29,11 @@ +@@ -28,6 +28,11 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -12,16 +12,16 @@ public class TileEntityConduit extends TileEntity { private static final int BLOCK_REFRESH_RATE = 2; -@@ -203,7 +208,7 @@ +@@ -202,7 +207,7 @@ EntityHuman entityhuman = (EntityHuman) iterator.next(); - if (blockposition.closerThan((BaseBlockPosition) entityhuman.blockPosition(), (double) j) && entityhuman.isInWaterOrRain()) { + if (blockposition.closerThan(entityhuman.blockPosition(), (double) j) && entityhuman.isInWaterOrRain()) { - entityhuman.addEffect(new MobEffect(MobEffects.CONDUIT_POWER, 260, 0, true, true)); + entityhuman.addEffect(new MobEffect(MobEffects.CONDUIT_POWER, 260, 0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONDUIT); // CraftBukkit } } -@@ -232,8 +237,13 @@ +@@ -231,8 +236,13 @@ } if (tileentityconduit.destroyTarget != null) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch index 51dafa244a..35208be285 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/entity/TileEntityEndGateway.java +++ b/net/minecraft/world/level/block/entity/TileEntityEndGateway.java -@@ -31,6 +31,14 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -32,6 +32,14 @@ + import net.minecraft.world.phys.Vec3D; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.world.level.dimension.WorldDimension; @@ -14,8 +14,8 @@ + public class TileEntityEndGateway extends TileEntityEnderPortal { - private static final Logger LOGGER = LogManager.getLogger(); -@@ -167,7 +175,7 @@ + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -168,7 +176,7 @@ tileentityendgateway.teleportCooldown = 100; BlockPosition blockposition1; @@ -24,7 +24,7 @@ blockposition1 = findOrCreateValidTeleportPos(worldserver, blockposition); blockposition1 = blockposition1.above(10); TileEntityEndGateway.LOGGER.debug("Creating portal at {}", blockposition1); -@@ -196,6 +204,27 @@ +@@ -197,6 +205,27 @@ entity1 = entity.getRootVehicle(); } 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 15aeaad1f4..ff058c0f79 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityFurnace.java +++ b/net/minecraft/world/level/block/entity/TileEntityFurnace.java -@@ -43,6 +43,20 @@ +@@ -45,6 +45,20 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.Vec3D; @@ -21,7 +21,7 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeHolder, AutoRecipeOutput { protected static final int SLOT_INPUT = 0; -@@ -182,6 +196,40 @@ +@@ -184,6 +198,40 @@ return map; } @@ -60,9 +60,9 @@ + // CraftBukkit end + private static boolean isNeverAFurnaceFuel(Item item) { - return TagsItem.NON_FLAMMABLE_WOOD.contains(item); + return item.builtInRegistryHolder().is(TagsItem.NON_FLAMMABLE_WOOD); } -@@ -265,13 +313,24 @@ +@@ -267,13 +315,24 @@ tileentityfurnace.cookingProgress = MathHelper.clamp(tileentityfurnace.cookingProgress - 2, (int) 0, tileentityfurnace.cookingTotalTime); } } else { @@ -90,7 +90,7 @@ flag1 = true; if (!itemstack.isEmpty()) { Item item = itemstack.getItem(); -@@ -287,11 +346,23 @@ +@@ -289,11 +348,23 @@ } if (tileentityfurnace.isLit() && canBurn(irecipe, tileentityfurnace.items, i)) { @@ -115,7 +115,7 @@ tileentityfurnace.setRecipeUsed(irecipe); } -@@ -330,17 +401,44 @@ +@@ -332,17 +403,44 @@ } } @@ -161,7 +161,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)); -@@ -364,7 +462,7 @@ +@@ -366,7 +464,7 @@ } private static int getTotalCookTime(World world, Recipes recipes, IInventory iinventory) { @@ -170,7 +170,7 @@ } public static boolean isFuel(ItemStack itemstack) { -@@ -483,14 +581,20 @@ +@@ -485,14 +583,20 @@ @Override public void awardUsedRecipes(EntityHuman entityhuman) {} @@ -193,7 +193,7 @@ List> list = Lists.newArrayList(); ObjectIterator objectiterator = this.recipesUsed.object2IntEntrySet().iterator(); -@@ -499,14 +603,14 @@ +@@ -501,14 +605,14 @@ worldserver.getRecipeManager().byKey((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> { list.add(irecipe); @@ -210,7 +210,7 @@ int j = MathHelper.floor((float) i * f); float f1 = MathHelper.frac((float) i * f); -@@ -514,6 +618,17 @@ +@@ -516,6 +620,17 @@ ++j; } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.patch b/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.patch index 6685ebccd9..0c6ef64321 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.java +++ b/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.java -@@ -37,6 +37,7 @@ - if (worldgenfeatureconfigured == null) { +@@ -38,6 +38,7 @@ + if (holder == null) { return false; } else { -+ setTreeType(worldgenfeatureconfigured); // CraftBukkit ++ setTreeType(holder); // CraftBukkit + WorldGenFeatureConfigured worldgenfeatureconfigured = (WorldGenFeatureConfigured) holder.value(); IBlockData iblockdata1 = Blocks.AIR.defaultBlockState(); - worldserver.setBlock(blockposition.offset(i, 0, j), iblockdata1, 4); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch b/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch index 691ad307e4..534dc37bf8 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch @@ -14,20 +14,20 @@ public WorldGenTreeProvider() {} @@ -26,6 +32,7 @@ - if (worldgenfeatureconfigured == null) { + if (holder == null) { return false; } else { -+ setTreeType(worldgenfeatureconfigured); // CraftBukkit ++ setTreeType(holder); // CraftBukkit + WorldGenFeatureConfigured worldgenfeatureconfigured = (WorldGenFeatureConfigured) holder.value(); + worldserver.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 4); - if (worldgenfeatureconfigured.place(worldserver, chunkgenerator, random, blockposition)) { - return true; -@@ -51,4 +58,48 @@ +@@ -53,4 +60,48 @@ return true; } + + // CraftBukkit start -+ protected void setTreeType(WorldGenFeatureConfigured worldgentreeabstract) { ++ protected void setTreeType(Holder> worldgentreeabstract) { + if (worldgentreeabstract == TreeFeatures.OAK || worldgentreeabstract == TreeFeatures.OAK_BEES_005) { + BlockSapling.treeType = TreeType.TREE; + } else if (worldgentreeabstract == TreeFeatures.HUGE_RED_MUSHROOM) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch b/paper-server/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch index dbe75e8377..58b40221d9 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/piston/BlockPiston.java +++ b/net/minecraft/world/level/block/piston/BlockPiston.java -@@ -38,6 +38,14 @@ +@@ -37,6 +37,14 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -15,7 +15,7 @@ public class BlockPiston extends BlockDirectional { public static final BlockStateBoolean EXTENDED = BlockProperties.EXTENDED; -@@ -138,6 +146,18 @@ +@@ -137,6 +145,18 @@ } } @@ -34,7 +34,7 @@ world.blockEvent(blockposition, this, b0, enumdirection.get3DDataValue()); } -@@ -316,6 +336,48 @@ +@@ -315,6 +335,48 @@ IBlockData[] aiblockdata = new IBlockData[list.size() + list2.size()]; EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.getOpposite(); int j = 0; 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 b6284ba702..4c5675d915 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 @@ -192,12 +192,3 @@ this.ticker = blockentityticker; } -@@ -775,7 +866,7 @@ - this.loggedInvalidBlockState = true; - Chunk.LOGGER.warn("Block entity {} @ {} state {} invalid for ticking:", new org.apache.logging.log4j.util.Supplier[]{this::getType, this::getPos, () -> { - return iblockdata; -- }}); -+ }}); // CraftBukkit - squelch checkstyle - } - - gameprofilerfiller.pop(); diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch index 8202a13726..2df08936ab 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,7 +1,16 @@ --- a/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/net/minecraft/world/level/chunk/ChunkGenerator.java -@@ -225,7 +225,7 @@ - } +@@ -261,7 +261,7 @@ + + while (iterator.hasNext()) { + Holder> holder = (Holder) iterator.next(); +- Stream stream = set1.stream(); ++ Stream> stream = set1.stream(); // CraftBukkit - decompile error + HolderSet holderset1 = ((StructureFeature) holder.value()).biomes(); + + Objects.requireNonNull(holderset1); +@@ -411,7 +411,7 @@ + return null; } - public void applyBiomeDecoration(GeneratorAccessSeed generatoraccessseed, IChunkAccess ichunkaccess, StructureManager structuremanager) { @@ -9,25 +18,25 @@ ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos(); if (!SharedConstants.debugVoidTerrain(chunkcoordintpair)) { -@@ -249,7 +249,7 @@ +@@ -427,7 +427,7 @@ + Set set = new ObjectArraySet(); - for (int k = 0; k < j; ++k) { - ChunkSection chunksection = achunksection[k]; -- DataPaletteBlock datapaletteblock = chunksection.getBiomes(); -+ DataPaletteBlock datapaletteblock = chunksection.getBiomes(); // CraftBukkit - decompile error + if (this instanceof ChunkProviderFlat) { +- Stream stream = this.biomeSource.possibleBiomes().stream().map(Holder::value); ++ Stream stream = this.biomeSource.possibleBiomes().stream().map(Holder::value); // CraftBukkit - decompile error - Objects.requireNonNull(set); - datapaletteblock.getAll(set::add); -@@ -278,7 +278,7 @@ - StructureGenerator structuregenerator = (StructureGenerator) iterator.next(); + Objects.requireNonNull(set); + stream.forEach(set::add); +@@ -467,7 +467,7 @@ + StructureFeature structurefeature = (StructureFeature) iterator.next(); seededrandom.setFeatureSeed(i, i1, l); - Supplier supplier = () -> { + Supplier supplier = () -> { // CraftBukkit - decompile error - Optional optional = iregistry1.getResourceKey(structuregenerator).map(Object::toString); + Optional optional = iregistry.getResourceKey(structurefeature).map(Object::toString); - Objects.requireNonNull(structuregenerator); -@@ -363,6 +363,33 @@ + Objects.requireNonNull(structurefeature); +@@ -552,6 +552,33 @@ } } @@ -58,15 +67,6 @@ + // CraftBukkit end + } + - private static StructureBoundingBox getWritableArea(IChunkAccess ichunkaccess) { - ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos(); - int i = chunkcoordintpair.getMinBlockX(); -@@ -438,7 +465,7 @@ + public boolean hasFeatureChunkInRange(ResourceKey resourcekey, long i, int j, int k, int l) { + StructureSet structureset = (StructureSet) this.structureSets.get(resourcekey); - Entry, Collection>> entry = (Entry) unmodifiableiterator.next(); - -- structurestart3 = ((StructureFeature) entry.getKey()).generate(iregistrycustom, this, this.biomeSource, definedstructuremanager, i, chunkcoordintpair, j, structuresettingsfeature1, ichunkaccess, (biomebase) -> { -+ structurestart3 = (entry.getKey()).generate(iregistrycustom, this, this.biomeSource, definedstructuremanager, i, chunkcoordintpair, j, structuresettingsfeature1, ichunkaccess, (biomebase) -> { // CraftBukkit - decompile error - Collection collection = (Collection) entry.getValue(); - - Objects.requireNonNull(collection); diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch index 9a32216ab8..4da2d4f0a7 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/chunk/ChunkSection.java +++ b/net/minecraft/world/level/chunk/ChunkSection.java -@@ -176,6 +176,12 @@ - return (BiomeBase) this.biomes.get(i, j, k); +@@ -190,6 +190,12 @@ + return (Holder) this.biomes.get(i, j, k); } + // CraftBukkit start -+ public void setBiome(int i, int j, int k, BiomeBase biome) { ++ public void setBiome(int i, int j, int k, Holder biome) { + this.biomes.set(i, j, k, biome); + } + // CraftBukkit end + public void fillBiomesFromNoise(BiomeResolver biomeresolver, Climate.Sampler climate_sampler, int i, int j) { - DataPaletteBlock datapaletteblock = this.getBiomes(); + DataPaletteBlock> datapaletteblock = this.getBiomes(); 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 408bb1f959..97f67f4eec 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/IChunkAccess.java +++ b/net/minecraft/world/level/chunk/IChunkAccess.java -@@ -77,6 +77,11 @@ +@@ -80,6 +80,11 @@ protected final LevelHeightAccessor levelHeightAccessor; protected final ChunkSection[] sections; @@ -12,7 +12,7 @@ public IChunkAccess(ChunkCoordIntPair chunkcoordintpair, ChunkConverter chunkconverter, LevelHeightAccessor levelheightaccessor, IRegistry iregistry, long i, @Nullable ChunkSection[] achunksection, @Nullable BlendingData blendingdata) { this.chunkPos = chunkcoordintpair; this.upgradeData = chunkconverter; -@@ -94,7 +99,11 @@ +@@ -97,7 +102,11 @@ } replaceMissingSections(levelheightaccessor, iregistry, this.sections); @@ -24,7 +24,7 @@ private static void replaceMissingSections(LevelHeightAccessor levelheightaccessor, IRegistry iregistry, ChunkSection[] achunksection) { for (int i = 0; i < achunksection.length; ++i) { -@@ -258,10 +267,11 @@ +@@ -259,10 +268,11 @@ public void setUnsaved(boolean flag) { this.unsaved = flag; @@ -37,12 +37,12 @@ } public abstract ChunkStatus getStatus(); -@@ -394,6 +404,27 @@ +@@ -395,6 +405,27 @@ } } + // CraftBukkit start -+ public void setBiome(int i, int j, int k, BiomeBase biome) { ++ public void setBiome(int i, int j, int k, Holder biome) { + try { + int l = QuartPos.fromBlock(this.getMinBuildHeight()); + int i1 = l + QuartPos.fromBlock(this.getHeight()) - 1; @@ -65,7 +65,7 @@ public void fillBiomesFromNoise(BiomeResolver biomeresolver, Climate.Sampler climate_sampler) { ChunkCoordIntPair chunkcoordintpair = this.getPos(); int i = QuartPos.fromBlock(chunkcoordintpair.getMinBlockX()); -@@ -425,8 +456,10 @@ +@@ -426,8 +457,10 @@ return this; } @@ -77,7 +77,7 @@ private final SerializableTickContainer blocks; private final SerializableTickContainer fluids; -@@ -442,5 +475,7 @@ +@@ -443,5 +476,7 @@ public SerializableTickContainer fluids() { return this.fluids; } diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch index fa3f814bc7..9c695b4d2c 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch @@ -1,15 +1,42 @@ --- a/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java +++ b/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java -@@ -190,7 +190,7 @@ +@@ -117,7 +117,7 @@ + }); + logger = ChunkRegionLoader.LOGGER; + Objects.requireNonNull(logger); +- datapaletteblock = (DataPaletteBlock) dataresult.getOrThrow(false, logger::error); ++ datapaletteblock = (DataPaletteBlock) ((DataResult>) dataresult).getOrThrow(false, logger::error); // CraftBukkit - decompile error + } else { + datapaletteblock = new DataPaletteBlock<>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), DataPaletteBlock.e.SECTION_STATES); + } +@@ -130,7 +130,7 @@ + }); + logger = ChunkRegionLoader.LOGGER; + Objects.requireNonNull(logger); +- datapaletteblock1 = (DataPaletteBlock) dataresult.getOrThrow(false, logger::error); ++ datapaletteblock1 = (DataPaletteBlock) ((DataResult>>) dataresult).getOrThrow(false, logger::error); // CraftBukkit - decompile error + } else { + datapaletteblock1 = new DataPaletteBlock<>(iregistry.asHolderIdMap(), iregistry.getHolderOrThrow(Biomes.PLAINS), DataPaletteBlock.e.SECTION_BIOMES); + } +@@ -161,7 +161,7 @@ + dataresult = BlendingData.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("blending_data"))); + logger1 = ChunkRegionLoader.LOGGER; + Objects.requireNonNull(logger1); +- blendingdata = (BlendingData) dataresult.resultOrPartial(logger1::error).orElse((Object) null); ++ blendingdata = (BlendingData) ((DataResult) dataresult).resultOrPartial(logger1::error).orElse(null); // CraftBukkit - decompile error + } else { + blendingdata = null; + } +@@ -192,7 +192,7 @@ dataresult = BelowZeroRetrogen.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("below_zero_retrogen"))); logger1 = ChunkRegionLoader.LOGGER; Objects.requireNonNull(logger1); - Optional optional = dataresult.resultOrPartial(logger1::error); -+ Optional optional = dataresult.resultOrPartial(logger1::error); // CraftBukkit - decompile error ++ Optional optional = ((DataResult) dataresult).resultOrPartial(logger1::error); // CraftBukkit - decompile error Objects.requireNonNull(protochunk); optional.ifPresent(protochunk::setBelowZeroRetrogen); -@@ -219,6 +219,13 @@ +@@ -221,6 +221,13 @@ } } @@ -23,7 +50,7 @@ ((IChunkAccess) object).setLightCorrect(flag); NBTTagCompound nbttagcompound2 = nbttagcompound.getCompound("Heightmaps"); EnumSet enumset = EnumSet.noneOf(HeightMap.Type.class); -@@ -321,7 +328,7 @@ +@@ -323,7 +330,7 @@ nbttagcompound.putLong("InhabitedTime", ichunkaccess.getInhabitedTime()); nbttagcompound.putString("Status", ichunkaccess.getStatus().getName()); BlendingData blendingdata = ichunkaccess.getBlendingData(); @@ -32,7 +59,16 @@ Logger logger; if (blendingdata != null) { -@@ -452,6 +459,11 @@ +@@ -370,7 +377,7 @@ + + if (flag1) { + ChunkSection chunksection = achunksection[j]; +- DataResult dataresult1 = ChunkRegionLoader.BLOCK_STATE_CODEC.encodeStart(DynamicOpsNBT.INSTANCE, chunksection.getStates()); ++ DataResult dataresult1 = ChunkRegionLoader.BLOCK_STATE_CODEC.encodeStart(DynamicOpsNBT.INSTANCE, chunksection.getStates()); // CraftBukkit - decompile error + Logger logger1 = ChunkRegionLoader.LOGGER; + + Objects.requireNonNull(logger1); +@@ -454,6 +461,11 @@ nbttagcompound.put("Heightmaps", nbttagcompound3); nbttagcompound.put("structures", packStructureData(StructurePieceSerializationContext.fromLevel(worldserver), chunkcoordintpair, ichunkaccess.getAllStarts(), ichunkaccess.getAllReferences())); diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/RegionFile.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/RegionFile.patch index 0dc4f280cf..f9394a9a46 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/RegionFile.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/RegionFile.patch @@ -32,7 +32,7 @@ - bytebuffer.flip(); + ((java.nio.Buffer) bytebuffer).flip(); // CraftBukkit - decompile error if (bytebuffer.remaining() < 5) { - RegionFile.LOGGER.error("Chunk {} header is truncated: expected {} but read {}", chunkcoordintpair, l, bytebuffer.remaining()); + RegionFile.LOGGER.error("Chunk {} header is truncated: expected {} but read {}", new Object[]{chunkcoordintpair, l, bytebuffer.remaining()}); return null; @@ -224,7 +225,7 @@ diff --git a/paper-server/nms-patches/net/minecraft/world/level/entity/PersistentEntitySectionManager.patch b/paper-server/nms-patches/net/minecraft/world/level/entity/PersistentEntitySectionManager.patch index f775e8dd0a..1892deeaaa 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/entity/PersistentEntitySectionManager.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/entity/PersistentEntitySectionManager.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/entity/PersistentEntitySectionManager.java +++ b/net/minecraft/world/level/entity/PersistentEntitySectionManager.java @@ -32,6 +32,11 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import net.minecraft.world.level.ChunkCoordIntPair; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.world.level.chunk.storage.EntityStorage; @@ -11,7 +11,7 @@ + public class PersistentEntitySectionManager implements AutoCloseable { - static final Logger LOGGER = LogManager.getLogger(); + static final Logger LOGGER = LogUtils.getLogger(); @@ -55,6 +60,16 @@ this.entityGetter = new LevelEntityGetterAdapter<>(this.visibleEntityStorage, this.sectionStorage); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationListener.patch b/paper-server/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationListener.patch index f0e742de2f..6b4ce3a0cd 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationListener.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationListener.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/gameevent/vibrations/VibrationListener.java +++ b/net/minecraft/world/level/gameevent/vibrations/VibrationListener.java -@@ -18,6 +18,13 @@ +@@ -16,6 +16,13 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.Vec3D; @@ -14,7 +14,7 @@ public class VibrationListener implements GameEventListener { protected final PositionSource listenerSource; -@@ -67,7 +74,13 @@ +@@ -65,7 +72,13 @@ } else { BlockPosition blockposition1 = (BlockPosition) optional.get(); diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.patch index 3652c99460..66b9188338 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.patch @@ -4,4 +4,4 @@ +// keep package net.minecraft.world.level.levelgen; - import com.google.common.collect.ImmutableList; + import com.google.common.collect.Sets; diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/GeneratorSettings.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/GeneratorSettings.patch deleted file mode 100644 index 694056c773..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/GeneratorSettings.patch +++ /dev/null @@ -1,45 +0,0 @@ ---- a/net/minecraft/world/level/levelgen/GeneratorSettings.java -+++ b/net/minecraft/world/level/levelgen/GeneratorSettings.java -@@ -35,9 +35,14 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - -+// CraftBukkit start -+import net.minecraft.resources.RegistryReadOps; -+import net.minecraft.server.packs.resources.IResourceManager; -+// CraftBukkit end -+ - public class GeneratorSettings { - -- public static final Codec CODEC = RecordCodecBuilder.create((instance) -> { -+ public static final Codec CODEC = RecordCodecBuilder.create((instance) -> { // CraftBukkit - decompile error - return instance.group(Codec.LONG.fieldOf("seed").stable().forGetter(GeneratorSettings::seed), Codec.BOOL.fieldOf("generate_features").orElse(true).stable().forGetter(GeneratorSettings::generateFeatures), Codec.BOOL.fieldOf("bonus_chest").orElse(false).stable().forGetter(GeneratorSettings::generateBonusChest), RegistryMaterials.dataPackCodec(IRegistry.LEVEL_STEM_REGISTRY, Lifecycle.stable(), WorldDimension.CODEC).xmap(WorldDimension::sortMap, Function.identity()).fieldOf("dimensions").forGetter(GeneratorSettings::dimensions), Codec.STRING.optionalFieldOf("legacy_custom_options").stable().forGetter((generatorsettings) -> { - return generatorsettings.legacyCustomOptions; - })).apply(instance, instance.stable(GeneratorSettings::new)); -@@ -130,7 +135,7 @@ - public static RegistryMaterials withOverworld(RegistryMaterials registrymaterials, Supplier supplier, ChunkGenerator chunkgenerator) { - RegistryMaterials registrymaterials1 = new RegistryMaterials<>(IRegistry.LEVEL_STEM_REGISTRY, Lifecycle.experimental()); - -- registrymaterials1.register(WorldDimension.OVERWORLD, (Object) (new WorldDimension(supplier, chunkgenerator)), Lifecycle.stable()); -+ registrymaterials1.register(WorldDimension.OVERWORLD, (new WorldDimension(supplier, chunkgenerator)), Lifecycle.stable()); // CraftBukkit - decompile error - Iterator iterator = registrymaterials.entrySet().iterator(); - - while (iterator.hasNext()) { -@@ -138,7 +143,7 @@ - ResourceKey resourcekey = (ResourceKey) entry.getKey(); - - if (resourcekey != WorldDimension.OVERWORLD) { -- registrymaterials1.register(resourcekey, (Object) ((WorldDimension) entry.getValue()), registrymaterials.lifecycle((WorldDimension) entry.getValue())); -+ registrymaterials1.register(resourcekey, ((WorldDimension) entry.getValue()), registrymaterials.lifecycle((WorldDimension) entry.getValue())); // CraftBukkit - decompile error - } - } - -@@ -256,7 +261,7 @@ - switch (b0) { - case 0: - JsonObject jsonobject = !s.isEmpty() ? ChatDeserializer.parse(s) : new JsonObject(); -- Dynamic dynamic = new Dynamic(JsonOps.INSTANCE, jsonobject); -+ Dynamic dynamic = new Dynamic(RegistryReadOps.createAndLoad(JsonOps.INSTANCE, IResourceManager.Empty.INSTANCE, (IRegistryCustom.Dimension) iregistrycustom), jsonobject); // CraftBukkit - SPIGOT-6237 - DataResult dataresult = GeneratorSettingsFlat.CODEC.parse(dynamic); - Logger logger = GeneratorSettings.LOGGER; - diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch index dff62de181..4320791a07 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/MobSpawnerPatrol.java +++ b/net/minecraft/world/level/levelgen/MobSpawnerPatrol.java -@@ -116,7 +116,7 @@ +@@ -117,7 +117,7 @@ entitymonsterpatrolling.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); entitymonsterpatrolling.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(blockposition), EnumMobSpawn.PATROL, (GroupDataEntity) null, (NBTTagCompound) null); diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/StructureSettings.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/StructureSettings.patch deleted file mode 100644 index fd34a6d157..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/StructureSettings.patch +++ /dev/null @@ -1,50 +0,0 @@ ---- a/net/minecraft/world/level/levelgen/StructureSettings.java -+++ b/net/minecraft/world/level/levelgen/StructureSettings.java -@@ -1,3 +1,4 @@ -+// mc-dev import - package net.minecraft.world.level.levelgen; - - import com.google.common.annotations.VisibleForTesting; -@@ -31,7 +32,8 @@ - return structuresettings.structureConfig; - })).apply(instance, StructureSettings::new); - }); -- public static final ImmutableMap, StructureSettingsFeature> DEFAULTS = ImmutableMap.builder().put(StructureGenerator.VILLAGE, new StructureSettingsFeature(34, 8, 10387312)).put(StructureGenerator.DESERT_PYRAMID, new StructureSettingsFeature(32, 8, 14357617)).put(StructureGenerator.IGLOO, new StructureSettingsFeature(32, 8, 14357618)).put(StructureGenerator.JUNGLE_TEMPLE, new StructureSettingsFeature(32, 8, 14357619)).put(StructureGenerator.SWAMP_HUT, new StructureSettingsFeature(32, 8, 14357620)).put(StructureGenerator.PILLAGER_OUTPOST, new StructureSettingsFeature(32, 8, 165745296)).put(StructureGenerator.STRONGHOLD, new StructureSettingsFeature(1, 0, 0)).put(StructureGenerator.OCEAN_MONUMENT, new StructureSettingsFeature(32, 5, 10387313)).put(StructureGenerator.END_CITY, new StructureSettingsFeature(20, 11, 10387313)).put(StructureGenerator.WOODLAND_MANSION, new StructureSettingsFeature(80, 20, 10387319)).put(StructureGenerator.BURIED_TREASURE, new StructureSettingsFeature(1, 0, 0)).put(StructureGenerator.MINESHAFT, new StructureSettingsFeature(1, 0, 0)).put(StructureGenerator.RUINED_PORTAL, new StructureSettingsFeature(40, 15, 34222645)).put(StructureGenerator.SHIPWRECK, new StructureSettingsFeature(24, 4, 165745295)).put(StructureGenerator.OCEAN_RUIN, new StructureSettingsFeature(20, 8, 14357621)).put(StructureGenerator.BASTION_REMNANT, new StructureSettingsFeature(27, 4, 30084232)).put(StructureGenerator.NETHER_BRIDGE, new StructureSettingsFeature(27, 4, 30084232)).put(StructureGenerator.NETHER_FOSSIL, new StructureSettingsFeature(2, 1, 14357921)).build(); -+ // CraftBukkit - decompile error -+ public static final ImmutableMap, StructureSettingsFeature> DEFAULTS = ImmutableMap., StructureSettingsFeature>builder().put(StructureGenerator.VILLAGE, new StructureSettingsFeature(34, 8, 10387312)).put(StructureGenerator.DESERT_PYRAMID, new StructureSettingsFeature(32, 8, 14357617)).put(StructureGenerator.IGLOO, new StructureSettingsFeature(32, 8, 14357618)).put(StructureGenerator.JUNGLE_TEMPLE, new StructureSettingsFeature(32, 8, 14357619)).put(StructureGenerator.SWAMP_HUT, new StructureSettingsFeature(32, 8, 14357620)).put(StructureGenerator.PILLAGER_OUTPOST, new StructureSettingsFeature(32, 8, 165745296)).put(StructureGenerator.STRONGHOLD, new StructureSettingsFeature(1, 0, 0)).put(StructureGenerator.OCEAN_MONUMENT, new StructureSettingsFeature(32, 5, 10387313)).put(StructureGenerator.END_CITY, new StructureSettingsFeature(20, 11, 10387313)).put(StructureGenerator.WOODLAND_MANSION, new StructureSettingsFeature(80, 20, 10387319)).put(StructureGenerator.BURIED_TREASURE, new StructureSettingsFeature(1, 0, 0)).put(StructureGenerator.MINESHAFT, new StructureSettingsFeature(1, 0, 0)).put(StructureGenerator.RUINED_PORTAL, new StructureSettingsFeature(40, 15, 34222645)).put(StructureGenerator.SHIPWRECK, new StructureSettingsFeature(24, 4, 165745295)).put(StructureGenerator.OCEAN_RUIN, new StructureSettingsFeature(20, 8, 14357621)).put(StructureGenerator.BASTION_REMNANT, new StructureSettingsFeature(27, 4, 30084232)).put(StructureGenerator.NETHER_BRIDGE, new StructureSettingsFeature(27, 4, 30084232)).put(StructureGenerator.NETHER_FOSSIL, new StructureSettingsFeature(2, 1, 14357921)).build(); - public static final StructureSettingsStronghold DEFAULT_STRONGHOLD; - private final Map, StructureSettingsFeature> structureConfig; - private final ImmutableMap, ImmutableMultimap, ResourceKey>> configuredStructures; -@@ -54,7 +56,7 @@ - } - - public StructureSettings(Optional optional, Map, StructureSettingsFeature> map) { -- this(map, (StructureSettingsStronghold) optional.orElse((Object) null)); -+ this(map, (StructureSettingsStronghold) optional.orElse(null)); // CraftBukkit - decompile error - } - - public StructureSettings(boolean flag) { -@@ -81,6 +83,15 @@ - } - - static { -+ // CraftBukkit - decompile error start -+ DEFAULT_STRONGHOLD = new StructureSettingsStronghold(32, 3, 128); -+ -+ for (StructureGenerator structuregenerator : IRegistry.STRUCTURE_FEATURE) { -+ if (!StructureSettings.DEFAULTS.containsKey(structuregenerator)) { -+ throw new IllegalStateException("Structure feature without default settings: " + IRegistry.STRUCTURE_FEATURE.getKey(structuregenerator)); -+ } -+ } -+ /* - Iterator iterator = IRegistry.STRUCTURE_FEATURE.iterator(); - - StructureGenerator structuregenerator; -@@ -95,5 +106,7 @@ - } while (StructureSettings.DEFAULTS.containsKey(structuregenerator)); - - throw new IllegalStateException("Structure feature without default settings: " + IRegistry.STRUCTURE_FEATURE.getKey(structuregenerator)); -+ */ -+ // CraftBukkit - decompile error end - } - } diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch index 380b7109c6..a519e64a8a 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.java +++ b/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.java @@ -20,6 +20,10 @@ - import net.minecraft.world.level.levelgen.feature.StructureGenerator; + import net.minecraft.world.level.World; import net.minecraft.world.level.storage.WorldPersistentData; +// CraftBukkit start @@ -11,7 +11,7 @@ public class PersistentStructureLegacy { private static final Map CURRENT_TO_LEGACY_MAP = (Map) SystemUtils.make(Maps.newHashMap(), (hashmap) -> { -@@ -234,16 +238,16 @@ +@@ -235,16 +239,16 @@ } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch b/paper-server/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch index 5ff4f33703..ea22096e12 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/material/FluidTypeFlowing.java +++ b/net/minecraft/world/level/material/FluidTypeFlowing.java -@@ -31,6 +31,15 @@ +@@ -30,6 +30,15 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -16,7 +16,7 @@ public abstract class FluidTypeFlowing extends FluidType { public static final BlockStateBoolean FALLING = BlockProperties.FALLING; -@@ -131,6 +140,15 @@ +@@ -130,6 +139,15 @@ Fluid fluid1 = this.getNewLiquid(generatoraccess, blockposition1, iblockdata1); if (this.canSpreadTo(generatoraccess, blockposition, iblockdata, EnumDirection.DOWN, blockposition1, iblockdata1, generatoraccess.getFluidState(blockposition1), fluid1.getType())) { @@ -32,7 +32,7 @@ this.spreadTo(generatoraccess, blockposition1, iblockdata1, EnumDirection.DOWN, fluid1); if (this.sourceNeighborCount(generatoraccess, blockposition) >= 3) { this.spreadToSides(generatoraccess, blockposition, fluid, iblockdata); -@@ -161,6 +179,15 @@ +@@ -160,6 +178,15 @@ IBlockData iblockdata1 = generatoraccess.getBlockState(blockposition1); if (this.canSpreadTo(generatoraccess, blockposition, iblockdata, enumdirection, blockposition1, iblockdata1, generatoraccess.getFluidState(blockposition1), fluid1.getType())) { @@ -48,7 +48,7 @@ this.spreadTo(generatoraccess, blockposition1, iblockdata1, enumdirection, fluid1); } } -@@ -439,12 +466,23 @@ +@@ -438,12 +465,23 @@ if (fluid1.isEmpty()) { fluid = fluid1; diff --git a/paper-server/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch b/paper-server/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch index 9fd0b9b13c..d696818519 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/material/FluidTypeLava.java +++ b/net/minecraft/world/level/material/FluidTypeLava.java -@@ -85,6 +85,13 @@ +@@ -84,6 +84,13 @@ if (iblockdata.isAir()) { if (this.hasFlammableNeighbours(world, blockposition1)) { @@ -14,7 +14,7 @@ world.setBlockAndUpdate(blockposition1, BlockFireAbstract.getState(world, blockposition1)); return; } -@@ -101,6 +108,14 @@ +@@ -100,6 +107,14 @@ } if (world.isEmptyBlock(blockposition2.above()) && this.isFlammable(world, blockposition2)) { @@ -29,9 +29,9 @@ world.setBlockAndUpdate(blockposition2.above(), BlockFireAbstract.getState(world, blockposition2)); } } -@@ -196,7 +211,11 @@ +@@ -195,7 +210,11 @@ - if (this.is(TagsFluid.LAVA) && fluid1.is((Tag) TagsFluid.WATER)) { + if (this.is(TagsFluid.LAVA) && fluid1.is(TagsFluid.WATER)) { if (iblockdata.getBlock() instanceof BlockFluids) { - generatoraccess.setBlock(blockposition, Blocks.STONE.defaultBlockState(), 3); + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch b/paper-server/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch index c9c196742e..d507c88975 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/portal/BlockPortalShape.java +++ b/net/minecraft/world/level/portal/BlockPortalShape.java -@@ -19,6 +19,11 @@ +@@ -18,6 +18,11 @@ import net.minecraft.world.level.block.state.properties.BlockProperties; import net.minecraft.world.phys.Vec3D; @@ -12,7 +12,7 @@ public class BlockPortalShape { private static final int MIN_WIDTH = 2; -@@ -36,6 +41,7 @@ +@@ -35,6 +40,7 @@ private BlockPosition bottomLeft; private int height; private final int width; @@ -20,7 +20,7 @@ public static Optional findEmptyPortalShape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { return findPortalShape(generatoraccess, blockposition, (blockportalshape) -> { -@@ -56,6 +62,7 @@ +@@ -55,6 +61,7 @@ } public BlockPortalShape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { @@ -28,7 +28,7 @@ this.level = generatoraccess; this.axis = enumdirection_enumaxis; this.rightDir = enumdirection_enumaxis == EnumDirection.EnumAxis.X ? EnumDirection.WEST : EnumDirection.SOUTH; -@@ -100,6 +107,7 @@ +@@ -99,6 +106,7 @@ if (!isEmpty(iblockdata)) { if (BlockPortalShape.FRAME.test(iblockdata, this.level, blockposition_mutableblockposition)) { @@ -36,7 +36,7 @@ return i; } break; -@@ -110,6 +118,7 @@ +@@ -109,6 +117,7 @@ if (!BlockPortalShape.FRAME.test(iblockdata1, this.level, blockposition_mutableblockposition)) { break; } @@ -44,7 +44,7 @@ } return 0; -@@ -129,6 +138,7 @@ +@@ -128,6 +137,7 @@ if (!BlockPortalShape.FRAME.test(this.level.getBlockState(blockposition_mutableblockposition1), this.level, blockposition_mutableblockposition1)) { return false; } @@ -52,7 +52,7 @@ } return true; -@@ -158,6 +168,10 @@ +@@ -157,6 +167,10 @@ ++this.numPortalBlocks; } } @@ -63,7 +63,7 @@ } return 21; -@@ -171,12 +185,28 @@ +@@ -170,12 +184,28 @@ return this.bottomLeft != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; } @@ -93,7 +93,7 @@ } public boolean isComplete() { -@@ -213,7 +243,7 @@ +@@ -212,7 +242,7 @@ return new Vec3D(d2, d3, d4); } @@ -102,7 +102,7 @@ BlockPosition blockposition = blockutil_rectangle.minCorner; IBlockData iblockdata = worldserver.getBlockState(blockposition); EnumDirection.EnumAxis enumdirection_enumaxis1 = (EnumDirection.EnumAxis) iblockdata.getOptionalValue(BlockProperties.HORIZONTAL_AXIS).orElse(EnumDirection.EnumAxis.X); -@@ -227,6 +257,6 @@ +@@ -226,6 +256,6 @@ boolean flag = enumdirection_enumaxis1 == EnumDirection.EnumAxis.X; Vec3D vec3d3 = new Vec3D((double) blockposition.getX() + (flag ? d2 : d4), (double) blockposition.getY() + d3, (double) blockposition.getZ() + (flag ? d4 : d2)); diff --git a/paper-server/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch b/paper-server/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch index 278510d586..9f0894cb9c 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/saveddata/maps/WorldMap.java +++ b/net/minecraft/world/level/saveddata/maps/WorldMap.java @@ -31,6 +31,16 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import net.minecraft.world.level.saveddata.PersistentBase; + import org.slf4j.Logger; +// CraftBukkit start +import java.util.UUID; @@ -16,7 +16,7 @@ + public class WorldMap extends PersistentBase { - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); @@ -53,6 +63,13 @@ private final Map frameMarkers = Maps.newHashMap(); private int trackedDecorationCount; @@ -42,14 +42,19 @@ } public static WorldMap createFresh(double d0, double d1, byte b0, boolean flag, boolean flag1, ResourceKey resourcekey) { -@@ -83,8 +104,26 @@ +@@ -79,12 +100,30 @@ + } + + public static WorldMap load(NBTTagCompound nbttagcompound) { +- DataResult dataresult = DimensionManager.parseLegacy(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("dimension"))); ++ DataResult> dataresult = DimensionManager.parseLegacy(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("dimension"))); // CraftBukkit - decompile error Logger logger = WorldMap.LOGGER; Objects.requireNonNull(logger); - ResourceKey resourcekey = (ResourceKey) dataresult.resultOrPartial(logger::error).orElseThrow(() -> { - return new IllegalArgumentException("Invalid map dimension: " + nbttagcompound.get("dimension")); + // CraftBukkit start -+ ResourceKey resourcekey = (ResourceKey) dataresult.resultOrPartial(logger::error).orElseGet(() -> { ++ ResourceKey resourcekey = dataresult.resultOrPartial(logger::error).orElseGet(() -> { + long least = nbttagcompound.getLong("UUIDLeast"); + long most = nbttagcompound.getLong("UUIDMost"); + diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/Convertable.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/Convertable.patch index a06bdcce7d..3bebbce6bc 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/Convertable.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/Convertable.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/storage/Convertable.java +++ b/net/minecraft/world/level/storage/Convertable.java -@@ -56,6 +56,10 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -58,6 +58,10 @@ + import net.minecraft.world.level.levelgen.GeneratorSettings; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.world.level.dimension.WorldDimension; @@ -10,21 +10,30 @@ + public class Convertable { - static final Logger LOGGER = LogManager.getLogger(); -@@ -216,7 +220,11 @@ - LevelVersion levelversion = LevelVersion.parse(dynamic); - WorldSettings worldsettings = WorldSettings.parse(dynamic, datapackconfiguration); + static final Logger LOGGER = LogUtils.getLogger(); +@@ -112,7 +116,7 @@ + } -- return WorldDataServer.parse(dynamic, datafixer, i, nbttagcompound2, worldsettings, levelversion, (GeneratorSettings) pair.getFirst(), (Lifecycle) pair.getSecond()); + private static DataPackConfiguration readDataPackConfig(Dynamic dynamic) { +- DataResult dataresult = DataPackConfiguration.CODEC.parse(dynamic); ++ DataResult dataresult = DataPackConfiguration.CODEC.parse(dynamic); // CraftBukkit - decompile error + Logger logger = Convertable.LOGGER; + + Objects.requireNonNull(logger); +@@ -232,7 +236,11 @@ + WorldSettings worldsettings = WorldSettings.parse(dynamic, datapackconfiguration); + Lifecycle lifecycle1 = ((Lifecycle) pair.getSecond()).add(lifecycle); + +- return WorldDataServer.parse(dynamic, datafixer, i, nbttagcompound2, worldsettings, levelversion, (GeneratorSettings) pair.getFirst(), lifecycle1); + // CraftBukkit start - Add PDC to world -+ WorldDataServer worldDataServer = WorldDataServer.parse(dynamic, datafixer, i, nbttagcompound2, worldsettings, levelversion, (GeneratorSettings) pair.getFirst(), (Lifecycle) pair.getSecond()); ++ WorldDataServer worldDataServer = WorldDataServer.parse(dynamic, datafixer, i, nbttagcompound2, worldsettings, levelversion, (GeneratorSettings) pair.getFirst(), lifecycle1); + worldDataServer.pdc = nbttagcompound1.get("BukkitValues"); + return worldDataServer; + // CraftBukkit end } catch (Exception exception) { Convertable.LOGGER.error("Exception reading {}", file, exception); return null; -@@ -277,9 +285,23 @@ +@@ -305,9 +313,23 @@ return this.backupDir; } @@ -50,7 +59,7 @@ public class ConversionSession implements AutoCloseable { -@@ -287,8 +309,12 @@ +@@ -315,8 +337,12 @@ public final Path levelPath; private final String levelId; private final Map resources = Maps.newHashMap(); @@ -64,7 +73,7 @@ this.levelId = s; this.levelPath = Convertable.this.baseDir.resolve(s); this.lock = SessionLock.create(this.levelPath); -@@ -305,7 +331,7 @@ +@@ -333,7 +359,7 @@ } public Path getDimensionPath(ResourceKey resourcekey) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch index 0234dffaad..1fa78fec1f 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/storage/WorldDataServer.java +++ b/net/minecraft/world/level/storage/WorldDataServer.java -@@ -40,6 +40,15 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -41,6 +41,15 @@ + import net.minecraft.world.level.timers.CustomFunctionCallbackTimers; + import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.network.protocol.game.PacketPlayOutServerDifficulty; @@ -15,8 +15,8 @@ + public class WorldDataServer implements IWorldDataServer, SaveData { - private static final Logger LOGGER = LogManager.getLogger(); -@@ -78,6 +87,19 @@ + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -80,6 +89,19 @@ private final Set knownServerBrands; private boolean wasModded; private final CustomFunctionCallbackTimerQueue scheduledEvents; @@ -36,17 +36,17 @@ private WorldDataServer(@Nullable DataFixer datafixer, int i, @Nullable NBTTagCompound nbttagcompound, boolean flag, int j, int k, int l, float f, long i1, long j1, int k1, int l1, int i2, boolean flag1, int j2, boolean flag2, boolean flag3, boolean flag4, WorldBorder.c worldborder_c, int k2, int l2, @Nullable UUID uuid, Set set, CustomFunctionCallbackTimerQueue customfunctioncallbacktimerqueue, @Nullable NBTTagCompound nbttagcompound1, NBTTagCompound nbttagcompound2, WorldSettings worldsettings, GeneratorSettings generatorsettings, Lifecycle lifecycle) { this.fixerUpper = datafixer; -@@ -121,7 +143,8 @@ +@@ -123,7 +145,8 @@ return (NBTBase) dynamic.get("DimensionData").get("1").get("DragonFight").orElseEmptyMap().getValue(); }); - return new WorldDataServer(datafixer, i, nbttagcompound, dynamic.get("WasModded").asBoolean(false), dynamic.get("SpawnX").asInt(0), dynamic.get("SpawnY").asInt(0), dynamic.get("SpawnZ").asInt(0), dynamic.get("SpawnAngle").asFloat(0.0F), j, dynamic.get("DayTime").asLong(j), levelversion.levelDataVersion(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.read(dynamic, WorldBorder.DEFAULT_SETTINGS), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(MinecraftSerializableUUID.CODEC).result().orElse((Object) null), (Set) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> { + // CraftBukkit - decompile error + return new WorldDataServer(datafixer, i, nbttagcompound, dynamic.get("WasModded").asBoolean(false), dynamic.get("SpawnX").asInt(0), dynamic.get("SpawnY").asInt(0), dynamic.get("SpawnZ").asInt(0), dynamic.get("SpawnAngle").asFloat(0.0F), j, dynamic.get("DayTime").asLong(j), levelversion.levelDataVersion(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.read(dynamic, WorldBorder.DEFAULT_SETTINGS), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(MinecraftSerializableUUID.CODEC).result().orElse(null), (Set) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> { - return SystemUtils.toStream(dynamic1.asString().result()); + return dynamic1.asString().result().stream(); }).collect(Collectors.toCollection(Sets::newLinkedHashSet)), new CustomFunctionCallbackTimerQueue<>(CustomFunctionCallbackTimers.SERVER_CALLBACKS, dynamic.get("ScheduledEvents").asStream()), (NBTTagCompound) dynamic.get("CustomBossEvents").orElseEmptyMap().getValue(), nbttagcompound1, worldsettings, generatorsettings, lifecycle); } -@@ -141,7 +164,7 @@ +@@ -143,7 +166,7 @@ private void setTagData(IRegistryCustom iregistrycustom, NBTTagCompound nbttagcompound, @Nullable NBTTagCompound nbttagcompound1) { NBTTagList nbttaglist = new NBTTagList(); @@ -55,16 +55,16 @@ Objects.requireNonNull(nbttaglist); stream.forEach(nbttaglist::add); -@@ -156,7 +179,7 @@ +@@ -158,7 +181,7 @@ nbttagcompound.put("Version", nbttagcompound2); nbttagcompound.putInt("DataVersion", SharedConstants.getCurrentVersion().getWorldVersion()); - RegistryWriteOps registrywriteops = RegistryWriteOps.create(DynamicOpsNBT.INSTANCE, iregistrycustom); -- DataResult dataresult = GeneratorSettings.CODEC.encodeStart(registrywriteops, this.worldGenSettings); -+ DataResult dataresult = GeneratorSettings.CODEC.encodeStart(registrywriteops, this.worldGenSettings); // CraftBukkit - decompile error + DynamicOps dynamicops = RegistryOps.create(DynamicOpsNBT.INSTANCE, iregistrycustom); +- DataResult dataresult = GeneratorSettings.CODEC.encodeStart(dynamicops, this.worldGenSettings); ++ DataResult dataresult = GeneratorSettings.CODEC.encodeStart(dynamicops, this.worldGenSettings); // CraftBukkit - decompile error Logger logger = WorldDataServer.LOGGER; Objects.requireNonNull(logger); -@@ -204,6 +227,8 @@ +@@ -206,6 +229,8 @@ nbttagcompound.putUUID("WanderingTraderId", this.wanderingTraderId); } @@ -73,7 +73,7 @@ } @Override -@@ -321,6 +346,20 @@ +@@ -323,6 +348,20 @@ @Override public void setThundering(boolean flag) { @@ -94,7 +94,7 @@ this.thundering = flag; } -@@ -341,6 +380,20 @@ +@@ -343,6 +382,20 @@ @Override public void setRaining(boolean flag) { @@ -115,7 +115,7 @@ this.raining = flag; } -@@ -407,6 +460,12 @@ +@@ -409,6 +462,12 @@ @Override public void setDifficulty(EnumDifficulty enumdifficulty) { this.settings = this.settings.withDifficulty(enumdifficulty); @@ -128,7 +128,7 @@ } @Override -@@ -527,4 +586,12 @@ +@@ -529,4 +588,12 @@ public WorldSettings getLevelSettings() { return this.settings.copy(); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/WorldNBTStorage.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/WorldNBTStorage.patch index 387e09fb6c..54680bac3b 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/WorldNBTStorage.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/WorldNBTStorage.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/storage/WorldNBTStorage.java +++ b/net/minecraft/world/level/storage/WorldNBTStorage.java @@ -12,6 +12,13 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import net.minecraft.world.entity.player.EntityHuman; + import org.slf4j.Logger; +// CraftBukkit start +import java.io.FileInputStream; @@ -13,7 +13,7 @@ + public class WorldNBTStorage { - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); @@ -55,6 +62,16 @@ } diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch index e5104efc5f..47f2844fe4 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/storage/loot/LootTable.java +++ b/net/minecraft/world/level/storage/loot/LootTable.java @@ -30,6 +30,13 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; + import org.apache.commons.lang3.ArrayUtils; + import org.slf4j.Logger; +// CraftBukkit start +import java.util.stream.Collectors; @@ -13,7 +13,7 @@ + public class LootTable { - static final Logger LOGGER = LogManager.getLogger(); + static final Logger LOGGER = LogUtils.getLogger(); @@ -115,8 +122,21 @@ } diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTableRegistry.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTableRegistry.patch index 051de7af11..c574b84e5c 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTableRegistry.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTableRegistry.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/storage/loot/LootTableRegistry.java +++ b/net/minecraft/world/level/storage/loot/LootTableRegistry.java @@ -22,6 +22,7 @@ - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); private static final Gson GSON = LootSerialization.createLootTableSerializer().create(); private Map tables = ImmutableMap.of(); + public Map lootTableToKey = ImmutableMap.of(); // CraftBukkit diff --git a/paper-server/pom.xml b/paper-server/pom.xml index 358eb72930..fe33bb84d8 100644 --- a/paper-server/pom.xml +++ b/paper-server/pom.xml @@ -4,7 +4,7 @@ org.bukkit craftbukkit jar - 1.18.1-R0.1-SNAPSHOT + 1.18.2-R0.1-SNAPSHOT CraftBukkit https://www.spigotmc.org/ @@ -13,7 +13,7 @@ UTF-8 unknown git - 1_18_R1 + 1_18_R2 16 16 @@ -48,7 +48,7 @@ org.apache.logging.log4j log4j-iostreams - 2.14.1 + 2.17.0 compile @@ -61,13 +61,13 @@ com.github.oshi oshi-core - 5.8.2 + 5.8.5 compile com.mojang authlib - 3.2.38 + 3.3.39 compile @@ -79,7 +79,7 @@ com.mojang datafixerupper - 4.0.26 + 4.1.27 compile @@ -88,6 +88,12 @@ 1.2.24 compile + + com.mojang + logging + 1.0.0 + compile + commons-io commons-io @@ -121,13 +127,13 @@ org.apache.logging.log4j log4j-core - 2.14.1 + 2.17.0 compile org.apache.logging.log4j log4j-slf4j18-impl - 2.14.1 + 2.17.0 compile diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index 1008a62e45..0fc38f7f10 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -11,6 +11,7 @@ import java.util.concurrent.locks.LockSupport; import java.util.function.BooleanSupplier; import java.util.function.Predicate; import net.minecraft.core.BlockPosition; +import net.minecraft.core.Holder; import net.minecraft.core.IRegistry; import net.minecraft.core.SectionPosition; import net.minecraft.nbt.DynamicOpsNBT; @@ -292,10 +293,10 @@ public class CraftChunk implements Chunk { byte[][] sectionSkyLights = new byte[cs.length][]; byte[][] sectionEmitLights = new byte[cs.length][]; boolean[] sectionEmpty = new boolean[cs.length]; - DataPaletteBlock[] biome = (includeBiome || includeBiomeTempRain) ? new DataPaletteBlock[cs.length] : null; + DataPaletteBlock>[] biome = (includeBiome || includeBiomeTempRain) ? new DataPaletteBlock[cs.length] : null; IRegistry iregistry = worldServer.registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY); - Codec> biomeCodec = DataPaletteBlock.codec(iregistry, iregistry.byNameCodec(), DataPaletteBlock.e.SECTION_BIOMES, iregistry.getOrThrow(Biomes.PLAINS)); + Codec>> biomeCodec = DataPaletteBlock.codec(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.e.SECTION_BIOMES, iregistry.getHolderOrThrow(Biomes.PLAINS)); for (int i = 0; i < cs.length; i++) { NBTTagCompound data = new NBTTagCompound(); @@ -333,7 +334,7 @@ public class CraftChunk implements Chunk { } World world = getWorld(); - return new CraftChunkSnapshot(getX(), getZ(), chunk.getMinBuildHeight(), chunk.getMaxBuildHeight(), world.getName(), world.getFullTime(), sectionBlockIDs, sectionSkyLights, sectionEmitLights, sectionEmpty, hmap, biome); + return new CraftChunkSnapshot(getX(), getZ(), chunk.getMinBuildHeight(), chunk.getMaxBuildHeight(), world.getName(), world.getFullTime(), sectionBlockIDs, sectionSkyLights, sectionEmitLights, sectionEmpty, hmap, iregistry, biome); } @Override @@ -350,7 +351,8 @@ public class CraftChunk implements Chunk { byte[][] skyLight = new byte[hSection][]; byte[][] emitLight = new byte[hSection][]; boolean[] empty = new boolean[hSection]; - DataPaletteBlock[] biome = (includeBiome || includeBiomeTempRain) ? new DataPaletteBlock[hSection] : null; + IRegistry iregistry = world.getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY); + DataPaletteBlock>[] biome = (includeBiome || includeBiomeTempRain) ? new DataPaletteBlock[hSection] : null; for (int i = 0; i < hSection; i++) { blockIDs[i] = emptyBlockIDs; @@ -359,12 +361,11 @@ public class CraftChunk implements Chunk { empty[i] = true; if (biome != null) { - IRegistry iregistry = world.getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY); - biome[i] = new DataPaletteBlock<>(iregistry, iregistry.getOrThrow(Biomes.PLAINS), DataPaletteBlock.e.SECTION_BIOMES); + biome[i] = new DataPaletteBlock<>(iregistry.asHolderIdMap(), iregistry.getHolderOrThrow(Biomes.PLAINS), DataPaletteBlock.e.SECTION_BIOMES); } } - return new CraftChunkSnapshot(x, z, world.getMinHeight(), world.getMaxHeight(), world.getName(), world.getFullTime(), blockIDs, skyLight, emitLight, empty, new HeightMap(actual, HeightMap.Type.MOTION_BLOCKING), biome); + return new CraftChunkSnapshot(x, z, world.getMinHeight(), world.getMaxHeight(), world.getName(), world.getFullTime(), blockIDs, skyLight, emitLight, empty, new HeightMap(actual, HeightMap.Type.MOTION_BLOCKING), iregistry, biome); } static void validateChunkCoordinates(int minY, int maxY, int x, int y, int z) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java index 5dc6517b52..1d45ca4d9a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java @@ -4,6 +4,7 @@ import com.google.common.base.Preconditions; import com.google.common.base.Predicates; import java.util.function.Predicate; import net.minecraft.core.BlockPosition; +import net.minecraft.core.Holder; import net.minecraft.core.IRegistry; import net.minecraft.world.level.biome.BiomeBase; import net.minecraft.world.level.block.state.IBlockData; @@ -31,9 +32,10 @@ public class CraftChunkSnapshot implements ChunkSnapshot { private final boolean[] empty; private final HeightMap hmap; // Height map private final long captureFulltime; - private final DataPaletteBlock[] biome; + private final IRegistry biomeRegistry; + private final DataPaletteBlock>[] biome; - CraftChunkSnapshot(int x, int z, int minHeight, int maxHeight, String wname, long wtime, DataPaletteBlock[] sectionBlockIDs, byte[][] sectionSkyLights, byte[][] sectionEmitLights, boolean[] sectionEmpty, HeightMap hmap, DataPaletteBlock[] biome) { + CraftChunkSnapshot(int x, int z, int minHeight, int maxHeight, String wname, long wtime, DataPaletteBlock[] sectionBlockIDs, byte[][] sectionSkyLights, byte[][] sectionEmitLights, boolean[] sectionEmpty, HeightMap hmap, IRegistry biomeRegistry, DataPaletteBlock>[] biome) { this.x = x; this.z = z; this.minHeight = minHeight; @@ -45,6 +47,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot { this.emitlight = sectionEmitLights; this.empty = sectionEmpty; this.hmap = hmap; + this.biomeRegistry = biomeRegistry; this.biome = biome; } @@ -132,8 +135,8 @@ public class CraftChunkSnapshot implements ChunkSnapshot { Preconditions.checkState(biome != null, "ChunkSnapshot created without biome. Please call getSnapshot with includeBiome=true"); validateChunkCoordinates(x, y, z); - DataPaletteBlock biome = this.biome[getSectionIndex(y >> 2)]; - return CraftBlock.biomeBaseToBiome((IRegistry) biome.registry, biome.get(x >> 2, (y & 0xF) >> 2, z >> 2)); + DataPaletteBlock> biome = this.biome[getSectionIndex(y >> 2)]; + return CraftBlock.biomeBaseToBiome(biomeRegistry, biome.get(x >> 2, (y & 0xF) >> 2, z >> 2)); } @Override @@ -146,8 +149,8 @@ public class CraftChunkSnapshot implements ChunkSnapshot { Preconditions.checkState(biome != null, "ChunkSnapshot created without biome. Please call getSnapshot with includeBiome=true"); validateChunkCoordinates(x, y, z); - DataPaletteBlock biome = this.biome[getSectionIndex(y >> 2)]; - return biome.get(x >> 2, (y & 0xF) >> 2, z >> 2).getTemperature(new BlockPosition((this.x << 4) | x, y, (this.z << 4) | z)); + DataPaletteBlock> biome = this.biome[getSectionIndex(y >> 2)]; + return biome.get(x >> 2, (y & 0xF) >> 2, z >> 2).value().getTemperature(new BlockPosition((this.x << 4) | x, y, (this.z << 4) | z)); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java index 1f3593b7b0..330f10e06b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java @@ -5,11 +5,11 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; -import java.util.Optional; import java.util.Random; import java.util.function.Predicate; import net.minecraft.core.BlockPosition; import net.minecraft.core.EnumDirection; +import net.minecraft.core.Holder; import net.minecraft.core.IRegistry; import net.minecraft.data.worldgen.features.TreeFeatures; import net.minecraft.world.entity.EntityAreaEffectCloud; @@ -49,7 +49,7 @@ import net.minecraft.world.level.block.BlockDiodeAbstract; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.chunk.ChunkGenerator; -import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; +import net.minecraft.world.level.levelgen.feature.WorldGenFeatureConfigured; import net.minecraft.world.phys.AxisAlignedBB; import org.bukkit.Location; import org.bukkit.Material; @@ -226,11 +226,11 @@ public abstract class CraftRegionAccessor implements RegionAccessor { @Override public void setBiome(int x, int y, int z, Biome biome) { Preconditions.checkArgument(biome != Biome.CUSTOM, "Cannot set the biome to %s", biome); - BiomeBase biomeBase = CraftBlock.biomeToBiomeBase(getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY), biome); + Holder biomeBase = CraftBlock.biomeToBiomeBase(getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY), biome); setBiome(x, y, z, biomeBase); } - public abstract void setBiome(int x, int y, int z, BiomeBase biomeBase); + public abstract void setBiome(int x, int y, int z, Holder biomeBase); @Override public BlockState getBlockState(Location location) { @@ -321,7 +321,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor { } public boolean generateTree(GeneratorAccessSeed access, ChunkGenerator chunkGenerator, BlockPosition pos, Random random, TreeType treeType) { - net.minecraft.world.level.levelgen.feature.WorldGenFeatureConfigured gen; + Holder gen; switch (treeType) { case BIG_TREE: gen = TreeFeatures.FANCY_OAK; @@ -386,7 +386,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor { break; } - return gen.feature.place(new FeaturePlaceContext(Optional.empty(), access, chunkGenerator, random, pos, gen.config)); + return ((WorldGenFeatureConfigured) gen.value()).place(access, chunkGenerator, random, pos); } @Override @@ -558,7 +558,8 @@ public abstract class CraftRegionAccessor implements RegionAccessor { entity = new EntityBoat(world, x, y, z); entity.moveTo(x, y, z, yaw, pitch); } else if (FallingBlock.class.isAssignableFrom(clazz)) { - entity = new EntityFallingBlock(world, x, y, z, getHandle().getBlockState(new BlockPosition(x, y, z))); + BlockPosition pos = new BlockPosition(x, y, z); + entity = EntityFallingBlock.fall(world, pos, getHandle().getBlockState(pos)); } else if (Projectile.class.isAssignableFrom(clazz)) { if (Snowball.class.isAssignableFrom(clazz)) { entity = new EntitySnowball(world, x, y, z); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 0eb444280a..f024eb2395 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -37,7 +37,6 @@ import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.Properties; import java.util.Random; import java.util.Set; import java.util.UUID; @@ -52,8 +51,8 @@ import net.minecraft.commands.CommandDispatcher; import net.minecraft.commands.CommandListenerWrapper; import net.minecraft.commands.arguments.ArgumentEntity; import net.minecraft.core.BlockPosition; +import net.minecraft.core.Holder; import net.minecraft.core.IRegistry; -import net.minecraft.core.RegistryMaterials; import net.minecraft.resources.MinecraftKey; import net.minecraft.resources.ResourceKey; import net.minecraft.server.ServerCommand; @@ -71,11 +70,8 @@ import net.minecraft.server.players.IpBanEntry; import net.minecraft.server.players.OpListEntry; import net.minecraft.server.players.PlayerList; import net.minecraft.server.players.WhiteListEntry; -import net.minecraft.tags.Tags; -import net.minecraft.tags.TagsBlock; -import net.minecraft.tags.TagsEntity; -import net.minecraft.tags.TagsFluid; -import net.minecraft.tags.TagsItem; +import net.minecraft.tags.TagKey; +import net.minecraft.util.ChatDeserializer; import net.minecraft.util.datafix.DataConverterRegistry; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.effect.MobEffects; @@ -461,7 +457,7 @@ public final class CraftServer implements Server { public void syncCommands() { // Clear existing commands - CommandDispatcher dispatcher = console.resources.commands = new CommandDispatcher(); + CommandDispatcher dispatcher = console.resources.managers().commands = new CommandDispatcher(); // Register all commands, vanilla ones will be using the old dispatcher references for (Map.Entry entry : commandMap.getKnownCommands().entrySet()) { @@ -1033,16 +1029,12 @@ public final class CraftServer implements Server { boolean hardcore = creator.hardcore(); - WorldDataServer worlddata = (WorldDataServer) worldSession.getDataTag(console.registryreadops, console.datapackconfiguration); + WorldDataServer worlddata = (WorldDataServer) worldSession.getDataTag(console.registryreadops, console.datapackconfiguration, console.registryHolder.allElementsLifecycle()); WorldSettings worldSettings; // See MinecraftServer.a(String, String, long, WorldType, JsonElement) if (worlddata == null) { - Properties properties = new Properties(); - properties.put("generator-settings", Objects.toString(creator.generatorSettings())); - properties.put("level-seed", Objects.toString(creator.seed())); - properties.put("generate-structures", Objects.toString(creator.generateStructures())); - properties.put("level-type", Objects.toString(creator.type().getName())); + DedicatedServerProperties.a properties = new DedicatedServerProperties.a(Objects.toString(creator.seed()), ChatDeserializer.parse(creator.generatorSettings()), creator.generateStructures(), creator.type().name().toLowerCase(Locale.ROOT)); GeneratorSettings generatorsettings = GeneratorSettings.create(console.registryAccess(), properties); worldSettings = new WorldSettings(name, EnumGamemode.byId(getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), console.datapackconfiguration); @@ -1059,28 +1051,28 @@ public final class CraftServer implements Server { long j = BiomeManager.obfuscateSeed(creator.seed()); List list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(worlddata)); - RegistryMaterials registrymaterials = worlddata.worldGenSettings().dimensions(); - WorldDimension worlddimension = (WorldDimension) registrymaterials.get(actualDimension); - DimensionManager dimensionmanager; + IRegistry iregistry = worlddata.worldGenSettings().dimensions(); + WorldDimension worlddimension = (WorldDimension) iregistry.get(actualDimension); + Holder holder; net.minecraft.world.level.chunk.ChunkGenerator chunkgenerator; if (worlddimension == null) { - dimensionmanager = (DimensionManager) console.registryHolder.registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrThrow(DimensionManager.OVERWORLD_LOCATION); + holder = console.registryHolder.registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrCreateHolder(DimensionManager.OVERWORLD_LOCATION); chunkgenerator = GeneratorSettings.makeDefaultOverworld(console.registryHolder, (new Random()).nextLong()); } else { - dimensionmanager = worlddimension.type(); + holder = worlddimension.typeHolder(); chunkgenerator = worlddimension.generator(); } - WorldInfo worldInfo = new CraftWorldInfo(worlddata, worldSession, creator.environment(), dimensionmanager); + WorldInfo worldInfo = new CraftWorldInfo(worlddata, worldSession, creator.environment(), holder.value()); if (biomeProvider == null && generator != null) { biomeProvider = generator.getDefaultBiomeProvider(worldInfo); } if (biomeProvider != null) { WorldChunkManager worldChunkManager = new CustomWorldChunkManager(worldInfo, biomeProvider, console.registryHolder.ownedRegistryOrThrow(IRegistry.BIOME_REGISTRY)); - if (chunkgenerator instanceof ChunkGeneratorAbstract) { - chunkgenerator = new ChunkGeneratorAbstract(((ChunkGeneratorAbstract) chunkgenerator).noises, worldChunkManager, chunkgenerator.strongholdSeed, ((ChunkGeneratorAbstract) chunkgenerator).settings); + if (chunkgenerator instanceof ChunkGeneratorAbstract cga) { + chunkgenerator = new ChunkGeneratorAbstract(cga.structureSets, cga.noises, worldChunkManager, cga.ringPlacementSeed, cga.settings); } } @@ -1094,7 +1086,7 @@ public final class CraftServer implements Server { worldKey = ResourceKey.create(IRegistry.DIMENSION_REGISTRY, new MinecraftKey(name.toLowerCase(java.util.Locale.ENGLISH))); } - WorldServer internal = (WorldServer) new WorldServer(console, console.executor, worldSession, worlddata, worldKey, dimensionmanager, getServer().progressListenerFactory.create(11), + WorldServer internal = (WorldServer) new WorldServer(console, console.executor, worldSession, worlddata, worldKey, holder, getServer().progressListenerFactory.create(11), chunkgenerator, worlddata.worldGenSettings().isDebug(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, creator.environment(), generator, biomeProvider); if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) { @@ -2161,19 +2153,19 @@ public final class CraftServer implements Server { case org.bukkit.Tag.REGISTRY_BLOCKS: Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Block namespace must have material type"); - return (org.bukkit.Tag) new CraftBlockTag(TagsBlock.getAllTags(), key); + return (org.bukkit.Tag) new CraftBlockTag(IRegistry.BLOCK, TagKey.create(IRegistry.BLOCK_REGISTRY, key)); case org.bukkit.Tag.REGISTRY_ITEMS: Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Item namespace must have material type"); - return (org.bukkit.Tag) new CraftItemTag(TagsItem.getAllTags(), key); + return (org.bukkit.Tag) new CraftItemTag(IRegistry.ITEM, TagKey.create(IRegistry.ITEM_REGISTRY, key)); case org.bukkit.Tag.REGISTRY_FLUIDS: Preconditions.checkArgument(clazz == org.bukkit.Fluid.class, "Fluid namespace must have fluid type"); - return (org.bukkit.Tag) new CraftFluidTag(TagsFluid.getAllTags(), key); + return (org.bukkit.Tag) new CraftFluidTag(IRegistry.FLUID, TagKey.create(IRegistry.FLUID_REGISTRY, key)); case org.bukkit.Tag.REGISTRY_ENTITY_TYPES: Preconditions.checkArgument(clazz == org.bukkit.entity.EntityType.class, "Entity type namespace must have entity type"); - return (org.bukkit.Tag) new CraftEntityTag(TagsEntity.getAllTags(), key); + return (org.bukkit.Tag) new CraftEntityTag(IRegistry.ENTITY_TYPE, TagKey.create(IRegistry.ENTITY_TYPE_REGISTRY, key)); default: throw new IllegalArgumentException(); } @@ -2186,23 +2178,23 @@ public final class CraftServer implements Server { case org.bukkit.Tag.REGISTRY_BLOCKS: Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Block namespace must have material type"); - Tags blockTags = TagsBlock.getAllTags(); - return blockTags.getAllTags().keySet().stream().map(key -> (org.bukkit.Tag) new CraftBlockTag(blockTags, key)).collect(ImmutableList.toImmutableList()); + IRegistry blockTags = IRegistry.BLOCK; + return blockTags.getTags().map(pair -> (org.bukkit.Tag) new CraftBlockTag(blockTags, pair.getFirst())).collect(ImmutableList.toImmutableList()); case org.bukkit.Tag.REGISTRY_ITEMS: Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Item namespace must have material type"); - Tags itemTags = TagsItem.getAllTags(); - return itemTags.getAllTags().keySet().stream().map(key -> (org.bukkit.Tag) new CraftItemTag(itemTags, key)).collect(ImmutableList.toImmutableList()); + IRegistry itemTags = IRegistry.ITEM; + return itemTags.getTags().map(pair -> (org.bukkit.Tag) new CraftItemTag(itemTags, pair.getFirst())).collect(ImmutableList.toImmutableList()); case org.bukkit.Tag.REGISTRY_FLUIDS: Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Fluid namespace must have fluid type"); - Tags fluidTags = TagsFluid.getAllTags(); - return fluidTags.getAllTags().keySet().stream().map(key -> (org.bukkit.Tag) new CraftFluidTag(fluidTags, key)).collect(ImmutableList.toImmutableList()); + IRegistry fluidTags = IRegistry.FLUID; + return fluidTags.getTags().map(pair -> (org.bukkit.Tag) new CraftFluidTag(fluidTags, pair.getFirst())).collect(ImmutableList.toImmutableList()); case org.bukkit.Tag.REGISTRY_ENTITY_TYPES: Preconditions.checkArgument(clazz == org.bukkit.entity.EntityType.class, "Entity type namespace must have entity type"); - Tags> entityTags = TagsEntity.getAllTags(); - return entityTags.getAllTags().keySet().stream().map(key -> (org.bukkit.Tag) new CraftEntityTag(entityTags, key)).collect(ImmutableList.toImmutableList()); + IRegistry> entityTags = IRegistry.ENTITY_TYPE; + return entityTags.getTags().map(pair -> (org.bukkit.Tag) new CraftEntityTag(entityTags, pair.getFirst())).collect(ImmutableList.toImmutableList()); default: throw new IllegalArgumentException(); } 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 cce1e7f4b1..578072f980 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -23,6 +23,8 @@ import java.util.UUID; import java.util.function.Predicate; import java.util.stream.Collectors; import net.minecraft.core.BlockPosition; +import net.minecraft.core.Holder; +import net.minecraft.core.IRegistry; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; @@ -39,6 +41,7 @@ import net.minecraft.server.level.Ticket; import net.minecraft.server.level.TicketType; import net.minecraft.server.level.WorldServer; import net.minecraft.sounds.SoundCategory; +import net.minecraft.tags.TagKey; import net.minecraft.util.ArraySetSorted; import net.minecraft.util.Unit; import net.minecraft.world.EnumDifficulty; @@ -58,7 +61,6 @@ import net.minecraft.world.level.biome.BiomeBase; import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.IChunkAccess; import net.minecraft.world.level.chunk.ProtoChunkExtension; -import net.minecraft.world.level.levelgen.feature.StructureGenerator; import net.minecraft.world.level.storage.SavedFile; import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.MovingObjectPosition; @@ -97,6 +99,7 @@ import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer; import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry; import org.bukkit.craftbukkit.potion.CraftPotionUtil; import org.bukkit.craftbukkit.util.CraftMagicNumbers; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.craftbukkit.util.CraftRayTraceResult; import org.bukkit.craftbukkit.util.CraftSpawnCategory; import org.bukkit.entity.AbstractArrow; @@ -749,7 +752,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { } @Override - public void setBiome(int x, int y, int z, BiomeBase bb) { + public void setBiome(int x, int y, int z, Holder bb) { BlockPosition pos = new BlockPosition(x, 0, z); if (this.world.hasChunkAt(pos)) { net.minecraft.world.level.chunk.Chunk chunk = this.world.getChunkAt(pos); @@ -770,7 +773,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public double getTemperature(int x, int y, int z) { BlockPosition pos = new BlockPosition(x, y, z); - return this.world.getNoiseBiome(x >> 2, y >> 2, z >> 2).getTemperature(pos); + return this.world.getNoiseBiome(x >> 2, y >> 2, z >> 2).value().getTemperature(pos); } @Override @@ -780,7 +783,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public double getHumidity(int x, int y, int z) { - return this.world.getNoiseBiome(x >> 2, y >> 2, z >> 2).getDownfall(); + return this.world.getNoiseBiome(x >> 2, y >> 2, z >> 2).value().getDownfall(); } @Override @@ -1142,7 +1145,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { Validate.notNull(material, "Material cannot be null"); Validate.isTrue(material.isBlock(), "Material must be a block"); - EntityFallingBlock entity = new EntityFallingBlock(world, location.getX(), location.getY(), location.getZ(), CraftMagicNumbers.getBlock(material).defaultBlockState()); + EntityFallingBlock entity = EntityFallingBlock.fall(world, new BlockPosition(location.getX(), location.getY(), location.getZ()), CraftMagicNumbers.getBlock(material).defaultBlockState()); entity.time = 1; world.addFreshEntity(entity, SpawnReason.CUSTOM); @@ -1154,7 +1157,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { Validate.notNull(location, "Location cannot be null"); Validate.notNull(data, "Material cannot be null"); - EntityFallingBlock entity = new EntityFallingBlock(world, location.getX(), location.getY(), location.getZ(), ((CraftBlockData) data).getState()); + EntityFallingBlock entity = EntityFallingBlock.fall(world, new BlockPosition(location.getX(), location.getY(), location.getZ()), ((CraftBlockData) data).getState()); entity.time = 1; world.addFreshEntity(entity, SpawnReason.CUSTOM); @@ -1774,7 +1777,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public Location locateNearestStructure(Location origin, StructureType structureType, int radius, boolean findUnexplored) { BlockPosition originPos = new BlockPosition(origin.getX(), origin.getY(), origin.getZ()); - BlockPosition nearest = getHandle().getChunkSource().getGenerator().findNearestMapFeature(getHandle(), StructureGenerator.STRUCTURES_REGISTRY.get(structureType.getName()), originPos, radius, findUnexplored); + BlockPosition nearest = getHandle().findNearestMapFeature(TagKey.create(IRegistry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY, CraftNamespacedKey.toMinecraft(structureType.getKey())), originPos, radius, findUnexplored); return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ()); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java index 61d84689cd..59299cb3f2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java @@ -181,11 +181,11 @@ public class Main { useConsole = false; } - if (false && Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { + if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { Date buildDate = new Date(Integer.parseInt(Main.class.getPackage().getImplementationVendor()) * 1000L); Calendar deadline = Calendar.getInstance(); - deadline.add(Calendar.DAY_OF_YEAR, -28); + deadline.add(Calendar.DAY_OF_YEAR, -3); if (buildDate.before(deadline.getTime())) { System.err.println("*** Error, this build is outdated ***"); System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***"); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index da7ee9c9b5..fbdf997c8c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -7,7 +7,9 @@ import java.util.List; import java.util.stream.Collectors; import net.minecraft.core.BlockPosition; import net.minecraft.core.EnumDirection; +import net.minecraft.core.Holder; import net.minecraft.core.IRegistry; +import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.WorldServer; import net.minecraft.world.EnumHand; import net.minecraft.world.EnumInteractionResult; @@ -333,6 +335,10 @@ public class CraftBlock implements Block { getWorld().setBiome(getX(), getY(), getZ(), bio); } + public static Biome biomeBaseToBiome(IRegistry registry, Holder base) { + return biomeBaseToBiome(registry, base.value()); + } + public static Biome biomeBaseToBiome(IRegistry registry, BiomeBase base) { if (base == null) { return null; @@ -342,17 +348,17 @@ public class CraftBlock implements Block { return (biome == null) ? Biome.CUSTOM : biome; } - public static BiomeBase biomeToBiomeBase(IRegistry registry, Biome bio) { + public static Holder biomeToBiomeBase(IRegistry registry, Biome bio) { if (bio == null || bio == Biome.CUSTOM) { return null; } - return registry.get(CraftNamespacedKey.toMinecraft(bio.getKey())); + return registry.getHolderOrThrow(ResourceKey.create(IRegistry.BIOME_REGISTRY, CraftNamespacedKey.toMinecraft(bio.getKey()))); } @Override public double getTemperature() { - return world.getBiome(position).getTemperature(position); + return world.getBiome(position).value().getTemperature(position); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java index 19ef0e242d..e10d76b9d5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java @@ -7,6 +7,7 @@ import java.util.Collection; import java.util.List; import java.util.Random; import net.minecraft.core.BlockPosition; +import net.minecraft.core.Holder; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.level.ChunkCoordIntPair; @@ -167,7 +168,7 @@ public class CraftLimitedRegion extends CraftRegionAccessor implements LimitedRe } @Override - public void setBiome(int x, int y, int z, BiomeBase biomeBase) { + public void setBiome(int x, int y, int z, Holder biomeBase) { Preconditions.checkArgument(isInRegion(x, y, z), "Coordinates %s, %s, %s are not in the region", x, y, z); IChunkAccess chunk = getHandle().getChunk(x >> 4, z >> 4, ChunkStatus.EMPTY); chunk.setBiome(x >> 2, y >> 2, z >> 2, biomeBase); 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 a055148705..dc506cdf6b 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 @@ -2,10 +2,12 @@ package org.bukkit.craftbukkit.generator; import com.google.common.base.Preconditions; import com.mojang.serialization.Codec; +import java.util.List; import java.util.Random; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import net.minecraft.core.BlockPosition; +import net.minecraft.core.Holder; import net.minecraft.core.IRegistry; import net.minecraft.core.IRegistryCustom; import net.minecraft.server.level.RegionLimitedWorldAccess; @@ -73,18 +75,18 @@ public class CustomChunkGenerator extends InternalChunkGenerator { @Override public Biome getBiome(int x, int y, int z) { - return CraftBlock.biomeBaseToBiome((IRegistry) biome.biomeRegistry, biome.getNoiseBiome(x >> 2, y >> 2, z >> 2)); + return CraftBlock.biomeBaseToBiome(biome.biomeRegistry, biome.getNoiseBiome(x >> 2, y >> 2, z >> 2)); } @Override public void setBiome(int x, int y, int z, Biome bio) { Preconditions.checkArgument(bio != Biome.CUSTOM, "Cannot set the biome to %s", bio); - biome.setBiome(x >> 2, y >> 2, z >> 2, CraftBlock.biomeToBiomeBase((IRegistry) biome.biomeRegistry, bio)); + biome.setBiome(x >> 2, y >> 2, z >> 2, CraftBlock.biomeToBiomeBase(biome.biomeRegistry, bio)); } } public CustomChunkGenerator(WorldServer world, net.minecraft.world.level.chunk.ChunkGenerator delegate, ChunkGenerator generator) { - super(delegate.getBiomeSource(), delegate.getSettings()); + super(delegate.structureSets, delegate.structureOverrides, delegate.getBiomeSource()); this.world = world; this.delegate = delegate; @@ -279,8 +281,8 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } @Override - public WeightedRandomList getMobsAt(BiomeBase biomebase, StructureManager structuremanager, EnumCreatureType enumcreaturetype, BlockPosition blockposition) { - return delegate.getMobsAt(biomebase, structuremanager, enumcreaturetype, blockposition); + public WeightedRandomList getMobsAt(Holder holder, StructureManager structuremanager, EnumCreatureType enumcreaturetype, BlockPosition blockposition) { + return delegate.getMobsAt(holder, structuremanager, enumcreaturetype, blockposition); } @Override @@ -288,6 +290,11 @@ public class CustomChunkGenerator extends InternalChunkGenerator { super.applyBiomeDecoration(generatoraccessseed, ichunkaccess, structuremanager, generator.shouldGenerateDecorations()); } + @Override + public void addDebugScreenInfo(List list, BlockPosition blockposition) { + delegate.addDebugScreenInfo(list, blockposition); + } + @Override public void spawnOriginalMobs(RegionLimitedWorldAccess regionlimitedworldaccess) { if (generator.shouldGenerateMobs()) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java index d86d9ae25c..e27bd6acec 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java @@ -4,6 +4,7 @@ import com.google.common.base.Preconditions; import com.mojang.serialization.Codec; import java.util.ArrayList; import java.util.List; +import net.minecraft.core.Holder; import net.minecraft.core.IRegistry; import net.minecraft.world.level.biome.BiomeBase; import net.minecraft.world.level.biome.Climate; @@ -19,8 +20,8 @@ public class CustomWorldChunkManager extends WorldChunkManager { private final BiomeProvider biomeProvider; private final IRegistry registry; - private static List biomeListToBiomeBaseList(List biomes, IRegistry registry) { - List biomeBases = new ArrayList<>(); + private static List> biomeListToBiomeBaseList(List biomes, IRegistry registry) { + List> biomeBases = new ArrayList<>(); for (Biome biome : biomes) { Preconditions.checkArgument(biome != Biome.CUSTOM, "Cannot use the biome %s", biome); @@ -50,7 +51,7 @@ public class CustomWorldChunkManager extends WorldChunkManager { } @Override - public BiomeBase getNoiseBiome(int x, int y, int z, Climate.Sampler sampler) { + public Holder getNoiseBiome(int x, int y, int z, Climate.Sampler sampler) { Biome biome = biomeProvider.getBiome(worldInfo, x << 2, y << 2, z << 2); Preconditions.checkArgument(biome != Biome.CUSTOM, "Cannot set the biome to %s", biome); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java index d9760201f8..ec3579f2ed 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java @@ -1,12 +1,15 @@ package org.bukkit.craftbukkit.generator; +import java.util.Optional; +import net.minecraft.core.HolderSet; +import net.minecraft.core.IRegistry; import net.minecraft.world.level.biome.WorldChunkManager; -import net.minecraft.world.level.levelgen.StructureSettings; +import net.minecraft.world.level.levelgen.structure.StructureSet; // Do not implement functions to this class, add to NormalChunkGenerator public abstract class InternalChunkGenerator extends net.minecraft.world.level.chunk.ChunkGenerator { - public InternalChunkGenerator(WorldChunkManager worldchunkmanager, StructureSettings structuresettings) { - super(worldchunkmanager, structuresettings); + public InternalChunkGenerator(IRegistry iregistry, Optional> optional, WorldChunkManager worldchunkmanager) { + super(iregistry, optional, worldchunkmanager); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java index 77de68931e..df180227e1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java @@ -3,25 +3,25 @@ package org.bukkit.craftbukkit.tag; import java.util.Collections; import java.util.Set; import java.util.stream.Collectors; -import net.minecraft.resources.MinecraftKey; -import net.minecraft.tags.Tags; +import net.minecraft.core.IRegistry; +import net.minecraft.tags.TagKey; import net.minecraft.world.level.block.Block; import org.bukkit.Material; import org.bukkit.craftbukkit.util.CraftMagicNumbers; public class CraftBlockTag extends CraftTag { - public CraftBlockTag(Tags registry, MinecraftKey tag) { + public CraftBlockTag(IRegistry registry, TagKey tag) { super(registry, tag); } @Override public boolean isTagged(Material item) { - return getHandle().contains(CraftMagicNumbers.getBlock(item)); + return CraftMagicNumbers.getBlock(item).builtInRegistryHolder().is(tag); } @Override public Set getValues() { - return Collections.unmodifiableSet(getHandle().getValues().stream().map((block) -> CraftMagicNumbers.getMaterial(block)).collect(Collectors.toSet())); + return Collections.unmodifiableSet(getHandle().stream().map((block) -> CraftMagicNumbers.getMaterial(block.value())).collect(Collectors.toSet())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java index 9c1c8f555d..86f85c2ffa 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java @@ -4,8 +4,8 @@ import java.util.Collections; import java.util.Set; import java.util.stream.Collectors; import net.minecraft.core.IRegistry; -import net.minecraft.resources.MinecraftKey; -import net.minecraft.tags.Tags; +import net.minecraft.resources.ResourceKey; +import net.minecraft.tags.TagKey; import net.minecraft.world.entity.EntityTypes; import org.bukkit.Registry; import org.bukkit.craftbukkit.util.CraftNamespacedKey; @@ -13,17 +13,17 @@ import org.bukkit.entity.EntityType; public class CraftEntityTag extends CraftTag, EntityType> { - public CraftEntityTag(Tags> registry, MinecraftKey tag) { + public CraftEntityTag(IRegistry> registry, TagKey> tag) { super(registry, tag); } @Override public boolean isTagged(EntityType entity) { - return getHandle().contains(IRegistry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(entity.getKey()))); + return registry.getHolderOrThrow(ResourceKey.create(IRegistry.ENTITY_TYPE_REGISTRY, CraftNamespacedKey.toMinecraft(entity.getKey()))).is(tag); } @Override public Set getValues() { - return Collections.unmodifiableSet(getHandle().getValues().stream().map((nms) -> Registry.ENTITY_TYPE.get(CraftNamespacedKey.fromMinecraft(EntityTypes.getKey(nms)))).collect(Collectors.toSet())); + return Collections.unmodifiableSet(getHandle().stream().map((nms) -> Registry.ENTITY_TYPE.get(CraftNamespacedKey.fromMinecraft(EntityTypes.getKey(nms.value())))).collect(Collectors.toSet())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftFluidTag.java b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftFluidTag.java index 6dd5f3736e..9d94b4bb9a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftFluidTag.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftFluidTag.java @@ -3,25 +3,25 @@ package org.bukkit.craftbukkit.tag; import java.util.Collections; import java.util.Set; import java.util.stream.Collectors; -import net.minecraft.resources.MinecraftKey; -import net.minecraft.tags.Tags; +import net.minecraft.core.IRegistry; +import net.minecraft.tags.TagKey; import net.minecraft.world.level.material.FluidType; import org.bukkit.Fluid; import org.bukkit.craftbukkit.util.CraftMagicNumbers; public class CraftFluidTag extends CraftTag { - public CraftFluidTag(Tags registry, MinecraftKey tag) { + public CraftFluidTag(IRegistry registry, TagKey tag) { super(registry, tag); } @Override public boolean isTagged(Fluid fluid) { - return getHandle().contains(CraftMagicNumbers.getFluid(fluid)); + return CraftMagicNumbers.getFluid(fluid).is(tag); } @Override public Set getValues() { - return Collections.unmodifiableSet(getHandle().getValues().stream().map(CraftMagicNumbers::getFluid).collect(Collectors.toSet())); + return Collections.unmodifiableSet(getHandle().stream().map((fluid) -> CraftMagicNumbers.getFluid(fluid.value())).collect(Collectors.toSet())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java index 11e9a103ca..3a5bcbc811 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java @@ -3,25 +3,25 @@ package org.bukkit.craftbukkit.tag; import java.util.Collections; import java.util.Set; import java.util.stream.Collectors; -import net.minecraft.resources.MinecraftKey; -import net.minecraft.tags.Tags; +import net.minecraft.core.IRegistry; +import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import org.bukkit.Material; import org.bukkit.craftbukkit.util.CraftMagicNumbers; public class CraftItemTag extends CraftTag { - public CraftItemTag(Tags registry, MinecraftKey tag) { + public CraftItemTag(IRegistry registry, TagKey tag) { super(registry, tag); } @Override public boolean isTagged(Material item) { - return getHandle().contains(CraftMagicNumbers.getItem(item)); + return CraftMagicNumbers.getItem(item).builtInRegistryHolder().is(tag); } @Override public Set getValues() { - return Collections.unmodifiableSet(getHandle().getValues().stream().map((item) -> CraftMagicNumbers.getMaterial(item)).collect(Collectors.toSet())); + return Collections.unmodifiableSet(getHandle().stream().map((item) -> CraftMagicNumbers.getMaterial(item.value())).collect(Collectors.toSet())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftTag.java b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftTag.java index 68a4bdb85b..77cefd4a41 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftTag.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftTag.java @@ -1,7 +1,8 @@ package org.bukkit.craftbukkit.tag; -import net.minecraft.resources.MinecraftKey; -import net.minecraft.tags.Tags; +import net.minecraft.core.HolderSet; +import net.minecraft.core.IRegistry; +import net.minecraft.tags.TagKey; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.bukkit.Tag; @@ -9,19 +10,19 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey; public abstract class CraftTag implements Tag { - private final net.minecraft.tags.Tags registry; - private final MinecraftKey tag; + protected final IRegistry registry; + protected final TagKey tag; // - private net.minecraft.tags.Tag handle; + private HolderSet.Named handle; - public CraftTag(Tags registry, MinecraftKey tag) { + public CraftTag(IRegistry registry, TagKey tag) { this.registry = registry; this.tag = tag; } - protected net.minecraft.tags.Tag getHandle() { + protected HolderSet.Named getHandle() { if (handle == null) { - handle = registry.getTagOrEmpty(tag); + handle = registry.getTag(tag).get(); } return handle; @@ -29,6 +30,6 @@ public abstract class CraftTag implements Tag { @Override public NamespacedKey getKey() { - return CraftNamespacedKey.fromMinecraft(tag); + return CraftNamespacedKey.fromMinecraft(tag.location()); } } 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 4ad9372e1d..3de9ccf84d 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 @@ -234,7 +234,7 @@ public final class CraftMagicNumbers implements UnsafeValues { * @return string */ public String getMappingsVersion() { - return "20b026e774dbf715e40a0b2afe114792"; + return "eaeedbff51b16ead3170906872fda334"; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java index 400b129111..3929427d7e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java @@ -5,8 +5,8 @@ import java.util.Random; import java.util.function.Predicate; import net.minecraft.core.BlockPosition; import net.minecraft.core.EnumDirection; +import net.minecraft.core.Holder; import net.minecraft.core.IRegistryCustom; -import net.minecraft.core.SectionPosition; import net.minecraft.core.particles.ParticleParam; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.WorldServer; @@ -30,8 +30,6 @@ import net.minecraft.world.level.dimension.DimensionManager; import net.minecraft.world.level.entity.EntityTypeTest; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.levelgen.HeightMap; -import net.minecraft.world.level.levelgen.feature.StructureGenerator; -import net.minecraft.world.level.levelgen.structure.StructureStart; import net.minecraft.world.level.lighting.LightEngine; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.FluidType; @@ -53,11 +51,6 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed { throw new UnsupportedOperationException("Not supported yet."); } - @Override - public List> startsForFeature(SectionPosition sp, StructureGenerator sg) { - throw new UnsupportedOperationException("Not supported yet."); - } - @Override public WorldServer getLevel() { throw new UnsupportedOperationException("Not supported yet."); @@ -169,7 +162,7 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed { } @Override - public BiomeBase getUncachedNoiseBiome(int i, int i1, int i2) { + public Holder getUncachedNoiseBiome(int i, int i1, int i2) { throw new UnsupportedOperationException("Not supported yet."); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java index 99564fed7c..327a38ea67 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.util; -import com.mojang.util.QueueLogAppender; +import com.mojang.logging.LogQueues; import java.io.IOException; import java.io.OutputStream; import java.util.logging.Level; @@ -28,7 +28,7 @@ public class TerminalConsoleWriterThread extends Thread { // Using name from log4j config in vanilla jar while (true) { - message = QueueLogAppender.getNextLogEvent("TerminalConsole"); + message = LogQueues.getNextLogEvent("TerminalConsole"); if (message == null) { continue; } diff --git a/paper-server/src/test/java/org/bukkit/support/AbstractTestingBase.java b/paper-server/src/test/java/org/bukkit/support/AbstractTestingBase.java index 5450d2e684..c4389513af 100644 --- a/paper-server/src/test/java/org/bukkit/support/AbstractTestingBase.java +++ b/paper-server/src/test/java/org/bukkit/support/AbstractTestingBase.java @@ -4,18 +4,15 @@ import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.MoreExecutors; import java.util.Collections; import java.util.List; -import java.util.concurrent.CompletableFuture; import net.minecraft.SharedConstants; +import net.minecraft.commands.CommandDispatcher; import net.minecraft.core.IRegistryCustom; +import net.minecraft.server.DataPackResources; import net.minecraft.server.DispenserRegistry; import net.minecraft.server.packs.EnumResourcePackType; import net.minecraft.server.packs.ResourcePackVanilla; import net.minecraft.server.packs.repository.ResourcePackSourceVanilla; import net.minecraft.server.packs.resources.ResourceManager; -import net.minecraft.tags.TagRegistry; -import net.minecraft.util.Unit; -import net.minecraft.world.level.storage.loot.LootPredicateManager; -import net.minecraft.world.level.storage.loot.LootTableRegistry; import org.bukkit.Material; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.junit.Assert; @@ -32,21 +29,19 @@ public abstract class AbstractTestingBase { // Materials that only exist in block form (or are legacy) public static final List INVALIDATED_MATERIALS; - public static final LootTableRegistry LOOT_TABLE_REGISTRY; - public static final TagRegistry TAG_REGISTRY; + public static final DataPackResources DATA_PACK; static { SharedConstants.tryDetectVersion(); DispenserRegistry.bootStrap(); // Set up resource manager - ResourceManager resourceManager = new ResourceManager(EnumResourcePackType.SERVER_DATA); + ResourceManager resourceManager = new ResourceManager(EnumResourcePackType.SERVER_DATA, Collections.singletonList(new ResourcePackVanilla(ResourcePackSourceVanilla.BUILT_IN_METADATA, "minecraft"))); // add tags and loot tables for unit tests - resourceManager.registerReloadListener(TAG_REGISTRY = new TagRegistry(IRegistryCustom.builtin())); - resourceManager.registerReloadListener(LOOT_TABLE_REGISTRY = new LootTableRegistry(new LootPredicateManager())); + IRegistryCustom.Dimension registry = IRegistryCustom.builtinCopy().freeze(); // Register vanilla pack - resourceManager.reload(MoreExecutors.directExecutor(), MoreExecutors.directExecutor(), Collections.singletonList(new ResourcePackVanilla(ResourcePackSourceVanilla.BUILT_IN_METADATA, "minecraft")), CompletableFuture.completedFuture(Unit.INSTANCE)).join(); + DATA_PACK = DataPackResources.loadResources(resourceManager, registry, CommandDispatcher.ServerType.DEDICATED, 0, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join(); // Bind tags - TAG_REGISTRY.getTags().bindToGlobal(); + DATA_PACK.updateRegistryTags(registry); DummyServer.setup(); DummyEnchantments.setup(); diff --git a/paper-server/src/test/java/org/bukkit/support/DummyServer.java b/paper-server/src/test/java/org/bukkit/support/DummyServer.java index b25fb75e83..99646442ff 100644 --- a/paper-server/src/test/java/org/bukkit/support/DummyServer.java +++ b/paper-server/src/test/java/org/bukkit/support/DummyServer.java @@ -93,7 +93,7 @@ public final class DummyServer implements InvocationHandler { @Override public Object handle(DummyServer server, Object[] args) { NamespacedKey key = (NamespacedKey) args[0]; - return new CraftLootTable(key, AbstractTestingBase.LOOT_TABLE_REGISTRY.get(CraftNamespacedKey.toMinecraft(key))); + return new CraftLootTable(key, AbstractTestingBase.DATA_PACK.getLootTables().get(CraftNamespacedKey.toMinecraft(key))); } } );