diff --git a/nms-patches/net/minecraft/commands/CommandDispatcher.patch b/nms-patches/net/minecraft/commands/CommandDispatcher.patch index fda4cb73e..a68679da9 100644 --- a/nms-patches/net/minecraft/commands/CommandDispatcher.patch +++ b/nms-patches/net/minecraft/commands/CommandDispatcher.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/CommandDispatcher.java +++ b/net/minecraft/commands/CommandDispatcher.java -@@ -109,6 +109,14 @@ +@@ -116,6 +116,14 @@ import net.minecraft.util.profiling.jfr.JvmProfiler; import org.slf4j.Logger; @@ -15,15 +15,15 @@ public class CommandDispatcher { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -120,6 +128,7 @@ +@@ -127,6 +135,7 @@ private final com.mojang.brigadier.CommandDispatcher dispatcher = new com.mojang.brigadier.CommandDispatcher(); public CommandDispatcher(CommandDispatcher.ServerType commanddispatcher_servertype, CommandBuildContext commandbuildcontext) { + this(); // CraftBukkit CommandAdvancement.register(this.dispatcher); - CommandAttribute.register(this.dispatcher); + CommandAttribute.register(this.dispatcher, commandbuildcontext); CommandExecute.register(this.dispatcher, commandbuildcontext); -@@ -204,6 +213,11 @@ +@@ -212,6 +221,11 @@ CommandPublish.register(this.dispatcher); } @@ -35,7 +35,7 @@ this.dispatcher.setConsumer((commandcontext, flag, i) -> { ((CommandListenerWrapper) commandcontext.getSource()).onCommandComplete(commandcontext, flag, i); }); -@@ -216,12 +230,59 @@ +@@ -224,12 +238,59 @@ return new ParseResults(commandcontextbuilder1, parseresults.getReader(), parseresults.getExceptions()); } @@ -96,7 +96,7 @@ CommandListenerWrapper commandlistenerwrapper = (CommandListenerWrapper) parseresults.getContext().getSource(); commandlistenerwrapper.getServer().getProfiler().push(() -> { -@@ -246,7 +307,7 @@ +@@ -254,7 +315,7 @@ if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) { int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor()); IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.empty().withStyle(EnumChatFormat.GRAY).withStyle((chatmodifier) -> { @@ -105,7 +105,7 @@ }); if (j > 10) { -@@ -296,11 +357,36 @@ +@@ -304,11 +365,36 @@ } public void sendCommands(EntityPlayer entityplayer) { @@ -143,7 +143,7 @@ entityplayer.connection.send(new PacketPlayOutCommands(rootcommandnode)); } -@@ -311,7 +397,7 @@ +@@ -319,7 +405,7 @@ CommandNode commandnode2 = (CommandNode) iterator.next(); if (commandnode2.canUse(commandlistenerwrapper)) { @@ -152,7 +152,7 @@ argumentbuilder.requires((icompletionprovider) -> { return true; -@@ -334,7 +420,7 @@ +@@ -342,7 +428,7 @@ argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect())); } diff --git a/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch b/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch index 332640742..9bb12cce0 100644 --- a/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch +++ b/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/CommandListenerWrapper.java +++ b/net/minecraft/commands/CommandListenerWrapper.java -@@ -38,6 +38,8 @@ +@@ -40,6 +40,8 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; @@ -9,7 +9,7 @@ public class CommandListenerWrapper implements ICompletionProvider { public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(IChatBaseComponent.translatable("permissions.requires.player")); -@@ -58,6 +60,7 @@ +@@ -60,6 +62,7 @@ private final Vec2F rotation; private final CommandSigningContext signingContext; private final TaskChainer chatMessageChainer; @@ -17,7 +17,7 @@ public CommandListenerWrapper(ICommandListener icommandlistener, Vec3D vec3d, Vec2F vec2f, WorldServer worldserver, int i, String s, IChatBaseComponent ichatbasecomponent, MinecraftServer minecraftserver, @Nullable Entity entity) { this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, (commandcontext, flag, j) -> { -@@ -172,9 +175,23 @@ +@@ -170,9 +173,23 @@ @Override public boolean hasPermission(int i) { @@ -41,7 +41,7 @@ public Vec3D getPosition() { return this.worldPosition; } -@@ -300,7 +317,7 @@ +@@ -298,7 +315,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); @@ -50,9 +50,9 @@ entityplayer.sendSystemMessage(ichatmutablecomponent); } } -@@ -368,4 +385,10 @@ - public IRegistryCustom registryAccess() { - return this.server.registryAccess(); +@@ -371,4 +388,10 @@ + public FeatureFlagSet enabledFeatures() { + return this.level.enabledFeatures(); } + + // CraftBukkit start diff --git a/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch b/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch index 8b74ab8a0..6d86c0ea3 100644 --- a/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch +++ b/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch @@ -9,7 +9,7 @@ private final Map vagueProperties = Maps.newHashMap(); private MinecraftKey id = new MinecraftKey(""); @Nullable -@@ -284,7 +284,7 @@ +@@ -276,7 +276,7 @@ Iterator iterator = iblockstate.getPossibleValues().iterator(); while (iterator.hasNext()) { @@ -18,7 +18,7 @@ if (t0 instanceof Integer) { Integer integer = (Integer) t0; -@@ -556,7 +556,7 @@ +@@ -548,7 +548,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); -@@ -592,7 +592,7 @@ +@@ -584,7 +584,7 @@ private static > void appendProperty(StringBuilder stringbuilder, IBlockState iblockstate, Comparable comparable) { stringbuilder.append(iblockstate.getName()); stringbuilder.append('='); diff --git a/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch b/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch index dbf2bf99a..73ff62a16 100644 --- a/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch +++ b/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java +++ b/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java -@@ -149,7 +149,7 @@ +@@ -147,7 +147,7 @@ axisalignedbb = this.createAabb(this.deltaX == null ? 0.0D : this.deltaX, this.deltaY == null ? 0.0D : this.deltaY, this.deltaZ == null ? 0.0D : this.deltaZ); } @@ -9,7 +9,7 @@ if (this.x == null && this.y == null && this.z == null) { function = (vec3d) -> { -@@ -206,8 +206,10 @@ +@@ -204,8 +204,10 @@ }; } @@ -22,7 +22,7 @@ this.suggestions = this::suggestSelector; if (!this.reader.canRead()) { throw ArgumentParserSelector.ERROR_MISSING_SELECTOR_TYPE.createWithContext(this.reader); -@@ -465,6 +467,12 @@ +@@ -463,6 +465,12 @@ } public EntitySelector parse() throws CommandSyntaxException { @@ -35,7 +35,7 @@ this.startPosition = this.reader.getCursor(); this.suggestions = this::suggestNameOrSelector; if (this.reader.canRead() && this.reader.peek() == '@') { -@@ -473,7 +481,7 @@ +@@ -471,7 +479,7 @@ } this.reader.skip(); diff --git a/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch b/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch index 799c40542..e4633ef40 100644 --- a/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch +++ b/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/net/minecraft/commands/arguments/selector/EntitySelector.java -@@ -90,7 +90,7 @@ +@@ -92,7 +92,7 @@ } private void checkPermissions(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException { diff --git a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch index cdf8e995a..335fabca3 100644 --- a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch +++ b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch @@ -47,7 +47,7 @@ + Object object = this.isChestBoat ? new ChestBoat(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()) : new EntityBoat(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); + // CraftBukkit end - ((EntityBoat) object).setType(this.type); + ((EntityBoat) object).setVariant(this.type); ((EntityBoat) object).setYRot(enumdirection.toYRot()); - worldserver.addFreshEntity((Entity) object); - itemstack.shrink(1); diff --git a/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch b/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch index b9ac6bc8d..9b34ddac0 100644 --- a/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch +++ b/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/IDispenseBehavior.java +++ b/net/minecraft/core/dispenser/IDispenseBehavior.java -@@ -76,6 +76,21 @@ +@@ -77,6 +77,21 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import org.slf4j.Logger; @@ -22,7 +22,7 @@ public interface IDispenseBehavior { Logger LOGGER = LogUtils.getLogger(); -@@ -200,14 +215,42 @@ +@@ -201,14 +216,42 @@ EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING); EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(itemstack.getTag()); @@ -67,7 +67,7 @@ isourceblock.getLevel().gameEvent((Entity) null, GameEvent.ENTITY_PLACE, isourceblock.getPos()); return itemstack; } -@@ -226,12 +269,40 @@ +@@ -227,12 +270,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 @@ +@@ -251,8 +322,35 @@ }); if (!list.isEmpty()) { @@ -146,7 +146,7 @@ this.setSuccess(true); return itemstack; } else { -@@ -278,7 +376,35 @@ +@@ -279,7 +377,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 @@ +@@ -322,9 +448,35 @@ } entityhorsechestedabstract = (EntityHorseChestedAbstract) iterator1.next(); @@ -221,7 +221,7 @@ this.setSuccess(true); return itemstack; } -@@ -332,12 +484,41 @@ +@@ -333,12 +485,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 @@ +@@ -360,12 +541,40 @@ double d3 = randomsource.triangle((double) enumdirection.getStepX(), 0.11485000000000001D); double d4 = randomsource.triangle((double) enumdirection.getStepY(), 0.11485000000000001D); double d5 = randomsource.triangle((double) enumdirection.getStepZ(), 0.11485000000000001D); @@ -310,7 +310,7 @@ return itemstack; } -@@ -396,9 +605,52 @@ +@@ -399,9 +608,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); } -@@ -425,7 +677,7 @@ +@@ -428,7 +680,7 @@ Block block = iblockdata.getBlock(); if (block instanceof IFluidSource) { @@ -373,7 +373,7 @@ if (itemstack1.isEmpty()) { return super.execute(isourceblock, itemstack); -@@ -433,6 +685,32 @@ +@@ -436,6 +688,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); -@@ -454,14 +732,42 @@ +@@ -457,14 +735,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); -@@ -487,12 +793,62 @@ +@@ -490,12 +796,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; } -@@ -502,12 +858,41 @@ +@@ -505,12 +861,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; } }); -@@ -531,6 +916,30 @@ +@@ -535,6 +920,30 @@ EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING); BlockPosition blockposition = isourceblock.getPos().relative(enumdirection); @@ -587,9 +587,9 @@ + // CraftBukkit end + 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.setBlock(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.defaultBlockState().setValue(BlockSkull.ROTATION, RotationSegment.convertToSegment(enumdirection)), 3); worldserver.gameEvent((Entity) null, GameEvent.BLOCK_PLACE, blockposition); -@@ -556,6 +965,30 @@ +@@ -560,6 +969,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); -@@ -605,6 +1038,30 @@ +@@ -609,6 +1042,30 @@ BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING)); IBlockData iblockdata = worldserver.getBlockState(blockposition); diff --git a/nms-patches/net/minecraft/network/PacketDataSerializer.patch b/nms-patches/net/minecraft/network/PacketDataSerializer.patch index c76c41103..c3ea1e9b3 100644 --- a/nms-patches/net/minecraft/network/PacketDataSerializer.patch +++ b/nms-patches/net/minecraft/network/PacketDataSerializer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/PacketDataSerializer.java +++ b/net/minecraft/network/PacketDataSerializer.java -@@ -68,6 +68,8 @@ +@@ -74,6 +74,8 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.Vec3D; @@ -9,7 +9,7 @@ public class PacketDataSerializer extends ByteBuf { private static final int MAX_VARINT_SIZE = 5; -@@ -158,7 +160,7 @@ +@@ -195,7 +197,7 @@ public > C readCollection(IntFunction intfunction, PacketDataSerializer.a packetdataserializer_a) { int i = this.readVarInt(); @@ -18,7 +18,7 @@ for (int j = 0; j < i; ++j) { c0.add(packetdataserializer_a.apply(this)); -@@ -169,7 +171,7 @@ +@@ -206,7 +208,7 @@ public void writeCollection(Collection collection, PacketDataSerializer.b packetdataserializer_b) { this.writeVarInt(collection.size()); @@ -27,7 +27,7 @@ while (iterator.hasNext()) { T t0 = iterator.next(); -@@ -196,12 +198,12 @@ +@@ -233,12 +235,12 @@ public void writeIntIdList(IntList intlist) { this.writeVarInt(intlist.size()); @@ -42,7 +42,25 @@ for (int j = 0; j < i; ++j) { K k0 = packetdataserializer_a.apply(this); -@@ -437,7 +439,7 @@ +@@ -272,7 +274,7 @@ + } + + public > void writeEnumSet(EnumSet enumset, Class oclass) { +- E[] ae = (Enum[]) oclass.getEnumConstants(); ++ E[] ae = oclass.getEnumConstants(); // CraftBukkit - decompile error + BitSet bitset = new BitSet(ae.length); + + for (int i = 0; i < ae.length; ++i) { +@@ -283,7 +285,7 @@ + } + + public > EnumSet readEnumSet(Class oclass) { +- E[] ae = (Enum[]) oclass.getEnumConstants(); ++ E[] ae = oclass.getEnumConstants(); // CraftBukkit - decompile error + BitSet bitset = this.readFixedBitSet(ae.length); + EnumSet enumset = EnumSet.noneOf(oclass); + +@@ -499,7 +501,7 @@ } public > T readEnum(Class oclass) { @@ -51,7 +69,7 @@ } public PacketDataSerializer writeEnum(Enum oenum) { -@@ -514,7 +516,7 @@ +@@ -576,7 +578,7 @@ } else { try { NBTCompressedStreamTools.write(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this))); @@ -60,7 +78,7 @@ throw new EncoderException(ioexception); } } -@@ -551,7 +553,7 @@ +@@ -613,7 +615,7 @@ } public PacketDataSerializer writeItem(ItemStack itemstack) { @@ -69,7 +87,7 @@ this.writeBoolean(false); } else { this.writeBoolean(true); -@@ -580,6 +582,11 @@ +@@ -642,6 +644,11 @@ ItemStack itemstack = new ItemStack(item, b0); itemstack.setTag(this.readNbt()); diff --git a/nms-patches/net/minecraft/network/chat/ChatMessageType.patch b/nms-patches/net/minecraft/network/chat/ChatMessageType.patch index 5e8d6ad21..53c44491b 100644 --- a/nms-patches/net/minecraft/network/chat/ChatMessageType.patch +++ b/nms-patches/net/minecraft/network/chat/ChatMessageType.patch @@ -15,16 +15,12 @@ + public static final ResourceKey RAW = create("raw"); // CraftBukkit private static ResourceKey create(String s) { - return ResourceKey.create(IRegistry.CHAT_TYPE_REGISTRY, new MinecraftKey(s)); -@@ -39,7 +41,10 @@ - RegistryGeneration.register(iregistry, ChatMessageType.MSG_COMMAND_OUTGOING, new ChatMessageType(ChatDecoration.outgoingDirectMessage("commands.message.display.outgoing"), ChatDecoration.withSender("chat.type.text.narrate"))); - RegistryGeneration.register(iregistry, ChatMessageType.TEAM_MSG_COMMAND_INCOMING, new ChatMessageType(ChatDecoration.teamMessage("chat.type.team.text"), ChatDecoration.withSender("chat.type.text.narrate"))); - RegistryGeneration.register(iregistry, ChatMessageType.TEAM_MSG_COMMAND_OUTGOING, new ChatMessageType(ChatDecoration.teamMessage("chat.type.team.sent"), ChatDecoration.withSender("chat.type.text.narrate"))); -- return RegistryGeneration.register(iregistry, ChatMessageType.EMOTE_COMMAND, new ChatMessageType(ChatDecoration.withSender("chat.type.emote"), ChatDecoration.withSender("chat.type.emote"))); -+ // CraftBukkit start -+ RegistryGeneration.register(iregistry, ChatMessageType.EMOTE_COMMAND, new ChatMessageType(ChatDecoration.withSender("chat.type.emote"), ChatDecoration.withSender("chat.type.emote"))); -+ return RegistryGeneration.register(iregistry, ChatMessageType.RAW, new ChatMessageType(new ChatDecoration("%s", List.of(ChatDecoration.a.CONTENT), ChatModifier.EMPTY), new ChatDecoration("%s", List.of(ChatDecoration.a.CONTENT), ChatModifier.EMPTY))); -+ // CraftBukkit end + return ResourceKey.create(Registries.CHAT_TYPE, new MinecraftKey(s)); +@@ -40,6 +42,7 @@ + bootstapcontext.register(ChatMessageType.TEAM_MSG_COMMAND_INCOMING, new ChatMessageType(ChatDecoration.teamMessage("chat.type.team.text"), ChatDecoration.withSender("chat.type.text.narrate"))); + bootstapcontext.register(ChatMessageType.TEAM_MSG_COMMAND_OUTGOING, new ChatMessageType(ChatDecoration.teamMessage("chat.type.team.sent"), ChatDecoration.withSender("chat.type.text.narrate"))); + bootstapcontext.register(ChatMessageType.EMOTE_COMMAND, new ChatMessageType(ChatDecoration.withSender("chat.type.emote"), ChatDecoration.withSender("chat.type.emote"))); ++ bootstapcontext.register(ChatMessageType.RAW, new ChatMessageType(new ChatDecoration("%s", List.of(ChatDecoration.a.CONTENT), ChatModifier.EMPTY), new ChatDecoration("%s", List.of(ChatDecoration.a.CONTENT), ChatModifier.EMPTY))); // CraftBukkit } public static ChatMessageType.a bind(ResourceKey resourcekey, Entity entity) { diff --git a/nms-patches/net/minecraft/network/syncher/DataWatcher.patch b/nms-patches/net/minecraft/network/syncher/DataWatcher.patch index d907cbb52..31b97b17e 100644 --- a/nms-patches/net/minecraft/network/syncher/DataWatcher.patch +++ b/nms-patches/net/minecraft/network/syncher/DataWatcher.patch @@ -1,6 +1,18 @@ --- a/net/minecraft/network/syncher/DataWatcher.java +++ b/net/minecraft/network/syncher/DataWatcher.java -@@ -142,6 +142,13 @@ +@@ -24,6 +24,11 @@ + import org.apache.commons.lang3.ObjectUtils; + import org.slf4j.Logger; + ++// CraftBukkit start ++import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; ++import net.minecraft.server.level.EntityPlayer; ++// CraftBukkit end ++ + public class DataWatcher { + + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -138,6 +143,13 @@ } @@ -14,12 +26,40 @@ public boolean isDirty() { return this.isDirty; } -@@ -274,7 +281,7 @@ - if (!Objects.equals(datawatcher_item1.accessor.getSerializer(), datawatcher_item.accessor.getSerializer())) { - throw new IllegalStateException(String.format(Locale.ROOT, "Invalid entity data item type for field %d on entity %s: old=%s(%s), new=%s(%s)", datawatcher_item.accessor.getId(), this.entity, datawatcher_item.value, datawatcher_item.value.getClass(), datawatcher_item1.value, datawatcher_item1.value.getClass())); +@@ -218,7 +230,7 @@ + if (!Objects.equals(datawatcher_b.serializer(), datawatcher_item.accessor.getSerializer())) { + throw new IllegalStateException(String.format(Locale.ROOT, "Invalid entity data item type for field %d on entity %s: old=%s(%s), new=%s(%s)", datawatcher_item.accessor.getId(), this.entity, datawatcher_item.value, datawatcher_item.value.getClass(), datawatcher_b.value, datawatcher_b.value.getClass())); } else { -- datawatcher_item.setValue(datawatcher_item1.getValue()); -+ datawatcher_item.setValue((T) datawatcher_item1.getValue()); // CraftBukkit - decompile error +- datawatcher_item.setValue(datawatcher_b.value); ++ datawatcher_item.setValue((T) datawatcher_b.value); // CraftBukkit - decompile error } } +@@ -226,6 +238,18 @@ + return this.itemsById.isEmpty(); + } + ++ // CraftBukkit start ++ public void refresh(EntityPlayer to) { ++ if (!this.isEmpty()) { ++ List> list = this.getNonDefaultValues(); ++ ++ if (list != null) { ++ to.connection.send(new PacketPlayOutEntityMetadata(this.entity.getId(), list)); ++ } ++ } ++ } ++ // CraftBukkit end ++ + public static class Item { + + final DataWatcherObject accessor; +@@ -268,7 +292,7 @@ + } + } + +- public static record b (int id, DataWatcherSerializer serializer, T value) { ++ public static record b(int id, DataWatcherSerializer serializer, T value) { // CraftBukkit - decompile error + + public static DataWatcher.b create(DataWatcherObject datawatcherobject, T t0) { + DataWatcherSerializer datawatcherserializer = datawatcherobject.getSerializer(); diff --git a/nms-patches/net/minecraft/resources/ResourceKey.patch b/nms-patches/net/minecraft/resources/ResourceKey.patch deleted file mode 100644 index c827ed500..000000000 --- a/nms-patches/net/minecraft/resources/ResourceKey.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/minecraft/resources/ResourceKey.java -+++ b/net/minecraft/resources/ResourceKey.java -@@ -9,7 +9,7 @@ - - public class ResourceKey { - -- private static final Map> VALUES = Collections.synchronizedMap(Maps.newIdentityHashMap()); -+ private static final Map> VALUES = Collections.synchronizedMap(Maps.newHashMap()); // CraftBukkit - SPIGOT-6973: remove costly intern - private final MinecraftKey registryName; - private final MinecraftKey location; - -@@ -28,7 +28,7 @@ - } - - private static ResourceKey create(MinecraftKey minecraftkey, MinecraftKey minecraftkey1) { -- String s = (minecraftkey + ":" + minecraftkey1).intern(); -+ String s = (minecraftkey + ":" + minecraftkey1); // CraftBukkit - SPIGOT-6973: remove costly intern - - return (ResourceKey) ResourceKey.VALUES.computeIfAbsent(s, (s1) -> { - return new ResourceKey<>(minecraftkey, minecraftkey1); -@@ -49,7 +49,7 @@ - } - - public Optional> cast(ResourceKey> resourcekey) { -- return this.isFor(resourcekey) ? Optional.of(this) : Optional.empty(); -+ return this.isFor(resourcekey) ? (Optional) Optional.of(this) : Optional.empty(); // CraftBukkit - decompile error - } - - public MinecraftKey location() { diff --git a/nms-patches/net/minecraft/server/DispenserRegistry.patch b/nms-patches/net/minecraft/server/DispenserRegistry.patch index 916bb76c0..266dca74e 100644 --- a/nms-patches/net/minecraft/server/DispenserRegistry.patch +++ b/nms-patches/net/minecraft/server/DispenserRegistry.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/DispenserRegistry.java +++ b/net/minecraft/server/DispenserRegistry.java -@@ -32,6 +32,12 @@ - import net.minecraft.world.level.levelgen.placement.PlacedFeature; +@@ -26,6 +26,12 @@ + import net.minecraft.world.level.block.BlockFire; import org.slf4j.Logger; +// CraftBukkit start @@ -13,7 +13,7 @@ public class DispenserRegistry { public static final PrintStream STDOUT = System.out; -@@ -42,6 +48,23 @@ +@@ -36,6 +42,23 @@ public static void bootStrap() { if (!DispenserRegistry.isBootstrapped) { @@ -35,10 +35,10 @@ + } + // CraftBukkit end DispenserRegistry.isBootstrapped = true; - if (IRegistry.REGISTRY.keySet().isEmpty()) { + if (BuiltInRegistries.REGISTRY.keySet().isEmpty()) { throw new IllegalStateException("Unable to load registries"); -@@ -58,6 +81,69 @@ - IRegistry.freezeBuiltins(); +@@ -52,6 +75,69 @@ + BuiltInRegistries.bootStrap(); wrapStreams(); } + // CraftBukkit start - easier than fixing the decompile diff --git a/nms-patches/net/minecraft/server/Main.patch b/nms-patches/net/minecraft/server/Main.patch index c1643ada4..3494b2d39 100644 --- a/nms-patches/net/minecraft/server/Main.patch +++ b/nms-patches/net/minecraft/server/Main.patch @@ -1,11 +1,12 @@ --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -58,6 +58,15 @@ +@@ -59,6 +59,16 @@ import net.minecraft.world.level.storage.WorldInfo; import org.slf4j.Logger; +// CraftBukkit start +import com.google.common.base.Charsets; ++import com.mojang.bridge.game.PackType; +import java.io.InputStreamReader; +import java.util.concurrent.atomic.AtomicReference; +import net.minecraft.SharedConstants; @@ -16,7 +17,7 @@ public class Main { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -65,8 +74,9 @@ +@@ -66,8 +76,9 @@ public Main() {} @DontObfuscate @@ -27,7 +28,7 @@ OptionParser optionparser = new OptionParser(); OptionSpec optionspec = optionparser.accepts("nogui"); OptionSpec optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); -@@ -91,9 +101,12 @@ +@@ -92,9 +103,12 @@ optionparser.printHelpOn(System.err); return; } @@ -41,7 +42,7 @@ JvmProfiler.INSTANCE.start(Environment.SERVER); } -@@ -101,13 +114,26 @@ +@@ -102,13 +116,26 @@ DispenserRegistry.validate(); SystemUtils.startTimerHackThread(); Path path = Paths.get("server.properties"); @@ -70,7 +71,7 @@ Main.LOGGER.info("Initialized '{}' and '{}'", path.toAbsolutePath(), path1.toAbsolutePath()); return; } -@@ -117,11 +143,12 @@ +@@ -118,11 +145,12 @@ return; } @@ -86,7 +87,7 @@ WorldInfo worldinfo = convertable_conversionsession.getSummary(); if (worldinfo != null) { -@@ -136,13 +163,32 @@ +@@ -137,13 +165,31 @@ } } @@ -97,7 +98,7 @@ Main.LOGGER.warn("Safe mode active, only vanilla datapack will be loaded"); } - ResourcePackRepository resourcepackrepository = new ResourcePackRepository(EnumResourcePackType.SERVER_DATA, new ResourcePackSource[]{new ResourcePackSourceVanilla(), new ResourcePackSourceFolder(convertable_conversionsession.getLevelPath(SavedFile.DATAPACK_DIR).toFile(), PackSource.WORLD)}); + ResourcePackRepository resourcepackrepository = ResourcePackSourceVanilla.createPackRepository(convertable_conversionsession.getLevelPath(SavedFile.DATAPACK_DIR)); + // CraftBukkit start + File bukkitDataPackFolder = new File(convertable_conversionsession.getLevelPath(SavedFile.DATAPACK_DIR).toFile(), "bukkit"); + if (!bukkitDataPackFolder.exists()) { @@ -108,55 +109,59 @@ + com.google.common.io.Files.write("{\n" + + " \"pack\": {\n" + + " \"description\": \"Data pack for resources provided by Bukkit plugins\",\n" -+ + " \"pack_format\": " + SharedConstants.getCurrentVersion().getPackVersion() + "\n" ++ + " \"pack_format\": " + SharedConstants.getCurrentVersion().getPackVersion(PackType.DATA) + "\n" + + " }\n" + + "}\n", mcMeta, com.google.common.base.Charsets.UTF_8); + } catch (java.io.IOException ex) { + throw new RuntimeException("Could not initialize Bukkit datapack", ex); + } -+ AtomicReference config = new AtomicReference<>(); -+ AtomicReference> ops = new AtomicReference<>(); ++ AtomicReference worldLoader = new AtomicReference<>(); + // CraftBukkit end WorldStem worldstem; -@@ -155,6 +201,12 @@ - return WorldStem.load(worldloader_a, (iresourcemanager, datapackconfiguration1) -> { - IRegistryCustom.e iregistrycustom_e = IRegistryCustom.builtinCopy(); - DynamicOps dynamicops = RegistryOps.createAndLoad(DynamicOpsNBT.INSTANCE, iregistrycustom_e, iresourcemanager); -+ // CraftBukkit start -+ config.set(datapackconfiguration1); -+ ops.set(dynamicops); -+ return Pair.of(null, iregistrycustom_e.freeze()); -+ // CraftBukkit end -+ /* - SaveData savedata = convertable_conversionsession.getDataTag(dynamicops, datapackconfiguration1, iregistrycustom_e.allElementsLifecycle()); +@@ -152,6 +198,7 @@ - if (savedata != null) { -@@ -177,6 +229,7 @@ + worldstem = (WorldStem) SystemUtils.blockUntilDone((executor) -> { + return WorldLoader.load(worldloader_c, (worldloader_a) -> { ++ worldLoader.set(worldloader_a); // CraftBukkit + IRegistry iregistry = worldloader_a.datapackDimensions().registryOrThrow(Registries.LEVEL_STEM); + DynamicOps dynamicops = RegistryOps.create(DynamicOpsNBT.INSTANCE, (HolderLookup.b) worldloader_a.datapackWorldgen()); + Pair pair = convertable_conversionsession.getDataTag(dynamicops, worldloader_a.dataConfiguration(), iregistry, worldloader_a.datapackWorldgen().allRegistriesLifecycle()); +@@ -163,7 +210,7 @@ + WorldOptions worldoptions; + WorldDimensions worlddimensions; - return Pair.of(worlddataserver, iregistrycustom_e.freeze()); - } -+ */ - }, SystemUtils.backgroundExecutor(), executor); - }).get(); - } catch (Exception exception) { -@@ -184,6 +237,7 @@ +- if (optionset.has(optionspec2)) { ++ if (optionset.has("demo")) { // CraftBukkit + worldsettings = MinecraftServer.DEMO_SETTINGS; + worldoptions = WorldOptions.DEMO_OPTIONS; + worlddimensions = WorldPresets.createNormalWorldDimensions(worldloader_a.datapackWorldgen()); +@@ -171,7 +218,7 @@ + DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.getProperties(); + + worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), worldloader_a.dataConfiguration()); +- worldoptions = optionset.has(optionspec3) ? dedicatedserverproperties.worldOptions.withBonusChest(true) : dedicatedserverproperties.worldOptions; ++ worldoptions = optionset.has("bonusChest") ? dedicatedserverproperties.worldOptions.withBonusChest(true) : dedicatedserverproperties.worldOptions; // CraftBukkit + worlddimensions = dedicatedserverproperties.createDimensions(worldloader_a.datapackWorldgen()); + } + +@@ -187,6 +234,7 @@ return; } + /* - IRegistryCustom.Dimension iregistrycustom_dimension = worldstem.registryAccess(); + IRegistryCustom.Dimension iregistrycustom_dimension = worldstem.registries().compositeAccess(); - dedicatedserversettings.getProperties().getWorldGenSettings(iregistrycustom_dimension); -@@ -196,21 +250,32 @@ - } + if (optionset.has(optionspec4)) { +@@ -198,21 +246,32 @@ + SaveData savedata = worldstem.worldData(); convertable_conversionsession.saveDataTag(iregistrycustom_dimension, savedata); + */ final DedicatedServer dedicatedserver = (DedicatedServer) MinecraftServer.spin((thread) -> { - DedicatedServer dedicatedserver1 = new DedicatedServer(thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), services, WorldLoadListenerLogger::new); -+ DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, config.get(), ops.get(), thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), services, WorldLoadListenerLogger::new); ++ DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, worldLoader.get(), thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), services, WorldLoadListenerLogger::new); + /* dedicatedserver1.setSingleplayerProfile(optionset.has(optionspec8) ? new GameProfile((UUID) null, (String) optionset.valueOf(optionspec8)) : null); @@ -184,7 +189,7 @@ Thread thread = new Thread("Server Shutdown Thread") { public void run() { dedicatedserver.halt(true); -@@ -219,6 +284,7 @@ +@@ -221,6 +280,7 @@ thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER)); Runtime.getRuntime().addShutdownHook(thread); @@ -192,12 +197,12 @@ } catch (Exception exception1) { Main.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", exception1); } -@@ -226,7 +292,7 @@ +@@ -246,7 +306,7 @@ } - public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, GeneratorSettings generatorsettings) { + public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, IRegistry iregistry) { - Main.LOGGER.info("Forcing world upgrade!"); + Main.LOGGER.info("Forcing world upgrade! {}", convertable_conversionsession.getLevelId()); // CraftBukkit - WorldUpgrader worldupgrader = new WorldUpgrader(convertable_conversionsession, datafixer, generatorsettings, flag); + WorldUpgrader worldupgrader = new WorldUpgrader(convertable_conversionsession, datafixer, iregistry, flag); IChatBaseComponent ichatbasecomponent = null; diff --git a/nms-patches/net/minecraft/server/MinecraftServer.patch b/nms-patches/net/minecraft/server/MinecraftServer.patch index 25578bc75..d4578ed50 100644 --- a/nms-patches/net/minecraft/server/MinecraftServer.patch +++ b/nms-patches/net/minecraft/server/MinecraftServer.patch @@ -1,28 +1,29 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -157,6 +157,31 @@ +@@ -165,6 +165,32 @@ import org.apache.commons.lang3.Validate; import org.slf4j.Logger; +// CraftBukkit start ++import com.mojang.datafixers.util.Pair; +import com.mojang.serialization.DynamicOps; +import com.mojang.serialization.Lifecycle; +import java.util.Random; +import jline.console.ConsoleReader; +import joptsimple.OptionSet; ++import net.minecraft.core.HolderLookup; +import net.minecraft.nbt.DynamicOpsNBT; +import net.minecraft.nbt.NBTBase; ++import net.minecraft.resources.RegistryOps; +import net.minecraft.server.dedicated.DedicatedServer; +import net.minecraft.server.dedicated.DedicatedServerProperties; +import net.minecraft.util.datafix.DataConverterRegistry; -+import net.minecraft.world.level.biome.WorldChunkManager; -+import net.minecraft.world.level.levelgen.ChunkGeneratorAbstract; ++import net.minecraft.world.level.levelgen.WorldDimensions; +import net.minecraft.world.level.levelgen.presets.WorldPresets; +import net.minecraft.world.level.storage.WorldDataServer; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.Main; -+import org.bukkit.craftbukkit.generator.CustomWorldChunkManager; +import org.bukkit.craftbukkit.util.CraftChatMessage; +import org.bukkit.craftbukkit.util.LazyPlayerSet; +import org.bukkit.event.player.AsyncPlayerChatPreviewEvent; @@ -32,22 +33,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant implements ICommandListener, AutoCloseable { public static final Logger LOGGER = LogUtils.getLogger(); -@@ -195,7 +220,7 @@ - private String localIp; - private int port; - public final IRegistryCustom.Dimension registryHolder; -- public final Map, WorldServer> levels; -+ private Map, WorldServer> levels; - private PlayerList playerList; - private volatile boolean running; - private boolean stopped; -@@ -239,6 +264,21 @@ +@@ -247,6 +273,20 @@ protected SaveData worldData; private volatile boolean isSaving; + // CraftBukkit start -+ public final DataPackConfiguration datapackconfiguration; -+ public final DynamicOps registryreadops; ++ public final WorldLoader.a worldLoader; + public org.bukkit.craftbukkit.CraftServer server; + public OptionSet options; + public org.bukkit.command.ConsoleCommandSender console; @@ -63,7 +54,7 @@ public static S spin(Function function) { AtomicReference atomicreference = new AtomicReference(); Thread thread = new Thread(() -> { -@@ -252,14 +292,14 @@ +@@ -260,14 +300,14 @@ thread.setPriority(8); } @@ -76,27 +67,26 @@ } - public MinecraftServer(Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) { -+ public MinecraftServer(OptionSet options, DataPackConfiguration datapackconfiguration, DynamicOps registryreadops, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) { ++ public MinecraftServer(OptionSet options, WorldLoader.a worldLoader, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) { super("Server"); this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; this.profiler = this.metricsRecorder.getProfiler(); -@@ -280,7 +320,7 @@ +@@ -288,7 +328,7 @@ this.frameTimer = new CircularTimer(); - this.registryHolder = worldstem.registryAccess(); + this.registries = worldstem.registries(); this.worldData = worldstem.worldData(); -- if (!this.worldData.worldGenSettings().dimensions().containsKey(WorldDimension.OVERWORLD)) { -+ if (false && !this.worldData.worldGenSettings().dimensions().containsKey(WorldDimension.OVERWORLD)) { // CraftBukkit - initialised later +- if (!this.registries.compositeAccess().registryOrThrow(Registries.LEVEL_STEM).containsKey(WorldDimension.OVERWORLD)) { ++ if (false && !this.registries.compositeAccess().registryOrThrow(Registries.LEVEL_STEM).containsKey(WorldDimension.OVERWORLD)) { // CraftBukkit - initialised later throw new IllegalStateException("Missing Overworld dimension data"); } else { this.proxy = proxy; -@@ -301,13 +341,41 @@ +@@ -311,13 +351,40 @@ this.serverThread = thread; this.executor = SystemUtils.backgroundExecutor(); } + // CraftBukkit start + this.options = options; -+ this.datapackconfiguration = datapackconfiguration; -+ this.registryreadops = registryreadops; ++ this.worldLoader = worldLoader; + 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) { @@ -132,7 +122,7 @@ ScoreboardServer scoreboardserver1 = this.getScoreboard(); Objects.requireNonNull(scoreboardserver1); -@@ -316,7 +384,7 @@ +@@ -326,7 +393,7 @@ protected abstract boolean initServer() throws IOException; @@ -141,7 +131,7 @@ if (!JvmProfiler.INSTANCE.isRunning()) { ; } -@@ -324,12 +392,8 @@ +@@ -334,12 +401,8 @@ boolean flag = false; ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted(); @@ -155,7 +145,7 @@ if (profiledduration != null) { profiledduration.finish(); } -@@ -344,25 +408,189 @@ +@@ -354,25 +417,183 @@ } @@ -163,39 +153,10 @@ + // CraftBukkit start + private void loadWorld0(String s) { + Convertable.ConversionSession worldSession = this.storageSource; -+ IRegistryCustom.Dimension iregistrycustom_dimension = this.registryHolder; -+ WorldDataServer overworldData = (WorldDataServer) worldSession.getDataTag(registryreadops, datapackconfiguration, iregistrycustom_dimension.allElementsLifecycle()); -+ if (overworldData == null) { -+ WorldSettings worldsettings; -+ GeneratorSettings generatorsettings; + -+ if (this.isDemo()) { -+ worldsettings = MinecraftServer.DEMO_SETTINGS; -+ generatorsettings = WorldPresets.demoSettings(iregistrycustom_dimension); -+ } else { -+ DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getProperties(); - -- protected void createLevels(WorldLoadListener worldloadlistener) { -- IWorldDataServer iworlddataserver = this.worldData.overworldData(); -- GeneratorSettings generatorsettings = this.worldData.worldGenSettings(); -- boolean flag = generatorsettings.isDebug(); -- long i = generatorsettings.seed(); -- long j = BiomeManager.obfuscateSeed(i); -- List list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver)); -- IRegistry iregistry = generatorsettings.dimensions(); -- WorldDimension worlddimension = (WorldDimension) iregistry.get(WorldDimension.OVERWORLD); -- WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, worlddimension, worldloadlistener, flag, j, list, true); -+ 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); -+ } -+ -+ overworldData = new WorldDataServer(worldsettings, generatorsettings, Lifecycle.stable()); -+ } -+ -+ GeneratorSettings overworldSettings = overworldData.worldGenSettings(); -+ IRegistry iregistry = overworldSettings.dimensions(); -+ for (WorldDimension worldDimension : iregistry) { -+ ResourceKey dimensionKey = iregistry.getResourceKey(worldDimension).get(); ++ IRegistry dimensions = this.registries.compositeAccess().registryOrThrow(Registries.LEVEL_STEM); ++ for (WorldDimension worldDimension : dimensions) { ++ ResourceKey dimensionKey = dimensions.getResourceKey(worldDimension).get(); + + WorldServer world; + int dimension = 0; @@ -215,7 +176,17 @@ + } else if (dimensionKey != WorldDimension.OVERWORLD) { + dimension = -999; + } -+ + +- protected void createLevels(WorldLoadListener worldloadlistener) { +- IWorldDataServer iworlddataserver = this.worldData.overworldData(); +- boolean flag = this.worldData.isDebugWorld(); +- IRegistry iregistry = this.registries.compositeAccess().registryOrThrow(Registries.LEVEL_STEM); +- WorldOptions worldoptions = this.worldData.worldGenOptions(); +- long i = worldoptions.seed(); +- long j = BiomeManager.obfuscateSeed(i); +- List list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver)); +- WorldDimension worlddimension = (WorldDimension) iregistry.get(WorldDimension.OVERWORLD); +- WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, worlddimension, worldloadlistener, flag, j, list, true); + String worldType = (dimension == -999) ? dimensionKey.location().getNamespace() + "_" + dimensionKey.location().getPath() : org.bukkit.World.Environment.getEnvironment(dimension).toString().toLowerCase(); + String name = (dimensionKey == WorldDimension.OVERWORLD) ? s : s + "_" + worldType; + if (dimension != 0) { @@ -252,7 +223,9 @@ + MinecraftServer.LOGGER.info("---- Migration of old " + worldType + " folder failed ----"); + } + } -+ + +- this.levels.put(World.OVERWORLD, worldserver); +- WorldPersistentData worldpersistentdata = worldserver.getDataStorage(); + try { + worldSession = Convertable.createDefault(server.getWorldContainer().toPath()).createAccess(name, dimensionKey); + } catch (IOException ex) { @@ -262,45 +235,60 @@ + + org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name); + org.bukkit.generator.BiomeProvider biomeProvider = this.server.getBiomeProvider(name); + +- this.readScoreboard(worldpersistentdata); +- this.commandStorage = new PersistentCommandStorage(worldpersistentdata); ++ WorldDataServer worlddata; ++ WorldLoader.a worldloader_a = this.worldLoader; ++ IRegistry iregistry = worldloader_a.datapackDimensions().registryOrThrow(Registries.LEVEL_STEM); ++ DynamicOps dynamicops = RegistryOps.create(DynamicOpsNBT.INSTANCE, (HolderLookup.b) worldloader_a.datapackWorldgen()); ++ Pair pair = worldSession.getDataTag(dynamicops, worldloader_a.dataConfiguration(), iregistry, worldloader_a.datapackWorldgen().allRegistriesLifecycle()); + -+ WorldDataServer worlddata = (WorldDataServer) worldSession.getDataTag((DynamicOps) registryreadops, datapackconfiguration, iregistrycustom_dimension.allElementsLifecycle()); -+ if (worlddata == null) { ++ if (pair != null) { ++ worlddata = (WorldDataServer) pair.getFirst(); ++ } else { + WorldSettings worldsettings; -+ GeneratorSettings generatorsettings; ++ WorldOptions worldoptions; ++ WorldDimensions worlddimensions; + + if (this.isDemo()) { + worldsettings = MinecraftServer.DEMO_SETTINGS; -+ generatorsettings = WorldPresets.demoSettings(iregistrycustom_dimension); ++ worldoptions = WorldOptions.DEMO_OPTIONS; ++ worlddimensions = WorldPresets.createNormalWorldDimensions(worldloader_a.datapackWorldgen()); + } else { + DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getProperties(); + -+ worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), datapackconfiguration); -+ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.getWorldGenSettings(iregistrycustom_dimension).withBonusChest() : dedicatedserverproperties.getWorldGenSettings(iregistrycustom_dimension); ++ worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), worldloader_a.dataConfiguration()); ++ worldoptions = options.has("bonusChest") ? dedicatedserverproperties.worldOptions.withBonusChest(true) : dedicatedserverproperties.worldOptions; ++ worlddimensions = dedicatedserverproperties.createDimensions(worldloader_a.datapackWorldgen()); + } + -+ worlddata = new WorldDataServer(worldsettings, generatorsettings, Lifecycle.stable()); ++ WorldDimensions.b worlddimensions_b = worlddimensions.bake(iregistry); ++ Lifecycle lifecycle = worlddimensions_b.lifecycle().add(worldloader_a.datapackWorldgen().allRegistriesLifecycle()); ++ ++ worlddata = new WorldDataServer(worldsettings, worldoptions, worlddimensions_b.specialWorldProperty(), lifecycle); + } + worlddata.checkName(name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end) + if (options.has("forceUpgrade")) { + net.minecraft.server.Main.forceUpgrade(worldSession, DataConverterRegistry.getDataFixer(), options.has("eraseCache"), () -> { + return true; -+ }, worlddata.worldGenSettings()); ++ }, iregistry); + } + + WorldDataServer iworlddataserver = worlddata; -+ GeneratorSettings generatorsettings = worlddata.worldGenSettings(); -+ boolean flag = generatorsettings.isDebug(); -+ long i = generatorsettings.seed(); ++ boolean flag = worlddata.isDebugWorld(); ++ WorldOptions worldoptions = worlddata.worldGenOptions(); ++ long i = worldoptions.seed(); + long j = BiomeManager.obfuscateSeed(i); + List list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver)); -+ WorldDimension worlddimension = (WorldDimension) iregistry.get(dimensionKey); ++ WorldDimension worlddimension = (WorldDimension) dimensions.get(dimensionKey); + -+ org.bukkit.generator.WorldInfo worldInfo = new org.bukkit.craftbukkit.generator.CraftWorldInfo(iworlddataserver, worldSession, org.bukkit.World.Environment.getEnvironment(dimension), worlddimension.typeHolder().value()); ++ org.bukkit.generator.WorldInfo worldInfo = new org.bukkit.craftbukkit.generator.CraftWorldInfo(iworlddataserver, worldSession, org.bukkit.World.Environment.getEnvironment(dimension), worlddimension.type().value()); + if (biomeProvider == null && gen != null) { + biomeProvider = gen.getDefaultBiomeProvider(worldInfo); + } + -+ ResourceKey worldKey = ResourceKey.create(IRegistry.DIMENSION_REGISTRY, dimensionKey.location()); ++ ResourceKey worldKey = ResourceKey.create(Registries.DIMENSION, dimensionKey.location()); + + if (dimensionKey == WorldDimension.OVERWORLD) { + this.worldData = worlddata; @@ -319,7 +307,7 @@ + } + + worlddata.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified()); -+ this.initWorld(world, worlddata, worldData, worlddata.worldGenSettings()); ++ this.initWorld(world, worlddata, worldData, worldoptions); + + this.addLevel(world); + this.getPlayerList().addWorldborderListener(world); @@ -340,16 +328,12 @@ + this.connection.acceptConnections(); + } + // CraftBukkit end - -- this.levels.put(World.OVERWORLD, worldserver); -- WorldPersistentData worldpersistentdata = worldserver.getDataStorage(); ++ + protected void forceDifficulty() {} - -- this.readScoreboard(worldpersistentdata); -- this.commandStorage = new PersistentCommandStorage(worldpersistentdata); ++ + // CraftBukkit start -+ public void initWorld(WorldServer worldserver, IWorldDataServer iworlddataserver, SaveData saveData, GeneratorSettings generatorsettings) { -+ boolean flag = generatorsettings.isDebug(); ++ public void initWorld(WorldServer worldserver, IWorldDataServer iworlddataserver, SaveData saveData, WorldOptions worldoptions) { ++ boolean flag = saveData.isDebugWorld(); + // CraftBukkit start + if (worldserver.generator != null) { + worldserver.getWorld().getPopulators().addAll(worldserver.generator.getDefaultPopulators(worldserver.getWorld())); @@ -360,7 +344,7 @@ if (!iworlddataserver.isInitialized()) { try { -@@ -386,29 +614,8 @@ +@@ -396,29 +617,8 @@ iworlddataserver.setInitialized(true); } @@ -376,7 +360,7 @@ - ResourceKey resourcekey = (ResourceKey) entry.getKey(); - - if (resourcekey != WorldDimension.OVERWORLD) { -- ResourceKey resourcekey1 = ResourceKey.create(IRegistry.DIMENSION_REGISTRY, resourcekey.location()); +- ResourceKey resourcekey1 = ResourceKey.create(Registries.DIMENSION, resourcekey.location()); - SecondaryWorldData secondaryworlddata = new SecondaryWorldData(this.worldData, iworlddataserver); - WorldServer worldserver1 = new WorldServer(this, this.executor, this.storageSource, secondaryworlddata, resourcekey1, (WorldDimension) entry.getValue(), worldloadlistener, flag, j, ImmutableList.of(), false); - @@ -391,7 +375,7 @@ private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) { if (flag1) { -@@ -416,6 +623,21 @@ +@@ -426,6 +626,21 @@ } else { ChunkProviderServer chunkproviderserver = worldserver.getChunkSource(); ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition()); @@ -413,7 +397,7 @@ int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver); if (i < worldserver.getMinBuildHeight()) { -@@ -473,8 +695,11 @@ +@@ -485,8 +700,11 @@ iworlddataserver.setGameType(EnumGamemode.SPECTATOR); } @@ -427,7 +411,7 @@ MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location()); BlockPosition blockposition = worldserver.getSharedSpawnPos(); -@@ -484,19 +709,23 @@ +@@ -496,19 +714,23 @@ chunkproviderserver.getLightEngine().setTaskPerBatch(500); this.nextTickTime = SystemUtils.getMillis(); @@ -460,7 +444,7 @@ ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk::load, "chunks"); if (forcedchunk != null) { -@@ -511,11 +740,18 @@ +@@ -523,11 +745,18 @@ } } @@ -482,7 +466,7 @@ } public EnumGamemode getDefaultGameType() { -@@ -545,12 +781,16 @@ +@@ -557,12 +786,16 @@ worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2); } @@ -499,7 +483,7 @@ if (flag1) { Iterator iterator1 = this.getAllLevels().iterator(); -@@ -585,12 +825,33 @@ +@@ -597,12 +830,33 @@ this.stopServer(); } @@ -533,7 +517,7 @@ if (this.getConnection() != null) { this.getConnection().stop(); } -@@ -600,6 +861,7 @@ +@@ -612,6 +866,7 @@ MinecraftServer.LOGGER.info("Saving players"); this.playerList.saveAll(); this.playerList.removeAll(); @@ -541,7 +525,7 @@ } MinecraftServer.LOGGER.info("Saving worlds"); -@@ -696,9 +958,10 @@ +@@ -707,9 +962,10 @@ while (this.running) { long i = SystemUtils.getMillis() - this.nextTickTime; @@ -553,7 +537,7 @@ 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; -@@ -709,6 +972,7 @@ +@@ -720,6 +976,7 @@ this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount); } @@ -561,7 +545,7 @@ this.nextTickTime += 50L; this.startMetricsRecordingTick(); this.profiler.push("tick"); -@@ -747,6 +1011,12 @@ +@@ -758,6 +1015,12 @@ this.services.profileCache().clearExecutor(); } @@ -574,24 +558,25 @@ this.onServerExit(); } -@@ -780,8 +1050,15 @@ +@@ -791,9 +1054,16 @@ } private boolean haveTime() { - return this.runningTask() || SystemUtils.getMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime); + // CraftBukkit start + return this.forceTicks || this.runningTask() || SystemUtils.getMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime); -+ } -+ + } + + private void executeModerately() { + this.runAllTasks(); + java.util.concurrent.locks.LockSupport.parkNanos("executing tasks", 1000L); - } ++ } + // CraftBukkit end - ++ protected void waitUntilNextTick() { this.runAllTasks(); -@@ -827,7 +1104,7 @@ + this.managedBlock(() -> { +@@ -838,7 +1108,7 @@ } } @@ -600,7 +585,7 @@ this.getProfiler().incrementCounter("runTask"); super.doRunTask(ticktask); } -@@ -898,7 +1175,7 @@ +@@ -909,7 +1179,7 @@ } } @@ -609,7 +594,7 @@ MinecraftServer.LOGGER.debug("Autosave started"); this.profiler.push("save"); this.saveEverything(true, false, false); -@@ -917,22 +1194,39 @@ +@@ -928,22 +1198,39 @@ } public void tickChildren(BooleanSupplier booleansupplier) { @@ -649,7 +634,7 @@ this.profiler.push("tick"); -@@ -995,6 +1289,22 @@ +@@ -1006,6 +1293,22 @@ return (WorldServer) this.levels.get(resourcekey); } @@ -672,7 +657,7 @@ public Set> levelKeys() { return this.levels.keySet(); } -@@ -1021,7 +1331,7 @@ +@@ -1032,7 +1335,7 @@ @DontObfuscate public String getServerModName() { @@ -681,9 +666,9 @@ } public SystemReport fillSystemReport(SystemReport systemreport) { -@@ -1372,11 +1682,11 @@ +@@ -1370,11 +1673,11 @@ public CompletableFuture reloadResources(Collection collection) { - IRegistryCustom.Dimension iregistrycustom_dimension = this.registryAccess(); + IRegistryCustom.Dimension iregistrycustom_dimension = this.registries.getAccessForLoading(RegistryLayer.RELOADABLE); CompletableFuture completablefuture = CompletableFuture.supplyAsync(() -> { - Stream stream = collection.stream(); + Stream stream = collection.stream(); // CraftBukkit - decompile error @@ -695,15 +680,15 @@ }, this).thenCompose((immutablelist) -> { ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist); -@@ -1391,6 +1701,7 @@ +@@ -1389,6 +1692,7 @@ }).thenAcceptAsync((minecraftserver_reloadableresources) -> { this.resources.close(); this.resources = minecraftserver_reloadableresources; + this.server.syncCommands(); // SPIGOT-5884: Lost on reload this.packRepository.setSelected(collection); - this.worldData.setDataPackConfig(getSelectedPacks(this.packRepository)); - this.resources.managers.updateRegistryTags(this.registryAccess()); -@@ -1740,7 +2051,7 @@ + WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(getSelectedPacks(this.packRepository), this.worldData.enabledFeatures()); + +@@ -1757,7 +2061,7 @@ try { label51: { @@ -712,7 +697,7 @@ try { arraylist = Lists.newArrayList(NativeModuleLister.listModules()); -@@ -1790,6 +2101,22 @@ +@@ -1807,6 +2111,22 @@ } @@ -735,7 +720,7 @@ private void startMetricsRecordingTick() { if (this.willStartRecordingMetrics) { this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> { -@@ -1912,8 +2239,30 @@ +@@ -1933,8 +2253,30 @@ } diff --git a/nms-patches/net/minecraft/server/commands/CommandEffect.patch b/nms-patches/net/minecraft/server/commands/CommandEffect.patch index 9de0636aa..fe749fc3b 100644 --- a/nms-patches/net/minecraft/server/commands/CommandEffect.patch +++ b/nms-patches/net/minecraft/server/commands/CommandEffect.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/CommandEffect.java +++ b/net/minecraft/server/commands/CommandEffect.java -@@ -72,7 +72,7 @@ +@@ -76,7 +76,7 @@ if (entity instanceof EntityLiving) { MobEffect mobeffect = new MobEffect(mobeffectlist, k, i, false, flag); @@ -9,7 +9,7 @@ ++j; } } -@@ -98,7 +98,7 @@ +@@ -102,7 +102,7 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); @@ -18,7 +18,7 @@ ++i; } } -@@ -123,7 +123,7 @@ +@@ -128,7 +128,7 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); diff --git a/nms-patches/net/minecraft/server/commands/CommandSummon.patch b/nms-patches/net/minecraft/server/commands/CommandSummon.patch index c3bdb2045..e2a71691d 100644 --- a/nms-patches/net/minecraft/server/commands/CommandSummon.patch +++ b/nms-patches/net/minecraft/server/commands/CommandSummon.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/CommandSummon.java +++ b/net/minecraft/server/commands/CommandSummon.java -@@ -65,7 +65,7 @@ +@@ -67,7 +67,7 @@ ((EntityInsentient) entity).finalizeSpawn(commandlistenerwrapper.getLevel(), commandlistenerwrapper.getLevel().getCurrentDifficultyAt(entity.blockPosition()), EnumMobSpawn.COMMAND, (GroupDataEntity) null, (NBTTagCompound) null); } diff --git a/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch b/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch index 071e23772..877797385 100644 --- a/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch +++ b/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch @@ -1,13 +1,11 @@ --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -56,6 +56,18 @@ +@@ -53,6 +53,16 @@ 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 net.minecraft.server.WorldLoader; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.io.IoBuilder; @@ -19,20 +17,20 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer { static final Logger LOGGER = LogUtils.getLogger(); -@@ -73,8 +85,10 @@ +@@ -70,8 +80,10 @@ @Nullable private final TextFilter textFilterClient; - public DedicatedServer(Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) { - super(thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, services, worldloadlistenerfactory); + // CraftBukkit start - Signature changed -+ public DedicatedServer(joptsimple.OptionSet options, DataPackConfiguration datapackconfiguration, DynamicOps registryreadops, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) { -+ super(options, datapackconfiguration, registryreadops, thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, services, worldloadlistenerfactory); ++ public DedicatedServer(joptsimple.OptionSet options, WorldLoader.a worldLoader, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) { ++ super(options, worldLoader, thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, services, worldloadlistenerfactory); + // CraftBukkit end this.settings = dedicatedserversettings; this.rconConsoleSource = new RemoteControlCommandListener(this); this.textFilterClient = TextFilter.createFromConfig(dedicatedserversettings.getProperties().textFilteringConfig); -@@ -84,13 +98,44 @@ +@@ -81,13 +93,44 @@ public boolean initServer() throws IOException { Thread thread = new Thread("Server console handler") { public void run() { @@ -80,7 +78,7 @@ } } catch (IOException ioexception) { DedicatedServer.LOGGER.error("Exception handling console input", ioexception); -@@ -99,6 +144,27 @@ +@@ -96,6 +139,27 @@ } }; @@ -108,7 +106,7 @@ thread.setDaemon(true); thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER)); thread.start(); -@@ -123,7 +189,7 @@ +@@ -120,7 +184,7 @@ this.setMotd(dedicatedserverproperties.motd); super.setPlayerIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get()); this.setEnforceWhitelist(dedicatedserverproperties.enforceWhitelist); @@ -117,12 +115,12 @@ DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode); InetAddress inetaddress = null; -@@ -147,6 +213,12 @@ +@@ -144,6 +208,12 @@ return false; } + // CraftBukkit start -+ this.setPlayerList(new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage)); ++ this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage)); + server.loadPlugins(); + server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP); + // CraftBukkit end @@ -130,12 +128,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."); -@@ -161,13 +233,13 @@ +@@ -158,13 +228,13 @@ if (!NameReferencingFileConverter.serverReadyAfterUserconversion(this)) { return false; } else { -- this.setPlayerList(new DedicatedPlayerList(this, this.registryAccess(), this.playerDataStorage)); -+ // this.setPlayerList(new DedicatedPlayerList(this, this.registryAccess(), this.playerDataStorage)); // CraftBukkit - moved up +- this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage)); ++ // this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage)); // CraftBukkit - moved up long i = SystemUtils.getNanos(); TileEntitySkull.setup(this.services, this); @@ -146,7 +144,7 @@ long j = SystemUtils.getNanos() - i; String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D); -@@ -184,6 +256,7 @@ +@@ -181,6 +251,7 @@ if (dedicatedserverproperties.enableRcon) { DedicatedServer.LOGGER.info("Starting remote control listener"); this.rconThread = RemoteControlListener.create(this); @@ -154,7 +152,7 @@ } if (this.getMaxTickLength() > 0L) { -@@ -300,6 +373,7 @@ +@@ -296,6 +367,7 @@ this.queryThreadGs4.stop(); } @@ -162,7 +160,7 @@ } @Override -@@ -321,7 +395,15 @@ +@@ -317,7 +389,15 @@ while (!this.consoleInput.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0); @@ -179,7 +177,7 @@ } } -@@ -546,14 +628,45 @@ +@@ -537,14 +617,45 @@ @Override public String getPluginNames() { @@ -227,7 +225,7 @@ }); return this.rconConsoleSource.getCommandResponse(); } -@@ -606,4 +719,15 @@ +@@ -597,4 +708,15 @@ public Optional getServerResourcePack() { return this.settings.getProperties().serverResourcePackInfo; } diff --git a/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch b/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch index 379b6c832..18c047aec 100644 --- a/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch +++ b/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/dedicated/DedicatedServerProperties.java +++ b/net/minecraft/server/dedicated/DedicatedServerProperties.java -@@ -37,10 +37,15 @@ - import net.minecraft.world.level.levelgen.structure.StructureSet; +@@ -45,11 +45,16 @@ + import net.minecraft.world.level.levelgen.presets.WorldPresets; import org.slf4j.Logger; +// CraftBukkit start @@ -12,13 +12,14 @@ static final Logger LOGGER = LogUtils.getLogger(); private static final Pattern SHA1 = Pattern.compile("^[a-fA-F0-9]{40}$"); + private static final Splitter COMMA_SPLITTER = Splitter.on(',').trimResults(); + public final boolean debug = this.get("debug", false); // CraftBukkit public final boolean onlineMode = this.get("online-mode", true); public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false); public final String serverIp = this.get("server-ip", ""); -@@ -95,8 +100,10 @@ - @Nullable - private GeneratorSettings worldGenSettings; +@@ -103,8 +108,10 @@ + private final DedicatedServerProperties.WorldDimensionData worldDimensionData; + public final WorldOptions worldOptions; - public DedicatedServerProperties(Properties properties) { - super(properties); @@ -29,8 +30,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"); -@@ -147,13 +154,15 @@ - this.serverResourcePackInfo = getServerPackInfo(this.get("resource-pack", ""), this.get("resource-pack-sha1", ""), this.getLegacyString("resource-pack-hash"), this.get("require-resource-pack", false), this.get("resource-pack-prompt", "")); +@@ -160,13 +167,15 @@ + this.initialDataPackConfiguration = getDatapackConfig(this.get("initial-enabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getEnabled())), this.get("initial-disabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getDisabled()))); } - public static DedicatedServerProperties fromFile(Path path) { @@ -42,30 +43,30 @@ @Override - protected DedicatedServerProperties reload(IRegistryCustom iregistrycustom, Properties properties) { -- DedicatedServerProperties dedicatedserverproperties = new DedicatedServerProperties(properties); +- return new DedicatedServerProperties(properties); + protected DedicatedServerProperties reload(IRegistryCustom iregistrycustom, Properties properties, OptionSet optionset) { -+ DedicatedServerProperties dedicatedserverproperties = new DedicatedServerProperties(properties, optionset); ++ return new DedicatedServerProperties(properties, optionset); + // CraftBukkit end + } - dedicatedserverproperties.getWorldGenSettings(iregistrycustom); - return dedicatedserverproperties; -@@ -222,10 +231,10 @@ + @Nullable +@@ -247,10 +256,10 @@ }).orElseThrow(() -> { return new IllegalStateException("Invalid datapack contents: can't find default preset"); }); - Optional optional = Optional.ofNullable(MinecraftKey.tryParse(this.levelType)).map((minecraftkey) -> { + Optional> optional = Optional.ofNullable(MinecraftKey.tryParse(this.levelType)).map((minecraftkey) -> { // CraftBukkit - decompile error - return ResourceKey.create(IRegistry.WORLD_PRESET_REGISTRY, minecraftkey); + return ResourceKey.create(Registries.WORLD_PRESET, minecraftkey); }).or(() -> { -- return Optional.ofNullable((ResourceKey) DedicatedServerProperties.a.LEGACY_PRESET_NAMES.get(this.levelType)); -+ return Optional.ofNullable(DedicatedServerProperties.a.LEGACY_PRESET_NAMES.get(this.levelType)); // CraftBukkit - decompile error +- return Optional.ofNullable((ResourceKey) DedicatedServerProperties.WorldDimensionData.LEGACY_PRESET_NAMES.get(this.levelType)); ++ return Optional.ofNullable(DedicatedServerProperties.WorldDimensionData.LEGACY_PRESET_NAMES.get(this.levelType)); // CraftBukkit - decompile error }); Objects.requireNonNull(iregistry); -@@ -239,7 +248,7 @@ +@@ -262,7 +271,7 @@ - if (holder1.is(WorldPresets.FLAT)) { - RegistryOps registryops = RegistryOps.create(JsonOps.INSTANCE, iregistrycustom); + if (holder.is(WorldPresets.FLAT)) { + RegistryOps registryops = RegistryOps.create(JsonOps.INSTANCE, (HolderLookup.b) iregistrycustom); - DataResult dataresult = GeneratorSettingsFlat.CODEC.parse(new Dynamic(registryops, this.generatorSettings())); + DataResult dataresult = GeneratorSettingsFlat.CODEC.parse(new Dynamic(registryops, this.generatorSettings())); // CraftBukkit - decompile error Logger logger = DedicatedServerProperties.LOGGER; diff --git a/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch b/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch index 6a3ffc270..5ffa553e5 100644 --- a/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch +++ b/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 -@@ -84,6 +84,16 @@ +@@ -85,6 +85,16 @@ this.clearCache(); } @@ -17,7 +17,7 @@ @Override public LightEngineThreaded getLightEngine() { return this.lightEngine; -@@ -128,7 +138,7 @@ +@@ -129,7 +139,7 @@ for (int l = 0; l < 4; ++l) { if (k == this.lastChunkPos[l] && chunkstatus == this.lastChunkStatus[l]) { ichunkaccess = this.lastChunk[l]; @@ -26,7 +26,7 @@ return ichunkaccess; } } -@@ -176,12 +186,12 @@ +@@ -177,12 +187,12 @@ if (playerchunk == null) { return null; } else { @@ -41,7 +41,7 @@ if (ichunkaccess1 != null) { this.storeInCache(k, ichunkaccess1, ChunkStatus.FULL); -@@ -229,7 +239,15 @@ +@@ -230,7 +240,15 @@ int l = 33 + ChunkStatus.getDistance(chunkstatus); PlayerChunk playerchunk = this.getVisibleChunkIfPresent(k); @@ -58,7 +58,7 @@ this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair); if (this.chunkAbsent(playerchunk, l)) { GameProfilerFiller gameprofilerfiller = this.level.getProfiler(); -@@ -248,7 +266,7 @@ +@@ -249,7 +267,7 @@ } private boolean chunkAbsent(@Nullable PlayerChunk playerchunk, int i) { @@ -67,7 +67,7 @@ } @Override -@@ -315,7 +333,7 @@ +@@ -316,7 +334,7 @@ } else if (!this.level.shouldTickBlocksAt(i)) { return false; } else { @@ -76,7 +76,7 @@ return either != null && either.left().isPresent(); } -@@ -328,11 +346,31 @@ +@@ -329,11 +347,31 @@ @Override public void close() throws IOException { @@ -109,7 +109,7 @@ @Override public void tick(BooleanSupplier booleansupplier, boolean flag) { this.level.getProfiler().push("purge"); -@@ -364,7 +402,7 @@ +@@ -365,7 +403,7 @@ gameprofilerfiller.push("pollingChunks"); int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); @@ -118,7 +118,7 @@ gameprofilerfiller.push("naturalSpawnCount"); int l = this.distanceManager.getNaturalSpawnChunkCount(); -@@ -385,7 +423,7 @@ +@@ -386,7 +424,7 @@ } gameprofilerfiller.popPush("spawnAndTick"); @@ -127,7 +127,7 @@ Collections.shuffle(list); Iterator iterator1 = list.iterator(); -@@ -586,13 +624,19 @@ +@@ -591,13 +629,19 @@ } @Override diff --git a/nms-patches/net/minecraft/server/level/EntityPlayer.patch b/nms-patches/net/minecraft/server/level/EntityPlayer.patch index 40b44a6e5..1fab621e9 100644 --- a/nms-patches/net/minecraft/server/level/EntityPlayer.patch +++ b/nms-patches/net/minecraft/server/level/EntityPlayer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/EntityPlayer.java +++ b/net/minecraft/server/level/EntityPlayer.java -@@ -148,6 +148,35 @@ +@@ -150,6 +150,35 @@ import net.minecraft.world.scores.criteria.IScoreboardCriteria; import org.slf4j.Logger; @@ -36,7 +36,7 @@ public class EntityPlayer extends EntityHuman { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -202,6 +231,21 @@ +@@ -207,6 +236,21 @@ public int latency; public boolean wonGame; @@ -55,10 +55,10 @@ + public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent + // CraftBukkit end + - public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, @Nullable ProfilePublicKey profilepublickey) { - super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile, profilepublickey); + public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile) { + super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile); this.chatVisibility = EnumChatVisibility.FULL; -@@ -264,12 +308,56 @@ +@@ -270,12 +314,56 @@ this.advancements = minecraftserver.getPlayerList().getPlayerAdvancements(this); this.maxUpStep = 1.0F; this.fudgeSpawnLocation(worldserver); @@ -116,7 +116,16 @@ int i = Math.max(0, this.server.getSpawnRadius(worldserver)); int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ())); -@@ -327,17 +415,26 @@ +@@ -324,7 +412,7 @@ + public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { + super.readAdditionalSaveData(nbttagcompound); + if (nbttagcompound.contains("warden_spawn_tracker", 10)) { +- DataResult dataresult = WardenSpawnTracker.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("warden_spawn_tracker"))); ++ DataResult dataresult = WardenSpawnTracker.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("warden_spawn_tracker"))); // CraftBukkit - decompile error + Logger logger = EntityPlayer.LOGGER; + + Objects.requireNonNull(logger); +@@ -343,17 +431,26 @@ if (nbttagcompound.contains("recipeBook", 10)) { this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager()); } @@ -139,12 +148,21 @@ 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; +- DataResult dataresult1 = World.RESOURCE_KEY_CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("SpawnDimension")); ++ DataResult> dataresult1 = World.RESOURCE_KEY_CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("SpawnDimension")); // CraftBukkit - decompile error + Logger logger1 = EntityPlayer.LOGGER; - Objects.requireNonNull(logger); -@@ -364,7 +461,20 @@ + Objects.requireNonNull(logger1); +@@ -366,7 +463,7 @@ + @Override + public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { + super.addAdditionalSaveData(nbttagcompound); +- DataResult dataresult = WardenSpawnTracker.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.wardenSpawnTracker); ++ DataResult dataresult = WardenSpawnTracker.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.wardenSpawnTracker); // CraftBukkit - decompile error + Logger logger = EntityPlayer.LOGGER; + + Objects.requireNonNull(logger); +@@ -387,7 +484,20 @@ Entity entity = this.getRootVehicle(); Entity entity1 = this.getVehicle(); @@ -166,16 +184,7 @@ NBTTagCompound nbttagcompound2 = new NBTTagCompound(); NBTTagCompound nbttagcompound3 = new NBTTagCompound(); -@@ -382,7 +492,7 @@ - nbttagcompound.putInt("SpawnZ", this.respawnPosition.getZ()); - nbttagcompound.putBoolean("SpawnForced", this.respawnForced); - nbttagcompound.putFloat("SpawnAngle", this.respawnAngle); -- DataResult dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.respawnDimension.location()); -+ DataResult dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.respawnDimension.location()); // CraftBukkit - decompile error - Logger logger = EntityPlayer.LOGGER; - - Objects.requireNonNull(logger); -@@ -390,9 +500,33 @@ +@@ -412,9 +522,33 @@ nbttagcompound.put("SpawnDimension", nbtbase); }); } @@ -209,7 +218,7 @@ public void setExperiencePoints(int i) { float f = (float) this.getXpNeededForNextLevel(); float f1 = (f - 1.0F) / f; -@@ -451,6 +585,11 @@ +@@ -473,6 +607,11 @@ @Override public void tick() { @@ -219,9 +228,9 @@ + } + // CraftBukkit end this.gameMode.tick(); + this.wardenSpawnTracker.tick(); --this.spawnInvulnerableTime; - if (this.invulnerableTime > 0) { -@@ -506,7 +645,7 @@ +@@ -529,7 +668,7 @@ } if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -230,7 +239,7 @@ this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -537,6 +676,12 @@ +@@ -560,6 +699,12 @@ this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience)); } @@ -243,7 +252,7 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel)); -@@ -551,6 +696,20 @@ +@@ -574,6 +719,20 @@ CriterionTriggers.LOCATION.trigger(this); } @@ -264,7 +273,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked"); -@@ -593,7 +752,8 @@ +@@ -616,7 +775,8 @@ } private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) { @@ -274,7 +283,7 @@ scoreboardscore.setScore(i); }); } -@@ -602,9 +762,47 @@ +@@ -625,9 +785,47 @@ public void die(DamageSource damagesource) { this.gameEvent(GameEvent.ENTITY_DIE); boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); @@ -324,7 +333,7 @@ this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> { boolean flag1 = true; -@@ -635,12 +833,18 @@ +@@ -658,12 +856,18 @@ if (this.level.getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) { this.tellNeutralMobsThatIDied(); } @@ -347,7 +356,7 @@ EntityLiving entityliving = this.getKillCredit(); if (entityliving != null) { -@@ -678,10 +882,12 @@ +@@ -701,10 +905,12 @@ String s = this.getScoreboardName(); String s1 = entity.getScoreboardName(); @@ -362,7 +371,7 @@ } else { this.awardStat(StatisticList.MOB_KILLS); } -@@ -699,7 +905,8 @@ +@@ -722,7 +928,8 @@ int i = scoreboardteam.getColor().getId(); if (i >= 0 && i < aiscoreboardcriteria.length) { @@ -372,7 +381,7 @@ } } -@@ -743,18 +950,20 @@ +@@ -766,18 +973,20 @@ } private boolean isPvpAllowed() { @@ -396,7 +405,7 @@ } else { return shapedetectorshape; } -@@ -763,11 +972,20 @@ +@@ -786,11 +995,20 @@ @Nullable @Override public Entity changeDimension(WorldServer worldserver) { @@ -420,7 +429,7 @@ this.unRide(); this.getLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); if (!this.wonGame) { -@@ -778,6 +996,8 @@ +@@ -801,6 +1019,8 @@ return this; } else { @@ -428,8 +437,8 @@ + /* WorldData worlddata = worldserver.getLevelData(); - this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true, this.getLastDeathLocation())); -@@ -787,22 +1007,52 @@ + this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), (byte) 3, this.getLastDeathLocation())); +@@ -810,20 +1030,50 @@ playerlist.sendPlayerPermissionLevel(this); worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); this.unsetRemoved(); @@ -468,7 +477,7 @@ + if (true) { // CraftBukkit + this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds + -+ this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true, this.getLastDeathLocation())); ++ this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), (byte) 3, this.getLastDeathLocation())); + this.connection.send(new PacketPlayOutServerDifficulty(this.level.getDifficulty(), this.level.getLevelData().isDifficultyLocked())); + PlayerList playerlist = this.server.getPlayerList(); + @@ -480,15 +489,12 @@ - worldserver1.getProfiler().push("placing"); + // CraftBukkit end this.setLevel(worldserver); - worldserver.addDuringPortalTeleport(this); -- this.setRot(shapedetectorshape.yRot, shapedetectorshape.xRot); -- this.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z); +- this.connection.teleport(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, shapedetectorshape.xRot); + this.connection.teleport(exit); // CraftBukkit - use internal teleport without event -+ this.connection.resetPosition(); // CraftBukkit - sync position after changing it (from PortalTravelAgent#findAndteleport) + this.connection.resetPosition(); + worldserver.addDuringPortalTeleport(this); worldserver1.getProfiler().pop(); - this.triggerDimensionChangeTriggers(worldserver1); - this.connection.send(new PacketPlayOutAbilities(this.getAbilities())); -@@ -820,39 +1070,66 @@ +@@ -843,39 +1093,66 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -561,7 +567,7 @@ } return optional1; -@@ -862,13 +1139,21 @@ +@@ -885,13 +1162,21 @@ public void triggerDimensionChangeTriggers(WorldServer worldserver) { ResourceKey resourcekey = worldserver.dimension(); ResourceKey resourcekey1 = this.level.dimension(); @@ -586,7 +592,7 @@ this.enteredNetherPosition = null; } -@@ -885,12 +1170,10 @@ +@@ -908,12 +1193,10 @@ this.containerMenu.broadcastChanges(); } @@ -602,7 +608,7 @@ return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE); } else if (!this.bedInRange(blockposition, enumdirection)) { return Either.left(EntityHuman.EnumBedResult.TOO_FAR_AWAY); -@@ -914,7 +1197,36 @@ +@@ -937,7 +1220,36 @@ } } @@ -640,7 +646,7 @@ this.awardStat(StatisticList.SLEEP_IN_BED); CriterionTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -927,9 +1239,8 @@ +@@ -950,9 +1262,8 @@ return either; } } @@ -651,7 +657,7 @@ } @Override -@@ -956,6 +1267,24 @@ +@@ -979,6 +1290,24 @@ @Override public void stopSleepInBed(boolean flag, boolean flag1) { @@ -676,7 +682,7 @@ if (this.isSleeping()) { this.getLevel().getChunkSource().broadcastAndSend(this, new PacketPlayOutAnimation(this, 2)); } -@@ -1037,8 +1366,9 @@ +@@ -1060,8 +1389,9 @@ this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos())); } @@ -687,7 +693,7 @@ } @Override -@@ -1046,13 +1376,35 @@ +@@ -1069,13 +1399,35 @@ if (itileinventory == null) { return OptionalInt.empty(); } else { @@ -723,7 +729,7 @@ if (container == null) { if (this.isSpectator()) { this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true); -@@ -1060,9 +1412,11 @@ +@@ -1083,9 +1435,11 @@ return OptionalInt.empty(); } else { @@ -737,7 +743,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1075,13 +1429,24 @@ +@@ -1098,13 +1452,24 @@ @Override public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { @@ -764,7 +770,7 @@ this.initMenu(this.containerMenu); } -@@ -1104,6 +1469,7 @@ +@@ -1127,6 +1492,7 @@ @Override public void closeContainer() { @@ -772,7 +778,7 @@ this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId)); this.doCloseContainer(); } -@@ -1133,7 +1499,7 @@ +@@ -1157,7 +1523,7 @@ @Override public void awardStat(Statistic statistic, int i) { this.stats.increment(this, statistic, i); @@ -781,7 +787,7 @@ scoreboardscore.add(i); }); } -@@ -1141,7 +1507,7 @@ +@@ -1165,7 +1531,7 @@ @Override public void resetStat(Statistic statistic) { this.stats.setValue(this, statistic, 0); @@ -790,7 +796,7 @@ } @Override -@@ -1157,7 +1523,7 @@ +@@ -1181,7 +1547,7 @@ for (int j = 0; j < i; ++j) { MinecraftKey minecraftkey = aminecraftkey1[j]; @@ -799,7 +805,7 @@ Objects.requireNonNull(list); optional.ifPresent(list::add); -@@ -1192,6 +1558,7 @@ +@@ -1216,6 +1582,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -807,7 +813,7 @@ } @Override -@@ -1247,7 +1614,7 @@ +@@ -1274,7 +1641,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -816,7 +822,7 @@ this.seenCredits = entityplayer.seenCredits; this.enteredNetherPosition = entityplayer.enteredNetherPosition; this.setShoulderEntityLeft(entityplayer.getShoulderEntityLeft()); -@@ -1390,7 +1757,20 @@ +@@ -1415,7 +1782,20 @@ return s; } @@ -837,16 +843,16 @@ this.chatVisibility = packetplayinsettings.chatVisibility(); this.canChatColor = packetplayinsettings.chatColors(); this.textFilteringEnabled = packetplayinsettings.textFilteringEnabled(); -@@ -1461,7 +1841,7 @@ +@@ -1486,7 +1866,7 @@ this.camera = (Entity) (entity == null ? this : entity); if (entity1 != this.camera) { this.connection.send(new PacketPlayOutCamera(this.camera)); -- this.teleportTo(this.camera.getX(), this.camera.getY(), this.camera.getZ()); +- this.connection.teleport(this.camera.getX(), this.camera.getY(), this.camera.getZ(), this.getYRot(), this.getXRot()); + this.connection.teleport(this.camera.getX(), this.camera.getY(), this.camera.getZ(), this.getYRot(), this.getXRot(), TeleportCause.SPECTATE); // CraftBukkit + this.connection.resetPosition(); } - } -@@ -1490,7 +1870,7 @@ +@@ -1516,7 +1896,7 @@ @Nullable public IChatBaseComponent getTabListDisplayName() { @@ -855,7 +861,7 @@ } @Override -@@ -1511,9 +1891,16 @@ +@@ -1537,9 +1917,16 @@ return this.advancements; } @@ -872,7 +878,7 @@ if (worldserver == this.level) { this.connection.teleport(d0, d1, d2, f, f1); } else { -@@ -1533,6 +1920,9 @@ +@@ -1559,6 +1946,9 @@ this.server.getPlayerList().sendLevelInfo(this, worldserver); this.server.getPlayerList().sendAllPlayerInfo(this); } @@ -882,9 +888,9 @@ } -@@ -1702,4 +2092,146 @@ - } - +@@ -1743,4 +2133,146 @@ + public RemoteChatSession getChatSession() { + return this.chatSession; } + + // CraftBukkit start - Add per-player time and weather. diff --git a/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch b/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch index e36650aa3..14e8321be 100644 --- a/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch +++ b/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/EntityTrackerEntry.java +++ b/net/minecraft/server/level/EntityTrackerEntry.java -@@ -40,6 +40,12 @@ +@@ -42,6 +42,12 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -13,10 +13,10 @@ public class EntityTrackerEntry { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -59,8 +65,12 @@ - private List lastPassengers; - private boolean wasRiding; +@@ -63,8 +69,12 @@ private boolean wasOnGround; + @Nullable + private List> trackedDataValues; + // CraftBukkit start + private final Set trackedPlayers; @@ -27,7 +27,7 @@ this.ap = Vec3D.ZERO; this.lastPassengers = Collections.emptyList(); this.level = worldserver; -@@ -80,7 +90,7 @@ +@@ -85,7 +95,7 @@ if (!list.equals(this.lastPassengers)) { this.lastPassengers = list; @@ -36,7 +36,7 @@ } Entity entity = this.entity; -@@ -88,18 +98,18 @@ +@@ -93,18 +103,18 @@ if (entity instanceof EntityItemFrame) { EntityItemFrame entityitemframe = (EntityItemFrame) entity; @@ -59,7 +59,7 @@ worldmap.tickCarriedBy(entityplayer, itemstack); Packet packet = worldmap.getUpdatePacket(integer, entityplayer); -@@ -204,7 +214,27 @@ +@@ -209,7 +219,27 @@ ++this.tickCount; if (this.entity.hurtMarked) { @@ -88,7 +88,7 @@ this.entity.hurtMarked = false; } -@@ -219,13 +249,16 @@ +@@ -224,13 +254,16 @@ PlayerConnection playerconnection = entityplayer.connection; Objects.requireNonNull(entityplayer.connection); @@ -107,8 +107,8 @@ + // CraftBukkit end } - Packet packet = this.entity.getAddEntityPacket(); -@@ -241,6 +274,12 @@ + Packet packet = this.entity.getAddEntityPacket(); +@@ -246,6 +279,12 @@ if (this.entity instanceof EntityLiving) { Collection collection = ((EntityLiving) this.entity).getAttributes().getSyncableAttributes(); @@ -121,7 +121,7 @@ if (!collection.isEmpty()) { consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection)); } -@@ -272,8 +311,14 @@ +@@ -277,8 +316,14 @@ if (!list.isEmpty()) { consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list)); } @@ -136,7 +136,7 @@ if (this.entity instanceof EntityLiving) { EntityLiving entityliving = (EntityLiving) this.entity; Iterator iterator = entityliving.getActiveEffects().iterator(); -@@ -314,6 +359,11 @@ +@@ -321,6 +366,11 @@ Set set = ((EntityLiving) this.entity).getAttributes().getDirtyAttributes(); if (!set.isEmpty()) { diff --git a/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch b/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch index 6bb8881e0..0f7b584a1 100644 --- a/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch +++ b/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/PlayerChunkMap.java +++ b/net/minecraft/server/level/PlayerChunkMap.java -@@ -103,6 +103,12 @@ +@@ -106,6 +106,12 @@ import org.apache.commons.lang3.mutable.MutableObject; import org.slf4j.Logger; @@ -13,7 +13,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.e { private static final byte CHUNK_TYPE_REPLACEABLE = -1; -@@ -145,6 +151,27 @@ +@@ -149,6 +155,27 @@ private final Queue unloadQueue; int viewDistance; @@ -41,7 +41,7 @@ public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, StructureTemplateManager structuretemplatemanager, Executor executor, IAsyncTaskHandler iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier supplier, int i, boolean flag) { super(convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag); this.visibleChunkMap = this.updatingChunkMap.clone(); -@@ -163,6 +190,11 @@ +@@ -167,6 +194,11 @@ this.storageName = path.getFileName().toString(); this.level = worldserver; this.generator = chunkgenerator; @@ -50,10 +50,10 @@ + chunkgenerator = ((CustomChunkGenerator) chunkgenerator).getDelegate(); + } + // CraftBukkit end - if (chunkgenerator instanceof ChunkGeneratorAbstract) { - ChunkGeneratorAbstract chunkgeneratorabstract = (ChunkGeneratorAbstract) chunkgenerator; + IRegistryCustom iregistrycustom = worldserver.registryAccess(); + long j = worldserver.getSeed(); -@@ -314,9 +346,12 @@ +@@ -326,9 +358,12 @@ CompletableFuture>> completablefuture1 = SystemUtils.sequence(list); CompletableFuture, PlayerChunk.Failure>> completablefuture2 = completablefuture1.thenApply((list2) -> { List list3 = Lists.newArrayList(); @@ -68,7 +68,7 @@ final Either either = (Either) iterator.next(); if (either == null) { -@@ -521,7 +556,7 @@ +@@ -533,7 +568,7 @@ private void scheduleUnload(long i, PlayerChunk playerchunk) { CompletableFuture completablefuture = playerchunk.getChunkToSave(); @@ -77,7 +77,7 @@ CompletableFuture completablefuture1 = playerchunk.getChunkToSave(); if (completablefuture1 != completablefuture) { -@@ -610,9 +645,9 @@ +@@ -622,9 +657,9 @@ ProtoChunk protochunk = ChunkRegionLoader.read(this.level, this.poiManager, chunkcoordintpair, (NBTTagCompound) optional.get()); this.markPosition(chunkcoordintpair, protochunk.getStatus().getChunkType()); @@ -89,7 +89,7 @@ } }, this.mainThreadExecutor).exceptionallyAsync((throwable) -> { return this.handleChunkLoadFailure(throwable, chunkcoordintpair); -@@ -718,7 +753,21 @@ +@@ -730,7 +765,21 @@ private static void postLoadProtoChunk(WorldServer worldserver, List list) { if (!list.isEmpty()) { @@ -112,7 +112,7 @@ } } -@@ -817,7 +866,7 @@ +@@ -829,7 +878,7 @@ if (!playerchunk.wasAccessibleSinceLastSave()) { return false; } else { @@ -121,7 +121,7 @@ if (!(ichunkaccess instanceof ProtoChunkExtension) && !(ichunkaccess instanceof Chunk)) { return false; -@@ -979,7 +1028,8 @@ +@@ -991,7 +1040,8 @@ return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty(); }); @@ -131,7 +131,7 @@ return chunk.getBlockEntities().size(); }).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> { return chunk.getBlockTicks().count(); -@@ -992,7 +1042,7 @@ +@@ -1004,7 +1054,7 @@ private static String printFuture(CompletableFuture> completablefuture) { try { @@ -140,7 +140,7 @@ return either != null ? (String) either.map((chunk) -> { return "done"; -@@ -1008,12 +1058,14 @@ +@@ -1020,12 +1070,14 @@ private CompletableFuture> readChunk(ChunkCoordIntPair chunkcoordintpair) { return this.read(chunkcoordintpair).thenApplyAsync((optional) -> { @@ -158,7 +158,7 @@ } boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) { -@@ -1434,7 +1486,7 @@ +@@ -1471,7 +1523,7 @@ public final Set seenBy = Sets.newIdentityHashSet(); public EntityTracker(Entity entity, int i, int j, boolean flag) { @@ -167,7 +167,7 @@ this.entity = entity; this.range = i; this.lastSectionPos = SectionPosition.of((EntityAccess) entity); -@@ -1493,6 +1545,11 @@ +@@ -1530,6 +1582,11 @@ double d2 = d0 * d0; boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer); diff --git a/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch b/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch index 9c3fe4446..5fca72ed0 100644 --- a/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch +++ b/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch @@ -28,7 +28,7 @@ public class PlayerInteractManager { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -56,6 +77,13 @@ +@@ -56,9 +77,16 @@ if (enumgamemode == this.gameModeForPlayer) { return false; } else { @@ -39,18 +39,13 @@ + return false; + } + // CraftBukkit end - this.setGameModeForPlayer(enumgamemode, this.gameModeForPlayer); + this.setGameModeForPlayer(enumgamemode, this.previousGameModeForPlayer); + this.player.onUpdateAbilities(); +- this.player.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.a.UPDATE_GAME_MODE, this.player)); ++ this.player.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.a.UPDATE_GAME_MODE, this.player), this.player); // CraftBukkit + this.level.updateSleepingPlayerList(); return true; } -@@ -66,7 +94,7 @@ - this.gameModeForPlayer = enumgamemode; - enumgamemode.updatePlayerAbilities(this.player.getAbilities()); - this.player.onUpdateAbilities(); -- this.player.server.getPlayerList().broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[]{this.player})); -+ this.player.server.getPlayerList().broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[]{this.player}), this.player); // CraftBukkit - this.level.updateSleepingPlayerList(); - } - @@ -88,7 +116,7 @@ } @@ -179,8 +174,7 @@ + + // Sword + Creative mode pre-cancel + event.setCancelled(isSwordNoBreak); - -- if (!this.player.getMainHandItem().getItem().canAttackBlock(iblockdata, this.level, blockposition, this.player)) { ++ + // Calculate default block experience + IBlockData nmsData = this.level.getBlockState(blockposition); + Block nmsBlock = nmsData.getBlock(); @@ -199,7 +193,8 @@ + } + // Let the client know the block still exists + this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition)); -+ + +- if (!this.player.getMainHandItem().getItem().canAttackBlock(iblockdata, this.level, blockposition, this.player)) { + // Brute force all possible updates + for (EnumDirection dir : EnumDirection.values()) { + this.player.connection.send(new PacketPlayOutBlockChange(level, blockposition.relative(dir))); @@ -257,20 +252,20 @@ + // CraftBukkit start + if (event.isDropItems()) { + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, level.captureDrops); -+ } + } + level.captureDrops = null; + + // Drop event experience + if (flag && event != null) { + iblockdata.getBlock().popExperience(this.level, blockposition, event.getExpToDrop()); - } ++ } + + return true; + // CraftBukkit end } } } -@@ -313,12 +469,52 @@ +@@ -313,14 +469,54 @@ } } @@ -286,7 +281,9 @@ + EnumInteractionResult enuminteractionresult = EnumInteractionResult.PASS; + boolean cancelledBlock = false; - if (this.gameModeForPlayer == EnumGamemode.SPECTATOR) { + if (!iblockdata.getBlock().isEnabled(world.enabledFeatures())) { + return EnumInteractionResult.FAIL; + } else if (this.gameModeForPlayer == EnumGamemode.SPECTATOR) { ITileInventory itileinventory = iblockdata.getMenuProvider(world, blockposition); + cancelledBlock = !(itileinventory instanceof ITileInventory); + } @@ -323,7 +320,7 @@ if (itileinventory != null) { entityplayer.openMenu(itileinventory); -@@ -332,7 +528,7 @@ +@@ -334,7 +530,7 @@ ItemStack itemstack1 = itemstack.copy(); if (!flag1) { @@ -332,7 +329,7 @@ if (enuminteractionresult.consumesAction()) { CriterionTriggers.ITEM_USED_ON_BLOCK.trigger(entityplayer, blockposition, itemstack1); -@@ -340,17 +536,17 @@ +@@ -342,17 +538,17 @@ } } @@ -353,7 +350,7 @@ } if (enuminteractionresult1.consumesAction()) { -@@ -358,10 +554,10 @@ +@@ -360,10 +556,10 @@ } return enuminteractionresult1; diff --git a/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch b/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch index 4361f150d..b638902b8 100644 --- a/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch +++ b/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/RegionLimitedWorldAccess.java +++ b/net/minecraft/server/level/RegionLimitedWorldAccess.java -@@ -207,7 +207,7 @@ +@@ -208,7 +208,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); -@@ -326,6 +326,13 @@ +@@ -327,6 +327,13 @@ @Override public boolean addFreshEntity(Entity entity) { diff --git a/nms-patches/net/minecraft/server/level/WorldServer.patch b/nms-patches/net/minecraft/server/level/WorldServer.patch index 979f3d4b2..9da4e176a 100644 --- a/nms-patches/net/minecraft/server/level/WorldServer.patch +++ b/nms-patches/net/minecraft/server/level/WorldServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/WorldServer.java +++ b/net/minecraft/server/level/WorldServer.java -@@ -153,6 +153,26 @@ +@@ -156,6 +156,26 @@ import net.minecraft.world.ticks.TickListServer; import org.slf4j.Logger; @@ -27,7 +27,7 @@ public class WorldServer extends World implements GeneratorAccessSeed { public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0); -@@ -170,7 +190,7 @@ +@@ -173,7 +193,7 @@ final List players; private final ChunkProviderServer chunkSource; private final MinecraftServer server; @@ -35,13 +35,13 @@ + public final WorldDataServer serverLevelData; // CraftBukkit - type final EntityTickList entityTickList; public final PersistentEntitySectionManager entityManager; - public boolean noSave; -@@ -194,11 +214,28 @@ + private final GameEventDispatcher gameEventDispatcher; +@@ -197,11 +217,28 @@ private final StructureCheck structureCheck; private final boolean tickTime; - public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey resourcekey, WorldDimension worlddimension, WorldLoadListener worldloadlistener, boolean flag, long i, List list, boolean flag1) { -- Holder holder = worlddimension.typeHolder(); +- Holder holder = worlddimension.type(); + // CraftBukkit start + public final Convertable.ConversionSession convertable; + public final UUID uuid; @@ -59,9 +59,9 @@ - super(iworlddataserver, resourcekey, holder, minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates()); + // Add env and gen to constructor, IWorldDataServer -> WorldDataServer + public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, WorldDataServer iworlddataserver, ResourceKey resourcekey, WorldDimension worlddimension, WorldLoadListener worldloadlistener, boolean flag, long i, List list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { -+ // Holder holder = worlddimension.typeHolder(); // CraftBukkit - decompile error ++ // Holder holder = worlddimension.type(); // CraftBukkit - decompile error + // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error -+ super(iworlddataserver, resourcekey, worlddimension.typeHolder(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env); ++ super(iworlddataserver, resourcekey, worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env); + this.pvpMode = minecraftserver.isPvpAllowed(); + convertable = convertable_conversionsession; + uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile()); @@ -69,7 +69,7 @@ this.players = Lists.newArrayList(); this.entityTickList = new EntityTickList(); this.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier()); -@@ -213,6 +250,22 @@ +@@ -215,6 +252,22 @@ this.customSpawners = list; this.serverLevelData = iworlddataserver; ChunkGenerator chunkgenerator = worlddimension.generator(); @@ -77,11 +77,11 @@ + serverLevelData.setWorld(this); + + if (biomeProvider != null) { -+ WorldChunkManager worldChunkManager = new CustomWorldChunkManager(getWorld(), biomeProvider, server.registryHolder.registryOrThrow(IRegistry.BIOME_REGISTRY)); ++ WorldChunkManager worldChunkManager = new CustomWorldChunkManager(getWorld(), biomeProvider, server.registryAccess().registryOrThrow(Registries.BIOME)); + if (chunkgenerator instanceof ChunkGeneratorAbstract cga) { -+ chunkgenerator = new ChunkGeneratorAbstract(cga.structureSets, cga.noises, worldChunkManager, cga.settings); ++ chunkgenerator = new ChunkGeneratorAbstract(worldChunkManager, cga.settings); + } else if (chunkgenerator instanceof ChunkProviderFlat cpf) { -+ chunkgenerator = new ChunkProviderFlat(cpf.structureSets, cpf.settings(), worldChunkManager); ++ chunkgenerator = new ChunkProviderFlat(cpf.settings(), worldChunkManager); + } + } + @@ -92,26 +92,27 @@ boolean flag2 = minecraftserver.forceSynchronousWrites(); DataFixer datafixer = minecraftserver.getFixerUpper(); EntityPersistentStorage entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver); -@@ -244,14 +297,15 @@ - long l = minecraftserver.getWorldData().worldGenSettings().seed(); +@@ -246,15 +299,16 @@ + long l = minecraftserver.getWorldData().worldGenOptions().seed(); this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer); -- this.structureManager = new StructureManager(this, minecraftserver.getWorldData().worldGenSettings(), this.structureCheck); +- this.structureManager = new StructureManager(this, minecraftserver.getWorldData().worldGenOptions(), this.structureCheck); - if (this.dimension() == World.END && this.dimensionTypeRegistration().is(BuiltinDimensionTypes.END)) { - this.dragonFight = new EnderDragonBattle(this, l, minecraftserver.getWorldData().endDragonFightData()); -+ this.structureManager = new StructureManager(this, this.serverLevelData.worldGenSettings(), structureCheck); // CraftBukkit ++ this.structureManager = new StructureManager(this, this.serverLevelData.worldGenOptions(), structureCheck); // CraftBukkit + if ((this.dimension() == World.END && this.dimensionTypeRegistration().is(BuiltinDimensionTypes.END)) || env == org.bukkit.World.Environment.THE_END) { // CraftBukkit - Allow to create EnderDragonBattle in default and custom END -+ this.dragonFight = new EnderDragonBattle(this, this.serverLevelData.worldGenSettings().seed(), this.serverLevelData.endDragonFightData()); // CraftBukkit ++ this.dragonFight = new EnderDragonBattle(this, this.serverLevelData.worldGenOptions().seed(), this.serverLevelData.endDragonFightData()); // CraftBukkit } else { this.dragonFight = null; } this.sleepStatus = new SleepStatus(); + this.gameEventDispatcher = new GameEventDispatcher(this); + this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit } public void setWeatherParameters(int i, int j, boolean flag, boolean flag1) { -@@ -283,12 +337,20 @@ +@@ -286,12 +340,20 @@ long j; if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { @@ -135,7 +136,7 @@ if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) { this.resetWeatherCycle(); } -@@ -314,7 +376,7 @@ +@@ -317,7 +379,7 @@ this.runBlockEvents(); this.handlingTick = false; gameprofilerfiller.pop(); @@ -144,7 +145,7 @@ if (flag) { this.resetEmptyTime(); -@@ -330,7 +392,7 @@ +@@ -333,7 +395,7 @@ this.entityTickList.forEach((entity) -> { if (!entity.isRemoved()) { @@ -153,7 +154,7 @@ entity.discard(); } else { gameprofilerfiller.push("checkDespawn"); -@@ -404,7 +466,7 @@ +@@ -405,7 +467,7 @@ private void wakeUpAllPlayers() { this.sleepStatus.removeAllSleepers(); @@ -162,24 +163,25 @@ entityplayer.stopSleepInBed(false, false); }); } -@@ -431,14 +493,14 @@ - entityhorseskeleton.setTrap(true); - entityhorseskeleton.setAge(0); - entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); -- this.addFreshEntity(entityhorseskeleton); -+ this.addFreshEntity(entityhorseskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit +@@ -433,7 +495,7 @@ + entityhorseskeleton.setTrap(true); + entityhorseskeleton.setAge(0); + entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); +- this.addFreshEntity(entityhorseskeleton); ++ this.addFreshEntity(entityhorseskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit + } } - EntityLightning entitylightning = (EntityLightning) EntityTypes.LIGHTNING_BOLT.create(this); - - entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition)); - entitylightning.setVisualOnly(flag1); -- this.addFreshEntity(entitylightning); -+ this.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.WEATHER); // CraftBukkit +@@ -442,7 +504,7 @@ + if (entitylightning != null) { + entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition)); + entitylightning.setVisualOnly(flag1); +- this.addFreshEntity(entitylightning); ++ this.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.WEATHER); // CraftBukkit + } } } - -@@ -449,12 +511,12 @@ +@@ -456,7 +518,7 @@ BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition).value(); if (biomebase.shouldFreeze(this, blockposition1)) { @@ -188,13 +190,20 @@ } if (flag) { - if (biomebase.shouldSnow(this, blockposition)) { -- this.setBlockAndUpdate(blockposition, Blocks.SNOW.defaultBlockState()); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.defaultBlockState(), null); // CraftBukkit +@@ -471,10 +533,10 @@ + IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, l + 1); + + Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition); +- this.setBlockAndUpdate(blockposition, iblockdata1); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, iblockdata1, null); // CraftBukkit + } + } else { +- this.setBlockAndUpdate(blockposition, Blocks.SNOW.defaultBlockState()); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.defaultBlockState(), null); // CraftBukkit + } } - IBlockData iblockdata = this.getBlockState(blockposition1); -@@ -650,6 +712,7 @@ +@@ -671,6 +733,7 @@ this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F); } @@ -202,7 +211,7 @@ if (this.oRainLevel != this.rainLevel) { this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension()); } -@@ -668,14 +731,47 @@ +@@ -689,14 +752,47 @@ this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } @@ -252,7 +261,7 @@ } public void resetEmptyTime() { -@@ -710,6 +806,7 @@ +@@ -731,6 +827,7 @@ }); gameprofilerfiller.incrementCounter("tickNonPassenger"); entity.tick(); @@ -260,7 +269,7 @@ this.getProfiler().pop(); Iterator iterator = entity.getPassengers().iterator(); -@@ -733,6 +830,7 @@ +@@ -754,6 +851,7 @@ }); gameprofilerfiller.incrementCounter("tickPassenger"); entity1.rideTick(); @@ -268,7 +277,7 @@ gameprofilerfiller.pop(); Iterator iterator = entity1.getPassengers().iterator(); -@@ -757,6 +855,7 @@ +@@ -778,6 +876,7 @@ ChunkProviderServer chunkproviderserver = this.getChunkSource(); if (!flag1) { @@ -276,7 +285,7 @@ if (iprogressupdate != null) { iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel")); } -@@ -774,11 +873,19 @@ +@@ -795,11 +894,19 @@ } } @@ -286,7 +295,7 @@ + + serverLevelData.setWorldBorder(worldserver1.getWorldBorder().createSettings()); + serverLevelData.setCustomBossEvents(this.server.getCustomBossEvents().save()); -+ convertable.saveDataTag(this.server.registryHolder, this.serverLevelData, this.server.getPlayerList().getSingleplayerData()); ++ convertable.saveDataTag(this.server.registryAccess(), this.serverLevelData, this.server.getPlayerList().getSingleplayerData()); + // CraftBukkit end } @@ -297,7 +306,7 @@ } this.getChunkSource().getDataStorage().save(); -@@ -824,15 +931,37 @@ +@@ -864,15 +971,37 @@ @Override public boolean addFreshEntity(Entity entity) { @@ -338,7 +347,7 @@ } public void addDuringCommandTeleport(EntityPlayer entityplayer) { -@@ -863,24 +992,37 @@ +@@ -903,24 +1032,37 @@ this.entityManager.addNewEntity(entityplayer); } @@ -380,7 +389,7 @@ return true; } } -@@ -894,10 +1036,32 @@ +@@ -934,10 +1076,32 @@ entityplayer.remove(entity_removalreason); } @@ -413,7 +422,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -906,6 +1070,12 @@ +@@ -946,6 +1110,12 @@ double d1 = (double) blockposition.getY() - entityplayer.getY(); double d2 = (double) blockposition.getZ() - entityplayer.getZ(); @@ -426,22 +435,7 @@ if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); } -@@ -942,6 +1112,14 @@ - public void gameEvent(GameEvent gameevent, Vec3D vec3d, GameEvent.a gameevent_a) { - int i = gameevent.getNotificationRadius(); - BlockPosition blockposition = new BlockPosition(vec3d); -+ // CraftBukkit start -+ GenericGameEvent event = new GenericGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.GAME_EVENT.getKey(gameevent))), new Location(this.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()), (gameevent_a.sourceEntity() == null) ? null : gameevent_a.sourceEntity().getBukkitEntity(), i, !Bukkit.isPrimaryThread()); -+ getCraftServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ return; -+ } -+ i = event.getRadius(); -+ // CraftBukkit end - int j = SectionPosition.blockToSectionCoord(blockposition.getX() - i); - int k = SectionPosition.blockToSectionCoord(blockposition.getY() - i); - int l = SectionPosition.blockToSectionCoord(blockposition.getZ() - i); -@@ -1014,7 +1192,18 @@ +@@ -1005,7 +1175,18 @@ Iterator iterator = this.navigatingMobs.iterator(); while (iterator.hasNext()) { @@ -461,28 +455,19 @@ NavigationAbstract navigationabstract = entityinsentient.getNavigation(); if (navigationabstract.shouldRecomputePath(blockposition)) { -@@ -1070,10 +1259,20 @@ - +@@ -1062,6 +1243,11 @@ @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) { + public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, World.a world_a) { + Explosion explosion = this.explode(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, world_a, false); + // CraftBukkit start -+ Explosion explosion = super.explode(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, explosion_effect); -+ + if (explosion.wasCanceled) { + return explosion; + } -+ -+ /* Remove - Explosion explosion = new Explosion(this, entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, explosion_effect); ++ // CraftBukkit end - explosion.explode(); - explosion.finalizeExplosion(false); -+ */ -+ // CraftBukkit end - TODO: Check if explosions are still properly implemented - if (explosion_effect == Explosion.Effect.NONE) { + if (!explosion.interactsWithBlocks()) { explosion.clearToBlow(); - } -@@ -1145,13 +1344,20 @@ +@@ -1134,13 +1320,20 @@ } public int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { @@ -505,16 +490,16 @@ ++j; } } -@@ -1202,7 +1408,7 @@ +@@ -1191,7 +1384,7 @@ @Nullable public BlockPosition findNearestMapStructure(TagKey tagkey, BlockPosition blockposition, int i, boolean flag) { -- if (!this.server.getWorldData().worldGenSettings().generateStructures()) { -+ if (!this.serverLevelData.worldGenSettings().generateStructures()) { // CraftBukkit +- if (!this.server.getWorldData().worldGenOptions().generateStructures()) { ++ if (!this.serverLevelData.worldGenOptions().generateStructures()) { // CraftBukkit return null; } else { - Optional> optional = this.registryAccess().registryOrThrow(IRegistry.STRUCTURE_REGISTRY).getTag(tagkey); -@@ -1244,11 +1450,21 @@ + Optional> optional = this.registryAccess().registryOrThrow(Registries.STRUCTURE).getTag(tagkey); +@@ -1233,11 +1426,21 @@ @Nullable @Override public WorldMap getMapData(String s) { @@ -537,7 +522,7 @@ this.getServer().overworld().getDataStorage().set(s, worldmap); } -@@ -1546,6 +1762,11 @@ +@@ -1535,6 +1738,11 @@ @Override public void blockUpdated(BlockPosition blockposition, Block block) { if (!this.isDebug()) { @@ -549,22 +534,22 @@ this.updateNeighborsAt(blockposition, block); } -@@ -1565,12 +1786,12 @@ +@@ -1554,12 +1762,12 @@ } public boolean isFlat() { -- return this.server.getWorldData().worldGenSettings().isFlatWorld(); -+ return this.serverLevelData.worldGenSettings().isFlatWorld(); // CraftBukkit +- return this.server.getWorldData().isFlatWorld(); ++ return this.serverLevelData.isFlatWorld(); // CraftBukkit } @Override public long getSeed() { -- return this.server.getWorldData().worldGenSettings().seed(); -+ return this.serverLevelData.worldGenSettings().seed(); // CraftBukkit +- return this.server.getWorldData().worldGenOptions().seed(); ++ return this.serverLevelData.worldGenOptions().seed(); // CraftBukkit } @Nullable -@@ -1593,7 +1814,7 @@ +@@ -1582,7 +1790,7 @@ private static String getTypeCount(Iterable iterable, Function function) { try { Object2IntOpenHashMap object2intopenhashmap = new Object2IntOpenHashMap(); @@ -573,7 +558,7 @@ while (iterator.hasNext()) { T t0 = iterator.next(); -@@ -1602,7 +1823,7 @@ +@@ -1591,7 +1799,7 @@ object2intopenhashmap.addTo(s, 1); } @@ -582,7 +567,7 @@ String s1 = (String) entry.getKey(); return s1 + ":" + entry.getIntValue(); -@@ -1613,17 +1834,33 @@ +@@ -1602,17 +1810,33 @@ } public static void makeObsidianPlatform(WorldServer worldserver) { @@ -618,7 +603,7 @@ } @Override -@@ -1734,6 +1971,7 @@ +@@ -1728,6 +1952,7 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -626,7 +611,7 @@ } public void onTrackingEnd(Entity entity) { -@@ -1770,6 +2008,14 @@ +@@ -1764,6 +1989,14 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); diff --git a/nms-patches/net/minecraft/server/network/LegacyPingHandler.patch b/nms-patches/net/minecraft/server/network/LegacyPingHandler.patch index bd62f879b..19162d39c 100644 --- a/nms-patches/net/minecraft/server/network/LegacyPingHandler.patch +++ b/nms-patches/net/minecraft/server/network/LegacyPingHandler.patch @@ -4,7 +4,7 @@ MinecraftServer minecraftserver = this.serverConnectionListener.getServer(); int i = bytebuf.readableBytes(); String s; -+ org.bukkit.event.server.ServerListPingEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(minecraftserver.server, inetsocketaddress.getAddress(), minecraftserver.getMotd(), minecraftserver.previewsChat(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); // CraftBukkit ++ org.bukkit.event.server.ServerListPingEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(minecraftserver.server, inetsocketaddress.getAddress(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); // CraftBukkit switch (i) { case 0: diff --git a/nms-patches/net/minecraft/server/network/LoginListener.patch b/nms-patches/net/minecraft/server/network/LoginListener.patch index 2eac6cf15..b58f09f2b 100644 --- a/nms-patches/net/minecraft/server/network/LoginListener.patch +++ b/nms-patches/net/minecraft/server/network/LoginListener.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/LoginListener.java +++ b/net/minecraft/server/network/LoginListener.java -@@ -41,6 +41,12 @@ +@@ -38,6 +38,12 @@ import org.apache.commons.lang3.Validate; import org.slf4j.Logger; @@ -10,10 +10,10 @@ +import org.bukkit.event.player.PlayerPreLoginEvent; +// CraftBukkit end + - public class LoginListener implements TickablePacketListener, PacketLoginInListener { + public class LoginListener implements PacketLoginInListener, TickablePacketListener { private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0); -@@ -88,6 +94,13 @@ +@@ -83,6 +89,13 @@ } @@ -27,13 +27,13 @@ @Override public NetworkManager getConnection() { return this.connection; -@@ -123,10 +136,12 @@ - } +@@ -104,10 +117,12 @@ + this.gameProfile = this.createFakeProfile(this.gameProfile); } - IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().canPlayerLogin(this.connection.getRemoteAddress(), this.gameProfile); + // CraftBukkit start - fire PlayerLoginEvent -+ EntityPlayer s = this.server.getPlayerList().canPlayerLogin(this, this.gameProfile, profilepublickey); ++ EntityPlayer s = this.server.getPlayerList().canPlayerLogin(this, this.gameProfile); - if (ichatbasecomponent != null) { - this.disconnect(ichatbasecomponent); @@ -43,25 +43,16 @@ } else { this.state = LoginListener.EnumProtocolState.ACCEPTED; if (this.server.getCompressionThreshold() >= 0 && !this.connection.isMemoryConnection()) { -@@ -139,7 +154,7 @@ +@@ -120,7 +135,7 @@ EntityPlayer entityplayer = this.server.getPlayerList().getPlayer(this.gameProfile.getId()); try { -- EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile, profilepublickey); +- EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile); + EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile, s); // CraftBukkit - add player reference if (entityplayer != null) { this.state = LoginListener.EnumProtocolState.DELAY_ACCEPT; -@@ -188,7 +203,7 @@ - public void handleHello(PacketLoginInStart packetlogininstart) { - Validate.validState(this.state == LoginListener.EnumProtocolState.HELLO, "Unexpected hello packet", new Object[0]); - Validate.validState(isValidUsername(packetlogininstart.name()), "Invalid characters in username", new Object[0]); -- this.profilePublicKeyData = (ProfilePublicKey.a) packetlogininstart.publicKey().orElse((Object) null); -+ this.profilePublicKeyData = (ProfilePublicKey.a) packetlogininstart.publicKey().orElse(null); // CraftBukkit - decompile error - GameProfile gameprofile = this.server.getSingleplayerProfile(); - - if (gameprofile != null && packetlogininstart.name().equalsIgnoreCase(gameprofile.getName())) { -@@ -249,6 +264,43 @@ +@@ -210,6 +225,43 @@ try { LoginListener.this.gameProfile = LoginListener.this.server.getSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.getAddress()); if (LoginListener.this.gameProfile != null) { @@ -105,7 +96,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()) { -@@ -268,6 +320,11 @@ +@@ -229,6 +281,11 @@ LoginListener.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.authservers_down")); LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable"); } diff --git a/nms-patches/net/minecraft/server/network/PacketStatusListener.patch b/nms-patches/net/minecraft/server/network/PacketStatusListener.patch index 3db9536e7..ca725c566 100644 --- a/nms-patches/net/minecraft/server/network/PacketStatusListener.patch +++ b/nms-patches/net/minecraft/server/network/PacketStatusListener.patch @@ -19,7 +19,7 @@ public class PacketStatusListener implements PacketStatusInListener { private static final IChatBaseComponent DISCONNECT_REASON = IChatBaseComponent.translatable("multiplayer.status.request_handled"); -@@ -35,7 +47,103 @@ +@@ -35,7 +47,102 @@ this.connection.disconnect(PacketStatusListener.DISCONNECT_REASON); } else { this.hasRequestedStatus = true; @@ -32,7 +32,7 @@ + CraftIconCache icon = server.server.getServerIcon(); + + ServerListPingEvent() { -+ super(connection.hostname, ((InetSocketAddress) connection.getRemoteAddress()).getAddress(), server.getMotd(), server.previewsChat(), server.getPlayerList().getMaxPlayers()); ++ super(connection.hostname, ((InetSocketAddress) connection.getRemoteAddress()).getAddress(), server.getMotd(), server.getPlayerList().getMaxPlayers()); + } + + @Override @@ -112,7 +112,6 @@ + } + + ServerPing ping = new ServerPing(); -+ ping.setPreviewsChat(event.shouldSendChatPreviews()); + ping.setFavicon(event.icon.value); + ping.setDescription(CraftChatMessage.fromString(event.getMotd(), true)[0]); + ping.setPlayers(playerSample); diff --git a/nms-patches/net/minecraft/server/network/PlayerConnection.patch b/nms-patches/net/minecraft/server/network/PlayerConnection.patch index 362eacb1d..fb35582b0 100644 --- a/nms-patches/net/minecraft/server/network/PlayerConnection.patch +++ b/nms-patches/net/minecraft/server/network/PlayerConnection.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/server/network/PlayerConnection.java +++ b/net/minecraft/server/network/PlayerConnection.java -@@ -184,6 +184,67 @@ - import org.apache.commons.lang3.StringUtils; +@@ -182,6 +182,67 @@ + import net.minecraft.world.phys.shapes.VoxelShapes; import org.slf4j.Logger; +// CraftBukkit start ++import com.mojang.datafixers.util.Pair; +import java.util.Arrays; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.atomic.AtomicInteger; -+import net.minecraft.network.chat.OutgoingPlayerChatMessage; ++import net.minecraft.network.chat.OutgoingChatMessage; +import net.minecraft.network.protocol.game.PacketPlayOutAttachEntity; +import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -+import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; +import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity; +import net.minecraft.network.protocol.game.PacketPlayOutSpawnPosition; +import net.minecraft.world.entity.EntityInsentient; @@ -68,7 +68,7 @@ public class PlayerConnection implements ServerPlayerConnection, TickablePacketListener, PacketListenerPlayIn { static final Logger LOGGER = LogUtils.getLogger(); -@@ -199,7 +260,9 @@ +@@ -198,7 +259,9 @@ private long keepAliveTime; private boolean keepAlivePending; private long keepAliveChallenge; @@ -79,13 +79,12 @@ private int dropSpamTickCount; private double firstGoodX; private double firstGoodY; -@@ -250,8 +313,32 @@ - this.signedMessageDecoder = SignedMessageChain.a.UNSIGNED; - } - +@@ -244,8 +307,31 @@ + this.keepAliveTime = SystemUtils.getMillis(); + entityplayer.getTextFilter().join(); + this.signedMessageDecoder = minecraftserver.enforceSecureProfile() ? SignedMessageChain.b.REJECT_ALL : SignedMessageChain.b.unsigned(entityplayer.getUUID()); - this.chatMessageChain = new FutureChain(minecraftserver); + this.chatMessageChain = new FutureChain(minecraftserver.chatExecutor); // CraftBukkit - async chat -+ + // CraftBukkit start - add fields and methods + this.cserver = minecraftserver.server; + } @@ -113,7 +112,7 @@ @Override public void tick() { -@@ -306,7 +393,7 @@ +@@ -300,7 +386,7 @@ this.server.getProfiler().push("keepAlive"); long i = SystemUtils.getMillis(); @@ -122,7 +121,7 @@ if (this.keepAlivePending) { this.disconnect(IChatBaseComponent.translatable("disconnect.timeout")); } else { -@@ -318,15 +405,21 @@ +@@ -312,15 +398,21 @@ } this.server.getProfiler().pop(); @@ -144,7 +143,7 @@ this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.idling")); } -@@ -351,16 +444,67 @@ +@@ -344,16 +436,67 @@ return this.server.isSingleplayerOwner(this.player.getGameProfile()); } @@ -213,7 +212,7 @@ } private CompletableFuture filterTextPacket(T t0, BiFunction> bifunction) { -@@ -424,7 +568,34 @@ +@@ -417,7 +560,34 @@ double d9 = entity.getDeltaMovement().lengthSqr(); double d10 = d6 * d6 + d7 * d7 + d8 * d8; @@ -249,7 +248,7 @@ PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8}); this.connection.send(new PacketPlayOutVehicleMove(entity)); return; -@@ -456,14 +627,72 @@ +@@ -449,14 +619,72 @@ } entity.absMoveTo(d3, d4, d5, f, f1); @@ -322,7 +321,7 @@ this.player.getLevel().getChunkSource().move(this.player); this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2); this.clientVehicleIsFloating = d11 >= -0.03125D && !flag1 && !this.server.isFlightAllowed() && !entity.isNoGravity() && this.noBlocksAround(entity); -@@ -497,6 +726,7 @@ +@@ -490,6 +718,7 @@ } this.awaitingPositionFromClient = null; @@ -330,7 +329,7 @@ } } -@@ -504,7 +734,7 @@ +@@ -497,7 +726,7 @@ @Override public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.getLevel()); @@ -339,7 +338,7 @@ RecipeBookServer recipebookserver = this.player.getRecipeBook(); Objects.requireNonNull(recipebookserver); -@@ -534,6 +764,12 @@ +@@ -527,6 +756,12 @@ @Override public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.getLevel()); @@ -352,7 +351,7 @@ StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand()); if (stringreader.canRead() && stringreader.peek() == '/') { -@@ -543,6 +779,7 @@ +@@ -536,6 +771,7 @@ ParseResults parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { @@ -360,7 +359,7 @@ this.connection.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions)); }); } -@@ -792,6 +1029,13 @@ +@@ -785,6 +1021,13 @@ if (container instanceof ContainerMerchant) { ContainerMerchant containermerchant = (ContainerMerchant) container; @@ -374,7 +373,7 @@ if (!containermerchant.stillValid(this.player)) { PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant); -@@ -806,6 +1050,13 @@ +@@ -799,6 +1042,13 @@ @Override public void handleEditBook(PacketPlayInBEdit packetplayinbedit) { @@ -388,7 +387,7 @@ int i = packetplayinbedit.getSlot(); if (PlayerInventory.isHotbarSlot(i) || i == 40) { -@@ -814,7 +1065,7 @@ +@@ -807,7 +1057,7 @@ Objects.requireNonNull(list); optional.ifPresent(list::add); @@ -397,7 +396,7 @@ Objects.requireNonNull(list); stream.forEach(list::add); -@@ -832,7 +1083,7 @@ +@@ -825,7 +1075,7 @@ ItemStack itemstack = this.player.getInventory().getItem(i); if (itemstack.is(Items.WRITABLE_BOOK)) { @@ -406,7 +405,7 @@ } } -@@ -857,16 +1108,16 @@ +@@ -850,16 +1100,16 @@ this.updateBookPages(list, (s) -> { return IChatBaseComponent.ChatSerializer.toJson(IChatBaseComponent.literal(s)); @@ -427,7 +426,7 @@ return NBTTagString.valueOf((String) unaryoperator.apply(filteredtext.filteredOrEmpty())); }); -@@ -892,6 +1143,7 @@ +@@ -885,6 +1135,7 @@ } itemstack.addTagElement("pages", nbttaglist); @@ -435,7 +434,7 @@ } @Override -@@ -928,7 +1180,7 @@ +@@ -921,7 +1172,7 @@ } else { WorldServer worldserver = this.player.getLevel(); @@ -444,7 +443,7 @@ if (this.tickCount == 0) { this.resetPosition(); } -@@ -938,7 +1190,7 @@ +@@ -931,7 +1182,7 @@ this.awaitingTeleportTime = this.tickCount; this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); } @@ -453,7 +452,7 @@ } else { this.awaitingTeleportTime = this.tickCount; double d0 = clampHorizontal(packetplayinflying.getX(this.player.getX())); -@@ -950,7 +1202,15 @@ +@@ -943,7 +1194,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); @@ -469,7 +468,7 @@ double d3 = this.player.getX(); double d4 = this.player.getY(); double d5 = this.player.getZ(); -@@ -970,15 +1230,33 @@ +@@ -963,15 +1222,33 @@ ++this.receivedMovePacketCount; int i = this.receivedMovePacketCount - this.knownMovePacketCount; @@ -505,7 +504,7 @@ PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d7, d8, d9}); this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot()); return; -@@ -999,6 +1277,7 @@ +@@ -992,6 +1269,7 @@ boolean flag1 = this.player.verticalCollisionBelow; this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9)); @@ -513,12 +512,13 @@ double d12 = d8; d7 = d0 - this.player.getX(); -@@ -1018,8 +1297,71 @@ +@@ -1011,9 +1289,72 @@ this.player.absMoveTo(d0, d1, d2, f, f1); if (!this.player.noPhysics && !this.player.isSleeping() && (flag2 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb))) { - this.teleport(d3, d4, d5, f, f1); + this.internalTeleport(d3, d4, d5, f, f1, Collections.emptySet(), false); // CraftBukkit - SPIGOT-1807: Don't call teleport event, when the client thinks the player is falling, because the chunks are not loaded on the client yet. + this.player.doCheckFallDamage(this.player.getY() - d6, packetplayinflying.isOnGround()); } else { + // CraftBukkit start - fire PlayerMoveEvent + // Rest to old location first @@ -586,7 +586,7 @@ 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()); -@@ -1058,19 +1400,80 @@ +@@ -1052,19 +1393,80 @@ return true; } @@ -612,9 +612,8 @@ public void teleport(double d0, double d1, double d2, float f, float f1, Set set) { - this.teleport(d0, d1, d2, f, f1, set, false); + this.teleport(d0, d1, d2, f, f1, set, PlayerTeleportEvent.TeleportCause.UNKNOWN); - } - -- public void teleport(double d0, double d1, double d2, float f, float f1, Set set, boolean flag) { ++ } ++ + public void teleport(double d0, double d1, double d2, float f, float f1, Set set, PlayerTeleportEvent.TeleportCause cause) { + this.teleport(d0, d1, d2, f, f1, set, false, cause); + } @@ -655,8 +654,9 @@ + + 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) { + private void internalTeleport(double d0, double d1, double d2, float f, float f1, Set set, boolean flag) { + // CraftBukkit start + if (Float.isNaN(f)) { @@ -671,7 +671,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; -@@ -1082,6 +1485,14 @@ +@@ -1076,6 +1478,14 @@ this.awaitingTeleport = 0; } @@ -686,7 +686,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)); -@@ -1090,6 +1501,7 @@ +@@ -1084,6 +1494,7 @@ @Override public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.getLevel()); @@ -694,7 +694,7 @@ BlockPosition blockposition = packetplayinblockdig.getPos(); this.player.resetLastActionTime(); -@@ -1100,14 +1512,46 @@ +@@ -1094,14 +1505,46 @@ if (!this.player.isSpectator()) { ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND); @@ -743,7 +743,7 @@ this.player.drop(false); } -@@ -1145,6 +1589,7 @@ +@@ -1139,6 +1582,7 @@ @Override public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.getLevel()); @@ -751,15 +751,15 @@ this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence()); WorldServer worldserver = this.player.getLevel(); EnumHand enumhand = packetplayinuseitem.getHand(); -@@ -1166,6 +1611,7 @@ +@@ -1162,6 +1606,7 @@ - if (blockposition.getY() < i) { - if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) { -+ 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)) { ++ 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)) { -@@ -1193,6 +1639,7 @@ + if (enumdirection == EnumDirection.UP && !enuminteractionresult.consumesAction() && blockposition.getY() >= i - 1 && wasBlockPlacementAttempt(this.player, itemstack)) { +@@ -1190,6 +1635,7 @@ @Override public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.getLevel()); @@ -767,10 +767,10 @@ this.ackBlockChangesUpTo(packetplayinblockplace.getSequence()); WorldServer worldserver = this.player.getLevel(); EnumHand enumhand = packetplayinblockplace.getHand(); -@@ -1200,6 +1647,49 @@ +@@ -1197,6 +1643,49 @@ this.player.resetLastActionTime(); - if (!itemstack.isEmpty()) { + if (!itemstack.isEmpty() && itemstack.isItemEnabled(worldserver.enabledFeatures())) { + // CraftBukkit start + // Raytrace to look for 'rogue armswings' + float f1 = this.player.getXRot(); @@ -817,7 +817,7 @@ EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand); if (enuminteractionresult.shouldSwing()) { -@@ -1220,7 +1710,7 @@ +@@ -1217,7 +1706,7 @@ Entity entity = packetplayinspectate.getEntity(worldserver); if (entity != null) { @@ -826,7 +826,7 @@ return; } } -@@ -1235,6 +1725,7 @@ +@@ -1232,6 +1721,7 @@ PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName()); this.disconnect(IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect")); } @@ -834,7 +834,7 @@ } -@@ -1254,11 +1745,26 @@ +@@ -1251,12 +1741,27 @@ @Override public void onDisconnect(IChatBaseComponent ichatbasecomponent) { @@ -845,6 +845,7 @@ + this.processedDisconnect = true; + } + // CraftBukkit end + this.chatMessageChain.close(); PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), ichatbasecomponent.getString()); + // CraftBukkit start - Replace vanilla quit message handling with our own. + /* @@ -862,7 +863,7 @@ this.player.getTextFilter().leave(); if (this.isSingleplayerOwner()) { PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out"); -@@ -1281,6 +1787,15 @@ +@@ -1279,6 +1784,15 @@ } public void send(Packet packet, @Nullable PacketSendListener packetsendlistener) { @@ -878,7 +879,7 @@ try { this.connection.send(packet, packetsendlistener); } catch (Throwable throwable) { -@@ -1297,7 +1812,16 @@ +@@ -1295,7 +1809,16 @@ @Override public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.getLevel()); @@ -895,7 +896,7 @@ if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) { this.player.stopUsingItem(); } -@@ -1306,16 +1830,23 @@ +@@ -1304,18 +1827,25 @@ this.player.resetLastActionTime(); } else { PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString()); @@ -914,31 +915,31 @@ if (isChatMessageIllegal(packetplayinchat.message())) { this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.illegal_characters")); } else { - if (this.tryHandleChat(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.lastSeenMessages())) { + Optional optional = this.tryHandleChat(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.lastSeenMessages()); + + if (optional.isPresent()) { - this.server.submit(() -> { + // this.server.submit(() -> { // CraftBukkit - async chat - PlayerChatMessage playerchatmessage = this.getSignedMessage(packetplayinchat); + PlayerChatMessage playerchatmessage; - if (this.verifyChatMessage(playerchatmessage)) { -@@ -1328,10 +1859,10 @@ - PlayerChatMessage playerchatmessage1 = ((PlayerChatMessage) completablefuture1.join()).filter(filtermask); + try { +@@ -1333,9 +1863,9 @@ + PlayerChatMessage playerchatmessage1 = playerchatmessage.withUnsignedContent((IChatBaseComponent) completablefuture1.join()).filter(((FilteredText) completablefuture.join()).mask()); - this.broadcastChatMessage(playerchatmessage1); -- }, this.server); -+ }, this.server.chatExecutor); // CraftBukkit - async chat - }); - } + this.broadcastChatMessage(playerchatmessage1); +- }, executor); ++ }, this.server.chatExecutor); // CraftBukkit - async chat + }); - }); + // }); // CraftBukkit - async chat } } -@@ -1353,8 +1884,21 @@ +@@ -1359,12 +1889,25 @@ } - private void performChatCommand(ServerboundChatCommandPacket serverboundchatcommandpacket) { -- ParseResults parseresults = this.parseCommand(serverboundchatcommandpacket.command()); -- Map map = this.collectSignedArguments(serverboundchatcommandpacket, PreviewableCommand.of(parseresults)); + private void performChatCommand(ServerboundChatCommandPacket serverboundchatcommandpacket, LastSeenMessages lastseenmessages) { +- ParseResults parseresults = this.parseCommand(serverboundchatcommandpacket.command()); + // CraftBukkit start + String command = "/" + serverboundchatcommandpacket.command(); + PlayerConnection.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + command); @@ -951,31 +952,40 @@ + } + command = event.getMessage().substring(1); + -+ ParseResults parseresults = this.parseCommand(command); -+ Map map = (serverboundchatcommandpacket.command().equals(command)) ? this.collectSignedArguments(serverboundchatcommandpacket, PreviewableCommand.of(parseresults)) : Collections.emptyMap(); ++ ParseResults parseresults = this.parseCommand(command); + // CraftBukkit end - Iterator iterator = map.values().iterator(); - PlayerChatMessage playerchatmessage; -@@ -1366,7 +1910,7 @@ - parseresults = CommandDispatcher.mapSource(parseresults, (commandlistenerwrapper) -> { - return commandlistenerwrapper.withSigningContext(commandsigningcontext_a); - }); -- this.server.getCommands().performCommand(parseresults, serverboundchatcommandpacket.command()); -+ this.server.getCommands().performCommand(parseresults, command); // CraftBukkit - return; - } + Map map; -@@ -1415,7 +1959,7 @@ + try { +- map = this.collectSignedArguments(serverboundchatcommandpacket, SignableCommand.of(parseresults), lastseenmessages); ++ map = (serverboundchatcommandpacket.command().equals(command)) ? this.collectSignedArguments(serverboundchatcommandpacket, SignableCommand.of(parseresults), lastseenmessages) : Collections.emptyMap(); // CraftBukkit + } catch (SignedMessageChain.a signedmessagechain_a) { + this.handleMessageDecodeFailure(signedmessagechain_a); + return; +@@ -1372,10 +1915,10 @@ + + CommandSigningContext.a commandsigningcontext_a = new CommandSigningContext.a(map); + +- parseresults = CommandDispatcher.mapSource(parseresults, (commandlistenerwrapper) -> { ++ parseresults = CommandDispatcher.mapSource(parseresults, (commandlistenerwrapper) -> { // CraftBukkit - decompile error + return commandlistenerwrapper.withSigningContext(commandsigningcontext_a); + }); +- this.server.getCommands().performCommand(parseresults, serverboundchatcommandpacket.command()); ++ this.server.getCommands().performCommand(parseresults, command); // CraftBukkit + } + + private void handleMessageDecodeFailure(SignedMessageChain.a signedmessagechain_a) { +@@ -1413,7 +1956,7 @@ PlayerConnection.LOGGER.warn("{} sent out-of-order chat: '{}'", this.player.getName().getString(), s); this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.out_of_order_chat")); - return false; + return Optional.empty(); - } else if (this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { + } else if (this.player.isRemoved() || this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales this.send(new ClientboundSystemChatPacket(IChatBaseComponent.translatable("chat.disabled.options").withStyle(EnumChatFormat.RED), false)); - return false; + return Optional.empty(); } else { -@@ -1459,6 +2003,135 @@ +@@ -1462,6 +2005,122 @@ return false; } @@ -984,7 +994,7 @@ + if (s.isEmpty() || this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { + return; + } -+ OutgoingPlayerChatMessage outgoing = OutgoingPlayerChatMessage.create(original); ++ OutgoingChatMessage outgoing = OutgoingChatMessage.create(original); + + if (!async && s.startsWith("/")) { + this.handleCommand(s); @@ -1006,9 +1016,6 @@ + org.bukkit.Bukkit.getPluginManager().callEvent(queueEvent); + + if (queueEvent.isCancelled()) { -+ if (outgoing != null) { -+ outgoing.sendHeadersToRemainingPlayers(PlayerConnection.this.server.getPlayerList()); -+ } + return null; + } + @@ -1017,7 +1024,7 @@ + if (originalFormat.equals(queueEvent.getFormat()) && originalMessage.equals(queueEvent.getMessage()) && queueEvent.getPlayer().getName().equalsIgnoreCase(queueEvent.getPlayer().getDisplayName())) { + PlayerConnection.this.server.getPlayerList().broadcastChatMessage(original, PlayerConnection.this.player, ChatMessageType.bind(ChatMessageType.CHAT, (Entity) PlayerConnection.this.player)); + return null; -+ } else if (CraftChatMessage.fromComponent(original.serverContent()).equals(message)) { ++ } else if (CraftChatMessage.fromComponent(original.decoratedContent()).equals(message)) { + PlayerConnection.this.server.getPlayerList().broadcastChatMessage(original, PlayerConnection.this.player, ChatMessageType.bind(ChatMessageType.RAW, (Entity) PlayerConnection.this.player)); + return null; + } @@ -1032,9 +1039,6 @@ + } + PlayerConnection.this.server.console.sendMessage(message); + -+ if (outgoing != null) { -+ outgoing.sendHeadersToRemainingPlayers(PlayerConnection.this.server.getPlayerList()); -+ } + return null; + }}; + if (async) { @@ -1051,9 +1055,6 @@ + } + } else { + if (event.isCancelled()) { -+ if (outgoing != null) { -+ outgoing.sendHeadersToRemainingPlayers(PlayerConnection.this.server.getPlayerList()); -+ } + return; + } + @@ -1062,7 +1063,7 @@ + if (originalFormat.equals(event.getFormat()) && originalMessage.equals(event.getMessage()) && event.getPlayer().getName().equalsIgnoreCase(event.getPlayer().getDisplayName())) { + PlayerConnection.this.server.getPlayerList().broadcastChatMessage(original, PlayerConnection.this.player, ChatMessageType.bind(ChatMessageType.CHAT, (Entity) PlayerConnection.this.player)); + return; -+ } else if (CraftChatMessage.fromComponent(original.serverContent()).equals(s)) { ++ } else if (CraftChatMessage.fromComponent(original.decoratedContent()).equals(s)) { + PlayerConnection.this.server.getPlayerList().broadcastChatMessage(original, PlayerConnection.this.player, ChatMessageType.bind(ChatMessageType.RAW, (Entity) PlayerConnection.this.player)); + return; + } @@ -1076,10 +1077,6 @@ + } + } + server.console.sendMessage(s); -+ -+ if (outgoing != null) { -+ outgoing.sendHeadersToRemainingPlayers(PlayerConnection.this.server.getPlayerList()); -+ } + } + } + } @@ -1108,22 +1105,19 @@ + } + // CraftBukkit end + - private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat) { - MessageSigner messagesigner = packetplayinchat.getSigner(this.player); - SignedMessageChain.c signedmessagechain_c = new SignedMessageChain.c(packetplayinchat.signature()); -@@ -1475,7 +2148,28 @@ + private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a { + SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages); + +@@ -1469,13 +2128,33 @@ } private void broadcastChatMessage(PlayerChatMessage playerchatmessage) { - this.server.getPlayerList().broadcastChatMessage(playerchatmessage, this.player, ChatMessageType.bind(ChatMessageType.CHAT, (Entity) this.player)); + // CraftBukkit start -+ String s = playerchatmessage.signedContent().plain(); ++ String s = playerchatmessage.signedContent(); + if (s.isEmpty()) { + LOGGER.warn(this.player.getScoreboardName() + " tried to send an empty message"); + } else if (getCraftPlayer().isConversing()) { -+ OutgoingPlayerChatMessage outgoing = OutgoingPlayerChatMessage.create(playerchatmessage); -+ outgoing.sendHeadersToRemainingPlayers(this.server.getPlayerList()); -+ + final String conversationInput = s; + this.server.processQueue.add(new Runnable() { + @Override @@ -1141,9 +1135,6 @@ this.detectRateSpam(); } -@@ -1503,8 +2197,10 @@ - } - private void detectRateSpam() { - this.chatSpamTickCount += 20; - if (this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { @@ -1154,30 +1145,7 @@ this.disconnect(IChatBaseComponent.translatable("disconnect.spam")); } -@@ -1568,7 +2264,7 @@ - List> list = previewablecommand.arguments(); - - if (list.isEmpty()) { -- return CompletableFuture.completedFuture((Object) null); -+ return CompletableFuture.completedFuture(null); // CraftBukkit - decompile error - } else { - for (int i = list.size() - 1; i >= 0; --i) { - PreviewableCommand.a previewablecommand_a = (PreviewableCommand.a) list.get(i); -@@ -1580,11 +2276,11 @@ - return completablefuture; - } - } catch (CommandSyntaxException commandsyntaxexception) { -- return CompletableFuture.completedFuture((Object) null); -+ return CompletableFuture.completedFuture(null); // CraftBukkit - decompile error - } - } - -- return CompletableFuture.completedFuture((Object) null); -+ return CompletableFuture.completedFuture(null); // CraftBukkit - decompile error - } - } - -@@ -1611,13 +2307,59 @@ +@@ -1497,13 +2176,59 @@ @Override public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.getLevel()); @@ -1237,71 +1205,73 @@ this.player.resetLastActionTime(); IJumpable ijumpable; -@@ -1702,6 +2444,7 @@ +@@ -1594,6 +2319,7 @@ @Override public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.getLevel()); + if (this.player.isImmobile()) return; // CraftBukkit - WorldServer worldserver = this.player.getLevel(); + final WorldServer worldserver = this.player.getLevel(); final Entity entity = packetplayinuseentity.getTarget(worldserver); -@@ -1714,10 +2457,49 @@ +@@ -1606,13 +2332,51 @@ if (entity.distanceToSqr(this.player.getEyePosition()) < PlayerConnection.MAX_INTERACTION_DISTANCE) { packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() { - private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a) { + private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit - ItemStack itemstack = PlayerConnection.this.player.getItemInHand(enumhand).copy(); -+ // CraftBukkit start -+ ItemStack itemInHand = PlayerConnection.this.player.getItemInHand(enumhand); -+ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient; -+ Item origItem = player.getInventory().getSelected() == null ? null : player.getInventory().getSelected().getItem(); + ItemStack itemstack = PlayerConnection.this.player.getItemInHand(enumhand); + + if (itemstack.isItemEnabled(worldserver.enabledFeatures())) { + ItemStack itemstack1 = itemstack.copy(); ++ // CraftBukkit start ++ ItemStack itemInHand = PlayerConnection.this.player.getItemInHand(enumhand); ++ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient; ++ Item origItem = player.getInventory().getSelected() == null ? null : player.getInventory().getSelected().getItem(); + -+ cserver.getPluginManager().callEvent(event); ++ cserver.getPluginManager().callEvent(event); + -+ // Entity in bucket - SPIGOT-4048 and SPIGOT-6859 -+ if ((entity instanceof Bucketable && entity instanceof EntityLiving && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) { -+ send(new PacketPlayOutSpawnEntity(entity)); -+ player.containerMenu.sendAllDataToRemote(); -+ } -+ -+ if (triggerLeashUpdate && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) { -+ // Refresh the current leash state -+ send(new PacketPlayOutAttachEntity(entity, ((EntityInsentient) entity).getLeashHolder())); -+ } -+ -+ if (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem) { -+ // Refresh the current entity metadata -+ send(new PacketPlayOutEntityMetadata(entity.getId(), entity.getEntityData(), true)); -+ // SPIGOT-7136 - Allays -+ if (entity instanceof Allay) { -+ send(new PacketPlayOutEntityEquipment(entity.getId(), Arrays.stream(EnumItemSlot.values()).map((slot) -> Pair.of(slot, ((EntityLiving) entity).getItemBySlot(slot).copy())).collect(Collectors.toList()))); ++ // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a ++ if ((entity instanceof Bucketable && entity instanceof EntityLiving && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) { ++ send(new PacketPlayOutSpawnEntity(entity)); + player.containerMenu.sendAllDataToRemote(); + } -+ } + -+ if (event.isCancelled()) { -+ return; -+ } -+ // CraftBukkit end ++ if (triggerLeashUpdate && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) { ++ // Refresh the current leash state ++ send(new PacketPlayOutAttachEntity(entity, ((EntityInsentient) entity).getLeashHolder())); ++ } + - EnumInteractionResult enuminteractionresult = playerconnection_a.run(PlayerConnection.this.player, entity, enumhand); ++ if (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem) { ++ // Refresh the current entity metadata ++ entity.getEntityData().refresh(player); ++ // SPIGOT-7136 - Allays ++ if (entity instanceof Allay) { ++ send(new PacketPlayOutEntityEquipment(entity.getId(), Arrays.stream(EnumItemSlot.values()).map((slot) -> Pair.of(slot, ((EntityLiving) entity).getItemBySlot(slot).copy())).collect(Collectors.toList()))); ++ player.containerMenu.sendAllDataToRemote(); ++ } ++ } ++ ++ if (event.isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + EnumInteractionResult enuminteractionresult = playerconnection_a.run(PlayerConnection.this.player, entity, enumhand); -+ // CraftBukkit start -+ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { -+ player.containerMenu.sendAllDataToRemote(); -+ } -+ // CraftBukkit end ++ // CraftBukkit start ++ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { ++ player.containerMenu.sendAllDataToRemote(); ++ } ++ // CraftBukkit end + - if (enuminteractionresult.consumesAction()) { - CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack, entity); - if (enuminteractionresult.shouldSwing()) { -@@ -1729,20 +2511,27 @@ + if (enuminteractionresult.consumesAction()) { + CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack1, entity); + if (enuminteractionresult.shouldSwing()) { +@@ -1625,23 +2389,29 @@ @Override public void onInteraction(EnumHand enumhand) { - this.performInteraction(enumhand, EntityHuman::interactOn); -+ this.performInteraction(enumhand, EntityHuman::interactOn, new PlayerInteractEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), (enumhand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); ++ this.performInteraction(enumhand, EntityHuman::interactOn, new PlayerInteractEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), (enumhand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); // CraftBukkit } @Override @@ -1315,19 +1285,21 @@ @Override public void onAttack() { - if (!(entity instanceof EntityItem) && !(entity instanceof EntityExperienceOrb) && !(entity instanceof EntityArrow) && entity != PlayerConnection.this.player) { -+ // CraftBukkit start ++ // CraftBukkit + if (!(entity instanceof EntityItem) && !(entity instanceof EntityExperienceOrb) && !(entity instanceof EntityArrow) && (entity != PlayerConnection.this.player || player.isSpectator())) { -+ ItemStack itemInHand = PlayerConnection.this.player.getMainHandItem(); - PlayerConnection.this.player.attack(entity); -+ -+ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { -+ player.containerMenu.sendAllDataToRemote(); -+ } -+ // CraftBukkit end + ItemStack itemstack = PlayerConnection.this.player.getItemInHand(EnumHand.MAIN_HAND); + + if (itemstack.isItemEnabled(worldserver.enabledFeatures())) { + PlayerConnection.this.player.attack(entity); ++ // CraftBukkit start ++ if (!itemstack.isEmpty() && itemstack.getCount() <= -1) { ++ player.containerMenu.sendAllDataToRemote(); ++ } ++ // CraftBukkit end + } } else { PlayerConnection.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.invalid_entity_attacked")); - PlayerConnection.LOGGER.warn("Player {} tried to attack an invalid entity", PlayerConnection.this.player.getName().getString()); -@@ -1787,15 +2576,21 @@ +@@ -1687,15 +2457,21 @@ @Override public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.getLevel()); @@ -1351,7 +1323,7 @@ this.player.containerMenu.sendAllDataToRemote(); } else if (!this.player.containerMenu.stillValid(this.player)) { PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); -@@ -1808,7 +2603,284 @@ +@@ -1708,7 +2484,284 @@ boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); @@ -1637,7 +1609,7 @@ ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator(); while (objectiterator.hasNext()) { -@@ -1848,6 +2920,7 @@ +@@ -1748,6 +2801,7 @@ @Override public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.getLevel()); @@ -1645,7 +1617,7 @@ this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) { if (!this.player.containerMenu.stillValid(this.player)) { -@@ -1885,6 +2958,43 @@ +@@ -1790,6 +2844,43 @@ boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45; boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); @@ -1689,7 +1661,7 @@ if (flag1 && flag2) { this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).set(itemstack); -@@ -1907,6 +3017,7 @@ +@@ -1812,6 +2903,7 @@ } private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List list) { @@ -1697,7 +1669,7 @@ this.player.resetLastActionTime(); WorldServer worldserver = this.player.getLevel(); BlockPosition blockposition = packetplayinupdatesign.getPos(); -@@ -1923,18 +3034,37 @@ +@@ -1828,18 +2920,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()); @@ -1737,7 +1709,7 @@ tileentitysign.setChanged(); worldserver.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3); -@@ -1944,6 +3074,7 @@ +@@ -1849,6 +2960,7 @@ @Override public void handleKeepAlive(PacketPlayInKeepAlive packetplayinkeepalive) { @@ -1745,7 +1717,7 @@ if (this.keepAlivePending && packetplayinkeepalive.getId() == this.keepAliveChallenge) { int i = (int) (SystemUtils.getMillis() - this.keepAliveTime); -@@ -1958,7 +3089,17 @@ +@@ -1863,7 +2975,17 @@ @Override public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.getLevel()); @@ -1764,7 +1736,7 @@ } @Override -@@ -1967,8 +3108,50 @@ +@@ -1872,8 +2994,50 @@ this.player.updateOptions(packetplayinsettings); } diff --git a/nms-patches/net/minecraft/server/players/PlayerList.patch b/nms-patches/net/minecraft/server/players/PlayerList.patch index c2489e974..3781f992e 100644 --- a/nms-patches/net/minecraft/server/players/PlayerList.patch +++ b/nms-patches/net/minecraft/server/players/PlayerList.patch @@ -1,12 +1,13 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -102,6 +102,24 @@ +@@ -107,6 +107,25 @@ import net.minecraft.world.scores.ScoreboardTeamBase; import org.slf4j.Logger; +// CraftBukkit start +import java.util.stream.Collectors; +import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; ++import net.minecraft.network.syncher.DataWatcher; +import net.minecraft.server.dedicated.DedicatedServer; +import net.minecraft.server.network.LoginListener; +import org.bukkit.Location; @@ -25,7 +26,7 @@ public abstract class PlayerList { public static final File USERBANLIST_FILE = new File("banned-players.json"); -@@ -113,14 +131,16 @@ +@@ -118,14 +137,16 @@ private static final int SEND_PLAYER_INFO_INTERVAL = 600; private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); private final MinecraftServer server; @@ -44,15 +45,15 @@ + // CraftBukkit end public final WorldNBTStorage playerIo; private boolean doWhiteList; - private final IRegistryCustom.Dimension registryHolder; -@@ -131,13 +151,23 @@ + private final LayeredRegistryAccess registries; +@@ -137,13 +158,23 @@ private static final boolean ALLOW_LOGOUTIVATOR = false; private int sendAllPlayerInfoIn; + // CraftBukkit start + private CraftServer cserver; + - public PlayerList(MinecraftServer minecraftserver, IRegistryCustom.Dimension iregistrycustom_dimension, WorldNBTStorage worldnbtstorage, int i) { + public PlayerList(MinecraftServer minecraftserver, LayeredRegistryAccess layeredregistryaccess, WorldNBTStorage worldnbtstorage, int i) { + this.cserver = minecraftserver.server = new CraftServer((DedicatedServer) minecraftserver, this); + minecraftserver.console = org.bukkit.craftbukkit.command.ColouredConsoleSender.getInstance(); + minecraftserver.reader.addCompleter(new org.bukkit.craftbukkit.command.ConsoleCommandCompleter(minecraftserver.server)); @@ -69,9 +70,9 @@ + // this.advancements = Maps.newHashMap(); + // CraftBukkit end this.server = minecraftserver; - this.registryHolder = iregistrycustom_dimension; - this.maxPlayers = i; -@@ -153,9 +183,15 @@ + this.registries = layeredregistryaccess; + this.synchronizedRegistries = (new IRegistryCustom.c(RegistrySynchronization.networkedRegistries(layeredregistryaccess))).freeze(); +@@ -160,9 +191,15 @@ usercache.add(gameprofile); NBTTagCompound nbttagcompound = this.load(entityplayer); ResourceKey resourcekey; @@ -88,7 +89,7 @@ Logger logger = PlayerList.LOGGER; Objects.requireNonNull(logger); -@@ -182,7 +218,8 @@ +@@ -189,7 +226,8 @@ s1 = networkmanager.getRemoteAddress().toString(); } @@ -98,15 +99,15 @@ WorldData worlddata = worldserver1.getLevelData(); entityplayer.loadGameTypes(nbttagcompound); -@@ -192,6 +229,7 @@ +@@ -199,6 +237,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.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, worldserver1.isDebug(), worldserver1.isFlat(), entityplayer.getLastDeathLocation())); + playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), entityplayer.gameMode.getGameModeForPlayer(), entityplayer.gameMode.getPreviousGameModeForPlayer(), this.server.levelKeys(), this.synchronizedRegistries, worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, worldserver1.isDebug(), worldserver1.isFlat(), entityplayer.getLastDeathLocation())); + entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit + playerconnection.send(new ClientboundUpdateEnabledFeaturesPacket(FeatureFlags.REGISTRY.toNames(worldserver1.enabledFeatures()))); playerconnection.send(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.BRAND, (new PacketDataSerializer(Unpooled.buffer())).writeUtf(this.getServer().getServerModName()))); playerconnection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); - playerconnection.send(new PacketPlayOutAbilities(entityplayer.getAbilities())); -@@ -210,19 +248,66 @@ +@@ -218,16 +257,68 @@ } else { ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.player.joined.renamed", entityplayer.getDisplayName(), s); } @@ -116,10 +117,14 @@ - this.broadcastSystemMessage(ichatmutablecomponent.withStyle(EnumChatFormat.YELLOW), false); playerconnection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot()); + entityplayer.sendServerStatus(this.server.getStatus()); + entityplayer.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(this.players)); this.players.add(entityplayer); this.playersByUUID.put(entityplayer.getUUID(), entityplayer); -- this.broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer})); -+ // this.broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer})); // CraftBukkit - replaced with loop below +- this.broadcastAll(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityplayer))); +- worldserver1.addNewPlayer(entityplayer); +- this.server.getCustomBossEvents().onPlayerConnect(entityplayer); ++ // this.broadcastAll(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityplayer))); // CraftBukkit - replaced with loop below + + // CraftBukkit start + CraftPlayer bukkitPlayer = entityplayer.getBukkitEntity(); @@ -144,10 +149,9 @@ + // CraftBukkit end + + // CraftBukkit start - sendAll above replaced with this loop -+ PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entityplayer); - - for (int i = 0; i < this.players.size(); ++i) { -- entityplayer.connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{(EntityPlayer) this.players.get(i)})); ++ ClientboundPlayerInfoUpdatePacket packet = ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityplayer)); ++ ++ for (int i = 0; i < this.players.size(); ++i) { + EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i); + + if (entityplayer1.getBukkitEntity().canSee(bukkitPlayer)) { @@ -158,14 +162,12 @@ + continue; + } + -+ entityplayer.connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer1})); - } ++ entityplayer.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityplayer1))); ++ } + entityplayer.sentListPacket = true; + // CraftBukkit end - -- worldserver1.addNewPlayer(entityplayer); -- this.server.getCustomBossEvents().onPlayerConnect(entityplayer); -+ entityplayer.connection.send(new PacketPlayOutEntityMetadata(entityplayer.getId(), entityplayer.getEntityData(), true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn ++ ++ entityplayer.getEntityData().refresh(entityplayer); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn + + // CraftBukkit start - Only add if the player wasn't moved in the event + if (entityplayer.level == worldserver1 && !worldserver1.players().contains(entityplayer)) { @@ -178,7 +180,7 @@ this.sendLevelInfo(entityplayer, worldserver1); this.server.getServerResourcePack().ifPresent((minecraftserver_serverresourcepackinfo) -> { entityplayer.sendTexturePack(minecraftserver_serverresourcepackinfo.url(), minecraftserver_serverresourcepackinfo.hash(), minecraftserver_serverresourcepackinfo.isRequired(), minecraftserver_serverresourcepackinfo.prompt()); -@@ -238,8 +323,11 @@ +@@ -242,8 +333,11 @@ if (nbttagcompound != null && nbttagcompound.contains("RootVehicle", 10)) { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle"); @@ -192,7 +194,7 @@ }); if (entity != null) { -@@ -282,6 +370,8 @@ +@@ -286,6 +380,8 @@ } entityplayer.initInventoryMenu(); @@ -201,7 +203,7 @@ } public void updateEntireScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { -@@ -314,30 +404,31 @@ +@@ -318,30 +414,31 @@ } public void addWorldborderListener(WorldServer worldserver) { @@ -238,7 +240,7 @@ } @Override -@@ -365,14 +456,15 @@ +@@ -369,14 +466,15 @@ } protected void save(EntityPlayer entityplayer) { @@ -256,7 +258,7 @@ if (advancementdataplayer != null) { advancementdataplayer.save(); -@@ -380,10 +472,24 @@ +@@ -384,10 +482,24 @@ } @@ -282,7 +284,7 @@ this.save(entityplayer); if (entityplayer.isPassenger()) { Entity entity = entityplayer.getRootVehicle(); -@@ -407,18 +513,66 @@ +@@ -411,18 +523,66 @@ if (entityplayer1 == entityplayer) { this.playersByUUID.remove(uuid); @@ -292,11 +294,12 @@ + // this.stats.remove(uuid); + // this.advancements.remove(uuid); + // CraftBukkit end -+ } -+ + } + +- this.broadcastAll(new ClientboundPlayerInfoRemovePacket(List.of(entityplayer.getUUID()))); + // CraftBukkit start -+ // this.broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer})); -+ PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityplayer); ++ // this.broadcastAll(new ClientboundPlayerInfoRemovePacket(List.of(entityplayer.getUUID()))); ++ ClientboundPlayerInfoRemovePacket packet = new ClientboundPlayerInfoRemovePacket(List.of(entityplayer.getUUID())); + for (int i = 0; i < players.size(); i++) { + EntityPlayer entityplayer2 = (EntityPlayer) this.players.get(i); + @@ -305,19 +308,18 @@ + } else { + entityplayer2.getBukkitEntity().onEntityRemove(entityplayer); + } - } ++ } + // This removes the scoreboard (and player reference) for the specific player in the manager + cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity()); + // CraftBukkit end - -- this.broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer})); ++ + return playerQuitEvent.getQuitMessage(); // CraftBukkit } - @Nullable - public IChatBaseComponent canPlayerLogin(SocketAddress socketaddress, GameProfile gameprofile) { + // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer -+ public EntityPlayer canPlayerLogin(LoginListener loginlistener, GameProfile gameprofile, ProfilePublicKey profilepublickey) { ++ public EntityPlayer canPlayerLogin(LoginListener loginlistener, GameProfile gameprofile) { IChatMutableComponent ichatmutablecomponent; - if (this.bans.isBanned(gameprofile)) { @@ -347,7 +349,7 @@ + // depending on the outcome. + SocketAddress socketaddress = loginlistener.connection.getRemoteAddress(); + -+ EntityPlayer entity = new EntityPlayer(this.server, this.server.getLevel(World.OVERWORLD), gameprofile, profilepublickey); ++ EntityPlayer entity = new EntityPlayer(this.server, this.server.getLevel(World.OVERWORLD), gameprofile); + Player player = entity.getBukkitEntity(); + PlayerLoginEvent event = new PlayerLoginEvent(player, loginlistener.connection.hostname, ((java.net.InetSocketAddress) socketaddress).getAddress()); + @@ -355,7 +357,7 @@ GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile); ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason()); -@@ -426,10 +580,12 @@ +@@ -430,10 +590,12 @@ ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires()))); } @@ -371,7 +373,7 @@ IpBanEntry ipbanentry = this.ipBans.get(socketaddress); ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.reason", ipbanentry.getReason()); -@@ -437,13 +593,25 @@ +@@ -441,13 +603,25 @@ ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires()))); } @@ -394,16 +396,16 @@ + return entity; } -- public EntityPlayer getPlayerForLogin(GameProfile gameprofile, @Nullable ProfilePublicKey profilepublickey) { +- public EntityPlayer getPlayerForLogin(GameProfile gameprofile) { + public EntityPlayer getPlayerForLogin(GameProfile gameprofile, EntityPlayer player) { // CraftBukkit - added EntityPlayer + /* CraftBukkit startMoved up UUID uuid = UUIDUtil.getOrCreatePlayerUUID(gameprofile); List list = Lists.newArrayList(); -@@ -470,14 +638,24 @@ +@@ -474,14 +648,24 @@ } - return new EntityPlayer(this.server, this.server.overworld(), gameprofile, profilepublickey); + return new EntityPlayer(this.server, this.server.overworld(), gameprofile); + */ + return player; + // CraftBukkit end @@ -425,10 +427,10 @@ WorldServer worldserver = this.server.getLevel(entityplayer.getRespawnDimension()); Optional optional; -@@ -489,6 +667,11 @@ +@@ -493,6 +677,11 @@ WorldServer worldserver1 = worldserver != null && optional.isPresent() ? worldserver : this.server.overworld(); - EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getGameProfile(), entityplayer.getProfilePublicKey()); + EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getGameProfile()); + // */ + EntityPlayer entityplayer1 = entityplayer; + org.bukkit.World fromWorld = entityplayer.getBukkitEntity().getWorld(); @@ -437,7 +439,7 @@ entityplayer1.connection = entityplayer.connection; entityplayer1.restoreFrom(entityplayer, flag); -@@ -504,49 +687,110 @@ +@@ -508,50 +697,112 @@ boolean flag2 = false; @@ -462,7 +464,8 @@ + } else { + optional = Optional.empty(); + } -+ + +- f1 = (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); + if (optional.isPresent()) { + IBlockData iblockdata = worldserver1.getBlockState(blockposition); + boolean flag3 = iblockdata.is(Blocks.RESPAWN_ANCHOR); @@ -473,8 +476,7 @@ + f1 = f; + } else { + Vec3D vec3d1 = Vec3D.atBottomCenterOf(blockposition).subtract(vec3d).normalize(); - -- f1 = (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); ++ + f1 = (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); + } + @@ -516,17 +518,18 @@ + while (avoidSuffocation && !worldserver1.noCollision((Entity) entityplayer1) && entityplayer1.getY() < (double) worldserver1.getMaxBuildHeight()) { entityplayer1.setPos(entityplayer1.getX(), entityplayer1.getY() + 1.0D, entityplayer1.getZ()); } + + int i = flag ? 1 : 0; +- WorldData worlddata = entityplayer1.level.getLevelData(); + // CraftBukkit start + WorldData worlddata = worldserver1.getLevelData(); -+ entityplayer1.connection.send(new PacketPlayOutRespawn(worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), worldserver1.isDebug(), worldserver1.isFlat(), flag, entityplayer1.getLastDeathLocation())); ++ entityplayer1.connection.send(new PacketPlayOutRespawn(worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), worldserver1.isDebug(), worldserver1.isFlat(), (byte) i, entityplayer1.getLastDeathLocation())); + entityplayer1.spawnIn(worldserver1); + entityplayer1.unsetRemoved(); + entityplayer1.connection.teleport(new Location(worldserver1.getWorld(), entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot())); + entityplayer1.setShiftKeyDown(false); -- WorldData worlddata = entityplayer1.level.getLevelData(); -- -- entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.level.dimensionTypeId(), entityplayer1.level.dimension(), BiomeManager.obfuscateSeed(entityplayer1.getLevel().getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), entityplayer1.getLevel().isDebug(), entityplayer1.getLevel().isFlat(), flag, entityplayer1.getLastDeathLocation())); +- entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.level.dimensionTypeId(), entityplayer1.level.dimension(), BiomeManager.obfuscateSeed(entityplayer1.getLevel().getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), entityplayer1.getLevel().isDebug(), entityplayer1.getLevel().isFlat(), (byte) i, entityplayer1.getLastDeathLocation())); - 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())); @@ -557,13 +560,13 @@ + + // Fire advancement trigger + entityplayer.triggerDimensionChangeTriggers(((CraftWorld) fromWorld).getHandle()); - ++ + // Don't fire on respawn + if (fromWorld != location.getWorld()) { + PlayerChangedWorldEvent event = new PlayerChangedWorldEvent(entityplayer.getBukkitEntity(), fromWorld); + server.server.getPluginManager().callEvent(event); + } -+ + + // Save player file again if they were disconnected + if (entityplayer.connection.isDisconnected()) { + this.save(entityplayer); @@ -572,16 +575,16 @@ return entityplayer1; } -@@ -559,7 +803,18 @@ +@@ -564,7 +815,18 @@ public void tick() { if (++this.sendAllPlayerInfoIn > 600) { -- this.broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players)); +- this.broadcastAll(new ClientboundPlayerInfoUpdatePacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.a.UPDATE_LATENCY), this.players)); + // CraftBukkit start + for (int i = 0; i < this.players.size(); ++i) { + final EntityPlayer target = (EntityPlayer) this.players.get(i); + -+ target.connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players.stream().filter(new Predicate() { ++ target.connection.send(new ClientboundPlayerInfoUpdatePacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.a.UPDATE_LATENCY), this.players.stream().filter(new Predicate() { + @Override + public boolean test(EntityPlayer input) { + return target.getBukkitEntity().canSee(input.getBukkitEntity()); @@ -592,7 +595,7 @@ this.sendAllPlayerInfoIn = 0; } -@@ -576,6 +831,25 @@ +@@ -581,6 +843,25 @@ } @@ -618,7 +621,7 @@ public void broadcastAll(Packet packet, ResourceKey resourcekey) { Iterator iterator = this.players.iterator(); -@@ -654,7 +928,7 @@ +@@ -659,7 +940,7 @@ } public void deop(GameProfile gameprofile) { @@ -627,7 +630,7 @@ EntityPlayer entityplayer = this.getPlayer(gameprofile.getId()); if (entityplayer != null) { -@@ -678,6 +952,7 @@ +@@ -683,6 +964,7 @@ entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0)); } @@ -635,7 +638,7 @@ this.server.getCommands().sendCommands(entityplayer); } -@@ -710,6 +985,12 @@ +@@ -715,6 +997,12 @@ for (int i = 0; i < this.players.size(); ++i) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(i); @@ -648,7 +651,7 @@ if (entityplayer != entityhuman && entityplayer.level.dimension() == resourcekey) { double d4 = d0 - entityplayer.getX(); double d5 = d1 - entityplayer.getY(); -@@ -749,23 +1030,34 @@ +@@ -754,23 +1042,34 @@ public void reloadWhiteList() {} public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) { @@ -688,7 +691,7 @@ } public int getPlayerCount() { -@@ -821,12 +1113,22 @@ +@@ -826,12 +1125,22 @@ } public void removeAll() { @@ -713,8 +716,8 @@ public void broadcastSystemMessage(IChatBaseComponent ichatbasecomponent, boolean flag) { this.broadcastSystemMessage(ichatbasecomponent, (entityplayer) -> { return ichatbasecomponent; -@@ -902,16 +1204,23 @@ - return !playerchatmessage.hasExpiredServer(Instant.now()) && playerchatmessage.verify(chatsender); +@@ -889,16 +1198,23 @@ + return playerchatmessage.hasSignature() && !playerchatmessage.hasExpiredServer(Instant.now()); } - public ServerStatisticManager getPlayerStats(EntityHuman entityhuman) { @@ -741,7 +744,7 @@ Path path = file2.toPath(); if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) { -@@ -920,7 +1229,7 @@ +@@ -907,7 +1223,7 @@ } serverstatisticmanager = new ServerStatisticManager(this.server, file1); @@ -750,7 +753,7 @@ } return serverstatisticmanager; -@@ -928,14 +1237,14 @@ +@@ -915,14 +1231,14 @@ public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) { UUID uuid = entityplayer.getUUID(); @@ -767,7 +770,7 @@ } advancementdataplayer.setPlayer(entityplayer); -@@ -986,13 +1295,20 @@ +@@ -973,13 +1289,20 @@ } public void reloadResources() { @@ -787,5 +790,5 @@ } + // CraftBukkit end - this.broadcastAll(new PacketPlayOutTags(TagNetworkSerialization.serializeTagsToNetwork(this.registryHolder))); + this.broadcastAll(new PacketPlayOutTags(TagNetworkSerialization.serializeTagsToNetwork(this.registries))); PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(this.server.getRecipeManager().getRecipes()); diff --git a/nms-patches/net/minecraft/stats/ServerStatisticManager.patch b/nms-patches/net/minecraft/stats/ServerStatisticManager.patch index 3b006c886..81bf5fa5a 100644 --- a/nms-patches/net/minecraft/stats/ServerStatisticManager.patch +++ b/nms-patches/net/minecraft/stats/ServerStatisticManager.patch @@ -5,7 +5,7 @@ package net.minecraft.stats; import com.google.common.collect.Maps; -@@ -161,13 +162,12 @@ +@@ -162,13 +163,12 @@ } private Optional> getStat(StatisticWrapper statisticwrapper, String s) { diff --git a/nms-patches/net/minecraft/util/SpawnUtil.patch b/nms-patches/net/minecraft/util/SpawnUtil.patch index eca28d62d..b374037a7 100644 --- a/nms-patches/net/minecraft/util/SpawnUtil.patch +++ b/nms-patches/net/minecraft/util/SpawnUtil.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/SpawnUtil.java +++ b/net/minecraft/util/SpawnUtil.java -@@ -18,6 +18,12 @@ +@@ -17,6 +17,12 @@ public SpawnUtil() {} public static Optional trySpawnMob(EntityTypes entitytypes, EnumMobSpawn enummobspawn, WorldServer worldserver, BlockPosition blockposition, int i, int j, int k, SpawnUtil.a spawnutil_a) { @@ -13,12 +13,12 @@ BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable(); for (int l = 0; l < i; ++l) { -@@ -26,11 +32,11 @@ +@@ -25,11 +31,11 @@ blockposition_mutableblockposition.setWithOffset(blockposition, i1, k, j1); if (worldserver.getWorldBorder().isWithinBounds((BlockPosition) blockposition_mutableblockposition) && moveToPossibleSpawnPosition(worldserver, k, blockposition_mutableblockposition, spawnutil_a)) { -- T t0 = (EntityInsentient) entitytypes.create(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition_mutableblockposition, enummobspawn, false, false); -+ T t0 = entitytypes.create(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition_mutableblockposition, enummobspawn, false, false); // CraftBukkit - decompile error +- T t0 = (EntityInsentient) entitytypes.create(worldserver, (NBTTagCompound) null, (Consumer) null, blockposition_mutableblockposition, enummobspawn, false, false); ++ T t0 = entitytypes.create(worldserver, (NBTTagCompound) null, null, blockposition_mutableblockposition, enummobspawn, false, false); // CraftBukkit - decompile error if (t0 != null) { if (t0.checkSpawnRules(worldserver, enummobspawn) && t0.checkSpawnObstruction(worldserver)) { diff --git a/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch b/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch index 03644328a..042c4ebd2 100644 --- a/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch +++ b/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 -@@ -439,6 +439,18 @@ +@@ -444,6 +444,18 @@ datafixerbuilder.addFixer(new DataConverterItemFrame(schema46, false)); Schema schema47 = datafixerbuilder.addSchema(1458, DataConverterRegistry.SAME_NAMESPACED); @@ -19,7 +19,7 @@ datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema47, false)); datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema47, false)); datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema47, false)); -@@ -756,12 +768,14 @@ +@@ -761,12 +773,14 @@ datafixerbuilder.addFixer(new DataConverterAddChoices(schema131, "Added Glow Squid", DataConverterTypes.ENTITY)); datafixerbuilder.addFixer(new DataConverterAddChoices(schema131, "Added Glow Item Frame", DataConverterTypes.ENTITY)); Schema schema132 = datafixerbuilder.addSchema(2690, DataConverterRegistry.SAME_NAMESPACED); @@ -36,7 +36,7 @@ datafixerbuilder.addFixer(DataConverterItemName.create(schema133, "Rename copper item suffixes", createRenamer(immutablemap1))); datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema133, "Rename copper blocks suffixes", createRenamer(immutablemap1))); -@@ -769,7 +783,8 @@ +@@ -774,7 +788,8 @@ datafixerbuilder.addFixer(new AddFlagIfNotPresentFix(schema134, DataConverterTypes.WORLD_GEN_SETTINGS, "has_increased_height_already", false)); Schema schema135 = datafixerbuilder.addSchema(2696, DataConverterRegistry.SAME_NAMESPACED); @@ -46,7 +46,7 @@ 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))); -@@ -856,10 +871,11 @@ +@@ -861,10 +876,11 @@ datafixerbuilder.addFixer(new DataConverterAddChoices(schema160, "Added Allay", DataConverterTypes.ENTITY)); Schema schema161 = datafixerbuilder.addSchema(3084, DataConverterRegistry.SAME_NAMESPACED); @@ -60,7 +60,7 @@ int2objectopenhashmap1.defaultReturnValue("minecraft:tabby"); int2objectopenhashmap1.put(0, "minecraft:tabby"); int2objectopenhashmap1.put(1, "minecraft:black"); -@@ -876,7 +892,8 @@ +@@ -881,7 +897,8 @@ Objects.requireNonNull(int2objectopenhashmap); datafixerbuilder.addFixer(new EntityVariantFix(schema162, "Change cat variant type", typereference, "minecraft:cat", "CatType", int2objectopenhashmap::get)); diff --git a/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch b/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch index bd97de7fc..4a3251219 100644 --- a/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch +++ b/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch @@ -1,17 +1,15 @@ --- a/net/minecraft/util/worldupdate/WorldUpgrader.java +++ b/net/minecraft/util/worldupdate/WorldUpgrader.java -@@ -40,6 +40,10 @@ - import net.minecraft.world.level.storage.WorldPersistentData; - import org.slf4j.Logger; - -+// CraftBukkit start -+import net.minecraft.world.level.dimension.WorldDimension; -+// CraftBukkit end -+ - public class WorldUpgrader { - +@@ -48,7 +48,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); -@@ -55,7 +59,7 @@ + private static final ThreadFactory THREAD_FACTORY = (new ThreadFactoryBuilder()).setDaemon(true).build(); + private final IRegistry dimensions; +- private final Set> levels; ++ private final Set> levels; // CraftBukkit + private final boolean eraseCache; + private final Convertable.ConversionSession levelStorage; + private final Thread thread; +@@ -59,14 +59,14 @@ private volatile int totalChunks; private volatile int converted; private volatile int skipped; @@ -20,24 +18,30 @@ private volatile IChatBaseComponent status = IChatBaseComponent.translatable("optimizeWorld.stage.counting"); private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$"); private final WorldPersistentData overworldDataStorage; -@@ -88,13 +92,13 @@ + + public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, IRegistry iregistry, boolean flag) { + this.dimensions = iregistry; +- this.levels = (Set) iregistry.registryKeySet().stream().map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet()); ++ this.levels = (Set) iregistry.registryKeySet().stream().collect(Collectors.toUnmodifiableSet()); // CraftBukkit + this.eraseCache = flag; + this.dataFixer = datafixer; + this.levelStorage = convertable_conversionsession; +@@ -93,12 +93,12 @@ private void work() { this.totalChunks = 0; - Builder, ListIterator> builder = ImmutableMap.builder(); -- ImmutableSet> immutableset = this.worldGenSettings.levels(); + Builder, ListIterator> builder = ImmutableMap.builder(); // CraftBukkit -+ ImmutableSet> immutableset = ImmutableSet.of(levelStorage.dimensionType); // CraftBukkit List list; - for (UnmodifiableIterator unmodifiableiterator = immutableset.iterator(); unmodifiableiterator.hasNext(); this.totalChunks += list.size()) { -- ResourceKey resourcekey = (ResourceKey) unmodifiableiterator.next(); -+ ResourceKey resourcekey = (ResourceKey) unmodifiableiterator.next(); // CraftBukkit + for (Iterator iterator = this.levels.iterator(); iterator.hasNext(); this.totalChunks += list.size()) { +- ResourceKey resourcekey = (ResourceKey) iterator.next(); ++ ResourceKey resourcekey = (ResourceKey) iterator.next(); // CraftBukkit list = this.getAllChunkPos(resourcekey); builder.put(resourcekey, list.listIterator()); -@@ -104,18 +108,18 @@ +@@ -108,18 +108,18 @@ this.finished = true; } else { float f = (float) this.totalChunks; @@ -45,12 +49,12 @@ - Builder, IChunkLoader> builder1 = ImmutableMap.builder(); + ImmutableMap, ListIterator> immutablemap = builder.build(); // CraftBukkit + Builder, IChunkLoader> builder1 = ImmutableMap.builder(); // CraftBukkit - UnmodifiableIterator unmodifiableiterator1 = immutableset.iterator(); + Iterator iterator1 = this.levels.iterator(); - while (unmodifiableiterator1.hasNext()) { -- ResourceKey resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); + while (iterator1.hasNext()) { +- ResourceKey resourcekey1 = (ResourceKey) iterator1.next(); - Path path = this.levelStorage.getDimensionPath(resourcekey1); -+ ResourceKey resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); // CraftBukkit ++ ResourceKey resourcekey1 = (ResourceKey) iterator1.next(); // CraftBukkit + Path path = this.levelStorage.getDimensionPath((ResourceKey) null); // CraftBukkit builder1.put(resourcekey1, new IChunkLoader(path.resolve("region"), this.dataFixer, true)); @@ -61,21 +65,21 @@ long i = SystemUtils.getMillis(); this.status = IChatBaseComponent.translatable("optimizeWorld.stage.upgrading"); -@@ -127,7 +131,7 @@ +@@ -131,7 +131,7 @@ float f2; - for (UnmodifiableIterator unmodifiableiterator2 = immutableset.iterator(); unmodifiableiterator2.hasNext(); f1 += f2) { -- ResourceKey resourcekey2 = (ResourceKey) unmodifiableiterator2.next(); -+ ResourceKey resourcekey2 = (ResourceKey) unmodifiableiterator2.next(); // CraftBukkit + for (Iterator iterator2 = this.levels.iterator(); iterator2.hasNext(); f1 += f2) { +- ResourceKey resourcekey2 = (ResourceKey) iterator2.next(); ++ ResourceKey resourcekey2 = (ResourceKey) iterator2.next(); // CraftBukkit ListIterator listiterator = (ListIterator) immutablemap.get(resourcekey2); IChunkLoader ichunkloader = (IChunkLoader) immutablemap1.get(resourcekey2); -@@ -140,10 +144,10 @@ +@@ -144,10 +144,10 @@ if (nbttagcompound != null) { int j = IChunkLoader.getVersion(nbttagcompound); -- ChunkGenerator chunkgenerator = ((WorldDimension) this.worldGenSettings.dimensions().get(GeneratorSettings.levelToLevelStem(resourcekey2))).generator(); -+ ChunkGenerator chunkgenerator = ((WorldDimension) this.worldGenSettings.dimensions().get(resourcekey2)).generator(); // CraftBukkit +- ChunkGenerator chunkgenerator = ((WorldDimension) this.dimensions.getOrThrow(Registries.levelToLevelStem(resourcekey2))).generator(); ++ ChunkGenerator chunkgenerator = ((WorldDimension) this.dimensions.getOrThrow(resourcekey2)).generator(); // CraftBukkit NBTTagCompound nbttagcompound1 = ichunkloader.upgradeChunkTag(resourcekey2, () -> { return this.overworldDataStorage; - }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer()); @@ -83,7 +87,7 @@ ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos")); if (!chunkcoordintpair1.equals(chunkcoordintpair)) { -@@ -223,8 +227,8 @@ +@@ -227,8 +227,8 @@ } } @@ -94,11 +98,11 @@ File file1 = new File(file, "region"); File[] afile = file1.listFiles((file2, s) -> { return s.endsWith(".mca"); -@@ -284,7 +288,7 @@ +@@ -288,7 +288,7 @@ } - public ImmutableSet> levels() { -- return this.worldGenSettings.levels(); + public Set> levels() { +- return this.levels; + throw new AssertionError("Unsupported"); // CraftBukkit } diff --git a/nms-patches/net/minecraft/world/damagesource/DamageSource.patch b/nms-patches/net/minecraft/world/damagesource/DamageSource.patch index 0d3349504..2923a51f4 100644 --- a/nms-patches/net/minecraft/world/damagesource/DamageSource.patch +++ b/nms-patches/net/minecraft/world/damagesource/DamageSource.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/damagesource/DamageSource.java +++ b/net/minecraft/world/damagesource/DamageSource.java -@@ -52,6 +52,18 @@ +@@ -49,6 +49,18 @@ private boolean isFall; private boolean noAggro; public final String msgId; @@ -17,5 +17,5 @@ + } + // CraftBukkit end - public static DamageSource sting(EntityLiving entityliving) { - return new EntityDamageSource("sting", entityliving); + public static DamageSource fallingBlock(Entity entity) { + return (new EntityDamageSource("fallingBlock", entity)).damageHelmet(); diff --git a/nms-patches/net/minecraft/world/damagesource/EntityDamageSourceIndirect.patch b/nms-patches/net/minecraft/world/damagesource/EntityDamageSourceIndirect.patch index 18403fd1d..f608ea6fd 100644 --- a/nms-patches/net/minecraft/world/damagesource/EntityDamageSourceIndirect.patch +++ b/nms-patches/net/minecraft/world/damagesource/EntityDamageSourceIndirect.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/damagesource/EntityDamageSourceIndirect.java +++ b/net/minecraft/world/damagesource/EntityDamageSourceIndirect.java -@@ -37,4 +37,10 @@ - - return !itemstack.isEmpty() && itemstack.hasCustomHoverName() ? IChatBaseComponent.translatable(s1, entityliving.getDisplayName(), ichatbasecomponent, itemstack.getDisplayName()) : IChatBaseComponent.translatable(s, entityliving.getDisplayName(), ichatbasecomponent); +@@ -53,4 +53,10 @@ + return IChatBaseComponent.translatable(s, entityliving.getDisplayName(), ichatbasecomponent); + } } + + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/effect/MobEffectUtil.patch b/nms-patches/net/minecraft/world/effect/MobEffectUtil.patch index 3b32c30d1..ceca27f2b 100644 --- a/nms-patches/net/minecraft/world/effect/MobEffectUtil.patch +++ b/nms-patches/net/minecraft/world/effect/MobEffectUtil.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/MobEffectUtil.java +++ b/net/minecraft/world/effect/MobEffectUtil.java -@@ -48,13 +48,19 @@ +@@ -44,13 +44,19 @@ } public static List addEffectToPlayersAround(WorldServer worldserver, @Nullable Entity entity, Vec3D vec3d, double d0, MobEffect mobeffect, int i) { diff --git a/nms-patches/net/minecraft/world/effect/MobEffects.patch b/nms-patches/net/minecraft/world/effect/MobEffects.patch index 414f08565..b3af648bb 100644 --- a/nms-patches/net/minecraft/world/effect/MobEffects.patch +++ b/nms-patches/net/minecraft/world/effect/MobEffects.patch @@ -1,17 +1,14 @@ --- a/net/minecraft/world/effect/MobEffects.java +++ b/net/minecraft/world/effect/MobEffects.java -@@ -69,6 +69,14 @@ - return new MobEffect.a(22); - })); - -+ // CraftBukkit start -+ static { -+ for (Object effect : IRegistry.MOB_EFFECT) { -+ org.bukkit.potion.PotionEffectType.registerPotionEffectType(new org.bukkit.craftbukkit.potion.CraftPotionEffectType((MobEffectList) effect)); -+ } -+ } -+ // CraftBukkit end -+ +@@ -73,6 +73,10 @@ public MobEffects() {} private static MobEffectList register(int i, String s, MobEffectList mobeffectlist) { +- return (MobEffectList) IRegistry.registerMapping(BuiltInRegistries.MOB_EFFECT, i, s, mobeffectlist); ++ // CraftBukkit start ++ mobeffectlist = (MobEffectList) IRegistry.registerMapping(BuiltInRegistries.MOB_EFFECT, i, s, mobeffectlist); ++ org.bukkit.potion.PotionEffectType.registerPotionEffectType(new org.bukkit.craftbukkit.potion.CraftPotionEffectType(mobeffectlist)); ++ return mobeffectlist; ++ // CraftBukkit end + } + } diff --git a/nms-patches/net/minecraft/world/entity/Entity.patch b/nms-patches/net/minecraft/world/entity/Entity.patch index 9cd95dada..14de7d95f 100644 --- a/nms-patches/net/minecraft/world/entity/Entity.patch +++ b/nms-patches/net/minecraft/world/entity/Entity.patch @@ -253,7 +253,7 @@ if (this.onGround) { block.stepOn(this.level, blockposition, iblockdata, this); } -@@ -938,6 +1114,20 @@ +@@ -946,6 +1122,20 @@ return SoundEffects.GENERIC_SPLASH; } @@ -273,8 +273,8 @@ + protected void checkInsideBlocks() { AxisAlignedBB axisalignedbb = this.getBoundingBox(); - BlockPosition blockposition = new BlockPosition(axisalignedbb.minX + 0.001D, axisalignedbb.minY + 0.001D, axisalignedbb.minZ + 0.001D); -@@ -1290,6 +1480,7 @@ + BlockPosition blockposition = new BlockPosition(axisalignedbb.minX + 1.0E-7D, axisalignedbb.minY + 1.0E-7D, axisalignedbb.minZ + 1.0E-7D); +@@ -1305,6 +1495,7 @@ this.yo = d1; this.zo = d4; this.setPos(d3, d1, d4); @@ -282,7 +282,7 @@ } public void moveTo(Vec3D vec3d) { -@@ -1480,6 +1671,12 @@ +@@ -1495,6 +1686,12 @@ return false; } @@ -295,7 +295,7 @@ public void awardKillScore(Entity entity, int i, DamageSource damagesource) { if (entity instanceof EntityPlayer) { CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource); -@@ -1513,7 +1710,7 @@ +@@ -1528,7 +1725,7 @@ } else { String s = this.getEncodeId(); @@ -304,7 +304,7 @@ return false; } else { nbttagcompound.putString("id", s); -@@ -1538,6 +1735,18 @@ +@@ -1553,6 +1750,18 @@ Vec3D vec3d = this.getDeltaMovement(); nbttagcompound.put("Motion", this.newDoubleList(vec3d.x, vec3d.y, vec3d.z)); @@ -323,7 +323,7 @@ nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot())); nbttagcompound.putFloat("FallDistance", this.fallDistance); nbttagcompound.putShort("Fire", (short) this.remainingFireTicks); -@@ -1546,6 +1755,22 @@ +@@ -1561,6 +1770,22 @@ nbttagcompound.putBoolean("Invulnerable", this.invulnerable); nbttagcompound.putInt("PortalCooldown", this.portalCooldown); nbttagcompound.putUUID("UUID", this.getUUID()); @@ -346,7 +346,7 @@ IChatBaseComponent ichatbasecomponent = this.getCustomName(); if (ichatbasecomponent != null) { -@@ -1613,6 +1838,11 @@ +@@ -1628,6 +1853,11 @@ } } @@ -358,7 +358,7 @@ return nbttagcompound; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); -@@ -1696,6 +1926,44 @@ +@@ -1711,6 +1941,44 @@ } else { throw new IllegalStateException("Entity has invalid position"); } @@ -403,7 +403,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded"); -@@ -1771,9 +2039,22 @@ +@@ -1786,9 +2054,22 @@ } else if (this.level.isClientSide) { return null; } else { @@ -426,7 +426,7 @@ this.level.addFreshEntity(entityitem); return entityitem; } -@@ -1867,7 +2148,7 @@ +@@ -1882,7 +2163,7 @@ this.setPose(EntityPose.STANDING); this.vehicle = entity; @@ -435,7 +435,7 @@ entity.getIndirectPassengersStream().filter((entity2) -> { return entity2 instanceof EntityPlayer; }).forEach((entity2) -> { -@@ -1898,7 +2179,7 @@ +@@ -1913,7 +2194,7 @@ Entity entity = this.vehicle; this.vehicle = null; @@ -444,7 +444,7 @@ } } -@@ -1907,10 +2188,31 @@ +@@ -1926,10 +2207,31 @@ this.removeVehicle(); } @@ -477,7 +477,7 @@ if (this.passengers.isEmpty()) { this.passengers = ImmutableList.of(entity); } else { -@@ -1926,12 +2228,32 @@ +@@ -1945,12 +2247,32 @@ } } @@ -511,7 +511,7 @@ if (this.passengers.size() == 1 && this.passengers.get(0) == entity) { this.passengers = ImmutableList.of(); } else { -@@ -1942,6 +2264,7 @@ +@@ -1961,6 +2283,7 @@ entity.boardingCooldown = 60; } @@ -519,7 +519,7 @@ } protected boolean canAddPassenger(Entity entity) { -@@ -2004,14 +2327,20 @@ +@@ -2023,14 +2346,20 @@ if (this.isInsidePortal) { MinecraftServer minecraftserver = worldserver.getServer(); @@ -543,7 +543,7 @@ this.level.getProfiler().pop(); } -@@ -2129,6 +2458,13 @@ +@@ -2148,6 +2477,13 @@ } public void setSwimming(boolean flag) { @@ -557,7 +557,7 @@ this.setSharedFlag(4, flag); } -@@ -2174,8 +2510,12 @@ +@@ -2193,8 +2529,12 @@ return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false; } @@ -571,7 +571,7 @@ } public boolean getSharedFlag(int i) { -@@ -2194,7 +2534,7 @@ +@@ -2213,7 +2553,7 @@ } public int getMaxAirSupply() { @@ -580,7 +580,7 @@ } public int getAirSupply() { -@@ -2202,7 +2542,18 @@ +@@ -2221,7 +2561,18 @@ } public void setAirSupply(int i) { @@ -600,7 +600,7 @@ } public int getTicksFrozen() { -@@ -2229,11 +2580,41 @@ +@@ -2248,11 +2599,41 @@ public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -644,7 +644,7 @@ } public void onAboveBubbleCol(boolean flag) { -@@ -2391,15 +2772,38 @@ +@@ -2417,15 +2798,38 @@ @Nullable public Entity changeDimension(WorldServer worldserver) { @@ -685,7 +685,7 @@ this.level.getProfiler().popPush("reloading"); Entity entity = this.getType().create(worldserver); -@@ -2408,9 +2812,17 @@ +@@ -2434,9 +2838,17 @@ entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot()); entity.setDeltaMovement(shapedetectorshape.speed); worldserver.addDuringTeleport(entity); @@ -705,7 +705,7 @@ } this.removeAfterChangingDimensions(); -@@ -2431,20 +2843,34 @@ +@@ -2457,20 +2869,34 @@ @Nullable protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) { @@ -745,18 +745,18 @@ IBlockData iblockdata = this.level.getBlockState(this.portalEntrancePos); EnumDirection.EnumAxis enumdirection_enumaxis; Vec3D vec3d; -@@ -2461,8 +2887,8 @@ +@@ -2487,8 +2913,8 @@ vec3d = new Vec3D(0.5D, 0.0D, 0.0D); } -- return BlockPortalShape.createPortalInfo(worldserver, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.getDimensions(this.getPose()), this.getDeltaMovement(), this.getYRot(), this.getXRot()); +- return BlockPortalShape.createPortalInfo(worldserver, blockutil_rectangle, enumdirection_enumaxis, vec3d, this, this.getDeltaMovement(), this.getYRot(), this.getXRot()); - }).orElse((Object) null); -+ return BlockPortalShape.createPortalInfo(worldserverFinal, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.getDimensions(this.getPose()), this.getDeltaMovement(), this.getYRot(), this.getXRot(), event); // CraftBukkit ++ return BlockPortalShape.createPortalInfo(worldserverFinal, blockutil_rectangle, enumdirection_enumaxis, vec3d, this, this.getDeltaMovement(), this.getYRot(), this.getXRot(), event); // CraftBukkit + }).orElse(null); // CraftBukkit - decompile error } } else { BlockPosition blockposition1; -@@ -2472,8 +2898,14 @@ +@@ -2498,8 +2924,14 @@ } else { blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos()); } @@ -772,7 +772,7 @@ } } -@@ -2481,8 +2913,23 @@ +@@ -2507,8 +2939,23 @@ return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose())); } @@ -798,7 +798,7 @@ } public boolean canChangeDimensions() { -@@ -2691,7 +3138,26 @@ +@@ -2731,7 +3178,26 @@ } public final void setBoundingBox(AxisAlignedBB axisalignedbb) { @@ -826,7 +826,7 @@ } protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) { -@@ -2979,6 +3445,11 @@ +@@ -3023,6 +3489,11 @@ vec3d = vec3d.add(vec3d1); ++k1; } diff --git a/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch b/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch index 3411bd03c..89c29c022 100644 --- a/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch +++ b/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityAreaEffectCloud.java +++ b/net/minecraft/world/entity/EntityAreaEffectCloud.java -@@ -32,6 +32,12 @@ +@@ -31,6 +31,12 @@ import net.minecraft.world.level.material.EnumPistonReaction; import org.slf4j.Logger; @@ -13,7 +13,7 @@ public class EntityAreaEffectCloud extends Entity { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -127,6 +133,22 @@ +@@ -129,6 +135,22 @@ } @@ -25,18 +25,18 @@ + } + + public String getPotionType() { -+ return ((MinecraftKey) IRegistry.POTION.getKey(this.potion)).toString(); ++ return ((MinecraftKey) BuiltInRegistries.POTION.getKey(this.potion)).toString(); + } + + public void setPotionType(String string) { -+ setPotion(IRegistry.POTION.get(new MinecraftKey(string))); ++ setPotion(BuiltInRegistries.POTION.get(new MinecraftKey(string))); + } + // CraftBukkit end + public int getColor() { return (Integer) this.getEntityData().get(EntityAreaEffectCloud.DATA_COLOR); } -@@ -259,6 +281,7 @@ +@@ -261,6 +283,7 @@ if (!list1.isEmpty()) { Iterator iterator1 = list1.iterator(); @@ -44,7 +44,7 @@ while (iterator1.hasNext()) { EntityLiving entityliving = (EntityLiving) iterator1.next(); -@@ -268,6 +291,17 @@ +@@ -270,6 +293,17 @@ double d8 = d6 * d6 + d7 * d7; if (d8 <= (double) (f * f)) { @@ -62,7 +62,7 @@ this.victims.put(entityliving, this.tickCount + this.reapplicationDelay); Iterator iterator2 = list.iterator(); -@@ -277,7 +311,7 @@ +@@ -279,7 +313,7 @@ if (mobeffect1.getEffect().isInstantenous()) { mobeffect1.getEffect().applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D); } else { diff --git a/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch b/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch index bf6cf42bd..d7cbd98e9 100644 --- a/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch +++ b/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 -@@ -20,6 +20,12 @@ +@@ -21,6 +21,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; -@@ -58,6 +64,7 @@ +@@ -59,6 +65,7 @@ @Override public void tick() { super.tick(); @@ -21,7 +21,7 @@ this.xo = this.getX(); this.yo = this.getY(); this.zo = this.getZ(); -@@ -83,7 +90,22 @@ +@@ -84,7 +91,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(); -@@ -226,7 +248,7 @@ +@@ -227,7 +249,7 @@ int i = this.repairPlayerItems(entityhuman, this.value); if (i > 0) { @@ -54,7 +54,7 @@ } --this.count; -@@ -244,9 +266,17 @@ +@@ -245,9 +267,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 { -@@ -271,6 +301,24 @@ +@@ -272,6 +302,24 @@ } public static int getExperienceValue(int i) { diff --git a/nms-patches/net/minecraft/world/entity/EntityInsentient.patch b/nms-patches/net/minecraft/world/entity/EntityInsentient.patch index cdcecb3a1..b2f789f37 100644 --- a/nms-patches/net/minecraft/world/entity/EntityInsentient.patch +++ b/nms-patches/net/minecraft/world/entity/EntityInsentient.patch @@ -135,26 +135,26 @@ } @Override -@@ -577,7 +650,7 @@ +@@ -576,7 +649,7 @@ + protected void pickUpItem(EntityItem entityitem) { ItemStack itemstack = entityitem.getItem(); +- ItemStack itemstack1 = this.equipItemIfPossible(itemstack.copy()); ++ ItemStack itemstack1 = this.equipItemIfPossible(itemstack.copy(), entityitem); // CraftBukkit - add item -- if (this.equipItemIfPossible(itemstack)) { -+ if (this.equipItemIfPossible(itemstack, entityitem)) { // CraftBukkit - add item + if (!itemstack1.isEmpty()) { this.onItemPickup(entityitem); - this.take(entityitem, itemstack.getCount()); - entityitem.discard(); -@@ -586,15 +659,29 @@ +@@ -590,15 +663,29 @@ } - public boolean equipItemIfPossible(ItemStack itemstack) { + public ItemStack equipItemIfPossible(ItemStack itemstack) { + // CraftBukkit start - add item + return this.equipItemIfPossible(itemstack, null); + } + -+ public boolean equipItemIfPossible(ItemStack itemstack, EntityItem entityitem) { ++ public ItemStack equipItemIfPossible(ItemStack itemstack, EntityItem entityitem) { + // CraftBukkit end - EnumItemSlot enumitemslot = getEquipmentSlotForItem(itemstack); + EnumItemSlot enumitemslot = this.getEquipmentSlotForItemStack(itemstack); ItemStack itemstack1 = this.getItemBySlot(enumitemslot); boolean flag = this.canReplaceCurrentItem(itemstack, itemstack1); @@ -174,8 +174,8 @@ + this.forceDrops = false; // CraftBukkit } - this.setItemSlotAndDropWhenKilled(enumitemslot, itemstack); -@@ -732,6 +819,7 @@ + if (enumitemslot.isArmor() && itemstack.getCount() > 1) { +@@ -750,6 +837,7 @@ @Override protected final void serverAiStep() { ++this.noActionTime; @@ -183,7 +183,7 @@ this.level.getProfiler().push("sensing"); this.sensing.tick(); this.level.getProfiler().pop(); -@@ -1125,6 +1213,12 @@ +@@ -1143,6 +1231,12 @@ if (!this.isAlive()) { return EnumInteractionResult.PASS; } else if (this.getLeashHolder() == entityhuman) { @@ -196,7 +196,7 @@ this.dropLeash(true, !entityhuman.getAbilities().instabuild); return EnumInteractionResult.sidedSuccess(this.level.isClientSide); } else { -@@ -1148,6 +1242,12 @@ +@@ -1166,6 +1260,12 @@ ItemStack itemstack = entityhuman.getItemInHand(enumhand); if (itemstack.is(Items.LEAD) && this.canBeLeashed(entityhuman)) { @@ -209,7 +209,7 @@ this.setLeashedTo(entityhuman, true); itemstack.shrink(1); return EnumInteractionResult.sidedSuccess(this.level.isClientSide); -@@ -1163,7 +1263,7 @@ +@@ -1181,7 +1281,7 @@ if (itemstack.getItem() instanceof ItemMonsterEgg) { if (this.level instanceof WorldServer) { ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem(); @@ -218,7 +218,7 @@ optional.ifPresent((entityinsentient) -> { this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient); -@@ -1213,12 +1313,19 @@ +@@ -1231,12 +1331,19 @@ return this.restrictRadius != -1.0F; } @@ -237,23 +237,23 @@ - T t0 = (EntityInsentient) entitytypes.create(this.level); + T t0 = entitytypes.create(this.level); // CraftBukkit - decompile error - t0.copyPosition(this); - t0.setBaby(this.isBaby()); -@@ -1250,7 +1357,12 @@ + if (t0 == null) { + return null; +@@ -1271,7 +1378,12 @@ + } } - } -- this.level.addFreshEntity(t0); -+ // CraftBukkit start -+ if (CraftEventFactory.callEntityTransformEvent(this, t0, transformReason).isCancelled()) { -+ return null; -+ } -+ this.level.addFreshEntity(t0, spawnReason); -+ // CraftBukkit end - if (this.isPassenger()) { - Entity entity = this.getVehicle(); +- this.level.addFreshEntity(t0); ++ // CraftBukkit start ++ if (CraftEventFactory.callEntityTransformEvent(this, t0, transformReason).isCancelled()) { ++ return null; ++ } ++ this.level.addFreshEntity(t0, spawnReason); ++ // CraftBukkit end + if (this.isPassenger()) { + Entity entity = this.getVehicle(); -@@ -1270,6 +1382,7 @@ +@@ -1292,6 +1404,7 @@ if (this.leashHolder != null) { if (!this.isAlive() || !this.leashHolder.isAlive()) { @@ -261,7 +261,7 @@ this.dropLeash(true, true); } -@@ -1281,7 +1394,9 @@ +@@ -1303,7 +1416,9 @@ this.leashHolder = null; this.leashInfoTag = null; if (!this.level.isClientSide && flag1) { @@ -271,7 +271,7 @@ } if (!this.level.isClientSide && flag && this.level instanceof WorldServer) { -@@ -1331,6 +1446,7 @@ +@@ -1353,6 +1468,7 @@ boolean flag1 = super.startRiding(entity, flag); if (flag1 && this.isLeashed()) { @@ -279,7 +279,7 @@ this.dropLeash(true, true); } -@@ -1355,7 +1471,9 @@ +@@ -1377,7 +1493,9 @@ } if (this.tickCount > 100) { @@ -289,7 +289,7 @@ this.leashInfoTag = null; } } -@@ -1432,7 +1550,14 @@ +@@ -1458,7 +1576,14 @@ int i = EnchantmentManager.getFireAspect(this); if (i > 0) { @@ -305,7 +305,7 @@ } boolean flag = entity.hurt(DamageSource.mobAttack(this), f); -@@ -1500,9 +1625,10 @@ +@@ -1532,9 +1657,10 @@ @Override protected void removeAfterChangingDimensions() { super.removeAfterChangingDimensions(); diff --git a/nms-patches/net/minecraft/world/entity/EntityLightning.patch b/nms-patches/net/minecraft/world/entity/EntityLightning.patch index 886ddea34..938e9bebc 100644 --- a/nms-patches/net/minecraft/world/entity/EntityLightning.patch +++ b/nms-patches/net/minecraft/world/entity/EntityLightning.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityLightning.java +++ b/net/minecraft/world/entity/EntityLightning.java -@@ -31,6 +31,10 @@ +@@ -29,6 +29,10 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public class EntityLightning extends Entity { private static final int START_LIFE = 2; -@@ -131,7 +135,7 @@ +@@ -129,7 +133,7 @@ } } @@ -20,7 +20,7 @@ if (!(this.level instanceof WorldServer)) { this.level.setSkyFlashTime(2); } else if (!this.visualOnly) { -@@ -165,8 +169,12 @@ +@@ -163,8 +167,12 @@ IBlockData iblockdata = BlockFireAbstract.getState(this.level, blockposition); if (this.level.getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level, blockposition)) { @@ -35,7 +35,7 @@ } for (int j = 0; j < i; ++j) { -@@ -174,8 +182,12 @@ +@@ -172,8 +180,12 @@ iblockdata = BlockFireAbstract.getState(this.level, blockposition1); if (this.level.getBlockState(blockposition1).isAir() && iblockdata.canSurvive(this.level, blockposition1)) { @@ -50,7 +50,7 @@ } } -@@ -239,8 +251,9 @@ +@@ -237,8 +249,9 @@ iblockdata = world.getBlockState(blockposition1); } while (!(iblockdata.getBlock() instanceof WeatheringCopper)); diff --git a/nms-patches/net/minecraft/world/entity/EntityLiving.patch b/nms-patches/net/minecraft/world/entity/EntityLiving.patch index 2a0c26a7d..69ab093ed 100644 --- a/nms-patches/net/minecraft/world/entity/EntityLiving.patch +++ b/nms-patches/net/minecraft/world/entity/EntityLiving.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityLiving.java +++ b/net/minecraft/world/entity/EntityLiving.java -@@ -118,6 +118,30 @@ +@@ -119,6 +119,30 @@ import net.minecraft.world.scores.ScoreboardTeam; import org.slf4j.Logger; @@ -31,7 +31,7 @@ public abstract class EntityLiving extends Entity { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -228,6 +252,20 @@ +@@ -229,6 +253,20 @@ private float swimAmountO; protected BehaviorController brain; private boolean skipDropExperience; @@ -52,7 +52,7 @@ protected EntityLiving(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -240,7 +278,9 @@ +@@ -241,7 +279,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(); -@@ -307,7 +347,13 @@ +@@ -308,7 +348,13 @@ double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D); int i = (int) (150.0D * d1); @@ -78,7 +78,7 @@ } } -@@ -661,10 +707,16 @@ +@@ -660,10 +706,16 @@ } public void onEquipItem(EnumItemSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1) { @@ -90,13 +90,13 @@ + // CraftBukkit end boolean flag = itemstack1.isEmpty() && itemstack.isEmpty(); - if (!flag && !ItemStack.isSameIgnoreDurability(itemstack, itemstack1) && !this.firstTick) { + if (!flag && !ItemStack.isSame(itemstack, itemstack1) && !this.firstTick) { - if (enumitemslot.getType() == EnumItemSlot.Function.ARMOR) { + if (enumitemslot.getType() == EnumItemSlot.Function.ARMOR && !silent) { // CraftBukkit this.playEquipSound(itemstack1); } -@@ -742,6 +794,17 @@ +@@ -741,6 +793,17 @@ } } @@ -114,7 +114,7 @@ if (nbttagcompound.contains("Health", 99)) { this.setHealth(nbttagcompound.getFloat("Health")); } -@@ -779,9 +842,32 @@ +@@ -778,9 +841,32 @@ } @@ -147,7 +147,7 @@ try { while (iterator.hasNext()) { MobEffectList mobeffectlist = (MobEffectList) iterator.next(); -@@ -791,6 +877,12 @@ +@@ -790,6 +876,12 @@ this.onEffectUpdated(mobeffect, true, (Entity) null); })) { if (!this.level.isClientSide) { @@ -160,7 +160,7 @@ iterator.remove(); this.onEffectRemoved(mobeffect); } -@@ -801,6 +893,17 @@ +@@ -800,6 +892,17 @@ } catch (ConcurrentModificationException concurrentmodificationexception) { ; } @@ -178,7 +178,7 @@ if (this.effectsDirty) { if (!this.level.isClientSide) { -@@ -927,7 +1030,13 @@ +@@ -926,7 +1029,13 @@ this.entityData.set(EntityLiving.DATA_EFFECT_COLOR_ID, 0); } @@ -192,7 +192,7 @@ if (this.level.isClientSide) { return false; } else { -@@ -936,7 +1045,14 @@ +@@ -935,7 +1044,14 @@ boolean flag; for (flag = false; iterator.hasNext(); flag = true) { @@ -208,7 +208,7 @@ iterator.remove(); } -@@ -965,18 +1081,48 @@ +@@ -964,18 +1080,48 @@ return this.addEffect(mobeffect, (Entity) null); } @@ -258,7 +258,7 @@ return true; } else { return false; -@@ -1013,13 +1159,39 @@ +@@ -1012,13 +1158,39 @@ return this.getMobType() == EnumMonsterType.UNDEAD; } @@ -299,7 +299,7 @@ if (mobeffect != null) { this.onEffectRemoved(mobeffect); -@@ -1056,20 +1228,55 @@ +@@ -1055,20 +1227,55 @@ } @@ -356,7 +356,7 @@ this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.clamp(f, 0.0F, this.getMaxHealth())); } -@@ -1083,7 +1290,7 @@ +@@ -1082,7 +1289,7 @@ return false; } else if (this.level.isClientSide) { return false; @@ -365,7 +365,7 @@ return false; } else if (damagesource.isFire() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -1094,10 +1301,11 @@ +@@ -1093,10 +1300,11 @@ this.noActionTime = 0; float f1 = f; @@ -379,7 +379,7 @@ this.hurtCurrentlyUsedShield(f); f2 = f; f = 0.0F; -@@ -1115,27 +1323,46 @@ +@@ -1116,27 +1324,46 @@ this.animationSpeed = 1.5F; boolean flag1 = true; @@ -431,7 +431,7 @@ this.hurtDir = 0.0F; Entity entity1 = damagesource.getEntity(); -@@ -1258,19 +1485,32 @@ +@@ -1259,19 +1486,32 @@ EnumHand[] aenumhand = EnumHand.values(); int i = aenumhand.length; @@ -468,7 +468,7 @@ EntityPlayer entityplayer = (EntityPlayer) this; entityplayer.awardStat(StatisticList.ITEM_USED.get(Items.TOTEM_OF_UNDYING)); -@@ -1278,14 +1518,16 @@ +@@ -1279,14 +1519,16 @@ } this.setHealth(1.0F); @@ -490,7 +490,7 @@ } } -@@ -1390,14 +1632,22 @@ +@@ -1391,14 +1633,22 @@ IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState(); if (this.level.getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level, blockposition)) { @@ -515,7 +515,7 @@ this.level.addFreshEntity(entityitem); } } -@@ -1417,21 +1667,40 @@ +@@ -1418,21 +1668,40 @@ boolean flag = this.lastHurtByPlayerTime > 0; @@ -559,7 +559,7 @@ } -@@ -1504,6 +1773,28 @@ +@@ -1517,6 +1786,28 @@ return itemstack.getEatingSound(); } @@ -588,7 +588,7 @@ @Override public void setOnGround(boolean flag) { super.setOnGround(flag); -@@ -1559,9 +1850,14 @@ +@@ -1572,9 +1863,14 @@ int i = this.calculateFallDamage(f, f1); if (i > 0) { @@ -604,7 +604,7 @@ return true; } else { return flag; -@@ -1610,7 +1906,7 @@ +@@ -1623,7 +1919,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) { if (!damagesource.isBypassArmor()) { @@ -613,7 +613,7 @@ f = CombatMath.getDamageAfterAbsorb(f, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS)); } -@@ -1623,7 +1919,8 @@ +@@ -1636,7 +1932,8 @@ } else { int i; @@ -623,7 +623,7 @@ i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f1 = f * (float) j; -@@ -1656,29 +1953,172 @@ +@@ -1669,29 +1966,172 @@ } } @@ -806,7 +806,7 @@ } public CombatTracker getCombatTracker() { -@@ -1699,9 +2139,19 @@ +@@ -1712,9 +2152,19 @@ } public final void setArrowCount(int i) { @@ -827,7 +827,7 @@ public final int getStingerCount() { return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID); } -@@ -1996,6 +2446,12 @@ +@@ -2017,6 +2467,12 @@ public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot); @@ -840,7 +840,7 @@ @Override public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack); -@@ -2239,6 +2695,7 @@ +@@ -2256,6 +2712,7 @@ } if (this.onGround && !this.level.isClientSide) { @@ -848,7 +848,7 @@ this.setSharedFlag(7, false); } } else { -@@ -2772,6 +3229,7 @@ +@@ -2793,6 +3250,7 @@ } if (!this.level.isClientSide) { @@ -856,7 +856,7 @@ this.setSharedFlag(7, flag); } -@@ -2931,14 +3389,21 @@ +@@ -2956,14 +3414,21 @@ @Override public boolean isPickable() { @@ -880,7 +880,7 @@ @Override public float getYHeadRot() { return this.yHeadRot; -@@ -3133,7 +3598,26 @@ +@@ -3158,7 +3623,26 @@ } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { this.triggerItemUseEffects(this.useItem, 16); @@ -908,7 +908,7 @@ if (itemstack != this.useItem) { this.setItemInHand(enumhand, itemstack); -@@ -3211,6 +3695,12 @@ +@@ -3236,6 +3720,12 @@ } public boolean randomTeleport(double d0, double d1, double d2, boolean flag) { @@ -921,7 +921,7 @@ double d3 = this.getX(); double d4 = this.getY(); double d5 = this.getZ(); -@@ -3235,16 +3725,41 @@ +@@ -3260,16 +3750,41 @@ } if (flag2) { @@ -966,7 +966,7 @@ } else { if (flag) { world.broadcastEntityEvent(this, (byte) 46); -@@ -3254,7 +3769,7 @@ +@@ -3279,7 +3794,7 @@ ((EntityCreature) this).getNavigation().stop(); } @@ -975,7 +975,7 @@ } } -@@ -3337,7 +3852,7 @@ +@@ -3357,7 +3872,7 @@ } public void stopSleeping() { @@ -984,7 +984,7 @@ World world = this.level; java.util.Objects.requireNonNull(this.level); -@@ -3369,7 +3884,7 @@ +@@ -3391,7 +3906,7 @@ @Nullable public EnumDirection getBedOrientation() { @@ -993,7 +993,7 @@ return blockposition != null ? BlockBed.getBedOrientation(this.level, blockposition) : null; } -@@ -3417,7 +3932,7 @@ +@@ -3439,7 +3954,7 @@ Pair pair = (Pair) iterator.next(); if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) { diff --git a/nms-patches/net/minecraft/world/entity/EntityTypes.patch b/nms-patches/net/minecraft/world/entity/EntityTypes.patch index 46f0566c3..bfd56ba27 100644 --- a/nms-patches/net/minecraft/world/entity/EntityTypes.patch +++ b/nms-patches/net/minecraft/world/entity/EntityTypes.patch @@ -1,6 +1,14 @@ --- a/net/minecraft/world/entity/EntityTypes.java +++ b/net/minecraft/world/entity/EntityTypes.java -@@ -159,7 +159,7 @@ +@@ -156,6 +156,7 @@ + import net.minecraft.world.phys.AxisAlignedBB; + import net.minecraft.world.phys.shapes.VoxelShape; + import net.minecraft.world.phys.shapes.VoxelShapes; ++import org.bukkit.event.entity.CreatureSpawnEvent; + import org.slf4j.Logger; + + public class EntityTypes implements FeatureElement, EntityTypeTest { +@@ -165,7 +166,7 @@ private final Holder.c> builtInRegistryHolder; private static final float MAGIC_HORSE_WIDTH = 1.3964844F; public static final EntityTypes ALLAY = register("allay", EntityTypes.Builder.of(Allay::new, EnumCreatureType.CREATURE).sized(0.35F, 0.6F).clientTrackingRange(8).updateInterval(2)); @@ -9,28 +17,66 @@ 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)); -@@ -293,8 +293,8 @@ - private MinecraftKey lootTable; +@@ -301,8 +302,8 @@ private final EntitySize dimensions; + private final FeatureFlagSet requiredFeatures; - private static EntityTypes register(String s, EntityTypes.Builder entitytypes_builder) { -- return (EntityTypes) IRegistry.register(IRegistry.ENTITY_TYPE, s, entitytypes_builder.build(s)); +- return (EntityTypes) IRegistry.register(BuiltInRegistries.ENTITY_TYPE, s, entitytypes_builder.build(s)); + private static EntityTypes register(String s, EntityTypes.Builder entitytypes_builder) { // CraftBukkit - decompile error -+ return (EntityTypes) IRegistry.register(IRegistry.ENTITY_TYPE, s, (EntityTypes) entitytypes_builder.build(s)); // CraftBukkit - decompile error ++ return (EntityTypes) IRegistry.register(BuiltInRegistries.ENTITY_TYPE, s, (EntityTypes) entitytypes_builder.build(s)); // CraftBukkit - decompile error } public static MinecraftKey getKey(EntityTypes entitytypes) { -@@ -326,10 +326,18 @@ +@@ -330,8 +331,15 @@ @Nullable - public T spawn(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) { + public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) { + // CraftBukkit start -+ return this.spawn(worldserver, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); ++ return this.spawn(worldserver, itemstack, entityhuman, blockposition, enummobspawn, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); + } + + @Nullable -+ public T spawn(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { - T t0 = this.create(worldserver, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1); ++ public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { ++ // CraftBukkit end + NBTTagCompound nbttagcompound; +- Consumer consumer; ++ Consumer consumer; // CraftBukkit - decompile error + + if (itemstack != null) { + nbttagcompound = itemstack.getTag(); +@@ -363,21 +371,37 @@ + NBTTagCompound nbttagcompound = itemstack.getTag(); + + return nbttagcompound != null ? consumer.andThen((entity) -> { +- updateCustomEntityTag(worldserver, entityhuman, entity, nbttagcompound); ++ try { updateCustomEntityTag(worldserver, entityhuman, entity, nbttagcompound); } catch (Throwable t) { LOGGER.warn("Error loading spawn egg NBT", t); } // CraftBukkit - SPIGOT-5665 + }) : consumer; + } + + @Nullable + public T spawn(WorldServer worldserver, BlockPosition blockposition, EnumMobSpawn enummobspawn) { +- return this.spawn(worldserver, (NBTTagCompound) null, (Consumer) null, blockposition, enummobspawn, false, false); ++ // CraftBukkit start ++ return this.spawn(worldserver, blockposition, enummobspawn, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); ++ } ++ ++ @Nullable ++ public T spawn(WorldServer worldserver, BlockPosition blockposition, EnumMobSpawn enummobspawn, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { ++ return this.spawn(worldserver, (NBTTagCompound) null, null, blockposition, enummobspawn, false, false, spawnReason); // CraftBukkit - decompile error ++ // CraftBukkit end + } + + @Nullable + public T spawn(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable Consumer consumer, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) { ++ // CraftBukkit start ++ return this.spawn(worldserver, nbttagcompound, consumer, blockposition, enummobspawn, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); ++ } ++ ++ @Nullable ++ public T spawn(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable Consumer consumer, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { ++ // CraftBukkit end + T t0 = this.create(worldserver, nbttagcompound, consumer, blockposition, enummobspawn, flag, flag1); if (t0 != null) { - worldserver.addFreshEntityWithPassengers(t0); @@ -40,16 +86,7 @@ } return t0; -@@ -365,7 +373,7 @@ - t0.setCustomName(ichatbasecomponent); - } - -- updateCustomEntityTag(worldserver, entityhuman, t0, nbttagcompound); -+ try { updateCustomEntityTag(worldserver, entityhuman, t0, nbttagcompound); } catch (Throwable t) { LOGGER.warn("Error loading spawn egg NBT", t); } // CraftBukkit - SPIGOT-5665 - return t0; - } - } -@@ -512,7 +520,7 @@ +@@ -564,7 +588,7 @@ } return entity; @@ -58,7 +95,7 @@ } public static Stream loadEntitiesRecursive(final List list, final World world) { -@@ -569,7 +577,7 @@ +@@ -621,7 +645,7 @@ @Nullable public T tryCast(Entity entity) { @@ -67,7 +104,7 @@ } @Override -@@ -602,7 +610,7 @@ +@@ -656,7 +680,7 @@ this.canSpawnFarFromPlayer = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC; } diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.patch index cda0a9bf4..207170382 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.java -@@ -10,6 +10,12 @@ +@@ -8,6 +8,12 @@ + import net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder; import net.minecraft.world.entity.ai.memory.MemoryModuleType; - import net.minecraft.world.entity.ai.memory.MemoryStatus; +// CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftLivingEntity; @@ -10,24 +10,25 @@ +import org.bukkit.event.entity.EntityTargetEvent; +// CraftBukkit end + - public class BehaviorAttackTargetForget extends Behavior { + public class BehaviorAttackTargetForget { private static final int TIMEOUT_TO_GET_WITHIN_ATTACK_RANGE = 200; -@@ -83,6 +89,17 @@ - } - - protected void clearAttackTarget(E e0) { -+ // CraftBukkit start -+ EntityLiving old = e0.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null); -+ EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(e0, null, (old != null && !old.isAlive()) ? EntityTargetEvent.TargetReason.TARGET_DIED : EntityTargetEvent.TargetReason.FORGOT_TARGET); -+ if (event.isCancelled()) { -+ return; -+ } -+ if (event.getTarget() != null) { -+ e0.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, ((CraftLivingEntity) event.getTarget()).getHandle()); -+ return; -+ } -+ // CraftBukkit end - this.onTargetErased.accept(e0, this.getAttackTarget(e0)); - e0.getBrain().eraseMemory(MemoryModuleType.ATTACK_TARGET); - } +@@ -41,6 +47,18 @@ + if (entityinsentient.canAttack(entityliving) && (!flag || !isTiredOfTryingToReachTarget(entityinsentient, behaviorbuilder_b.tryGet(memoryaccessor1))) && entityliving.isAlive() && entityliving.level == entityinsentient.level && !predicate.test(entityliving)) { + return true; + } else { ++ // CraftBukkit start ++ EntityLiving old = entityinsentient.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null); ++ EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(entityinsentient, null, (old != null && !old.isAlive()) ? EntityTargetEvent.TargetReason.TARGET_DIED : EntityTargetEvent.TargetReason.FORGOT_TARGET); ++ if (event.isCancelled()) { ++ return false; ++ } ++ if (event.getTarget() == null) { ++ memoryaccessor.erase(); ++ return true; ++ } ++ entityliving = ((CraftLivingEntity) event.getTarget()).getHandle(); ++ // CraftBukkit end + biconsumer.accept(entityinsentient, entityliving); + memoryaccessor.erase(); + return true; diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.patch index 9a64b9c24..774133bc5 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.java -@@ -10,6 +10,13 @@ +@@ -8,6 +8,13 @@ + import net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder; import net.minecraft.world.entity.ai.memory.MemoryModuleType; - import net.minecraft.world.entity.ai.memory.MemoryStatus; +// CraftBukkit start +import net.minecraft.server.level.EntityPlayer; @@ -11,30 +11,24 @@ +import org.bukkit.event.entity.EntityTargetEvent; +// CraftBukkit end + - public class BehaviorAttackTargetSet extends Behavior { + public class BehaviorAttackTargetSet { - private final Predicate canAttackPredicate; -@@ -42,13 +49,21 @@ - } - - protected void start(WorldServer worldserver, E e0, long i) { -- ((Optional) this.targetFinderFunction.apply(e0)).ifPresent((entityliving) -> { -+ (this.targetFinderFunction.apply(e0)).ifPresent((entityliving) -> { // CraftBukkit - decompile error - setAttackTarget(e0, entityliving); - }); - } - - public static void setAttackTarget(E e0, EntityLiving entityliving) { -- e0.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, (Object) entityliving); -+ // CraftBukkit start -+ EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(e0, entityliving, (entityliving instanceof EntityPlayer) ? EntityTargetEvent.TargetReason.CLOSEST_PLAYER : EntityTargetEvent.TargetReason.CLOSEST_ENTITY); -+ if (event.isCancelled()) { -+ return; -+ } -+ entityliving = (event.getTarget() != null) ? ((CraftLivingEntity) event.getTarget()).getHandle() : null; -+ // CraftBukkit end -+ -+ e0.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, entityliving); // CraftBukkit - decompile error - e0.getBrain().eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); - } - } + public BehaviorAttackTargetSet() {} +@@ -35,6 +42,17 @@ + if (!entityinsentient.canAttack(entityliving)) { + return false; + } else { ++ // CraftBukkit start ++ EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(entityinsentient, entityliving, (entityliving instanceof EntityPlayer) ? EntityTargetEvent.TargetReason.CLOSEST_PLAYER : EntityTargetEvent.TargetReason.CLOSEST_ENTITY); ++ if (event.isCancelled()) { ++ return false; ++ } ++ if (event.getTarget() == null) { ++ memoryaccessor.erase(); ++ return true; ++ } ++ entityliving = ((CraftLivingEntity) event.getTarget()).getHandle(); ++ // CraftBukkit end + memoryaccessor.set(entityliving); + memoryaccessor1.erase(); + return true; diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorCareer.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorCareer.patch index de2d1efd7..da83bdcf6 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorCareer.patch +++ b/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 -@@ -12,6 +12,12 @@ +@@ -9,6 +9,12 @@ import net.minecraft.world.entity.npc.EntityVillager; import net.minecraft.world.entity.npc.VillagerProfession; @@ -10,31 +10,22 @@ +import org.bukkit.event.entity.VillagerCareerChangeEvent; +// CraftBukkit end + - public class BehaviorCareer extends Behavior { + public class BehaviorCareer { - public BehaviorCareer() { -@@ -28,7 +34,7 @@ - GlobalPos globalpos = (GlobalPos) entityvillager.getBrain().getMemory(MemoryModuleType.POTENTIAL_JOB_SITE).get(); - - entityvillager.getBrain().eraseMemory(MemoryModuleType.POTENTIAL_JOB_SITE); -- entityvillager.getBrain().setMemory(MemoryModuleType.JOB_SITE, (Object) globalpos); -+ entityvillager.getBrain().setMemory(MemoryModuleType.JOB_SITE, globalpos); // CraftBukkit - decompile error - worldserver.broadcastEntityEvent(entityvillager, (byte) 14); - if (entityvillager.getVillagerData().getProfession() == VillagerProfession.NONE) { - MinecraftServer minecraftserver = worldserver.getServer(); -@@ -40,7 +46,14 @@ - return villagerprofession.heldJobSite().test(holder); - }).findFirst(); - }).ifPresent((villagerprofession) -> { -- entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(villagerprofession)); -+ // CraftBukkit start - Fire VillagerCareerChangeEvent where Villager gets employed -+ VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.nmsToBukkitProfession(villagerprofession), VillagerCareerChangeEvent.ChangeReason.EMPLOYED); -+ if (event.isCancelled()) { -+ return; -+ } + public BehaviorCareer() {} +@@ -37,7 +43,14 @@ + return villagerprofession.heldJobSite().test(holder); + }).findFirst(); + }).ifPresent((villagerprofession) -> { +- entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(villagerprofession)); ++ // CraftBukkit start - Fire VillagerCareerChangeEvent where Villager gets employed ++ VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.nmsToBukkitProfession(villagerprofession), VillagerCareerChangeEvent.ChangeReason.EMPLOYED); ++ if (event.isCancelled()) { ++ return; ++ } + -+ entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(CraftVillager.bukkitToNmsProfession(event.getProfession()))); -+ // CraftBukkit end - entityvillager.refreshBrain(worldserver); - }); - } ++ entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(CraftVillager.bukkitToNmsProfession(event.getProfession()))); ++ // CraftBukkit end + entityvillager.refreshBrain(worldserver); + }); + return true; diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFindAdmirableItem.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFindAdmirableItem.patch index 11c605563..76c9978ab 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFindAdmirableItem.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFindAdmirableItem.patch @@ -1,28 +1,23 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorFindAdmirableItem.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorFindAdmirableItem.java -@@ -35,6 +35,25 @@ +@@ -28,6 +28,20 @@ + EntityItem entityitem = (EntityItem) behaviorbuilder_b.get(memoryaccessor2); - @Override - protected void start(WorldServer worldserver, E e0, long i) { -+ // CraftBukkit start -+ if (e0 instanceof net.minecraft.world.entity.animal.allay.Allay) { -+ Entity target = this.getClosestLovedItem(e0); -+ org.bukkit.event.entity.EntityTargetEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(e0, target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY); + if (behaviorbuilder_b.tryGet(memoryaccessor3).isEmpty() && predicate.test(entityliving) && entityitem.closerThan(entityliving, (double) i) && entityliving.level.getWorldBorder().isWithinBounds(entityitem.blockPosition())) { ++ // CraftBukkit start ++ if (entityliving instanceof net.minecraft.world.entity.animal.allay.Allay) { ++ org.bukkit.event.entity.EntityTargetEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(entityliving, entityitem, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY); + -+ if (event.isCancelled()) { -+ return; -+ } ++ if (event.isCancelled()) { ++ return false; ++ } ++ if (!(event.getTarget() instanceof EntityItem)) { ++ memoryaccessor2.erase(); ++ } + -+ target = (event.getTarget() == null) ? null : ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle(); -+ if (target instanceof EntityItem item) { -+ e0.getBrain().setMemory(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, java.util.Optional.of(item)); -+ BehaviorUtil.setWalkAndLookTargetMemories(e0, target, this.speedModifier, 0); -+ } else { -+ e0.getBrain().eraseMemory(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM); -+ } -+ return; -+ } -+ // CraftBukkit end - BehaviorUtil.setWalkAndLookTargetMemories(e0, (Entity) this.getClosestLovedItem(e0), this.speedModifier, 0); - } ++ entityitem = (EntityItem) ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle(); ++ } ++ // CraftBukkit end + MemoryTarget memorytarget = new MemoryTarget(new BehaviorPositionEntity(entityitem, false), f, 0); + memoryaccessor.set(new BehaviorPositionEntity(entityitem, true)); diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFollowAdult.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFollowAdult.patch index 5059baa3d..fd374d374 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFollowAdult.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFollowAdult.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorFollowAdult.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorFollowAdult.java -@@ -10,6 +10,13 @@ +@@ -8,6 +8,13 @@ import net.minecraft.world.entity.ai.memory.MemoryModuleType; - import net.minecraft.world.entity.ai.memory.MemoryStatus; + import net.minecraft.world.entity.ai.memory.MemoryTarget; +// CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftLivingEntity; @@ -11,25 +11,28 @@ +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +// CraftBukkit end + - public class BehaviorFollowAdult extends Behavior { + public class BehaviorFollowAdult { - private final UniformInt followRange; -@@ -38,7 +45,17 @@ - } + public BehaviorFollowAdult() {} +@@ -25,9 +32,20 @@ + if (!entityageable.isBaby()) { + return false; + } else { +- EntityAgeable entityageable1 = (EntityAgeable) behaviorbuilder_b.get(memoryaccessor); ++ EntityLiving entityageable1 = (EntityAgeable) behaviorbuilder_b.get(memoryaccessor); // CraftBukkit - type - protected void start(WorldServer worldserver, E e0, long i) { -- BehaviorUtil.setWalkAndLookTargetMemories(e0, (Entity) this.getNearestAdult(e0), (Float) this.speedModifier.apply(e0), this.followRange.getMinValue() - 1); -+ // CraftBukkit start -+ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(e0, this.getNearestAdult(e0), EntityTargetEvent.TargetReason.FOLLOW_LEADER); -+ if (event.isCancelled()) { -+ return; -+ } -+ if (event.getTarget() != null) { -+ BehaviorUtil.setWalkAndLookTargetMemories(e0, ((CraftLivingEntity) event.getTarget()).getHandle(), this.speedModifier.apply(e0), this.followRange.getMinValue() - 1); -+ } else { -+ e0.getBrain().eraseMemory(MemoryModuleType.NEAREST_VISIBLE_ADULT); -+ } -+ // CraftBukkit end - } + if (entityageable.closerThan(entityageable1, (double) (uniformint.getMaxValue() + 1)) && !entityageable.closerThan(entityageable1, (double) uniformint.getMinValue())) { ++ // CraftBukkit start ++ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(entityageable, entityageable1, EntityTargetEvent.TargetReason.FOLLOW_LEADER); ++ if (event.isCancelled()) { ++ return false; ++ } ++ if (event.getTarget() == null) { ++ memoryaccessor.erase(); ++ return true; ++ } ++ entityageable1 = ((CraftLivingEntity) event.getTarget()).getHandle(); ++ // CraftBukkit end + MemoryTarget memorytarget = new MemoryTarget(new BehaviorPositionEntity(entityageable1, false), (Float) function.apply(entityageable), uniformint.getMinValue() - 1); - private EntityAgeable getNearestAdult(E e0) { + memoryaccessor1.set(new BehaviorPositionEntity(entityageable1, true)); diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.patch index 07d0bf161..640dfea90 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.patch @@ -1,48 +1,39 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorInteractDoor.java -@@ -69,6 +69,13 @@ - BlockDoor blockdoor = (BlockDoor) iblockdata.getBlock(); +@@ -61,6 +61,13 @@ + BlockDoor blockdoor = (BlockDoor) iblockdata.getBlock(); - if (!blockdoor.isOpen(iblockdata)) { -+ // CraftBukkit start - entities opening doors -+ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entityliving.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(entityliving.level, blockposition)); -+ entityliving.level.getCraftServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - blockdoor.setOpen(entityliving, worldserver, iblockdata, blockposition, true); - } + if (!blockdoor.isOpen(iblockdata)) { ++ // CraftBukkit start - entities opening doors ++ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entityliving.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(entityliving.level, blockposition)); ++ entityliving.level.getCraftServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ return false; ++ } ++ // CraftBukkit end + blockdoor.setOpen(entityliving, worldserver, iblockdata, blockposition, true); + } -@@ -84,6 +91,13 @@ - BlockDoor blockdoor1 = (BlockDoor) iblockdata1.getBlock(); +@@ -76,6 +83,13 @@ + BlockDoor blockdoor1 = (BlockDoor) iblockdata1.getBlock(); - if (!blockdoor1.isOpen(iblockdata1)) { -+ // CraftBukkit start - entities opening doors -+ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entityliving.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(entityliving.level, blockposition1)); -+ entityliving.level.getCraftServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - blockdoor1.setOpen(entityliving, worldserver, iblockdata1, blockposition1, true); - this.rememberDoorToClose(worldserver, entityliving, blockposition1); - } -@@ -134,7 +148,7 @@ - private static boolean areOtherMobsComingThroughDoor(WorldServer worldserver, EntityLiving entityliving, BlockPosition blockposition) { - BehaviorController behaviorcontroller = entityliving.getBrain(); + if (!blockdoor1.isOpen(iblockdata1)) { ++ // CraftBukkit start - entities opening doors ++ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entityliving.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(entityliving.level, blockposition1)); ++ entityliving.level.getCraftServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ return false; ++ } ++ // CraftBukkit end + blockdoor1.setOpen(entityliving, worldserver, iblockdata1, blockposition1, true); + optional = rememberDoorToClose(memoryaccessor1, optional, worldserver, blockposition1); + } +@@ -129,7 +143,7 @@ + } -- return !behaviorcontroller.hasMemoryValue(MemoryModuleType.NEAREST_LIVING_ENTITIES) ? false : ((List) behaviorcontroller.getMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES).get()).stream().filter((entityliving1) -> { -+ return !behaviorcontroller.hasMemoryValue(MemoryModuleType.NEAREST_LIVING_ENTITIES) ? false : (behaviorcontroller.getMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES).get()).stream().filter((entityliving1) -> { // CraftBukkit - decompile error + private static boolean areOtherMobsComingThroughDoor(EntityLiving entityliving, BlockPosition blockposition, Optional> optional) { +- return optional.isEmpty() ? false : ((List) optional.get()).stream().filter((entityliving1) -> { ++ return optional.isEmpty() ? false : (optional.get()).stream().filter((entityliving1) -> { // CraftBukkit - decompile error return entityliving1.getType() == entityliving.getType(); }).filter((entityliving1) -> { 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 { -- behaviorcontroller.setMemory(MemoryModuleType.DOORS_TO_CLOSE, (Object) Sets.newHashSet(new GlobalPos[]{globalpos})); -+ behaviorcontroller.setMemory(MemoryModuleType.DOORS_TO_CLOSE, Sets.newHashSet(new GlobalPos[]{globalpos})); // CraftBukkit - decompile error - } - - } diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorProfession.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorProfession.patch index 0c286d793..ba56da049 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorProfession.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorProfession.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorProfession.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorProfession.java -@@ -8,6 +8,12 @@ +@@ -6,6 +6,12 @@ import net.minecraft.world.entity.npc.VillagerData; import net.minecraft.world.entity.npc.VillagerProfession; @@ -10,22 +10,22 @@ +import org.bukkit.event.entity.VillagerCareerChangeEvent; +// CraftBukkit end + - public class BehaviorProfession extends Behavior { + public class BehaviorProfession { - public BehaviorProfession() { -@@ -21,7 +27,14 @@ - } + public BehaviorProfession() {} +@@ -17,7 +23,14 @@ + VillagerData villagerdata = entityvillager.getVillagerData(); - protected void start(WorldServer worldserver, EntityVillager entityvillager, long i) { -- entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(VillagerProfession.NONE)); -+ // CraftBukkit start -+ VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.nmsToBukkitProfession(VillagerProfession.NONE), VillagerCareerChangeEvent.ChangeReason.LOSING_JOB); -+ if (event.isCancelled()) { -+ return; -+ } + if (villagerdata.getProfession() != VillagerProfession.NONE && villagerdata.getProfession() != VillagerProfession.NITWIT && entityvillager.getVillagerXp() == 0 && villagerdata.getLevel() <= 1) { +- entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(VillagerProfession.NONE)); ++ // CraftBukkit start ++ VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.nmsToBukkitProfession(VillagerProfession.NONE), VillagerCareerChangeEvent.ChangeReason.LOSING_JOB); ++ if (event.isCancelled()) { ++ return false; ++ } + -+ entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(CraftVillager.bukkitToNmsProfession(event.getProfession()))); -+ // CraftBukkit end - entityvillager.refreshBrain(worldserver); - } - } ++ entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(CraftVillager.bukkitToNmsProfession(event.getProfession()))); ++ // CraftBukkit end + entityvillager.refreshBrain(worldserver); + return true; + } else { diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorUtil.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorUtil.patch index 19e9e37d3..08d5c7778 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorUtil.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorUtil.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorUtil.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorUtil.java -@@ -61,7 +61,7 @@ +@@ -60,7 +60,7 @@ } public static void lookAtEntity(EntityLiving entityliving, EntityLiving entityliving1) { @@ -9,7 +9,7 @@ } private static void setWalkAndLookTargetMemoriesToEachOther(EntityLiving entityliving, EntityLiving entityliving1, float f) { -@@ -82,8 +82,8 @@ +@@ -81,8 +81,8 @@ public static void setWalkAndLookTargetMemories(EntityLiving entityliving, BehaviorPosition behaviorposition, float f, int i) { MemoryTarget memorytarget = new MemoryTarget(behaviorposition, f, i); @@ -20,7 +20,7 @@ } public static void throwItem(EntityLiving entityliving, ItemStack itemstack, Vec3D vec3d) { -@@ -93,6 +93,7 @@ +@@ -92,6 +92,7 @@ } public static void throwItem(EntityLiving entityliving, ItemStack itemstack, Vec3D vec3d, Vec3D vec3d1, float f) { @@ -28,7 +28,7 @@ double d0 = entityliving.getEyeY() - (double) f; EntityItem entityitem = new EntityItem(entityliving.level, entityliving.getX(), d0, entityliving.getZ(), itemstack); -@@ -102,12 +103,19 @@ +@@ -101,12 +102,19 @@ vec3d2 = vec3d2.normalize().multiply(vec3d1.x, vec3d1.y, vec3d1.z); entityitem.setDeltaMovement(vec3d2); entityitem.setDefaultPickUpDelay(); diff --git a/nms-patches/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.patch b/nms-patches/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.patch index 34dff9110..904dd8f58 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.patch @@ -40,7 +40,7 @@ @@ -82,8 +96,8 @@ protected void tick(WorldServer worldserver, E e0, long i) { - if (this.ramCandidate.isPresent()) { + if (!this.ramCandidate.isEmpty()) { - e0.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(((PrepareRamNearestTarget.a) this.ramCandidate.get()).getStartPosition(), this.walkSpeed, 0))); - e0.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorPositionEntity(((PrepareRamNearestTarget.a) this.ramCandidate.get()).getTarget(), true))); + e0.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(((PrepareRamNearestTarget.a) this.ramCandidate.get()).getStartPosition(), this.walkSpeed, 0))); // CraftBukkit - decompile error @@ -54,7 +54,7 @@ if (i - (Long) this.reachedRamPositionTimestamp.get() >= (long) this.ramPrepareTime) { - e0.getBrain().setMemory(MemoryModuleType.RAM_TARGET, (Object) this.getEdgeOfBlock(blockposition, ((PrepareRamNearestTarget.a) this.ramCandidate.get()).getTargetPosition())); + e0.getBrain().setMemory(MemoryModuleType.RAM_TARGET, this.getEdgeOfBlock(blockposition, ((PrepareRamNearestTarget.a) this.ramCandidate.get()).getTargetPosition())); // CraftBukkit - decompile error - worldserver.playSound((EntityHuman) null, (Entity) e0, (SoundEffect) this.getPrepareRamSound.apply(e0), SoundCategory.HOSTILE, 1.0F, e0.getVoicePitch()); + worldserver.playSound((EntityHuman) null, (Entity) e0, (SoundEffect) this.getPrepareRamSound.apply(e0), SoundCategory.NEUTRAL, 1.0F, e0.getVoicePitch()); this.ramCandidate = Optional.empty(); } @@ -152,7 +166,7 @@ diff --git a/nms-patches/net/minecraft/world/entity/ai/sensing/TemptingSensor.patch b/nms-patches/net/minecraft/world/entity/ai/sensing/TemptingSensor.patch index 7d4dc6e14..414d830b7 100644 --- a/nms-patches/net/minecraft/world/entity/ai/sensing/TemptingSensor.patch +++ b/nms-patches/net/minecraft/world/entity/ai/sensing/TemptingSensor.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/sensing/TemptingSensor.java +++ b/net/minecraft/world/entity/ai/sensing/TemptingSensor.java -@@ -17,6 +17,14 @@ +@@ -18,6 +18,14 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeItemStack; @@ -15,7 +15,7 @@ public class TemptingSensor extends Sensor { public static final int TEMPTATION_RANGE = 10; -@@ -29,7 +37,7 @@ +@@ -30,7 +38,7 @@ protected void doTick(WorldServer worldserver, EntityCreature entitycreature) { BehaviorController behaviorcontroller = entitycreature.getBrain(); @@ -24,7 +24,7 @@ return TemptingSensor.TEMPT_TARGETING.test(entitycreature, entityplayer); }).filter((entityplayer) -> { return entitycreature.closerThan(entityplayer, 10.0D); -@@ -41,7 +49,17 @@ +@@ -44,7 +52,17 @@ if (!list.isEmpty()) { EntityHuman entityhuman = (EntityHuman) list.get(0); diff --git a/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch b/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch index 2f35f2724..f62b64420 100644 --- a/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch +++ b/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch @@ -9,7 +9,7 @@ public class EntityBat extends EntityAmbient { public static final float FLAP_DEGREES_PER_TICK = 74.48451F; -@@ -137,16 +139,24 @@ +@@ -140,16 +142,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())) { -@@ -170,7 +180,11 @@ +@@ -173,7 +183,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 @@ } } -@@ -200,7 +214,11 @@ +@@ -203,7 +217,11 @@ return false; } else { if (!this.level.isClientSide && this.isResting()) { diff --git a/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch b/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch index 34c73766a..9fd8543e5 100644 --- a/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch +++ b/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch @@ -31,7 +31,7 @@ + if (playerBucketFishEvent.isCancelled()) { + ((EntityPlayer) entityhuman).containerMenu.sendAllDataToRemote(); // We need to update inventory to resync client's bucket + ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutSpawnEntity(t0)); // We need to play out these packets as the client assumes the fish is gone -+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutEntityMetadata(t0.getId(), t0.getEntityData(), true)); // Need to send data such as the display name to client ++ t0.getEntityData().refresh((EntityPlayer) entityhuman); // Need to send data such as the display name to client + return Optional.of(EnumInteractionResult.FAIL); + } + t0.playSound(((Bucketable) t0).getPickupSound(), 1.0F, 1.0F); diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch b/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch index 308e13904..c8770e423 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch @@ -9,7 +9,7 @@ } } -@@ -643,11 +643,15 @@ +@@ -646,11 +646,15 @@ if (this.isInvulnerableTo(damagesource)) { return false; } else { @@ -27,7 +27,7 @@ } } -@@ -1223,7 +1227,7 @@ +@@ -1226,7 +1230,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(); -@@ -1296,7 +1300,7 @@ +@@ -1299,7 +1303,7 @@ @Override protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) { if (entityinsentient instanceof EntityBee && this.mob.hasLineOfSight(entityliving)) { @@ -45,7 +45,7 @@ } } -@@ -1305,7 +1309,7 @@ +@@ -1308,7 +1312,7 @@ private static class c extends PathfinderGoalNearestAttackableTarget { c(EntityBee entitybee) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch b/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch index d011b7c87..170bd5db7 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch +++ b/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 -@@ -410,7 +410,7 @@ +@@ -415,7 +415,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); -@@ -467,7 +467,7 @@ +@@ -472,7 +472,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) { -@@ -608,7 +608,15 @@ +@@ -613,7 +613,15 @@ while (iterator.hasNext()) { ItemStack itemstack = (ItemStack) iterator.next(); @@ -35,7 +35,7 @@ } } -@@ -640,10 +648,10 @@ +@@ -645,10 +653,10 @@ private final EntityCat cat; public a(EntityCat entitycat, Class oclass, float f, double d0, double d1) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityChicken.patch b/nms-patches/net/minecraft/world/entity/animal/EntityChicken.patch index 3b3646a30..2ee248f0b 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityChicken.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityChicken.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityChicken.java +++ b/net/minecraft/world/entity/animal/EntityChicken.java -@@ -95,7 +95,9 @@ +@@ -96,7 +96,9 @@ this.flap += this.flapping * 2.0F; if (!this.level.isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) { this.playSound(SoundEffects.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch b/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch index 98f7d7eea..ba850bb86 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityCow.java +++ b/net/minecraft/world/entity/animal/EntityCow.java -@@ -30,6 +30,11 @@ +@@ -31,6 +31,11 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.block.state.IBlockData; @@ -12,7 +12,7 @@ public class EntityCow extends EntityAnimal { public EntityCow(EntityTypes entitytypes, World world) { -@@ -82,8 +87,16 @@ +@@ -83,8 +88,16 @@ ItemStack itemstack = entityhuman.getItemInHand(enumhand); if (itemstack.is(Items.BUCKET) && !this.isBaby()) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch b/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch index 4d02db8f9..034dfba6a 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch +++ b/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 -@@ -511,7 +511,8 @@ +@@ -516,7 +516,8 @@ protected void pickUpItem(EntityItem entityitem) { ItemStack itemstack = entityitem.getItem(); @@ -10,7 +10,7 @@ int i = itemstack.getCount(); if (i > 1) { -@@ -866,6 +867,16 @@ +@@ -871,6 +872,16 @@ if (entityplayer1 != null && entityplayer != entityplayer1) { entityfox.addTrustedUUID(entityplayer1.getUUID()); } @@ -27,7 +27,7 @@ if (entityplayer2 != null) { entityplayer2.awardStat(StatisticList.ANIMALS_BRED); -@@ -876,12 +887,14 @@ +@@ -881,12 +892,14 @@ this.partner.setAge(6000); this.animal.resetLove(); this.partner.resetLove(); @@ -46,7 +46,7 @@ } } -@@ -1272,13 +1285,18 @@ +@@ -1277,13 +1290,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); -@@ -1435,7 +1453,7 @@ +@@ -1440,7 +1458,7 @@ private EntityLiving trustedLastHurt; private int timestamp; diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch b/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch index de162c368..d67502cf4 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch +++ b/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 -@@ -43,6 +43,13 @@ +@@ -42,6 +42,13 @@ import net.minecraft.world.level.gameevent.GameEvent; import org.apache.commons.lang3.tuple.Pair; @@ -11,10 +11,10 @@ +import org.bukkit.event.entity.EntityTransformEvent; +// CraftBukkit end + - public class EntityMushroomCow extends EntityCow implements IShearable { + public class EntityMushroomCow extends EntityCow implements IShearable, VariantHolder { private static final DataWatcherObject DATA_TYPE = DataWatcher.defineId(EntityMushroomCow.class, DataWatcherRegistry.STRING); -@@ -116,6 +123,11 @@ +@@ -115,6 +122,11 @@ this.playSound(soundeffect, 1.0F, 1.0F); return EnumInteractionResult.sidedSuccess(this.level.isClientSide); } else if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { @@ -26,40 +26,40 @@ this.shear(SoundCategory.PLAYERS); this.gameEvent(GameEvent.SHEAR, entityhuman); if (!this.level.isClientSide) { -@@ -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); -- this.discard(); -+ // this.discard(); // CraftBukkit - moved down - EntityCow entitycow = (EntityCow) EntityTypes.COW.create(this.level); +@@ -165,7 +177,7 @@ - entitycow.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); + if (entitycow != null) { + ((WorldServer) this.level).sendParticles(Particles.EXPLOSION, this.getX(), this.getY(0.5D), this.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D); +- this.discard(); ++ // this.discard(); // CraftBukkit - moved down + entitycow.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); + entitycow.setHealth(this.getHealth()); + entitycow.yBodyRot = this.yBodyRot; @@ -179,10 +191,25 @@ - } + } - entitycow.setInvulnerable(this.isInvulnerable()); -- this.level.addFreshEntity(entitycow); -+ // CraftBukkit start -+ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) { -+ return; -+ } -+ this.level.addFreshEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); -+ -+ this.discard(); // CraftBukkit - from above -+ // CraftBukkit end - - for (int i = 0; i < 5; ++i) { -- this.level.addFreshEntity(new EntityItem(this.level, this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getMushroomType().blockState.getBlock()))); + entitycow.setInvulnerable(this.isInvulnerable()); +- this.level.addFreshEntity(entitycow); + // CraftBukkit start -+ EntityItem entityitem = new EntityItem(this.level, this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getMushroomType().blockState.getBlock())); -+ EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); -+ Bukkit.getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ continue; ++ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) { ++ return; + } -+ this.level.addFreshEntity(entityitem); ++ this.level.addFreshEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); ++ ++ this.discard(); // CraftBukkit - from above + // CraftBukkit end + + for (int i = 0; i < 5; ++i) { +- this.level.addFreshEntity(new EntityItem(this.level, this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getVariant().blockState.getBlock()))); ++ // CraftBukkit start ++ EntityItem entityitem = new EntityItem(this.level, this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getVariant().blockState.getBlock())); ++ EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); ++ Bukkit.getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ continue; ++ } ++ this.level.addFreshEntity(entityitem); ++ // CraftBukkit end + } } } - diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch b/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch index 0e0790068..46bd745c5 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch @@ -10,7 +10,7 @@ this.setTrusting(true); this.spawnTrustingParticles(true); this.level.broadcastEntityEvent(this, (byte) 41); -@@ -312,10 +313,10 @@ +@@ -313,10 +314,10 @@ private final EntityOcelot ocelot; public a(EntityOcelot entityocelot, Class oclass, float f, double d0, double d1) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch b/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch index 22bf133e9..60cc6fac9 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityPanda.java +++ b/net/minecraft/world/entity/animal/EntityPanda.java -@@ -64,6 +64,8 @@ +@@ -65,6 +65,8 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.Vec3D; @@ -9,7 +9,7 @@ public class EntityPanda extends EntityAnimal { private static final DataWatcherObject UNHAPPY_COUNTER = DataWatcher.defineId(EntityPanda.class, DataWatcherRegistry.INT); -@@ -526,7 +528,7 @@ +@@ -532,7 +534,7 @@ @Override protected void pickUpItem(EntityItem entityitem) { @@ -18,7 +18,7 @@ this.onItemPickup(entityitem); ItemStack itemstack = entityitem.getItem(); -@@ -872,10 +874,10 @@ +@@ -863,10 +865,10 @@ private final EntityPanda panda; public c(EntityPanda entitypanda, Class oclass, float f, double d0, double d1) { @@ -32,7 +32,7 @@ this.panda = entitypanda; } -@@ -1114,7 +1116,7 @@ +@@ -1105,7 +1107,7 @@ @Override protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) { if (entityinsentient instanceof EntityPanda && ((EntityPanda) entityinsentient).isAggressive()) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch b/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch index 8dae655a4..bf2e2006d 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch +++ b/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 -@@ -257,7 +257,7 @@ +@@ -261,7 +261,7 @@ } if (!this.level.isClientSide) { @@ -9,7 +9,7 @@ this.tame(entityhuman); this.level.broadcastEntityEvent(this, (byte) 7); } else { -@@ -271,7 +271,7 @@ +@@ -275,7 +275,7 @@ itemstack.shrink(1); } @@ -18,7 +18,7 @@ if (entityhuman.isCreative() || !this.isInvulnerable()) { this.hurt(DamageSource.playerAttack(entityhuman), Float.MAX_VALUE); } -@@ -383,7 +383,7 @@ +@@ -387,7 +387,7 @@ @Override public boolean isPushable() { @@ -27,7 +27,7 @@ } @Override -@@ -399,7 +399,7 @@ +@@ -403,7 +403,7 @@ return false; } else { if (!this.level.isClientSide) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch b/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch index 9d052ecdb..51a7c532a 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch @@ -11,18 +11,18 @@ public class EntityPig extends EntityAnimal implements ISteerable, ISaddleable { private static final DataWatcherObject DATA_SADDLE_ID = DataWatcher.defineId(EntityPig.class, DataWatcherRegistry.BOOLEAN); -@@ -249,7 +253,13 @@ - } +@@ -250,7 +254,13 @@ + } - entitypigzombie.setPersistenceRequired(); -- worldserver.addFreshEntity(entitypigzombie); -+ // CraftBukkit start -+ if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) { -+ return; -+ } -+ // CraftBukkit - added a reason for spawning this creature -+ worldserver.addFreshEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); -+ // CraftBukkit end - this.discard(); - } else { - super.thunderHit(worldserver, entitylightning); + entitypigzombie.setPersistenceRequired(); +- worldserver.addFreshEntity(entitypigzombie); ++ // CraftBukkit start ++ if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) { ++ return; ++ } ++ // CraftBukkit - added a reason for spawning this creature ++ worldserver.addFreshEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); ++ // CraftBukkit end + this.discard(); + } else { + super.thunderHit(worldserver, entitylightning); diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch b/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch index b1102eade..275266eaf 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch +++ b/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 -@@ -90,8 +90,14 @@ +@@ -88,8 +88,14 @@ super(entitytypes, world); this.jumpControl = new EntityRabbit.ControllerJumpRabbit(this); this.moveControl = new EntityRabbit.ControllerMoveRabbit(this); @@ -15,7 +15,7 @@ @Override public void registerGoals() { -@@ -559,9 +565,23 @@ +@@ -570,9 +576,23 @@ int i = (Integer) iblockdata.getValue(BlockCarrots.AGE); if (i == 0) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch b/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch index a7116a75a..43864f357 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch @@ -15,7 +15,7 @@ public class EntitySheep extends EntityAnimal implements IShearable { private static final int EAT_ANIMATION_TICKS = 40; -@@ -222,6 +230,11 @@ +@@ -243,6 +251,11 @@ if (itemstack.is(Items.SHEARS)) { if (!this.level.isClientSide && this.readyForShearing()) { @@ -27,7 +27,7 @@ this.shear(SoundCategory.PLAYERS); this.gameEvent(GameEvent.SHEAR, entityhuman); itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { -@@ -243,7 +256,9 @@ +@@ -264,7 +277,9 @@ int i = 1 + this.random.nextInt(3); for (int j = 0; j < i; ++j) { @@ -37,7 +37,7 @@ if (entityitem != null) { entityitem.setDeltaMovement(entityitem.getDeltaMovement().add((double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (this.random.nextFloat() * 0.05F), (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F))); -@@ -333,6 +348,12 @@ +@@ -357,6 +372,12 @@ @Override public void ate() { @@ -50,7 +50,7 @@ super.ate(); this.setSheared(false); if (this.isBaby()) { -@@ -352,7 +373,7 @@ +@@ -376,7 +397,7 @@ EnumColor enumcolor = ((EntitySheep) entityanimal).getColor(); EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor(); InventoryCrafting inventorycrafting = makeContainer(enumcolor, enumcolor1); @@ -59,7 +59,7 @@ return recipecrafting.assemble(inventorycrafting); }).map(ItemStack::getItem); -@@ -375,10 +396,18 @@ +@@ -399,10 +420,18 @@ public boolean stillValid(EntityHuman entityhuman) { return false; } diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch b/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch index b0ff1574b..165db82c7 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch @@ -20,7 +20,7 @@ } private static class e extends ControllerMove { -@@ -480,8 +484,12 @@ +@@ -482,8 +486,12 @@ } else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) { World world = this.turtle.level; diff --git a/nms-patches/net/minecraft/world/entity/animal/allay/Allay.patch b/nms-patches/net/minecraft/world/entity/animal/allay/Allay.patch index 439006e3f..bd3542eae 100644 --- a/nms-patches/net/minecraft/world/entity/animal/allay/Allay.patch +++ b/nms-patches/net/minecraft/world/entity/animal/allay/Allay.patch @@ -48,7 +48,7 @@ } if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) { -@@ -303,7 +310,12 @@ +@@ -306,7 +313,12 @@ ItemStack itemstack1 = this.getItemInHand(EnumHand.MAIN_HAND); if (this.isDancing() && this.isDuplicationItem(itemstack) && this.canDuplicate()) { @@ -62,7 +62,7 @@ this.level.broadcastEntityEvent(this, (byte) 18); this.level.playSound(entityhuman, (Entity) this, SoundEffects.AMETHYST_BLOCK_CHIME, SoundCategory.NEUTRAL, 2.0F, 1.0F); this.removeInteractionItem(entityhuman, itemstack); -@@ -315,7 +327,7 @@ +@@ -318,7 +330,7 @@ this.setItemInHand(EnumHand.MAIN_HAND, itemstack2); this.removeInteractionItem(entityhuman, itemstack); this.level.playSound(entityhuman, (Entity) this, SoundEffects.ALLAY_ITEM_GIVEN, SoundCategory.NEUTRAL, 2.0F, 1.0F); @@ -71,7 +71,7 @@ return EnumInteractionResult.SUCCESS; } else if (!itemstack1.isEmpty() && enumhand == EnumHand.MAIN_HAND && itemstack.isEmpty()) { this.setItemSlot(EnumItemSlot.MAINHAND, ItemStack.EMPTY); -@@ -407,6 +419,7 @@ +@@ -439,6 +451,7 @@ } private boolean shouldStopDancing() { @@ -79,25 +79,25 @@ return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), (double) GameEvent.JUKEBOX_PLAY.getNotificationRadius()) || !this.level.getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX); } -@@ -446,7 +459,7 @@ +@@ -483,7 +496,7 @@ public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(nbttagcompound); - nbttagcompound.put("Inventory", this.inventory.createTag()); + this.writeInventoryToTag(nbttagcompound); - DataResult dataresult = VibrationListener.codec(this.vibrationListenerConfig).encodeStart(DynamicOpsNBT.INSTANCE, (VibrationListener) this.dynamicVibrationListener.getListener()); + DataResult dataresult = VibrationListener.codec(this.vibrationListenerConfig).encodeStart(DynamicOpsNBT.INSTANCE, (VibrationListener) this.dynamicVibrationListener.getListener()); // CraftBukkit - decompile error Logger logger = Allay.LOGGER; Objects.requireNonNull(logger); -@@ -462,7 +475,7 @@ +@@ -499,7 +512,7 @@ super.readAdditionalSaveData(nbttagcompound); - this.inventory.fromTag(nbttagcompound.getList("Inventory", 10)); + this.readInventoryFromTag(nbttagcompound); if (nbttagcompound.contains("listener", 10)) { - DataResult dataresult = VibrationListener.codec(this.vibrationListenerConfig).parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("listener"))); + DataResult dataresult = VibrationListener.codec(this.vibrationListenerConfig).parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("listener"))); // CraftBukkit - decompile error Logger logger = Allay.LOGGER; Objects.requireNonNull(logger); -@@ -508,7 +521,7 @@ +@@ -532,7 +545,7 @@ return Allay.DUPLICATION_ITEM.test(itemstack); } @@ -106,7 +106,7 @@ Allay allay = (Allay) EntityTypes.ALLAY.create(this.level); if (allay != null) { -@@ -516,17 +529,17 @@ +@@ -540,17 +553,17 @@ allay.setPersistenceRequired(); allay.resetDuplicationCooldown(); this.resetDuplicationCooldown(); diff --git a/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch b/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch index 3b5888aae..54e1ed833 100644 --- a/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch +++ b/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java +++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java -@@ -66,10 +66,17 @@ +@@ -68,9 +68,16 @@ - public class Axolotl extends EntityAnimal implements LerpingModel, Bucketable { + public class Axolotl extends EntityAnimal implements LerpingModel, VariantHolder, Bucketable { + // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + @Override @@ -10,7 +10,6 @@ + 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, MemoryModuleType.IS_PANICKING}); @@ -19,7 +18,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); -@@ -187,7 +194,7 @@ +@@ -188,7 +195,7 @@ @Override public int getMaxAirSupply() { @@ -27,8 +26,8 @@ + return maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() } - public Axolotl.Variant getVariant() { -@@ -423,7 +430,7 @@ + @Override +@@ -418,7 +425,7 @@ if (i < 2400) { i = Math.min(2400, 100 + i); @@ -37,7 +36,7 @@ } entityhuman.removeEffect(MobEffects.DIG_SLOWDOWN); -@@ -473,7 +480,7 @@ +@@ -468,7 +475,7 @@ @Override public BehaviorController getBrain() { diff --git a/nms-patches/net/minecraft/world/entity/animal/frog/Tadpole.patch b/nms-patches/net/minecraft/world/entity/animal/frog/Tadpole.patch index d3af9c52b..f8e7f4762 100644 --- a/nms-patches/net/minecraft/world/entity/animal/frog/Tadpole.patch +++ b/nms-patches/net/minecraft/world/entity/animal/frog/Tadpole.patch @@ -9,19 +9,19 @@ } @Override -@@ -232,8 +232,14 @@ +@@ -233,8 +233,14 @@ + } + + frog.setPersistenceRequired(); ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTransformEvent(this, frog, org.bukkit.event.entity.EntityTransformEvent.TransformReason.METAMORPHOSIS).isCancelled()) { ++ this.setAge(0); // Sets the age to 0 for avoid a loop if the event is canceled ++ return; ++ } ++ // CraftBukkit end + this.playSound(SoundEffects.TADPOLE_GROW_UP, 0.15F, 1.0F); +- worldserver.addFreshEntityWithPassengers(frog); ++ worldserver.addFreshEntityWithPassengers(frog, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.METAMORPHOSIS); // CraftBukkit - add SpawnReason + this.discard(); } - - frog.setPersistenceRequired(); -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTransformEvent(this, frog, org.bukkit.event.entity.EntityTransformEvent.TransformReason.METAMORPHOSIS).isCancelled()) { -+ this.setAge(0); // Sets the age to 0 for avoid a loop if the event is canceled -+ return; -+ } -+ // CraftBukkit end - this.playSound(SoundEffects.TADPOLE_GROW_UP, 0.15F, 1.0F); -- worldserver.addFreshEntityWithPassengers(frog); -+ worldserver.addFreshEntityWithPassengers(frog, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.METAMORPHOSIS); // CraftBukkit - add SpawnReason - this.discard(); } - diff --git a/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch b/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch index f63d51e9d..681f54696 100644 --- a/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch +++ b/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch @@ -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); -@@ -156,7 +161,7 @@ +@@ -181,7 +186,7 @@ @Override public BehaviorController getBrain() { @@ -21,7 +21,7 @@ } @Override -@@ -194,8 +199,15 @@ +@@ -219,8 +224,15 @@ ItemStack itemstack = entityhuman.getItemInHand(enumhand); if (itemstack.is(Items.BUCKET) && !this.isBaby()) { diff --git a/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch b/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch index 76396accc..f3517cde5 100644 --- a/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch +++ b/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java +++ b/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java -@@ -72,6 +72,8 @@ +@@ -74,6 +74,8 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -9,7 +9,7 @@ public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, HasCustomInventoryScreen, IJumpable, ISaddleable { public static final int EQUIPMENT_SLOT_OFFSET = 400; -@@ -111,6 +113,7 @@ +@@ -113,6 +115,7 @@ private float mouthAnimO; protected boolean canGallop = true; protected int gallopSoundCounter; @@ -17,7 +17,7 @@ protected EntityHorseAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -296,7 +299,7 @@ +@@ -312,7 +315,7 @@ public void createInventory() { InventorySubcontainer inventorysubcontainer = this.inventory; @@ -26,7 +26,7 @@ if (inventorysubcontainer != null) { inventorysubcontainer.removeListener(this); int i = Math.min(inventorysubcontainer.getContainerSize(), this.inventory.getContainerSize()); -@@ -412,7 +415,7 @@ +@@ -416,7 +419,7 @@ } public int getMaxTemper() { @@ -35,7 +35,7 @@ } @Override -@@ -483,7 +486,7 @@ +@@ -487,7 +490,7 @@ } if (this.getHealth() < this.getMaxHealth() && f > 0.0F) { @@ -44,7 +44,7 @@ flag = true; } -@@ -560,7 +563,7 @@ +@@ -564,7 +567,7 @@ super.aiStep(); if (!this.level.isClientSide && this.isAlive()) { if (this.random.nextInt(900) == 0 && this.deathTime == 0) { @@ -53,7 +53,7 @@ } if (this.canEatGrass()) { -@@ -791,6 +794,7 @@ +@@ -838,6 +841,7 @@ if (this.getOwnerUUID() != null) { nbttagcompound.putUUID("Owner", this.getOwnerUUID()); } @@ -61,7 +61,7 @@ if (!this.inventory.getItem(0).isEmpty()) { nbttagcompound.put("SaddleItem", this.inventory.getItem(0).save(new NBTTagCompound())); -@@ -818,6 +822,11 @@ +@@ -865,6 +869,11 @@ if (uuid != null) { this.setOwnerUUID(uuid); } @@ -73,7 +73,7 @@ if (nbttagcompound.contains("SaddleItem", 10)) { ItemStack itemstack = ItemStack.of(nbttagcompound.getCompound("SaddleItem")); -@@ -895,6 +904,18 @@ +@@ -942,6 +951,18 @@ @Override public void handleStartJump(int i) { @@ -90,5 +90,5 @@ + } + // CraftBukkit end this.allowStandSliding = true; - this.stand(); + this.standIfPossible(); this.playJumpSound(); diff --git a/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlama.patch b/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlama.patch index 2d68a6ddd..c7277b78b 100644 --- a/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlama.patch +++ b/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 -@@ -77,6 +77,12 @@ +@@ -82,6 +82,12 @@ return false; } diff --git a/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch b/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch index 37ea0a4b7..25306fc4b 100644 --- a/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch +++ b/nms-patches/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.java +++ b/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.java -@@ -152,7 +152,7 @@ +@@ -153,7 +153,7 @@ @Override public void start() { diff --git a/nms-patches/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.patch b/nms-patches/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.patch index 40d5db148..6e536d03d 100644 --- a/nms-patches/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.patch +++ b/nms-patches/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.patch @@ -1,28 +1,26 @@ --- a/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.java +++ b/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.java -@@ -39,19 +39,20 @@ +@@ -41,12 +41,12 @@ + if (entitylightning != null) { + entitylightning.moveTo(this.horse.getX(), this.horse.getY(), this.horse.getZ()); + entitylightning.setVisualOnly(true); +- worldserver.addFreshEntity(entitylightning); ++ worldserver.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRAP); // CraftBukkit + EntitySkeleton entityskeleton = this.createSkeleton(difficultydamagescaler, this.horse); - entitylightning.moveTo(this.horse.getX(), this.horse.getY(), this.horse.getZ()); - entitylightning.setVisualOnly(true); -- worldserver.addFreshEntity(entitylightning); -+ worldserver.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRAP); // CraftBukkit - EntitySkeleton entityskeleton = this.createSkeleton(difficultydamagescaler, this.horse); + if (entityskeleton != null) { + entityskeleton.startRiding(this.horse); +- worldserver.addFreshEntityWithPassengers(entityskeleton); ++ worldserver.addFreshEntityWithPassengers(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP); // CraftBukkit -- entityskeleton.startRiding(this.horse); -- worldserver.addFreshEntityWithPassengers(entityskeleton); -+ if (entityskeleton != null) entityskeleton.startRiding(this.horse); // CraftBukkit -+ worldserver.addFreshEntityWithPassengers(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP); // CraftBukkit - - for (int i = 0; i < 3; ++i) { - EntityHorseAbstract entityhorseabstract = this.createHorse(difficultydamagescaler); -+ if (entityhorseabstract == null) continue; // CraftBukkit - EntitySkeleton entityskeleton1 = this.createSkeleton(difficultydamagescaler, entityhorseabstract); - -- entityskeleton1.startRiding(entityhorseabstract); -+ if (entityskeleton1 != null) entityskeleton1.startRiding(entityhorseabstract); // CraftBukkit - entityhorseabstract.push(this.horse.getRandom().triangle(0.0D, 1.1485D), 0.0D, this.horse.getRandom().triangle(0.0D, 1.1485D)); -- worldserver.addFreshEntityWithPassengers(entityhorseabstract); -+ worldserver.addFreshEntityWithPassengers(entityhorseabstract, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit - } - - } + for (int i = 0; i < 3; ++i) { + EntityHorseAbstract entityhorseabstract = this.createHorse(difficultydamagescaler); +@@ -57,7 +57,7 @@ + if (entityskeleton1 != null) { + entityskeleton1.startRiding(entityhorseabstract); + entityhorseabstract.push(this.horse.getRandom().triangle(0.0D, 1.1485D), 0.0D, this.horse.getRandom().triangle(0.0D, 1.1485D)); +- worldserver.addFreshEntityWithPassengers(entityhorseabstract); ++ worldserver.addFreshEntityWithPassengers(entityhorseabstract, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit + } + } + } diff --git a/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch b/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch index de8c74851..5669175b7 100644 --- a/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch +++ b/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.java +++ b/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.java -@@ -21,6 +21,11 @@ +@@ -19,6 +19,11 @@ import net.minecraft.world.level.block.BlockFireAbstract; import net.minecraft.world.level.dimension.end.EnderDragonBattle; @@ -12,7 +12,7 @@ public class EntityEnderCrystal extends Entity { private static final DataWatcherObject> DATA_BEAM_TARGET = DataWatcher.defineId(EntityEnderCrystal.class, DataWatcherRegistry.OPTIONAL_BLOCK_POS); -@@ -56,7 +61,11 @@ +@@ -54,7 +59,11 @@ BlockPosition blockposition = this.blockPosition(); if (((WorldServer) this.level).dragonFight() != null && this.level.getBlockState(blockposition).isAir()) { @@ -25,7 +25,7 @@ } } -@@ -96,9 +105,22 @@ +@@ -94,11 +103,24 @@ return false; } else { if (!this.isRemoved() && !this.level.isClientSide) { @@ -36,7 +36,9 @@ + // CraftBukkit end this.remove(Entity.RemovalReason.KILLED); if (!damagesource.isExplosion()) { -- this.level.explode((Entity) null, this.getX(), this.getY(), this.getZ(), 6.0F, Explosion.Effect.DESTROY); + DamageSource damagesource1 = damagesource.getEntity() != null ? DamageSource.explosion(this, damagesource.getEntity()) : null; + +- this.level.explode(this, damagesource1, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), 6.0F, false, World.a.BLOCK); + // CraftBukkit start + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 6.0F, false); + this.level.getCraftServer().getPluginManager().callEvent(event); @@ -44,7 +46,7 @@ + this.unsetRemoved(); + return false; + } -+ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Explosion.Effect.DESTROY); ++ this.level.explode(this, damagesource1, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.BLOCK); + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch b/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch index 69cacfdd2..d008dc60b 100644 --- a/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch +++ b/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/wither/EntityWither.java +++ b/net/minecraft/world/entity/boss/wither/EntityWither.java -@@ -55,6 +55,17 @@ +@@ -54,6 +54,17 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.Vec3D; @@ -18,21 +18,21 @@ public class EntityWither extends EntityMonster implements PowerableMob, IRangedEntity { private static final DataWatcherObject DATA_TARGET_A = DataWatcher.defineId(EntityWither.class, DataWatcherRegistry.INT); -@@ -249,16 +260,40 @@ +@@ -247,15 +258,40 @@ + i = this.getInvulnerableTicks() - 1; 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; +- this.level.explode(this, this.getX(), this.getEyeY(), this.getZ(), 7.0F, false, World.a.MOB); + // CraftBukkit start -+ // this.level.explode(this, this.getX(), this.getEyeY(), this.getZ(), 7.0F, false, explosion_effect); ++ // this.level.explode(this, this.getX(), this.getEyeY(), this.getZ(), 7.0F, false, World.a.MOB); + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false); + this.level.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ this.level.explode(this, this.getX(), this.getEyeY(), this.getZ(), event.getRadius(), event.getFire(), explosion_effect); ++ this.level.explode(this, this.getX(), this.getEyeY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); + } + // CraftBukkit end - -- this.level.explode(this, this.getX(), this.getEyeY(), this.getZ(), 7.0F, false, explosion_effect); ++ if (!this.isSilent()) { - this.level.globalLevelEvent(1023, this.blockPosition(), 0); + // CraftBukkit start - Use relative location for far away sounds @@ -62,7 +62,7 @@ } } else { -@@ -303,6 +338,7 @@ +@@ -300,6 +336,7 @@ if (!list.isEmpty()) { EntityLiving entityliving1 = (EntityLiving) list.get(this.random.nextInt(list.size())); @@ -70,7 +70,7 @@ this.setAlternativeTarget(i, entityliving1.getId()); } } -@@ -333,6 +369,11 @@ +@@ -330,6 +367,11 @@ IBlockData iblockdata = this.level.getBlockState(blockposition); if (canDestroy(iblockdata)) { @@ -82,7 +82,7 @@ flag = this.level.destroyBlock(blockposition, true, this) || flag; } } -@@ -346,7 +387,7 @@ +@@ -343,7 +385,7 @@ } if (this.tickCount % 20 == 0) { diff --git a/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch b/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch index b5f31c0d2..05c00ed41 100644 --- a/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch +++ b/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/EntityItemFrame.java +++ b/net/minecraft/world/entity/decoration/EntityItemFrame.java -@@ -93,16 +93,27 @@ +@@ -94,16 +94,27 @@ @Override protected void recalculateBoundingBox() { if (this.direction != null) { @@ -37,7 +37,7 @@ switch (enumdirection_enumaxis) { case X: -@@ -118,9 +129,10 @@ +@@ -119,9 +130,10 @@ d4 /= 32.0D; d5 /= 32.0D; d6 /= 32.0D; @@ -49,7 +49,7 @@ @Override public boolean survives() { -@@ -170,6 +182,11 @@ +@@ -171,6 +183,11 @@ return false; } else if (!damagesource.isExplosion() && !this.getItem().isEmpty()) { if (!this.level.isClientSide) { @@ -61,7 +61,7 @@ this.dropItem(damagesource.getEntity(), false); this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F); } -@@ -297,6 +314,12 @@ +@@ -298,6 +315,12 @@ } public void setItem(ItemStack itemstack, boolean flag) { @@ -74,7 +74,7 @@ if (!itemstack.isEmpty()) { itemstack = itemstack.copy(); itemstack.setCount(1); -@@ -304,7 +327,7 @@ +@@ -305,7 +328,7 @@ this.onItemChanged(itemstack); this.getEntityData().set(EntityItemFrame.DATA_ITEM, itemstack); diff --git a/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch b/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch index 96babdd83..aee917fc7 100644 --- a/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch +++ b/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 -@@ -24,6 +24,12 @@ +@@ -25,6 +25,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; -@@ -95,22 +101,42 @@ +@@ -96,22 +102,42 @@ while (iterator.hasNext()) { entityinsentient = (EntityInsentient) iterator.next(); if (entityinsentient.getLeashHolder() == entityhuman) { diff --git a/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch b/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch index d6cfa8ad4..cf5861eaa 100644 --- a/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch +++ b/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/EntityFallingBlock.java +++ b/net/minecraft/world/entity/item/EntityFallingBlock.java -@@ -46,6 +46,8 @@ +@@ -48,6 +48,8 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -9,7 +9,7 @@ public class EntityFallingBlock extends Entity { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -80,10 +82,17 @@ +@@ -82,10 +84,17 @@ } public static EntityFallingBlock fall(World world, BlockPosition blockposition, IBlockData iblockdata) { @@ -28,7 +28,7 @@ return entityfallingblock; } -@@ -166,6 +175,12 @@ +@@ -168,6 +177,12 @@ this.blockState = (IBlockData) this.blockState.setValue(BlockProperties.WATERLOGGED, true); } @@ -41,7 +41,7 @@ if (this.level.setBlock(blockposition, this.blockState, 3)) { ((WorldServer) this.level).getChunkSource().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition))); this.discard(); -@@ -236,7 +251,7 @@ +@@ -238,7 +253,7 @@ if (i < 0) { return false; } else { @@ -50,7 +50,7 @@ DamageSource damagesource1; if (this.blockState.getBlock() instanceof Fallable) { -@@ -252,7 +267,9 @@ +@@ -254,7 +269,9 @@ float f2 = (float) Math.min(MathHelper.floor((float) i * this.fallDamagePerDistance), this.fallDamageMax); this.level.getEntities((Entity) this, this.getBoundingBox(), predicate).forEach((entity) -> { diff --git a/nms-patches/net/minecraft/world/entity/item/EntityItem.patch b/nms-patches/net/minecraft/world/entity/item/EntityItem.patch index 6c75c2884..d8903753e 100644 --- a/nms-patches/net/minecraft/world/entity/item/EntityItem.patch +++ b/nms-patches/net/minecraft/world/entity/item/EntityItem.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/EntityItem.java +++ b/net/minecraft/world/entity/item/EntityItem.java -@@ -32,6 +32,12 @@ +@@ -30,6 +30,12 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.Vec3D; @@ -13,7 +13,7 @@ public class EntityItem extends Entity { private static final DataWatcherObject DATA_ITEM = DataWatcher.defineId(EntityItem.class, DataWatcherRegistry.ITEM_STACK); -@@ -46,6 +52,7 @@ +@@ -44,6 +50,7 @@ @Nullable private UUID owner; public final float bobOffs; @@ -21,7 +21,7 @@ public EntityItem(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -103,9 +110,12 @@ +@@ -101,9 +108,12 @@ this.discard(); } else { super.tick(); @@ -37,7 +37,7 @@ this.xo = this.getX(); this.yo = this.getY(); -@@ -155,9 +165,11 @@ +@@ -153,9 +163,11 @@ this.mergeWithNeighbours(); } @@ -49,7 +49,7 @@ this.hasImpulse |= this.updateInWaterStateAndDoFluidPushing(); if (!this.level.isClientSide) { -@@ -169,6 +181,12 @@ +@@ -167,6 +179,12 @@ } if (!this.level.isClientSide && this.age >= 6000) { @@ -62,7 +62,7 @@ this.discard(); } -@@ -244,10 +262,11 @@ +@@ -242,10 +260,11 @@ private static void merge(EntityItem entityitem, ItemStack itemstack, ItemStack itemstack1) { ItemStack itemstack2 = merge(itemstack, itemstack1, 64); @@ -75,7 +75,7 @@ merge(entityitem, itemstack, itemstack1); entityitem.pickupDelay = Math.max(entityitem.pickupDelay, entityitem1.pickupDelay); entityitem.age = Math.min(entityitem.age, entityitem1.age); -@@ -273,6 +292,11 @@ +@@ -271,6 +290,11 @@ } else if (this.level.isClientSide) { return true; } else { @@ -87,7 +87,7 @@ this.markHurt(); this.health = (int) ((float) this.health - f); this.gameEvent(GameEvent.ENTITY_DAMAGE, damagesource.getEntity()); -@@ -336,6 +360,46 @@ +@@ -334,6 +358,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()) { -@@ -379,7 +443,9 @@ +@@ -377,7 +441,9 @@ } public void setItem(ItemStack itemstack) { diff --git a/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch b/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch index e14a4674c..41f495b05 100644 --- a/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch +++ b/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/item/EntityTNTPrimed.java +++ b/net/minecraft/world/entity/item/EntityTNTPrimed.java -@@ -17,12 +17,16 @@ - import net.minecraft.world.level.Explosion; +@@ -14,12 +14,16 @@ + import net.minecraft.world.entity.EnumMoveType; import net.minecraft.world.level.World; +import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit @@ -17,7 +17,7 @@ public EntityTNTPrimed(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -73,10 +77,13 @@ +@@ -70,10 +74,13 @@ this.setFuse(i); if (i <= 0) { @@ -32,7 +32,7 @@ } else { this.updateInWaterStateAndDoFluidPushing(); if (this.level.isClientSide) { -@@ -87,9 +94,16 @@ +@@ -84,9 +91,16 @@ } private void explode() { @@ -40,12 +40,12 @@ + // CraftBukkit start + // float f = 4.0F; -- this.level.explode(this, this.getX(), this.getY(0.0625D), this.getZ(), 4.0F, Explosion.Effect.BREAK); +- this.level.explode(this, this.getX(), this.getY(0.0625D), this.getZ(), 4.0F, World.a.TNT); + ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); + this.level.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ this.level.explode(this, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), Explosion.Effect.BREAK); ++ this.level.explode(this, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT); + } + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch b/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch index f12344b05..52cb0fb0c 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityCreeper.java +++ b/net/minecraft/world/entity/monster/EntityCreeper.java -@@ -44,6 +44,12 @@ +@@ -43,6 +43,12 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.gameevent.GameEvent; @@ -13,7 +13,7 @@ public class EntityCreeper extends EntityMonster implements PowerableMob { private static final DataWatcherObject DATA_SWELL_DIR = DataWatcher.defineId(EntityCreeper.class, DataWatcherRegistry.INT); -@@ -219,9 +225,19 @@ +@@ -218,9 +224,19 @@ @Override public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { super.thunderHit(worldserver, entitylightning); @@ -35,11 +35,11 @@ protected EnumInteractionResult mobInteract(EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.getItemInHand(enumhand); @@ -246,10 +262,18 @@ - Explosion.Effect explosion_effect = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE; + if (!this.level.isClientSide) { float f = this.isPowered() ? 2.0F : 1.0F; - this.dead = true; -- this.level.explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, explosion_effect); +- this.level.explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, World.a.MOB); - this.discard(); - this.spawnLingeringCloud(); + // CraftBukkit start @@ -47,7 +47,7 @@ + this.level.getCraftServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { + this.dead = true; -+ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), explosion_effect); ++ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); + this.discard(); + this.spawnLingeringCloud(); + } else { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch b/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch index bf15a005d..1dc295b04 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch +++ b/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 -@@ -109,7 +109,17 @@ +@@ -114,7 +114,17 @@ @Override public void setTarget(@Nullable EntityLiving entityliving) { @@ -19,7 +19,7 @@ AttributeModifiable attributemodifiable = this.getAttribute(GenericAttributes.MOVEMENT_SPEED); if (entityliving == null) { -@@ -124,6 +134,7 @@ +@@ -129,6 +139,7 @@ attributemodifiable.addTransientModifier(EntityEnderman.SPEED_MODIFIER_ATTACKING); } } @@ -27,7 +27,7 @@ } -@@ -474,9 +485,13 @@ +@@ -490,9 +501,13 @@ if (iblockdata2 != null) { iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level, blockposition); if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) { @@ -41,7 +41,7 @@ } } -@@ -515,9 +530,13 @@ +@@ -531,9 +546,13 @@ boolean flag = movingobjectpositionblock.getBlockPos().equals(blockposition); if (iblockdata.is(TagsBlock.ENDERMAN_HOLDABLE) && flag) { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityEvoker.patch b/nms-patches/net/minecraft/world/entity/monster/EntityEvoker.patch index 128cf3dae..1a6e2a83d 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityEvoker.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityEvoker.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/monster/EntityEvoker.java +++ b/net/minecraft/world/entity/monster/EntityEvoker.java -@@ -191,7 +191,7 @@ - entityvex.setOwner(EntityEvoker.this); - entityvex.setBoundOrigin(blockposition); - entityvex.setLimitedLife(20 * (30 + EntityEvoker.this.random.nextInt(90))); -- worldserver.addFreshEntityWithPassengers(entityvex); -+ worldserver.addFreshEntityWithPassengers(entityvex, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPELL); // CraftBukkit - Add SpawnReason +@@ -192,7 +192,7 @@ + entityvex.setOwner(EntityEvoker.this); + entityvex.setBoundOrigin(blockposition); + entityvex.setLimitedLife(20 * (30 + EntityEvoker.this.random.nextInt(90))); +- worldserver.addFreshEntityWithPassengers(entityvex); ++ worldserver.addFreshEntityWithPassengers(entityvex, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPELL); // CraftBukkit - Add SpawnReason + } } - } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityIllagerWizard.patch b/nms-patches/net/minecraft/world/entity/monster/EntityIllagerWizard.patch index 00ed14149..e2273bc71 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityIllagerWizard.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityIllagerWizard.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityIllagerWizard.java +++ b/net/minecraft/world/entity/monster/EntityIllagerWizard.java -@@ -161,6 +161,11 @@ +@@ -155,6 +155,11 @@ public void tick() { --this.attackWarmupDelay; if (this.attackWarmupDelay == 0) { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch b/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch index 0d68577d3..b3fd8e09d 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityPigZombie.java +++ b/net/minecraft/world/entity/monster/EntityPigZombie.java -@@ -145,7 +145,7 @@ +@@ -154,7 +154,7 @@ }).filter((entitypigzombie) -> { return !entitypigzombie.isAlliedTo((Entity) this.getTarget()); }).forEach((entitypigzombie) -> { @@ -9,7 +9,7 @@ }); } -@@ -154,7 +154,7 @@ +@@ -163,7 +163,7 @@ } @Override @@ -18,7 +18,7 @@ if (this.getTarget() == null && entityliving != null) { this.playFirstAngerSoundIn = EntityPigZombie.FIRST_ANGER_SOUND_DELAY.sample(this.random); this.ticksUntilNextAlert = EntityPigZombie.ALERT_INTERVAL.sample(this.random); -@@ -164,12 +164,21 @@ +@@ -173,12 +173,21 @@ this.setLastHurtByPlayer((EntityHuman) entityliving); } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch b/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch index 6b620ea96..2c77b6759 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/monster/EntityShulker.java +++ b/net/minecraft/world/entity/monster/EntityShulker.java -@@ -57,6 +57,12 @@ - import net.minecraft.world.phys.AxisAlignedBB; +@@ -59,6 +59,12 @@ import net.minecraft.world.phys.Vec3D; + import org.joml.Vector3f; +// CraftBukkit start +import net.minecraft.server.level.WorldServer; @@ -10,10 +10,10 @@ +import org.bukkit.event.entity.EntityTeleportEvent; +// CraftBukkit end + - public class EntityShulker extends EntityGolem implements IMonster { + public class EntityShulker extends EntityGolem implements VariantHolder>, IMonster { private static final UUID COVERED_ARMOR_MODIFIER_UUID = UUID.fromString("7E0292F2-9434-48D5-A29F-9583AF7DF27F"); -@@ -405,6 +411,16 @@ +@@ -407,6 +413,16 @@ EnumDirection enumdirection = this.findAttachableSurface(blockposition1); if (enumdirection != null) { @@ -30,12 +30,12 @@ this.unRide(); this.setAttachFace(enumdirection); this.playSound(SoundEffects.SHULKER_TELEPORT, 1.0F, 1.0F); -@@ -478,7 +494,7 @@ +@@ -477,7 +493,7 @@ + if (entityshulker != null) { + entityshulker.setVariant(this.getVariant()); + entityshulker.moveTo(vec3d); +- this.level.addFreshEntity(entityshulker); ++ this.level.addFreshEntity(entityshulker, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - the mysteries of life } - entityshulker.moveTo(vec3d); -- this.level.addFreshEntity(entityshulker); -+ this.level.addFreshEntity(entityshulker, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - the mysteries of life } - } - } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch b/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch index e47e55a36..f9af5924c 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntitySkeleton.java +++ b/net/minecraft/world/entity/monster/EntitySkeleton.java -@@ -86,7 +86,7 @@ +@@ -90,7 +90,7 @@ } protected void doFreezeConversion() { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch b/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch index eaacbbfa3..ffec2feab 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch @@ -15,7 +15,7 @@ public class EntitySlime extends EntityInsentient implements IMonster { private static final DataWatcherObject ID_SIZE = DataWatcher.defineId(EntitySlime.class, DataWatcherRegistry.INT); -@@ -184,7 +192,7 @@ +@@ -185,7 +193,7 @@ @Override public EntityTypes getType() { @@ -24,7 +24,7 @@ } @Override -@@ -198,6 +206,19 @@ +@@ -199,6 +207,19 @@ int j = i / 2; int k = 2 + this.random.nextInt(3); @@ -44,14 +44,14 @@ for (int l = 0; l < k; ++l) { float f1 = ((float) (l % 2) - 0.5F) * f; float f2 = ((float) (l / 2) - 0.5F) * f; -@@ -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); -- this.level.addFreshEntity(entityslime); -+ slimes.add(entityslime); // CraftBukkit -+ } -+ +@@ -214,9 +235,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); +- this.level.addFreshEntity(entityslime); ++ slimes.add(entityslime); // CraftBukkit + } + } + // CraftBukkit start + if (CraftEventFactory.callEntityTransformEvent(this, slimes, EntityTransformEvent.TransformReason.SPLIT).isCancelled()) { + super.remove(entity_removalreason); @@ -59,7 +59,7 @@ + } + for (EntityLiving living : slimes) { + this.level.addFreshEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason - } ++ } + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntitySpider.patch b/nms-patches/net/minecraft/world/entity/monster/EntitySpider.patch index 818140c99..f09ac2ca8 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntitySpider.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntitySpider.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntitySpider.java +++ b/net/minecraft/world/entity/monster/EntitySpider.java -@@ -177,7 +177,7 @@ +@@ -179,7 +179,7 @@ MobEffectList mobeffectlist = ((EntitySpider.GroupDataSpider) object).effect; if (mobeffectlist != null) { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch b/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch index 8551e5017..e6995b4a0 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityVex.java +++ b/net/minecraft/world/entity/monster/EntityVex.java -@@ -373,7 +373,7 @@ +@@ -386,7 +386,7 @@ @Override public void start() { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch b/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch index 1c04bb95c..5b44a2ae2 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch @@ -16,7 +16,7 @@ public class EntityZombie extends EntityMonster { private static final UUID SPEED_MODIFIER_BABY_UUID = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); -@@ -85,6 +94,7 @@ +@@ -86,6 +95,7 @@ private boolean canBreakDoors; private int inWaterTime; public int conversionTime; @@ -24,7 +24,7 @@ public EntityZombie(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -201,7 +211,10 @@ +@@ -202,7 +212,10 @@ public void tick() { if (!this.level.isClientSide && this.isAlive() && !this.isNoAi()) { if (this.isUnderWaterConverting()) { @@ -36,7 +36,7 @@ if (this.conversionTime < 0) { this.doUnderWaterConversion(); } -@@ -218,6 +231,7 @@ +@@ -219,6 +232,7 @@ } super.tick(); @@ -44,7 +44,7 @@ } @Override -@@ -250,6 +264,7 @@ +@@ -251,6 +265,7 @@ } public void startUnderWaterConversion(int i) { @@ -52,7 +52,7 @@ this.conversionTime = i; this.getEntityData().set(EntityZombie.DATA_DROWNED_CONVERSION_ID, true); } -@@ -263,11 +278,15 @@ +@@ -264,11 +279,15 @@ } protected void convertToZombieType(EntityTypes entitytypes) { @@ -69,7 +69,7 @@ } } -@@ -307,9 +326,9 @@ +@@ -308,9 +327,9 @@ if (SpawnerCreature.isSpawnPositionOk(entitypositiontypes_surface, this.level, blockposition, entitytypes) && EntityPositionTypes.checkSpawnRules(entitytypes, worldserver, EnumMobSpawn.REINFORCEMENT, blockposition, this.level.random)) { entityzombie.setPos((double) i1, (double) j1, (double) k1); if (!this.level.hasNearbyAlivePlayer((double) i1, (double) j1, (double) k1, 7.0D) && this.level.isUnobstructed(entityzombie) && this.level.noCollision((Entity) entityzombie) && !this.level.containsAnyLiquid(entityzombie.getBoundingBox())) { @@ -81,7 +81,7 @@ this.getAttribute(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE).addPermanentModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); entityzombie.getAttribute(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE).addPermanentModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); break; -@@ -330,7 +349,14 @@ +@@ -331,7 +350,14 @@ float f = this.level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < f * 0.3F) { @@ -97,49 +97,54 @@ } } -@@ -412,21 +438,30 @@ +@@ -413,8 +439,17 @@ + if (worldserver.getDifficulty() != EnumDifficulty.HARD && this.random.nextBoolean()) { + return flag; } - - EntityVillager entityvillager = (EntityVillager) entityliving; -- EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false); + // CraftBukkit start + flag = zombifyVillager(worldserver, entityvillager, this.blockPosition(), this.isSilent(), CreatureSpawnEvent.SpawnReason.INFECTION) == null; + } +- EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false); + return flag; + } + + public static EntityZombieVillager zombifyVillager(WorldServer worldserver, EntityVillager entityvillager, net.minecraft.core.BlockPosition blockPosition, boolean silent, CreatureSpawnEvent.SpawnReason spawnReason) { -+ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, spawnReason); -+ if (entityzombievillager != null) { ++ { ++ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, spawnReason); + // CraftBukkit end - entityzombievillager.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombievillager.blockPosition()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true), (NBTTagCompound) null); - entityzombievillager.setVillagerData(entityvillager.getVillagerData()); - entityzombievillager.setGossips((NBTBase) entityvillager.getGossips().store(DynamicOpsNBT.INSTANCE).getValue()); - entityzombievillager.setTradeOffers(entityvillager.getOffers().createTag()); - entityzombievillager.setVillagerXp(entityvillager.getVillagerXp()); -- if (!this.isSilent()) { -- worldserver.levelEvent((EntityHuman) null, 1026, this.blockPosition(), 0); -+ // CraftBukkit start -+ if (!silent) { -+ worldserver.levelEvent((EntityHuman) null, 1026, blockPosition, 0); + + if (entityzombievillager != null) { + entityzombievillager.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombievillager.blockPosition()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true), (NBTTagCompound) null); +@@ -422,15 +457,17 @@ + entityzombievillager.setGossips((NBTBase) entityvillager.getGossips().store(DynamicOpsNBT.INSTANCE)); + entityzombievillager.setTradeOffers(entityvillager.getOffers().createTag()); + entityzombievillager.setVillagerXp(entityvillager.getVillagerXp()); +- if (!this.isSilent()) { +- worldserver.levelEvent((EntityHuman) null, 1026, this.blockPosition(), 0); ++ // CraftBukkit start ++ if (!silent) { ++ worldserver.levelEvent((EntityHuman) null, 1026, blockPosition, 0); + } + +- flag = false; ++ // flag = false; } -- -- flag = false; -+ // CraftBukkit end - } +- } - return flag; -+ return entityzombievillager; // CraftBukkit ++ return entityzombievillager; ++ } ++ // CraftBukkit end } @Override -@@ -478,7 +513,7 @@ - entitychicken1.finalizeSpawn(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null); - entitychicken1.setChickenJockey(true); - this.startRiding(entitychicken1); -- worldaccess.addFreshEntity(entitychicken1); -+ worldaccess.addFreshEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit +@@ -483,7 +520,7 @@ + entitychicken1.finalizeSpawn(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null); + entitychicken1.setChickenJockey(true); + this.startRiding(entitychicken1); +- worldaccess.addFreshEntity(entitychicken1); ++ worldaccess.addFreshEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit + } } } - } diff --git a/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch b/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch index 63dee2ddc..0f27d24e8 100644 --- a/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch +++ b/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/EntityPiglin.java +++ b/net/minecraft/world/entity/monster/piglin/EntityPiglin.java -@@ -54,6 +54,18 @@ +@@ -56,6 +56,18 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; @@ -8,7 +8,7 @@ +import java.util.stream.Collectors; +import java.util.HashSet; +import java.util.Set; -+import net.minecraft.core.IRegistry; ++import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.nbt.NBTBase; @@ -19,10 +19,10 @@ public class EntityPiglin extends EntityPiglinAbstract implements ICrossbow, InventoryCarrier { private static final DataWatcherObject DATA_BABY_ID = DataWatcher.defineId(EntityPiglin.class, DataWatcherRegistry.BOOLEAN); -@@ -74,6 +86,10 @@ +@@ -76,6 +88,10 @@ public boolean cannotHunt; protected static final ImmutableList>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.NEAREST_ITEMS, SensorType.HURT_BY, SensorType.PIGLIN_SPECIFIC_SENSOR); - protected static final ImmutableList> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.DOORS_TO_CLOSE, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLINS, MemoryModuleType.NEARBY_ADULT_PIGLINS, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryModuleType.HURT_BY, MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.WALK_TARGET, new MemoryModuleType[]{MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.INTERACTION_TARGET, MemoryModuleType.PATH, MemoryModuleType.ANGRY_AT, MemoryModuleType.UNIVERSAL_ANGER, MemoryModuleType.AVOID_TARGET, MemoryModuleType.ADMIRING_ITEM, MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM, MemoryModuleType.ADMIRING_DISABLED, MemoryModuleType.DISABLE_WALK_TO_ADMIRE_ITEM, MemoryModuleType.CELEBRATE_LOCATION, MemoryModuleType.DANCING, MemoryModuleType.HUNTED_RECENTLY, MemoryModuleType.NEAREST_VISIBLE_BABY_HOGLIN, MemoryModuleType.NEAREST_VISIBLE_NEMESIS, MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, MemoryModuleType.RIDE_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_HUNTABLE_HOGLIN, MemoryModuleType.NEAREST_TARGETABLE_PLAYER_NOT_WEARING_GOLD, MemoryModuleType.NEAREST_PLAYER_HOLDING_WANTED_ITEM, MemoryModuleType.ATE_RECENTLY, MemoryModuleType.NEAREST_REPELLENT}); + protected static final ImmutableList> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.DOORS_TO_CLOSE, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLINS, MemoryModuleType.NEARBY_ADULT_PIGLINS, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryModuleType.ITEM_PICKUP_COOLDOWN_TICKS, MemoryModuleType.HURT_BY, MemoryModuleType.HURT_BY_ENTITY, new MemoryModuleType[]{MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.INTERACTION_TARGET, MemoryModuleType.PATH, MemoryModuleType.ANGRY_AT, MemoryModuleType.UNIVERSAL_ANGER, MemoryModuleType.AVOID_TARGET, MemoryModuleType.ADMIRING_ITEM, MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM, MemoryModuleType.ADMIRING_DISABLED, MemoryModuleType.DISABLE_WALK_TO_ADMIRE_ITEM, MemoryModuleType.CELEBRATE_LOCATION, MemoryModuleType.DANCING, MemoryModuleType.HUNTED_RECENTLY, MemoryModuleType.NEAREST_VISIBLE_BABY_HOGLIN, MemoryModuleType.NEAREST_VISIBLE_NEMESIS, MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, MemoryModuleType.RIDE_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_HUNTABLE_HOGLIN, MemoryModuleType.NEAREST_TARGETABLE_PLAYER_NOT_WEARING_GOLD, MemoryModuleType.NEAREST_PLAYER_HOLDING_WANTED_ITEM, MemoryModuleType.ATE_RECENTLY, MemoryModuleType.NEAREST_REPELLENT}); + // CraftBukkit start - Custom bartering and interest list + public Set allowedBarterItems = new HashSet<>(); + public Set interestItems = new HashSet<>(); @@ -30,33 +30,33 @@ public EntityPiglin(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -92,6 +108,14 @@ +@@ -94,6 +110,14 @@ } - nbttagcompound.put("Inventory", this.inventory.createTag()); + this.writeInventoryToTag(nbttagcompound); + // CraftBukkit start + NBTTagList barterList = new NBTTagList(); -+ allowedBarterItems.stream().map(IRegistry.ITEM::getKey).map(MinecraftKey::toString).map(NBTTagString::valueOf).forEach(barterList::add); ++ allowedBarterItems.stream().map(BuiltInRegistries.ITEM::getKey).map(MinecraftKey::toString).map(NBTTagString::valueOf).forEach(barterList::add); + nbttagcompound.put("Bukkit.BarterList", barterList); + NBTTagList interestList = new NBTTagList(); -+ interestItems.stream().map(IRegistry.ITEM::getKey).map(MinecraftKey::toString).map(NBTTagString::valueOf).forEach(interestList::add); ++ interestItems.stream().map(BuiltInRegistries.ITEM::getKey).map(MinecraftKey::toString).map(NBTTagString::valueOf).forEach(interestList::add); + nbttagcompound.put("Bukkit.InterestList", interestList); + // CraftBukkit end } @Override -@@ -100,6 +124,10 @@ +@@ -102,6 +126,10 @@ this.setBaby(nbttagcompound.getBoolean("IsBaby")); this.setCannotHunt(nbttagcompound.getBoolean("CannotHunt")); - this.inventory.fromTag(nbttagcompound.getList("Inventory", 10)); + this.readInventoryFromTag(nbttagcompound); + // CraftBukkit start -+ this.allowedBarterItems = nbttagcompound.getList("Bukkit.BarterList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(IRegistry.ITEM::get).collect(Collectors.toCollection(HashSet::new)); -+ this.interestItems = nbttagcompound.getList("Bukkit.InterestList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(IRegistry.ITEM::get).collect(Collectors.toCollection(HashSet::new)); ++ this.allowedBarterItems = nbttagcompound.getList("Bukkit.BarterList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(BuiltInRegistries.ITEM::get).collect(Collectors.toCollection(HashSet::new)); ++ this.interestItems = nbttagcompound.getList("Bukkit.InterestList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(BuiltInRegistries.ITEM::get).collect(Collectors.toCollection(HashSet::new)); + // CraftBukkit end } @VisibleForDebug -@@ -206,7 +234,7 @@ +@@ -223,7 +251,7 @@ @Override public BehaviorController getBrain() { @@ -65,7 +65,7 @@ } @Override -@@ -349,7 +377,7 @@ +@@ -368,7 +396,7 @@ } protected void holdInOffHand(ItemStack itemstack) { @@ -74,7 +74,7 @@ this.setItemSlot(EnumItemSlot.OFFHAND, itemstack); this.setGuaranteedDrop(EnumItemSlot.OFFHAND); } else { -@@ -375,8 +403,8 @@ +@@ -394,8 +422,8 @@ if (EnchantmentManager.hasBindingCurse(itemstack1)) { return false; } else { @@ -85,7 +85,7 @@ return flag && !flag1 ? true : (!flag && flag1 ? false : (this.isAdult() && !itemstack.is(Items.CROSSBOW) && itemstack1.is(Items.CROSSBOW) ? false : super.canReplaceCurrentItem(itemstack, itemstack1))); } -@@ -405,7 +433,7 @@ +@@ -424,7 +452,7 @@ @Override protected SoundEffect getAmbientSound() { diff --git a/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.patch b/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.patch index d362955d5..0ea9568fe 100644 --- a/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.patch +++ b/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.java +++ b/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.java -@@ -100,7 +100,7 @@ +@@ -108,7 +108,7 @@ } protected void finishConversion(WorldServer worldserver) { @@ -9,7 +9,7 @@ if (entitypigzombie != null) { entitypigzombie.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0)); -@@ -117,7 +117,7 @@ +@@ -125,7 +125,7 @@ @Nullable @Override public EntityLiving getTarget() { diff --git a/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch b/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch index b2b123ad9..78bc59e86 100644 --- a/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch +++ b/nms-patches/net/minecraft/world/entity/monster/piglin/PiglinAI.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/PiglinAI.java +++ b/net/minecraft/world/entity/monster/piglin/PiglinAI.java -@@ -71,6 +71,13 @@ +@@ -74,6 +74,13 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParameters; import net.minecraft.world.phys.Vec3D; @@ -14,7 +14,26 @@ public class PiglinAI { public static final int REPELLENT_DETECTION_RANGE_HORIZONTAL = 8; -@@ -186,13 +193,13 @@ +@@ -164,7 +171,8 @@ + } + + private static void initRideHoglinActivity(BehaviorController behaviorcontroller) { +- behaviorcontroller.addActivityAndRemoveMemoryWhenStopped(Activity.RIDE, 10, ImmutableList.of(BehaviorStartRiding.create(0.8F), BehaviorLookTarget.create(PiglinAI::isPlayerHoldingLovedItem, 8.0F), BehaviorBuilder.sequence(BehaviorBuilder.triggerIf(Entity::isPassenger), TriggerGate.triggerOneShuffled(ImmutableList.builder().addAll(createLookBehaviors()).add(Pair.of(BehaviorBuilder.triggerIf((entitypiglin) -> { ++ // CraftBukkit - decompile error ++ behaviorcontroller.addActivityAndRemoveMemoryWhenStopped(Activity.RIDE, 10, ImmutableList.of(BehaviorStartRiding.create(0.8F), BehaviorLookTarget.create(PiglinAI::isPlayerHoldingLovedItem, 8.0F), BehaviorBuilder.sequence(BehaviorBuilder.triggerIf(Entity::isPassenger), TriggerGate.triggerOneShuffled(ImmutableList., Integer>>builder().addAll(createLookBehaviors()).add(Pair.of(BehaviorBuilder.triggerIf((entitypiglin) -> { + return true; + }), 1)).build())), BehaviorStopRiding.create(8, PiglinAI::wantsToStopRiding)), MemoryModuleType.RIDE_TARGET); + } +@@ -174,7 +182,7 @@ + } + + private static BehaviorGateSingle createIdleLookBehaviors() { +- return new BehaviorGateSingle<>(ImmutableList.builder().addAll(createLookBehaviors()).add(Pair.of(new BehaviorNop(30, 60), 1)).build()); ++ return new BehaviorGateSingle<>(ImmutableList., Integer>>builder().addAll(createLookBehaviors()).add(Pair.of(new BehaviorNop(30, 60), 1)).build()); // CraftBukkit - decompile error + } + + private static BehaviorGateSingle createIdleMovementBehaviors() { +@@ -195,13 +203,13 @@ protected static void updateActivity(EntityPiglin entitypiglin) { BehaviorController behaviorcontroller = entitypiglin.getBrain(); @@ -31,7 +50,7 @@ Objects.requireNonNull(entitypiglin); optional.ifPresent(entitypiglin::playSoundEvent); -@@ -224,23 +231,27 @@ +@@ -233,23 +241,27 @@ stopWalking(entitypiglin); ItemStack itemstack; @@ -58,12 +77,12 @@ } else if (isFood(itemstack) && !hasEatenRecently(entitypiglin)) { eat(entitypiglin); } else { -- boolean flag = entitypiglin.equipItemIfPossible(itemstack); -+ boolean flag = entitypiglin.equipItemIfPossible(itemstack, entityitem); // CraftBukkit +- boolean flag = !entitypiglin.equipItemIfPossible(itemstack).equals(ItemStack.EMPTY); ++ boolean flag = !entitypiglin.equipItemIfPossible(itemstack, entityitem).equals(ItemStack.EMPTY); // CraftBukkit if (!flag) { putInInventory(entitypiglin, itemstack); -@@ -276,9 +287,14 @@ +@@ -285,9 +297,14 @@ boolean flag1; if (entitypiglin.isAdult()) { @@ -78,9 +97,9 @@ + } + // CraftBukkit end } else if (!flag1) { - boolean flag2 = entitypiglin.equipItemIfPossible(itemstack); + boolean flag2 = !entitypiglin.equipItemIfPossible(itemstack).isEmpty(); -@@ -291,7 +307,7 @@ +@@ -300,7 +317,7 @@ if (!flag1) { ItemStack itemstack1 = entitypiglin.getMainHandItem(); @@ -89,7 +108,7 @@ putInInventory(entitypiglin, itemstack1); } else { throwItems(entitypiglin, Collections.singletonList(itemstack1)); -@@ -368,7 +384,7 @@ +@@ -377,7 +394,7 @@ return false; } else if (isAdmiringDisabled(entitypiglin) && entitypiglin.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET)) { return false; @@ -98,7 +117,7 @@ return isNotHoldingLovedItemInOffHand(entitypiglin); } else { boolean flag = entitypiglin.canAddToInventory(itemstack); -@@ -377,6 +393,12 @@ +@@ -386,6 +403,12 @@ } } @@ -111,7 +130,7 @@ protected static boolean isLovedItem(ItemStack itemstack) { return itemstack.is(TagsItem.PIGLIN_LOVED); } -@@ -472,7 +494,7 @@ +@@ -481,7 +504,7 @@ } protected static boolean canAdmire(EntityPiglin entitypiglin, ItemStack itemstack) { @@ -120,7 +139,7 @@ } protected static void wasHurtBy(EntityPiglin entitypiglin, EntityLiving entityliving) { -@@ -739,6 +761,12 @@ +@@ -738,6 +761,12 @@ return entitypiglin.getBrain().hasMemoryValue(MemoryModuleType.ADMIRING_ITEM); } @@ -133,7 +152,7 @@ private static boolean isBarterCurrency(ItemStack itemstack) { return itemstack.is(PiglinAI.BARTERING_ITEM); } -@@ -776,7 +804,7 @@ +@@ -775,7 +804,7 @@ } private static boolean isNotHoldingLovedItemInOffHand(EntityPiglin entitypiglin) { diff --git a/nms-patches/net/minecraft/world/entity/monster/warden/Warden.patch b/nms-patches/net/minecraft/world/entity/monster/warden/Warden.patch index ea698caee..c5be45a19 100644 --- a/nms-patches/net/minecraft/world/entity/monster/warden/Warden.patch +++ b/nms-patches/net/minecraft/world/entity/monster/warden/Warden.patch @@ -61,3 +61,12 @@ } @Override +@@ -560,7 +560,7 @@ + + public void setAttackTarget(EntityLiving entityliving) { + this.getBrain().eraseMemory(MemoryModuleType.ROAR_TARGET); +- this.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, (Object) entityliving); ++ this.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, entityliving); // CraftBukkit - decompile error + this.getBrain().eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); + SonicBoom.setCooldown(this, 200); + } diff --git a/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch b/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch index 813f6a004..92f87d2dd 100644 --- a/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch +++ b/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch @@ -72,21 +72,21 @@ Logger logger = EntityVillager.LOGGER; Objects.requireNonNull(logger); -@@ -818,7 +838,12 @@ - } +@@ -820,7 +840,12 @@ + } - entitywitch.setPersistenceRequired(); -- worldserver.addFreshEntityWithPassengers(entitywitch); -+ // CraftBukkit start -+ if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) { -+ return; -+ } -+ worldserver.addFreshEntityWithPassengers(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); -+ // CraftBukkit end - this.releaseAllPois(); - this.discard(); - } else { -@@ -904,7 +929,7 @@ + entitywitch.setPersistenceRequired(); +- worldserver.addFreshEntityWithPassengers(entitywitch); ++ // CraftBukkit start ++ if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) { ++ return; ++ } ++ worldserver.addFreshEntityWithPassengers(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); ++ // CraftBukkit end + this.releaseAllPois(); + this.discard(); + } else { +@@ -909,7 +934,7 @@ }).limit(5L).collect(Collectors.toList()); if (list1.size() >= j) { @@ -95,7 +95,7 @@ list.forEach(SensorGolemLastSeen::golemDetected); } } -@@ -961,7 +986,7 @@ +@@ -966,7 +991,7 @@ @Override public void startSleeping(BlockPosition blockposition) { super.startSleeping(blockposition); @@ -104,7 +104,7 @@ this.brain.eraseMemory(MemoryModuleType.WALK_TARGET); this.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); } -@@ -969,7 +994,7 @@ +@@ -974,7 +999,7 @@ @Override public void stopSleeping() { super.stopSleeping(); diff --git a/nms-patches/net/minecraft/world/entity/npc/InventoryCarrier.patch b/nms-patches/net/minecraft/world/entity/npc/InventoryCarrier.patch index 9ff6004c6..977c92582 100644 --- a/nms-patches/net/minecraft/world/entity/npc/InventoryCarrier.patch +++ b/nms-patches/net/minecraft/world/entity/npc/InventoryCarrier.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/InventoryCarrier.java +++ b/net/minecraft/world/entity/npc/InventoryCarrier.java -@@ -20,6 +20,13 @@ +@@ -23,6 +23,13 @@ return; } diff --git a/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch b/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch index e832fe7ad..c19f83c2c 100644 --- a/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch +++ b/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/npc/MobSpawnerTrader.java +++ b/net/minecraft/world/entity/npc/MobSpawnerTrader.java -@@ -113,7 +113,7 @@ +@@ -110,7 +110,7 @@ return false; } -- EntityVillagerTrader entityvillagertrader = (EntityVillagerTrader) EntityTypes.WANDERING_TRADER.spawn(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition2, EnumMobSpawn.EVENT, false, false); -+ EntityVillagerTrader entityvillagertrader = (EntityVillagerTrader) EntityTypes.WANDERING_TRADER.spawn(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition2, EnumMobSpawn.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit +- EntityVillagerTrader entityvillagertrader = (EntityVillagerTrader) EntityTypes.WANDERING_TRADER.spawn(worldserver, blockposition2, EnumMobSpawn.EVENT); ++ EntityVillagerTrader entityvillagertrader = (EntityVillagerTrader) EntityTypes.WANDERING_TRADER.spawn(worldserver, blockposition2, EnumMobSpawn.EVENT, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit if (entityvillagertrader != null) { for (int i = 0; i < 2; ++i) { -@@ -121,7 +121,7 @@ +@@ -118,7 +118,7 @@ } this.serverLevelData.setWanderingTraderId(entityvillagertrader.getUUID()); @@ -18,12 +18,12 @@ entityvillagertrader.setWanderTarget(blockposition1); entityvillagertrader.restrictTo(blockposition1, 16); return true; -@@ -136,7 +136,7 @@ +@@ -133,7 +133,7 @@ BlockPosition blockposition = this.findSpawnPositionNear(worldserver, entityvillagertrader.blockPosition(), i); if (blockposition != null) { -- EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawn(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition, EnumMobSpawn.EVENT, false, false); -+ EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawn(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition, EnumMobSpawn.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit +- EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawn(worldserver, blockposition, EnumMobSpawn.EVENT); ++ EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawn(worldserver, blockposition, EnumMobSpawn.EVENT, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit if (entityllamatrader != null) { entityllamatrader.setLeashedTo(entityvillagertrader, true); diff --git a/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch b/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch index 334483347..1f6086572 100644 --- a/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch +++ b/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/EntityHuman.java +++ b/net/minecraft/world/entity/player/EntityHuman.java -@@ -117,6 +117,20 @@ +@@ -115,6 +115,20 @@ import net.minecraft.world.scores.ScoreboardTeamBase; import org.slf4j.Logger; @@ -21,7 +21,7 @@ public abstract class EntityHuman extends EntityLiving { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -130,7 +144,8 @@ +@@ -128,7 +142,8 @@ public static final float SWIMMING_BB_HEIGHT = 0.6F; public static final float DEFAULT_EYE_HEIGHT = 1.62F; public static final EntitySize STANDING_DIMENSIONS = EntitySize.scalable(0.6F, 1.8F); @@ -31,7 +31,7 @@ private static final int FLY_ACHIEVEMENT_SPEED = 25; private static final DataWatcherObject DATA_PLAYER_ABSORPTION_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.FLOAT); private static final DataWatcherObject DATA_SCORE_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.INT); -@@ -140,10 +155,10 @@ +@@ -138,10 +153,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); @@ -41,10 +41,10 @@ public Container containerMenu; - protected FoodMetaData foodData = new FoodMetaData(); + protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor - protected WardenSpawnTracker wardenSpawnTracker = new WardenSpawnTracker(0, 0, 0); protected int jumpTriggerTime; public float oBob; -@@ -174,6 +189,16 @@ + public float bob; +@@ -169,6 +184,16 @@ @Nullable public EntityFishingHook fishing; @@ -58,10 +58,10 @@ + } + // CraftBukkit end + - public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile, @Nullable ProfilePublicKey profilepublickey) { + public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile) { super(EntityTypes.PLAYER, world); this.lastItemInMainHand = ItemStack.EMPTY; -@@ -315,7 +340,7 @@ +@@ -308,7 +333,7 @@ ItemStack itemstack = this.getItemBySlot(EnumItemSlot.HEAD); if (itemstack.is(Items.TURTLE_HELMET) && !this.isEyeInFluid(TagsFluid.WATER)) { @@ -70,7 +70,7 @@ } } -@@ -507,7 +532,8 @@ +@@ -502,7 +527,8 @@ if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL && this.level.getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { if (this.getHealth() < this.getMaxHealth() && this.tickCount % 20 == 0) { @@ -80,7 +80,7 @@ } if (this.foodData.needsFood() && this.tickCount % 10 == 0) { -@@ -671,6 +697,13 @@ +@@ -666,6 +692,13 @@ @Nullable public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1) { @@ -94,7 +94,7 @@ if (itemstack.isEmpty()) { return null; } else { -@@ -705,6 +738,33 @@ +@@ -700,6 +733,33 @@ entityitem.setDeltaMovement((double) (-f3 * f2 * 0.3F) + Math.cos((double) f5) * (double) f6, (double) (-f1 * 0.3F + 0.1F + (this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (f4 * f2 * 0.3F) + Math.sin((double) f5) * (double) f6); } @@ -128,43 +128,25 @@ return entityitem; } } -@@ -781,7 +841,7 @@ - this.setScore(nbttagcompound.getInt("Score")); - this.foodData.readAdditionalSaveData(nbttagcompound); - if (nbttagcompound.contains("warden_spawn_tracker", 10)) { -- DataResult dataresult = WardenSpawnTracker.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("warden_spawn_tracker"))); -+ DataResult dataresult = WardenSpawnTracker.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("warden_spawn_tracker"))); // CraftBukkit - decompile error - Logger logger = EntityHuman.LOGGER; - - Objects.requireNonNull(logger); -@@ -805,7 +865,7 @@ +@@ -790,7 +850,7 @@ } if (nbttagcompound.contains("LastDeathLocation", 10)) { -- DataResult dataresult1 = GlobalPos.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("LastDeathLocation")); -+ DataResult dataresult1 = GlobalPos.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("LastDeathLocation")); // CraftBukkit - decompile error - Logger logger1 = EntityHuman.LOGGER; +- DataResult dataresult = GlobalPos.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("LastDeathLocation")); ++ DataResult dataresult = GlobalPos.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("LastDeathLocation")); // CraftBukkit - decompile error + Logger logger = EntityHuman.LOGGER; - Objects.requireNonNull(logger1); -@@ -827,7 +887,7 @@ - nbttagcompound.putInt("XpSeed", this.enchantmentSeed); - nbttagcompound.putInt("Score", this.getScore()); - this.foodData.addAdditionalSaveData(nbttagcompound); -- DataResult dataresult = WardenSpawnTracker.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.wardenSpawnTracker); -+ DataResult dataresult = WardenSpawnTracker.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.wardenSpawnTracker); // CraftBukkit - decompile error - Logger logger = EntityHuman.LOGGER; - - Objects.requireNonNull(logger); -@@ -845,7 +905,7 @@ + Objects.requireNonNull(logger); +@@ -823,7 +883,7 @@ } this.getLastDeathLocation().flatMap((globalpos) -> { -- DataResult dataresult1 = GlobalPos.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, globalpos); -+ DataResult dataresult1 = GlobalPos.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, globalpos); // CraftBukkit - decompile error - Logger logger1 = EntityHuman.LOGGER; +- DataResult dataresult = GlobalPos.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, globalpos); ++ DataResult dataresult = GlobalPos.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, globalpos); // CraftBukkit - decompile error + Logger logger = EntityHuman.LOGGER; - Objects.requireNonNull(logger1); -@@ -872,12 +932,12 @@ + Objects.requireNonNull(logger); +@@ -850,12 +910,12 @@ return false; } else { if (!this.level.isClientSide) { @@ -179,7 +161,7 @@ } if (this.level.getDifficulty() == EnumDifficulty.EASY) { -@@ -889,7 +949,13 @@ +@@ -867,7 +927,13 @@ } } @@ -194,7 +176,7 @@ } } } -@@ -909,10 +975,29 @@ +@@ -887,10 +953,29 @@ } public boolean canHarmPlayer(EntityHuman entityhuman) { @@ -227,7 +209,7 @@ } @Override -@@ -954,8 +1039,13 @@ +@@ -932,8 +1017,13 @@ } } @@ -242,7 +224,7 @@ if (!this.isInvulnerableTo(damagesource)) { f = this.getDamageAfterArmorAbsorb(damagesource, f); f = this.getDamageAfterMagicAbsorb(damagesource, f); -@@ -970,7 +1060,7 @@ +@@ -948,7 +1038,7 @@ } if (f != 0.0F) { @@ -251,7 +233,7 @@ float f3 = this.getHealth(); this.setHealth(this.getHealth() - f); -@@ -981,6 +1071,7 @@ +@@ -959,6 +1049,7 @@ } } @@ -259,7 +241,7 @@ } @Override -@@ -1140,7 +1231,7 @@ +@@ -1122,7 +1213,7 @@ f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; @@ -268,7 +250,7 @@ if (f > 0.0F || f1 > 0.0F) { boolean flag = f2 > 0.9F; boolean flag1 = false; -@@ -1179,8 +1270,15 @@ +@@ -1161,8 +1252,15 @@ if (entity instanceof EntityLiving) { f3 = ((EntityLiving) entity).getHealth(); if (j > 0 && !entity.isOnFire()) { @@ -286,7 +268,7 @@ } } -@@ -1208,8 +1306,11 @@ +@@ -1190,8 +1288,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) { @@ -299,7 +281,7 @@ } } -@@ -1218,9 +1319,26 @@ +@@ -1200,9 +1301,26 @@ } if (entity instanceof EntityPlayer && entity.hurtMarked) { @@ -326,7 +308,7 @@ } if (flag2) { -@@ -1265,7 +1383,14 @@ +@@ -1247,7 +1365,14 @@ this.awardStat(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F)); if (j > 0) { @@ -342,7 +324,7 @@ } if (this.level instanceof WorldServer && f5 > 2.0F) { -@@ -1275,12 +1400,17 @@ +@@ -1257,12 +1382,17 @@ } } @@ -361,7 +343,7 @@ } } -@@ -1362,6 +1492,12 @@ +@@ -1339,6 +1469,12 @@ } public Either startSleepInBed(BlockPosition blockposition) { @@ -374,7 +356,7 @@ this.startSleeping(blockposition); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1446,9 +1582,9 @@ +@@ -1423,9 +1559,9 @@ super.jumpFromGround(); this.awardStat(StatisticList.JUMP); if (this.isSprinting()) { @@ -386,7 +368,7 @@ } } -@@ -1482,7 +1618,11 @@ +@@ -1459,7 +1595,11 @@ this.setDeltaMovement(vec3d2.x, d3 * 0.6D, vec3d2.z); this.flyingSpeed = f; this.resetFallDistance(); @@ -399,7 +381,7 @@ } else { super.travel(vec3d); } -@@ -1517,19 +1657,19 @@ +@@ -1494,19 +1634,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); @@ -422,7 +404,7 @@ } } else if (this.onClimbable()) { if (d1 > 0.0D) { -@@ -1540,13 +1680,13 @@ +@@ -1517,13 +1657,13 @@ if (i > 0) { if (this.isSprinting()) { this.awardStat(StatisticList.SPRINT_ONE_CM, i); @@ -439,7 +421,7 @@ } } } else if (this.isFallFlying()) { -@@ -1617,12 +1757,24 @@ +@@ -1589,12 +1729,24 @@ } public void startFallFlying() { @@ -465,7 +447,7 @@ } @Override -@@ -1713,10 +1865,21 @@ +@@ -1685,10 +1837,21 @@ return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2); } @@ -488,7 +470,7 @@ } } -@@ -1802,13 +1965,20 @@ +@@ -1774,13 +1937,20 @@ @Override public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { @@ -512,7 +494,7 @@ } } -@@ -1847,26 +2017,31 @@ +@@ -1819,26 +1989,31 @@ protected void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level.getGameTime()) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch index 14800b33f..1f16586c3 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityArrow.java +++ b/net/minecraft/world/entity/projectile/EntityArrow.java -@@ -45,6 +45,12 @@ +@@ -46,6 +46,12 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.shapes.VoxelShape; @@ -13,7 +13,7 @@ public abstract class EntityArrow extends IProjectile { private static final double ARROW_BASE_DAMAGE = 2.0D; -@@ -211,7 +217,7 @@ +@@ -212,7 +218,7 @@ } if (object != null && !flag) { @@ -22,7 +22,7 @@ this.hasImpulse = true; } -@@ -358,7 +364,13 @@ +@@ -359,7 +365,13 @@ int k = entity.getRemainingFireTicks(); if (this.isOnFire() && !flag) { @@ -37,7 +37,7 @@ } if (entity.hurt(damagesource, (float) i)) { -@@ -521,7 +533,22 @@ +@@ -522,7 +534,22 @@ @Override public void playerTouch(EntityHuman entityhuman) { if (!this.level.isClientSide && (this.inGround || this.isNoPhysics()) && this.shakeTime <= 0) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch index 9ae1ff919..a63e15e5c 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch @@ -16,7 +16,7 @@ public class EntityEgg extends EntityProjectileThrowable { public EntityEgg(EntityTypes entitytypes, World world) { -@@ -48,20 +57,40 @@ +@@ -48,22 +57,42 @@ protected void onHit(MovingObjectPosition movingobjectposition) { super.onHit(movingobjectposition); if (!this.level.isClientSide) { @@ -47,17 +47,20 @@ + hatchingType = event.getHatchingType(); + } -- entitychicken.setAge(-24000); -- entitychicken.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F); -- this.level.addFreshEntity(entitychicken); +- if (entitychicken != null) { +- entitychicken.setAge(-24000); +- entitychicken.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F); +- this.level.addFreshEntity(entitychicken); + if (hatching) { + for (int i = 0; i < b0; ++i) { + Entity entity = level.getWorld().createEntity(new org.bukkit.Location(level.getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass()); -+ if (entity.getBukkitEntity() instanceof Ageable) { -+ ((Ageable) entity.getBukkitEntity()).setBaby(); ++ if (entity != null) { ++ if (entity.getBukkitEntity() instanceof Ageable) { ++ ((Ageable) entity.getBukkitEntity()).setBaby(); ++ } ++ level.getWorld().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); + } -+ level.getWorld().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); -+ } + } } + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch index a9d191d1c..d1d1d52ce 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch @@ -14,15 +14,12 @@ public class EntityEnderPearl extends EntityProjectileThrowable { public EntityEnderPearl(EntityTypes entitytypes, World world) { -@@ -53,21 +60,34 @@ +@@ -53,23 +60,36 @@ EntityPlayer entityplayer = (EntityPlayer) entity; if (entityplayer.connection.getConnection().isConnected() && entityplayer.level == this.level && !entityplayer.isSleeping()) { - if (this.random.nextFloat() < 0.05F && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { - EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(this.level); -- -- entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); -- this.level.addFreshEntity(entityendermite); + // CraftBukkit start - Fire PlayerTeleportEvent + org.bukkit.craftbukkit.entity.CraftPlayer player = entityplayer.getBukkitEntity(); + org.bukkit.Location location = getBukkitEntity().getLocation(); @@ -36,14 +33,24 @@ + if (this.random.nextFloat() < 0.05F && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { + EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(this.level); + -+ entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); -+ this.level.addFreshEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL); ++ if (entityendermite != null) { ++ entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); ++ this.level.addFreshEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL); ++ } + } -+ + +- if (entityendermite != null) { +- entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); +- this.level.addFreshEntity(entityendermite); + if (entity.isPassenger()) { + entity.stopRiding(); -+ } -+ + } +- } + +- if (entity.isPassenger()) { +- entityplayer.dismountTo(this.getX(), this.getY(), this.getZ()); +- } else { +- entity.teleportTo(this.getX(), this.getY(), this.getZ()); + entityplayer.connection.teleport(teleEvent.getTo()); + entity.resetFallDistance(); + CraftEventFactory.entityDamage = this; @@ -51,19 +58,13 @@ + CraftEventFactory.entityDamage = null; } - -- if (entity.isPassenger()) { -- entityplayer.dismountTo(this.getX(), this.getY(), this.getZ()); -- } else { -- entity.teleportTo(this.getX(), this.getY(), this.getZ()); -- } -- - entity.resetFallDistance(); - entity.hurt(DamageSource.FALL, 5.0F); + // CraftBukkit end } } else if (entity != null) { entity.teleportTo(this.getX(), this.getY(), this.getZ()); -@@ -96,7 +116,7 @@ +@@ -98,7 +118,7 @@ public Entity changeDimension(WorldServer worldserver) { Entity entity = this.getOwner(); diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityEnderSignal.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityEnderSignal.patch index c6c2cbd0c..b539557d1 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityEnderSignal.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityEnderSignal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityEnderSignal.java +++ b/net/minecraft/world/entity/projectile/EntityEnderSignal.java -@@ -38,7 +38,7 @@ +@@ -36,7 +36,7 @@ } public void setItem(ItemStack itemstack) { @@ -9,7 +9,7 @@ this.getEntityData().set(EntityEnderSignal.DATA_ITEM_STACK, (ItemStack) SystemUtils.make(itemstack.copy(), (itemstack1) -> { itemstack1.setCount(1); })); -@@ -182,7 +182,7 @@ +@@ -180,7 +180,7 @@ public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { ItemStack itemstack = ItemStack.of(nbttagcompound.getCompound("Item")); diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch index 3dd3b632d..34cb63ad9 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityEvokerFangs.java +++ b/net/minecraft/world/entity/projectile/EntityEvokerFangs.java -@@ -130,7 +130,9 @@ +@@ -128,7 +128,9 @@ if (entityliving.isAlive() && !entityliving.isInvulnerable() && entityliving != entityliving1) { if (entityliving1 == null) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch index eedb848ce..fddbf1c4d 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityFireball.java +++ b/net/minecraft/world/entity/projectile/EntityFireball.java -@@ -14,11 +14,15 @@ +@@ -15,11 +15,15 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.Vec3D; @@ -16,7 +16,7 @@ protected EntityFireball(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -28,6 +32,12 @@ +@@ -29,6 +33,12 @@ this(entitytypes, world); this.moveTo(d0, d1, d2, this.getYRot(), this.getXRot()); this.reapplyPosition(); @@ -29,7 +29,7 @@ double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5); if (d6 != 0.0D) { -@@ -74,7 +84,13 @@ +@@ -75,7 +85,13 @@ MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity); if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { @@ -44,7 +44,7 @@ } this.checkInsideBlocks(); -@@ -160,6 +176,11 @@ +@@ -161,6 +177,11 @@ if (entity != null) { if (!this.level.isClientSide) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch index 44bfe5ecc..cdd7d162a 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityFireworks.java +++ b/net/minecraft/world/entity/projectile/EntityFireworks.java -@@ -29,15 +29,17 @@ +@@ -29,6 +29,8 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -9,17 +9,6 @@ public class EntityFireworks extends IProjectile implements ItemSupplier { public static final DataWatcherObject DATA_ID_FIREWORKS_ITEM = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.ITEM_STACK); - private static final DataWatcherObject DATA_ATTACHED_TO_TARGET = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.OPTIONAL_UNSIGNED_INT); - public static final DataWatcherObject DATA_SHOT_AT_ANGLE = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.BOOLEAN); -- private int life; -+ public int life; // PAIL private -> public - public int lifetime; - @Nullable -- private EntityLiving attachedToEntity; -+ public EntityLiving attachedToEntity; // PAIL private -> public - - public EntityFireworks(EntityTypes entitytypes, World world) { - super(entitytypes, world); @@ -144,7 +146,7 @@ MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity); diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch index 8213c2918..7890a87d9 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityFishingHook.java +++ b/net/minecraft/world/entity/projectile/EntityFishingHook.java -@@ -45,6 +45,12 @@ +@@ -46,6 +46,12 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -13,7 +13,7 @@ public class EntityFishingHook extends IProjectile { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -66,6 +72,12 @@ +@@ -67,6 +73,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 = RandomSource.create(); -@@ -260,7 +272,7 @@ +@@ -261,7 +273,7 @@ private void checkCollision() { MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity); @@ -35,7 +35,7 @@ } @Override -@@ -307,6 +319,10 @@ +@@ -308,6 +320,10 @@ this.timeUntilLured = 0; this.timeUntilHooked = 0; this.getEntityData().set(EntityFishingHook.DATA_BITING, false); @@ -46,7 +46,7 @@ } } else { float f; -@@ -340,6 +356,13 @@ +@@ -341,6 +357,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; -@@ -376,8 +399,10 @@ +@@ -377,8 +400,10 @@ this.timeUntilHooked = MathHelper.nextInt(this.random, 20, 80); } } else { @@ -73,7 +73,7 @@ } } -@@ -444,6 +469,14 @@ +@@ -445,6 +470,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); -@@ -459,6 +492,15 @@ +@@ -460,6 +493,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(); -@@ -466,7 +508,11 @@ +@@ -467,7 +509,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); @@ -117,7 +117,7 @@ if (itemstack1.is(TagsItem.FISHES)) { entityhuman.awardStat(StatisticList.FISH_CAUGHT, 1); } -@@ -476,8 +522,25 @@ +@@ -477,8 +523,25 @@ } if (this.onGround) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch index 9cad1f9bc..32a91fe40 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityLargeFireball.java +++ b/net/minecraft/world/entity/projectile/EntityLargeFireball.java -@@ -11,17 +11,21 @@ +@@ -10,17 +10,21 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.MovingObjectPositionEntity; @@ -22,24 +22,24 @@ } @Override -@@ -30,7 +34,15 @@ +@@ -29,7 +33,15 @@ if (!this.level.isClientSide) { boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); -- this.level.explode((Entity) null, this.getX(), this.getY(), this.getZ(), (float) this.explosionPower, flag, flag ? Explosion.Effect.DESTROY : Explosion.Effect.NONE); +- this.level.explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionPower, flag, World.a.MOB); + // CraftBukkit start - fire ExplosionPrimeEvent + ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); + this.level.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + // give 'this' instead of (Entity) null so we know what causes the damage -+ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), flag ? Explosion.Effect.DESTROY : Explosion.Effect.NONE); ++ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); + } + // CraftBukkit end this.discard(); } -@@ -61,7 +73,8 @@ +@@ -60,7 +72,8 @@ public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { super.readAdditionalSaveData(nbttagcompound); if (nbttagcompound.contains("ExplosionPower", 99)) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch index b0228f150..f5157116b 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch @@ -17,7 +17,7 @@ public class EntityPotion extends EntityProjectileThrowable implements ItemSupplier { public static final double SPLASH_RANGE = 4.0D; -@@ -98,7 +108,7 @@ +@@ -100,7 +110,7 @@ if (flag) { this.applyWater(); @@ -26,7 +26,7 @@ if (this.isLingering()) { this.makeAreaOfEffectCloud(itemstack, potionregistry); } else { -@@ -144,6 +154,7 @@ +@@ -149,6 +159,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(); -@@ -162,21 +173,47 @@ +@@ -167,21 +178,47 @@ d1 = 1.0D; } @@ -96,7 +96,7 @@ } } } -@@ -212,7 +249,14 @@ +@@ -217,7 +254,14 @@ entityareaeffectcloud.setFixedColor(nbttagcompound.getInt("CustomPotionColor")); } @@ -112,7 +112,7 @@ } public boolean isLingering() { -@@ -223,13 +267,25 @@ +@@ -228,13 +272,25 @@ IBlockData iblockdata = this.level.getBlockState(blockposition); if (iblockdata.is(TagsBlock.FIRE)) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch index a5f75dd8c..62ec7ee76 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/EntityThrownTrident.java +++ b/net/minecraft/world/entity/projectile/EntityThrownTrident.java -@@ -156,7 +156,7 @@ - - entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition)); - entitylightning.setCause(entity1 instanceof EntityPlayer ? (EntityPlayer) entity1 : null); -- this.level.addFreshEntity(entitylightning); -+ ((WorldServer) this.level).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit - soundeffect = SoundEffects.TRIDENT_THUNDER; - f1 = 5.0F; - } +@@ -157,7 +157,7 @@ + if (entitylightning != null) { + entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition)); + entitylightning.setCause(entity1 instanceof EntityPlayer ? (EntityPlayer) entity1 : null); +- this.level.addFreshEntity(entitylightning); ++ ((WorldServer) this.level).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit + soundeffect = SoundEffects.TRIDENT_THUNDER; + f1 = 5.0F; + } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch index 709a78c88..7498e9828 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch @@ -10,11 +10,11 @@ + } + + public String getPotionType() { -+ return IRegistry.POTION.getKey(this.potion).toString(); ++ return BuiltInRegistries.POTION.getKey(this.potion).toString(); + } + + public void setPotionType(String string) { -+ this.potion = IRegistry.POTION.get(new net.minecraft.resources.MinecraftKey(string)); ++ this.potion = BuiltInRegistries.POTION.get(new net.minecraft.resources.MinecraftKey(string)); + this.getEntityData().set(EntityTippedArrow.ID_EFFECT_COLOR, PotionUtil.getColor((Collection) PotionUtil.getAllEffects(this.potion, (Collection) this.effects))); + } + diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch index bf24ae7df..f59e6ad66 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityWitherSkull.java +++ b/net/minecraft/world/entity/projectile/EntityWitherSkull.java -@@ -21,6 +21,8 @@ +@@ -20,6 +20,8 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.MovingObjectPositionEntity; @@ -9,7 +9,7 @@ public class EntityWitherSkull extends EntityFireball { private static final DataWatcherObject DATA_DANGEROUS = DataWatcher.defineId(EntityWitherSkull.class, DataWatcherRegistry.BOOLEAN); -@@ -64,7 +66,7 @@ +@@ -63,7 +65,7 @@ if (entity.isAlive()) { this.doEnchantDamageEffects(entityliving, entity); } else { @@ -18,7 +18,7 @@ } } } else { -@@ -81,7 +83,7 @@ +@@ -80,7 +82,7 @@ } if (b0 > 0) { @@ -27,18 +27,18 @@ } } -@@ -94,7 +96,15 @@ +@@ -91,7 +93,15 @@ + protected void onHit(MovingObjectPosition movingobjectposition) { + super.onHit(movingobjectposition); if (!this.level.isClientSide) { - Explosion.Effect explosion_effect = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE; - -- this.level.explode(this, this.getX(), this.getY(), this.getZ(), 1.0F, false, explosion_effect); +- this.level.explode(this, this.getX(), this.getY(), this.getZ(), 1.0F, false, World.a.MOB); + // CraftBukkit start -+ // this.level.createExplosion(this, this.locX(), this.locY(), this.locZ(), 1.0F, false, explosion_effect); ++ // this.level.explode(this, this.getX(), this.getY(), this.getZ(), 1.0F, false, World.a.MOB); + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 1.0F, false); + this.level.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), explosion_effect); ++ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); + } + // CraftBukkit end this.discard(); diff --git a/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch b/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch index aea8e7ee5..2254dcf3c 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/IProjectile.java +++ b/net/minecraft/world/entity/projectile/IProjectile.java -@@ -22,6 +22,10 @@ +@@ -23,6 +23,10 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public abstract class IProjectile extends Entity { @Nullable -@@ -31,6 +35,10 @@ +@@ -32,6 +36,10 @@ private boolean leftOwner; private boolean hasBeenShot; @@ -22,7 +22,7 @@ IProjectile(EntityTypes entitytypes, World world) { super(entitytypes, world); } -@@ -40,6 +48,7 @@ +@@ -41,6 +49,7 @@ this.ownerUUID = entity.getUUID(); this.cachedOwner = entity; } @@ -30,7 +30,7 @@ } -@@ -143,6 +152,16 @@ +@@ -144,6 +153,16 @@ this.setDeltaMovement(this.getDeltaMovement().add(vec3d.x, entity.isOnGround() ? 0.0D : vec3d.y, vec3d.z)); } @@ -47,7 +47,7 @@ protected void onHit(MovingObjectPosition movingobjectposition) { MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType(); -@@ -163,6 +182,11 @@ +@@ -164,6 +183,11 @@ protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) {} protected void onHitBlock(MovingObjectPositionBlock movingobjectpositionblock) { diff --git a/nms-patches/net/minecraft/world/entity/raid/Raid.patch b/nms-patches/net/minecraft/world/entity/raid/Raid.patch index 5ecc24172..07dd23d35 100644 --- a/nms-patches/net/minecraft/world/entity/raid/Raid.patch +++ b/nms-patches/net/minecraft/world/entity/raid/Raid.patch @@ -74,38 +74,38 @@ this.stop(); return; } -@@ -539,6 +554,10 @@ - Raid.Wave[] araid_wave = Raid.Wave.VALUES; +@@ -540,6 +555,10 @@ int j = araid_wave.length; + int k = 0; + // CraftBukkit start + EntityRaider leader = null; + List raiders = new java.util.ArrayList<>(); + // CraftBukkit end - for (int k = 0; k < j; ++k) { + while (k < j) { Raid.Wave raid_wave = araid_wave[k]; int l = this.getDefaultNumSpawns(raid_wave, i, flag1) + this.getPotentialBonusSpawns(raid_wave, this.random, i, difficultydamagescaler, flag1); -@@ -551,9 +570,11 @@ - entityraider.setPatrolLeader(true); - this.setLeader(i, entityraider); - flag = true; -+ leader = entityraider; // CraftBukkit - } +@@ -555,9 +574,11 @@ + entityraider.setPatrolLeader(true); + this.setLeader(i, entityraider); + flag = true; ++ leader = entityraider; // CraftBukkit + } - this.joinRaid(i, entityraider, blockposition, false); -+ raiders.add(entityraider); // CraftBukkit - if (raid_wave.entityType == EntityTypes.RAVAGER) { - EntityRaider entityraider1 = null; - -@@ -572,6 +593,7 @@ - this.joinRaid(i, entityraider1, blockposition, false); - entityraider1.moveTo(blockposition, 0.0F, 0.0F); - entityraider1.startRiding(entityraider); + this.joinRaid(i, entityraider, blockposition, false); + raiders.add(entityraider); // CraftBukkit - } - } - } -@@ -581,6 +603,7 @@ + if (raid_wave.entityType == EntityTypes.RAVAGER) { + EntityRaider entityraider1 = null; + +@@ -576,6 +597,7 @@ + this.joinRaid(i, entityraider1, blockposition, false); + entityraider1.moveTo(blockposition, 0.0F, 0.0F); + entityraider1.startRiding(entityraider); ++ raiders.add(entityraider); // CraftBukkit + } + } + +@@ -593,6 +615,7 @@ ++this.groupsSpawned; this.updateBossbar(); this.setDirty(); @@ -113,7 +113,7 @@ } public void joinRaid(int i, EntityRaider entityraider, @Nullable BlockPosition blockposition, boolean flag) { -@@ -596,7 +619,7 @@ +@@ -608,7 +631,7 @@ entityraider.finalizeSpawn(this.level, this.level.getCurrentDifficultyAt(blockposition), EnumMobSpawn.EVENT, (GroupDataEntity) null, (NBTTagCompound) null); entityraider.applyRaidBuffs(i, false); entityraider.setOnGround(true); @@ -122,7 +122,7 @@ } } -@@ -846,6 +869,12 @@ +@@ -858,6 +881,12 @@ this.heroesOfTheVillage.add(entity.getUUID()); } diff --git a/nms-patches/net/minecraft/world/entity/vehicle/ChestBoat.patch b/nms-patches/net/minecraft/world/entity/vehicle/ChestBoat.patch index c79b666b7..e3eded3fa 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/ChestBoat.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/ChestBoat.patch @@ -14,7 +14,7 @@ public class ChestBoat extends EntityBoat implements HasCustomInventoryScreen, ContainerEntity { -@@ -215,4 +222,51 @@ +@@ -218,4 +225,51 @@ public void clearItemStacks() { this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); } diff --git a/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch b/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch index bcb67508b..e46bdb3bb 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/EntityBoat.java +++ b/net/minecraft/world/entity/vehicle/EntityBoat.java -@@ -51,6 +51,15 @@ +@@ -53,6 +53,15 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -13,10 +13,10 @@ +import org.bukkit.event.vehicle.VehicleMoveEvent; +// CraftBukkit end + - public class EntityBoat extends Entity { + public class EntityBoat extends Entity implements VariantHolder { private static final DataWatcherObject DATA_ID_HURT = DataWatcher.defineId(EntityBoat.class, DataWatcherRegistry.INT); -@@ -91,6 +100,14 @@ +@@ -93,6 +102,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]; -@@ -160,6 +177,19 @@ +@@ -162,6 +179,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); -@@ -168,6 +198,15 @@ +@@ -170,6 +200,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.destroy(damagesource); } -@@ -207,9 +246,29 @@ +@@ -209,9 +248,29 @@ public void push(Entity entity) { if (entity instanceof EntityBoat) { if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) { @@ -97,7 +97,7 @@ super.push(entity); } -@@ -262,6 +321,7 @@ +@@ -276,6 +335,7 @@ return this.getDirection().getClockWise(); } @@ -105,7 +105,7 @@ @Override public void tick() { this.oldStatus = this.status; -@@ -302,6 +362,22 @@ +@@ -316,6 +376,22 @@ this.setDeltaMovement(Vec3D.ZERO); } @@ -128,7 +128,7 @@ this.tickBubbleColumn(); for (int i = 0; i <= 1; ++i) { -@@ -809,6 +885,11 @@ +@@ -823,6 +899,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; -@@ -822,6 +903,7 @@ +@@ -836,6 +917,7 @@ } } } diff --git a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch index e597ed5b7..b1d15ae89 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java +++ b/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java -@@ -48,6 +48,15 @@ +@@ -47,6 +47,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); -@@ -90,6 +99,17 @@ +@@ -89,6 +98,17 @@ private double lyd; private double lzd; @@ -34,7 +34,7 @@ protected EntityMinecartAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); this.blocksBuilding = true; -@@ -216,6 +236,19 @@ +@@ -215,6 +235,19 @@ if (this.isInvulnerableTo(damagesource)) { return false; } else { @@ -54,7 +54,7 @@ this.setHurtDir(-this.getHurtDir()); this.setHurtTime(10); this.markHurt(); -@@ -224,6 +257,15 @@ +@@ -223,6 +256,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(); -@@ -285,6 +327,14 @@ +@@ -284,6 +326,14 @@ @Override public void tick() { @@ -85,7 +85,7 @@ if (this.getHurtTime() > 0) { this.setHurtTime(this.getHurtTime() - 1); } -@@ -294,7 +344,7 @@ +@@ -293,7 +343,7 @@ } this.checkOutOfWorld(); @@ -94,7 +94,7 @@ double d0; if (this.level.isClientSide) { -@@ -360,6 +410,18 @@ +@@ -359,6 +409,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)); -@@ -368,8 +430,26 @@ +@@ -367,8 +429,26 @@ Entity entity = (Entity) list.get(l); if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.isVehicle() && !entity.isPassenger()) { @@ -140,7 +140,7 @@ entity.push(this); } } -@@ -381,6 +461,14 @@ +@@ -380,6 +460,14 @@ Entity entity1 = (Entity) iterator.next(); if (!this.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof EntityMinecartAbstract) { @@ -155,7 +155,7 @@ entity1.push(this); } } -@@ -397,7 +485,7 @@ +@@ -396,7 +484,7 @@ } protected double getMaxSpeed() { @@ -164,7 +164,7 @@ } public void activateMinecart(int i, int j, int k, boolean flag) {} -@@ -408,12 +496,16 @@ +@@ -407,12 +495,16 @@ this.setDeltaMovement(MathHelper.clamp(vec3d.x, -d0, d0), vec3d.y, MathHelper.clamp(vec3d.z, -d0, d0)); if (this.onGround) { @@ -183,7 +183,7 @@ } } -@@ -604,7 +696,7 @@ +@@ -603,7 +695,7 @@ } protected void applyNaturalSlowdown() { @@ -192,7 +192,7 @@ Vec3D vec3d = this.getDeltaMovement(); vec3d = vec3d.multiply(d0, 0.0D, d0); -@@ -743,6 +835,14 @@ +@@ -742,6 +834,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; -@@ -922,4 +1022,26 @@ +@@ -916,4 +1016,26 @@ private EnumMinecartType() {} } diff --git a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartTNT.patch b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartTNT.patch index 2980df4ea..4c636eae7 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartTNT.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartTNT.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/EntityMinecartTNT.java +++ b/net/minecraft/world/entity/vehicle/EntityMinecartTNT.java -@@ -20,6 +20,10 @@ +@@ -22,6 +22,10 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.material.Fluid; @@ -11,11 +11,11 @@ public class EntityMinecartTNT extends EntityMinecartAbstract { private static final byte EVENT_PRIME = 10; -@@ -106,7 +110,15 @@ +@@ -114,7 +118,15 @@ d1 = 5.0D; } -- this.level.explode(this, this.getX(), this.getY(), this.getZ(), (float) (4.0D + this.random.nextDouble() * 1.5D * d1), Explosion.Effect.BREAK); +- this.level.explode(this, damagesource, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), (float) (4.0D + this.random.nextDouble() * 1.5D * d1), false, World.a.TNT); + // CraftBukkit start + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), (float) (4.0D + this.random.nextDouble() * 1.5D * d1), false); + this.level.getCraftServer().getPluginManager().callEvent(event); @@ -23,7 +23,7 @@ + fuse = -1; + return; + } -+ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Explosion.Effect.BREAK); ++ this.level.explode(this, damagesource, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT); + // CraftBukkit end this.discard(); } diff --git a/nms-patches/net/minecraft/world/inventory/Container.patch b/nms-patches/net/minecraft/world/inventory/Container.patch index 99056e25f..9c269c7d0 100644 --- a/nms-patches/net/minecraft/world/inventory/Container.patch +++ b/nms-patches/net/minecraft/world/inventory/Container.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/Container.java +++ b/net/minecraft/world/inventory/Container.java -@@ -32,6 +32,20 @@ +@@ -33,6 +33,20 @@ import net.minecraft.world.level.block.entity.TileEntity; import org.slf4j.Logger; @@ -21,7 +21,7 @@ public abstract class Container { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -62,6 +76,27 @@ +@@ -63,6 +77,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(); -@@ -163,6 +198,15 @@ +@@ -164,6 +199,15 @@ } @@ -65,7 +65,7 @@ public void removeSlotListener(ICrafting icrafting) { this.containerListeners.remove(icrafting); } -@@ -379,7 +423,7 @@ +@@ -380,7 +424,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); -@@ -390,6 +434,7 @@ +@@ -391,6 +435,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(); -@@ -406,12 +451,48 @@ +@@ -407,12 +452,48 @@ } l -= itemstack3.getCount() - j1; @@ -134,7 +134,7 @@ } this.resetQuickCraft(); -@@ -429,8 +510,11 @@ +@@ -430,8 +511,11 @@ if (i == -999) { if (!this.getCarried().isEmpty()) { if (clickaction == ClickAction.PRIMARY) { @@ -147,7 +147,7 @@ } else { entityhuman.drop(this.getCarried().split(1), true); } -@@ -493,6 +577,15 @@ +@@ -494,6 +578,15 @@ } slot.setChanged(); @@ -163,7 +163,7 @@ } } else { Slot slot2; -@@ -600,13 +693,14 @@ +@@ -607,13 +700,14 @@ ItemStack itemstack = this.getCarried(); if (!itemstack.isEmpty()) { @@ -179,7 +179,7 @@ } } -@@ -820,6 +914,11 @@ +@@ -827,6 +921,11 @@ } public ItemStack getCarried() { diff --git a/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch b/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch index 2e73006e0..50e280e26 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch @@ -74,7 +74,7 @@ + CraftItemStack item = CraftItemStack.asCraftMirror(itemstack); + org.bukkit.enchantments.EnchantmentOffer[] offers = new EnchantmentOffer[3]; + for (j = 0; j < 3; ++j) { -+ org.bukkit.enchantments.Enchantment enchantment = (this.enchantClue[j] >= 0) ? org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.ENCHANTMENT.getKey(IRegistry.ENCHANTMENT.byId(this.enchantClue[j])))) : null; ++ org.bukkit.enchantments.Enchantment enchantment = (this.enchantClue[j] >= 0) ? org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.ENCHANTMENT.getKey(BuiltInRegistries.ENCHANTMENT.byId(this.enchantClue[j])))) : null; + offers[j] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.levelClue[j], this.costs[j]) : null; + } + @@ -95,7 +95,7 @@ + EnchantmentOffer offer = event.getOffers()[j]; + if (offer != null) { + this.costs[j] = offer.getCost(); -+ this.enchantClue[j] = IRegistry.ENCHANTMENT.getId(IRegistry.ENCHANTMENT.get(CraftNamespacedKey.toMinecraft(offer.getEnchantment().getKey()))); ++ this.enchantClue[j] = BuiltInRegistries.ENCHANTMENT.getId(BuiltInRegistries.ENCHANTMENT.get(CraftNamespacedKey.toMinecraft(offer.getEnchantment().getKey()))); + this.levelClue[j] = offer.getEnchantmentLevel(); + } else { + this.costs[j] = 0; @@ -121,7 +121,7 @@ + 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); ++ enchants.put(org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.ENCHANTMENT.getKey(instance.enchantment))), instance.level); + } + CraftItemStack item = CraftItemStack.asCraftMirror(itemstack2); + @@ -150,7 +150,7 @@ + try { + if (flag) { + NamespacedKey enchantId = entry.getKey().getKey(); -+ Enchantment nms = IRegistry.ENCHANTMENT.get(CraftNamespacedKey.toMinecraft(enchantId)); ++ Enchantment nms = BuiltInRegistries.ENCHANTMENT.get(CraftNamespacedKey.toMinecraft(enchantId)); + if (nms == null) { + continue; + } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch b/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch index dbc4ee2cf..ce5d94be3 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch @@ -18,25 +18,27 @@ public ContainerSmithing(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); -@@ -61,13 +66,15 @@ +@@ -61,7 +66,7 @@ List list = this.level.getRecipeManager().getRecipesFor(Recipes.SMITHING, this.inputSlots, this.level); if (list.isEmpty()) { - this.resultSlots.setItem(0, ItemStack.EMPTY); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit } else { - this.selectedRecipe = (RecipeSmithing) list.get(0); - ItemStack itemstack = this.selectedRecipe.assemble(this.inputSlots); - - this.resultSlots.setRecipeUsed(this.selectedRecipe); -- this.resultSlots.setItem(0, itemstack); -+ // CraftBukkit start -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack); -+ // CraftBukkit end + RecipeSmithing recipesmithing = (RecipeSmithing) list.get(0); + ItemStack itemstack = recipesmithing.assemble(this.inputSlots); +@@ -69,7 +74,9 @@ + if (itemstack.isItemEnabled(this.level.enabledFeatures())) { + this.selectedRecipe = recipesmithing; + this.resultSlots.setRecipeUsed(recipesmithing); +- this.resultSlots.setItem(0, itemstack); ++ // CraftBukkit start ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack); ++ // CraftBukkit end + } } - } -@@ -83,4 +90,18 @@ +@@ -86,4 +93,18 @@ public boolean canTakeItemForPickAll(ItemStack itemstack, Slot slot) { return slot.container != this.resultSlots && super.canTakeItemForPickAll(itemstack, slot); } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch b/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch index 69f5242da..8d21248f6 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch @@ -36,15 +36,15 @@ this.access = containeraccess; this.player = playerinventory.player; this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 124, 35)); -@@ -74,6 +86,7 @@ - itemstack = recipecrafting.assemble(inventorycrafting); +@@ -78,6 +90,7 @@ + } } } + itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, inventorycraftresult, itemstack, container.getBukkitView(), optional.orElse(null) instanceof RecipeRepair); // CraftBukkit inventorycraftresult.setItem(0, itemstack); container.setRemoteSlot(0, itemstack); -@@ -114,6 +127,7 @@ +@@ -118,6 +131,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { @@ -52,7 +52,7 @@ return stillValid(this.access, entityhuman, Blocks.CRAFTING_TABLE); } -@@ -202,4 +216,17 @@ +@@ -206,4 +220,17 @@ public boolean shouldMoveToInventory(int i) { return i != this.getResultSlotIndex(); } diff --git a/nms-patches/net/minecraft/world/inventory/Containers.patch b/nms-patches/net/minecraft/world/inventory/Containers.patch index eb322eead..4e752911a 100644 --- a/nms-patches/net/minecraft/world/inventory/Containers.patch +++ b/nms-patches/net/minecraft/world/inventory/Containers.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/inventory/Containers.java +++ b/net/minecraft/world/inventory/Containers.java -@@ -3,6 +3,10 @@ - import net.minecraft.core.IRegistry; +@@ -4,6 +4,10 @@ + import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.entity.player.PlayerInventory; +// CraftBukkit start @@ -11,7 +11,7 @@ public class Containers { public static final Containers GENERIC_9x1 = register("generic_9x1", ContainerChest::oneRow); -@@ -22,7 +26,7 @@ +@@ -23,7 +27,7 @@ public static final Containers GRINDSTONE = register("grindstone", ContainerGrindstone::new); public static final Containers HOPPER = register("hopper", ContainerHopper::new); public static final Containers LECTERN = register("lectern", (i, playerinventory) -> { diff --git a/nms-patches/net/minecraft/world/item/ItemArmorStand.patch b/nms-patches/net/minecraft/world/item/ItemArmorStand.patch index cf2d2c146..507c297b3 100644 --- a/nms-patches/net/minecraft/world/item/ItemArmorStand.patch +++ b/nms-patches/net/minecraft/world/item/ItemArmorStand.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemArmorStand.java +++ b/net/minecraft/world/item/ItemArmorStand.java -@@ -55,6 +55,11 @@ +@@ -57,6 +57,11 @@ entityarmorstand.moveTo(entityarmorstand.getX(), entityarmorstand.getY(), entityarmorstand.getZ(), f, 0.0F); this.randomizePose(entityarmorstand, world.random); diff --git a/nms-patches/net/minecraft/world/item/ItemBlock.patch b/nms-patches/net/minecraft/world/item/ItemBlock.patch index 8c2061101..387341211 100644 --- a/nms-patches/net/minecraft/world/item/ItemBlock.patch +++ b/nms-patches/net/minecraft/world/item/ItemBlock.patch @@ -13,8 +13,8 @@ + public class ItemBlock extends Item { - private static final String BLOCK_ENTITY_TAG = "BlockEntityTag"; -@@ -69,6 +76,12 @@ + public static final String BLOCK_ENTITY_TAG = "BlockEntityTag"; +@@ -71,6 +78,12 @@ return EnumInteractionResult.FAIL; } else { IBlockData iblockdata = this.getPlacementState(blockactioncontext1); @@ -27,7 +27,7 @@ if (iblockdata == null) { return EnumInteractionResult.FAIL; -@@ -85,6 +98,19 @@ +@@ -87,6 +100,19 @@ iblockdata1 = this.updateBlockStateFromTag(blockposition, world, itemstack, iblockdata1); this.updateCustomBlockEntityTag(blockposition, world, entityhuman, itemstack, iblockdata1); iblockdata1.getBlock().setPlacedBy(world, blockposition, iblockdata1, entityhuman, itemstack); @@ -47,7 +47,7 @@ if (entityhuman instanceof EntityPlayer) { CriterionTriggers.PLACED_BLOCK.trigger((EntityPlayer) entityhuman, blockposition, itemstack); } -@@ -92,9 +118,9 @@ +@@ -94,9 +120,9 @@ SoundEffectType soundeffecttype = iblockdata1.getSoundType(); @@ -59,7 +59,7 @@ itemstack.shrink(1); } -@@ -130,6 +156,21 @@ +@@ -132,6 +158,21 @@ if (nbttagcompound != null) { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("BlockStateTag"); @@ -81,7 +81,7 @@ BlockStateList blockstatelist = iblockdata.getBlock().getStateDefinition(); Iterator iterator = nbttagcompound1.getAllKeys().iterator(); -@@ -144,11 +185,6 @@ +@@ -146,11 +187,6 @@ } } } @@ -93,7 +93,7 @@ return iblockdata1; } -@@ -161,8 +197,15 @@ +@@ -163,8 +199,15 @@ protected boolean canPlace(BlockActionContext blockactioncontext, IBlockData iblockdata) { EntityHuman entityhuman = blockactioncontext.getPlayer(); VoxelShapeCollision voxelshapecollision = entityhuman == null ? VoxelShapeCollision.empty() : VoxelShapeCollision.of(entityhuman); @@ -110,7 +110,7 @@ } protected boolean mustSurvive() { -@@ -245,7 +288,7 @@ +@@ -239,7 +282,7 @@ if (nbttagcompound != null && nbttagcompound.contains("Items", 9)) { NBTTagList nbttaglist = nbttagcompound.getList("Items", 10); diff --git a/nms-patches/net/minecraft/world/item/ItemBlockWallable.patch b/nms-patches/net/minecraft/world/item/ItemBlockWallable.patch index 04ca4fcbd..f1eec8067 100644 --- a/nms-patches/net/minecraft/world/item/ItemBlockWallable.patch +++ b/nms-patches/net/minecraft/world/item/ItemBlockWallable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemBlockWallable.java +++ b/net/minecraft/world/item/ItemBlockWallable.java -@@ -9,6 +9,12 @@ +@@ -10,6 +10,12 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -13,7 +13,7 @@ public class ItemBlockWallable extends ItemBlock { -@@ -42,7 +48,19 @@ +@@ -49,7 +55,19 @@ } } diff --git a/nms-patches/net/minecraft/world/item/ItemBoat.patch b/nms-patches/net/minecraft/world/item/ItemBoat.patch index c2bf13f42..ed6818e2c 100644 --- a/nms-patches/net/minecraft/world/item/ItemBoat.patch +++ b/nms-patches/net/minecraft/world/item/ItemBoat.patch @@ -13,7 +13,7 @@ + // CraftBukkit end EntityBoat entityboat = this.getBoat(world, movingobjectpositionblock); - entityboat.setType(this.type); + entityboat.setVariant(this.type); @@ -66,7 +73,15 @@ return InteractionResultWrapper.fail(itemstack); } else { diff --git a/nms-patches/net/minecraft/world/item/ItemCrossbow.patch b/nms-patches/net/minecraft/world/item/ItemCrossbow.patch index 3dcdb0d84..b0629ccb4 100644 --- a/nms-patches/net/minecraft/world/item/ItemCrossbow.patch +++ b/nms-patches/net/minecraft/world/item/ItemCrossbow.patch @@ -11,9 +11,9 @@ } if (!loadProjectile(entityliving, itemstack, itemstack1, k > 0, flag)) { -@@ -236,11 +240,27 @@ - vector3fa.transform(quaternion); - ((IProjectile) object).shoot((double) vector3fa.x(), (double) vector3fa.y(), (double) vector3fa.z(), f1, f2); +@@ -235,11 +239,27 @@ + + ((IProjectile) object).shoot((double) vector3f.x(), (double) vector3f.y(), (double) vector3f.z(), f1, f2); } + // CraftBukkit start + org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityliving, itemstack, itemstack1, (Entity) object, entityliving.getUsedItemHand(), f, true); diff --git a/nms-patches/net/minecraft/world/item/ItemMonsterEgg.patch b/nms-patches/net/minecraft/world/item/ItemMonsterEgg.patch index e6b714461..b3c272e26 100644 --- a/nms-patches/net/minecraft/world/item/ItemMonsterEgg.patch +++ b/nms-patches/net/minecraft/world/item/ItemMonsterEgg.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemMonsterEgg.java +++ b/net/minecraft/world/item/ItemMonsterEgg.java -@@ -181,7 +181,7 @@ +@@ -186,7 +186,7 @@ return Optional.empty(); } else { ((EntityInsentient) object).moveTo(vec3d.x(), vec3d.y(), vec3d.z(), 0.0F, 0.0F); @@ -9,7 +9,7 @@ if (itemstack.hasCustomHoverName()) { ((EntityInsentient) object).setCustomName(itemstack.getHoverName()); } -@@ -190,7 +190,7 @@ +@@ -195,7 +195,7 @@ itemstack.shrink(1); } diff --git a/nms-patches/net/minecraft/world/item/ItemPotion.patch b/nms-patches/net/minecraft/world/item/ItemPotion.patch index a715257e8..70bceabbb 100644 --- a/nms-patches/net/minecraft/world/item/ItemPotion.patch +++ b/nms-patches/net/minecraft/world/item/ItemPotion.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemPotion.java +++ b/net/minecraft/world/item/ItemPotion.java -@@ -63,7 +63,7 @@ +@@ -60,7 +60,7 @@ if (mobeffect.getEffect().isInstantenous()) { mobeffect.getEffect().applyInstantenousEffect(entityhuman, entityhuman, entityliving, mobeffect.getAmplifier(), 1.0D); } else { diff --git a/nms-patches/net/minecraft/world/item/ItemSign.patch b/nms-patches/net/minecraft/world/item/ItemSign.patch index be83c5d26..4e2c6bef5 100644 --- a/nms-patches/net/minecraft/world/item/ItemSign.patch +++ b/nms-patches/net/minecraft/world/item/ItemSign.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/item/ItemSign.java +++ b/net/minecraft/world/item/ItemSign.java -@@ -10,6 +10,8 @@ +@@ -11,6 +11,8 @@ public class ItemSign extends ItemBlockWallable { + public static BlockPosition openSign; // CraftBukkit + public ItemSign(Item.Info item_info, Block block, Block block1) { - super(block, block1, item_info); + super(block, block1, item_info, EnumDirection.DOWN); } -@@ -19,7 +21,10 @@ +@@ -20,7 +22,10 @@ boolean flag = super.updateCustomBlockEntityTag(blockposition, world, entityhuman, itemstack, iblockdata); if (!world.isClientSide && !flag && entityhuman != null) { diff --git a/nms-patches/net/minecraft/world/item/ItemSkullPlayer.patch b/nms-patches/net/minecraft/world/item/ItemSkullPlayer.patch index f1dc6a368..7578b47a4 100644 --- a/nms-patches/net/minecraft/world/item/ItemSkullPlayer.patch +++ b/nms-patches/net/minecraft/world/item/ItemSkullPlayer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemSkullPlayer.java +++ b/net/minecraft/world/item/ItemSkullPlayer.java -@@ -50,6 +50,16 @@ +@@ -51,6 +51,16 @@ TileEntitySkull.updateGameprofile(gameprofile, (gameprofile1) -> { nbttagcompound.put("SkullOwner", GameProfileSerializer.writeGameProfile(new NBTTagCompound(), gameprofile1)); }); diff --git a/nms-patches/net/minecraft/world/item/ItemStack.patch b/nms-patches/net/minecraft/world/item/ItemStack.patch index f36b0adc6..c101bd52d 100644 --- a/nms-patches/net/minecraft/world/item/ItemStack.patch +++ b/nms-patches/net/minecraft/world/item/ItemStack.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -71,6 +71,40 @@ +@@ -74,6 +74,40 @@ import net.minecraft.world.level.block.state.pattern.ShapeDetectorBlock; import org.slf4j.Logger; @@ -41,7 +41,7 @@ public final class ItemStack { public static final Codec CODEC = RecordCodecBuilder.create((instance) -> { -@@ -146,16 +180,30 @@ +@@ -150,16 +184,30 @@ this.updateEmptyCacheFlag(); } @@ -64,7 +64,7 @@ - private ItemStack(NBTTagCompound nbttagcompound) { + // CraftBukkit - break into own method + private void load(NBTTagCompound nbttagcompound) { - this.item = (Item) IRegistry.ITEM.get(new MinecraftKey(nbttagcompound.getString("id"))); + this.item = (Item) BuiltInRegistries.ITEM.get(new MinecraftKey(nbttagcompound.getString("id"))); this.count = nbttagcompound.getByte("Count"); if (nbttagcompound.contains("tag", 10)) { - this.tag = nbttagcompound.getCompound("tag"); @@ -74,7 +74,7 @@ this.getItem().verifyTagAfterLoad(this.tag); } -@@ -163,6 +211,11 @@ +@@ -167,6 +215,11 @@ this.setDamageValue(this.getDamageValue()); } @@ -86,7 +86,7 @@ this.updateEmptyCacheFlag(); } -@@ -216,7 +269,7 @@ +@@ -224,7 +277,7 @@ return this.getItem().builtInRegistryHolder().tags(); } @@ -95,8 +95,8 @@ EntityHuman entityhuman = itemactioncontext.getPlayer(); BlockPosition blockposition = itemactioncontext.getClickedPos(); ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getLevel(), blockposition, false); -@@ -224,12 +277,157 @@ - if (entityhuman != null && !entityhuman.getAbilities().mayBuild && !this.hasAdventureModePlaceTagForBlock(itemactioncontext.getLevel().registryAccess().registryOrThrow(IRegistry.BLOCK_REGISTRY), shapedetectorblock)) { +@@ -232,12 +285,157 @@ + if (entityhuman != null && !entityhuman.getAbilities().mayBuild && !this.hasAdventureModePlaceTagForBlock(itemactioncontext.getLevel().registryAccess().registryOrThrow(Registries.BLOCK), shapedetectorblock)) { return EnumInteractionResult.PASS; } else { + // CraftBukkit start - handle all block place event logic here @@ -254,7 +254,7 @@ return enuminteractionresult; } -@@ -310,6 +508,21 @@ +@@ -318,6 +516,21 @@ } i -= k; @@ -276,7 +276,7 @@ if (i <= 0) { return false; } -@@ -331,6 +544,11 @@ +@@ -339,6 +552,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) { -@@ -486,6 +704,17 @@ +@@ -493,6 +711,17 @@ return this.tag; } @@ -306,16 +306,7 @@ public NBTTagCompound getOrCreateTag() { if (this.tag == null) { this.setTag(new NBTTagCompound()); -@@ -782,7 +1011,7 @@ - - private static Collection expandBlockState(String s) { - try { -- return (Collection) ArgumentBlock.parseForTesting((IRegistry) IRegistry.BLOCK, s, true).map((argumentblock_a) -> { -+ return (Collection) ArgumentBlock.parseForTesting(IRegistry.BLOCK, s, true).map((argumentblock_a) -> { // CraftBukkit - decompile error - return Lists.newArrayList(new IChatBaseComponent[]{argumentblock_a.blockState().getBlock().getName().withStyle(EnumChatFormat.DARK_GRAY)}); - }, (argumentblock_b) -> { - return (List) argumentblock_b.tag().stream().map((holder) -> { -@@ -848,6 +1077,12 @@ +@@ -859,6 +1088,12 @@ } public void setRepairCost(int i) { @@ -328,7 +319,7 @@ this.getOrCreateTag().putInt("RepairCost", i); } -@@ -897,6 +1132,13 @@ +@@ -908,6 +1143,13 @@ nbttaglist.add(nbttagcompound); } diff --git a/nms-patches/net/minecraft/world/item/ItemWorldMap.patch b/nms-patches/net/minecraft/world/item/ItemWorldMap.patch index 8f18294a5..833f64a21 100644 --- a/nms-patches/net/minecraft/world/item/ItemWorldMap.patch +++ b/nms-patches/net/minecraft/world/item/ItemWorldMap.patch @@ -12,7 +12,7 @@ public class ItemWorldMap extends ItemWorldMapBase { public static final int IMAGE_WIDTH = 128; -@@ -67,7 +72,7 @@ +@@ -69,7 +74,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 @@ +@@ -77,6 +82,10 @@ int l = world.getFreeMapId(); world.setMapData(makeKey(l), worldmap); diff --git a/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch b/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch index 83168c00c..6a51bb211 100644 --- a/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch +++ b/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch @@ -22,7 +22,7 @@ - Map, Builder>> map1 = Maps.newHashMap(); + // CraftBukkit start - SPIGOT-5667 make sure all types are populated and mutable + Map, Object2ObjectLinkedOpenHashMap>> map1 = Maps.newHashMap(); -+ for (Recipes recipeType : IRegistry.RECIPE_TYPE) { ++ for (Recipes recipeType : BuiltInRegistries.RECIPE_TYPE) { + map1.put(recipeType, new Object2ObjectLinkedOpenHashMap<>()); + } + // CraftBukkit end @@ -153,7 +153,7 @@ + public void clearRecipes() { + this.recipes = Maps.newHashMap(); + -+ for (Recipes recipeType : IRegistry.RECIPE_TYPE) { ++ for (Recipes recipeType : BuiltInRegistries.RECIPE_TYPE) { + this.recipes.put(recipeType, new Object2ObjectLinkedOpenHashMap<>()); + } + diff --git a/nms-patches/net/minecraft/world/item/crafting/FurnaceRecipe.patch b/nms-patches/net/minecraft/world/item/crafting/FurnaceRecipe.patch index 83e292a0b..29cfe021b 100644 --- a/nms-patches/net/minecraft/world/item/crafting/FurnaceRecipe.patch +++ b/nms-patches/net/minecraft/world/item/crafting/FurnaceRecipe.patch @@ -14,19 +14,22 @@ + public class FurnaceRecipe extends RecipeCooking { - public FurnaceRecipe(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { -@@ -19,4 +27,14 @@ + public FurnaceRecipe(MinecraftKey minecraftkey, String s, CookingBookCategory cookingbookcategory, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { +@@ -19,4 +27,17 @@ public RecipeSerializer getSerializer() { return RecipeSerializer.SMELTING_RECIPE; } + ++ // CraftBukkit start + @Override + public Recipe toBukkitRecipe() { + CraftItemStack result = CraftItemStack.asCraftMirror(this.result); + + CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); + recipe.setGroup(this.group); ++ recipe.setCategory(CraftRecipe.getCategory(this.category())); + + return recipe; + } ++ // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch b/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch index 9265a4bc9..eae352e7f 100644 --- a/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch +++ b/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/crafting/IRecipeComplex.java +++ b/net/minecraft/world/item/crafting/IRecipeComplex.java -@@ -25,4 +25,11 @@ - public ItemStack getResultItem() { - return ItemStack.EMPTY; +@@ -32,4 +32,11 @@ + public CraftingBookCategory category() { + return this.category; } + + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/item/crafting/RecipeBlasting.patch b/nms-patches/net/minecraft/world/item/crafting/RecipeBlasting.patch index 7258d4f4b..009430c47 100644 --- a/nms-patches/net/minecraft/world/item/crafting/RecipeBlasting.patch +++ b/nms-patches/net/minecraft/world/item/crafting/RecipeBlasting.patch @@ -14,8 +14,8 @@ + public class RecipeBlasting extends RecipeCooking { - public RecipeBlasting(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { -@@ -19,4 +27,16 @@ + public RecipeBlasting(MinecraftKey minecraftkey, String s, CookingBookCategory cookingbookcategory, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { +@@ -19,4 +27,17 @@ public RecipeSerializer getSerializer() { return RecipeSerializer.BLASTING_RECIPE; } @@ -27,6 +27,7 @@ + + CraftBlastingRecipe recipe = new CraftBlastingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); + recipe.setGroup(this.group); ++ recipe.setCategory(CraftRecipe.getCategory(this.category())); + + return recipe; + } diff --git a/nms-patches/net/minecraft/world/item/crafting/RecipeCampfire.patch b/nms-patches/net/minecraft/world/item/crafting/RecipeCampfire.patch index 89d3b558e..9d3bbbd4f 100644 --- a/nms-patches/net/minecraft/world/item/crafting/RecipeCampfire.patch +++ b/nms-patches/net/minecraft/world/item/crafting/RecipeCampfire.patch @@ -14,8 +14,8 @@ + public class RecipeCampfire extends RecipeCooking { - public RecipeCampfire(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { -@@ -19,4 +27,16 @@ + public RecipeCampfire(MinecraftKey minecraftkey, String s, CookingBookCategory cookingbookcategory, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { +@@ -19,4 +27,17 @@ public RecipeSerializer getSerializer() { return RecipeSerializer.CAMPFIRE_COOKING_RECIPE; } @@ -27,6 +27,7 @@ + + CraftCampfireRecipe recipe = new CraftCampfireRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); + recipe.setGroup(this.group); ++ recipe.setCategory(CraftRecipe.getCategory(this.category())); + + return recipe; + } diff --git a/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch b/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch index 8cc045fc9..77f22ede9 100644 --- a/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch +++ b/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/RecipeItemStack.java +++ b/net/minecraft/world/item/crafting/RecipeItemStack.java -@@ -37,6 +37,7 @@ +@@ -38,6 +38,7 @@ public ItemStack[] itemStacks; @Nullable private IntList stackingIds; @@ -8,19 +8,19 @@ public RecipeItemStack(Stream stream) { this.values = (RecipeItemStack.Provider[]) stream.toArray((i) -> { -@@ -74,6 +75,15 @@ - for (int j = 0; j < i; ++j) { - ItemStack itemstack1 = aitemstack[j]; +@@ -69,6 +70,15 @@ + for (int j = 0; j < i; ++j) { + ItemStack itemstack1 = aitemstack[j]; -+ // CraftBukkit start -+ if (exact) { -+ if (itemstack1.getItem() == itemstack.getItem() && ItemStack.tagMatches(itemstack, itemstack1)) { -+ return true; -+ } -+ -+ continue; ++ // CraftBukkit start ++ if (exact) { ++ if (itemstack1.getItem() == itemstack.getItem() && ItemStack.tagMatches(itemstack, itemstack1)) { ++ return true; + } -+ // CraftBukkit end - if (itemstack1.is(itemstack.getItem())) { - return true; - } ++ ++ continue; ++ } ++ // CraftBukkit end + if (itemstack1.is(itemstack.getItem())) { + return true; + } diff --git a/nms-patches/net/minecraft/world/item/crafting/RecipeSmoking.patch b/nms-patches/net/minecraft/world/item/crafting/RecipeSmoking.patch index 579754727..d862c495b 100644 --- a/nms-patches/net/minecraft/world/item/crafting/RecipeSmoking.patch +++ b/nms-patches/net/minecraft/world/item/crafting/RecipeSmoking.patch @@ -14,8 +14,8 @@ + public class RecipeSmoking extends RecipeCooking { - public RecipeSmoking(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { -@@ -19,4 +27,16 @@ + public RecipeSmoking(MinecraftKey minecraftkey, String s, CookingBookCategory cookingbookcategory, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { +@@ -19,4 +27,17 @@ public RecipeSerializer getSerializer() { return RecipeSerializer.SMOKING_RECIPE; } @@ -27,6 +27,7 @@ + + CraftSmokingRecipe recipe = new CraftSmokingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); + recipe.setGroup(this.group); ++ recipe.setCategory(CraftRecipe.getCategory(this.category())); + + return recipe; + } diff --git a/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch b/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch index c58965ff4..90d2aad99 100644 --- a/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch +++ b/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch @@ -14,7 +14,7 @@ public class ShapedRecipes implements RecipeCrafting { final int width; -@@ -41,6 +48,66 @@ +@@ -43,6 +50,67 @@ this.result = itemstack; } @@ -23,6 +23,7 @@ + CraftItemStack result = CraftItemStack.asCraftMirror(this.result); + CraftShapedRecipe recipe = new CraftShapedRecipe(result, this); + recipe.setGroup(this.group); ++ recipe.setCategory(CraftRecipe.getCategory(this.category())); + + switch (this.height) { + case 1: diff --git a/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch b/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch index aea76f623..7b4073097 100644 --- a/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch +++ b/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch @@ -13,7 +13,7 @@ public class ShapelessRecipes implements RecipeCrafting { private final MinecraftKey id; -@@ -28,6 +34,20 @@ +@@ -30,6 +36,21 @@ this.ingredients = nonnulllist; } @@ -23,6 +23,7 @@ + CraftItemStack result = CraftItemStack.asCraftMirror(this.result); + CraftShapelessRecipe recipe = new CraftShapelessRecipe(result, this); + recipe.setGroup(this.group); ++ recipe.setCategory(CraftRecipe.getCategory(this.category())); + + for (RecipeItemStack list : this.ingredients) { + recipe.addIngredient(CraftRecipe.toBukkit(list)); diff --git a/nms-patches/net/minecraft/world/item/enchantment/Enchantments.patch b/nms-patches/net/minecraft/world/item/enchantment/Enchantments.patch index f70508972..73229f02f 100644 --- a/nms-patches/net/minecraft/world/item/enchantment/Enchantments.patch +++ b/nms-patches/net/minecraft/world/item/enchantment/Enchantments.patch @@ -1,17 +1,14 @@ --- a/net/minecraft/world/item/enchantment/Enchantments.java +++ b/net/minecraft/world/item/enchantment/Enchantments.java -@@ -46,6 +46,14 @@ - public static final Enchantment MENDING = register("mending", new EnchantmentMending(Enchantment.Rarity.RARE, EnumItemSlot.values())); - public static final Enchantment VANISHING_CURSE = register("vanishing_curse", new EnchantmentVanishing(Enchantment.Rarity.VERY_RARE, EnumItemSlot.values())); - -+ // CraftBukkit start -+ static { -+ for (Object enchantment : IRegistry.ENCHANTMENT) { -+ org.bukkit.enchantments.Enchantment.registerEnchantment(new org.bukkit.craftbukkit.enchantments.CraftEnchantment((Enchantment) enchantment)); -+ } -+ } -+ // CraftBukkit end -+ +@@ -50,6 +50,10 @@ public Enchantments() {} private static Enchantment register(String s, Enchantment enchantment) { +- return (Enchantment) IRegistry.register(BuiltInRegistries.ENCHANTMENT, s, enchantment); ++ // CraftBukkit start ++ enchantment = (Enchantment) IRegistry.register(BuiltInRegistries.ENCHANTMENT, s, enchantment); ++ org.bukkit.enchantments.Enchantment.registerEnchantment(new org.bukkit.craftbukkit.enchantments.CraftEnchantment(enchantment)); ++ return enchantment; ++ // CraftBukkit end + } + } diff --git a/nms-patches/net/minecraft/world/level/Explosion.patch b/nms-patches/net/minecraft/world/level/Explosion.patch index 800faaa44..201b83c38 100644 --- a/nms-patches/net/minecraft/world/level/Explosion.patch +++ b/nms-patches/net/minecraft/world/level/Explosion.patch @@ -22,9 +22,9 @@ private final Map hitPlayers; + public boolean wasCanceled = false; // CraftBukkit - add field - public Explosion(World world, @Nullable Entity entity, double d0, double d1, double d2, float f) { - this(world, entity, d0, d1, d2, f, false, Explosion.Effect.DESTROY); -@@ -82,7 +92,7 @@ + public Explosion(World world, @Nullable Entity entity, double d0, double d1, double d2, float f, List list) { + this(world, entity, d0, d1, d2, f, false, Explosion.Effect.DESTROY_WITH_DECAY, list); +@@ -78,7 +88,7 @@ this.hitPlayers = Maps.newHashMap(); this.level = world; this.source = entity; @@ -33,7 +33,7 @@ this.x = d0; this.y = d1; this.z = d2; -@@ -132,6 +142,11 @@ +@@ -128,6 +138,11 @@ } public void explode() { @@ -45,7 +45,7 @@ this.level.gameEvent(this.source, GameEvent.EXPLODE, new Vec3D(this.x, this.y, this.z)); Set set = Sets.newHashSet(); boolean flag = true; -@@ -215,7 +230,35 @@ +@@ -211,7 +226,35 @@ double d12 = (double) getSeenPercent(vec3d, entity); double d13 = (1.0D - d7) * d12; @@ -82,7 +82,7 @@ double d14 = d13; if (entity instanceof EntityLiving) { -@@ -258,6 +301,51 @@ +@@ -254,6 +297,51 @@ SystemUtils.shuffle(this.toBlow, this.level.random); ObjectListIterator objectlistiterator = this.toBlow.iterator(); @@ -134,18 +134,18 @@ while (objectlistiterator.hasNext()) { BlockPosition blockposition = (BlockPosition) objectlistiterator.next(); -@@ -276,8 +364,8 @@ +@@ -272,8 +360,8 @@ TileEntity tileentity = iblockdata.hasBlockEntity() ? this.level.getBlockEntity(blockposition) : null; LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder(worldserver)).withRandom(this.level.random).withParameter(LootContextParameters.ORIGIN, Vec3D.atCenterOf(blockposition)).withParameter(LootContextParameters.TOOL, ItemStack.EMPTY).withOptionalParameter(LootContextParameters.BLOCK_ENTITY, tileentity).withOptionalParameter(LootContextParameters.THIS_ENTITY, this.source); -- if (this.blockInteraction == Explosion.Effect.DESTROY) { +- if (this.blockInteraction == Explosion.Effect.DESTROY_WITH_DECAY) { - loottableinfo_builder.withParameter(LootContextParameters.EXPLOSION_RADIUS, this.radius); -+ if (this.blockInteraction == Explosion.Effect.DESTROY || yield < 1.0F) { // CraftBukkit - add yield ++ if (this.blockInteraction == Explosion.Effect.DESTROY_WITH_DECAY || yield < 1.0F) { // CraftBukkit - add yield + loottableinfo_builder.withParameter(LootContextParameters.EXPLOSION_RADIUS, 1.0F / yield); // CraftBukkit - add yield } iblockdata.spawnAfterBreak(worldserver, blockposition, ItemStack.EMPTY, flag2); -@@ -309,7 +397,11 @@ +@@ -305,7 +393,11 @@ BlockPosition blockposition2 = (BlockPosition) objectlistiterator1.next(); if (this.random.nextInt(3) == 0 && this.level.getBlockState(blockposition2).isAir() && this.level.getBlockState(blockposition2.below()).isSolidRender(this.level, blockposition2.below())) { diff --git a/nms-patches/net/minecraft/world/level/GameRules.patch b/nms-patches/net/minecraft/world/level/GameRules.patch index 2df13429c..a5f6d93cc 100644 --- a/nms-patches/net/minecraft/world/level/GameRules.patch +++ b/nms-patches/net/minecraft/world/level/GameRules.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/GameRules.java +++ b/net/minecraft/world/level/GameRules.java -@@ -119,7 +119,7 @@ +@@ -126,7 +126,7 @@ } public > T getRule(GameRules.GameRuleKey gamerules_gamerulekey) { @@ -9,7 +9,7 @@ } public NBTTagCompound createTag() { -@@ -133,7 +133,7 @@ +@@ -140,7 +140,7 @@ private void loadFromTag(DynamicLike dynamiclike) { this.rules.forEach((gamerules_gamerulekey, gamerules_gamerulevalue) -> { @@ -18,7 +18,7 @@ Objects.requireNonNull(gamerules_gamerulevalue); optional.ifPresent(gamerules_gamerulevalue::deserialize); -@@ -153,8 +153,8 @@ +@@ -160,8 +160,8 @@ } private static > void callVisitorCap(GameRules.GameRuleVisitor gamerules_gamerulevisitor, GameRules.GameRuleKey gamerules_gamerulekey, GameRules.GameRuleDefinition gamerules_gameruledefinition) { @@ -29,7 +29,7 @@ } public void assignFrom(GameRules gamerules, @Nullable MinecraftServer minecraftserver) { -@@ -246,7 +246,7 @@ +@@ -253,7 +253,7 @@ } public T createRule() { @@ -38,7 +38,7 @@ } public void callVisitor(GameRules.GameRuleVisitor gamerules_gamerulevisitor, GameRules.GameRuleKey gamerules_gamerulekey) { -@@ -276,7 +276,7 @@ +@@ -283,7 +283,7 @@ } @@ -47,7 +47,7 @@ public abstract String serialize(); -@@ -342,7 +342,7 @@ +@@ -349,7 +349,7 @@ } @Override @@ -56,7 +56,7 @@ this.value = Boolean.parseBoolean(s); } -@@ -407,7 +407,7 @@ +@@ -414,7 +414,7 @@ } @Override diff --git a/nms-patches/net/minecraft/world/level/GeneratorAccess.patch b/nms-patches/net/minecraft/world/level/GeneratorAccess.patch index 225fb6817..70019a156 100644 --- a/nms-patches/net/minecraft/world/level/GeneratorAccess.patch +++ b/nms-patches/net/minecraft/world/level/GeneratorAccess.patch @@ -14,7 +14,7 @@ return new NextTickListEntry<>(t0, blockposition, this.getLevelData().getGameTime() + (long) i, this.nextSubTickCount()); } -@@ -110,4 +110,6 @@ +@@ -114,4 +114,6 @@ default void gameEvent(GameEvent gameevent, BlockPosition blockposition, GameEvent.a gameevent_a) { this.gameEvent(gameevent, Vec3D.atCenterOf(blockposition), gameevent_a); } diff --git a/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch b/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch index 4b0fd8649..9dd0552fc 100644 --- a/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch +++ b/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/MobSpawnerAbstract.java +++ b/net/minecraft/world/level/MobSpawnerAbstract.java -@@ -47,6 +47,7 @@ +@@ -50,6 +50,7 @@ - public void setEntityId(EntityTypes entitytypes) { - this.nextSpawnData.getEntityToSpawn().putString("id", IRegistry.ENTITY_TYPE.getKey(entitytypes).toString()); + public void setEntityId(EntityTypes entitytypes, @Nullable World world, RandomSource randomsource, BlockPosition blockposition) { + this.getOrCreateNextSpawnData(world, randomsource, blockposition).getEntityToSpawn().putString("id", BuiltInRegistries.ENTITY_TYPE.getKey(entitytypes).toString()); + this.spawnPotentials = SimpleWeightedRandomList.empty(); // CraftBukkit - SPIGOT-3496, MC-92282 } private boolean isNearPlayer(World world, BlockPosition blockposition) { -@@ -148,7 +149,7 @@ +@@ -152,7 +153,7 @@ } } diff --git a/nms-patches/net/minecraft/world/level/SpawnerCreature.patch b/nms-patches/net/minecraft/world/level/SpawnerCreature.patch index 485095df8..24b8cc9da 100644 --- a/nms-patches/net/minecraft/world/level/SpawnerCreature.patch +++ b/nms-patches/net/minecraft/world/level/SpawnerCreature.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/SpawnerCreature.java +++ b/net/minecraft/world/level/SpawnerCreature.java -@@ -48,6 +48,13 @@ +@@ -49,6 +49,13 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -14,7 +14,7 @@ public final class SpawnerCreature { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -112,10 +119,25 @@ +@@ -113,10 +120,25 @@ EnumCreatureType[] aenumcreaturetype = SpawnerCreature.SPAWNING_CATEGORIES; int i = aenumcreaturetype.length; @@ -41,7 +41,7 @@ Objects.requireNonNull(spawnercreature_d); SpawnerCreature.c spawnercreature_c = spawnercreature_d::canSpawn; -@@ -200,10 +222,15 @@ +@@ -201,10 +223,15 @@ entityinsentient.moveTo(d0, (double) i, d1, worldserver.random.nextFloat() * 360.0F, 0.0F); if (isValidPositionForMob(worldserver, entityinsentient, d2)) { groupdataentity = entityinsentient.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityinsentient.blockPosition()), EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null); @@ -61,7 +61,7 @@ if (j >= entityinsentient.getMaxSpawnClusterSize()) { return; } -@@ -384,7 +411,7 @@ +@@ -390,7 +417,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); @@ -70,7 +70,7 @@ flag = true; } } -@@ -505,8 +532,10 @@ +@@ -511,8 +538,10 @@ return this.unmodifiableMobCategoryCounts; } diff --git a/nms-patches/net/minecraft/world/level/World.patch b/nms-patches/net/minecraft/world/level/World.patch index 67bed4228..aa2aa3ecf 100644 --- a/nms-patches/net/minecraft/world/level/World.patch +++ b/nms-patches/net/minecraft/world/level/World.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/World.java +++ b/net/minecraft/world/level/World.java -@@ -67,6 +67,31 @@ - import net.minecraft.world.phys.AxisAlignedBB; +@@ -70,6 +70,31 @@ + import net.minecraft.world.phys.Vec3D; import net.minecraft.world.scores.Scoreboard; +// CraftBukkit start @@ -31,8 +31,8 @@ + public abstract class World implements GeneratorAccess, AutoCloseable { - public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(IRegistry.DIMENSION_REGISTRY); -@@ -108,7 +133,43 @@ + public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); +@@ -111,7 +136,43 @@ private final ResourceKey dimension; private long subTickCount; @@ -77,7 +77,7 @@ this.profiler = supplier; this.levelData = worlddatamutable; this.dimensionTypeRegistration = holder; -@@ -123,12 +184,12 @@ +@@ -126,12 +187,12 @@ this.worldBorder = new WorldBorder() { @Override public double getCenterX() { @@ -92,7 +92,7 @@ } }; } else { -@@ -139,6 +200,42 @@ +@@ -142,6 +203,42 @@ this.biomeManager = new BiomeManager(this, i); this.isDebug = flag1; this.neighborUpdater = new CollectingNeighborUpdater(this, j); @@ -135,7 +135,7 @@ } @Override -@@ -196,6 +293,17 @@ +@@ -199,6 +296,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()) { -@@ -203,9 +311,24 @@ +@@ -206,9 +314,24 @@ } else { Chunk chunk = this.getChunkAt(blockposition); Block block = iblockdata.getBlock(); @@ -179,7 +179,7 @@ return false; } else { IBlockData iblockdata2 = this.getBlockState(blockposition); -@@ -216,6 +339,7 @@ +@@ -219,6 +342,7 @@ this.getProfiler().pop(); } @@ -187,7 +187,7 @@ if (iblockdata2 == iblockdata) { if (iblockdata1 != iblockdata2) { this.setBlocksDirty(blockposition, iblockdata1, iblockdata2); -@@ -242,12 +366,69 @@ +@@ -245,12 +369,69 @@ this.onBlockStateChange(blockposition, iblockdata1, iblockdata2); } @@ -257,7 +257,7 @@ public void onBlockStateChange(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {} @Override -@@ -333,6 +514,14 @@ +@@ -336,6 +517,14 @@ @Override public IBlockData getBlockState(BlockPosition blockposition) { @@ -272,7 +272,7 @@ if (this.isOutsideBuildHeight(blockposition)) { return Blocks.VOID_AIR.defaultBlockState(); } else { -@@ -470,6 +659,16 @@ +@@ -527,6 +716,16 @@ @Nullable @Override public TileEntity getBlockEntity(BlockPosition blockposition) { @@ -289,7 +289,7 @@ return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, Chunk.EnumTileEntityState.IMMEDIATE)); } -@@ -477,6 +676,12 @@ +@@ -534,6 +733,12 @@ BlockPosition blockposition = tileentity.getBlockPos(); if (!this.isOutsideBuildHeight(blockposition)) { @@ -302,10 +302,10 @@ this.getChunkAt(blockposition).addAndRegisterBlockEntity(tileentity); } } -@@ -595,7 +800,7 @@ +@@ -664,7 +869,7 @@ - for (int j = 0; j < i; ++j) { - EntityComplexPart entitycomplexpart = aentitycomplexpart[j]; + for (int k = 0; k < j; ++k) { + EntityComplexPart entitycomplexpart = aentitycomplexpart[k]; - T t0 = (Entity) entitytypetest.tryCast(entitycomplexpart); + T t0 = entitytypetest.tryCast(entitycomplexpart); // CraftBukkit - decompile error diff --git a/nms-patches/net/minecraft/world/level/block/Block.patch b/nms-patches/net/minecraft/world/level/block/Block.patch index 997e52802..39750ef49 100644 --- a/nms-patches/net/minecraft/world/level/block/Block.patch +++ b/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 -@@ -356,7 +356,13 @@ +@@ -354,7 +354,13 @@ EntityItem entityitem = (EntityItem) supplier.get(); entityitem.setDefaultPickUpDelay(); @@ -15,7 +15,7 @@ } } -@@ -382,7 +388,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,7 +24,7 @@ dropResources(iblockdata, world, blockposition, tileentity, entityhuman, itemstack); } -@@ -522,16 +528,24 @@ +@@ -516,16 +522,24 @@ return this.builtInRegistryHolder; } diff --git a/nms-patches/net/minecraft/world/level/block/BlockBed.patch b/nms-patches/net/minecraft/world/level/block/BlockBed.patch index 6ac72cba4..07ae9f933 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockBed.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockBed.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockBed.java +++ b/net/minecraft/world/level/block/BlockBed.java -@@ -87,7 +87,8 @@ +@@ -86,7 +86,8 @@ } } @@ -10,7 +10,7 @@ world.removeBlock(blockposition, false); BlockPosition blockposition1 = blockposition.relative(((EnumDirection) iblockdata.getValue(BlockBed.FACING)).getOpposite()); -@@ -104,7 +105,16 @@ +@@ -105,7 +106,16 @@ return EnumInteractionResult.SUCCESS; } else { @@ -27,7 +27,7 @@ if (entityhuman_enumbedresult.getMessage() != null) { entityhuman.displayClientMessage(entityhuman_enumbedresult.getMessage(), true); } -@@ -115,8 +125,27 @@ +@@ -116,8 +126,29 @@ } } @@ -42,7 +42,9 @@ + world.removeBlock(blockposition1, false); + } + -+ world.explode((Entity) null, DamageSource.badRespawnPointExplosion(), (ExplosionDamageCalculator) null, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, 5.0F, true, Explosion.Effect.DESTROY); ++ Vec3D vec3d = blockposition.getCenter(); ++ ++ world.explode((Entity) null, DamageSource.badRespawnPointExplosion(vec3d), (ExplosionDamageCalculator) null, vec3d, 5.0F, true, World.a.BLOCK); + return EnumInteractionResult.SUCCESS; + } + } diff --git a/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch b/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch index 55582c529..c1915f801 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockButtonAbstract.java +++ b/net/minecraft/world/level/block/BlockButtonAbstract.java -@@ -27,6 +27,11 @@ +@@ -26,6 +26,11 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -9,10 +9,10 @@ +import org.bukkit.event.entity.EntityInteractEvent; +// CraftBukkit end + - public abstract class BlockButtonAbstract extends BlockAttachable { + public class BlockButtonAbstract extends BlockAttachable { public static final BlockStateBoolean POWERED = BlockProperties.POWERED; -@@ -97,6 +102,19 @@ +@@ -109,6 +114,19 @@ if ((Boolean) iblockdata.getValue(BlockButtonAbstract.POWERED)) { return EnumInteractionResult.CONSUME; } else { @@ -32,46 +32,22 @@ this.press(iblockdata, world, blockposition); this.playSound(entityhuman, world, blockposition, true); world.gameEvent((Entity) entityhuman, GameEvent.BLOCK_ACTIVATE, blockposition); -@@ -148,6 +166,16 @@ - if (this.sensitive) { - this.checkPressed(iblockdata, worldserver, blockposition); - } else { -+ // CraftBukkit start -+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ -+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0); -+ worldserver.getCraftServer().getPluginManager().callEvent(eventRedstone); -+ -+ if (eventRedstone.getNewCurrent() > 0) { -+ return; -+ } -+ // CraftBukkit end - worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockButtonAbstract.POWERED, false), 3); - this.updateNeighbours(iblockdata, worldserver, blockposition); - this.playSound((EntityHuman) null, worldserver, blockposition, false); -@@ -169,11 +197,48 @@ - boolean flag = !list.isEmpty(); +@@ -171,11 +189,36 @@ + } + + protected void checkPressed(IBlockData iblockdata, World world, BlockPosition blockposition) { +- EntityArrow entityarrow = this.arrowsCanPress ? (EntityArrow) world.getEntitiesOfClass(EntityArrow.class, iblockdata.getShape(world, blockposition).bounds().move(blockposition)).stream().findFirst().orElse((Object) null) : null; ++ EntityArrow entityarrow = this.arrowsCanPress ? (EntityArrow) world.getEntitiesOfClass(EntityArrow.class, iblockdata.getShape(world, blockposition).bounds().move(blockposition)).stream().findFirst().orElse(null) : null; // CraftBukkit - decompile error + boolean flag = entityarrow != null; boolean flag1 = (Boolean) iblockdata.getValue(BlockButtonAbstract.POWERED); + // CraftBukkit start - Call interact event when arrows turn on wooden buttons + if (flag1 != flag && flag) { + org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ boolean allowed = false; ++ EntityInteractEvent event = new EntityInteractEvent(entityarrow.getBukkitEntity(), block); ++ world.getCraftServer().getPluginManager().callEvent(event); + -+ // If all of the events are cancelled block the button press, else allow -+ for (Object object : list) { -+ if (object != null) { -+ EntityInteractEvent event = new EntityInteractEvent(((Entity) object).getBukkitEntity(), block); -+ world.getCraftServer().getPluginManager().callEvent(event); -+ -+ if (!event.isCancelled()) { -+ allowed = true; -+ break; -+ } -+ } -+ } -+ -+ if (!allowed) { ++ if (event.isCancelled()) { + return; + } + } @@ -94,8 +70,3 @@ world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockButtonAbstract.POWERED, flag), 3); this.updateNeighbours(iblockdata, world, blockposition); this.playSound((EntityHuman) null, world, blockposition, flag); -- world.gameEvent((Entity) list.stream().findFirst().orElse((Object) null), flag ? GameEvent.BLOCK_ACTIVATE : GameEvent.BLOCK_DEACTIVATE, blockposition); -+ world.gameEvent((Entity) list.stream().findFirst().orElse(null), flag ? GameEvent.BLOCK_ACTIVATE : GameEvent.BLOCK_DEACTIVATE, blockposition); // CraftBukkit - decompile error - } - - if (flag) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockDoor.patch b/nms-patches/net/minecraft/world/level/block/BlockDoor.patch index 8a3a97d5f..ce966a4a4 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockDoor.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockDoor.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockDoor.java +++ b/net/minecraft/world/level/block/BlockDoor.java -@@ -33,6 +33,8 @@ +@@ -35,6 +35,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -9,7 +9,7 @@ public class BlockDoor extends Block { public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING; -@@ -191,9 +193,24 @@ +@@ -189,9 +191,24 @@ @Override public void neighborChanged(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) { @@ -34,5 +34,5 @@ + boolean flag1 = eventRedstone.getNewCurrent() > 0; + // CraftBukkit end if (flag1 != (Boolean) iblockdata.getValue(BlockDoor.OPEN)) { - this.playSound(world, blockposition, flag1); + this.playSound((Entity) null, world, blockposition, flag1); world.gameEvent((Entity) null, flag1 ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, blockposition); diff --git a/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch b/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch index c5b6c7f83..abcc5ac60 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockFenceGate.java +++ b/net/minecraft/world/level/block/BlockFenceGate.java -@@ -129,6 +129,17 @@ +@@ -142,6 +142,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/nms-patches/net/minecraft/world/level/block/BlockFungi.patch b/nms-patches/net/minecraft/world/level/block/BlockFungi.patch index fa77e15a8..e68922f41 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockFungi.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockFungi.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/level/block/BlockFungi.java +++ b/net/minecraft/world/level/block/BlockFungi.java -@@ -51,6 +51,13 @@ - +@@ -59,6 +59,13 @@ @Override public void performBonemeal(WorldServer worldserver, RandomSource randomsource, BlockPosition blockposition, IBlockData iblockdata) { -+ // CraftBukkit start -+ if (this == Blocks.WARPED_FUNGUS) { -+ BlockSapling.treeType = org.bukkit.TreeType.WARPED_FUNGUS; -+ } else if (this == Blocks.CRIMSON_FUNGUS) { -+ BlockSapling.treeType = org.bukkit.TreeType.CRIMSON_FUNGUS; -+ } -+ // CraftBukkit end - ((WorldGenFeatureConfigured) ((Holder) this.feature.get()).value()).place(worldserver, worldserver.getChunkSource().getGenerator(), randomsource, blockposition); + this.getFeature(worldserver).ifPresent((holder) -> { ++ // CraftBukkit start ++ if (this == Blocks.WARPED_FUNGUS) { ++ BlockSapling.treeType = org.bukkit.TreeType.WARPED_FUNGUS; ++ } else if (this == Blocks.CRIMSON_FUNGUS) { ++ BlockSapling.treeType = org.bukkit.TreeType.CRIMSON_FUNGUS; ++ } ++ // CraftBukkit end + ((WorldGenFeatureConfigured) holder.value()).place(worldserver, worldserver.getChunkSource().getGenerator(), randomsource, blockposition); + }); } - } diff --git a/nms-patches/net/minecraft/world/level/block/BlockMobSpawner.patch b/nms-patches/net/minecraft/world/level/block/BlockMobSpawner.patch index c812c6e61..8754c79b5 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockMobSpawner.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockMobSpawner.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockMobSpawner.java +++ b/net/minecraft/world/level/block/BlockMobSpawner.java -@@ -33,12 +33,20 @@ +@@ -43,12 +43,20 @@ @Override public void spawnAfterBreak(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) { super.spawnAfterBreak(iblockdata, worldserver, blockposition, itemstack, flag); diff --git a/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch b/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch index 91aa852e6..9956b7319 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch @@ -9,12 +9,12 @@ public class BlockMonsterEggs extends Block { private final Block hostBlock; -@@ -41,7 +43,7 @@ - EntitySilverfish entitysilverfish = (EntitySilverfish) EntityTypes.SILVERFISH.create(worldserver); +@@ -42,7 +44,7 @@ - entitysilverfish.moveTo((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F); -- worldserver.addFreshEntity(entitysilverfish); -+ worldserver.addFreshEntity(entitysilverfish, SpawnReason.SILVERFISH_BLOCK); // CraftBukkit - add SpawnReason - entitysilverfish.spawnAnim(); - } + if (entitysilverfish != null) { + entitysilverfish.moveTo((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F); +- worldserver.addFreshEntity(entitysilverfish); ++ worldserver.addFreshEntity(entitysilverfish, SpawnReason.SILVERFISH_BLOCK); // CraftBukkit - add SpawnReason + entitysilverfish.spawnAnim(); + } diff --git a/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch b/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch index 07d705c15..9b93497cb 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockMushroom.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockMushroom.java +++ b/net/minecraft/world/level/block/BlockMushroom.java -@@ -16,6 +16,10 @@ +@@ -18,6 +18,10 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -11,7 +11,7 @@ public class BlockMushroom extends BlockPlant implements IBlockFragilePlantElement { protected static final float AABB_OFFSET = 3.0F; -@@ -61,7 +65,7 @@ +@@ -63,7 +67,7 @@ } if (worldserver.isEmptyBlock(blockposition2) && iblockdata.canSurvive(worldserver, blockposition2)) { @@ -20,11 +20,11 @@ } } -@@ -82,6 +86,7 @@ - - public boolean growMushroom(WorldServer worldserver, BlockPosition blockposition, IBlockData iblockdata, RandomSource randomsource) { - worldserver.removeBlock(blockposition, false); -+ BlockSapling.treeType = (this == Blocks.BROWN_MUSHROOM) ? TreeType.BROWN_MUSHROOM : TreeType.BROWN_MUSHROOM; // CraftBukkit - if (((WorldGenFeatureConfigured) ((Holder) this.featureSupplier.get()).value()).place(worldserver, worldserver.getChunkSource().getGenerator(), randomsource, blockposition)) { - return true; +@@ -89,6 +93,7 @@ + return false; } else { + worldserver.removeBlock(blockposition, false); ++ BlockSapling.treeType = (this == Blocks.BROWN_MUSHROOM) ? TreeType.BROWN_MUSHROOM : TreeType.BROWN_MUSHROOM; // CraftBukkit + if (((WorldGenFeatureConfigured) ((Holder) optional.get()).value()).place(worldserver, worldserver.getChunkSource().getGenerator(), randomsource, blockposition)) { + return true; + } else { diff --git a/nms-patches/net/minecraft/world/level/block/BlockNote.patch b/nms-patches/net/minecraft/world/level/block/BlockNote.patch index 2c2c301c8..a00e29d47 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockNote.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockNote.patch @@ -1,24 +1,19 @@ --- a/net/minecraft/world/level/block/BlockNote.java +++ b/net/minecraft/world/level/block/BlockNote.java -@@ -51,7 +51,8 @@ - +@@ -77,6 +77,7 @@ if (flag1 != (Boolean) iblockdata.getValue(BlockNote.POWERED)) { if (flag1) { -- this.playNote((Entity) null, world, blockposition); -+ this.playNote((Entity) null, world, blockposition, iblockdata); // CraftBukkit + this.playNote((Entity) null, iblockdata, world, blockposition); + iblockdata = world.getBlockState(blockposition); // CraftBukkit - SPIGOT-5617: update in case changed in event } world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockNote.POWERED, flag1), 3); -@@ -59,11 +60,18 @@ +@@ -86,6 +87,12 @@ - } - -- private void playNote(@Nullable Entity entity, World world, BlockPosition blockposition) { -+ private void playNote(@Nullable Entity entity, World world, BlockPosition blockposition, IBlockData data) { // CraftBukkit - if (world.getBlockState(blockposition.above()).isAir()) { + private void playNote(@Nullable Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) { + if (!((BlockPropertyInstrument) iblockdata.getValue(BlockNote.INSTRUMENT)).requiresAirAbove() || world.getBlockState(blockposition.above()).isAir()) { + // CraftBukkit start -+ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, blockposition, data.getValue(BlockNote.INSTRUMENT), data.getValue(BlockNote.NOTE)); ++ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, blockposition, iblockdata.getValue(BlockNote.INSTRUMENT), iblockdata.getValue(BlockNote.NOTE)); + if (event.isCancelled()) { + return; + } @@ -26,25 +21,3 @@ world.blockEvent(blockposition, this, 0, 0); world.gameEvent(entity, GameEvent.NOTE_BLOCK_PLAY, blockposition); } -+ - } - - @Override -@@ -73,7 +81,7 @@ - } else { - iblockdata = (IBlockData) iblockdata.cycle(BlockNote.NOTE); - world.setBlock(blockposition, iblockdata, 3); -- this.playNote(entityhuman, world, blockposition); -+ this.playNote(entityhuman, world, blockposition, iblockdata); // CraftBukkit - entityhuman.awardStat(StatisticList.TUNE_NOTEBLOCK); - return EnumInteractionResult.CONSUME; - } -@@ -82,7 +90,7 @@ - @Override - public void attack(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) { - if (!world.isClientSide) { -- this.playNote(entityhuman, world, blockposition); -+ this.playNote(entityhuman, world, blockposition, iblockdata); // CraftBukkit - entityhuman.awardStat(StatisticList.PLAY_NOTEBLOCK); - } - } diff --git a/nms-patches/net/minecraft/world/level/block/BlockNylium.patch b/nms-patches/net/minecraft/world/level/block/BlockNylium.patch index 608f3c409..011872236 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockNylium.patch +++ b/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 -@@ -31,6 +31,11 @@ +@@ -33,6 +33,11 @@ @Override public void randomTick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, RandomSource randomsource) { if (!canBeNylium(iblockdata, worldserver, blockposition)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockPortal.patch b/nms-patches/net/minecraft/world/level/block/BlockPortal.patch index 96a7b2722..0c8d6f52b 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockPortal.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockPortal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockPortal.java +++ b/net/minecraft/world/level/block/BlockPortal.java -@@ -27,6 +27,10 @@ +@@ -24,6 +24,10 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -11,17 +11,17 @@ public class BlockPortal extends Block { public static final BlockStateEnum AXIS = BlockProperties.HORIZONTAL_AXIS; -@@ -58,7 +62,8 @@ +@@ -55,7 +59,8 @@ } if (worldserver.getBlockState(blockposition).isValidSpawn(worldserver, blockposition, EntityTypes.ZOMBIFIED_PIGLIN)) { -- Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawn(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.above(), EnumMobSpawn.STRUCTURE, false, false); +- Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawn(worldserver, blockposition.above(), EnumMobSpawn.STRUCTURE); + // CraftBukkit - set spawn reason to NETHER_PORTAL -+ Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawn(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.above(), EnumMobSpawn.STRUCTURE, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); ++ Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawn(worldserver, blockposition.above(), EnumMobSpawn.STRUCTURE, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); if (entity != null) { entity.setPortalCooldown(); -@@ -80,6 +85,10 @@ +@@ -77,6 +82,10 @@ @Override public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { if (!entity.isPassenger() && !entity.isVehicle() && entity.canChangeDimensions()) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockPressurePlateBinary.patch b/nms-patches/net/minecraft/world/level/block/BlockPressurePlateBinary.patch index c8f9bf8f1..fef2be489 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockPressurePlateBinary.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockPressurePlateBinary.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/BlockPressurePlateBinary.java +++ b/net/minecraft/world/level/block/BlockPressurePlateBinary.java -@@ -18,6 +18,8 @@ - import net.minecraft.world.level.material.Material; +@@ -17,6 +17,8 @@ + import net.minecraft.world.level.block.state.properties.BlockStateBoolean; import net.minecraft.world.phys.AxisAlignedBB; +import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit @@ -9,7 +9,7 @@ public class BlockPressurePlateBinary extends BlockPressurePlateAbstract { public static final BlockStateBoolean POWERED = BlockProperties.POWERED; -@@ -81,6 +83,26 @@ +@@ -74,6 +76,26 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); diff --git a/nms-patches/net/minecraft/world/level/block/BlockPressurePlateWeighted.patch b/nms-patches/net/minecraft/world/level/block/BlockPressurePlateWeighted.patch index 25ac3dcf7..49f2abe0b 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockPressurePlateWeighted.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockPressurePlateWeighted.patch @@ -9,7 +9,7 @@ public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract { public static final BlockStateInteger POWER = BlockProperties.POWER; -@@ -27,7 +29,31 @@ +@@ -31,7 +33,31 @@ @Override protected int getSignalStrength(World world, BlockPosition blockposition) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch b/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch index b60e96af3..df573e6c9 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch @@ -1,74 +1,30 @@ --- a/net/minecraft/world/level/block/BlockPumpkinCarved.java +++ b/net/minecraft/world/level/block/BlockPumpkinCarved.java -@@ -26,6 +26,11 @@ +@@ -26,6 +26,10 @@ import net.minecraft.world.level.block.state.properties.BlockStateDirection; import net.minecraft.world.level.material.Material; +// CraftBukkit start -+import org.bukkit.craftbukkit.util.BlockStateListPopulator; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +// CraftBukkit end + public class BlockPumpkinCarved extends BlockFacingHorizontal implements ItemWearable { public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING; -@@ -64,19 +69,28 @@ - EntityPlayer entityplayer; - int j; +@@ -82,9 +86,14 @@ + } -+ BlockStateListPopulator blockList = new BlockStateListPopulator(world); // CraftBukkit - Use BlockStateListPopulator - if (shapedetector_shapedetectorcollection != null) { - for (i = 0; i < this.getOrCreateSnowGolemFull().getHeight(); ++i) { - ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.getBlock(0, i, 0); + private static void spawnGolemInWorld(World world, ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection, Entity entity, BlockPosition blockposition) { +- clearPatternBlocks(world, shapedetector_shapedetectorcollection); ++ // clearPatternBlocks(world, shapedetector_shapedetectorcollection); // CraftBukkit - moved down + entity.moveTo((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.05D, (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F); +- world.addFreshEntity(entity); ++ // CraftBukkit start ++ if (!world.addFreshEntity(entity, SpawnReason.BUILD_IRONGOLEM)) { ++ return; ++ } ++ clearPatternBlocks(world, shapedetector_shapedetectorcollection); // CraftBukkit - from above ++ // CraftBukkit end + Iterator iterator = world.getEntitiesOfClass(EntityPlayer.class, entity.getBoundingBox().inflate(5.0D)).iterator(); -- world.setBlock(shapedetectorblock.getPos(), Blocks.AIR.defaultBlockState(), 2); -- world.levelEvent(2001, shapedetectorblock.getPos(), Block.getId(shapedetectorblock.getState())); -+ blockList.setBlock(shapedetectorblock.getPos(), Blocks.AIR.defaultBlockState(), 2); // CraftBukkit -+ // world.levelEvent(2001, shapedetectorblock.getPos(), Block.getId(shapedetectorblock.getState())); // CraftBukkit - } - - EntitySnowman entitysnowman = (EntitySnowman) EntityTypes.SNOW_GOLEM.create(world); - BlockPosition blockposition1 = shapedetector_shapedetectorcollection.getBlock(0, 2, 0).getPos(); - - entitysnowman.moveTo((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.05D, (double) blockposition1.getZ() + 0.5D, 0.0F, 0.0F); -- world.addFreshEntity(entitysnowman); -+ // CraftBukkit start -+ if (!world.addFreshEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) { -+ return; -+ } -+ for (BlockPosition pos : blockList.getBlocks()) { -+ world.levelEvent(2001, pos, Block.getId(world.getBlockState(pos))); -+ } -+ blockList.updateList(); -+ // CraftBukkit end - iterator = world.getEntitiesOfClass(EntityPlayer.class, entitysnowman.getBoundingBox().inflate(5.0D)).iterator(); - - while (iterator.hasNext()) { -@@ -96,8 +110,8 @@ - for (int k = 0; k < this.getOrCreateIronGolemFull().getHeight(); ++k) { - ShapeDetectorBlock shapedetectorblock2 = shapedetector_shapedetectorcollection.getBlock(i, k, 0); - -- world.setBlock(shapedetectorblock2.getPos(), Blocks.AIR.defaultBlockState(), 2); -- world.levelEvent(2001, shapedetectorblock2.getPos(), Block.getId(shapedetectorblock2.getState())); -+ blockList.setBlock(shapedetectorblock2.getPos(), Blocks.AIR.defaultBlockState(), 2); // CraftBukkit -+ // world.levelEvent(2001, shapedetectorblock2.getPos(), Block.getId(shapedetectorblock2.getState())); // CraftBukkit - } - } - -@@ -106,7 +120,15 @@ - - entityirongolem.setPlayerCreated(true); - entityirongolem.moveTo((double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.05D, (double) blockposition2.getZ() + 0.5D, 0.0F, 0.0F); -- world.addFreshEntity(entityirongolem); -+ // CraftBukkit start -+ if (!world.addFreshEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) { -+ return; -+ } -+ for (BlockPosition pos : blockList.getBlocks()) { -+ world.levelEvent(2001, pos, Block.getId(world.getBlockState(pos))); -+ } -+ blockList.updateList(); -+ // CraftBukkit end - iterator = world.getEntitiesOfClass(EntityPlayer.class, entityirongolem.getBoundingBox().inflate(5.0D)).iterator(); - - while (iterator.hasNext()) { + while (iterator.hasNext()) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockRedstoneWire.patch b/nms-patches/net/minecraft/world/level/block/BlockRedstoneWire.patch index a044e6341..620681b82 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockRedstoneWire.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockRedstoneWire.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockRedstoneWire.java +++ b/net/minecraft/world/level/block/BlockRedstoneWire.java -@@ -37,6 +37,8 @@ +@@ -36,6 +36,8 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -9,7 +9,7 @@ public class BlockRedstoneWire extends Block { public static final BlockStateEnum NORTH = BlockProperties.NORTH_REDSTONE; -@@ -255,7 +257,16 @@ +@@ -254,7 +256,16 @@ private void updatePowerStrength(World world, BlockPosition blockposition, IBlockData iblockdata) { int i = this.calculateTargetStrength(world, blockposition); diff --git a/nms-patches/net/minecraft/world/level/block/BlockSapling.patch b/nms-patches/net/minecraft/world/level/block/BlockSapling.patch index 6695878ec..5888367fa 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockSapling.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockSapling.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockSapling.java +++ b/net/minecraft/world/level/block/BlockSapling.java -@@ -14,12 +14,20 @@ +@@ -15,12 +15,20 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -21,7 +21,7 @@ protected BlockSapling(WorldGenTreeProvider worldgentreeprovider, BlockBase.Info blockbase_info) { super(blockbase_info); -@@ -44,7 +52,32 @@ +@@ -45,7 +53,32 @@ if ((Integer) iblockdata.getValue(BlockSapling.STAGE) == 0) { worldserver.setBlock(blockposition, (IBlockData) iblockdata.cycle(BlockSapling.STAGE), 4); } else { diff --git a/nms-patches/net/minecraft/world/level/block/BlockStem.patch b/nms-patches/net/minecraft/world/level/block/BlockStem.patch index 04747ad42..b0d4755bc 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockStem.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockStem.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockStem.java +++ b/net/minecraft/world/level/block/BlockStem.java -@@ -20,6 +20,8 @@ +@@ -21,6 +21,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -9,7 +9,7 @@ public class BlockStem extends BlockPlant implements IBlockFragilePlantElement { public static final int MAX_AGE = 7; -@@ -56,14 +58,18 @@ +@@ -57,14 +59,18 @@ if (i < 7) { iblockdata = (IBlockData) iblockdata.setValue(BlockStem.AGE, i + 1); @@ -30,7 +30,7 @@ worldserver.setBlockAndUpdate(blockposition, (IBlockData) this.fruit.getAttachedStem().defaultBlockState().setValue(BlockFacingHorizontal.FACING, enumdirection)); } } -@@ -92,7 +98,7 @@ +@@ -93,7 +99,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/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch b/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch index e6f8edbb6..48254eb35 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockSweetBerryBush.java +++ b/net/minecraft/world/level/block/BlockSweetBerryBush.java -@@ -27,6 +27,14 @@ +@@ -28,6 +28,14 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -15,7 +15,7 @@ public class BlockSweetBerryBush extends BlockPlant implements IBlockFragilePlantElement { private static final float HURT_SPEED_THRESHOLD = 0.003F; -@@ -62,7 +70,7 @@ +@@ -63,7 +71,7 @@ if (i < 3 && randomsource.nextInt(5) == 0 && worldserver.getRawBrightness(blockposition.above(), 0) >= 9) { IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSweetBerryBush.AGE, i + 1); @@ -24,7 +24,7 @@ worldserver.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1)); } -@@ -77,7 +85,9 @@ +@@ -78,7 +86,9 @@ double d1 = Math.abs(entity.getZ() - entity.zOld); if (d0 >= 0.003000000026077032D || d1 >= 0.003000000026077032D) { @@ -34,7 +34,7 @@ } } -@@ -94,7 +104,15 @@ +@@ -95,7 +105,15 @@ } else if (i > 1) { int j = 1 + world.random.nextInt(2); diff --git a/nms-patches/net/minecraft/world/level/block/BlockTallPlant.patch b/nms-patches/net/minecraft/world/level/block/BlockTallPlant.patch index edd9e3651..29e068b69 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTallPlant.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockTallPlant.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockTallPlant.java +++ b/net/minecraft/world/level/block/BlockTallPlant.java -@@ -92,6 +92,11 @@ +@@ -94,6 +94,11 @@ } protected static void preventCreativeDropFromBottomPart(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch b/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch index 7a4599e8e..6bc1d195e 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockTrapdoor.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockTrapdoor.java +++ b/net/minecraft/world/level/block/BlockTrapdoor.java -@@ -28,6 +28,8 @@ +@@ -30,6 +30,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -9,7 +9,7 @@ public class BlockTrapdoor extends BlockFacingHorizontal implements IBlockWaterlogged { public static final BlockStateBoolean OPEN = BlockProperties.OPEN; -@@ -116,6 +118,19 @@ +@@ -113,6 +115,19 @@ boolean flag1 = world.hasNeighborSignal(blockposition); if (flag1 != (Boolean) iblockdata.getValue(BlockTrapdoor.POWERED)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch b/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch index e7218a928..da3b4f904 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch @@ -54,12 +54,12 @@ worldserver.playSound((EntityHuman) null, blockposition, SoundEffects.TURTLE_EGG_HATCH, SoundCategory.BLOCKS, 0.7F, 0.9F + randomsource.nextFloat() * 0.2F); worldserver.removeBlock(blockposition, false); -@@ -104,7 +133,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); -- worldserver.addFreshEntity(entityturtle); -+ worldserver.addFreshEntity(entityturtle, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); // CraftBukkit +@@ -105,7 +134,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); +- worldserver.addFreshEntity(entityturtle); ++ worldserver.addFreshEntity(entityturtle, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); // CraftBukkit + } } } - } diff --git a/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch b/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch index b50996e4d..0b6490fba 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch @@ -1,18 +1,17 @@ --- a/net/minecraft/world/level/block/BlockWitherSkull.java +++ b/net/minecraft/world/level/block/BlockWitherSkull.java -@@ -26,6 +26,11 @@ +@@ -26,6 +26,10 @@ import net.minecraft.world.level.block.state.predicate.MaterialPredicate; import net.minecraft.world.level.material.Material; +// CraftBukkit start -+import org.bukkit.craftbukkit.util.BlockStateListPopulator; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +// CraftBukkit end + public class BlockWitherSkull extends BlockSkull { @Nullable -@@ -49,6 +54,7 @@ +@@ -49,6 +53,7 @@ } public static void checkSpawn(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) { @@ -20,45 +19,32 @@ if (!world.isClientSide) { IBlockData iblockdata = tileentityskull.getBlockState(); boolean flag = iblockdata.is(Blocks.WITHER_SKELETON_SKULL) || iblockdata.is(Blocks.WITHER_SKELETON_WALL_SKULL); -@@ -58,12 +64,14 @@ - ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.find(world, blockposition); +@@ -60,12 +65,18 @@ + EntityWither entitywither = (EntityWither) EntityTypes.WITHER.create(world); - if (shapedetector_shapedetectorcollection != null) { -+ // CraftBukkit start - Use BlockStateListPopulator -+ BlockStateListPopulator blockList = new BlockStateListPopulator(world); - for (int i = 0; i < shapedetector.getWidth(); ++i) { - for (int j = 0; j < shapedetector.getHeight(); ++j) { - ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.getBlock(i, j, 0); + if (entitywither != null) { +- BlockPumpkinCarved.clearPatternBlocks(world, shapedetector_shapedetectorcollection); ++ // BlockPumpkinCarved.clearPatternBlocks(world, shapedetector_shapedetectorcollection); // CraftBukkit - move down + BlockPosition blockposition1 = shapedetector_shapedetectorcollection.getBlock(1, 2, 0).getPos(); -- world.setBlock(shapedetectorblock.getPos(), Blocks.AIR.defaultBlockState(), 2); -- world.levelEvent(2001, shapedetectorblock.getPos(), Block.getId(shapedetectorblock.getState())); -+ blockList.setBlock(shapedetectorblock.getPos(), Blocks.AIR.defaultBlockState(), 2); // CraftBukkit -+ // world.levelEvent(2001, shapedetectorblock.getPos(), Block.getId(shapedetectorblock.getState())); // CraftBukkit + entitywither.moveTo((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.55D, (double) blockposition1.getZ() + 0.5D, shapedetector_shapedetectorcollection.getForwards().getAxis() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F); + entitywither.yBodyRot = shapedetector_shapedetectorcollection.getForwards().getAxis() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F; + entitywither.makeInvulnerable(); ++ // CraftBukkit start ++ if (!world.addFreshEntity(entitywither, SpawnReason.BUILD_WITHER)) { ++ return; ++ } ++ BlockPumpkinCarved.clearPatternBlocks(world, shapedetector_shapedetectorcollection); // CraftBukkit - from above ++ // CraftBukkit end + Iterator iterator = world.getEntitiesOfClass(EntityPlayer.class, entitywither.getBoundingBox().inflate(50.0D)).iterator(); + + while (iterator.hasNext()) { +@@ -74,7 +85,7 @@ + CriterionTriggers.SUMMONED_ENTITY.trigger(entityplayer, (Entity) entitywither); } + +- world.addFreshEntity(entitywither); ++ // world.addFreshEntity(entitywither); // CraftBukkit - moved up + BlockPumpkinCarved.updatePatternBlocks(world, shapedetector_shapedetectorcollection); } -@@ -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(); -+ // CraftBukkit start -+ if (!world.addFreshEntity(entitywither, SpawnReason.BUILD_WITHER)) { -+ return; -+ } -+ for (BlockPosition pos : blockList.getBlocks()) { -+ world.levelEvent(2001, pos, Block.getId(world.getBlockState(pos))); -+ } -+ blockList.updateList(); -+ // CraftBukkit end - Iterator iterator = world.getEntitiesOfClass(EntityPlayer.class, entitywither.getBoundingBox().inflate(50.0D)).iterator(); - - while (iterator.hasNext()) { -@@ -81,7 +98,7 @@ - CriterionTriggers.SUMMONED_ENTITY.trigger(entityplayer, (Entity) entitywither); - } - -- world.addFreshEntity(entitywither); -+ // world.addFreshEntity(entitywither); // CraftBukkit - moved up - - for (int k = 0; k < shapedetector.getWidth(); ++k) { - for (int l = 0; l < shapedetector.getHeight(); ++l) { diff --git a/nms-patches/net/minecraft/world/level/block/CaveVinesBlock.patch b/nms-patches/net/minecraft/world/level/block/CaveVinesBlock.patch index aca985b88..db14d6623 100644 --- a/nms-patches/net/minecraft/world/level/block/CaveVinesBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/CaveVinesBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CaveVinesBlock.java +++ b/net/minecraft/world/level/block/CaveVinesBlock.java -@@ -57,7 +57,7 @@ +@@ -58,7 +58,7 @@ @Override public EnumInteractionResult use(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) { diff --git a/nms-patches/net/minecraft/world/level/block/CaveVinesPlantBlock.patch b/nms-patches/net/minecraft/world/level/block/CaveVinesPlantBlock.patch index 57f58da3f..15243ccf4 100644 --- a/nms-patches/net/minecraft/world/level/block/CaveVinesPlantBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/CaveVinesPlantBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CaveVinesPlantBlock.java +++ b/net/minecraft/world/level/block/CaveVinesPlantBlock.java -@@ -40,7 +40,7 @@ +@@ -41,7 +41,7 @@ @Override public EnumInteractionResult use(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) { diff --git a/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch b/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch index af9dd1b9d..a7998e6ed 100644 --- a/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch @@ -31,12 +31,12 @@ world.setBlock(blockposition, (IBlockData) iblockdata.setValue(LightningRodBlock.POWERED, true), 3); this.updateNeighbours(iblockdata, world, blockposition); world.scheduleTick(blockposition, (Block) this, 8); -@@ -134,7 +151,7 @@ - Entity entity = iprojectile.getOwner(); +@@ -135,7 +152,7 @@ + Entity entity = iprojectile.getOwner(); + + entitylightning.setCause(entity instanceof EntityPlayer ? (EntityPlayer) entity : null); +- world.addFreshEntity(entitylightning); ++ ((WorldServer) world).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit + } - entitylightning.setCause(entity instanceof EntityPlayer ? (EntityPlayer) entity : null); -- world.addFreshEntity(entitylightning); -+ ((WorldServer) world).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit world.playSound((EntityHuman) null, blockposition, SoundEffects.TRIDENT_THUNDER, SoundCategory.WEATHER, 5.0F, 1.0F); - } - } diff --git a/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch b/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch index 5310672c1..8131dcd68 100644 --- a/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkSensorBlock.java +++ b/net/minecraft/world/level/block/SculkSensorBlock.java -@@ -42,6 +42,11 @@ +@@ -38,6 +38,11 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -12,7 +12,7 @@ public class SculkSensorBlock extends BlockTileEntity implements IBlockWaterlogged { public static final int ACTIVE_TICKS = 40; -@@ -135,6 +140,18 @@ +@@ -87,6 +92,18 @@ @Override public void stepOn(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { if (!world.isClientSide() && canActivate(iblockdata) && entity.getType() != EntityTypes.WARDEN) { @@ -31,7 +31,7 @@ TileEntity tileentity = world.getBlockEntity(blockposition); if (tileentity instanceof SculkSensorBlockEntity) { -@@ -234,6 +251,15 @@ +@@ -188,6 +205,15 @@ } public static void deactivate(World world, BlockPosition blockposition, IBlockData iblockdata) { @@ -47,7 +47,7 @@ world.setBlock(blockposition, (IBlockData) ((IBlockData) iblockdata.setValue(SculkSensorBlock.PHASE, SculkSensorPhase.COOLDOWN)).setValue(SculkSensorBlock.POWER, 0), 3); world.scheduleTick(blockposition, iblockdata.getBlock(), 1); if (!(Boolean) iblockdata.getValue(SculkSensorBlock.WATERLOGGED)) { -@@ -244,6 +270,15 @@ +@@ -198,6 +224,15 @@ } public static void activate(@Nullable Entity entity, World world, BlockPosition blockposition, IBlockData iblockdata, int i) { @@ -63,7 +63,7 @@ world.setBlock(blockposition, (IBlockData) ((IBlockData) iblockdata.setValue(SculkSensorBlock.PHASE, SculkSensorPhase.ACTIVE)).setValue(SculkSensorBlock.POWER, i), 3); world.scheduleTick(blockposition, iblockdata.getBlock(), 40); updateNeighbours(world, blockposition); -@@ -306,9 +341,16 @@ +@@ -260,9 +295,16 @@ @Override public void spawnAfterBreak(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) { super.spawnAfterBreak(iblockdata, worldserver, blockposition, itemstack, flag); diff --git a/nms-patches/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.patch b/nms-patches/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.patch new file mode 100644 index 000000000..98acf9f8f --- /dev/null +++ b/nms-patches/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.patch @@ -0,0 +1,66 @@ +--- a/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java +@@ -17,12 +17,54 @@ + import net.minecraft.world.level.block.state.properties.BlockStateBoolean; + import org.slf4j.Logger; + ++// CraftBukkit start ++import java.util.List; ++import org.bukkit.Location; ++import org.bukkit.craftbukkit.entity.CraftHumanEntity; ++import org.bukkit.entity.HumanEntity; ++// CraftBukkit end ++ + public class ChiseledBookShelfBlockEntity extends TileEntity implements IInventory { + + public static final int MAX_BOOKS_IN_STORAGE = 6; + private static final Logger LOGGER = LogUtils.getLogger(); + private final NonNullList items; + public int lastInteractedSlot; ++ // CraftBukkit start - add fields and methods ++ public List transaction = new java.util.ArrayList<>(); ++ private int maxStack = 1; ++ ++ @Override ++ public List getContents() { ++ return this.items; ++ } ++ ++ @Override ++ public void onOpen(CraftHumanEntity who) { ++ transaction.add(who); ++ } ++ ++ @Override ++ public void onClose(CraftHumanEntity who) { ++ transaction.remove(who); ++ } ++ ++ @Override ++ public List getViewers() { ++ return transaction; ++ } ++ ++ @Override ++ public void setMaxStackSize(int size) { ++ maxStack = size; ++ } ++ ++ @Override ++ public Location getLocation() { ++ if (level == null) return null; ++ return new org.bukkit.Location(level.getWorld(), worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()); ++ } ++ // CraftBukkit end + + public ChiseledBookShelfBlockEntity(BlockPosition blockposition, IBlockData iblockdata) { + super(TileEntityTypes.CHISELED_BOOKSHELF, blockposition, iblockdata); +@@ -113,7 +155,7 @@ + + @Override + public int getMaxStackSize() { +- return 1; ++ return maxStack; // CraftBukkit + } + + @Override diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBarrel.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBarrel.patch index 570715f7a..f7705b809 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBarrel.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBarrel.patch @@ -48,5 +48,5 @@ + } + // CraftBukkit end private NonNullList items; - public ContainerOpenersCounter openersCounter; + public final ContainerOpenersCounter openersCounter; diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch index 7f98340b6..f44d969f7 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityBeacon.java +++ b/net/minecraft/world/level/block/entity/TileEntityBeacon.java -@@ -37,6 +37,11 @@ +@@ -38,6 +38,11 @@ import net.minecraft.world.level.levelgen.HeightMap; import net.minecraft.world.phys.AxisAlignedBB; @@ -9,10 +9,10 @@ +import org.bukkit.potion.PotionEffect; +// CraftBukkit end + - public class TileEntityBeacon extends TileEntity implements ITileInventory { + public class TileEntityBeacon extends TileEntity implements ITileInventory, INamableTileEntity { private static final int MAX_LEVELS = 4; -@@ -59,6 +64,15 @@ +@@ -61,6 +66,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); -@@ -234,39 +248,78 @@ +@@ -236,39 +250,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); } -@@ -295,8 +348,11 @@ +@@ -297,8 +350,11 @@ @Override public void load(NBTTagCompound nbttagcompound) { super.load(nbttagcompound); diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch index 1021f0c69..4be4c3530 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch @@ -13,24 +13,24 @@ public class TileEntityCampfire extends TileEntity implements Clearable { private static final int BURN_COOL_SPEED = 2; -@@ -58,6 +64,20 @@ - return recipecampfire.assemble(inventorysubcontainer); +@@ -59,6 +65,20 @@ }).orElse(itemstack); -+ // CraftBukkit start - fire BlockCookEvent -+ CraftItemStack source = CraftItemStack.asCraftMirror(itemstack); -+ org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1); + if (itemstack1.isItemEnabled(world.enabledFeatures())) { ++ // CraftBukkit start - fire BlockCookEvent ++ CraftItemStack source = CraftItemStack.asCraftMirror(itemstack); ++ org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1); + -+ BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(world, blockposition), source, result); -+ world.getCraftServer().getPluginManager().callEvent(blockCookEvent); ++ BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(world, blockposition), source, result); ++ world.getCraftServer().getPluginManager().callEvent(blockCookEvent); + -+ if (blockCookEvent.isCancelled()) { -+ return; -+ } ++ if (blockCookEvent.isCancelled()) { ++ return; ++ } + -+ result = blockCookEvent.getResult(); -+ itemstack1 = CraftItemStack.asNMSCopy(result); -+ // CraftBukkit end - InventoryUtils.dropItemStack(world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1); - tileentitycampfire.items.set(i, ItemStack.EMPTY); - world.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3); ++ result = blockCookEvent.getResult(); ++ itemstack1 = CraftItemStack.asNMSCopy(result); ++ // CraftBukkit end + InventoryUtils.dropItemStack(world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1); + tileentitycampfire.items.set(i, ItemStack.EMPTY); + world.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3); diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityContainer.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityContainer.patch index 5e0076377..bb36a0fa7 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityContainer.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityContainer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityContainer.java +++ b/net/minecraft/world/level/block/entity/TileEntityContainer.java -@@ -88,4 +88,12 @@ +@@ -89,4 +89,12 @@ } protected abstract Container createMenu(int i, PlayerInventory playerinventory); diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch index 35208be28..4099dc87a 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityEndGateway.java +++ b/net/minecraft/world/level/block/entity/TileEntityEndGateway.java -@@ -32,6 +32,14 @@ +@@ -33,6 +33,14 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -15,7 +15,7 @@ public class TileEntityEndGateway extends TileEntityEnderPortal { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -168,7 +176,7 @@ +@@ -169,7 +177,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); -@@ -197,6 +205,27 @@ +@@ -198,6 +206,27 @@ entity1 = entity.getRootVehicle(); } diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch index e5c97a922..a7766b64a 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch @@ -30,7 +30,7 @@ } public static Map getFuel() { -@@ -188,6 +202,40 @@ +@@ -182,6 +196,40 @@ return map; } @@ -71,7 +71,7 @@ private static boolean isNeverAFurnaceFuel(Item item) { return item.builtInRegistryHolder().is(TagsItem.NON_FLAMMABLE_WOOD); } -@@ -276,7 +324,7 @@ +@@ -270,7 +318,7 @@ IRecipe irecipe; if (flag2) { @@ -80,7 +80,7 @@ } else { irecipe = null; } -@@ -284,9 +332,20 @@ +@@ -278,9 +326,20 @@ int i = tileentityfurnace.getMaxStackSize(); if (!tileentityfurnace.isLit() && canBurn(irecipe, tileentityfurnace.items, i)) { @@ -103,7 +103,7 @@ flag1 = true; if (flag3) { Item item = itemstack.getItem(); -@@ -302,11 +361,23 @@ +@@ -296,11 +355,23 @@ } if (tileentityfurnace.isLit() && canBurn(irecipe, tileentityfurnace.items, i)) { @@ -128,7 +128,7 @@ tileentityfurnace.setRecipeUsed(irecipe); } -@@ -345,17 +416,44 @@ +@@ -339,17 +410,44 @@ } } @@ -174,7 +174,7 @@ if (itemstack.is(Blocks.WET_SPONGE.asItem()) && !((ItemStack) nonnulllist.get(1)).isEmpty() && ((ItemStack) nonnulllist.get(1)).is(Items.BUCKET)) { nonnulllist.set(1, new ItemStack(Items.WATER_BUCKET)); -@@ -379,7 +477,7 @@ +@@ -373,7 +471,7 @@ } private static int getTotalCookTime(World world, TileEntityFurnace tileentityfurnace) { @@ -183,7 +183,7 @@ } public static boolean isFuel(ItemStack itemstack) { -@@ -498,14 +596,20 @@ +@@ -492,14 +590,20 @@ @Override public void awardUsedRecipes(EntityHuman entityhuman) {} @@ -206,7 +206,7 @@ List> list = Lists.newArrayList(); ObjectIterator objectiterator = this.recipesUsed.object2IntEntrySet().iterator(); -@@ -514,14 +618,14 @@ +@@ -508,14 +612,14 @@ worldserver.getRecipeManager().byKey((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> { list.add(irecipe); @@ -223,7 +223,7 @@ int j = MathHelper.floor((float) i * f); float f1 = MathHelper.frac((float) i * f); -@@ -529,6 +633,17 @@ +@@ -523,6 +627,17 @@ ++j; } diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch index 283773a34..60667be8f 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityShulkerBox.patch @@ -60,7 +60,7 @@ this.level.gameEvent((Entity) entityhuman, GameEvent.CONTAINER_OPEN, this.worldPosition); @@ -175,6 +212,7 @@ public void stopOpen(EntityHuman entityhuman) { - if (!entityhuman.isSpectator()) { + if (!this.remove && !entityhuman.isSpectator()) { --this.openCount; + if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call. this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount); diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch index 9d431706f..92ce5bb09 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntitySign.java +++ b/net/minecraft/world/level/block/entity/TileEntitySign.java -@@ -24,7 +24,7 @@ +@@ -25,7 +25,7 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; @@ -8,8 +8,8 @@ +public class TileEntitySign extends TileEntity implements ICommandListener { // CraftBukkit - implements public static final int LINES = 4; - private static final String[] RAW_TEXT_FIELD_NAMES = new String[]{"Text1", "Text2", "Text3", "Text4"}; -@@ -64,6 +64,12 @@ + private static final int MAX_TEXT_LINE_WIDTH = 90; +@@ -83,6 +83,12 @@ } } @@ -22,7 +22,7 @@ nbttagcompound.putString("Color", this.color.getName()); nbttagcompound.putBoolean("GlowingText", this.hasGlowingText); } -@@ -74,8 +80,24 @@ +@@ -93,8 +99,24 @@ super.load(nbttagcompound); this.color = EnumColor.byName(nbttagcompound.getString("Color"), EnumColor.BLACK); @@ -47,7 +47,7 @@ IChatBaseComponent ichatbasecomponent = this.loadLine(s); this.messages[i] = ichatbasecomponent; -@@ -113,6 +135,10 @@ +@@ -132,6 +154,10 @@ if (ichatmutablecomponent != null) { return ichatmutablecomponent; } @@ -58,7 +58,7 @@ } catch (Exception exception) { ; } -@@ -204,11 +230,37 @@ +@@ -240,11 +266,37 @@ return true; } @@ -97,7 +97,7 @@ } public EnumColor getColor() { -@@ -241,6 +293,6 @@ +@@ -277,6 +329,6 @@ private void markUpdated() { this.setChanged(); diff --git a/nms-patches/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.patch b/nms-patches/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.patch index 0c6ef6432..77aa0915e 100644 --- a/nms-patches/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.patch +++ b/nms-patches/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.patch @@ -1,10 +1,16 @@ --- a/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.java +++ b/net/minecraft/world/level/block/grower/WorldGenMegaTreeProvider.java -@@ -38,6 +38,7 @@ - if (holder == null) { +@@ -40,11 +40,12 @@ + if (resourcekey == null) { return false; } else { -+ setTreeType(holder); // CraftBukkit - WorldGenFeatureConfigured worldgenfeatureconfigured = (WorldGenFeatureConfigured) holder.value(); - IBlockData iblockdata1 = Blocks.AIR.defaultBlockState(); +- Holder> holder = (Holder) worldserver.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).getHolder(resourcekey).orElse((Object) null); ++ Holder> holder = (Holder) worldserver.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).getHolder(resourcekey).orElse(null); // CraftBukkit - decompile error + + if (holder == null) { + return false; + } else { ++ setTreeType(holder); // CraftBukkit + WorldGenFeatureConfigured worldgenfeatureconfigured = (WorldGenFeatureConfigured) holder.value(); + IBlockData iblockdata1 = Blocks.AIR.defaultBlockState(); diff --git a/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch b/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch index b7748cedb..cd90f3836 100644 --- a/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch +++ b/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/grower/WorldGenTreeProvider.java +++ b/net/minecraft/world/level/block/grower/WorldGenTreeProvider.java -@@ -12,6 +12,12 @@ +@@ -14,6 +14,12 @@ import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.levelgen.feature.WorldGenFeatureConfigured; @@ -13,21 +13,28 @@ public abstract class WorldGenTreeProvider { public WorldGenTreeProvider() {} -@@ -25,6 +31,7 @@ - if (holder == null) { +@@ -27,11 +33,12 @@ + if (resourcekey == null) { return false; } else { -+ setTreeType(holder); // CraftBukkit - WorldGenFeatureConfigured worldgenfeatureconfigured = (WorldGenFeatureConfigured) holder.value(); - IBlockData iblockdata1 = worldserver.getFluidState(blockposition).createLegacyBlock(); +- Holder> holder = (Holder) worldserver.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).getHolder(resourcekey).orElse((Object) null); ++ Holder> holder = (Holder) worldserver.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).getHolder(resourcekey).orElse(null); // CraftBukkit - decompile error -@@ -57,4 +64,52 @@ + if (holder == null) { + return false; + } else { ++ setTreeType(holder); // CraftBukkit + WorldGenFeatureConfigured worldgenfeatureconfigured = (WorldGenFeatureConfigured) holder.value(); + IBlockData iblockdata1 = worldserver.getFluidState(blockposition).createLegacyBlock(); + +@@ -65,4 +72,53 @@ return true; } + + // CraftBukkit start -+ protected void setTreeType(Holder> worldgentreeabstract) { ++ protected void setTreeType(Holder> holder) { ++ ResourceKey> worldgentreeabstract = holder.unwrapKey().get(); + if (worldgentreeabstract == TreeFeatures.OAK || worldgentreeabstract == TreeFeatures.OAK_BEES_005) { + BlockSapling.treeType = TreeType.TREE; + } else if (worldgentreeabstract == TreeFeatures.HUGE_RED_MUSHROOM) { diff --git a/nms-patches/net/minecraft/world/level/chunk/Chunk.patch b/nms-patches/net/minecraft/world/level/chunk/Chunk.patch index 9e87eb85c..0d6d691e4 100644 --- a/nms-patches/net/minecraft/world/level/chunk/Chunk.patch +++ b/nms-patches/net/minecraft/world/level/chunk/Chunk.patch @@ -10,12 +10,12 @@ private Supplier fullStatus; @Nullable @@ -94,7 +94,7 @@ - super(chunkcoordintpair, chunkconverter, world, world.registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY), i, achunksection, blendingdata); + super(chunkcoordintpair, chunkconverter, world, world.registryAccess().registryOrThrow(Registries.BIOME), i, achunksection, blendingdata); this.tickersInLevel = Maps.newHashMap(); this.clientLightReady = false; - this.level = world; + this.level = (WorldServer) world; // CraftBukkit - type - this.gameEventDispatcherSections = new Int2ObjectOpenHashMap(); + this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap(); HeightMap.Type[] aheightmap_type = HeightMap.Type.values(); int j = aheightmap_type.length; @@ -110,8 +110,20 @@ @@ -174,7 +174,7 @@ public boolean isEmpty() { return false; } -@@ -684,7 +775,7 @@ +@@ -682,7 +773,7 @@ private void updateBlockEntityTicker(T t0) { IBlockData iblockdata = t0.getBlockState(); @@ -183,7 +183,7 @@ if (blockentityticker == null) { this.removeBlockEntityTicker(t0.getBlockPos()); -@@ -777,7 +868,7 @@ +@@ -775,7 +866,7 @@ private boolean loggedInvalidBlockState; a(TileEntity tileentity, BlockEntityTicker blockentityticker) { diff --git a/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch b/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch index d7e9727ef..b1e8eabbe 100644 --- a/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch +++ b/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/net/minecraft/world/level/chunk/ChunkGenerator.java -@@ -417,7 +417,7 @@ +@@ -306,7 +306,7 @@ } } @@ -9,7 +9,7 @@ ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos(); if (!SharedConstants.debugVoidTerrain(chunkcoordintpair)) { -@@ -439,7 +439,7 @@ +@@ -328,7 +328,7 @@ for (int k = 0; k < j; ++k) { ChunkSection chunksection = achunksection[k]; @@ -18,7 +18,7 @@ Objects.requireNonNull(set); palettedcontainerro.getAll(set::add); -@@ -465,7 +465,7 @@ +@@ -354,7 +354,7 @@ Structure structure = (Structure) iterator.next(); seededrandom.setFeatureSeed(i, i1, l); @@ -27,12 +27,12 @@ Optional optional = iregistry.getResourceKey(structure).map(Object::toString); Objects.requireNonNull(structure); -@@ -550,6 +550,33 @@ +@@ -439,6 +439,33 @@ } } ++ // CraftBukkit start + public void applyBiomeDecoration(GeneratorAccessSeed generatoraccessseed, IChunkAccess ichunkaccess, StructureManager structuremanager) { -+ // CraftBukkit start + applyBiomeDecoration(generatoraccessseed, ichunkaccess, structuremanager, true); + } + @@ -55,9 +55,9 @@ + limitedRegion.saveEntities(); + limitedRegion.breakLink(); + } -+ // CraftBukkit end + } ++ // CraftBukkit end + - public boolean hasStructureChunkInRange(Holder holder, RandomState randomstate, long i, int j, int k, int l) { - StructureSet structureset = (StructureSet) holder.value(); - + private static StructureBoundingBox getWritableArea(IChunkAccess ichunkaccess) { + ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos(); + int i = chunkcoordintpair.getMinBlockX(); diff --git a/nms-patches/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.patch b/nms-patches/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.patch new file mode 100644 index 000000000..ac75ddd5c --- /dev/null +++ b/nms-patches/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.patch @@ -0,0 +1,7 @@ +--- a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java ++++ b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java +@@ -1,3 +1,4 @@ ++// mc-dev import + package net.minecraft.world.level.chunk; + + import com.google.common.base.Stopwatch; diff --git a/nms-patches/net/minecraft/world/level/chunk/ChunkStatus.patch b/nms-patches/net/minecraft/world/level/chunk/ChunkStatus.patch index 3a8e3510e..90d983395 100644 --- a/nms-patches/net/minecraft/world/level/chunk/ChunkStatus.patch +++ b/nms-patches/net/minecraft/world/level/chunk/ChunkStatus.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/chunk/ChunkStatus.java +++ b/net/minecraft/world/level/chunk/ChunkStatus.java -@@ -47,7 +47,7 @@ +@@ -48,7 +48,7 @@ }); public static final ChunkStatus STRUCTURE_STARTS = register("structure_starts", ChunkStatus.EMPTY, 0, ChunkStatus.PRE_FEATURES, ChunkStatus.Type.PROTOCHUNK, (chunkstatus, executor, worldserver, chunkgenerator, structuretemplatemanager, lightenginethreaded, function, list, ichunkaccess, flag) -> { if (!ichunkaccess.getStatus().isOrAfter(chunkstatus)) { -- if (worldserver.getServer().getWorldData().worldGenSettings().generateStructures()) { -+ if (worldserver.serverLevelData.worldGenSettings().generateStructures()) { // CraftBukkit - chunkgenerator.createStructures(worldserver.registryAccess(), worldserver.getChunkSource().randomState(), worldserver.structureManager(), ichunkaccess, structuretemplatemanager, worldserver.getSeed()); +- if (worldserver.getServer().getWorldData().worldGenOptions().generateStructures()) { ++ if (worldserver.serverLevelData.worldGenOptions().generateStructures()) { // CraftBukkit + chunkgenerator.createStructures(worldserver.registryAccess(), worldserver.getChunkSource().getGeneratorState(), worldserver.structureManager(), ichunkaccess, structuretemplatemanager); } diff --git a/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch b/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch index 528fb3648..fd8424238 100644 --- a/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch +++ b/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java +++ b/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java -@@ -100,7 +100,7 @@ +@@ -102,7 +102,7 @@ ChunkProviderServer chunkproviderserver = worldserver.getChunkSource(); LightEngine lightengine = chunkproviderserver.getLightEngine(); - IRegistry iregistry = worldserver.registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY); + IRegistry iregistry = worldserver.registryAccess().registryOrThrow(Registries.BIOME); - Codec>> codec = makeBiomeCodec(iregistry); + Codec>> codec = makeBiomeCodecRW(iregistry); // CraftBukkit - read/write boolean flag2 = false; DataResult dataresult; -@@ -120,12 +120,12 @@ +@@ -122,12 +122,12 @@ }); logger = ChunkRegionLoader.LOGGER; Objects.requireNonNull(logger); @@ -24,7 +24,7 @@ if (nbttagcompound1.contains("biomes", 10)) { dataresult = codec.parse(DynamicOpsNBT.INSTANCE, nbttagcompound1.getCompound("biomes")).promotePartial((s) -> { -@@ -133,12 +133,12 @@ +@@ -135,12 +135,12 @@ }); logger = ChunkRegionLoader.LOGGER; Objects.requireNonNull(logger); @@ -39,7 +39,7 @@ achunksection[k] = chunksection; villageplace.checkConsistencyWithBlocks(chunkcoordintpair, chunksection); -@@ -172,7 +172,7 @@ +@@ -174,7 +174,7 @@ dataresult = BlendingData.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("blending_data"))); logger1 = ChunkRegionLoader.LOGGER; Objects.requireNonNull(logger1); @@ -48,7 +48,7 @@ } else { blendingdata = null; } -@@ -203,7 +203,7 @@ +@@ -205,7 +205,7 @@ dataresult = BelowZeroRetrogen.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("below_zero_retrogen"))); logger1 = ChunkRegionLoader.LOGGER; Objects.requireNonNull(logger1); @@ -57,7 +57,7 @@ Objects.requireNonNull(protochunk); optional.ifPresent(protochunk::setBelowZeroRetrogen); -@@ -232,6 +232,13 @@ +@@ -234,6 +234,13 @@ } } @@ -71,7 +71,7 @@ ((IChunkAccess) object1).setLightCorrect(flag); NBTTagCompound nbttagcompound2 = nbttagcompound.getCompound("Heightmaps"); EnumSet enumset = EnumSet.noneOf(HeightMap.Type.class); -@@ -322,6 +329,12 @@ +@@ -328,6 +335,12 @@ return DataPaletteBlock.codecRO(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getHolderOrThrow(Biomes.PLAINS)); } @@ -84,7 +84,7 @@ public static NBTTagCompound write(WorldServer worldserver, IChunkAccess ichunkaccess) { ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos(); NBTTagCompound nbttagcompound = new NBTTagCompound(); -@@ -334,7 +347,7 @@ +@@ -340,7 +353,7 @@ nbttagcompound.putLong("InhabitedTime", ichunkaccess.getInhabitedTime()); nbttagcompound.putString("Status", ichunkaccess.getStatus().getName()); BlendingData blendingdata = ichunkaccess.getBlendingData(); @@ -93,7 +93,7 @@ Logger logger; if (blendingdata != null) { -@@ -381,7 +394,7 @@ +@@ -387,7 +400,7 @@ if (flag1) { ChunkSection chunksection = achunksection[j]; @@ -102,7 +102,7 @@ Logger logger1 = ChunkRegionLoader.LOGGER; Objects.requireNonNull(logger1); -@@ -465,6 +478,11 @@ +@@ -471,6 +484,11 @@ nbttagcompound.put("Heightmaps", nbttagcompound3); nbttagcompound.put("structures", packStructureData(StructurePieceSerializationContext.fromLevel(worldserver), chunkcoordintpair, ichunkaccess.getAllStarts(), ichunkaccess.getAllReferences())); diff --git a/nms-patches/net/minecraft/world/level/chunk/storage/RegionFileCache.patch b/nms-patches/net/minecraft/world/level/chunk/storage/RegionFileCache.patch index 57edeb9b5..139e55385 100644 --- a/nms-patches/net/minecraft/world/level/chunk/storage/RegionFileCache.patch +++ b/nms-patches/net/minecraft/world/level/chunk/storage/RegionFileCache.patch @@ -13,7 +13,7 @@ Path path = this.folder; int j = chunkcoordintpair.getRegionX(); Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca"); -+ if (existingOnly && !Files.exists(path1)) return null; // CraftBukkit ++ if (existingOnly && !java.nio.file.Files.exists(path1)) return null; // CraftBukkit RegionFile regionfile1 = new RegionFile(path1, this.folder, this.sync); this.regionCache.putAndMoveToFirst(i, regionfile1); diff --git a/nms-patches/net/minecraft/world/level/gameevent/GameEventDispatcher.patch b/nms-patches/net/minecraft/world/level/gameevent/GameEventDispatcher.patch new file mode 100644 index 000000000..44296cb98 --- /dev/null +++ b/nms-patches/net/minecraft/world/level/gameevent/GameEventDispatcher.patch @@ -0,0 +1,32 @@ +--- a/net/minecraft/world/level/gameevent/GameEventDispatcher.java ++++ b/net/minecraft/world/level/gameevent/GameEventDispatcher.java +@@ -11,6 +11,14 @@ + import net.minecraft.world.level.chunk.Chunk; + import net.minecraft.world.phys.Vec3D; + ++// CraftBukkit start ++import net.minecraft.core.registries.BuiltInRegistries; ++import org.bukkit.Bukkit; ++import org.bukkit.Location; ++import org.bukkit.craftbukkit.util.CraftNamespacedKey; ++import org.bukkit.event.world.GenericGameEvent; ++// CraftBukkit end ++ + public class GameEventDispatcher { + + private final WorldServer level; +@@ -22,6 +30,14 @@ + public void post(GameEvent gameevent, Vec3D vec3d, GameEvent.a gameevent_a) { + int i = gameevent.getNotificationRadius(); + BlockPosition blockposition = new BlockPosition(vec3d); ++ // CraftBukkit start ++ GenericGameEvent event = new GenericGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.GAME_EVENT.getKey(gameevent))), new Location(level.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()), (gameevent_a.sourceEntity() == null) ? null : gameevent_a.sourceEntity().getBukkitEntity(), i, !Bukkit.isPrimaryThread()); ++ level.getCraftServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ return; ++ } ++ i = event.getRadius(); ++ // CraftBukkit end + int j = SectionPosition.blockToSectionCoord(blockposition.getX() - i); + int k = SectionPosition.blockToSectionCoord(blockposition.getY() - i); + int l = SectionPosition.blockToSectionCoord(blockposition.getZ() - i); diff --git a/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationListener.patch b/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationListener.patch index 7ee31dad5..570dac021 100644 --- a/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationListener.patch +++ b/nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationListener.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/gameevent/vibrations/VibrationListener.java +++ b/net/minecraft/world/level/gameevent/vibrations/VibrationListener.java -@@ -28,6 +28,13 @@ +@@ -29,6 +29,13 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start -+import net.minecraft.core.IRegistry; ++import net.minecraft.core.registries.BuiltInRegistries; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.event.block.BlockReceiveGameEvent; @@ -13,65 +13,38 @@ + public class VibrationListener implements GameEventListener { - protected final PositionSource listenerSource; -@@ -51,7 +58,7 @@ + @VisibleForTesting +@@ -96,7 +103,7 @@ }), ExtraCodecs.NON_NEGATIVE_INT.fieldOf("event_delay").orElse(0).forGetter((vibrationlistener) -> { return vibrationlistener.travelTimeInTicks; - })).apply(instance, (positionsource, integer, optional, ofloat, integer1) -> { -- return new VibrationListener(positionsource, integer, vibrationlistener_b, (VibrationListener.a) optional.orElse((Object) null), ofloat, integer1); -+ return new VibrationListener(positionsource, integer, vibrationlistener_b, (VibrationListener.a) optional.orElse(null), ofloat, integer1); // CraftBukkit - decompile error + })).apply(instance, (positionsource, integer, optional, vibrationselector, integer1) -> { +- return new VibrationListener(positionsource, integer, vibrationlistener_a, (VibrationInfo) optional.orElse((Object) null), vibrationselector, integer1); ++ return new VibrationListener(positionsource, integer, vibrationlistener_a, (VibrationInfo) optional.orElse(null), vibrationselector, integer1); // CraftBukkit - decompile error }); }); } -@@ -73,7 +80,7 @@ +@@ -138,7 +145,7 @@ --this.travelTimeInTicks; if (this.travelTimeInTicks <= 0) { this.travelTimeInTicks = 0; -- this.config.onSignalReceive(worldserver, this, new BlockPosition(this.receivingEvent.pos), this.receivingEvent.gameEvent, (Entity) this.receivingEvent.getEntity(worldserver).orElse((Object) null), (Entity) this.receivingEvent.getProjectileOwner(worldserver).orElse((Object) null), this.receivingDistance); -+ this.config.onSignalReceive(worldserver, this, new BlockPosition(this.receivingEvent.pos), this.receivingEvent.gameEvent, (Entity) this.receivingEvent.getEntity(worldserver).orElse(null), (Entity) this.receivingEvent.getProjectileOwner(worldserver).orElse(null), this.receivingDistance); // CraftBukkit - decompile error - this.receivingEvent = null; +- this.config.onSignalReceive(worldserver, this, new BlockPosition(this.currentVibration.pos()), this.currentVibration.gameEvent(), (Entity) this.currentVibration.getEntity(worldserver).orElse((Object) null), (Entity) this.currentVibration.getProjectileOwner(worldserver).orElse((Object) null), this.currentVibration.distance()); ++ this.config.onSignalReceive(worldserver, this, new BlockPosition(this.currentVibration.pos()), this.currentVibration.gameEvent(), (Entity) this.currentVibration.getEntity(worldserver).orElse(null), (Entity) this.currentVibration.getProjectileOwner(worldserver).orElse(null), this.currentVibration.distance()); // CraftBukkit - decompile error + this.currentVibration = null; } } -@@ -110,7 +117,14 @@ - Vec3D vec3d = gameevent_b.source(); - Vec3D vec3d1 = (Vec3D) optional.get(); +@@ -170,7 +177,14 @@ + } else { + Vec3D vec3d1 = (Vec3D) optional.get(); -- if (!this.config.shouldListen(worldserver, this, new BlockPosition(vec3d), gameevent, gameevent_a)) { -+ // CraftBukkit start -+ boolean defaultCancel = !this.config.shouldListen(worldserver, this, new BlockPosition(vec3d), gameevent, gameevent_a); -+ Entity entity = gameevent_a.sourceEntity(); -+ BlockReceiveGameEvent event = new BlockReceiveGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.GAME_EVENT.getKey(gameevent))), CraftBlock.at(worldserver, new BlockPosition(vec3d1)), (entity == null) ? null : entity.getBukkitEntity()); -+ event.setCancelled(defaultCancel); -+ worldserver.getCraftServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ // CraftBukkit end - return false; - } else if (isOccluded(worldserver, vec3d, vec3d1)) { - return false; -@@ -206,7 +220,7 @@ - }), ExtraCodecs.UUID.optionalFieldOf("projectile_owner").forGetter((vibrationlistener_a) -> { - return Optional.ofNullable(vibrationlistener_a.projectileOwnerUuid()); - })).apply(instance, (gameevent, ofloat, vec3d, optional, optional1) -> { -- return new VibrationListener.a(gameevent, ofloat, vec3d, (UUID) optional.orElse((Object) null), (UUID) optional1.orElse((Object) null)); -+ return new VibrationListener.a(gameevent, ofloat, vec3d, (UUID) optional.orElse(null), (UUID) optional1.orElse(null)); // CraftBukkit - decompile error - }); - }); - -@@ -233,7 +247,7 @@ - - public Optional getEntity(WorldServer worldserver) { - return Optional.ofNullable(this.entity).or(() -> { -- Optional optional = Optional.ofNullable(this.uuid); -+ Optional optional = Optional.ofNullable(this.uuid); // CraftBukkit - decompile error - - Objects.requireNonNull(worldserver); - return optional.map(worldserver::getEntity); -@@ -246,7 +260,7 @@ - }).map((entity) -> { - return (IProjectile) entity; - }).map(IProjectile::getOwner).or(() -> { -- Optional optional = Optional.ofNullable(this.projectileOwnerUuid); -+ Optional optional = Optional.ofNullable(this.projectileOwnerUuid); // CraftBukkit - decompile error - - Objects.requireNonNull(worldserver); - return optional.map(worldserver::getEntity); +- if (!this.config.shouldListen(worldserver, this, new BlockPosition(vec3d), gameevent, gameevent_a)) { ++ // CraftBukkit start ++ boolean defaultCancel = !this.config.shouldListen(worldserver, this, new BlockPosition(vec3d), gameevent, gameevent_a); ++ Entity entity = gameevent_a.sourceEntity(); ++ BlockReceiveGameEvent event = new BlockReceiveGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.GAME_EVENT.getKey(gameevent))), CraftBlock.at(worldserver, new BlockPosition(vec3d1)), (entity == null) ? null : entity.getBukkitEntity()); ++ event.setCancelled(defaultCancel); ++ worldserver.getCraftServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ // CraftBukkit end + return false; + } else if (isOccluded(worldserver, vec3d, vec3d1)) { + return false; diff --git a/nms-patches/net/minecraft/world/level/levelgen/ChunkProviderFlat.patch b/nms-patches/net/minecraft/world/level/levelgen/ChunkProviderFlat.patch index 486579ede..6434e53e0 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/ChunkProviderFlat.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/ChunkProviderFlat.patch @@ -1,23 +1,21 @@ --- a/net/minecraft/world/level/levelgen/ChunkProviderFlat.java +++ b/net/minecraft/world/level/levelgen/ChunkProviderFlat.java -@@ -32,11 +32,17 @@ +@@ -35,10 +35,16 @@ private final GeneratorSettingsFlat settings; - public ChunkProviderFlat(IRegistry iregistry, GeneratorSettingsFlat generatorsettingsflat) { -- Optional optional = generatorsettingsflat.structureOverrides(); + public ChunkProviderFlat(GeneratorSettingsFlat generatorsettingsflat) { - WorldChunkManagerHell worldchunkmanagerhell = new WorldChunkManagerHell(generatorsettingsflat.getBiome()); + // CraftBukkit start -+ // Optional optional = generatorsettingsflat.structureOverrides(); + // WorldChunkManagerHell worldchunkmanagerhell = new WorldChunkManagerHell(generatorsettingsflat.getBiome()); - Objects.requireNonNull(generatorsettingsflat); -- super(iregistry, optional, worldchunkmanagerhell, SystemUtils.memoize(generatorsettingsflat::adjustGenerationSettings)); +- super(worldchunkmanagerhell, SystemUtils.memoize(generatorsettingsflat::adjustGenerationSettings)); + // Objects.requireNonNull(generatorsettingsflat); -+ this(iregistry, generatorsettingsflat, new WorldChunkManagerHell(generatorsettingsflat.getBiome())); ++ this(generatorsettingsflat, new WorldChunkManagerHell(generatorsettingsflat.getBiome())); + } + -+ public ChunkProviderFlat(IRegistry iregistry, GeneratorSettingsFlat generatorsettingsflat, net.minecraft.world.level.biome.WorldChunkManager worldchunkmanager) { -+ super(iregistry, generatorsettingsflat.structureOverrides(), worldchunkmanager, SystemUtils.memoize(generatorsettingsflat::adjustGenerationSettings)); ++ public ChunkProviderFlat(GeneratorSettingsFlat generatorsettingsflat, net.minecraft.world.level.biome.WorldChunkManager worldchunkmanager) { ++ super(worldchunkmanager, SystemUtils.memoize(generatorsettingsflat::adjustGenerationSettings)); + // CraftBukkit end this.settings = generatorsettingsflat; } diff --git a/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPhantom.patch b/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPhantom.patch index da85e3924..9fd5c5678 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPhantom.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPhantom.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/levelgen/MobSpawnerPhantom.java +++ b/net/minecraft/world/level/levelgen/MobSpawnerPhantom.java -@@ -75,7 +75,7 @@ - - entityphantom.moveTo(blockposition1, 0.0F, 0.0F); - groupdataentity = entityphantom.finalizeSpawn(worldserver, difficultydamagescaler, EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null); -- worldserver.addFreshEntityWithPassengers(entityphantom); -+ worldserver.addFreshEntityWithPassengers(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit +@@ -76,7 +76,7 @@ + if (entityphantom != null) { + entityphantom.moveTo(blockposition1, 0.0F, 0.0F); + groupdataentity = entityphantom.finalizeSpawn(worldserver, difficultydamagescaler, EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null); +- worldserver.addFreshEntityWithPassengers(entityphantom); ++ worldserver.addFreshEntityWithPassengers(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit + ++i; + } } - - i += k; diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/SwampHutPiece.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/SwampHutPiece.patch index 608acdbe8..0dc4ec237 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/SwampHutPiece.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/SwampHutPiece.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/SwampHutPiece.java +++ b/net/minecraft/world/level/levelgen/structure/structures/SwampHutPiece.java -@@ -99,7 +99,7 @@ - entitywitch.setPersistenceRequired(); - entitywitch.moveTo((double) blockposition_mutableblockposition.getX() + 0.5D, (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + 0.5D, 0.0F, 0.0F); - entitywitch.finalizeSpawn(generatoraccessseed, generatoraccessseed.getCurrentDifficultyAt(blockposition_mutableblockposition), EnumMobSpawn.STRUCTURE, (GroupDataEntity) null, (NBTTagCompound) null); -- generatoraccessseed.addFreshEntityWithPassengers(entitywitch); -+ generatoraccessseed.addFreshEntityWithPassengers(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason +@@ -100,7 +100,7 @@ + entitywitch.setPersistenceRequired(); + entitywitch.moveTo((double) blockposition_mutableblockposition.getX() + 0.5D, (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + 0.5D, 0.0F, 0.0F); + entitywitch.finalizeSpawn(generatoraccessseed, generatoraccessseed.getCurrentDifficultyAt(blockposition_mutableblockposition), EnumMobSpawn.STRUCTURE, (GroupDataEntity) null, (NBTTagCompound) null); +- generatoraccessseed.addFreshEntityWithPassengers(entitywitch); ++ generatoraccessseed.addFreshEntityWithPassengers(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason + } } } - -@@ -118,7 +118,7 @@ - entitycat.setPersistenceRequired(); - entitycat.moveTo((double) blockposition_mutableblockposition.getX() + 0.5D, (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + 0.5D, 0.0F, 0.0F); - entitycat.finalizeSpawn(worldaccess, worldaccess.getCurrentDifficultyAt(blockposition_mutableblockposition), EnumMobSpawn.STRUCTURE, (GroupDataEntity) null, (NBTTagCompound) null); -- worldaccess.addFreshEntityWithPassengers(entitycat); -+ worldaccess.addFreshEntityWithPassengers(entitycat, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason +@@ -121,7 +121,7 @@ + entitycat.setPersistenceRequired(); + entitycat.moveTo((double) blockposition_mutableblockposition.getX() + 0.5D, (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + 0.5D, 0.0F, 0.0F); + entitycat.finalizeSpawn(worldaccess, worldaccess.getCurrentDifficultyAt(blockposition_mutableblockposition), EnumMobSpawn.STRUCTURE, (GroupDataEntity) null, (NBTTagCompound) null); +- worldaccess.addFreshEntityWithPassengers(entitycat); ++ worldaccess.addFreshEntityWithPassengers(entitycat, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason + } } } - diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch index 200cd16b6..2c78f77e7 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java -@@ -51,6 +51,12 @@ +@@ -52,6 +52,12 @@ import net.minecraft.world.phys.shapes.VoxelShapeBitSet; import net.minecraft.world.phys.shapes.VoxelShapeDiscrete; @@ -13,7 +13,7 @@ public class DefinedStructure { public static final String PALETTE_TAG = "palette"; -@@ -70,6 +76,11 @@ +@@ -71,6 +77,11 @@ private BaseBlockPosition size; private String author; @@ -25,7 +25,7 @@ public DefinedStructure() { this.size = BaseBlockPosition.ZERO; this.author = "?"; -@@ -143,7 +154,7 @@ +@@ -144,7 +155,7 @@ } private static List buildInfoList(List list, List list1, List list2) { @@ -34,7 +34,7 @@ return definedstructure_blockinfo.pos.getY(); }).thenComparingInt((definedstructure_blockinfo) -> { return definedstructure_blockinfo.pos.getX(); -@@ -464,11 +475,13 @@ +@@ -465,11 +476,13 @@ } private static Optional createEntityIgnoreException(WorldAccess worldaccess, NBTTagCompound nbttagcompound) { @@ -52,7 +52,7 @@ } public BaseBlockPosition getSize(EnumBlockRotation enumblockrotation) { -@@ -683,6 +696,13 @@ +@@ -684,6 +697,13 @@ nbttagcompound.put("entities", nbttaglist3); nbttagcompound.put("size", this.newIntegerList(this.size.getX(), this.size.getY(), this.size.getZ())); nbttagcompound.putInt("DataVersion", SharedConstants.getCurrentVersion().getWorldVersion()); @@ -66,7 +66,7 @@ return nbttagcompound; } -@@ -722,6 +742,12 @@ +@@ -723,6 +743,12 @@ } } @@ -78,8 +78,8 @@ + // CraftBukkit end } - private void loadPalette(NBTTagList nbttaglist, NBTTagList nbttaglist1) { -@@ -861,7 +887,7 @@ + private void loadPalette(HolderGetter holdergetter, NBTTagList nbttaglist, NBTTagList nbttaglist1) { +@@ -862,7 +888,7 @@ public IBlockData stateFor(int i) { IBlockData iblockdata = (IBlockData) this.ids.byId(i); diff --git a/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch b/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch index ea22096e1..e0d98830f 100644 --- a/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch +++ b/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch @@ -17,35 +17,35 @@ public static final BlockStateBoolean FALLING = BlockProperties.FALLING; @@ -130,6 +139,15 @@ - Fluid fluid1 = this.getNewLiquid(generatoraccess, blockposition1, iblockdata1); + Fluid fluid1 = this.getNewLiquid(world, blockposition1, iblockdata1); - if (this.canSpreadTo(generatoraccess, blockposition, iblockdata, EnumDirection.DOWN, blockposition1, iblockdata1, generatoraccess.getFluidState(blockposition1), fluid1.getType())) { + if (this.canSpreadTo(world, blockposition, iblockdata, EnumDirection.DOWN, blockposition1, iblockdata1, world.getFluidState(blockposition1), fluid1.getType())) { + // CraftBukkit start -+ org.bukkit.block.Block source = CraftBlock.at(generatoraccess, blockposition); ++ org.bukkit.block.Block source = CraftBlock.at(world, blockposition); + BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN); -+ generatoraccess.getMinecraftWorld().getCraftServer().getPluginManager().callEvent(event); ++ world.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; + } + // CraftBukkit end - this.spreadTo(generatoraccess, blockposition1, iblockdata1, EnumDirection.DOWN, fluid1); - if (this.sourceNeighborCount(generatoraccess, blockposition) >= 3) { - this.spreadToSides(generatoraccess, blockposition, fluid, iblockdata); + this.spreadTo(world, blockposition1, iblockdata1, EnumDirection.DOWN, fluid1); + if (this.sourceNeighborCount(world, blockposition) >= 3) { + this.spreadToSides(world, blockposition, fluid, iblockdata); @@ -160,6 +178,15 @@ - IBlockData iblockdata1 = generatoraccess.getBlockState(blockposition1); + IBlockData iblockdata1 = world.getBlockState(blockposition1); - if (this.canSpreadTo(generatoraccess, blockposition, iblockdata, enumdirection, blockposition1, iblockdata1, generatoraccess.getFluidState(blockposition1), fluid1.getType())) { + if (this.canSpreadTo(world, blockposition, iblockdata, enumdirection, blockposition1, iblockdata1, world.getFluidState(blockposition1), fluid1.getType())) { + // CraftBukkit start -+ org.bukkit.block.Block source = CraftBlock.at(generatoraccess, blockposition); ++ org.bukkit.block.Block source = CraftBlock.at(world, blockposition); + BlockFromToEvent event = new BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection)); -+ generatoraccess.getMinecraftWorld().getCraftServer().getPluginManager().callEvent(event); ++ world.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + continue; + } + // CraftBukkit end - this.spreadTo(generatoraccess, blockposition1, iblockdata1, enumdirection, fluid1); + this.spreadTo(world, blockposition1, iblockdata1, enumdirection, fluid1); } } @@ -438,12 +465,23 @@ diff --git a/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch b/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch index d507c8897..88fb15b34 100644 --- a/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch +++ b/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/portal/BlockPortalShape.java +++ b/net/minecraft/world/level/portal/BlockPortalShape.java -@@ -18,6 +18,11 @@ - import net.minecraft.world.level.block.state.properties.BlockProperties; - import net.minecraft.world.phys.Vec3D; +@@ -22,6 +22,11 @@ + import net.minecraft.world.phys.shapes.VoxelShape; + import net.minecraft.world.phys.shapes.VoxelShapes; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftPortalEvent; @@ -12,7 +12,7 @@ public class BlockPortalShape { private static final int MIN_WIDTH = 2; -@@ -35,6 +40,7 @@ +@@ -41,6 +46,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) -> { -@@ -55,6 +61,7 @@ +@@ -61,6 +67,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; -@@ -99,6 +106,7 @@ +@@ -105,6 +112,7 @@ if (!isEmpty(iblockdata)) { if (BlockPortalShape.FRAME.test(iblockdata, this.level, blockposition_mutableblockposition)) { @@ -36,7 +36,7 @@ return i; } break; -@@ -109,6 +117,7 @@ +@@ -115,6 +123,7 @@ if (!BlockPortalShape.FRAME.test(iblockdata1, this.level, blockposition_mutableblockposition)) { break; } @@ -44,7 +44,7 @@ } return 0; -@@ -128,6 +137,7 @@ +@@ -134,6 +143,7 @@ if (!BlockPortalShape.FRAME.test(this.level.getBlockState(blockposition_mutableblockposition1), this.level, blockposition_mutableblockposition1)) { return false; } @@ -52,7 +52,7 @@ } return true; -@@ -157,6 +167,10 @@ +@@ -163,6 +173,10 @@ ++this.numPortalBlocks; } } @@ -63,7 +63,7 @@ } return 21; -@@ -170,12 +184,28 @@ +@@ -176,12 +190,28 @@ return this.bottomLeft != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; } @@ -93,20 +93,21 @@ } public boolean isComplete() { -@@ -212,7 +242,7 @@ +@@ -218,7 +248,7 @@ return new Vec3D(d2, d3, d4); } -- public static ShapeDetectorShape createPortalInfo(WorldServer worldserver, BlockUtil.Rectangle blockutil_rectangle, EnumDirection.EnumAxis enumdirection_enumaxis, Vec3D vec3d, EntitySize entitysize, Vec3D vec3d1, float f, float f1) { -+ public static ShapeDetectorShape createPortalInfo(WorldServer worldserver, BlockUtil.Rectangle blockutil_rectangle, EnumDirection.EnumAxis enumdirection_enumaxis, Vec3D vec3d, EntitySize entitysize, Vec3D vec3d1, float f, float f1, CraftPortalEvent portalEventInfo) { // CraftBukkit +- public static ShapeDetectorShape createPortalInfo(WorldServer worldserver, BlockUtil.Rectangle blockutil_rectangle, EnumDirection.EnumAxis enumdirection_enumaxis, Vec3D vec3d, Entity entity, Vec3D vec3d1, float f, float f1) { ++ public static ShapeDetectorShape createPortalInfo(WorldServer worldserver, BlockUtil.Rectangle blockutil_rectangle, EnumDirection.EnumAxis enumdirection_enumaxis, Vec3D vec3d, Entity entity, Vec3D vec3d1, float f, float f1, CraftPortalEvent portalEventInfo) { // CraftBukkit 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); -@@ -226,6 +256,6 @@ - boolean flag = enumdirection_enumaxis1 == EnumDirection.EnumAxis.X; +@@ -234,7 +264,7 @@ Vec3D vec3d3 = new Vec3D((double) blockposition.getX() + (flag ? d2 : d4), (double) blockposition.getY() + d3, (double) blockposition.getZ() + (flag ? d4 : d2)); + Vec3D vec3d4 = findCollisionFreePosition(vec3d3, worldserver, entity, entitysize); -- return new ShapeDetectorShape(vec3d3, vec3d2, f + (float) i, f1); -+ return new ShapeDetectorShape(vec3d3, vec3d2, f + (float) i, f1, worldserver, portalEventInfo); // CraftBukkit +- return new ShapeDetectorShape(vec3d4, vec3d2, f + (float) i, f1); ++ return new ShapeDetectorShape(vec3d4, vec3d2, f + (float) i, f1, worldserver, portalEventInfo); // CraftBukkit } - } + + private static Vec3D findCollisionFreePosition(Vec3D vec3d, WorldServer worldserver, Entity entity, EntitySize entitysize) { diff --git a/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch b/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch index 9f0894cb9..9ca358485 100644 --- a/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch +++ b/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch @@ -30,7 +30,7 @@ + private WorldMap(int i, int j, byte b0, boolean flag, boolean flag1, boolean flag2, ResourceKey resourcekey) { this.scale = b0; - this.x = i; + this.centerX = i; @@ -62,6 +79,10 @@ this.unlimitedTracking = flag1; this.locked = flag2; @@ -107,8 +107,8 @@ + } + } + // CraftBukkit end - nbttagcompound.putInt("xCenter", this.x); - nbttagcompound.putInt("zCenter", this.z); + nbttagcompound.putInt("xCenter", this.centerX); + nbttagcompound.putInt("zCenter", this.centerZ); nbttagcompound.putByte("scale", this.scale); @@ -503,7 +561,7 @@ this.player = entityhuman; diff --git a/nms-patches/net/minecraft/world/level/storage/Convertable.patch b/nms-patches/net/minecraft/world/level/storage/Convertable.patch index 3fae5bfc5..fc64e3ad3 100644 --- a/nms-patches/net/minecraft/world/level/storage/Convertable.patch +++ b/nms-patches/net/minecraft/world/level/storage/Convertable.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/storage/Convertable.java +++ b/net/minecraft/world/level/storage/Convertable.java -@@ -61,6 +61,10 @@ - import net.minecraft.world.level.levelgen.presets.WorldPresets; +@@ -69,6 +69,10 @@ + import net.minecraft.world.level.levelgen.WorldDimensions; import org.slf4j.Logger; +// CraftBukkit start @@ -11,29 +11,24 @@ public class Convertable { static final Logger LOGGER = LogUtils.getLogger(); -@@ -114,7 +118,7 @@ +@@ -115,7 +119,7 @@ } - private static DataPackConfiguration readDataPackConfig(Dynamic dynamic) { -- DataResult dataresult = DataPackConfiguration.CODEC.parse(dynamic); -+ DataResult dataresult = DataPackConfiguration.CODEC.parse(dynamic); // CraftBukkit - decompile error + private static WorldDataConfiguration readDataConfig(Dynamic dynamic) { +- DataResult dataresult = WorldDataConfiguration.CODEC.parse(dynamic); ++ DataResult dataresult = WorldDataConfiguration.CODEC.parse(dynamic); // CraftBukkit - decompile error Logger logger = Convertable.LOGGER; Objects.requireNonNull(logger); -@@ -241,7 +245,11 @@ - WorldSettings worldsettings = WorldSettings.parse(dynamic, datapackconfiguration); - Lifecycle lifecycle1 = ((Lifecycle) pair.getSecond()).add(lifecycle); +@@ -253,6 +257,7 @@ + WorldDimensions.b worlddimensions_b = generatorsettings.dimensions().bake(iregistry); + Lifecycle lifecycle1 = worlddimensions_b.lifecycle().add(lifecycle); + WorldDataServer worlddataserver = WorldDataServer.parse(dynamic, datafixer, i, nbttagcompound2, worldsettings, levelversion, worlddimensions_b.specialWorldProperty(), generatorsettings.options(), lifecycle1); ++ worlddataserver.pdc = nbttagcompound1.get("BukkitValues"); // CraftBukkit - Add PDC to world -- 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(), lifecycle1); -+ worldDataServer.pdc = nbttagcompound1.get("BukkitValues"); -+ return worldDataServer; -+ // CraftBukkit end - } catch (Exception exception) { - Convertable.LOGGER.error("Exception reading {}", path, exception); - return null; -@@ -314,9 +322,23 @@ + return Pair.of(worlddataserver, worlddimensions_b); + }; +@@ -334,9 +339,23 @@ return this.backupDir; } @@ -59,7 +54,7 @@ public static record a(List levels) implements Iterable { -@@ -369,8 +391,12 @@ +@@ -389,8 +408,12 @@ public final Convertable.b levelDirectory; private final String levelId; private final Map resources = Maps.newHashMap(); @@ -73,7 +68,7 @@ this.levelId = s; this.levelDirectory = new Convertable.b(Convertable.this.baseDir.resolve(s)); this.lock = SessionLock.create(this.levelDirectory.path()); -@@ -381,7 +407,7 @@ +@@ -401,7 +424,7 @@ } public Path getLevelPath(SavedFile savedfile) { @@ -82,7 +77,7 @@ Convertable.b convertable_b = this.levelDirectory; Objects.requireNonNull(this.levelDirectory); -@@ -389,7 +415,7 @@ +@@ -409,7 +432,7 @@ } public Path getDimensionPath(ResourceKey resourcekey) { diff --git a/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch b/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch index 0ca6c2b56..9db1551ed 100644 --- a/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch +++ b/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/WorldDataServer.java +++ b/net/minecraft/world/level/storage/WorldDataServer.java -@@ -42,6 +42,15 @@ +@@ -43,6 +43,15 @@ import net.minecraft.world.level.timers.CustomFunctionCallbackTimers; import org.slf4j.Logger; @@ -16,7 +16,7 @@ public class WorldDataServer implements IWorldDataServer, SaveData { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -81,6 +90,19 @@ +@@ -83,6 +92,19 @@ private final Set knownServerBrands; private boolean wasModded; private final CustomFunctionCallbackTimerQueue scheduledEvents; @@ -34,9 +34,9 @@ + } + // CraftBukkit end - 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) { - if (!generatorsettings.dimensions().containsKey(WorldDimension.OVERWORLD)) { -@@ -128,7 +150,8 @@ + private WorldDataServer(@Nullable DataFixer datafixer, int i, @Nullable NBTTagCompound nbttagcompound, boolean flag, int j, int k, int l, float f, long i1, long j1, int k1, int l1, int i2, boolean flag1, int j2, boolean flag2, boolean flag3, boolean flag4, WorldBorder.c worldborder_c, int k2, int l2, @Nullable UUID uuid, Set set, CustomFunctionCallbackTimerQueue customfunctioncallbacktimerqueue, @Nullable NBTTagCompound nbttagcompound1, NBTTagCompound nbttagcompound2, WorldSettings worldsettings, WorldOptions worldoptions, WorldDataServer.a worlddataserver_a, Lifecycle lifecycle) { + this.fixerUpper = datafixer; +@@ -127,7 +149,8 @@ return (NBTBase) dynamic.get("DimensionData").get("1").get("DragonFight").orElseEmptyMap().getValue(); }); @@ -44,9 +44,9 @@ + // 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(UUIDUtil.CODEC).result().orElse(null), (Set) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> { 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); + }).collect(Collectors.toCollection(Sets::newLinkedHashSet)), new CustomFunctionCallbackTimerQueue<>(CustomFunctionCallbackTimers.SERVER_CALLBACKS, dynamic.get("ScheduledEvents").asStream()), (NBTTagCompound) dynamic.get("CustomBossEvents").orElseEmptyMap().getValue(), nbttagcompound1, worldsettings, worldoptions, worlddataserver_a, lifecycle); } -@@ -148,7 +171,7 @@ +@@ -147,7 +170,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); -@@ -163,7 +186,7 @@ +@@ -162,7 +185,7 @@ nbttagcompound.put("Version", nbttagcompound2); nbttagcompound.putInt("DataVersion", SharedConstants.getCurrentVersion().getWorldVersion()); - 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 + DynamicOps dynamicops = RegistryOps.create(DynamicOpsNBT.INSTANCE, (HolderLookup.b) iregistrycustom); +- DataResult dataresult = GeneratorSettings.encode(dynamicops, this.worldOptions, iregistrycustom); ++ DataResult dataresult = GeneratorSettings.encode(dynamicops, this.worldOptions, iregistrycustom); // CraftBukkit - decompile error Logger logger = WorldDataServer.LOGGER; Objects.requireNonNull(logger); -@@ -211,6 +234,8 @@ +@@ -214,6 +237,8 @@ nbttagcompound.putUUID("WanderingTraderId", this.wanderingTraderId); } @@ -73,7 +73,7 @@ } @Override -@@ -328,6 +353,20 @@ +@@ -331,6 +356,20 @@ @Override public void setThundering(boolean flag) { @@ -94,7 +94,7 @@ this.thundering = flag; } -@@ -348,6 +387,20 @@ +@@ -351,6 +390,20 @@ @Override public void setRaining(boolean flag) { @@ -115,7 +115,7 @@ this.raining = flag; } -@@ -414,6 +467,12 @@ +@@ -417,6 +470,12 @@ @Override public void setDifficulty(EnumDifficulty enumdifficulty) { this.settings = this.settings.withDifficulty(enumdifficulty); @@ -128,11 +128,10 @@ } @Override -@@ -534,4 +593,12 @@ - public WorldSettings getLevelSettings() { +@@ -548,6 +607,14 @@ return this.settings.copy(); } -+ + + // CraftBukkit start - Check if the name stored in NBT is the correct one + public void checkName(String name) { + if (!this.settings.levelName.equals(name)) { @@ -140,4 +139,7 @@ + } + } + // CraftBukkit end - } ++ + /** @deprecated */ + @Deprecated + public static enum a { diff --git a/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch b/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch index ef729d747..6bf2a9f47 100644 --- a/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch +++ b/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch @@ -14,7 +14,7 @@ public class LootTable { static final Logger LOGGER = LogUtils.getLogger(); -@@ -117,8 +124,21 @@ +@@ -119,8 +126,21 @@ } public void fill(IInventory iinventory, LootTableInfo loottableinfo) { diff --git a/pom.xml b/pom.xml index eb0e934f0..8810fa769 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.bukkit craftbukkit jar - 1.19.2-R0.1-SNAPSHOT + 1.19.3-R0.1-SNAPSHOT CraftBukkit https://www.spigotmc.org/ @@ -13,7 +13,7 @@ UTF-8 unknown git - 1_19_R1 + 1_19_R2 17 17 @@ -48,7 +48,7 @@ org.apache.logging.log4j log4j-iostreams - 2.17.0 + 2.19.0 compile @@ -61,13 +61,13 @@ com.github.oshi oshi-core - 5.8.5 + 6.2.2 compile com.mojang authlib - 3.11.49 + 3.16.29 compile @@ -85,13 +85,13 @@ com.mojang javabridge - 1.2.24 + 2.0.25 compile com.mojang logging - 1.0.0 + 1.1.1 compile @@ -103,81 +103,81 @@ io.netty netty-buffer - 4.1.77.Final + 4.1.82.Final compile io.netty netty-codec - 4.1.77.Final + 4.1.82.Final compile io.netty netty-common - 4.1.77.Final + 4.1.82.Final compile io.netty netty-handler - 4.1.77.Final + 4.1.82.Final compile io.netty netty-resolver - 4.1.77.Final + 4.1.82.Final compile io.netty netty-transport - 4.1.77.Final + 4.1.82.Final compile io.netty netty-transport-classes-epoll - 4.1.77.Final + 4.1.82.Final compile io.netty netty-transport-native-epoll - 4.1.77.Final + 4.1.82.Final linux-x86_64 compile io.netty netty-transport-native-epoll - 4.1.77.Final + 4.1.82.Final linux-aarch_64 compile io.netty netty-transport-native-unix-common - 4.1.77.Final + 4.1.82.Final compile it.unimi.dsi fastutil - 8.5.6 + 8.5.9 compile net.java.dev.jna jna - 5.10.0 + 5.12.1 compile net.java.dev.jna jna-platform - 5.10.0 + 5.12.1 compile @@ -195,19 +195,25 @@ org.apache.logging.log4j log4j-core - 2.17.0 + 2.19.0 compile org.apache.logging.log4j - log4j-slf4j18-impl - 2.17.0 + log4j-slf4j2-impl + 2.19.0 + compile + + + org.joml + joml + 1.10.5 compile org.slf4j slf4j-api - 1.8.0-beta4 + 2.0.1 compile diff --git a/src/main/java/org/bukkit/craftbukkit/CraftArt.java b/src/main/java/org/bukkit/craftbukkit/CraftArt.java index dcfa7b5d2..a4f35fed6 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftArt.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftArt.java @@ -4,7 +4,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.BiMap; import com.google.common.collect.ImmutableBiMap; import net.minecraft.core.Holder; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceKey; import net.minecraft.world.entity.decoration.PaintingVariant; import org.bukkit.Art; @@ -14,8 +14,8 @@ public class CraftArt { static { ImmutableBiMap.Builder, Art> artworkBuilder = ImmutableBiMap.builder(); - for (ResourceKey key : IRegistry.PAINTING_VARIANT.registryKeySet()) { - artworkBuilder.put(IRegistry.PAINTING_VARIANT.getHolderOrThrow(key), Art.getByName(key.location().getPath())); + for (ResourceKey key : BuiltInRegistries.PAINTING_VARIANT.registryKeySet()) { + artworkBuilder.put(BuiltInRegistries.PAINTING_VARIANT.getHolderOrThrow(key), Art.getByName(key.location().getPath())); } artwork = artworkBuilder.build(); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index d58076279..43515bd64 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -14,6 +14,7 @@ import net.minecraft.core.BlockPosition; import net.minecraft.core.Holder; import net.minecraft.core.IRegistry; import net.minecraft.core.SectionPosition; +import net.minecraft.core.registries.Registries; import net.minecraft.nbt.DynamicOpsNBT; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.server.level.WorldServer; @@ -296,7 +297,7 @@ public class CraftChunk implements Chunk { boolean[] sectionEmpty = new boolean[cs.length]; PalettedContainerRO>[] biome = (includeBiome || includeBiomeTempRain) ? new DataPaletteBlock[cs.length] : null; - IRegistry iregistry = worldServer.registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY); + IRegistry iregistry = worldServer.registryAccess().registryOrThrow(Registries.BIOME); Codec>> biomeCodec = DataPaletteBlock.codecRO(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getHolderOrThrow(Biomes.PLAINS)); for (int i = 0; i < cs.length; i++) { @@ -352,7 +353,7 @@ public class CraftChunk implements Chunk { byte[][] skyLight = new byte[hSection][]; byte[][] emitLight = new byte[hSection][]; boolean[] empty = new boolean[hSection]; - IRegistry iregistry = world.getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY); + IRegistry iregistry = world.getHandle().registryAccess().registryOrThrow(Registries.BIOME); DataPaletteBlock>[] biome = (includeBiome || includeBiomeTempRain) ? new DataPaletteBlock[hSection] : null; Codec>> biomeCodec = DataPaletteBlock.codecRO(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getHolderOrThrow(Biomes.PLAINS)); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftParticle.java b/src/main/java/org/bukkit/craftbukkit/CraftParticle.java index 61949ff08..0f6fff086 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftParticle.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftParticle.java @@ -3,11 +3,9 @@ package org.bukkit.craftbukkit; import com.google.common.base.Preconditions; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; -import com.mojang.math.Vector3fa; import java.util.HashMap; import java.util.Map; import net.minecraft.core.BlockPosition; -import net.minecraft.core.IRegistry; import net.minecraft.core.particles.DustColorTransitionOptions; import net.minecraft.core.particles.ParticleParam; import net.minecraft.core.particles.ParticleParamBlock; @@ -17,6 +15,7 @@ import net.minecraft.core.particles.ParticleType; import net.minecraft.core.particles.SculkChargeParticleOptions; import net.minecraft.core.particles.ShriekParticleOption; import net.minecraft.core.particles.VibrationParticleOption; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.MinecraftKey; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.gameevent.BlockPositionSource; @@ -33,6 +32,7 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.inventory.ItemStack; import org.bukkit.material.MaterialData; +import org.joml.Vector3f; public enum CraftParticle { @@ -171,7 +171,7 @@ public enum CraftParticle { canonical = aliases.get(particle); } - net.minecraft.core.particles.Particle nms = IRegistry.PARTICLE_TYPE.get(particles.get(canonical)); + net.minecraft.core.particles.Particle nms = BuiltInRegistries.PARTICLE_TYPE.get(particles.get(canonical)); Preconditions.checkArgument(nms != null, "No NMS particle %s", particle); if (particle.getDataType().equals(Void.class)) { @@ -193,13 +193,13 @@ public enum CraftParticle { if (particle.getDataType() == Particle.DustOptions.class) { Particle.DustOptions data = (Particle.DustOptions) obj; Color color = data.getColor(); - return new ParticleParamRedstone(new Vector3fa(color.getRed() / 255.0f, color.getGreen() / 255.0f, color.getBlue() / 255.0f), data.getSize()); + return new ParticleParamRedstone(new Vector3f(color.getRed() / 255.0f, color.getGreen() / 255.0f, color.getBlue() / 255.0f), data.getSize()); } if (particle.getDataType() == Particle.DustTransition.class) { Particle.DustTransition data = (Particle.DustTransition) obj; Color from = data.getColor(); Color to = data.getToColor(); - return new DustColorTransitionOptions(new Vector3fa(from.getRed() / 255.0f, from.getGreen() / 255.0f, from.getBlue() / 255.0f), new Vector3fa(to.getRed() / 255.0f, to.getGreen() / 255.0f, to.getBlue() / 255.0f), data.getSize()); + return new DustColorTransitionOptions(new Vector3f(from.getRed() / 255.0f, from.getGreen() / 255.0f, from.getBlue() / 255.0f), new Vector3f(to.getRed() / 255.0f, to.getGreen() / 255.0f, to.getBlue() / 255.0f), data.getSize()); } if (particle.getDataType() == Vibration.class) { Vibration vibration = (Vibration) obj; @@ -232,6 +232,6 @@ public enum CraftParticle { } public static Particle toBukkit(net.minecraft.core.particles.Particle nms) { - return particles.inverse().get(IRegistry.PARTICLE_TYPE.getKey(nms)); + return particles.inverse().get(BuiltInRegistries.PARTICLE_TYPE.getKey(nms)); } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java index 50e2d11ce..cf5ba4080 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java @@ -11,7 +11,10 @@ import net.minecraft.core.BlockPosition; import net.minecraft.core.EnumDirection; import net.minecraft.core.Holder; import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.data.worldgen.features.TreeFeatures; +import net.minecraft.resources.ResourceKey; import net.minecraft.util.RandomSource; import net.minecraft.world.entity.EntityAreaEffectCloud; import net.minecraft.world.entity.EntityExperienceOrb; @@ -79,6 +82,7 @@ import org.bukkit.entity.Bat; import org.bukkit.entity.Bee; import org.bukkit.entity.Blaze; import org.bukkit.entity.Boat; +import org.bukkit.entity.Camel; import org.bukkit.entity.Cat; import org.bukkit.entity.CaveSpider; import org.bukkit.entity.ChestBoat; @@ -221,7 +225,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor { @Override public Biome getBiome(int x, int y, int z) { - return CraftBlock.biomeBaseToBiome(getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY), getHandle().getNoiseBiome(x >> 2, y >> 2, z >> 2)); + return CraftBlock.biomeBaseToBiome(getHandle().registryAccess().registryOrThrow(Registries.BIOME), getHandle().getNoiseBiome(x >> 2, y >> 2, z >> 2)); } @Override @@ -232,7 +236,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor { @Override public void setBiome(int x, int y, int z, Biome biome) { Preconditions.checkArgument(biome != Biome.CUSTOM, "Cannot set the biome to %s", biome); - Holder biomeBase = CraftBlock.biomeToBiomeBase(getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY), biome); + Holder biomeBase = CraftBlock.biomeToBiomeBase(getHandle().registryAccess().registryOrThrow(Registries.BIOME), biome); setBiome(x, y, z, biomeBase); } @@ -327,7 +331,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor { } public boolean generateTree(GeneratorAccessSeed access, ChunkGenerator chunkGenerator, BlockPosition pos, RandomSource random, TreeType treeType) { - Holder gen; + ResourceKey> gen; switch (treeType) { case BIG_TREE: gen = TreeFeatures.FANCY_OAK; @@ -398,7 +402,8 @@ public abstract class CraftRegionAccessor implements RegionAccessor { break; } - return ((WorldGenFeatureConfigured) gen.value()).place(access, chunkGenerator, random, pos); + Holder> holder = access.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).getHolder(gen).orElse(null); + return (holder != null) ? holder.value().place(access, chunkGenerator, random, pos) : false; } @Override @@ -694,6 +699,8 @@ public abstract class CraftRegionAccessor implements RegionAccessor { entity = EntityTypes.SKELETON_HORSE.create(world); } else if (ZombieHorse.class.isAssignableFrom(clazz)) { entity = EntityTypes.ZOMBIE_HORSE.create(world); + } else if (Camel.class.isAssignableFrom(clazz)) { + entity = EntityTypes.CAMEL.create(world); } else { entity = EntityTypes.HORSE.create(world); } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java index 05fe8d7e0..bbf6851dd 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java @@ -7,6 +7,8 @@ import java.util.function.BiFunction; import java.util.stream.Stream; import net.minecraft.core.IRegistry; import net.minecraft.core.IRegistryCustom; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.bukkit.Registry; @@ -20,10 +22,10 @@ public class CraftRegistry implements Registry { public static Registry createRegistry(Class bukkitClass, IRegistryCustom registryHolder) { if (bukkitClass == Structure.class) { - return new CraftRegistry<>(registryHolder.registryOrThrow(IRegistry.STRUCTURE_REGISTRY), CraftStructure::new); + return new CraftRegistry<>(registryHolder.registryOrThrow(Registries.STRUCTURE), CraftStructure::new); } if (bukkitClass == StructureType.class) { - return new CraftRegistry<>(IRegistry.STRUCTURE_TYPES, CraftStructureType::new); + return new CraftRegistry<>(BuiltInRegistries.STRUCTURE_TYPE, CraftStructureType::new); } return null; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index a0f586e88..20cdae8de 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -7,11 +7,14 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterators; import com.google.common.collect.Lists; import com.google.common.collect.MapMaker; +import com.google.gson.JsonObject; import com.mojang.authlib.GameProfile; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.tree.CommandNode; import com.mojang.brigadier.tree.LiteralCommandNode; +import com.mojang.datafixers.util.Pair; +import com.mojang.serialization.DynamicOps; import com.mojang.serialization.Lifecycle; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufOutputStream; @@ -51,11 +54,18 @@ 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.HolderLookup; import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.nbt.DynamicOpsNBT; +import net.minecraft.nbt.NBTBase; import net.minecraft.resources.MinecraftKey; +import net.minecraft.resources.RegistryOps; import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; import net.minecraft.server.ServerCommand; +import net.minecraft.server.WorldLoader; import net.minecraft.server.bossevents.BossBattleCustom; import net.minecraft.server.commands.CommandReload; import net.minecraft.server.dedicated.DedicatedPlayerList; @@ -101,10 +111,14 @@ import net.minecraft.world.level.dimension.WorldDimension; import net.minecraft.world.level.levelgen.GeneratorSettings; import net.minecraft.world.level.levelgen.MobSpawnerPatrol; import net.minecraft.world.level.levelgen.MobSpawnerPhantom; +import net.minecraft.world.level.levelgen.WorldDimensions; +import net.minecraft.world.level.levelgen.WorldOptions; +import net.minecraft.world.level.levelgen.presets.WorldPresets; import net.minecraft.world.level.material.FluidType; import net.minecraft.world.level.saveddata.maps.MapIcon; import net.minecraft.world.level.saveddata.maps.WorldMap; import net.minecraft.world.level.storage.Convertable; +import net.minecraft.world.level.storage.SaveData; import net.minecraft.world.level.storage.WorldDataServer; import net.minecraft.world.level.storage.WorldNBTStorage; import net.minecraft.world.level.storage.loot.LootTableRegistry; @@ -644,7 +658,7 @@ public final class CraftServer implements Server { @Override public boolean getGenerateStructures() { - return this.getProperties().getWorldGenSettings(this.getServer().registryAccess()).generateStructures(); + return this.getServer().getWorldData().worldGenOptions().generateStructures(); } @Override @@ -1037,16 +1051,28 @@ public final class CraftServer implements Server { boolean hardcore = creator.hardcore(); - WorldDataServer worlddata = (WorldDataServer) worldSession.getDataTag(console.registryreadops, console.datapackconfiguration, console.registryHolder.allElementsLifecycle()); + WorldDataServer worlddata; + WorldLoader.a worldloader_a = console.worldLoader; + IRegistry iregistry = worldloader_a.datapackDimensions().registryOrThrow(Registries.LEVEL_STEM); + DynamicOps dynamicops = RegistryOps.create(DynamicOpsNBT.INSTANCE, (HolderLookup.b) worldloader_a.datapackWorldgen()); + Pair pair = worldSession.getDataTag(dynamicops, worldloader_a.dataConfiguration(), iregistry, worldloader_a.datapackWorldgen().allRegistriesLifecycle()); - WorldSettings worldSettings; - // See MinecraftServer.a(String, String, long, WorldType, JsonElement) - if (worlddata == null) { - DedicatedServerProperties.a properties = new DedicatedServerProperties.a(Objects.toString(creator.seed()), ChatDeserializer.parse((creator.generatorSettings().isEmpty()) ? "{}" : creator.generatorSettings()), creator.generateStructures(), creator.type().name().toLowerCase(Locale.ROOT)); + if (pair != null) { + worlddata = (WorldDataServer) pair.getFirst(); + } else { + WorldSettings worldsettings; + WorldOptions worldoptions = new WorldOptions(creator.seed(), creator.generateStructures(), false); + WorldDimensions worlddimensions; - GeneratorSettings generatorsettings = properties.create(console.registryAccess()); - worldSettings = new WorldSettings(name, EnumGamemode.byId(getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), console.datapackconfiguration); - worlddata = new WorldDataServer(worldSettings, generatorsettings, Lifecycle.stable()); + DedicatedServerProperties.WorldDimensionData properties = new DedicatedServerProperties.WorldDimensionData(ChatDeserializer.parse((creator.generatorSettings().isEmpty()) ? "{}" : creator.generatorSettings()), creator.type().name().toLowerCase(Locale.ROOT)); + + worldsettings = new WorldSettings(name, EnumGamemode.byId(getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), worldloader_a.dataConfiguration()); + worlddimensions = properties.create(worldloader_a.datapackWorldgen()); + + WorldDimensions.b worlddimensions_b = worlddimensions.bake(iregistry); + Lifecycle lifecycle = worlddimensions_b.lifecycle().add(worldloader_a.datapackWorldgen().allRegistriesLifecycle()); + + worlddata = new WorldDataServer(worldsettings, worldoptions, worlddimensions_b.specialWorldProperty(), lifecycle); } worlddata.checkName(name); worlddata.setModdedInfo(console.getServerModName(), console.getModdedStatus().shouldReportAsModified()); @@ -1054,15 +1080,14 @@ public final class CraftServer implements Server { if (console.options.has("forceUpgrade")) { net.minecraft.server.Main.forceUpgrade(worldSession, DataConverterRegistry.getDataFixer(), console.options.has("eraseCache"), () -> { return true; - }, worlddata.worldGenSettings()); + }, iregistry); } long j = BiomeManager.obfuscateSeed(creator.seed()); List list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(worlddata)); - IRegistry iregistry = worlddata.worldGenSettings().dimensions(); WorldDimension worlddimension = (WorldDimension) iregistry.get(actualDimension); - WorldInfo worldInfo = new CraftWorldInfo(worlddata, worldSession, creator.environment(), worlddimension.typeHolder().value()); + WorldInfo worldInfo = new CraftWorldInfo(worlddata, worldSession, creator.environment(), worlddimension.type().value()); if (biomeProvider == null && generator != null) { biomeProvider = generator.getDefaultBiomeProvider(worldInfo); } @@ -1074,17 +1099,17 @@ public final class CraftServer implements Server { } else if (name.equals(levelName + "_the_end")) { worldKey = net.minecraft.world.level.World.END; } else { - worldKey = ResourceKey.create(IRegistry.DIMENSION_REGISTRY, new MinecraftKey(name.toLowerCase(java.util.Locale.ENGLISH))); + worldKey = ResourceKey.create(Registries.DIMENSION, new MinecraftKey(name.toLowerCase(java.util.Locale.ENGLISH))); } WorldServer internal = (WorldServer) new WorldServer(console, console.executor, worldSession, worlddata, worldKey, worlddimension, getServer().progressListenerFactory.create(11), - worlddata.worldGenSettings().isDebug(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, creator.environment(), generator, biomeProvider); + worlddata.isDebugWorld(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, creator.environment(), generator, biomeProvider); if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) { return null; } - console.initWorld(internal, worlddata, worlddata, worlddata.worldGenSettings()); + console.initWorld(internal, worlddata, worlddata, worlddata.worldGenOptions()); internal.setSpawnSettings(true, true); console.addLevel(internal); @@ -1409,7 +1434,7 @@ public final class CraftServer implements Server { @Override public boolean shouldSendChatPreviews() { - return this.getServer().previewsChat(); + return false; } @Override @@ -2046,7 +2071,7 @@ public final class CraftServer implements Server { public ChunkGenerator.ChunkData createChunkData(World world) { Validate.notNull(world, "World cannot be null"); WorldServer handle = ((CraftWorld) world).getHandle(); - return new OldCraftChunkData(world.getMinHeight(), world.getMaxHeight(), handle.registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY)); + return new OldCraftChunkData(world.getMinHeight(), world.getMaxHeight(), handle.registryAccess().registryOrThrow(Registries.BIOME)); } @Override @@ -2176,30 +2201,30 @@ public final class CraftServer implements Server { switch (registry) { case org.bukkit.Tag.REGISTRY_BLOCKS -> { Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Block namespace must have material type"); - TagKey blockTagKey = TagKey.create(IRegistry.BLOCK_REGISTRY, key); - if (IRegistry.BLOCK.isKnownTagName(blockTagKey)) { - return (org.bukkit.Tag) new CraftBlockTag(IRegistry.BLOCK, blockTagKey); + TagKey blockTagKey = TagKey.create(Registries.BLOCK, key); + if (BuiltInRegistries.BLOCK.getTag(blockTagKey).isPresent()) { + return (org.bukkit.Tag) new CraftBlockTag(BuiltInRegistries.BLOCK, blockTagKey); } } case org.bukkit.Tag.REGISTRY_ITEMS -> { Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Item namespace must have material type"); - TagKey itemTagKey = TagKey.create(IRegistry.ITEM_REGISTRY, key); - if (IRegistry.ITEM.isKnownTagName(itemTagKey)) { - return (org.bukkit.Tag) new CraftItemTag(IRegistry.ITEM, itemTagKey); + TagKey itemTagKey = TagKey.create(Registries.ITEM, key); + if (BuiltInRegistries.ITEM.getTag(itemTagKey).isPresent()) { + return (org.bukkit.Tag) new CraftItemTag(BuiltInRegistries.ITEM, itemTagKey); } } case org.bukkit.Tag.REGISTRY_FLUIDS -> { Preconditions.checkArgument(clazz == org.bukkit.Fluid.class, "Fluid namespace must have fluid type"); - TagKey fluidTagKey = TagKey.create(IRegistry.FLUID_REGISTRY, key); - if (IRegistry.FLUID.isKnownTagName(fluidTagKey)) { - return (org.bukkit.Tag) new CraftFluidTag(IRegistry.FLUID, fluidTagKey); + TagKey fluidTagKey = TagKey.create(Registries.FLUID, key); + if (BuiltInRegistries.FLUID.getTag(fluidTagKey).isPresent()) { + return (org.bukkit.Tag) new CraftFluidTag(BuiltInRegistries.FLUID, fluidTagKey); } } case org.bukkit.Tag.REGISTRY_ENTITY_TYPES -> { Preconditions.checkArgument(clazz == org.bukkit.entity.EntityType.class, "Entity type namespace must have entity type"); - TagKey> entityTagKey = TagKey.create(IRegistry.ENTITY_TYPE_REGISTRY, key); - if (IRegistry.ENTITY_TYPE.isKnownTagName(entityTagKey)) { - return (org.bukkit.Tag) new CraftEntityTag(IRegistry.ENTITY_TYPE, entityTagKey); + TagKey> entityTagKey = TagKey.create(Registries.ENTITY_TYPE, key); + if (BuiltInRegistries.ENTITY_TYPE.getTag(entityTagKey).isPresent()) { + return (org.bukkit.Tag) new CraftEntityTag(BuiltInRegistries.ENTITY_TYPE, entityTagKey); } } default -> throw new IllegalArgumentException(); @@ -2216,22 +2241,22 @@ public final class CraftServer implements Server { switch (registry) { case org.bukkit.Tag.REGISTRY_BLOCKS -> { Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Block namespace must have material type"); - IRegistry blockTags = IRegistry.BLOCK; + IRegistry blockTags = BuiltInRegistries.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"); - IRegistry itemTags = IRegistry.ITEM; + IRegistry itemTags = BuiltInRegistries.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"); - IRegistry fluidTags = IRegistry.FLUID; + IRegistry fluidTags = BuiltInRegistries.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"); - IRegistry> entityTags = IRegistry.ENTITY_TYPE; + IRegistry> entityTags = BuiltInRegistries.ENTITY_TYPE; return entityTags.getTags().map(pair -> (org.bukkit.Tag) new CraftEntityTag(entityTags, pair.getFirst())).collect(ImmutableList.toImmutableList()); } default -> throw new IllegalArgumentException(); @@ -2272,7 +2297,7 @@ public final class CraftServer implements Server { @Override public Registry getRegistry(Class aClass) { - return (Registry) registries.computeIfAbsent(aClass, key -> CraftRegistry.createRegistry(aClass, console.registryHolder)); + return (Registry) registries.computeIfAbsent(aClass, key -> CraftRegistry.createRegistry(aClass, console.registryAccess())); } @Deprecated diff --git a/src/main/java/org/bukkit/craftbukkit/CraftSound.java b/src/main/java/org/bukkit/craftbukkit/CraftSound.java index e839d50c7..04b697531 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit; import com.google.common.base.Preconditions; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.MinecraftKey; import net.minecraft.sounds.SoundEffect; import org.bukkit.Registry; @@ -11,20 +11,20 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey; public class CraftSound { public static SoundEffect getSoundEffect(String s) { - SoundEffect effect = IRegistry.SOUND_EVENT.get(new MinecraftKey(s)); + SoundEffect effect = BuiltInRegistries.SOUND_EVENT.get(new MinecraftKey(s)); Preconditions.checkArgument(effect != null, "Sound effect %s does not exist", s); return effect; } public static SoundEffect getSoundEffect(Sound s) { - SoundEffect effect = IRegistry.SOUND_EVENT.get(CraftNamespacedKey.toMinecraft(s.getKey())); + SoundEffect effect = BuiltInRegistries.SOUND_EVENT.get(CraftNamespacedKey.toMinecraft(s.getKey())); Preconditions.checkArgument(effect != null, "Sound effect %s does not exist", s); return effect; } public static Sound getBukkit(SoundEffect soundEffect) { - return Registry.SOUNDS.get(CraftNamespacedKey.fromMinecraft(IRegistry.SOUND_EVENT.getKey(soundEffect))); + return Registry.SOUNDS.get(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.SOUND_EVENT.getKey(soundEffect))); } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java b/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java index 8ff708624..f409a3f27 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java @@ -4,6 +4,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.BiMap; import com.google.common.collect.ImmutableBiMap; import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.MinecraftKey; import net.minecraft.stats.ServerStatisticManager; import net.minecraft.stats.StatisticList; @@ -123,9 +124,9 @@ public enum CraftStatistic { public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.stats.Statistic statistic) { IRegistry statRegistry = statistic.getType().getRegistry(); - MinecraftKey nmsKey = IRegistry.STAT_TYPE.getKey(statistic.getType()); + MinecraftKey nmsKey = BuiltInRegistries.STAT_TYPE.getKey(statistic.getType()); - if (statRegistry == IRegistry.CUSTOM_STAT) { + if (statRegistry == BuiltInRegistries.CUSTOM_STAT) { nmsKey = (MinecraftKey) statistic.getValue(); } @@ -169,7 +170,7 @@ public enum CraftStatistic { public static net.minecraft.stats.Statistic getEntityStatistic(org.bukkit.Statistic stat, EntityType entity) { if (entity.getName() != null) { - EntityTypes nmsEntity = IRegistry.ENTITY_TYPE.get(new MinecraftKey(entity.getName())); + EntityTypes nmsEntity = BuiltInRegistries.ENTITY_TYPE.get(new MinecraftKey(entity.getName())); if (stat == org.bukkit.Statistic.KILL_ENTITY) { return net.minecraft.stats.StatisticList.ENTITY_KILLED.get(nmsEntity); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index f8b308a8a..dd6779e6f 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -9,7 +9,6 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -27,11 +26,12 @@ import java.util.stream.Collectors; import net.minecraft.core.BlockPosition; import net.minecraft.core.Holder; import net.minecraft.core.HolderSet; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; -import net.minecraft.network.protocol.game.PacketPlayOutCustomSoundEffect; import net.minecraft.network.protocol.game.PacketPlayOutEntitySound; +import net.minecraft.network.protocol.game.PacketPlayOutNamedSoundEffect; import net.minecraft.network.protocol.game.PacketPlayOutUpdateTime; import net.minecraft.network.protocol.game.PacketPlayOutWorldEvent; import net.minecraft.resources.MinecraftKey; @@ -43,7 +43,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.sounds.SoundEffect; import net.minecraft.util.ArraySetSorted; import net.minecraft.util.Unit; import net.minecraft.world.EnumDifficulty; @@ -56,7 +56,6 @@ import net.minecraft.world.entity.projectile.EntityArrow; import net.minecraft.world.entity.projectile.EntityTippedArrow; import net.minecraft.world.entity.raid.PersistentRaid; import net.minecraft.world.level.ChunkCoordIntPair; -import net.minecraft.world.level.Explosion; import net.minecraft.world.level.GameRules; import net.minecraft.world.level.RayTrace; import net.minecraft.world.level.biome.BiomeBase; @@ -661,7 +660,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source) { - return !world.explode(source == null ? null : ((CraftEntity) source).getHandle(), x, y, z, power, setFire, breakBlocks ? Explosion.Effect.BREAK : Explosion.Effect.NONE).wasCanceled; + return !world.explode(source == null ? null : ((CraftEntity) source).getHandle(), x, y, z, power, setFire, breakBlocks ? net.minecraft.world.level.World.a.MOB : net.minecraft.world.level.World.a.NONE).wasCanceled; } @Override @@ -1321,7 +1320,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean canGenerateStructures() { - return world.serverLevelData.worldGenSettings().generateStructures(); + return world.serverLevelData.worldGenOptions().generateStructures(); } @Override @@ -1563,7 +1562,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { double y = loc.getY(); double z = loc.getZ(); - PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), SoundCategory.valueOf(category.name()), new Vec3D(x, y, z), volume, pitch, getHandle().getRandom().nextLong()); + PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(Holder.direct(SoundEffect.createVariableRangeEvent(new MinecraftKey(sound))), SoundCategory.valueOf(category.name()), x, y, z, volume, pitch, getHandle().getRandom().nextLong()); world.getServer().getPlayerList().broadcast(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.dimension(), packet); } @@ -1576,7 +1575,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { public void playSound(Entity entity, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) { if (!(entity instanceof CraftEntity craftEntity) || entity.getWorld() != this || sound == null || category == null) return; - PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, getHandle().getRandom().nextLong()); + PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(CraftSound.getSoundEffect(sound)), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, getHandle().getRandom().nextLong()); PlayerChunkMap.EntityTracker entityTracker = getHandle().getChunkSource().chunkMap.entityMap.get(entity.getEntityId()); if (entityTracker != null) { entityTracker.broadcastAndSend(packet); diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java index 1c7c239a6..1043a9455 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -183,11 +183,11 @@ public class Main { useConsole = false; } - if (false && Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { + if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { Date buildDate = new Date(Integer.parseInt(Main.class.getPackage().getImplementationVendor()) * 1000L); Calendar deadline = Calendar.getInstance(); - deadline.add(Calendar.DAY_OF_YEAR, -28); + deadline.add(Calendar.DAY_OF_YEAR, -3); if (buildDate.before(deadline.getTime())) { System.err.println("*** Error, this build is outdated ***"); System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***"); diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java index c8713d887..136b69b90 100644 --- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java +++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.attribute; import com.google.common.base.Preconditions; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.entity.ai.attributes.AttributeBase; import net.minecraft.world.entity.ai.attributes.AttributeMapBase; import org.bukkit.Registry; @@ -27,7 +27,7 @@ public class CraftAttributeMap implements Attributable { } public static AttributeBase toMinecraft(Attribute attribute) { - return IRegistry.ATTRIBUTE.get(CraftNamespacedKey.toMinecraft(attribute.getKey())); + return BuiltInRegistries.ATTRIBUTE.get(CraftNamespacedKey.toMinecraft(attribute.getKey())); } public static Attribute fromMinecraft(String nms) { diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 34d99e545..a7cf4b5fe 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -11,6 +11,8 @@ import net.minecraft.core.BlockPosition; import net.minecraft.core.EnumDirection; import net.minecraft.core.Holder; import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.WorldServer; import net.minecraft.world.EnumHand; @@ -360,7 +362,7 @@ public class CraftBlock implements Block { return null; } - return registry.getHolderOrThrow(ResourceKey.create(IRegistry.BIOME_REGISTRY, CraftNamespacedKey.toMinecraft(bio.getKey()))); + return registry.getHolderOrThrow(ResourceKey.create(Registries.BIOME, CraftNamespacedKey.toMinecraft(bio.getKey()))); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java index c2e86310a..25fc1249d 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java @@ -11,6 +11,8 @@ import javax.annotation.Nullable; import net.minecraft.core.BlockPosition; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.level.GeneratorAccess; +import net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity; +import net.minecraft.world.level.block.entity.HangingSignBlockEntity; import net.minecraft.world.level.block.entity.SculkCatalystBlockEntity; import net.minecraft.world.level.block.entity.SculkSensorBlockEntity; import net.minecraft.world.level.block.entity.SculkShriekerBlockEntity; @@ -124,6 +126,8 @@ public final class CraftBlockStates { Arrays.asList( Material.ACACIA_SIGN, Material.ACACIA_WALL_SIGN, + Material.BAMBOO_SIGN, + Material.BAMBOO_WALL_SIGN, Material.BIRCH_SIGN, Material.BIRCH_WALL_SIGN, Material.CRIMSON_SIGN, @@ -143,12 +147,39 @@ public final class CraftBlockStates { ), CraftSign.class, CraftSign::new, TileEntitySign::new ); + register( + Arrays.asList( + Material.ACACIA_HANGING_SIGN, + Material.ACACIA_WALL_HANGING_SIGN, + Material.BAMBOO_HANGING_SIGN, + Material.BAMBOO_WALL_HANGING_SIGN, + Material.BIRCH_HANGING_SIGN, + Material.BIRCH_WALL_HANGING_SIGN, + Material.CRIMSON_HANGING_SIGN, + Material.CRIMSON_WALL_HANGING_SIGN, + Material.DARK_OAK_HANGING_SIGN, + Material.DARK_OAK_WALL_HANGING_SIGN, + Material.JUNGLE_HANGING_SIGN, + Material.JUNGLE_WALL_HANGING_SIGN, + Material.MANGROVE_HANGING_SIGN, + Material.MANGROVE_WALL_HANGING_SIGN, + Material.OAK_HANGING_SIGN, + Material.OAK_WALL_HANGING_SIGN, + Material.SPRUCE_HANGING_SIGN, + Material.SPRUCE_WALL_HANGING_SIGN, + Material.WARPED_HANGING_SIGN, + Material.WARPED_WALL_HANGING_SIGN + ), CraftHangingSign.class, CraftHangingSign::new, HangingSignBlockEntity::new + ); + register( Arrays.asList( Material.CREEPER_HEAD, Material.CREEPER_WALL_HEAD, Material.DRAGON_HEAD, Material.DRAGON_WALL_HEAD, + Material.PIGLIN_HEAD, + Material.PIGLIN_WALL_HEAD, Material.PLAYER_HEAD, Material.PLAYER_WALL_HEAD, Material.SKELETON_SKULL, @@ -268,6 +299,7 @@ public final class CraftBlockStates { register(Material.BLAST_FURNACE, CraftBlastFurnace.class, CraftBlastFurnace::new, TileEntityBlastFurnace::new); register(Material.BREWING_STAND, CraftBrewingStand.class, CraftBrewingStand::new, TileEntityBrewingStand::new); register(Material.CHEST, CraftChest.class, CraftChest::new, TileEntityChest::new); + register(Material.CHISELED_BOOKSHELF, CraftChiseledBookshelf.class, CraftChiseledBookshelf::new, ChiseledBookShelfBlockEntity::new); register(Material.COMPARATOR, CraftComparator.class, CraftComparator::new, TileEntityComparator::new); register(Material.CONDUIT, CraftConduit.class, CraftConduit::new, TileEntityConduit::new); register(Material.DAYLIGHT_DETECTOR, CraftDaylightDetector.class, CraftDaylightDetector::new, TileEntityLightDetector::new); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftChiseledBookshelf.java b/src/main/java/org/bukkit/craftbukkit/block/CraftChiseledBookshelf.java new file mode 100644 index 000000000..96aec21a9 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftChiseledBookshelf.java @@ -0,0 +1,38 @@ +package org.bukkit.craftbukkit.block; + +import net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity; +import org.bukkit.World; +import org.bukkit.block.ChiseledBookshelf; +import org.bukkit.craftbukkit.inventory.CraftInventoryChiseledBookshelf; +import org.bukkit.inventory.ChiseledBookshelfInventory; + +public class CraftChiseledBookshelf extends CraftBlockEntityState implements ChiseledBookshelf { + + public CraftChiseledBookshelf(World world, ChiseledBookShelfBlockEntity tileEntity) { + super(world, tileEntity); + } + + @Override + public int getLastInteractedSlot() { + return getSnapshot().getLastInteractedSlot(); + } + + @Override + public void setLastInteractedSlot(int lastInteractedSlot) { + getSnapshot().lastInteractedSlot = lastInteractedSlot; + } + + @Override + public ChiseledBookshelfInventory getSnapshotInventory() { + return new CraftInventoryChiseledBookshelf(this.getSnapshot()); + } + + @Override + public ChiseledBookshelfInventory getInventory() { + if (!this.isPlaced()) { + return this.getSnapshotInventory(); + } + + return new CraftInventoryChiseledBookshelf(this.getTileEntity()); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java index a90a2113e..3d5802ea2 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java @@ -26,7 +26,7 @@ public class CraftCreatureSpawner extends CraftBlockEntityState implements HangingSign { + + public CraftHangingSign(World world, HangingSignBlockEntity tileEntity) { + super(world, tileEntity); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java index 428e8bfef..8c05d5664 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java @@ -11,13 +11,13 @@ import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.util.CraftChatMessage; import org.bukkit.entity.Player; -public class CraftSign extends CraftBlockEntityState implements Sign { +public class CraftSign extends CraftBlockEntityState implements Sign { // Lazily initialized only if requested: private String[] originalLines = null; private String[] lines = null; - public CraftSign(World world, TileEntitySign tileEntity) { + public CraftSign(World world, T tileEntity) { super(world, tileEntity); } @@ -75,7 +75,7 @@ public class CraftSign extends CraftBlockEntityState implements } @Override - public void applyTo(TileEntitySign sign) { + public void applyTo(T sign) { super.applyTo(sign); if (lines != null) { @@ -94,7 +94,7 @@ public class CraftSign extends CraftBlockEntityState implements Preconditions.checkArgument(sign.isPlaced(), "Sign must be placed"); Preconditions.checkArgument(sign.getWorld() == player.getWorld(), "Sign must be in same world as Player"); - TileEntitySign handle = ((CraftSign) sign).getTileEntity(); + TileEntitySign handle = ((CraftSign) sign).getTileEntity(); handle.isEditable = true; ((CraftPlayer) player).getHandle().openTextEdit(handle); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java index b60a96f85..5d99db70e 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java @@ -149,6 +149,9 @@ public class CraftSkull extends CraftBlockEntityState implement case ZOMBIE_HEAD: case ZOMBIE_WALL_HEAD: return SkullType.ZOMBIE; + case PIGLIN_HEAD: + case PIGLIN_WALL_HEAD: + return SkullType.PIGLIN; case PLAYER_HEAD: case PLAYER_WALL_HEAD: return SkullType.PLAYER; diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java index 546a3cc02..28e2bbd31 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java +++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java @@ -12,7 +12,7 @@ import java.util.stream.Collectors; import net.minecraft.commands.arguments.blocks.ArgumentBlock; import net.minecraft.core.BlockPosition; import net.minecraft.core.EnumDirection; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.INamable; import net.minecraft.world.level.BlockAccessAir; @@ -227,7 +227,7 @@ public class CraftBlockData implements BlockData { // Mimicked from BlockDataAbstract#toString() public String toString(Map, Comparable> states) { - StringBuilder stateString = new StringBuilder(IRegistry.BLOCK.getKey(state.getBlock()).toString()); + StringBuilder stateString = new StringBuilder(BuiltInRegistries.BLOCK.getKey(state.getBlock()).toString()); if (!states.isEmpty()) { stateString.append('['); @@ -306,7 +306,7 @@ public class CraftBlockData implements BlockData { private static IBlockState getState(Class block, String name, boolean optional) { IBlockState state = null; - for (Block instance : IRegistry.BLOCK) { + for (Block instance : BuiltInRegistries.BLOCK) { if (instance.getClass() == block) { if (state == null) { state = instance.getStateDefinition().getProperty(name); @@ -363,6 +363,7 @@ public class CraftBlockData implements BlockData { register(net.minecraft.world.level.block.BlockBlastFurnace.class, org.bukkit.craftbukkit.block.impl.CraftBlastFurnace::new); register(net.minecraft.world.level.block.BlockBrewingStand.class, org.bukkit.craftbukkit.block.impl.CraftBrewingStand::new); register(net.minecraft.world.level.block.BlockBubbleColumn.class, org.bukkit.craftbukkit.block.impl.CraftBubbleColumn::new); + register(net.minecraft.world.level.block.BlockButtonAbstract.class, org.bukkit.craftbukkit.block.impl.CraftButtonAbstract::new); register(net.minecraft.world.level.block.BlockCactus.class, org.bukkit.craftbukkit.block.impl.CraftCactus::new); register(net.minecraft.world.level.block.BlockCake.class, org.bukkit.craftbukkit.block.impl.CraftCake::new); register(net.minecraft.world.level.block.BlockCampfire.class, org.bukkit.craftbukkit.block.impl.CraftCampfire::new); @@ -453,7 +454,6 @@ public class CraftBlockData implements BlockData { register(net.minecraft.world.level.block.BlockStem.class, org.bukkit.craftbukkit.block.impl.CraftStem::new); register(net.minecraft.world.level.block.BlockStemAttached.class, org.bukkit.craftbukkit.block.impl.CraftStemAttached::new); register(net.minecraft.world.level.block.BlockStepAbstract.class, org.bukkit.craftbukkit.block.impl.CraftStepAbstract::new); - register(net.minecraft.world.level.block.BlockStoneButton.class, org.bukkit.craftbukkit.block.impl.CraftStoneButton::new); register(net.minecraft.world.level.block.BlockStonecutter.class, org.bukkit.craftbukkit.block.impl.CraftStonecutter::new); register(net.minecraft.world.level.block.BlockStructure.class, org.bukkit.craftbukkit.block.impl.CraftStructure::new); register(net.minecraft.world.level.block.BlockSweetBerryBush.class, org.bukkit.craftbukkit.block.impl.CraftSweetBerryBush::new); @@ -472,11 +472,12 @@ public class CraftBlockData implements BlockData { register(net.minecraft.world.level.block.BlockWeepingVines.class, org.bukkit.craftbukkit.block.impl.CraftWeepingVines::new); register(net.minecraft.world.level.block.BlockWitherSkull.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkull::new); register(net.minecraft.world.level.block.BlockWitherSkullWall.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkullWall::new); - register(net.minecraft.world.level.block.BlockWoodButton.class, org.bukkit.craftbukkit.block.impl.CraftWoodButton::new); register(net.minecraft.world.level.block.CandleBlock.class, org.bukkit.craftbukkit.block.impl.CraftCandle::new); register(net.minecraft.world.level.block.CandleCakeBlock.class, org.bukkit.craftbukkit.block.impl.CraftCandleCake::new); register(net.minecraft.world.level.block.CaveVinesBlock.class, org.bukkit.craftbukkit.block.impl.CraftCaveVines::new); register(net.minecraft.world.level.block.CaveVinesPlantBlock.class, org.bukkit.craftbukkit.block.impl.CraftCaveVinesPlant::new); + register(net.minecraft.world.level.block.CeilingHangingSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftCeilingHangingSign::new); + register(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, org.bukkit.craftbukkit.block.impl.CraftChiseledBookShelf::new); register(net.minecraft.world.level.block.GlowLichenBlock.class, org.bukkit.craftbukkit.block.impl.CraftGlowLichen::new); register(net.minecraft.world.level.block.HangingRootsBlock.class, org.bukkit.craftbukkit.block.impl.CraftHangingRoots::new); register(net.minecraft.world.level.block.InfestedRotatedPillarBlock.class, org.bukkit.craftbukkit.block.impl.CraftInfestedRotatedPillar::new); @@ -486,6 +487,7 @@ public class CraftBlockData implements BlockData { register(net.minecraft.world.level.block.MangroveLeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangroveLeaves::new); register(net.minecraft.world.level.block.MangrovePropaguleBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangrovePropagule::new); register(net.minecraft.world.level.block.MangroveRootsBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangroveRoots::new); + register(net.minecraft.world.level.block.PiglinWallSkullBlock.class, org.bukkit.craftbukkit.block.impl.CraftPiglinWallSkull::new); register(net.minecraft.world.level.block.PointedDripstoneBlock.class, org.bukkit.craftbukkit.block.impl.CraftPointedDripstone::new); register(net.minecraft.world.level.block.PowderSnowCauldronBlock.class, org.bukkit.craftbukkit.block.impl.CraftPowderSnowCauldron::new); register(net.minecraft.world.level.block.SculkCatalystBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkCatalyst::new); @@ -494,6 +496,7 @@ public class CraftBlockData implements BlockData { register(net.minecraft.world.level.block.SculkVeinBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkVein::new); register(net.minecraft.world.level.block.SmallDripleafBlock.class, org.bukkit.craftbukkit.block.impl.CraftSmallDripleaf::new); register(net.minecraft.world.level.block.TallSeagrassBlock.class, org.bukkit.craftbukkit.block.impl.CraftTallSeagrass::new); + register(net.minecraft.world.level.block.WallHangingSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftWallHangingSign::new); register(net.minecraft.world.level.block.WeatheringCopperSlabBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperSlab::new); register(net.minecraft.world.level.block.WeatheringCopperStairBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperStair::new); register(net.minecraft.world.level.block.piston.BlockPiston.class, org.bukkit.craftbukkit.block.impl.CraftPiston::new); @@ -518,11 +521,11 @@ public class CraftBlockData implements BlockData { try { // Material provided, force that material in if (block != null) { - data = IRegistry.BLOCK.getKey(block) + data; + data = BuiltInRegistries.BLOCK.getKey(block) + data; } StringReader reader = new StringReader(data); - ArgumentBlock.a arg = ArgumentBlock.parseForBlock(IRegistry.BLOCK, reader, false); + ArgumentBlock.a arg = ArgumentBlock.parseForBlock(BuiltInRegistries.BLOCK.asLookup(), reader, false); Preconditions.checkArgument(!reader.canRead(), "Spurious trailing data: " + data); blockData = arg.blockState(); diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftChiseledBookshelf.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftChiseledBookshelf.java new file mode 100644 index 000000000..a7009f4ed --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftChiseledBookshelf.java @@ -0,0 +1,40 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.ChiseledBookshelf; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftChiseledBookshelf extends CraftBlockData implements ChiseledBookshelf { + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean[] SLOT_OCCUPIED = new net.minecraft.world.level.block.state.properties.BlockStateBoolean[]{ + getBoolean("slot_0_occupied"), getBoolean("slot_1_occupied"), getBoolean("slot_2_occupied"), + getBoolean("slot_3_occupied"), getBoolean("slot_4_occupied"), getBoolean("slot_5_occupied") + }; + + @Override + public boolean isSlotOccupied(int slot) { + return get(SLOT_OCCUPIED[slot]); + } + + @Override + public void setSlotOccupied(int slot, boolean has) { + set(SLOT_OCCUPIED[slot], has); + } + + @Override + public java.util.Set getOccupiedSlots() { + com.google.common.collect.ImmutableSet.Builder slots = com.google.common.collect.ImmutableSet.builder(); + + for (int index = 0; index < getMaximumOccupiedSlots(); index++) { + if (isSlotOccupied(index)) { + slots.add(index); + } + } + + return slots.build(); + } + + @Override + public int getMaximumOccupiedSlots() { + return SLOT_OCCUPIED.length; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStoneButton.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftButtonAbstract.java similarity index 78% rename from src/main/java/org/bukkit/craftbukkit/block/impl/CraftStoneButton.java rename to src/main/java/org/bukkit/craftbukkit/block/impl/CraftButtonAbstract.java index 7333591d8..c0af065d2 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStoneButton.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftButtonAbstract.java @@ -3,19 +3,19 @@ */ package org.bukkit.craftbukkit.block.impl; -public final class CraftStoneButton extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Switch, org.bukkit.block.data.Directional, org.bukkit.block.data.FaceAttachable, org.bukkit.block.data.Powerable { +public final class CraftButtonAbstract extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Switch, org.bukkit.block.data.Directional, org.bukkit.block.data.FaceAttachable, org.bukkit.block.data.Powerable { - public CraftStoneButton() { + public CraftButtonAbstract() { super(); } - public CraftStoneButton(net.minecraft.world.level.block.state.IBlockData state) { + public CraftButtonAbstract(net.minecraft.world.level.block.state.IBlockData state) { super(state); } // org.bukkit.craftbukkit.block.data.type.CraftSwitch - private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACE = getEnum(net.minecraft.world.level.block.BlockStoneButton.class, "face"); + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACE = getEnum(net.minecraft.world.level.block.BlockButtonAbstract.class, "face"); @Override public org.bukkit.block.data.type.Switch.Face getFace() { @@ -29,7 +29,7 @@ public final class CraftStoneButton extends org.bukkit.craftbukkit.block.data.Cr // org.bukkit.craftbukkit.block.data.CraftDirectional - private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACING = getEnum(net.minecraft.world.level.block.BlockStoneButton.class, "facing"); + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACING = getEnum(net.minecraft.world.level.block.BlockButtonAbstract.class, "facing"); @Override public org.bukkit.block.BlockFace getFacing() { @@ -48,7 +48,7 @@ public final class CraftStoneButton extends org.bukkit.craftbukkit.block.data.Cr // org.bukkit.craftbukkit.block.data.CraftFaceAttachable - private static final net.minecraft.world.level.block.state.properties.BlockStateEnum ATTACH_FACE = getEnum(net.minecraft.world.level.block.BlockStoneButton.class, "face"); + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum ATTACH_FACE = getEnum(net.minecraft.world.level.block.BlockButtonAbstract.class, "face"); @Override public org.bukkit.block.data.FaceAttachable.AttachedFace getAttachedFace() { @@ -62,7 +62,7 @@ public final class CraftStoneButton extends org.bukkit.craftbukkit.block.data.Cr // org.bukkit.craftbukkit.block.data.CraftPowerable - private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean POWERED = getBoolean(net.minecraft.world.level.block.BlockStoneButton.class, "powered"); + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean POWERED = getBoolean(net.minecraft.world.level.block.BlockButtonAbstract.class, "powered"); @Override public boolean isPowered() { diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCeilingHangingSign.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCeilingHangingSign.java new file mode 100644 index 000000000..6d00c6327 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCeilingHangingSign.java @@ -0,0 +1,146 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftCeilingHangingSign extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.HangingSign, org.bukkit.block.data.Attachable, org.bukkit.block.data.Rotatable, org.bukkit.block.data.Waterlogged { + + public CraftCeilingHangingSign() { + super(); + } + + public CraftCeilingHangingSign(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftAttachable + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean ATTACHED = getBoolean(net.minecraft.world.level.block.CeilingHangingSignBlock.class, "attached"); + + @Override + public boolean isAttached() { + return get(ATTACHED); + } + + @Override + public void setAttached(boolean attached) { + set(ATTACHED, attached); + } + + // org.bukkit.craftbukkit.block.data.CraftRotatable + + private static final net.minecraft.world.level.block.state.properties.BlockStateInteger ROTATION = getInteger(net.minecraft.world.level.block.CeilingHangingSignBlock.class, "rotation"); + + @Override + public org.bukkit.block.BlockFace getRotation() { + int data = get(ROTATION); + switch (data) { + case 0x0: + return org.bukkit.block.BlockFace.SOUTH; + case 0x1: + return org.bukkit.block.BlockFace.SOUTH_SOUTH_WEST; + case 0x2: + return org.bukkit.block.BlockFace.SOUTH_WEST; + case 0x3: + return org.bukkit.block.BlockFace.WEST_SOUTH_WEST; + case 0x4: + return org.bukkit.block.BlockFace.WEST; + case 0x5: + return org.bukkit.block.BlockFace.WEST_NORTH_WEST; + case 0x6: + return org.bukkit.block.BlockFace.NORTH_WEST; + case 0x7: + return org.bukkit.block.BlockFace.NORTH_NORTH_WEST; + case 0x8: + return org.bukkit.block.BlockFace.NORTH; + case 0x9: + return org.bukkit.block.BlockFace.NORTH_NORTH_EAST; + case 0xA: + return org.bukkit.block.BlockFace.NORTH_EAST; + case 0xB: + return org.bukkit.block.BlockFace.EAST_NORTH_EAST; + case 0xC: + return org.bukkit.block.BlockFace.EAST; + case 0xD: + return org.bukkit.block.BlockFace.EAST_SOUTH_EAST; + case 0xE: + return org.bukkit.block.BlockFace.SOUTH_EAST; + case 0xF: + return org.bukkit.block.BlockFace.SOUTH_SOUTH_EAST; + default: + throw new IllegalArgumentException("Unknown rotation " + data); + } + } + + @Override + public void setRotation(org.bukkit.block.BlockFace rotation) { + int val; + switch (rotation) { + case SOUTH: + val = 0x0; + break; + case SOUTH_SOUTH_WEST: + val = 0x1; + break; + case SOUTH_WEST: + val = 0x2; + break; + case WEST_SOUTH_WEST: + val = 0x3; + break; + case WEST: + val = 0x4; + break; + case WEST_NORTH_WEST: + val = 0x5; + break; + case NORTH_WEST: + val = 0x6; + break; + case NORTH_NORTH_WEST: + val = 0x7; + break; + case NORTH: + val = 0x8; + break; + case NORTH_NORTH_EAST: + val = 0x9; + break; + case NORTH_EAST: + val = 0xA; + break; + case EAST_NORTH_EAST: + val = 0xB; + break; + case EAST: + val = 0xC; + break; + case EAST_SOUTH_EAST: + val = 0xD; + break; + case SOUTH_EAST: + val = 0xE; + break; + case SOUTH_SOUTH_EAST: + val = 0xF; + break; + default: + throw new IllegalArgumentException("Illegal rotation " + rotation); + } + set(ROTATION, val); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.CeilingHangingSignBlock.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChiseledBookShelf.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChiseledBookShelf.java new file mode 100644 index 000000000..ed89dde79 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChiseledBookShelf.java @@ -0,0 +1,69 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftChiseledBookShelf extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.ChiseledBookshelf, org.bukkit.block.data.Directional { + + public CraftChiseledBookShelf() { + super(); + } + + public CraftChiseledBookShelf(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftChiseledBookshelf + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean[] SLOT_OCCUPIED = new net.minecraft.world.level.block.state.properties.BlockStateBoolean[]{ + getBoolean(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, "slot_0_occupied"), getBoolean(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, "slot_1_occupied"), getBoolean(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, "slot_2_occupied"), + getBoolean(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, "slot_3_occupied"), getBoolean(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, "slot_4_occupied"), getBoolean(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, "slot_5_occupied") + }; + + @Override + public boolean isSlotOccupied(int slot) { + return get(SLOT_OCCUPIED[slot]); + } + + @Override + public void setSlotOccupied(int slot, boolean has) { + set(SLOT_OCCUPIED[slot], has); + } + + @Override + public java.util.Set getOccupiedSlots() { + com.google.common.collect.ImmutableSet.Builder slots = com.google.common.collect.ImmutableSet.builder(); + + for (int index = 0; index < getMaximumOccupiedSlots(); index++) { + if (isSlotOccupied(index)) { + slots.add(index); + } + } + + return slots.build(); + } + + @Override + public int getMaximumOccupiedSlots() { + return SLOT_OCCUPIED.length; + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACING = getEnum(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPiglinWallSkull.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPiglinWallSkull.java new file mode 100644 index 000000000..8e797a09e --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPiglinWallSkull.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftPiglinWallSkull extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { + + public CraftPiglinWallSkull() { + super(); + } + + public CraftPiglinWallSkull(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACING = getEnum(net.minecraft.world.level.block.PiglinWallSkullBlock.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWallHangingSign.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWallHangingSign.java new file mode 100644 index 000000000..68b65d34a --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWallHangingSign.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftWallHangingSign extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.WallHangingSign, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged { + + public CraftWallHangingSign() { + super(); + } + + public CraftWallHangingSign(net.minecraft.world.level.block.state.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACING = getEnum(net.minecraft.world.level.block.WallHangingSignBlock.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.WallHangingSignBlock.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWoodButton.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWoodButton.java deleted file mode 100644 index 15c8eb8ca..000000000 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWoodButton.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Automatically generated file, changes will be lost. - */ -package org.bukkit.craftbukkit.block.impl; - -public final class CraftWoodButton extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Switch, org.bukkit.block.data.Directional, org.bukkit.block.data.FaceAttachable, org.bukkit.block.data.Powerable { - - public CraftWoodButton() { - super(); - } - - public CraftWoodButton(net.minecraft.world.level.block.state.IBlockData state) { - super(state); - } - - // org.bukkit.craftbukkit.block.data.type.CraftSwitch - - private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACE = getEnum(net.minecraft.world.level.block.BlockWoodButton.class, "face"); - - @Override - public org.bukkit.block.data.type.Switch.Face getFace() { - return get(FACE, org.bukkit.block.data.type.Switch.Face.class); - } - - @Override - public void setFace(org.bukkit.block.data.type.Switch.Face face) { - set(FACE, face); - } - - // org.bukkit.craftbukkit.block.data.CraftDirectional - - private static final net.minecraft.world.level.block.state.properties.BlockStateEnum FACING = getEnum(net.minecraft.world.level.block.BlockWoodButton.class, "facing"); - - @Override - public org.bukkit.block.BlockFace getFacing() { - return get(FACING, org.bukkit.block.BlockFace.class); - } - - @Override - public void setFacing(org.bukkit.block.BlockFace facing) { - set(FACING, facing); - } - - @Override - public java.util.Set getFaces() { - return getValues(FACING, org.bukkit.block.BlockFace.class); - } - - // org.bukkit.craftbukkit.block.data.CraftFaceAttachable - - private static final net.minecraft.world.level.block.state.properties.BlockStateEnum ATTACH_FACE = getEnum(net.minecraft.world.level.block.BlockWoodButton.class, "face"); - - @Override - public org.bukkit.block.data.FaceAttachable.AttachedFace getAttachedFace() { - return get(ATTACH_FACE, org.bukkit.block.data.FaceAttachable.AttachedFace.class); - } - - @Override - public void setAttachedFace(org.bukkit.block.data.FaceAttachable.AttachedFace face) { - set(ATTACH_FACE, face); - } - - // org.bukkit.craftbukkit.block.data.CraftPowerable - - private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean POWERED = getBoolean(net.minecraft.world.level.block.BlockWoodButton.class, "powered"); - - @Override - public boolean isPowered() { - return get(POWERED); - } - - @Override - public void setPowered(boolean powered) { - set(POWERED, powered); - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java index a0ed7e645..662520b20 100644 --- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.enchantments; import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.item.enchantment.EnchantmentBinding; import net.minecraft.world.item.enchantment.EnchantmentVanishing; import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -14,7 +15,7 @@ public class CraftEnchantment extends Enchantment { private final net.minecraft.world.item.enchantment.Enchantment target; public CraftEnchantment(net.minecraft.world.item.enchantment.Enchantment target) { - super(CraftNamespacedKey.fromMinecraft(IRegistry.ENCHANTMENT.getKey(target))); + super(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.ENCHANTMENT.getKey(target))); this.target = target; } @@ -82,7 +83,7 @@ public class CraftEnchantment extends Enchantment { @Override public String getName() { // PAIL: migration paths - switch (IRegistry.ENCHANTMENT.getId(target)) { + switch (BuiltInRegistries.ENCHANTMENT.getId(target)) { case 0: return "PROTECTION_ENVIRONMENTAL"; case 1: @@ -162,7 +163,7 @@ public class CraftEnchantment extends Enchantment { case 38: return "VANISHING_CURSE"; default: - return "UNKNOWN_ENCHANT_" + IRegistry.ENCHANTMENT.getId(target); + return "UNKNOWN_ENCHANT_" + BuiltInRegistries.ENCHANTMENT.getId(target); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java index 85847d344..4e69b6427 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java @@ -45,6 +45,6 @@ public class CraftAxolotl extends CraftAnimals implements Axolotl { public void setVariant(Variant variant) { Preconditions.checkArgument(variant != null, "variant"); - getHandle().setVariant(net.minecraft.world.entity.animal.axolotl.Axolotl.Variant.BY_ID[variant.ordinal()]); + getHandle().setVariant(net.minecraft.world.entity.animal.axolotl.Axolotl.Variant.byId(variant.ordinal())); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java index abc84289f..dad97bfa8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java @@ -17,24 +17,24 @@ public class CraftBoat extends CraftVehicle implements Boat { @Override public TreeSpecies getWoodType() { - return getTreeSpecies(getHandle().getBoatType()); + return getTreeSpecies(getHandle().getVariant()); } @Override public void setWoodType(TreeSpecies species) { - getHandle().setType(getBoatType(species)); + getHandle().setVariant(getBoatType(species)); } @Override public Type getBoatType() { - return boatTypeFromNms(getHandle().getBoatType()); + return boatTypeFromNms(getHandle().getVariant()); } @Override public void setBoatType(Type type) { Preconditions.checkArgument(type != null, "Boat.Type cannot be null"); - getHandle().setType(boatTypeToNms(type)); + getHandle().setVariant(boatTypeToNms(type)); } @Override @@ -111,12 +111,14 @@ public class CraftBoat extends CraftVehicle implements Boat { case SPRUCE -> Type.SPRUCE; case DARK_OAK -> Type.DARK_OAK; case MANGROVE -> Type.MANGROVE; + case BAMBOO -> Type.BAMBOO; }; } public static EntityBoat.EnumBoatType boatTypeToNms(Boat.Type type) { return switch (type) { default -> throw new EnumConstantNotPresentException(EntityBoat.EnumBoatType.class, type.name()); + case BAMBOO -> EntityBoat.EnumBoatType.BAMBOO; case MANGROVE -> EntityBoat.EnumBoatType.MANGROVE; case SPRUCE -> EntityBoat.EnumBoatType.SPRUCE; case DARK_OAK -> EntityBoat.EnumBoatType.DARK_OAK; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java new file mode 100644 index 000000000..aa92b94a0 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java @@ -0,0 +1,43 @@ +package org.bukkit.craftbukkit.entity; + +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Camel; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Horse; + +public class CraftCamel extends CraftAbstractHorse implements Camel { + + public CraftCamel(CraftServer server, net.minecraft.world.entity.animal.camel.Camel entity) { + super(server, entity); + } + + @Override + public net.minecraft.world.entity.animal.camel.Camel getHandle() { + return (net.minecraft.world.entity.animal.camel.Camel) super.getHandle(); + } + + @Override + public String toString() { + return "CraftCamel"; + } + + @Override + public EntityType getType() { + return EntityType.CAMEL; + } + + @Override + public Horse.Variant getVariant() { + return Horse.Variant.CAMEL; + } + + @Override + public boolean isDashing() { + return getHandle().isDashing(); + } + + @Override + public void setDashing(boolean dashing) { + getHandle().setDashing(dashing); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java index 3bdbffc3b..3498bac14 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java @@ -1,8 +1,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; -import net.minecraft.core.IRegistry; -import net.minecraft.world.entity.animal.CatVariant; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.entity.animal.EntityCat; import net.minecraft.world.item.EnumColor; import org.bukkit.DyeColor; @@ -34,14 +33,14 @@ public class CraftCat extends CraftTameableAnimal implements Cat { @Override public Type getCatType() { - return Type.values()[IRegistry.CAT_VARIANT.getId(getHandle().getCatVariant())]; + return Type.values()[BuiltInRegistries.CAT_VARIANT.getId(getHandle().getVariant())]; } @Override public void setCatType(Type type) { Preconditions.checkArgument(type != null, "Cannot have null Type"); - getHandle().setCatVariant(IRegistry.CAT_VARIANT.byId(type.ordinal())); + getHandle().setVariant(BuiltInRegistries.CAT_VARIANT.byId(type.ordinal())); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 6d51dd2da..c68bda925 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -58,6 +58,7 @@ import net.minecraft.world.entity.animal.EntityWaterAnimal; import net.minecraft.world.entity.animal.EntityWolf; import net.minecraft.world.entity.animal.allay.Allay; import net.minecraft.world.entity.animal.axolotl.Axolotl; +import net.minecraft.world.entity.animal.camel.Camel; import net.minecraft.world.entity.animal.frog.Frog; import net.minecraft.world.entity.animal.frog.Tadpole; import net.minecraft.world.entity.animal.goat.Goat; @@ -257,6 +258,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } else if (entity instanceof EntityHorse) { return new CraftHorse(server, (EntityHorse) entity); } else if (entity instanceof EntityHorseSkeleton) { return new CraftSkeletonHorse(server, (EntityHorseSkeleton) entity); } else if (entity instanceof EntityHorseZombie) { return new CraftZombieHorse(server, (EntityHorseZombie) entity); } + else if (entity instanceof Camel) { return new CraftCamel(server, (Camel) entity); } } else if (entity instanceof EntityRabbit) { return new CraftRabbit(server, (EntityRabbit) entity); } else if (entity instanceof EntityPolarBear) { return new CraftPolarBear(server, (EntityPolarBear) entity); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java index 4014416fa..d3319f143 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java @@ -33,14 +33,14 @@ public class CraftFox extends CraftAnimals implements Fox { @Override public Type getFoxType() { - return Type.values()[getHandle().getFoxType().ordinal()]; + return Type.values()[getHandle().getVariant().ordinal()]; } @Override public void setFoxType(Type type) { Preconditions.checkArgument(type != null, "type"); - getHandle().setFoxType(EntityFox.Type.values()[type.ordinal()]); + getHandle().setVariant(EntityFox.Type.values()[type.ordinal()]); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java index 7c1f3ea15..2371aca0b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.entity.animal.frog.Frog; import org.bukkit.Registry; import org.bukkit.craftbukkit.CraftServer; @@ -46,13 +46,13 @@ public class CraftFrog extends CraftAnimals implements org.bukkit.entity.Frog { @Override public Variant getVariant() { - return Registry.FROG_VARIANT.get(CraftNamespacedKey.fromMinecraft(IRegistry.FROG_VARIANT.getKey(getHandle().getVariant()))); + return Registry.FROG_VARIANT.get(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.FROG_VARIANT.getKey(getHandle().getVariant()))); } @Override public void setVariant(Variant variant) { Preconditions.checkArgument(variant != null, "variant"); - getHandle().setVariant(IRegistry.FROG_VARIANT.get(CraftNamespacedKey.toMinecraft(variant.getKey()))); + getHandle().setVariant(BuiltInRegistries.FROG_VARIANT.get(CraftNamespacedKey.toMinecraft(variant.getKey()))); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java index f5f4ce420..b9e0df66f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java @@ -2,7 +2,6 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; import net.minecraft.core.EnumDirection; -import net.minecraft.network.syncher.DataWatcher; import net.minecraft.world.entity.decoration.EntityHanging; import net.minecraft.world.entity.decoration.EntityItemFrame; import net.minecraft.world.level.block.Blocks; @@ -44,9 +43,8 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame { super.update(); // mark dirty, so that the client gets updated with item and rotation - for (DataWatcher.Item dataItem : getHandle().getEntityData().getAll()) { - getHandle().getEntityData().markDirty(dataItem.getAccessor()); - } + getHandle().getEntityData().markDirty(EntityItemFrame.DATA_ITEM); + getHandle().getEntityData().markDirty(EntityItemFrame.DATA_ROTATION); // update redstone if (!getHandle().generation) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java index f5447991f..4b5fe3808 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java @@ -23,14 +23,14 @@ public class CraftLlama extends CraftChestedHorse implements Llama { @Override public Color getColor() { - return Color.values()[getHandle().getVariant()]; + return Color.values()[getHandle().getVariant().ordinal()]; } @Override public void setColor(Color color) { Preconditions.checkArgument(color != null, "color"); - getHandle().setVariant(color.ordinal()); + getHandle().setVariant(EntityLlama.Variant.byId(color.ordinal())); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java index a44f815fa..24e2197ac 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java @@ -19,14 +19,14 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow { @Override public Variant getVariant() { - return Variant.values()[getHandle().getMushroomType().ordinal()]; + return Variant.values()[getHandle().getVariant().ordinal()]; } @Override public void setVariant(Variant variant) { Preconditions.checkArgument(variant != null, "variant"); - getHandle().setMushroomType(EntityMushroomCow.Type.values()[variant.ordinal()]); + getHandle().setVariant(EntityMushroomCow.Type.values()[variant.ordinal()]); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java index 4b7f8e3b8..e9726b051 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java @@ -20,14 +20,14 @@ public class CraftParrot extends CraftTameableAnimal implements Parrot { @Override public Variant getVariant() { - return Variant.values()[getHandle().getVariant()]; + return Variant.values()[getHandle().getVariant().ordinal()]; } @Override public void setVariant(Variant variant) { Preconditions.checkArgument(variant != null, "variant"); - getHandle().setVariant(variant.ordinal()); + getHandle().setVariant(EntityParrot.Variant.byId(variant.ordinal())); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index d7e408cd2..bfda73ada 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -30,13 +30,16 @@ import java.util.logging.Logger; import javax.annotation.Nullable; import net.minecraft.advancements.AdvancementProgress; import net.minecraft.core.BlockPosition; +import net.minecraft.core.Holder; import net.minecraft.core.SectionPosition; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.PacketDataSerializer; -import net.minecraft.network.chat.ChatMessageContent; import net.minecraft.network.chat.IChatBaseComponent; import net.minecraft.network.chat.PlayerChatMessage; import net.minecraft.network.protocol.game.ClientboundClearTitlesPacket; +import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket; +import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket; import net.minecraft.network.protocol.game.ClientboundSetBorderCenterPacket; import net.minecraft.network.protocol.game.ClientboundSetBorderLerpSizePacket; import net.minecraft.network.protocol.game.ClientboundSetBorderSizePacket; @@ -48,7 +51,6 @@ import net.minecraft.network.protocol.game.ClientboundSetTitlesAnimationPacket; import net.minecraft.network.protocol.game.PacketPlayOutBlockBreakAnimation; import net.minecraft.network.protocol.game.PacketPlayOutBlockChange; import net.minecraft.network.protocol.game.PacketPlayOutCustomPayload; -import net.minecraft.network.protocol.game.PacketPlayOutCustomSoundEffect; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; import net.minecraft.network.protocol.game.PacketPlayOutEntitySound; import net.minecraft.network.protocol.game.PacketPlayOutExperience; @@ -56,7 +58,6 @@ import net.minecraft.network.protocol.game.PacketPlayOutGameStateChange; import net.minecraft.network.protocol.game.PacketPlayOutMap; import net.minecraft.network.protocol.game.PacketPlayOutMultiBlockChange; import net.minecraft.network.protocol.game.PacketPlayOutNamedSoundEffect; -import net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo; import net.minecraft.network.protocol.game.PacketPlayOutPlayerListHeaderFooter; import net.minecraft.network.protocol.game.PacketPlayOutSpawnPosition; import net.minecraft.network.protocol.game.PacketPlayOutStopSound; @@ -71,6 +72,7 @@ import net.minecraft.server.level.PlayerChunkMap; import net.minecraft.server.level.WorldServer; import net.minecraft.server.network.PlayerConnection; import net.minecraft.server.players.WhiteListEntry; +import net.minecraft.sounds.SoundEffect; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityLiving; import net.minecraft.world.entity.EnumItemSlot; @@ -299,7 +301,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { getHandle().listName = name.equals(getName()) ? null : CraftChatMessage.fromStringOrNull(name); for (EntityPlayer player : (List) server.getHandle().players) { if (player.getBukkitEntity().canSee(this)) { - player.connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, getHandle())); + player.connection.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.a.UPDATE_DISPLAY_NAME, getHandle())); } } } @@ -387,7 +389,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void chat(String msg) { if (getHandle().connection == null) return; - getHandle().connection.chat(msg, PlayerChatMessage.system(new ChatMessageContent(msg)), false); + getHandle().connection.chat(msg, PlayerChatMessage.system(msg), false); } @Override @@ -434,7 +436,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } float f = (float) Math.pow(2.0D, (note - 12.0D) / 12.0D); - getHandle().connection.send(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f, getHandle().getRandom().nextLong())); + getHandle().connection.send(new PacketPlayOutNamedSoundEffect(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(CraftSound.getSoundEffect("block.note_block." + instrumentName)), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f, getHandle().getRandom().nextLong())); } @Override @@ -496,7 +498,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { break; } float f = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D); - getHandle().connection.send(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f, getHandle().getRandom().nextLong())); + getHandle().connection.send(new PacketPlayOutNamedSoundEffect(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(CraftSound.getSoundEffect("block.note_block." + instrumentName)), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f, getHandle().getRandom().nextLong())); } @Override @@ -513,7 +515,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void playSound(Location loc, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) { if (loc == null || sound == null || category == null || getHandle().connection == null) return; - PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), loc.getX(), loc.getY(), loc.getZ(), volume, pitch, getHandle().getRandom().nextLong()); + PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(CraftSound.getSoundEffect(sound)), net.minecraft.sounds.SoundCategory.valueOf(category.name()), loc.getX(), loc.getY(), loc.getZ(), volume, pitch, getHandle().getRandom().nextLong()); getHandle().connection.send(packet); } @@ -521,7 +523,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch) { if (loc == null || sound == null || category == null || getHandle().connection == null) return; - PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), new Vec3D(loc.getX(), loc.getY(), loc.getZ()), volume, pitch, getHandle().getRandom().nextLong()); + PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(Holder.direct(SoundEffect.createVariableRangeEvent(new MinecraftKey(sound))), net.minecraft.sounds.SoundCategory.valueOf(category.name()), loc.getX(), loc.getY(), loc.getZ(), volume, pitch, getHandle().getRandom().nextLong()); getHandle().connection.send(packet); } @@ -534,7 +536,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void playSound(org.bukkit.entity.Entity entity, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) { if (!(entity instanceof CraftEntity craftEntity) || sound == null || category == null || getHandle().connection == null) return; - PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, getHandle().getRandom().nextLong()); + PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(CraftSound.getSoundEffect(sound)), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, getHandle().getRandom().nextLong()); getHandle().connection.send(packet); } @@ -1267,7 +1269,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (other instanceof EntityPlayer) { EntityPlayer otherPlayer = (EntityPlayer) other; if (otherPlayer.sentListPacket) { - getHandle().connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, otherPlayer)); + getHandle().connection.send(new ClientboundPlayerInfoRemovePacket(List.of(otherPlayer.getUUID()))); } } @@ -1313,7 +1315,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (other instanceof EntityPlayer) { EntityPlayer otherPlayer = (EntityPlayer) other; - getHandle().connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, otherPlayer)); + getHandle().connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(otherPlayer))); } PlayerChunkMap.EntityTracker entry = tracker.entityMap.get(other.getId()); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java index 959cc28b0..67a717c58 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java @@ -32,8 +32,7 @@ public class CraftRabbit extends CraftAnimals implements Rabbit { @Override public Type getRabbitType() { - int type = getHandle().getRabbitType(); - return CraftMagicMapping.fromMagic(type); + return Type.values()[getHandle().getVariant().ordinal()]; } @Override @@ -48,43 +47,6 @@ public class CraftRabbit extends CraftAnimals implements Rabbit { entity.initializePathFinderGoals(); } - entity.setRabbitType(CraftMagicMapping.toMagic(type)); - } - - private static class CraftMagicMapping { - - private static final int[] types = new int[Type.values().length]; - private static final Type[] reverse = new Type[Type.values().length]; - - static { - set(Type.BROWN, 0); - set(Type.WHITE, 1); - set(Type.BLACK, 2); - set(Type.BLACK_AND_WHITE, 3); - set(Type.GOLD, 4); - set(Type.SALT_AND_PEPPER, 5); - set(Type.THE_KILLER_BUNNY, 99); - } - - private static void set(Type type, int value) { - types[type.ordinal()] = value; - if (value < reverse.length) { - reverse[value] = type; - } - } - - public static Type fromMagic(int magic) { - if (magic >= 0 && magic < reverse.length) { - return reverse[magic]; - } else if (magic == 99) { - return Type.THE_KILLER_BUNNY; - } else { - return null; - } - } - - public static int toMagic(Type type) { - return types[type.ordinal()]; - } + entity.setVariant(EntityRabbit.Variant.values()[type.ordinal()]); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java index 87f87cda6..f4e1a4f29 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java @@ -32,32 +32,32 @@ public class CraftTropicalFish extends CraftFish implements TropicalFish { @Override public DyeColor getPatternColor() { - return getPatternColor(getHandle().getVariant()); + return getPatternColor(getHandle().getPackedVariant()); } @Override public void setPatternColor(DyeColor color) { - getHandle().setVariant(getData(color, getBodyColor(), getPattern())); + getHandle().setPackedVariant(getData(color, getBodyColor(), getPattern())); } @Override public DyeColor getBodyColor() { - return getBodyColor(getHandle().getVariant()); + return getBodyColor(getHandle().getPackedVariant()); } @Override public void setBodyColor(DyeColor color) { - getHandle().setVariant(getData(getPatternColor(), color, getPattern())); + getHandle().setPackedVariant(getData(getPatternColor(), color, getPattern())); } @Override public Pattern getPattern() { - return getPattern(getHandle().getVariant()); + return getPattern(getHandle().getPackedVariant()); } @Override public void setPattern(Pattern pattern) { - getHandle().setVariant(getData(getPatternColor(), getBodyColor(), pattern)); + getHandle().setPackedVariant(getData(getPatternColor(), getBodyColor(), pattern)); } public static enum CraftPattern { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java index 72aa1ecd9..2cbd611a1 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -3,7 +3,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; import java.util.Locale; import net.minecraft.core.BlockPosition; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.entity.monster.EntityZombie; import net.minecraft.world.entity.monster.EntityZombieVillager; import net.minecraft.world.entity.npc.EntityVillager; @@ -60,13 +60,13 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { @Override public Type getVillagerType() { - return Type.valueOf(IRegistry.VILLAGER_TYPE.getKey(getHandle().getVillagerData().getType()).getPath().toUpperCase(Locale.ROOT)); + return Type.valueOf(BuiltInRegistries.VILLAGER_TYPE.getKey(getHandle().getVillagerData().getType()).getPath().toUpperCase(Locale.ROOT)); } @Override public void setVillagerType(Type type) { Validate.notNull(type); - getHandle().setVillagerData(getHandle().getVillagerData().setType(IRegistry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey())))); + getHandle().setVillagerData(getHandle().getVillagerData().setType(BuiltInRegistries.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey())))); } @Override @@ -130,10 +130,10 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { } public static Profession nmsToBukkitProfession(VillagerProfession nms) { - return Profession.valueOf(IRegistry.VILLAGER_PROFESSION.getKey(nms).getPath().toUpperCase(Locale.ROOT)); + return Profession.valueOf(BuiltInRegistries.VILLAGER_PROFESSION.getKey(nms).getPath().toUpperCase(Locale.ROOT)); } public static VillagerProfession bukkitToNmsProfession(Profession bukkit) { - return IRegistry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(bukkit.getKey())); + return BuiltInRegistries.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(bukkit.getKey())); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java index cbe5eba57..9b46e7511 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java @@ -3,7 +3,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; import java.util.Locale; import java.util.UUID; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.MinecraftKey; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.monster.EntityZombieVillager; @@ -39,24 +39,24 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager { @Override public Villager.Profession getVillagerProfession() { - return Villager.Profession.valueOf(IRegistry.VILLAGER_PROFESSION.getKey(getHandle().getVillagerData().getProfession()).getPath().toUpperCase(Locale.ROOT)); + return Villager.Profession.valueOf(BuiltInRegistries.VILLAGER_PROFESSION.getKey(getHandle().getVillagerData().getProfession()).getPath().toUpperCase(Locale.ROOT)); } @Override public void setVillagerProfession(Villager.Profession profession) { Validate.notNull(profession); - getHandle().setVillagerData(getHandle().getVillagerData().setProfession(IRegistry.VILLAGER_PROFESSION.get(new MinecraftKey(profession.name().toLowerCase(Locale.ROOT))))); + getHandle().setVillagerData(getHandle().getVillagerData().setProfession(BuiltInRegistries.VILLAGER_PROFESSION.get(new MinecraftKey(profession.name().toLowerCase(Locale.ROOT))))); } @Override public Villager.Type getVillagerType() { - return Villager.Type.valueOf(IRegistry.VILLAGER_TYPE.getKey(getHandle().getVillagerData().getType()).getPath().toUpperCase(Locale.ROOT)); + return Villager.Type.valueOf(BuiltInRegistries.VILLAGER_TYPE.getKey(getHandle().getVillagerData().getType()).getPath().toUpperCase(Locale.ROOT)); } @Override public void setVillagerType(Villager.Type type) { Validate.notNull(type); - getHandle().setVillagerData(getHandle().getVillagerData().setType(IRegistry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey())))); + getHandle().setVillagerData(getHandle().getVillagerData().setType(BuiltInRegistries.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey())))); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryKey.java b/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryKey.java index 246b5ea80..0307516d1 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryKey.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryKey.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.memory; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.entity.ai.memory.MemoryModuleType; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.entity.memory.MemoryKey; @@ -10,10 +10,10 @@ public final class CraftMemoryKey { private CraftMemoryKey() {} public static MemoryModuleType fromMemoryKey(MemoryKey memoryKey) { - return (MemoryModuleType) IRegistry.MEMORY_MODULE_TYPE.get(CraftNamespacedKey.toMinecraft(memoryKey.getKey())); + return (MemoryModuleType) BuiltInRegistries.MEMORY_MODULE_TYPE.get(CraftNamespacedKey.toMinecraft(memoryKey.getKey())); } public static MemoryKey toMemoryKey(MemoryModuleType memoryModuleType) { - return MemoryKey.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.MEMORY_MODULE_TYPE.getKey(memoryModuleType))); + return MemoryKey.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.MEMORY_MODULE_TYPE.getKey(memoryModuleType))); } } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index ca98ddf7d..87b2a368f 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -840,8 +840,8 @@ public class CraftEventFactory { /** * Server methods */ - public static ServerListPingEvent callServerListPingEvent(Server craftServer, InetAddress address, String motd, boolean shouldSendChatPreviews, int numPlayers, int maxPlayers) { - ServerListPingEvent event = new ServerListPingEvent(address, motd, shouldSendChatPreviews, numPlayers, maxPlayers); + public static ServerListPingEvent callServerListPingEvent(Server craftServer, InetAddress address, String motd, int numPlayers, int maxPlayers) { + ServerListPingEvent event = new ServerListPingEvent("", address, motd, numPlayers, maxPlayers); craftServer.getPluginManager().callEvent(event); return event; } @@ -924,7 +924,7 @@ public class CraftEventFactory { } else if (blockDamage != null) { DamageCause cause = null; Block damager = blockDamage; - if (source == DamageSource.CACTUS || source == DamageSource.SWEET_BERRY_BUSH || source == DamageSource.STALAGMITE || source == DamageSource.FALLING_STALACTITE || source == DamageSource.ANVIL) { + if (source == DamageSource.CACTUS || source == DamageSource.SWEET_BERRY_BUSH || source == DamageSource.STALAGMITE || "fallingStalactite".equals(source.msgId) || "anvil".equals(source.msgId)) { cause = DamageCause.CONTACT; } else if (source == DamageSource.HOT_FLOOR) { cause = DamageCause.HOT_FLOOR; @@ -952,7 +952,7 @@ public class CraftEventFactory { DamageCause cause = null; CraftEntity damager = entityDamage.getBukkitEntity(); entityDamage = null; - if (source == DamageSource.ANVIL || source == DamageSource.FALLING_BLOCK || source == DamageSource.FALLING_STALACTITE) { + if ("fallingStalactite".equals(source.msgId) || "fallingBlock".equals(source.msgId) || "anvil".equals(source.msgId)) { cause = DamageCause.FALLING_BLOCK; } else if (damager instanceof LightningStrike) { cause = DamageCause.LIGHTNING; @@ -1046,7 +1046,7 @@ public class CraftEventFactory { Map> modifierFunctions = new EnumMap>(DamageModifier.class); modifiers.put(DamageModifier.BASE, rawDamage); modifierFunctions.put(DamageModifier.BASE, ZERO); - if (source == DamageSource.FALLING_BLOCK || source == DamageSource.ANVIL) { + if ("fallingBlock".equals(source.msgId) || "anvil".equals(source.msgId)) { modifiers.put(DamageModifier.HARD_HAT, hardHatModifier); modifierFunctions.put(DamageModifier.HARD_HAT, hardHat); } diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CraftWorldInfo.java b/src/main/java/org/bukkit/craftbukkit/generator/CraftWorldInfo.java index 7bed837ac..8b7ce81a1 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CraftWorldInfo.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftWorldInfo.java @@ -22,7 +22,7 @@ public class CraftWorldInfo implements WorldInfo { this.name = worldDataServer.getLevelName(); this.uuid = WorldUUID.getUUID(session.levelDirectory.path().toFile()); this.environment = environment; - this.seed = ((WorldDataServer) worldDataServer).worldGenSettings().seed(); + this.seed = ((WorldDataServer) worldDataServer).worldGenOptions().seed(); this.minHeight = dimensionManager.minY(); this.maxHeight = dimensionManager.minY() + dimensionManager.height(); } diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java index 57a27ad58..7c3b1d949 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java @@ -25,6 +25,7 @@ import net.minecraft.world.level.biome.WorldChunkManager; import net.minecraft.world.level.block.ITileEntity; import net.minecraft.world.level.block.entity.TileEntity; import net.minecraft.world.level.block.state.IBlockData; +import net.minecraft.world.level.chunk.ChunkGeneratorStructureState; import net.minecraft.world.level.chunk.ChunkSection; import net.minecraft.world.level.chunk.IChunkAccess; import net.minecraft.world.level.chunk.ProtoChunk; @@ -86,7 +87,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } public CustomChunkGenerator(WorldServer world, net.minecraft.world.level.chunk.ChunkGenerator delegate, ChunkGenerator generator) { - super(delegate.structureSets, delegate.structureOverrides, delegate.getBiomeSource()); + super(delegate.getBiomeSource(), delegate.generationSettingsGetter); this.world = world; this.delegate = delegate; @@ -117,14 +118,14 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } @Override - public void createStructures(IRegistryCustom iregistrycustom, RandomState randomstate, StructureManager structuremanager, IChunkAccess ichunkaccess, StructureTemplateManager structuretemplatemanager, long i) { + public void createStructures(IRegistryCustom iregistrycustom, ChunkGeneratorStructureState chunkgeneratorstructurestate, StructureManager structuremanager, IChunkAccess ichunkaccess, StructureTemplateManager structuretemplatemanager) { SeededRandom random = getSeededRandom(); int x = ichunkaccess.getPos().x; int z = ichunkaccess.getPos().z; - random.setSeed(MathHelper.getSeed(x, "should-structures".hashCode(), z) ^ i); + random.setSeed(MathHelper.getSeed(x, "should-structures".hashCode(), z) ^ world.getSeed()); if (generator.shouldGenerateStructures(this.world.getWorld(), new RandomSourceWrapper.RandomWrapper(random), x, z)) { - super.createStructures(iregistrycustom, randomstate, structuremanager, ichunkaccess, structuretemplatemanager, i); + super.createStructures(iregistrycustom, chunkgeneratorstructurestate, structuremanager, ichunkaccess, structuretemplatemanager); } } diff --git a/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java index ec3579f2e..05160224b 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java @@ -1,15 +1,15 @@ package org.bukkit.craftbukkit.generator; -import java.util.Optional; -import net.minecraft.core.HolderSet; -import net.minecraft.core.IRegistry; +import java.util.function.Function; +import net.minecraft.core.Holder; +import net.minecraft.world.level.biome.BiomeBase; +import net.minecraft.world.level.biome.BiomeSettingsGeneration; import net.minecraft.world.level.biome.WorldChunkManager; -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(IRegistry iregistry, Optional> optional, WorldChunkManager worldchunkmanager) { - super(iregistry, optional, worldchunkmanager); + public InternalChunkGenerator(WorldChunkManager worldchunkmanager, Function, BiomeSettingsGeneration> function) { + super(worldchunkmanager, function); } } diff --git a/src/main/java/org/bukkit/craftbukkit/generator/strucutre/CraftStructure.java b/src/main/java/org/bukkit/craftbukkit/generator/strucutre/CraftStructure.java index 8b79b9be3..0d45002ef 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/strucutre/CraftStructure.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/strucutre/CraftStructure.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.generator.strucutre; -import net.minecraft.core.IRegistry; import net.minecraft.core.IRegistryCustom; +import net.minecraft.core.registries.Registries; import org.bukkit.NamespacedKey; import org.bukkit.Registry; import org.bukkit.craftbukkit.util.CraftNamespacedKey; @@ -15,7 +15,7 @@ public class CraftStructure extends Structure { return null; } - return Registry.STRUCTURE.get(CraftNamespacedKey.fromMinecraft(registryHolder.registryOrThrow(IRegistry.STRUCTURE_REGISTRY).getKey(minecraft))); + return Registry.STRUCTURE.get(CraftNamespacedKey.fromMinecraft(registryHolder.registryOrThrow(Registries.STRUCTURE).getKey(minecraft))); } public static net.minecraft.world.level.levelgen.structure.Structure bukkitToMinecraft(Structure bukkit) { diff --git a/src/main/java/org/bukkit/craftbukkit/generator/strucutre/CraftStructureType.java b/src/main/java/org/bukkit/craftbukkit/generator/strucutre/CraftStructureType.java index a841596ce..494919a8d 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/strucutre/CraftStructureType.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/strucutre/CraftStructureType.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.generator.strucutre; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import org.bukkit.NamespacedKey; import org.bukkit.Registry; import org.bukkit.craftbukkit.util.CraftNamespacedKey; @@ -13,7 +13,7 @@ public class CraftStructureType extends StructureType { return null; } - return Registry.STRUCTURE_TYPE.get(CraftNamespacedKey.fromMinecraft(IRegistry.STRUCTURE_TYPES.getKey(minecraft))); + return Registry.STRUCTURE_TYPE.get(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.STRUCTURE_TYPE.getKey(minecraft))); } public static net.minecraft.world.level.levelgen.structure.StructureType bukkitToMinecraft(StructureType bukkit) { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftBlastingRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftBlastingRecipe.java index b9a44c781..276216473 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftBlastingRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftBlastingRecipe.java @@ -18,6 +18,7 @@ public class CraftBlastingRecipe extends BlastingRecipe implements CraftRecipe { } CraftBlastingRecipe ret = new CraftBlastingRecipe(recipe.getKey(), recipe.getResult(), recipe.getInputChoice(), recipe.getExperience(), recipe.getCookingTime()); ret.setGroup(recipe.getGroup()); + ret.setCategory(recipe.getCategory()); return ret; } @@ -25,6 +26,6 @@ public class CraftBlastingRecipe extends BlastingRecipe implements CraftRecipe { public void addToCraftingManager() { ItemStack result = this.getResult(); - MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeBlasting(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); + MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeBlasting(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftRecipe.getCategory(this.getCategory()), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftCampfireRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftCampfireRecipe.java index 0a87d9573..132e8c924 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftCampfireRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftCampfireRecipe.java @@ -18,6 +18,7 @@ public class CraftCampfireRecipe extends CampfireRecipe implements CraftRecipe { } CraftCampfireRecipe ret = new CraftCampfireRecipe(recipe.getKey(), recipe.getResult(), recipe.getInputChoice(), recipe.getExperience(), recipe.getCookingTime()); ret.setGroup(recipe.getGroup()); + ret.setCategory(recipe.getCategory()); return ret; } @@ -25,6 +26,6 @@ public class CraftCampfireRecipe extends CampfireRecipe implements CraftRecipe { public void addToCraftingManager() { ItemStack result = this.getResult(); - MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeCampfire(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); + MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeCampfire(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftRecipe.getCategory(this.getCategory()), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftCreativeCategory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftCreativeCategory.java deleted file mode 100644 index 55ed932d9..000000000 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftCreativeCategory.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.bukkit.craftbukkit.inventory; - -import com.google.common.collect.ImmutableMap; -import java.util.Map; -import net.minecraft.world.item.CreativeModeTab; -import org.bukkit.inventory.CreativeCategory; - -public final class CraftCreativeCategory { - - private static final Map NMS_TO_BUKKIT = ImmutableMap.builder() - .put(CreativeModeTab.TAB_BUILDING_BLOCKS, CreativeCategory.BUILDING_BLOCKS) - .put(CreativeModeTab.TAB_DECORATIONS, CreativeCategory.DECORATIONS) - .put(CreativeModeTab.TAB_REDSTONE, CreativeCategory.REDSTONE) - .put(CreativeModeTab.TAB_TRANSPORTATION, CreativeCategory.TRANSPORTATION) - .put(CreativeModeTab.TAB_MISC, CreativeCategory.MISC) // Interchangeable with TAB_MATERIALS, same instance - .put(CreativeModeTab.TAB_FOOD, CreativeCategory.FOOD) - .put(CreativeModeTab.TAB_TOOLS, CreativeCategory.TOOLS) - .put(CreativeModeTab.TAB_COMBAT, CreativeCategory.COMBAT) - .put(CreativeModeTab.TAB_BREWING, CreativeCategory.BREWING) - .build(); - - public static CreativeCategory fromNMS(CreativeModeTab tab) { - if (tab == null) { - return null; - } - - CreativeCategory bukkit = NMS_TO_BUKKIT.get(tab); - if (bukkit == null) { - throw new UnsupportedOperationException("Item is not present in any known CreativeModeTab. This is a bug."); - } - - return bukkit; - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java index c1a04c5df..a4e919164 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java @@ -18,6 +18,7 @@ public class CraftFurnaceRecipe extends FurnaceRecipe implements CraftRecipe { } CraftFurnaceRecipe ret = new CraftFurnaceRecipe(recipe.getKey(), recipe.getResult(), recipe.getInputChoice(), recipe.getExperience(), recipe.getCookingTime()); ret.setGroup(recipe.getGroup()); + ret.setCategory(recipe.getCategory()); return ret; } @@ -25,6 +26,6 @@ public class CraftFurnaceRecipe extends FurnaceRecipe implements CraftRecipe { public void addToCraftingManager() { ItemStack result = this.getResult(); - MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.FurnaceRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); + MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.FurnaceRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftRecipe.getCategory(this.getCategory()), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java index 88ae61c14..df59694e7 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -9,6 +9,7 @@ import net.minecraft.world.inventory.InventoryCrafting; import net.minecraft.world.inventory.InventoryEnderChest; import net.minecraft.world.inventory.InventoryMerchant; import net.minecraft.world.level.block.BlockComposter; +import net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity; import net.minecraft.world.level.block.entity.IHopper; import net.minecraft.world.level.block.entity.TileEntityBarrel; import net.minecraft.world.level.block.entity.TileEntityBlastFurnace; @@ -489,6 +490,8 @@ public class CraftInventory implements Inventory { return InventoryType.BARREL; } else if (inventory instanceof TileEntityLectern.LecternInventory) { return InventoryType.LECTERN; + } else if (inventory instanceof ChiseledBookShelfBlockEntity) { + return InventoryType.CHISELED_BOOKSHELF; } else if (this instanceof CraftInventoryLoom) { return InventoryType.LOOM; } else if (this instanceof CraftInventoryCartography) { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryChiseledBookshelf.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryChiseledBookshelf.java new file mode 100644 index 000000000..e2082746f --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryChiseledBookshelf.java @@ -0,0 +1,18 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity; +import org.bukkit.block.ChiseledBookshelf; +import org.bukkit.inventory.ChiseledBookshelfInventory; + +public class CraftInventoryChiseledBookshelf extends CraftInventory implements ChiseledBookshelfInventory { + + public CraftInventoryChiseledBookshelf(ChiseledBookShelfBlockEntity inventory) { + super(inventory); + + } + + @Override + public ChiseledBookshelf getHolder() { + return (ChiseledBookshelf) inventory.getOwner(); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java index dd9b1e6fc..b7460c191 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -4,7 +4,7 @@ import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.commands.arguments.item.ArgumentParserItemStack; import net.minecraft.core.HolderLookup; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.item.Item; import org.apache.commons.lang.Validate; @@ -68,6 +68,8 @@ public final class CraftItemFactory implements ItemFactory { case CREEPER_WALL_HEAD: case DRAGON_HEAD: case DRAGON_WALL_HEAD: + case PIGLIN_HEAD: + case PIGLIN_WALL_HEAD: case PLAYER_HEAD: case PLAYER_WALL_HEAD: case SKELETON_SKULL: @@ -207,23 +209,45 @@ public final class CraftItemFactory implements ItemFactory { case JUKEBOX: case DISPENSER: case DROPPER: + case ACACIA_HANGING_SIGN: case ACACIA_SIGN: + case ACACIA_WALL_HANGING_SIGN: case ACACIA_WALL_SIGN: + case BAMBOO_HANGING_SIGN: + case BAMBOO_SIGN: + case BAMBOO_WALL_HANGING_SIGN: + case BAMBOO_WALL_SIGN: + case BIRCH_HANGING_SIGN: case BIRCH_SIGN: + case BIRCH_WALL_HANGING_SIGN: case BIRCH_WALL_SIGN: + case CRIMSON_HANGING_SIGN: case CRIMSON_SIGN: + case CRIMSON_WALL_HANGING_SIGN: case CRIMSON_WALL_SIGN: + case DARK_OAK_HANGING_SIGN: case DARK_OAK_SIGN: + case DARK_OAK_WALL_HANGING_SIGN: case DARK_OAK_WALL_SIGN: + case JUNGLE_HANGING_SIGN: case JUNGLE_SIGN: + case JUNGLE_WALL_HANGING_SIGN: case JUNGLE_WALL_SIGN: + case MANGROVE_HANGING_SIGN: case MANGROVE_SIGN: + case MANGROVE_WALL_HANGING_SIGN: case MANGROVE_WALL_SIGN: + case OAK_HANGING_SIGN: case OAK_SIGN: + case OAK_WALL_HANGING_SIGN: case OAK_WALL_SIGN: + case SPRUCE_HANGING_SIGN: case SPRUCE_SIGN: + case SPRUCE_WALL_HANGING_SIGN: case SPRUCE_WALL_SIGN: + case WARPED_HANGING_SIGN: case WARPED_SIGN: + case WARPED_WALL_HANGING_SIGN: case WARPED_WALL_SIGN: case SPAWNER: case BREWING_STAND: @@ -268,6 +292,7 @@ public final class CraftItemFactory implements ItemFactory { case SCULK_CATALYST: case SCULK_SHRIEKER: case SCULK_SENSOR: + case CHISELED_BOOKSHELF: return new CraftMetaBlockState(meta, material); case TROPICAL_FISH_BUCKET: return meta instanceof CraftMetaTropicalFishBucket ? meta : new CraftMetaTropicalFishBucket(meta); @@ -354,7 +379,7 @@ public final class CraftItemFactory implements ItemFactory { @Override public ItemStack createItemStack(String input) throws IllegalArgumentException { try { - ArgumentParserItemStack.a arg = ArgumentParserItemStack.parseForItem(HolderLookup.forRegistry(IRegistry.ITEM), new StringReader(input)); + ArgumentParserItemStack.a arg = ArgumentParserItemStack.parseForItem(BuiltInRegistries.ITEM.asLookup(), new StringReader(input)); Item item = arg.item().value(); net.minecraft.world.item.ItemStack nmsItemStack = new net.minecraft.world.item.ItemStack(item); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index a4c3625cc..b34fa65a4 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -331,6 +331,8 @@ public final class CraftItemStack extends ItemStack { case CREEPER_WALL_HEAD: case DRAGON_HEAD: case DRAGON_WALL_HEAD: + case PIGLIN_HEAD: + case PIGLIN_WALL_HEAD: case PLAYER_HEAD: case PLAYER_WALL_HEAD: case SKELETON_SKULL: @@ -470,23 +472,45 @@ public final class CraftItemStack extends ItemStack { case JUKEBOX: case DISPENSER: case DROPPER: + case ACACIA_HANGING_SIGN: case ACACIA_SIGN: + case ACACIA_WALL_HANGING_SIGN: case ACACIA_WALL_SIGN: + case BAMBOO_HANGING_SIGN: + case BAMBOO_SIGN: + case BAMBOO_WALL_HANGING_SIGN: + case BAMBOO_WALL_SIGN: + case BIRCH_HANGING_SIGN: case BIRCH_SIGN: + case BIRCH_WALL_HANGING_SIGN: case BIRCH_WALL_SIGN: + case CRIMSON_HANGING_SIGN: case CRIMSON_SIGN: + case CRIMSON_WALL_HANGING_SIGN: case CRIMSON_WALL_SIGN: + case DARK_OAK_HANGING_SIGN: case DARK_OAK_SIGN: + case DARK_OAK_WALL_HANGING_SIGN: case DARK_OAK_WALL_SIGN: + case JUNGLE_HANGING_SIGN: case JUNGLE_SIGN: + case JUNGLE_WALL_HANGING_SIGN: case JUNGLE_WALL_SIGN: + case MANGROVE_HANGING_SIGN: case MANGROVE_SIGN: + case MANGROVE_WALL_HANGING_SIGN: case MANGROVE_WALL_SIGN: + case OAK_HANGING_SIGN: case OAK_SIGN: + case OAK_WALL_HANGING_SIGN: case OAK_WALL_SIGN: + case SPRUCE_HANGING_SIGN: case SPRUCE_SIGN: + case SPRUCE_WALL_HANGING_SIGN: case SPRUCE_WALL_SIGN: + case WARPED_HANGING_SIGN: case WARPED_SIGN: + case WARPED_WALL_HANGING_SIGN: case WARPED_WALL_SIGN: case SPAWNER: case BREWING_STAND: @@ -531,6 +555,7 @@ public final class CraftItemStack extends ItemStack { case SCULK_CATALYST: case SCULK_SHRIEKER: case SCULK_SENSOR: + case CHISELED_BOOKSHELF: return new CraftMetaBlockState(item.getTag(), CraftMagicNumbers.getMaterial(item.getItem())); case TROPICAL_FISH_BUCKET: return new CraftMetaTropicalFishBucket(item.getTag()); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java index ac133e049..671c39574 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java @@ -47,23 +47,45 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta Material.JUKEBOX, Material.DISPENSER, Material.DROPPER, + Material.ACACIA_HANGING_SIGN, Material.ACACIA_SIGN, + Material.ACACIA_WALL_HANGING_SIGN, Material.ACACIA_WALL_SIGN, + Material.BAMBOO_HANGING_SIGN, + Material.BAMBOO_SIGN, + Material.BAMBOO_WALL_HANGING_SIGN, + Material.BAMBOO_WALL_SIGN, + Material.BIRCH_HANGING_SIGN, Material.BIRCH_SIGN, + Material.BIRCH_WALL_HANGING_SIGN, Material.BIRCH_WALL_SIGN, + Material.CRIMSON_HANGING_SIGN, Material.CRIMSON_SIGN, + Material.CRIMSON_WALL_HANGING_SIGN, Material.CRIMSON_WALL_SIGN, + Material.DARK_OAK_HANGING_SIGN, Material.DARK_OAK_SIGN, + Material.DARK_OAK_WALL_HANGING_SIGN, Material.DARK_OAK_WALL_SIGN, + Material.JUNGLE_HANGING_SIGN, Material.JUNGLE_SIGN, + Material.JUNGLE_WALL_HANGING_SIGN, Material.JUNGLE_WALL_SIGN, + Material.MANGROVE_HANGING_SIGN, Material.MANGROVE_SIGN, + Material.MANGROVE_WALL_HANGING_SIGN, Material.MANGROVE_WALL_SIGN, + Material.OAK_HANGING_SIGN, Material.OAK_SIGN, + Material.OAK_WALL_HANGING_SIGN, Material.OAK_WALL_SIGN, + Material.SPRUCE_HANGING_SIGN, Material.SPRUCE_SIGN, + Material.SPRUCE_WALL_HANGING_SIGN, Material.SPRUCE_WALL_SIGN, + Material.WARPED_HANGING_SIGN, Material.WARPED_SIGN, + Material.WARPED_WALL_HANGING_SIGN, Material.WARPED_WALL_SIGN, Material.SPAWNER, Material.BREWING_STAND, @@ -90,7 +112,8 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta Material.BEE_NEST, Material.SCULK_CATALYST, Material.SCULK_SHRIEKER, - Material.SCULK_SENSOR + Material.SCULK_SENSOR, + Material.CHISELED_BOOKSHELF ); static { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java index e3f7f4562..9dcf8c5f6 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java @@ -28,6 +28,8 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { Material.CREEPER_WALL_HEAD, Material.DRAGON_HEAD, Material.DRAGON_WALL_HEAD, + Material.PIGLIN_HEAD, + Material.PIGLIN_WALL_HEAD, Material.PLAYER_HEAD, Material.PLAYER_WALL_HEAD, Material.SKELETON_SKULL, diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java index 83d697210..6c1641b85 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java @@ -7,6 +7,8 @@ import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; import org.bukkit.inventory.RecipeChoice; +import org.bukkit.inventory.recipe.CookingBookCategory; +import org.bukkit.inventory.recipe.CraftingBookCategory; public interface CraftRecipe extends Recipe { @@ -26,7 +28,7 @@ public interface CraftRecipe extends Recipe { throw new IllegalArgumentException("Unknown recipe stack instance " + bukkit); } - stack.dissolve(); + stack.getItems(); if (requireNotEmpty && stack.itemStacks.length == 0) { throw new IllegalArgumentException("Recipe requires at least one non-air choice!"); } @@ -35,7 +37,7 @@ public interface CraftRecipe extends Recipe { } public static RecipeChoice toBukkit(RecipeItemStack list) { - list.dissolve(); + list.getItems(); if (list.itemStacks.length == 0) { return null; @@ -58,4 +60,20 @@ public interface CraftRecipe extends Recipe { return new RecipeChoice.MaterialChoice(choices); } } + + public static net.minecraft.world.item.crafting.CraftingBookCategory getCategory(CraftingBookCategory bukkit) { + return net.minecraft.world.item.crafting.CraftingBookCategory.valueOf(bukkit.name()); + } + + public static CraftingBookCategory getCategory(net.minecraft.world.item.crafting.CraftingBookCategory nms) { + return CraftingBookCategory.valueOf(nms.name()); + } + + public static net.minecraft.world.item.crafting.CookingBookCategory getCategory(CookingBookCategory bukkit) { + return net.minecraft.world.item.crafting.CookingBookCategory.valueOf(bukkit.name()); + } + + public static CookingBookCategory getCategory(net.minecraft.world.item.crafting.CookingBookCategory nms) { + return CookingBookCategory.valueOf(nms.name()); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java index 8770d62bf..c967eb73b 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java @@ -3,6 +3,7 @@ package org.bukkit.craftbukkit.inventory; import java.util.Map; import net.minecraft.core.NonNullList; import net.minecraft.server.MinecraftServer; +import net.minecraft.world.item.crafting.CraftingBookCategory; import net.minecraft.world.item.crafting.RecipeItemStack; import net.minecraft.world.item.crafting.ShapedRecipes; import org.bukkit.NamespacedKey; @@ -30,6 +31,7 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe { } CraftShapedRecipe ret = new CraftShapedRecipe(recipe.getKey(), recipe.getResult()); ret.setGroup(recipe.getGroup()); + ret.setCategory(recipe.getCategory()); String[] shape = recipe.getShape(); ret.shape(shape); Map ingredientMap = recipe.getChoiceMap(); @@ -55,7 +57,6 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe { data.set(i * width + j, toNMS(ingred.get(row.charAt(j)), false)); } } - - MinecraftServer.getServer().getRecipeManager().addRecipe(new ShapedRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), width, shape.length, data, CraftItemStack.asNMSCopy(this.getResult()))); + MinecraftServer.getServer().getRecipeManager().addRecipe(new ShapedRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftRecipe.getCategory(this.getCategory()), width, shape.length, data, CraftItemStack.asNMSCopy(this.getResult()))); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java index 1f9b5dcbb..9f9c7f18a 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java @@ -30,6 +30,7 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe } CraftShapelessRecipe ret = new CraftShapelessRecipe(recipe.getKey(), recipe.getResult()); ret.setGroup(recipe.getGroup()); + ret.setCategory(recipe.getCategory()); for (RecipeChoice ingred : recipe.getChoiceList()) { ret.addIngredient(ingred); } @@ -44,6 +45,6 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe data.set(i, toNMS(ingred.get(i), true)); } - MinecraftServer.getServer().getRecipeManager().addRecipe(new ShapelessRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftItemStack.asNMSCopy(this.getResult()), data)); + MinecraftServer.getServer().getRecipeManager().addRecipe(new ShapelessRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data)); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmokingRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmokingRecipe.java index 1bed390af..d1644f401 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmokingRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmokingRecipe.java @@ -18,6 +18,7 @@ public class CraftSmokingRecipe extends SmokingRecipe implements CraftRecipe { } CraftSmokingRecipe ret = new CraftSmokingRecipe(recipe.getKey(), recipe.getResult(), recipe.getInputChoice(), recipe.getExperience(), recipe.getCookingTime()); ret.setGroup(recipe.getGroup()); + ret.setCategory(recipe.getCategory()); return ret; } @@ -25,6 +26,6 @@ public class CraftSmokingRecipe extends SmokingRecipe implements CraftRecipe { public void addToCraftingManager() { ItemStack result = this.getResult(); - MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeSmoking(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); + MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeSmoking(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftRecipe.getCategory(this.getCategory()), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); } } diff --git a/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java b/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java index ed79cfbfc..c3c64bd40 100644 --- a/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java +++ b/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java @@ -10,6 +10,7 @@ import java.util.Optional; import java.util.Set; import net.minecraft.SharedConstants; import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.DynamicOpsNBT; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; @@ -333,7 +334,7 @@ public final class CraftLegacy { } String name = blockTag.get("Name").asString(""); - Block block = IRegistry.BLOCK.get(new MinecraftKey(name)); + Block block = BuiltInRegistries.BLOCK.get(new MinecraftKey(name)); if (block == null) { continue; } @@ -411,7 +412,7 @@ public final class CraftLegacy { } // Preconditions.checkState(newId.contains("minecraft:"), "Unknown new material for " + matData); - Item newMaterial = IRegistry.ITEM.get(new MinecraftKey(newId)); + Item newMaterial = BuiltInRegistries.ITEM.get(new MinecraftKey(newId)); if (newMaterial == Items.AIR) { continue; diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java index 830a1ab3d..93ae67284 100644 --- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java +++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java @@ -74,22 +74,22 @@ public final class CraftMapView implements MapView { @Override public int getCenterX() { - return worldMap.x; + return worldMap.centerX; } @Override public int getCenterZ() { - return worldMap.z; + return worldMap.centerZ; } @Override public void setCenterX(int x) { - worldMap.x = x; + worldMap.centerX = x; } @Override public void setCenterZ(int z) { - worldMap.z = z; + worldMap.centerZ = z; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java index 39177b1a1..f7cbf787f 100644 --- a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java +++ b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit.potion; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.effect.MobEffectList; import org.bukkit.Color; import org.bukkit.potion.PotionEffectType; @@ -8,7 +9,7 @@ public class CraftPotionEffectType extends PotionEffectType { private final MobEffectList handle; public CraftPotionEffectType(MobEffectList handle) { - super(MobEffectList.getId(handle), org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(net.minecraft.core.IRegistry.MOB_EFFECT.getKey(handle))); + super(MobEffectList.getId(handle), org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(BuiltInRegistries.MOB_EFFECT.getKey(handle))); this.handle = handle; } diff --git a/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java b/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java index 3c02a335f..8a43688cd 100644 --- a/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java +++ b/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java @@ -1,10 +1,10 @@ package org.bukkit.craftbukkit.tag; -import java.util.Collections; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.tags.TagKey; import net.minecraft.world.entity.EntityTypes; @@ -20,7 +20,7 @@ public class CraftEntityTag extends CraftTag, EntityType> { @Override public boolean isTagged(EntityType entity) { - return registry.getHolderOrThrow(ResourceKey.create(IRegistry.ENTITY_TYPE_REGISTRY, CraftNamespacedKey.toMinecraft(entity.getKey()))).is(tag); + return registry.getHolderOrThrow(ResourceKey.create(Registries.ENTITY_TYPE, CraftNamespacedKey.toMinecraft(entity.getKey()))).is(tag); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 31882c8f5..909deb4d0 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -23,7 +23,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import net.minecraft.SharedConstants; import net.minecraft.advancements.critereon.LootDeserializationContext; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.DynamicOpsNBT; import net.minecraft.nbt.MojangsonParser; import net.minecraft.nbt.NBTBase; @@ -36,7 +36,6 @@ import net.minecraft.util.ChatDeserializer; import net.minecraft.util.datafix.DataConverterRegistry; import net.minecraft.util.datafix.fixes.DataConverterTypes; import net.minecraft.world.entity.ai.attributes.AttributeBase; -import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.IBlockData; @@ -56,7 +55,6 @@ import org.bukkit.craftbukkit.CraftEquipmentSlot; import org.bukkit.craftbukkit.attribute.CraftAttributeInstance; import org.bukkit.craftbukkit.attribute.CraftAttributeMap; import org.bukkit.craftbukkit.block.data.CraftBlockData; -import org.bukkit.craftbukkit.inventory.CraftCreativeCategory; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.legacy.CraftLegacy; import org.bukkit.inventory.CreativeCategory; @@ -105,16 +103,16 @@ public final class CraftMagicNumbers implements UnsafeValues { private static final Map MATERIAL_FLUID = new HashMap<>(); static { - for (Block block : IRegistry.BLOCK) { - BLOCK_MATERIAL.put(block, Material.getMaterial(IRegistry.BLOCK.getKey(block).getPath().toUpperCase(Locale.ROOT))); + for (Block block : BuiltInRegistries.BLOCK) { + BLOCK_MATERIAL.put(block, Material.getMaterial(BuiltInRegistries.BLOCK.getKey(block).getPath().toUpperCase(Locale.ROOT))); } - for (Item item : IRegistry.ITEM) { - ITEM_MATERIAL.put(item, Material.getMaterial(IRegistry.ITEM.getKey(item).getPath().toUpperCase(Locale.ROOT))); + for (Item item : BuiltInRegistries.ITEM) { + ITEM_MATERIAL.put(item, Material.getMaterial(BuiltInRegistries.ITEM.getKey(item).getPath().toUpperCase(Locale.ROOT))); } - for (FluidType fluid : IRegistry.FLUID) { - FLUID_MATERIAL.put(fluid, Registry.FLUID.get(CraftNamespacedKey.fromMinecraft(IRegistry.FLUID.getKey(fluid)))); + for (FluidType fluid : BuiltInRegistries.FLUID) { + FLUID_MATERIAL.put(fluid, Registry.FLUID.get(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.FLUID.getKey(fluid)))); } for (Material material : Material.values()) { @@ -123,13 +121,13 @@ public final class CraftMagicNumbers implements UnsafeValues { } MinecraftKey key = key(material); - IRegistry.ITEM.getOptional(key).ifPresent((item) -> { + BuiltInRegistries.ITEM.getOptional(key).ifPresent((item) -> { MATERIAL_ITEM.put(material, item); }); - IRegistry.BLOCK.getOptional(key).ifPresent((block) -> { + BuiltInRegistries.BLOCK.getOptional(key).ifPresent((block) -> { MATERIAL_BLOCK.put(material, block); }); - IRegistry.FLUID.getOptional(key).ifPresent((fluid) -> { + BuiltInRegistries.FLUID.getOptional(key).ifPresent((fluid) -> { MATERIAL_FLUID.put(material, fluid); }); } @@ -237,7 +235,7 @@ public final class CraftMagicNumbers implements UnsafeValues { * @return string */ public String getMappingsVersion() { - return "69c84c88aeb92ce9fa9525438b93f4fe"; + return "1afe2ffe8a9d7fc510442a168b3d4338"; } @Override @@ -351,7 +349,7 @@ public final class CraftMagicNumbers implements UnsafeValues { Multimap nmsDefaultAttributes = getItem(material).getDefaultAttributeModifiers(CraftEquipmentSlot.getNMS(slot)); for (Entry mapEntry : nmsDefaultAttributes.entries()) { - Attribute attribute = CraftAttributeMap.fromMinecraft(IRegistry.ATTRIBUTE.getKey(mapEntry.getKey()).toString()); + Attribute attribute = CraftAttributeMap.fromMinecraft(BuiltInRegistries.ATTRIBUTE.getKey(mapEntry.getKey()).toString()); defaultAttributes.put(attribute, CraftAttributeInstance.convert(mapEntry.getValue(), slot)); } @@ -360,8 +358,7 @@ public final class CraftMagicNumbers implements UnsafeValues { @Override public CreativeCategory getCreativeCategory(Material material) { - CreativeModeTab category = getItem(material).getItemCategory(); - return CraftCreativeCategory.fromNMS(category); + return CreativeCategory.BUILDING_BLOCKS; // TODO: Figure out what to do with this } /** diff --git a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java index 83827c23a..944acab3d 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java +++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java @@ -1,7 +1,6 @@ package org.bukkit.craftbukkit.util; import java.util.List; -import java.util.Random; import java.util.function.Predicate; import net.minecraft.core.BlockPosition; import net.minecraft.core.EnumDirection; @@ -16,6 +15,7 @@ import net.minecraft.util.RandomSource; import net.minecraft.world.DifficultyDamageScaler; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.level.GeneratorAccessSeed; import net.minecraft.world.level.biome.BiomeBase; import net.minecraft.world.level.biome.BiomeManager; @@ -124,11 +124,6 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed { throw new UnsupportedOperationException("Not supported yet."); } - @Override - public IRegistryCustom registryAccess() { - throw new UnsupportedOperationException("Not supported yet."); - } - @Override public List getEntities(Entity entity, AxisAlignedBB aabb, Predicate prdct) { throw new UnsupportedOperationException("Not supported yet."); @@ -184,6 +179,16 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed { throw new UnsupportedOperationException("Not supported yet."); } + @Override + public IRegistryCustom registryAccess() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public FeatureFlagSet enabledFeatures() { + throw new UnsupportedOperationException("Not supported yet."); + } + @Override public float getShade(EnumDirection ed, boolean bln) { throw new UnsupportedOperationException("Not supported yet."); diff --git a/src/test/java/org/bukkit/ArtTest.java b/src/test/java/org/bukkit/ArtTest.java index 5ea0c5ae4..68c938eae 100644 --- a/src/test/java/org/bukkit/ArtTest.java +++ b/src/test/java/org/bukkit/ArtTest.java @@ -9,7 +9,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import net.minecraft.core.Holder; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceKey; import net.minecraft.world.entity.decoration.PaintingVariant; import org.bukkit.craftbukkit.CraftArt; @@ -23,8 +23,8 @@ public class ArtTest extends AbstractTestingBase { public void verifyMapping() { List arts = Lists.newArrayList(Art.values()); - for (ResourceKey key : IRegistry.PAINTING_VARIANT.registryKeySet()) { - Holder enumArt = IRegistry.PAINTING_VARIANT.getHolderOrThrow(key); + for (ResourceKey key : BuiltInRegistries.PAINTING_VARIANT.registryKeySet()) { + Holder enumArt = BuiltInRegistries.PAINTING_VARIANT.getHolderOrThrow(key); String name = key.location().getPath(); int width = enumArt.value().getWidth() / UNIT_MULTIPLIER; int height = enumArt.value().getHeight() / UNIT_MULTIPLIER; @@ -57,7 +57,7 @@ public class ArtTest extends AbstractTestingBase { @Test public void testCraftArtToBukkit() { Map> cache = new EnumMap(Art.class); - for (Holder enumArt : IRegistry.PAINTING_VARIANT.asHolderIdMap()) { + for (Holder enumArt : BuiltInRegistries.PAINTING_VARIANT.asHolderIdMap()) { Art art = CraftArt.NotchToBukkit(enumArt); assertNotNull("Could not CraftArt.NotchToBukkit " + enumArt, art); assertThat("Duplicate artwork " + enumArt, cache.put(art, enumArt), is(nullValue())); diff --git a/src/test/java/org/bukkit/BiomeTest.java b/src/test/java/org/bukkit/BiomeTest.java index c95b80286..07a61ad33 100644 --- a/src/test/java/org/bukkit/BiomeTest.java +++ b/src/test/java/org/bukkit/BiomeTest.java @@ -1,6 +1,5 @@ package org.bukkit; -import net.minecraft.data.RegistryGeneration; import net.minecraft.world.level.biome.BiomeBase; import org.bukkit.block.Biome; import org.bukkit.craftbukkit.block.CraftBlock; @@ -17,14 +16,14 @@ public class BiomeTest extends AbstractTestingBase { continue; } - Assert.assertNotNull("No NMS mapping for " + biome, CraftBlock.biomeToBiomeBase(RegistryGeneration.BIOME, biome)); + Assert.assertNotNull("No NMS mapping for " + biome, CraftBlock.biomeToBiomeBase(BIOMES, biome)); } } @Test public void testMinecraftToBukkit() { - for (BiomeBase biomeBase : RegistryGeneration.BIOME) { - Biome biome = CraftBlock.biomeBaseToBiome(RegistryGeneration.BIOME, biomeBase); + for (BiomeBase biomeBase : BIOMES) { + Biome biome = CraftBlock.biomeBaseToBiome(BIOMES, biomeBase); Assert.assertTrue("No Bukkit mapping for " + biomeBase, biome != null && biome != Biome.CUSTOM); } } diff --git a/src/test/java/org/bukkit/BlockDataConversionTest.java b/src/test/java/org/bukkit/BlockDataConversionTest.java index 85e139467..3aded3548 100644 --- a/src/test/java/org/bukkit/BlockDataConversionTest.java +++ b/src/test/java/org/bukkit/BlockDataConversionTest.java @@ -2,7 +2,7 @@ package org.bukkit; import java.util.ArrayList; import java.util.List; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.IBlockData; import org.bukkit.craftbukkit.block.data.CraftBlockData; @@ -13,7 +13,7 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; /** - * This test class ensures that all Blocks (as registered in IRegistry.BLOCK) + * This test class ensures that all Blocks (as registered in BuiltInRegistries.BLOCK) * can be converted into their CraftBlockData equivalent. */ @RunWith(Parameterized.class) @@ -22,7 +22,7 @@ public class BlockDataConversionTest extends AbstractTestingBase { @Parameterized.Parameters(name = "{index}: {0}") public static List args() { List list = new ArrayList<>(); - for (Block block : (Iterable) IRegistry.BLOCK) { + for (Block block : (Iterable) BuiltInRegistries.BLOCK) { list.add(new Object[]{block.defaultBlockState()}); } return list; diff --git a/src/test/java/org/bukkit/EnchantmentTest.java b/src/test/java/org/bukkit/EnchantmentTest.java index 073559da1..f32102a17 100644 --- a/src/test/java/org/bukkit/EnchantmentTest.java +++ b/src/test/java/org/bukkit/EnchantmentTest.java @@ -1,6 +1,6 @@ package org.bukkit; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.MinecraftKey; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.enchantments.Enchantment; @@ -12,8 +12,8 @@ public class EnchantmentTest extends AbstractTestingBase { @Test public void verifyMapping() { - for (MinecraftKey key : IRegistry.ENCHANTMENT.keySet()) { - net.minecraft.world.item.enchantment.Enchantment nms = IRegistry.ENCHANTMENT.get(key); + for (MinecraftKey key : BuiltInRegistries.ENCHANTMENT.keySet()) { + net.minecraft.world.item.enchantment.Enchantment nms = BuiltInRegistries.ENCHANTMENT.get(key); Enchantment bukkitById = Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(key)); diff --git a/src/test/java/org/bukkit/GameEventTest.java b/src/test/java/org/bukkit/GameEventTest.java index e133dff23..bb25e9e0e 100644 --- a/src/test/java/org/bukkit/GameEventTest.java +++ b/src/test/java/org/bukkit/GameEventTest.java @@ -1,6 +1,6 @@ package org.bukkit; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.support.AbstractTestingBase; import org.junit.Assert; @@ -10,8 +10,8 @@ public class GameEventTest extends AbstractTestingBase { @Test public void toBukkit() { - for (net.minecraft.world.level.gameevent.GameEvent nms : IRegistry.GAME_EVENT) { - GameEvent bukkit = GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.GAME_EVENT.getKey(nms))); + for (net.minecraft.world.level.gameevent.GameEvent nms : BuiltInRegistries.GAME_EVENT) { + GameEvent bukkit = GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.GAME_EVENT.getKey(nms))); Assert.assertNotNull("Bukkit should not be null " + nms, bukkit); } diff --git a/src/test/java/org/bukkit/MaterialTest.java b/src/test/java/org/bukkit/MaterialTest.java index 0f4016391..f2973810c 100644 --- a/src/test/java/org/bukkit/MaterialTest.java +++ b/src/test/java/org/bukkit/MaterialTest.java @@ -11,7 +11,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.stream.StreamSupport; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.MinecraftKey; import net.minecraft.world.item.Item; import org.bukkit.craftbukkit.util.CraftMagicNumbers; @@ -31,13 +31,13 @@ public class MaterialTest extends AbstractTestingBase { materials.put(CraftMagicNumbers.key(material), material); } - Iterator items = IRegistry.ITEM.iterator(); + Iterator items = BuiltInRegistries.ITEM.iterator(); while (items.hasNext()) { Item item = items.next(); if (item == null) continue; - MinecraftKey id = IRegistry.ITEM.getKey(item); + MinecraftKey id = BuiltInRegistries.ITEM.getKey(item); String name = item.getDescriptionId(); Material material = materials.remove(id); @@ -53,13 +53,13 @@ public class MaterialTest extends AbstractTestingBase { public void verifyMaterialOrder() { List expectedOrder = new ArrayList<>(Material.values().length); - // Start with items in the same order as IRegistry.ITEM - StreamSupport.stream(IRegistry.ITEM.spliterator(), false) + // Start with items in the same order as BuiltInRegistries.ITEM + StreamSupport.stream(BuiltInRegistries.ITEM.spliterator(), false) .map(CraftMagicNumbers::getMaterial) .forEach(expectedOrder::add); - // Then non-item blocks in the same order as IRegistry.BLOCK - StreamSupport.stream(IRegistry.BLOCK.spliterator(), false) + // Then non-item blocks in the same order as BuiltInRegistries.BLOCK + StreamSupport.stream(BuiltInRegistries.BLOCK.spliterator(), false) .map(CraftMagicNumbers::getMaterial) .filter(block -> !block.isItem()) .forEach(expectedOrder::add); diff --git a/src/test/java/org/bukkit/ParticleTest.java b/src/test/java/org/bukkit/ParticleTest.java index 29e2f55b9..a1f935854 100644 --- a/src/test/java/org/bukkit/ParticleTest.java +++ b/src/test/java/org/bukkit/ParticleTest.java @@ -1,6 +1,6 @@ package org.bukkit; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.CraftParticle; import org.bukkit.craftbukkit.block.data.CraftBlockData; @@ -36,8 +36,8 @@ public class ParticleTest extends AbstractTestingBase { Assert.assertNotNull("Missing Bukkit->NMS particle mapping for " + bukkit, CraftParticle.toNMS(bukkit, data)); } - for (net.minecraft.core.particles.Particle nms : IRegistry.PARTICLE_TYPE) { - Assert.assertNotNull("Missing NMS->Bukkit particle mapping for " + IRegistry.PARTICLE_TYPE.getKey(nms), CraftParticle.toBukkit(nms)); + for (net.minecraft.core.particles.Particle nms : BuiltInRegistries.PARTICLE_TYPE) { + Assert.assertNotNull("Missing NMS->Bukkit particle mapping for " + BuiltInRegistries.PARTICLE_TYPE.getKey(nms), CraftParticle.toBukkit(nms)); } } } diff --git a/src/test/java/org/bukkit/PotionEffectTypeTest.java b/src/test/java/org/bukkit/PotionEffectTypeTest.java index 6cbc96641..2257e056f 100644 --- a/src/test/java/org/bukkit/PotionEffectTypeTest.java +++ b/src/test/java/org/bukkit/PotionEffectTypeTest.java @@ -5,7 +5,7 @@ import static org.junit.Assert.*; import com.google.common.collect.Lists; import java.util.Collections; import java.util.List; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.MinecraftKey; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.potion.PotionEffectType; @@ -18,7 +18,7 @@ public class PotionEffectTypeTest extends AbstractTestingBase { public void verifyMapping() { List effects = Lists.newArrayList(PotionEffectType.values()); - for (MinecraftKey key : IRegistry.MOB_EFFECT.keySet()) { + for (MinecraftKey key : BuiltInRegistries.MOB_EFFECT.keySet()) { String name = key.getPath(); PotionEffectType effect = PotionEffectType.getByKey(CraftNamespacedKey.fromMinecraft(key)); diff --git a/src/test/java/org/bukkit/SoundTest.java b/src/test/java/org/bukkit/SoundTest.java index 18a98c589..e6274f9f7 100644 --- a/src/test/java/org/bukkit/SoundTest.java +++ b/src/test/java/org/bukkit/SoundTest.java @@ -2,7 +2,7 @@ package org.bukkit; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.MinecraftKey; import org.bukkit.craftbukkit.CraftSound; import org.bukkit.support.AbstractTestingBase; @@ -19,7 +19,7 @@ public class SoundTest extends AbstractTestingBase { @Test public void testReverse() { - for (MinecraftKey effect : IRegistry.SOUND_EVENT.keySet()) { + for (MinecraftKey effect : BuiltInRegistries.SOUND_EVENT.keySet()) { assertNotNull(effect + "", Sound.valueOf(effect.getPath().replace('.', '_').toUpperCase(java.util.Locale.ENGLISH))); } } diff --git a/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java b/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java index 2439ca837..5c0fbee45 100644 --- a/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java +++ b/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java @@ -3,7 +3,7 @@ package org.bukkit; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; import com.google.common.collect.HashMultiset; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.stats.StatisticWrapper; import net.minecraft.world.entity.EntityTypes; import org.bukkit.craftbukkit.CraftStatistic; @@ -31,7 +31,7 @@ public class StatisticsAndAchievementsTest extends AbstractTestingBase { @SuppressWarnings("unchecked") public void verifyStatisticMapping() throws Throwable { HashMultiset statistics = HashMultiset.create(); - for (StatisticWrapper wrapper : IRegistry.STAT_TYPE) { + for (StatisticWrapper wrapper : BuiltInRegistries.STAT_TYPE) { for (Object child : wrapper.getRegistry()) { net.minecraft.stats.Statistic statistic = wrapper.get(child); String message = String.format("org.bukkit.Statistic is missing: '%s'", statistic); @@ -39,9 +39,9 @@ public class StatisticsAndAchievementsTest extends AbstractTestingBase { Statistic subject = CraftStatistic.getBukkitStatistic(statistic); assertThat(message, subject, is(not(nullValue()))); - if (wrapper.getRegistry() == IRegistry.BLOCK || wrapper.getRegistry() == IRegistry.ITEM) { + if (wrapper.getRegistry() == BuiltInRegistries.BLOCK || wrapper.getRegistry() == BuiltInRegistries.ITEM) { assertNotNull("Material type map missing for " + wrapper.getRegistry().getKey(child), CraftStatistic.getMaterialFromStatistic(statistic)); - } else if (wrapper.getRegistry() == IRegistry.ENTITY_TYPE) { + } else if (wrapper.getRegistry() == BuiltInRegistries.ENTITY_TYPE) { assertNotNull("Entity type map missing for " + EntityTypes.getKey((EntityTypes) child), CraftStatistic.getEntityTypeFromStatistic((net.minecraft.stats.Statistic>) statistic)); } diff --git a/src/test/java/org/bukkit/block/banner/PatternTypeTest.java b/src/test/java/org/bukkit/block/banner/PatternTypeTest.java index e6b76ec8d..7f85dd628 100644 --- a/src/test/java/org/bukkit/block/banner/PatternTypeTest.java +++ b/src/test/java/org/bukkit/block/banner/PatternTypeTest.java @@ -1,7 +1,7 @@ package org.bukkit.block.banner; import junit.framework.Assert; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.level.block.entity.EnumBannerPatternType; import org.bukkit.support.AbstractTestingBase; import org.junit.Test; @@ -10,7 +10,7 @@ public class PatternTypeTest extends AbstractTestingBase { @Test public void testToBukkit() { - for (EnumBannerPatternType nms : IRegistry.BANNER_PATTERN) { + for (EnumBannerPatternType nms : BuiltInRegistries.BANNER_PATTERN) { PatternType bukkit = PatternType.getByIdentifier(nms.getHashname()); Assert.assertNotNull("No Bukkit banner for " + nms + " " + nms.getHashname(), bukkit); @@ -21,7 +21,7 @@ public class PatternTypeTest extends AbstractTestingBase { public void testToNMS() { for (PatternType bukkit : PatternType.values()) { EnumBannerPatternType found = null; - for (EnumBannerPatternType nms : IRegistry.BANNER_PATTERN) { + for (EnumBannerPatternType nms : BuiltInRegistries.BANNER_PATTERN) { if (bukkit.getIdentifier().equals(nms.getHashname())) { found = nms; break; diff --git a/src/test/java/org/bukkit/craftbukkit/attribute/AttributeTest.java b/src/test/java/org/bukkit/craftbukkit/attribute/AttributeTest.java index 09b61c247..458e4e700 100644 --- a/src/test/java/org/bukkit/craftbukkit/attribute/AttributeTest.java +++ b/src/test/java/org/bukkit/craftbukkit/attribute/AttributeTest.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.attribute; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.MinecraftKey; import net.minecraft.world.entity.ai.attributes.AttributeBase; import org.bukkit.attribute.Attribute; @@ -12,7 +12,7 @@ public class AttributeTest extends AbstractTestingBase { @Test public void testToBukkit() { - for (MinecraftKey nms : IRegistry.ATTRIBUTE.keySet()) { + for (MinecraftKey nms : BuiltInRegistries.ATTRIBUTE.keySet()) { Attribute bukkit = CraftAttributeMap.fromMinecraft(nms.toString()); Assert.assertNotNull(nms.toString(), bukkit); diff --git a/src/test/java/org/bukkit/craftbukkit/block/BlockStateTest.java b/src/test/java/org/bukkit/craftbukkit/block/BlockStateTest.java index 60e75d60d..79dc00ec9 100644 --- a/src/test/java/org/bukkit/craftbukkit/block/BlockStateTest.java +++ b/src/test/java/org/bukkit/craftbukkit/block/BlockStateTest.java @@ -5,7 +5,7 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import net.minecraft.core.BlockPosition; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.ITileEntity; import net.minecraft.world.level.block.entity.TileEntity; @@ -18,7 +18,7 @@ public class BlockStateTest extends AbstractTestingBase { @Test public void testTileEntityBlockStates() { - for (Block block : IRegistry.BLOCK) { + for (Block block : BuiltInRegistries.BLOCK) { Material material = CraftMagicNumbers.getMaterial(block); Class blockStateType = CraftBlockStates.getBlockStateType(material); boolean isCraftBlockEntityState = CraftBlockEntityState.class.isAssignableFrom(blockStateType); diff --git a/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java b/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java index 6cd61efea..8faa97063 100644 --- a/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java +++ b/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java @@ -1,9 +1,6 @@ package org.bukkit.craftbukkit.generator; import static org.junit.Assert.*; -import net.minecraft.core.IRegistry; -import net.minecraft.data.RegistryGeneration; -import net.minecraft.world.level.biome.BiomeBase; import org.bukkit.Material; import org.bukkit.block.data.BlockData; import org.bukkit.support.AbstractTestingBase; @@ -13,7 +10,6 @@ public class ChunkDataTest extends AbstractTestingBase { private static final BlockData RED_WOOL = Material.RED_WOOL.createBlockData(); private static final BlockData AIR = Material.AIR.createBlockData(); - private static final IRegistry BIOMES = RegistryGeneration.BIOME; private boolean testSetBlock(OldCraftChunkData data, int x, int y, int z, BlockData type, BlockData expected) { data.setBlock(x, y, z, type); diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java index c0253c44d..42d19b7d2 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java @@ -6,7 +6,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.UUID; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemBlock; @@ -151,7 +151,7 @@ public class ItemMetaTest extends AbstractTestingBase { public void testBlockStateMeta() { List queue = new ArrayList<>(); - for (Item item : IRegistry.ITEM) { + for (Item item : BuiltInRegistries.ITEM) { if (item instanceof ItemBlock) { queue.add(((ItemBlock) item).getBlock()); } diff --git a/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java b/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java index f1d3c8aad..0599eae35 100644 --- a/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java +++ b/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java @@ -92,6 +92,13 @@ public class LegacyTest extends AbstractTestingBase { Material.MANGROVE_WOOD, Material.MUD, Material.MUDDY_MANGROVE_ROOTS, Material.MUD_BRICKS, Material.MUD_BRICK_SLAB, Material.MUD_BRICK_STAIRS, Material.MUD_BRICK_WALL, Material.MUSIC_DISC_5, Material.OAK_CHEST_BOAT, Material.OCHRE_FROGLIGHT, Material.PACKED_MUD, Material.PEARLESCENT_FROGLIGHT, Material.POTTED_MANGROVE_PROPAGULE, Material.RECOVERY_COMPASS, Material.REINFORCED_DEEPSLATE, Material.SCULK, Material.SCULK_CATALYST, Material.SCULK_SHRIEKER, Material.SCULK_VEIN, Material.SPRUCE_CHEST_BOAT, Material.STRIPPED_MANGROVE_LOG, Material.STRIPPED_MANGROVE_WOOD, Material.TADPOLE_BUCKET, Material.TADPOLE_SPAWN_EGG, Material.VERDANT_FROGLIGHT, Material.WARDEN_SPAWN_EGG, + // 1.19.3 + Material.ACACIA_HANGING_SIGN, Material.ACACIA_WALL_HANGING_SIGN, Material.BAMBOO_BLOCK, Material.BAMBOO_BUTTON, Material.BAMBOO_CHEST_RAFT, Material.BAMBOO_DOOR, Material.BAMBOO_FENCE, Material.BAMBOO_FENCE_GATE, Material.BAMBOO_HANGING_SIGN, + Material.BAMBOO_MOSAIC, Material.BAMBOO_MOSAIC_SLAB, Material.BAMBOO_MOSAIC_STAIRS, Material.BAMBOO_PLANKS, Material.BAMBOO_PRESSURE_PLATE, Material.BAMBOO_RAFT, Material.BAMBOO_SIGN, Material.BAMBOO_SLAB, Material.BAMBOO_STAIRS, Material.BAMBOO_TRAPDOOR, + Material.BAMBOO_WALL_HANGING_SIGN, Material.BAMBOO_WALL_SIGN, Material.BIRCH_HANGING_SIGN, Material.BIRCH_WALL_HANGING_SIGN, Material.CAMEL_SPAWN_EGG, Material.CHISELED_BOOKSHELF, Material.CRIMSON_HANGING_SIGN, Material.CRIMSON_WALL_HANGING_SIGN, + Material.DARK_OAK_HANGING_SIGN, Material.DARK_OAK_WALL_HANGING_SIGN, Material.ENDER_DRAGON_SPAWN_EGG, Material.IRON_GOLEM_SPAWN_EGG, Material.JUNGLE_HANGING_SIGN, Material.JUNGLE_WALL_HANGING_SIGN, Material.MANGROVE_HANGING_SIGN, + Material.MANGROVE_WALL_HANGING_SIGN, Material.OAK_HANGING_SIGN, Material.OAK_WALL_HANGING_SIGN, Material.PIGLIN_HEAD, Material.PIGLIN_WALL_HEAD, Material.SNOW_GOLEM_SPAWN_EGG, Material.SPRUCE_HANGING_SIGN, Material.SPRUCE_WALL_HANGING_SIGN, + Material.STRIPPED_BAMBOO_BLOCK, Material.WARPED_HANGING_SIGN, Material.WARPED_WALL_HANGING_SIGN, Material.WITHER_SPAWN_EGG, // Material.LEGACY_AIR, Material.LEGACY_DEAD_BUSH, Material.LEGACY_BURNING_FURNACE, Material.LEGACY_WALL_SIGN, Material.LEGACY_REDSTONE_TORCH_OFF, Material.LEGACY_SKULL, Material.LEGACY_REDSTONE_COMPARATOR_ON, Material.LEGACY_WALL_BANNER, Material.LEGACY_MONSTER_EGG)); diff --git a/src/test/java/org/bukkit/enchantments/EnchantmentTargetTest.java b/src/test/java/org/bukkit/enchantments/EnchantmentTargetTest.java index 2a0507866..9423fbebb 100644 --- a/src/test/java/org/bukkit/enchantments/EnchantmentTargetTest.java +++ b/src/test/java/org/bukkit/enchantments/EnchantmentTargetTest.java @@ -1,6 +1,6 @@ package org.bukkit.enchantments; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.item.Item; import net.minecraft.world.item.enchantment.EnchantmentSlotType; import org.bukkit.Material; @@ -28,7 +28,7 @@ public class EnchantmentTargetTest { Assert.assertNotNull("No bukkit target for slot " + nmsSlot, bukkitTarget); - for (Item item : IRegistry.ITEM) { + for (Item item : BuiltInRegistries.ITEM) { Material material = CraftMagicNumbers.getMaterial(item); boolean nms = nmsSlot.canEnchant(item); diff --git a/src/test/java/org/bukkit/entity/EntityTypesTest.java b/src/test/java/org/bukkit/entity/EntityTypesTest.java index 810f1c704..724e03c96 100644 --- a/src/test/java/org/bukkit/entity/EntityTypesTest.java +++ b/src/test/java/org/bukkit/entity/EntityTypesTest.java @@ -3,7 +3,7 @@ package org.bukkit.entity; import java.util.Arrays; import java.util.Set; import java.util.stream.Collectors; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.MinecraftKey; import net.minecraft.world.entity.EntityTypes; import org.bukkit.support.AbstractTestingBase; @@ -16,7 +16,7 @@ public class EntityTypesTest extends AbstractTestingBase { public void testMaps() { Set allBukkit = Arrays.stream(EntityType.values()).filter((b) -> b.getName() != null).collect(Collectors.toSet()); - for (EntityTypes nms : IRegistry.ENTITY_TYPE) { + for (EntityTypes nms : BuiltInRegistries.ENTITY_TYPE) { MinecraftKey key = EntityTypes.getKey(nms); EntityType bukkit = EntityType.fromName(key.getPath()); diff --git a/src/test/java/org/bukkit/entity/memory/CraftMemoryKeyTest.java b/src/test/java/org/bukkit/entity/memory/CraftMemoryKeyTest.java index 090d05b6e..4131128e6 100644 --- a/src/test/java/org/bukkit/entity/memory/CraftMemoryKeyTest.java +++ b/src/test/java/org/bukkit/entity/memory/CraftMemoryKeyTest.java @@ -1,7 +1,7 @@ package org.bukkit.entity.memory; import net.minecraft.core.GlobalPos; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.entity.ai.memory.MemoryModuleType; import org.bukkit.Location; import org.bukkit.craftbukkit.entity.memory.CraftMemoryKey; @@ -56,7 +56,7 @@ public class CraftMemoryKeyTest extends AbstractTestingBase { @Test public void shouldReturnNullWhenBukkitRepresentationOfKeyisNotAvailableAndSerializerIsNotPresent() { - for (MemoryModuleType memoryModuleType : IRegistry.MEMORY_MODULE_TYPE) { + for (MemoryModuleType memoryModuleType : BuiltInRegistries.MEMORY_MODULE_TYPE) { if (!memoryModuleType.getCodec().isPresent()) { MemoryKey bukkitNoKey = CraftMemoryKey.toMemoryKey(memoryModuleType); Assert.assertNull("MemoryModuleType should be null", bukkitNoKey); @@ -67,10 +67,10 @@ public class CraftMemoryKeyTest extends AbstractTestingBase { @Test @Ignore("Unit type not yet implemented") public void shouldReturnAnInstanceOfMemoryKeyWhenBukkitRepresentationOfKeyisAvailableAndSerializerIsPresent() { - for (MemoryModuleType memoryModuleType : IRegistry.MEMORY_MODULE_TYPE) { + for (MemoryModuleType memoryModuleType : BuiltInRegistries.MEMORY_MODULE_TYPE) { if (memoryModuleType.getCodec().isPresent()) { MemoryKey bukkitNoKey = CraftMemoryKey.toMemoryKey(memoryModuleType); - Assert.assertNotNull("MemoryModuleType should not be null " + IRegistry.MEMORY_MODULE_TYPE.getKey(memoryModuleType), bukkitNoKey); + Assert.assertNotNull("MemoryModuleType should not be null " + BuiltInRegistries.MEMORY_MODULE_TYPE.getKey(memoryModuleType), bukkitNoKey); } } } diff --git a/src/test/java/org/bukkit/generator/structure/StructureTest.java b/src/test/java/org/bukkit/generator/structure/StructureTest.java index 712e20d8a..6ae21e6c6 100644 --- a/src/test/java/org/bukkit/generator/structure/StructureTest.java +++ b/src/test/java/org/bukkit/generator/structure/StructureTest.java @@ -3,6 +3,7 @@ package org.bukkit.generator.structure; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.MinecraftKey; import org.bukkit.NamespacedKey; import org.bukkit.Registry; @@ -30,9 +31,9 @@ public class StructureTest extends AbstractTestingBase { @Test public void testMinecraftToBukkitFieldName() { - IRegistry structureIRegistry = AbstractTestingBase.REGISTRY_CUSTOM.registryOrThrow(IRegistry.STRUCTURE_REGISTRY); - for (net.minecraft.world.level.levelgen.structure.Structure structure : structureIRegistry) { - MinecraftKey minecraftKey = structureIRegistry.getKey(structure); + IRegistry structureBuiltInRegistries = AbstractTestingBase.REGISTRY_CUSTOM.registryOrThrow(Registries.STRUCTURE); + for (net.minecraft.world.level.levelgen.structure.Structure structure : structureBuiltInRegistries) { + MinecraftKey minecraftKey = structureBuiltInRegistries.getKey(structure); try { Structure bukkit = (Structure) Structure.class.getField(minecraftKey.getPath().toUpperCase()).get(null); diff --git a/src/test/java/org/bukkit/generator/structure/StructureTypeTest.java b/src/test/java/org/bukkit/generator/structure/StructureTypeTest.java index 0eb269795..c72020db9 100644 --- a/src/test/java/org/bukkit/generator/structure/StructureTypeTest.java +++ b/src/test/java/org/bukkit/generator/structure/StructureTypeTest.java @@ -2,7 +2,7 @@ package org.bukkit.generator.structure; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.MinecraftKey; import org.bukkit.NamespacedKey; import org.bukkit.Registry; @@ -30,8 +30,8 @@ public class StructureTypeTest extends AbstractTestingBase { @Test public void testMinecraftToBukkitFieldName() { - for (net.minecraft.world.level.levelgen.structure.StructureType structureType : IRegistry.STRUCTURE_TYPES) { - MinecraftKey minecraftKey = IRegistry.STRUCTURE_TYPES.getKey(structureType); + for (net.minecraft.world.level.levelgen.structure.StructureType structureType : BuiltInRegistries.STRUCTURE_TYPE) { + MinecraftKey minecraftKey = BuiltInRegistries.STRUCTURE_TYPE.getKey(structureType); try { StructureType bukkit = (StructureType) StructureType.class.getField(minecraftKey.getPath().toUpperCase()).get(null); diff --git a/src/test/java/org/bukkit/potion/PotionTest.java b/src/test/java/org/bukkit/potion/PotionTest.java index 9ad5d356d..aca572f75 100644 --- a/src/test/java/org/bukkit/potion/PotionTest.java +++ b/src/test/java/org/bukkit/potion/PotionTest.java @@ -4,7 +4,7 @@ import static org.junit.Assert.*; import java.util.EnumMap; import java.util.List; import java.util.Map; -import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.MinecraftKey; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectList; @@ -16,7 +16,7 @@ public class PotionTest extends AbstractTestingBase { @Test public void testEffectCompleteness() throws Throwable { Map effects = new EnumMap(PotionType.class); - for (Object reg : IRegistry.POTION) { + for (Object reg : BuiltInRegistries.POTION) { List eff = ((PotionRegistry) reg).getEffects(); if (eff.size() != 1) continue; int id = MobEffectList.getId(eff.get(0).getEffect()); @@ -34,8 +34,8 @@ public class PotionTest extends AbstractTestingBase { @Test public void testEffectType() { - for (MobEffectList nms : IRegistry.MOB_EFFECT) { - MinecraftKey key = IRegistry.MOB_EFFECT.getKey(nms); + for (MobEffectList nms : BuiltInRegistries.MOB_EFFECT) { + MinecraftKey key = BuiltInRegistries.MOB_EFFECT.getKey(nms); int id = MobEffectList.getId(nms); PotionEffectType bukkit = PotionEffectType.getById(id); diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java index fc8e9403d..2426a840b 100644 --- a/src/test/java/org/bukkit/support/AbstractTestingBase.java +++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java @@ -6,13 +6,20 @@ import java.util.Collections; import java.util.List; import net.minecraft.SharedConstants; import net.minecraft.commands.CommandDispatcher; +import net.minecraft.core.IRegistry; import net.minecraft.core.IRegistryCustom; +import net.minecraft.core.LayeredRegistryAccess; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.RegistryDataLoader; import net.minecraft.server.DataPackResources; import net.minecraft.server.DispenserRegistry; +import net.minecraft.server.RegistryLayer; +import net.minecraft.server.WorldLoader; 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.world.flag.FeatureFlags; +import net.minecraft.world.level.biome.BiomeBase; import org.bukkit.Material; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.junit.Assert; @@ -31,18 +38,23 @@ public abstract class AbstractTestingBase { public static final DataPackResources DATA_PACK; public static final IRegistryCustom.Dimension REGISTRY_CUSTOM; + public static final IRegistry BIOMES; static { SharedConstants.tryDetectVersion(); DispenserRegistry.bootStrap(); // Set up resource manager - ResourceManager resourceManager = new ResourceManager(EnumResourcePackType.SERVER_DATA, Collections.singletonList(new ResourcePackVanilla(ResourcePackSourceVanilla.BUILT_IN_METADATA, "minecraft"))); + ResourceManager resourceManager = new ResourceManager(EnumResourcePackType.SERVER_DATA, Collections.singletonList(new ResourcePackSourceVanilla().getVanillaPack())); // add tags and loot tables for unit tests - REGISTRY_CUSTOM = IRegistryCustom.builtinCopy().freeze(); + LayeredRegistryAccess layers = RegistryLayer.createRegistryAccess(); + layers = WorldLoader.loadAndReplaceLayer(resourceManager, layers, RegistryLayer.WORLDGEN, RegistryDataLoader.WORLDGEN_REGISTRIES); + REGISTRY_CUSTOM = layers.compositeAccess().freeze(); // Register vanilla pack - DATA_PACK = DataPackResources.loadResources(resourceManager, REGISTRY_CUSTOM, CommandDispatcher.ServerType.DEDICATED, 0, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join(); + DATA_PACK = DataPackResources.loadResources(resourceManager, REGISTRY_CUSTOM, FeatureFlags.REGISTRY.allFlags(), CommandDispatcher.ServerType.DEDICATED, 0, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join(); // Bind tags DATA_PACK.updateRegistryTags(REGISTRY_CUSTOM); + // Biome shortcut + BIOMES = REGISTRY_CUSTOM.registryOrThrow(Registries.BIOME); DummyServer.setup(); DummyEnchantments.setup(); @@ -54,6 +66,6 @@ public abstract class AbstractTestingBase { } } INVALIDATED_MATERIALS = builder.build(); - Assert.assertEquals("Expected 592 invalidated materials (got " + INVALIDATED_MATERIALS.size() + ")", 592, INVALIDATED_MATERIALS.size()); + Assert.assertEquals("Expected 604 invalidated materials (got " + INVALIDATED_MATERIALS.size() + ")", 604, INVALIDATED_MATERIALS.size()); } }